* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f6f8;
  color: #1a1a1a;
  line-height: 1.5;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: block;
  margin-bottom: 24px;
}

.app-header h1 {
  margin: 0 0 12px;
  font-size: 1.5rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.header-top h1 {
  margin: 0;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  color: #555;
  font-size: 0.9rem;
}

.logout-form {
  margin: 0;
}

button.ghost {
  background: transparent;
  color: #555;
  border: 1px solid #ccd3db;
  padding: 6px 12px;
  font-size: 0.85rem;
}

button.ghost:hover {
  background: #eef2f7;
  color: #1a1a1a;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #e8eef7 0%, #f4f6f8 45%, #eef1f5 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.login-form input[type="text"],
.login-form input[type="password"],
.users-form input[type="text"],
.users-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.login-form button {
  width: 100%;
  margin-top: 4px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #555;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 420px;
  background: #e8eef7;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
}

.mode-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none;
  color: #555;
  min-width: 0;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.mode-tab:hover {
  color: #1a1a1a;
  background: rgba(255, 255, 255, 0.55);
}

.mode-tab.active {
  background: #fff;
  color: #005ff9;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.mode-desc {
  font-size: 0.75rem;
  color: #888;
  margin-top: 2px;
}

.mode-tab.active .mode-desc {
  color: #5b7fc7;
}

.subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #dde3ea;
  padding-bottom: 0;
}

.subnav a {
  padding: 10px 16px;
  color: #555;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav a:hover {
  color: #005ff9;
}

.subnav a.active {
  color: #005ff9;
  border-bottom-color: #005ff9;
  font-weight: 600;
}

header:not(.app-header) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

header:not(.app-header) h1 {
  margin: 0;
  font-size: 1.5rem;
}

nav a {
  margin-left: 16px;
  color: #555;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  color: #005ff9;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card .label {
  display: block;
  font-size: 0.85rem;
  color: #666;
}

.card .value {
  font-size: 1.75rem;
  font-weight: 700;
}

.filter-cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 20px;
}

.filter-cards .filter-card {
  flex: 1 1 0;
  min-width: 0;
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 8px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  color: inherit;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-cards .filter-card .label {
  display: inline;
  font-size: 0.72rem;
  color: #666;
}

.filter-cards .filter-card .value {
  display: inline;
  font-size: 0.95rem;
  font-weight: 700;
  margin-left: 4px;
}

.filter-cards .filter-card:hover {
  border-color: #c5d7f7;
  box-shadow: 0 2px 8px rgba(0, 95, 249, 0.12);
}

.filter-cards .filter-card.active {
  border-color: #005ff9;
  box-shadow: 0 2px 8px rgba(0, 95, 249, 0.18);
}

.filter-cards .filter-card.active .value {
  color: #005ff9;
}

.filter-cards .filter-card.active .label {
  color: #334;
}

.panel {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel h2 {
  margin-top: 0;
}

.hint {
  color: #666;
  font-size: 0.9rem;
}

.upload-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0;
}

.secondary-upload {
  padding-top: 16px;
  border-top: 1px solid #e8eef7;
}

.field-label {
  display: block;
  width: 100%;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.inline-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 16px 0;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: #444;
}

.inline-form input[type="number"] {
  width: 140px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
}

button {
  background: #005ff9;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.95rem;
}

button:hover {
  background: #004ecc;
}

button.danger {
  background: #d93025;
}

button.danger:hover {
  background: #b3261e;
}

button.warning {
  background: #e37400;
}

button.warning:hover {
  background: #c46300;
}

button.success {
  background: #1e8e3e;
}

button.success:hover {
  background: #188038;
}

.queue-paused-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #fff4e5;
  border: 1px solid #f9c47a;
  border-radius: 8px;
  color: #8a4b08;
  font-size: 0.9rem;
}

textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}

.title-cell {
  max-width: 280px;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions form {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8eef7;
  font-size: 0.8rem;
}

.status-error .badge {
  background: #fde8e6;
  color: #b3261e;
}

.status-done .badge {
  background: #e6f4ea;
  color: #137333;
}

.status-preview .badge {
  background: #fff4e5;
  color: #b06000;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #444;
  cursor: pointer;
}

.test-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 16px 0;
}

.test-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 260px;
  font-size: 0.9rem;
  color: #444;
}

.test-form input[type="text"],
.test-form input[type="url"] {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 320px;
}

.preview-panel h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #555;
}

.preview-block {
  margin-bottom: 16px;
}

.preview-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.preview-text {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.6;
}

.test-loading.is-hidden {
  display: none;
}

.test-status-panel h2 {
  margin: 0;
}

.test-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.test-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.test-badge-success {
  background: #e6f4ea;
  color: #137333;
}

.test-badge-partial {
  background: #fff4e5;
  color: #b06000;
}

.test-badge-error {
  background: #fde8e6;
  color: #b3261e;
}

.test-badge-running {
  background: #e8eef7;
  color: #005ff9;
}

.test-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.test-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.test-step:last-child {
  border-bottom: none;
}

.test-step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.test-step-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.test-step-label {
  font-weight: 500;
}

.test-step-detail {
  font-size: 0.85rem;
  color: #666;
  word-break: break-word;
}

.test-step-ok .test-step-icon {
  background: #e6f4ea;
  color: #137333;
}

.test-step-error .test-step-icon {
  background: #fde8e6;
  color: #b3261e;
}

.test-step-error .test-step-label {
  color: #b3261e;
}

.test-step-running .test-step-icon {
  background: #e8eef7;
  color: #005ff9;
}

.test-step-wait .test-step-icon,
.test-step-skip .test-step-icon {
  background: #f0f0f0;
  color: #999;
}

.test-step-skip .test-step-label {
  color: #999;
}

.test-hint {
  margin-top: 16px;
  margin-bottom: 0;
}

.test-hint ol {
  margin: 8px 0 0;
  padding-left: 20px;
}

.test-hint li {
  margin: 4px 0;
}

.alert.info {
  background: #e8f0fe;
  color: #174ea6;
}

.error-row td {
  color: #b3261e;
  font-size: 0.85rem;
  background: #fff5f5;
}

.preview-row details {
  font-size: 0.85rem;
}

.preview-row p {
  white-space: pre-wrap;
  margin: 8px 0 0;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.alert.success {
  background: #e6f4ea;
  color: #137333;
}

.alert.error {
  background: #fde8e6;
  color: #b3261e;
}

.empty {
  text-align: center;
  color: #888;
  padding: 24px !important;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 0.9rem;
  color: #666;
}

.sort-btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #d0d7de;
  color: #1a1a1a;
  text-decoration: none;
  font-size: 0.9rem;
}

.sort-btn:hover {
  background: #f6f8fa;
}

.sort-btn.active {
  border-color: #005ff9;
  color: #005ff9;
  background: #e8f0fe;
}

.queue-root.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
}

.panel-action {
  margin: 0;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.pagination:last-child {
  margin: 16px 0 0;
}

.pagination-summary {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
}

.pagination-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-link {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #d0d7de;
  color: #005ff9;
  text-decoration: none;
  font-size: 0.9rem;
}

.pagination-link:hover:not(.disabled) {
  background: #f6f8fa;
}

.pagination-link.disabled {
  color: #aaa;
  background: #f4f6f8;
  cursor: default;
}

code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
