/* ─────────────────────────────────────────────────────────────────
   Pre-OCR control panel — dark theme (canonical)
   Tokens + components per DESIGN.md. Light theme is a follow-up.
   ───────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces (warm-neutral dark, hue 60-80, chroma 0.008-0.012) */
  --bg:           oklch(18% 0.008 60);
  --bg-elevated:  oklch(22% 0.008 60);
  --panel:        oklch(25% 0.010 60);
  --panel-strong: oklch(28% 0.012 60);

  /* Text */
  --text:         oklch(96% 0.012 80);
  --text-2:       oklch(80% 0.010 70);
  --text-muted:   oklch(58% 0.010 65);

  /* Lines */
  --rule:         oklch(32% 0.010 60);
  --rule-strong:  oklch(40% 0.012 60);

  /* Actionable colors (amber accent for dark) */
  --accent:       oklch(78% 0.16 75);
  --accent-bg:    oklch(32% 0.05 75);
  --accent-faint: oklch(26% 0.03 75);

  --warn:         oklch(78% 0.14 45);
  --warn-bg:      oklch(32% 0.06 50);
  --success:      oklch(75% 0.16 145);
  --danger:       oklch(72% 0.18 25);
  --danger-bg:    oklch(30% 0.08 25);
  --ok:           oklch(78% 0.13 145);
  --ok-bg:        oklch(30% 0.06 145);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --font-arabic: "Noto Naskh Arabic", "Amiri", "Adobe Arabic", serif;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;

  /* Radius */
  --radius-sm: 3px;
  --radius:    5px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Shell metrics */
  --rail-w: clamp(220px, 20vw, 320px);
  --topbar-h: 52px;
  --content-pad-x: clamp(24px, 4vw, 56px);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms;
  --t: 250ms;
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: 0ms; --t: 0ms; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  font-feature-settings: "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────────────────────
   Shell — icon rail (left) + topbar (top) + main (rest)
   ───────────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

aside.rail {
  background: var(--bg-elevated);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3) var(--space-3);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  gap: var(--space-1);
}

/* Brand row at top of rail */
.rail .brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-4);
  text-decoration: none;
  color: inherit;
}
.rail .brand .mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}
.rail .brand .wordmark {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}
.rail .brand .wordmark small {
  display: block;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0;
  margin-top: 1px;
}

/* Section labels in rail */
.rail .section-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  padding: var(--space-4) var(--space-2) var(--space-1);
}
.rail .section-label:first-of-type { padding-top: var(--space-2); }

/* Nav items — text rail */
.rail a.nav-item,
.rail button.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 400;
  position: relative;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  text-decoration: none;
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  line-height: 1.3;
}
.rail a.nav-item:hover,
.rail button.nav-item:hover { background: var(--bg); color: var(--text); }
.rail a.nav-item.active {
  background: var(--panel);
  color: var(--accent);
  font-weight: 500;
}
.rail a.nav-item.active::before {
  content: "";
  position: absolute;
  left: -1px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.rail .nav-item svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
  flex-shrink: 0;
}
.rail .nav-item .label { flex: 1; }
.rail .nav-item .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.rail a.nav-item.active .kbd {
  background: var(--bg-elevated);
  border-color: var(--accent-bg);
  color: var(--accent);
}

.rail .spacer { flex: 1; min-height: var(--space-4); }

/* User identity card pinned to bottom */
.rail .user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--rule);
  margin-top: var(--space-2);
  text-decoration: none;
  color: inherit;
}
.rail .user-card .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.rail .user-card .who {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.rail .user-card .who .email {
  display: block;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail .user-card .who .role {
  color: var(--text-muted);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1px;
}
.rail .user-card .signout {
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.rail .user-card .signout:hover {
  color: var(--danger);
  border-color: var(--rule-strong);
  background: var(--bg);
}
.rail .user-card .signout svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.75;
}

main.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--rule);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-h);
  gap: var(--space-4);
}
.crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12.5px;
  color: var(--text-2);
  flex-wrap: wrap;
}
.crumbs strong { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--text-muted); }
.topbar .right {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.status-pill .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2s infinite var(--ease);
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   color-mix(in oklab, var(--accent) 50%, transparent); }
  70%  { box-shadow: 0 0 0 6px color-mix(in oklab, var(--accent)  0%, transparent); }
  100% { box-shadow: 0 0 0 0   color-mix(in oklab, var(--accent)  0%, transparent); }
}

