:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --surface-2: #efeae2;
  --ink: #1d1f1b;
  --ink-2: #5b5f57;
  --ink-3: #8a8d84;
  --line: #e2dcd2;
  --accent: #2f5d50;
  --accent-ink: #f6f3ee;
  --accent-soft: #dfe9e4;
  --warn: #9a5b13;
  --warn-soft: #f6e8d3;
  --bad: #9b2c2c;
  --bad-soft: #f5dcdc;
  --good: #2f6b3a;
  --good-soft: #dcecdc;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(40, 32, 20, .05), 0 6px 20px -12px rgba(40, 32, 20, .18);
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151613; --surface: #1c1e1a; --surface-2: #24271f; --ink: #ecebe5; --ink-2: #b4b5ab; --ink-3: #85877d;
    --line: #2f322a; --accent: #8cc2ad; --accent-ink: #12201b; --accent-soft: #23352e; --warn: #e2b071; --warn-soft: #3a2d1b;
    --bad: #ec9a9a; --bad-soft: #3d2222; --good: #9ccf9f; --good-soft: #213425;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151613; --surface: #1c1e1a; --surface-2: #24271f; --ink: #ecebe5; --ink-2: #b4b5ab; --ink-3: #85877d;
  --line: #2f322a; --accent: #8cc2ad; --accent-ink: #12201b; --accent-soft: #23352e; --warn: #e2b071; --warn-soft: #3a2d1b;
  --bad: #ec9a9a; --bad-soft: #3d2222; --good: #9ccf9f; --good-soft: #213425;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-family: var(--display); font-size: clamp(1.7rem, 3.4vw, 2.3rem); line-height: 1.15; font-weight: 500; }
h2 { font-family: var(--display); font-size: 1.25rem; font-weight: 500; }
h3 { font-size: 1rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 28px 18px; display: flex; flex-direction: column; gap: 28px; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 0 8px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.nav .count { margin-left: auto; font-size: 12px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; min-width: 20px; text-align: center; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink-3); cursor: pointer; text-align: left; font-size: 13px; }
.linkish:hover { color: var(--ink); }
.main { padding: 40px clamp(16px, 4vw, 56px) 96px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 60ch; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding-top: 24px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-3); text-decoration: none; padding: 4px 0; position: relative; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .tabbar .dot { position: absolute; top: 2px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
}
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 13px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; border: 1px solid transparent; padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--accent); color: var(--accent-ink); transition: transform .05s ease, opacity .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { opacity: .92; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: transparent; color: var(--ink-2); padding: 6px 10px; }
.btn.quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn.sm { padding: 6px 12px; font-size: 13px; }

.field { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.field:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea.field { min-height: 110px; resize: vertical; }
select.field { width: auto; padding: 6px 10px; }
label.lbl { display: block; font-weight: 500; margin-bottom: 6px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 36px 20px; color: var(--ink-2); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- home ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; display: block; }
.stat:hover { border-color: var(--ink-3); }
.stat b { display: block; font-family: var(--display); font-size: 1.9rem; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: 13px; }
.attn { border-left: 3px solid var(--warn); }
.attn.question { border-left-color: var(--accent); }
.attn-text { white-space: pre-wrap; color: var(--ink-2); margin: 6px 0 10px; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 18px; }
.step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.step-n { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; color: var(--ink-2); }
.step.done .step-n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- matches ---------- */
.job { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; }
.job-title { font-weight: 600; font-size: 1.02rem; text-decoration: none; }
.job-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.score { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 1.15rem; background: var(--surface-2); }
.score.hi { background: var(--good-soft); color: var(--good); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.bullets { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--ink-2); }
.bullets li::before { content: attr(data-mark) " "; font-weight: 600; }
.bullets li.plus::before { color: var(--good); }
.bullets li.minus::before { color: var(--bad); }
.job-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-height: 160px; }
.col-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 2px 4px 10px; }
.app-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.app-card + .app-card { margin-top: 10px; }
.app-co { font-weight: 600; }
.doc-links { display: flex; gap: 10px; font-size: 13px; }
.doc-links a { color: var(--accent); }

/* ---------- assistant ---------- */
.task { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; padding-top: 0; }
.task-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--ink-3); }
.task-dot.running, .task-dot.ready { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
.task-dot.done { background: var(--good); }
.task-dot.blocked { background: var(--accent); }
.task-dot.failed { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .task-dot { animation: none !important; } }
.task-summary { white-space: pre-wrap; color: var(--ink-2); font-size: 14px; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- documents ---------- */
.drop { display: block; border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.file-row:first-child { border-top: 0; }
.file-row a { text-decoration: none; font-weight: 500; overflow-wrap: anywhere; }
.file-row a:hover { text-decoration: underline; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(400px, 100%); padding: 32px; }
.login h1 { margin: 18px 0 6px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); color: #fff; }
@media (max-width: 860px) { .toast { bottom: 84px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.app-line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
