/* Visual system for the migration dashboard. Two lanes, one accent color
   each: blue for cdc, grey for backfill. Status colors are reused for the
   breaker pill, the SLA gauge and transient chip flags so the same red
   always means the same thing across the page. */

:root {
  --bg: #f2f4f8;
  --panel-bg: #ffffff;
  --text: #1b2130;
  --muted: #667085;
  --border: #e3e7ee;
  --cdc: #2563eb;
  --cdc-soft: #dbe6fd;
  --backfill: #6b7280;
  --backfill-soft: #e5e7eb;
  --calm: #15803d;
  --calm-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a;
    --panel-bg: #171b26;
    --text: #e6e9f0;
    --muted: #9aa3b2;
    --border: #2a3040;
    --cdc-soft: #1c2c4d;
    --backfill-soft: #2a2f3a;
    --calm-soft: #0f3321;
    --amber-soft: #3a2a0d;
    --red-soft: #3a1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  min-width: 0;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}

.topbar-status {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  white-space: nowrap;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.pill-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}

.pill-value {
  font-weight: 600;
}

.pill.state-calm .pill-dot { background: var(--calm); }
.pill.state-amber .pill-dot { background: var(--amber); }
.pill.state-red .pill-dot { background: var(--red); }
.pill.state-calm { background: var(--calm-soft); }
.pill.state-red { background: var(--red-soft); }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px 20px 32px;
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

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

.panel-header h2 {
  font-size: 14px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.panel-title-secondary {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--muted);
}

.panel-explain {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  max-width: 70ch;
}

.pacing-note {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.legend {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-item.muted {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-cdc { background: var(--cdc); }
.swatch-backfill { background: var(--backfill); }

.columns-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
}

.columns {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.column {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  flex: 1 1 180px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
}

.column-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 4px;
}

.column-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.column-title-secondary {
  display: block;
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.8;
}

.column-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  flex-shrink: 0;
}

.column-hint {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}

.column-explain {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 8px;
  line-height: 1.35;
}

.failed-row {
  margin-top: 8px;
  background: var(--red-soft);
  border: 1px dashed var(--red);
  border-radius: 8px;
  padding: 8px;
}

.failed-row .column-title {
  color: var(--red);
}

.failed-row .column-count {
  color: var(--red);
}

.column-tray.failed-tray {
  min-height: 28px;
  max-height: 64px;
}

.column-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
  min-height: 96px;
  max-height: 160px;
  overflow: hidden;
}

.chip {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--cdc);
  flex-shrink: 0;
  transition: background-color 0.25s ease, transform 0.2s ease;
  position: relative;
}

.chip.lane-backfill {
  background: var(--backfill);
}

.chip.flag-retry {
  box-shadow: 0 0 0 2px var(--amber);
}

.chip.flag-dlq {
  box-shadow: 0 0 0 2px var(--red);
}

.chip.chip-enter {
  animation: chip-pop 0.25s ease;
}

@keyframes chip-pop {
  from { transform: scale(0.4); opacity: 0.2; }
  to { transform: scale(1); opacity: 1; }
}

.chip-overflow {
  font-size: 11px;
  color: var(--muted);
  align-self: center;
  padding: 0 4px;
}

.throughput-row {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.throughput-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.throughput-label {
  color: var(--muted);
}

.throughput-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sla-lag-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gauge-track {
  position: relative;
  height: 14px;
  background: var(--calm-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.gauge-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--calm);
  transition: width 0.4s ease, background-color 0.4s ease;
}

.gauge-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 20px;
  background: var(--amber);
  left: 50%;
}

.gauge-marker-breach {
  background: var(--red);
  left: 100%;
}

.gauge-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

.intro-body {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 24px;
  align-items: start;
}

.intro-statement {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  max-width: 60ch;
}

.intro-try-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.intro-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--muted);
  max-width: 90ch;
}

.intro-steps li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.intro-steps li:last-child {
  margin-bottom: 0;
}

.intro-steps strong {
  color: var(--text);
}

@media (max-width: 640px) {
  .intro-body {
    grid-template-columns: 1fr;
  }
}

.controls-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-file-group {
  flex-wrap: wrap;
  gap: 10px;
}

.control-group-label {
  color: var(--muted);
  font-size: 12px;
}

.add-file-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.control-group label {
  color: var(--muted);
  font-size: 12px;
}

.control-hint {
  font-size: 12px;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.97);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: var(--cdc);
  border-color: var(--cdc);
  color: #fff;
}

.restart-group {
  margin-left: auto;
}

.btn-danger {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.btn-danger:hover {
  filter: brightness(0.95);
}

.btn-danger.confirming {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

select {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.recent-empty {
  color: var(--muted);
  font-size: 12px;
}

.recent-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recent-card.card-enter {
  animation: card-pop 0.3s ease;
}

@keyframes card-pop {
  from { transform: translateY(-6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.recent-filename {
  font-weight: 700;
  font-size: 13px;
  word-break: break-word;
}

.recent-field {
  font-size: 11px;
  color: var(--muted);
}

.recent-field .recent-field-label {
  color: var(--muted);
}

.recent-field .recent-field-value {
  color: var(--text);
  font-weight: 600;
}

.recent-object-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  word-break: break-all;
}

.recent-ocr-text {
  font-size: 11px;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  max-height: 64px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.recent-duration {
  font-size: 11px;
  color: var(--calm);
  font-weight: 600;
}