/* Page content — fills the main column, no artificial cap. */
.content {
  padding: var(--space-5) var(--content-pad-x) var(--space-8);
  width: 100%;
  flex: 1;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.2;
}
.page-head .sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 4px;
}
.stats {
  display: flex;
  gap: var(--space-5);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stats strong {
  color: var(--text);
  font-weight: 500;
  margin-right: 6px;
}
.stats .warn { color: var(--warn); }
.stats .ok { color: var(--ok); }

/* ─────────────────────────────────────────────────────────────────
   Sections
   ───────────────────────────────────────────────────────────────── */

section.card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}
section.card + section.card { margin-top: var(--space-4); }
section.card > header {
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
section.card > header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
section.card > header .right { font-size: 12px; color: var(--text-muted); }

section.bare { margin-top: var(--space-6); }
section.bare h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--rule);
}
section.bare h2 .count {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: var(--space-2);
}

/* ─────────────────────────────────────────────────────────────────
   Filter chips
   ───────────────────────────────────────────────────────────────── */

.filters {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.chip {
  font-family: var(--font-sans);
  font-size: 11.5px;
  padding: 5px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--text-muted); }
.chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 500;
}

/* ─────────────────────────────────────────────────────────────────
   Tables
   ───────────────────────────────────────────────────────────────── */

.data-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data thead th {
  text-align: left;
  padding: 9px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr {
  transition: background var(--t-fast) var(--ease);
}
table.data tbody tr:hover td { background: var(--panel); }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; }
table.data .row-title {
  color: var(--text);
  font-weight: 500;
  transition: color var(--t-fast) var(--ease);
}
table.data a.row-title:hover { color: var(--accent); }
table.data .sub-line {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.5;
}
table.data tbody tr.empty td {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-6) var(--space-4);
}

.panel-foot {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--rule);
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Compact key-value table */
table.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.kv th, table.kv td {
  padding: 8px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.kv tr:last-child th, table.kv tr:last-child td { border-bottom: none; }
table.kv th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: 200px;
  background: var(--bg);
}
table.kv td.val { font-family: var(--font-mono); color: var(--text); font-variant-numeric: tabular-nums; }

/* Backwards-compat alias for old `table.admin-table` markup (deprecated; use `.data` or `.kv`). */
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 12.5px;
}
table.admin-table th, table.admin-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
table.admin-table thead th, table.admin-table > tr:first-child th {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
table.admin-table tbody tr:last-child td { border-bottom: none; }
table.admin-table tbody tr:hover td { background: var(--panel); }

/* ─────────────────────────────────────────────────────────────────
   Badges
   ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 500;
  white-space: nowrap;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.neutral   { background: var(--panel);    color: var(--text-2); }
.badge.cleaned   { background: var(--accent-bg); color: var(--accent); }
.badge.verifying { background: var(--panel-strong); color: var(--text-2); }
.badge.verified  { background: var(--ok-bg);   color: var(--ok); }
.badge.published { background: var(--ok-bg);   color: var(--ok); }
.badge.cleaning  { background: var(--accent-bg); color: var(--accent); }
.badge.processing,
.badge.processed { background: var(--panel-strong); color: var(--text-2); }
.badge.archived  { background: var(--danger-bg); color: var(--danger); }
.badge.stale     { background: var(--warn-bg); color: var(--warn); }
.badge.raw       { background: var(--panel-strong); color: var(--text-muted); }

/* ─────────────────────────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────────────────────────── */

button, .btn, input[type="submit"] {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  text-decoration: none;
  line-height: 1.4;
}
button:hover, .btn:hover {
  background: var(--panel);
  border-color: var(--text-muted);
}
button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  padding: 7px 14px;
  font-weight: 600;
}
button.primary:hover {
  background: color-mix(in oklab, var(--accent) 92%, white);
  border-color: color-mix(in oklab, var(--accent) 92%, white);
}
button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
button.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
button.ghost:hover {
  background: var(--panel);
  color: var(--text);
}
button:disabled, .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; }

/* ─────────────────────────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────────────────────────── */

