:root {
  --canvas: #08090a;
  --surface: #0f1011;
  --surface-raised: #191a1b;
  --surface-hover: #222329;
  --text-primary: #f7f8f8;
  --text-secondary: #d0d6e0;
  --text-muted: #8a8f98;
  --border-subtle: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --accent: #5e6ad2;
  --accent-hover: #828fff;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius-card: 8px;
  --radius-panel: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--canvas);
  color: var(--text-secondary);
  font-family: "Inter Variable", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { color: var(--text-primary); }
a { color: var(--accent-hover); text-decoration: none; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }
.mono { font-family: "Berkeley Mono", "SF Mono", "JetBrains Mono", monospace; font-size: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .row, input, textarea { transition: background 140ms ease-out, border-color 140ms ease-out, opacity 140ms ease-out, transform 140ms ease-out; }
}

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 590; color: var(--text-primary); }
.brand-name { font-size: 15px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(94,106,210,0.18); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.health { font-size: 12px; }
.health.ok { color: var(--success); }
.health.bad { color: var(--error); }
.user-chip { font-size: 12px; padding: 3px 10px; border: 1px solid var(--border-subtle); border-radius: 999px; }

/* ---- layout ---- */
.workspace {
  max-width: 1440px; margin: 0 auto; padding: 24px;
  display: grid; gap: 16px;
  grid-template-columns: 340px minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: start;
}
@media (max-width: 1100px) { .workspace { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: 20px;
}
.section-title { font-size: 20px; font-weight: 590; margin: 0 0 14px; }

/* ---- intake ---- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 8px 10px; font-size: 14px; font-weight: 510;
  color: var(--text-muted); background: transparent;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-card);
  cursor: pointer;
}
.tab:hover { background: var(--surface-hover); color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-color: var(--accent); background: rgba(94,106,210,0.12); }

.intake-form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 510; color: var(--text-muted); }
input, textarea, #search {
  font: inherit; font-size: 14px; color: var(--text-primary);
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); padding: 9px 11px; width: 100%;
}
input:focus, textarea:focus, #search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(94,106,210,0.25); }
textarea { resize: vertical; }
.hint { font-size: 12px; margin: 2px 0 0; }

.btn {
  font: inherit; font-size: 14px; font-weight: 510; cursor: pointer;
  border-radius: var(--radius-card); padding: 9px 14px;
  border: 1px solid var(--border-subtle); background: var(--surface); color: var(--text-primary);
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: 0.55; cursor: default; }

.alert { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-card); font-size: 13px; border: 1px solid var(--border-subtle); }
.alert.error { color: #fecaca; background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); }
.alert.success { color: #a7f3d0; background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.4); }

/* ---- list ---- */
.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-head .section-title { margin: 0; white-space: nowrap; }
#search { max-width: 260px; margin-left: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  font-size: 12px; font-weight: 510; padding: 4px 10px; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--border-subtle);
  background: var(--surface); color: var(--text-muted);
}
.chip:hover { background: var(--surface-hover); }
.chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.rows { display: flex; flex-direction: column; gap: 8px; max-height: 66vh; overflow-y: auto; }
.row {
  text-align: left; width: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); padding: 12px;
}
.row:hover { background: var(--surface-hover); }
.row.selected { border-color: var(--accent); background: rgba(94,106,210,0.10); }
.row-title { color: var(--text-primary); font-weight: 510; font-size: 14px; margin-bottom: 4px; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border-subtle); }
.badge.cat { color: var(--accent-hover); border-color: rgba(94,106,210,0.4); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-processed { background: var(--success); }
.status-partial { background: var(--warning); }
.status-failed { background: var(--error); }
.empty { padding: 20px 4px; }

/* ---- detail ---- */
.detail-body h3 { color: var(--text-primary); font-size: 14px; font-weight: 590; margin: 18px 0 8px; }
.detail-title { font-size: 22px; font-weight: 590; color: var(--text-primary); margin: 0 0 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.detail-body ul { margin: 0; padding-left: 18px; }
.detail-body li { margin-bottom: 6px; }
.summary-md { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: 12px; font-size: 14px; }
.paths { list-style: none; padding: 0; margin: 0; }
.paths li { word-break: break-all; margin-bottom: 4px; }
.extract-preview { white-space: pre-wrap; max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: 12px; font-size: 13px; color: var(--text-secondary); }

/* ---- login ---- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-panel); padding: 32px; }
.login-brand { display: flex; align-items: center; gap: 10px; color: var(--text-primary); font-weight: 590; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.login-card .btn { margin-top: 4px; }
