/* Vision console — dark, calm, one gold accent (plan.md §12.1). */
:root {
  --bg: #0e0f11;
  --surface: #16171a;
  --surface-2: #1d1f23;
  --surface-3: #25272c;
  --border: #2b2d33;
  --text: #e9e7e2;
  --muted: #9b9ba1;
  --faint: #6c6c73;
  --accent: #e2b13c;
  --accent-ink: #1b1505;
  --accent-soft: rgba(226, 177, 60, 0.14);
  --ok: #3fb950;
  --warn: #d6a01e;
  --danger: #ef5b52;
  --info: #58a6ff;
  --a-vision: #e2b13c;
  --a-friday: #2dd4bf;
  --a-jarvis: #60a5fa;
  --a-dume: #9ca3af;
  --a-edith: #c084fc;
  --radius: 10px;
  --radius-sm: 6px;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s;
}
button:hover:not(:disabled) { border-color: #3a3d44; background: #2b2e34; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { background: #ecc054; border-color: #ecc054; }
button.danger { color: #ffb3ae; border-color: #5c2b28; background: #2a1716; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
button.small { padding: 4px 8px; font-size: 12px; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 1.2em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: rgba(14, 15, 17, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.22em; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.brand .stone { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.health { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.dot { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok::before { background: var(--ok); }
.dot.warn::before { background: var(--warn); }
.dot.bad::before { background: var(--danger); }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.role-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-transform: capitalize; }

.tabs {
  display: flex; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
  background: var(--bg);
}
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: 10px 12px; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover:not(.active) { background: none; color: var(--text); }

main { padding: 16px; max-width: 1600px; margin: 0 auto; }

/* ---------- panes / cards ---------- */
.pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.pane-body { padding: 12px 14px; }
.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.empty { color: var(--faint); font-size: 13px; padding: 18px 4px; text-align: center; }

/* ---------- console layout ---------- */
.console { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .console { grid-template-columns: 280px minmax(0, 1fr); } .side-pane { grid-column: 1 / -1; } }
@media (min-width: 1280px) { .console { grid-template-columns: 290px minmax(0, 1fr) 340px; } .side-pane { grid-column: auto; } }
@media (min-width: 900px) { .tasks-pane, .feed-pane, .side-pane { height: calc(100vh - 128px); display: flex; flex-direction: column; } }
.tasks-pane .pane-body, .feed-pane .pane-body, .side-pane .pane-body { overflow-y: auto; flex: 1; }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.examples button { font-size: 12px; padding: 4px 9px; border-radius: 999px; }
.task-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 899px) { .task-list { max-height: 38vh; overflow-y: auto; } }
.task-item { padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.task-item:hover { background: var(--surface-2); }
.task-item.active { background: var(--accent-soft); border-color: rgba(226, 177, 60, 0.35); }
.task-item .title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item .meta { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.chip.running, .chip.queued { background: rgba(88, 166, 255, 0.14); color: var(--info); }
.chip.waiting_approval, .chip.waiting_human, .chip.needs_review { background: rgba(214, 160, 30, 0.16); color: var(--warn); }
.chip.done { background: rgba(63, 185, 80, 0.14); color: var(--ok); }
.chip.failed, .chip.escalated, .chip.budget_exceeded, .chip.timeout { background: rgba(239, 91, 82, 0.14); color: var(--danger); }
.chip.cancelled { color: var(--faint); }

/* ---------- feed ---------- */
.feed { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.entry { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.entry > .body { min-width: 0; flex: 1; }
.atag { flex: none; font: 600 11px/1.9 var(--mono); padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--muted); }
.atag.vision { color: var(--a-vision); background: rgba(226, 177, 60, 0.12); }
.atag.friday { color: var(--a-friday); background: rgba(45, 212, 191, 0.12); }
.atag.jarvis { color: var(--a-jarvis); background: rgba(96, 165, 250, 0.12); }
.atag.dume { color: var(--a-dume); background: rgba(156, 163, 175, 0.12); }
.atag.edith { color: var(--a-edith); background: rgba(192, 132, 252, 0.12); }
.entry.dim { color: var(--muted); font-size: 12.5px; }
.entry.warn .body { color: var(--warn); }
.entry.bad .body { color: var(--danger); }
.msg { white-space: pre-wrap; word-break: break-word; }
.msg.md { white-space: normal; }
.stream-caret::after { content: '▍'; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
details.tool { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
details.tool > summary { cursor: pointer; padding: 5px 9px; list-style: none; display: flex; gap: 6px; align-items: center; overflow: hidden; }
details.tool > summary::-webkit-details-marker { display: none; }
details.tool > summary .args { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
details.tool .tool-body { border-top: 1px solid var(--border); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.status-ic { flex: none; width: 14px; text-align: center; }
.status-ic.ok { color: var(--ok); }
.status-ic.bad { color: var(--danger); }
.status-ic.wait { color: var(--faint); }
.eref { font: 600 11.5px var(--mono); color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(226, 177, 60, 0.3); border-radius: 4px; padding: 0 5px; cursor: pointer; }
.eref:hover { background: rgba(226, 177, 60, 0.25); }
.thinking-line { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brief { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.md h2 { font-size: 14px; margin: 14px 0 6px; color: var(--accent); }
.md h1, .md h3 { font-size: 14px; margin: 12px 0 6px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--border); color: var(--muted); }
.notice { border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; border: 1px solid; }
.notice.warn { background: rgba(214, 160, 30, 0.1); border-color: rgba(214, 160, 30, 0.35); color: #f0c95a; }
.notice.bad { background: rgba(239, 91, 82, 0.1); border-color: rgba(239, 91, 82, 0.35); color: #ff9d97; }
.notice.ok { background: rgba(63, 185, 80, 0.1); border-color: rgba(63, 185, 80, 0.3); color: #7ee28f; }
.plan { margin: 0 0 10px; padding-left: 20px; color: var(--muted); font-size: 13px; }

/* ---------- side panels ---------- */
.side-pane .pane-body { display: flex; flex-direction: column; gap: 18px; }
.panel h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.count { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; font-weight: 700; }

/* ---------- tables (users, audit) ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid select { width: auto; padding: 4px 6px; font-size: 12.5px; }
.page { display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- dialog / toast ---------- */
dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog .dlg-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 8px; }
dialog .dlg-body { padding: 14px 16px; overflow: auto; max-height: calc(100vh - 160px); }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 13px; z-index: 50; max-width: calc(100vw - 32px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.toast.bad { border-color: #5c2b28; color: #ffb3ae; }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px 24px; }
.auth-card .brand { justify-content: center; margin-bottom: 4px; font-size: 18px; }
.auth-card .tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-card button.primary { width: 100%; margin-top: 16px; padding: 10px; }

@media (max-width: 640px) {
  main { padding: 10px; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .health { order: 3; width: 100%; gap: 10px; }
  .who .name { display: none; }
}
.center { text-align: center; }
.brief:empty { display: none; }
.approvals-list { display: flex; flex-direction: column; gap: 10px; }
.card.approval { display: flex; flex-direction: column; gap: 8px; }
.card.approval pre.card { max-height: 220px; overflow: auto; background: var(--surface); }
.question-card { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.settings-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.settings-grid .pane-body > .row { margin-top: 12px; }
a.btn { display: inline-block; text-decoration: none; }
a.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
h3.spaced { margin-top: 18px; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.card.lesson { display: flex; flex-direction: column; gap: 6px; }
details.pane > summary { cursor: pointer; list-style: none; }
details.pane > summary::-webkit-details-marker { display: none; }