form.admin-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 640px;
}
form.admin-form.wide { max-width: none; }
form.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
form.admin-form input,
form.admin-form select,
form.admin-form textarea {
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}
form.admin-form input[type="file"] { padding: 6px; }
form.admin-form input:focus,
form.admin-form select:focus,
form.admin-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
form.admin-form input::placeholder { color: var(--text-muted); }
form.admin-form textarea { resize: vertical; min-height: 80px; }

/* Inline horizontal form (filter bar) */
form.inline {
  display: flex;
  gap: var(--space-2);
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
form.inline label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
form.inline input,
form.inline select {
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 5px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  min-width: 140px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}

/* ─────────────────────────────────────────────────────────────────
   Flash messages
   ───────────────────────────────────────────────────────────────── */

.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--rule);
  margin-bottom: var(--space-4);
  font-size: 13px;
}
.flash.ok       { background: var(--ok-bg);     border-color: color-mix(in oklab, var(--ok) 30%, transparent);     color: var(--ok); }
.flash.error    { background: var(--danger-bg); border-color: color-mix(in oklab, var(--danger) 30%, transparent); color: var(--danger); }
.flash.warning  { background: var(--warn-bg);   border-color: color-mix(in oklab, var(--warn) 30%, transparent);   color: var(--warn); }
.flash pre {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  color: var(--text);
  margin: var(--space-2) 0 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─────────────────────────────────────────────────────────────────
   Inline elements
   ───────────────────────────────────────────────────────────────── */

.muted     { color: var(--text-muted); }
.mono      { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.divider   { height: 1px; background: var(--rule); margin: var(--space-5) 0; border: 0; }
.tag       { font-size: 11.5px; color: var(--text-muted); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--text-muted);
}
code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}

/* Action button row (item-detail action forms) */
.action-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.action-row form {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
  margin: 0;
}
.action-row form select,
.action-row form input[type="text"] {
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 5px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

/* RTL accommodation */
[dir="rtl"], .rtl {
  font-family: var(--font-arabic);
  font-size: 14.5px;
  line-height: 1.7;
}

/* Topbar horizontal padding follows content padding so the topbar's
   crumbs align with content edges on every viewport size. */
.topbar { padding-left: var(--content-pad-x); padding-right: var(--content-pad-x); }

/* Responsive — collapse to icon-only rail under 880px */
@media (max-width: 880px) {
  :root { --rail-w: 56px; --content-pad-x: 20px; }
  .rail .brand .wordmark,
  .rail .section-label,
  .rail .nav-item .label,
  .rail .nav-item .kbd,
  .rail .user-card .who { display: none; }
  .rail .brand { justify-content: center; padding: var(--space-2) 0 var(--space-4); }
  .rail { padding: var(--space-3) 0; align-items: center; }
  .rail a.nav-item,
  .rail button.nav-item { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .rail .user-card { justify-content: center; padding: var(--space-3) 0; }
  .rail .user-card .signout { display: none; }
  table.kv th { width: 130px; font-size: 10.5px; }
  .stats { display: none; }
}
@media (max-width: 520px) {
  :root { --content-pad-x: 14px; }
  .topbar { padding: var(--space-2) var(--content-pad-x); }
}

/* ─────────────────────────────────────────────────────────────────
   Smart input — typeahead chips
   ───────────────────────────────────────────────────────────────── */

smart-input {
  display: block;
  position: relative;
  width: 100%;
}
.si-host {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 5px 8px;
  min-height: 36px;
  transition: border-color var(--t-fast) var(--ease);
}
.si-host:focus-within { border-color: var(--accent); }
.si-chips { display: contents; }
.si-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 9px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 11.5px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.si-chip-x {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}
.si-input {
  flex: 1;
  min-width: 80px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 2px 4px;
}
.si-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  list-style: none;
  z-index: 20;
  max-height: 280px;
  overflow-y: auto;
}
.si-option {
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 12.5px;
}
.si-option.hl,
.si-option:hover { background: var(--panel); color: var(--text); }

/* ─── Ingest page (v2 redesign) ─────────────────────────────── */

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--rule-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--text-muted);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  margin-top: var(--space-5);
  margin-bottom: var(--space-5);
}
.drop-zone:hover { border-color: var(--text-muted); }
.drop-zone.is-over {
  border-color: var(--accent);
  background: var(--accent-faint);
  color: var(--text);
}
.drop-zone .icon { width: 48px; height: 48px; }
.drop-zone .drop-headline {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.drop-zone .drop-sub { font-size: 12.5px; }
.drop-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Status line above the queue body */
.queue-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: 13px;
  color: var(--text-2);
}
.queue-status .strip-clear {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}
.queue-status .strip-clear:hover { color: var(--danger); }

/* Shared header — 2-column grid on wide screens */
.shared-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 899px) {
  .shared-header { grid-template-columns: 1fr; }
}
.shared-header label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.shared-header label > smart-input,
.shared-header label > select,
.shared-header label > input {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}

/* Row table — 5 columns */
.row-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-5);
}
.row-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--rule);
}
.row-table tbody tr {
  position: relative;
}
.row-table tbody td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  min-height: 44px;
}
.row-table tbody tr:last-child td { border-bottom: none; }

/* Source cell with icon + filename/URL */
.row-table td.source-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 280px;
}
.row-table .row-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}
.row-table .source-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Row inputs / selects */
.row-table input[type="text"],
.row-table select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
}

/* Compact smart-input variant (inside row table) */
.row-table smart-input[data-compact="true"] .si-host {
  min-height: 32px;
  padding: 2px 4px;
  font-size: 12.5px;
}
.row-table smart-input[data-compact="true"] .si-chip {
  font-size: 11px;
  padding: 1px 6px;
}

/* Row remove + per-row progress / result */
.row-table .row-actions {
  text-align: right;
  white-space: nowrap;
}
.row-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: width var(--t-fast) var(--ease);
}
.row-result {
  font-size: 11.5px;
  margin-top: 4px;
}
.row-result.ok { color: var(--success); }
.row-result.err { color: var(--danger); }

/* Submit button group + cancel link */
.row-table + .btn-group,
[data-queue-actions] {
  margin-top: var(--space-5);
}

/* Results panel */
.results-panel {
  margin-top: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.results-panel h2 {
  margin: 0 0 var(--space-3);
  font-size: 15px;
  font-weight: 600;
}
.results-panel .results-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.results-panel .results-row.ok .icon { color: var(--success); }
.results-panel .results-row.err .icon { color: var(--danger); }
.results-panel .results-row .filename {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.results-panel .results-row .reason { color: var(--danger); font-size: 12px; }
.results-panel .results-actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-2);
}
.results-panel .url-deferred-banner {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border-left: 3px solid var(--warn);
  background: rgba(217, 119, 6, 0.08);
  font-size: 12.5px;
}
.results-panel .url-deferred-banner ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-4);
}

/* URL paste modal (native <dialog>) */
.url-modal {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 480px;
  width: 90%;
}
.url-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
.url-modal .modal-head {
  display: flex;
  align-items: center;
  margin: 0 0 var(--space-4);
}
.url-modal .modal-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}
.url-modal .modal-head .dismiss {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.url-modal .url-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.url-modal .url-row [data-modal-url-display] {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-mono);
}
.url-modal .error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}
.url-modal footer.btn-group {
  margin-top: var(--space-4);
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Hide the v1 drop-strip / ingest-tabs / file-row-table classes
   defensively in case any are referenced from leftover CSS users. */
.ingest-tabs, .ingest-tab, .ingest-tab-panel,
.drop-strip, .file-row-table,
.deferred-notice, .url-input-row { display: none !important; }

/* NOTE: belongs with the smart-input rules above (.si-option, .si-option.hl),
   but kept here because it is the sole instance — not a duplicate. */
.si-option.si-create { color: var(--accent); font-style: italic; }

/* ─── Error pages (401 / 403 / 404 / 5xx) ────────────────────── */
.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(ellipse at top, var(--accent-faint), transparent 60%),
    var(--bg);
}
.error-card {
  max-width: 440px;
  width: 100%;
  text-align: center;
  padding: var(--space-6);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}
.error-code {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}
.error-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 var(--space-3);
}
.error-message {
  color: var(--text-2);
  font-size: 13px;
  margin: 0 0 var(--space-5);
  line-height: 1.5;
}
.error-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
}
