:root { --bg:#f6f7f9; --card:#fff; --ink:#1d2430; --muted:#6b7480; --line:#e3e6ea; --accent:#1f5fd1;
        --ok:#1a7f4b; --warn:#b26a00; --bad:#c23030; --off:#8a929c; --wait:#7a4fd0; }
* { box-sizing: border-box; }
body { margin:0; font:14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; background:var(--bg); color:var(--ink); }
a { color:var(--accent); text-decoration:none; } a:hover { text-decoration:underline; }
header { display:flex; align-items:center; gap:20px; padding:10px 24px; background:#141a24; color:#fff; }
header a { color:#cfd6e0; } header a.brand { color:#fff; font-weight:600; }
header nav { display:flex; gap:16px; flex:1; } header form { margin:0; }
.badge { display:inline-block; min-width:18px; padding:0 6px; border-radius:9px; background:var(--bad); color:#fff; font-size:12px; text-align:center; }
main { max-width:1280px; margin:20px auto; padding:0 24px; }
h1 { font-size:20px; margin:0 0 4px; } h2 { font-size:16px; margin:24px 0 8px; } .sub { color:var(--muted); margin-bottom:16px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:16px; margin-bottom:16px; }
table { width:100%; border-collapse:collapse; background:var(--card); }
th, td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
th { font-weight:600; color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.03em; }
.pill { display:inline-block; padding:1px 8px; border-radius:10px; font-size:12px; font-weight:600; background:#eef0f3; color:var(--muted); }
.s-running,.s-dispatched { background:#e3edff; color:var(--accent); } .s-succeeded,.s-ok,.s-idle,.s-allowed,.s-approved,.s-answered,.s-used { background:#e2f4ea; color:var(--ok); }
.s-failed,.s-error,.s-budget_exceeded,.s-killed,.s-denied,.s-rejected { background:#fbe5e5; color:var(--bad); }
.s-waiting_human,.s-waiting,.s-paused,.s-pending,.s-open,.s-pending_approval { background:#efe7fb; color:var(--wait); }
.s-queued { background:#fff2dc; color:var(--warn); } .s-dry_run { background:#fff2dc; color:var(--warn); } .s-off { background:#eef0f3; color:var(--off); }
.muted { color:var(--muted); } .small { font-size:12px; } .mono { font-family:ui-monospace, Menlo, monospace; font-size:12px; }
.row { display:flex; gap:16px; flex-wrap:wrap; align-items:flex-start; } .row > .card { flex:1; min-width:320px; }
button, .btn { font:inherit; padding:5px 12px; border-radius:6px; border:1px solid var(--line); background:#fff; cursor:pointer; color:var(--ink); }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; } button.danger { color:var(--bad); border-color:#efb7b7; }
button.ok { color:var(--ok); border-color:#a9dcc0; }
form.inline { display:inline; margin:0; }
textarea, input[type=text], input[type=email], input[type=password] { width:100%; font:inherit; padding:7px 9px; border:1px solid var(--line); border-radius:6px; }
textarea { min-height:70px; }
.timeline { list-style:none; margin:0; padding:0; }
.timeline li { display:grid; grid-template-columns:42px 90px 1fr; gap:10px; padding:8px 0; border-bottom:1px solid var(--line); }
.timeline .seq { color:var(--muted); font-size:12px; text-align:right; padding-top:2px; }
details summary { cursor:pointer; color:var(--muted); font-size:12px; }
pre { white-space:pre-wrap; word-break:break-word; background:#f3f5f8; padding:8px; border-radius:6px; max-height:360px; overflow:auto; font-size:12px; }
.kv { display:grid; grid-template-columns:160px 1fr; gap:4px 12px; }
.kv div:nth-child(odd) { color:var(--muted); }
.warnbox { background:#fff2dc; border:1px solid #f0d49b; padding:10px 14px; border-radius:6px; margin-bottom:12px; }
.toolgrid { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:6px 20px; }
.toolgrid label { display:flex; gap:8px; align-items:baseline; }
.login { max-width:360px; margin:12vh auto; }

/* --- v2: cards, tabs, turns, proposal ------------------------------------------------ */
.needs { display:grid; grid-template-columns:repeat(auto-fit, minmax(260px, 1fr)); gap:12px; margin-bottom:20px; }
.needs .card { margin:0; padding:12px 14px; }
.needs h3 { margin:0 0 6px; font-size:13px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); display:flex; justify-content:space-between; }
.needs .item { display:block; padding:5px 0; border-top:1px solid var(--line); font-size:13px; color:var(--ink); }
.needs .item:first-of-type { border-top:0; }
.needs .item:hover { background:#f7f9fc; text-decoration:none; }
.needs .empty { color:var(--muted); font-size:13px; }
.count { font-weight:700; color:var(--ink); }
.count.hot { color:var(--bad); }
.agents { display:flex; flex-direction:column; gap:10px; }
details.agent { background:var(--card); border:1px solid var(--line); border-radius:10px; }
details.agent[open] { box-shadow:0 2px 10px rgba(20,30,50,.06); }
details.agent > summary { list-style:none; cursor:pointer; padding:14px 16px; }
details.agent > summary::-webkit-details-marker { display:none; }
.agent-row { display:grid; grid-template-columns:28px 1.6fr 1.4fr 1.2fr 1fr auto; gap:14px; align-items:center; }
.chev { color:var(--muted); transition:transform .15s; font-size:14px; }
details[open] .chev { transform:rotate(90deg); }
.agent-name { font-weight:600; font-size:15px; } .agent-name a { color:var(--ink); }
.stat { font-size:12px; color:var(--muted); } .stat b { color:var(--ink); font-size:14px; }
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; background:var(--off); vertical-align:middle; }
.dot.running { background:var(--accent); animation:pulse 1.2s infinite; } .dot.idle { background:var(--ok); }
.dot.waiting { background:var(--wait); } .dot.failed { background:var(--bad); }
@keyframes pulse { 50% { opacity:.35; } }
.panel { border-top:1px solid var(--line); padding:6px 16px 14px 58px; }
.runline { display:grid; grid-template-columns:110px 1fr 140px 90px; gap:12px; padding:7px 0; border-bottom:1px solid var(--line); align-items:center; color:var(--ink); font-size:13px; }
.runline:hover { background:#f7f9fc; text-decoration:none; }
.runline .t { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.runline .t small { display:block; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.section-label { font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin:12px 0 2px; }
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--line); margin:16px 0; }
.tabs a { padding:8px 14px; color:var(--muted); border-bottom:2px solid transparent; margin-bottom:-1px; }
.tabs a.on { color:var(--ink); border-bottom-color:var(--accent); font-weight:600; }
.tabs a:hover { text-decoration:none; color:var(--ink); }
.crumbs { font-size:13px; color:var(--muted); margin-bottom:6px; } .crumbs a { color:var(--muted); }
.headline { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.facts { display:flex; gap:22px; flex-wrap:wrap; margin:10px 0 16px; font-size:13px; color:var(--muted); }
.facts b { color:var(--ink); display:block; font-size:15px; }
.turn { border-left:3px solid var(--line); margin:0 0 14px 6px; padding:2px 0 2px 14px; }
.turn.has-model { border-left-color:#c8d6f0; }
.turn-head { font-size:13px; color:var(--muted); margin-bottom:4px; }
.turn-head .say { color:var(--ink); font-size:14px; }
.call { display:flex; gap:10px; align-items:flex-start; padding:6px 10px; background:#f7f8fa; border-radius:6px; margin:4px 0; font-size:13px; }
.call .ico { width:20px; text-align:center; }
.call .body { flex:1; min-width:0; }
.call .name { font-family:ui-monospace, Menlo, monospace; font-size:12px; color:var(--muted); }
.email { background:#fff; border:1px solid var(--line); border-radius:8px; padding:14px 16px; white-space:pre-wrap; font-size:14px; line-height:1.55; }
.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chip { font-size:12px; padding:2px 8px; border-radius:10px; background:#fff2dc; color:var(--warn); }
.chip.ok { background:#e2f4ea; color:var(--ok); }
.bar { height:6px; background:#eef0f3; border-radius:3px; overflow:hidden; width:120px; display:inline-block; vertical-align:middle; }
.bar > span { display:block; height:100%; background:var(--ok); }
.bar.low > span { background:var(--warn); }
.kgrid { display:grid; grid-template-columns:260px 1fr; gap:16px; }
.kfile { padding:6px 8px; border-radius:6px; display:block; color:var(--ink); font-size:13px; }
.kfile:hover, .kfile.on { background:#eef3fd; text-decoration:none; }
.md h1 { font-size:18px; } .md h2 { font-size:15px; margin-top:18px; } .md table { font-size:13px; } .md td, .md th { border:1px solid var(--line); }
.md code { background:#f3f5f8; padding:0 3px; border-radius:3px; }
.flash { background:#e2f4ea; border:1px solid #a9dcc0; padding:8px 12px; border-radius:6px; margin-bottom:12px; font-size:13px; }

/* --- v3: nav state, forms, matrix, costs ----------------------------------------------- */
header nav a.on { color:#fff; font-weight:600; border-bottom:2px solid #fff; padding-bottom:2px; }
header .spend { font-size:12px; color:#cfd6e0; border:1px solid #39424f; padding:3px 8px; border-radius:12px; }
header .spend.hot { border-color:var(--bad); color:#ffb4b4; }
.help { font-size:12px; color:var(--muted); margin:2px 0 8px; }
.form-grid { display:grid; grid-template-columns:200px 1fr; gap:10px 16px; align-items:start; }
.form-grid > label { font-weight:600; font-size:13px; padding-top:7px; }
select, input[type=number] { font:inherit; padding:6px 8px; border:1px solid var(--line); border-radius:6px; background:#fff; }
textarea.code, textarea.prompt { font-family:ui-monospace, Menlo, monospace; font-size:12.5px; line-height:1.45; }
textarea.prompt { min-height:360px; } textarea.code { min-height:160px; }
.limits { display:grid; grid-template-columns:repeat(3, minmax(160px, 1fr)); gap:10px; }
.limits label { font-size:12px; color:var(--muted); display:block; }
.limits input { width:100%; }
.matrix { border-collapse:separate; border-spacing:0; font-size:12px; }
.matrix th, .matrix td { border-bottom:1px solid var(--line); padding:4px 6px; text-align:center; }
.matrix th.tool, .matrix td.tool { text-align:left; white-space:nowrap; }
.matrix thead th { position:sticky; top:0; background:#fff; }
.cell button { border:0; background:transparent; padding:2px 6px; border-radius:4px; cursor:pointer; font-size:13px; min-width:30px; }
.cell button.allowed { background:#e2f4ea; color:var(--ok); } .cell button.approval { background:#efe7fb; color:var(--wait); }
.cell button.none { color:#c3c8cf; }
.cell button:hover { outline:1px solid var(--accent); }
.conn { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.kpis { display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:12px; margin-bottom:16px; }
.kpi { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:12px 14px; }
.kpi .v { font-size:24px; font-weight:700; } .kpi .l { color:var(--muted); font-size:12px; }
.meter { height:8px; background:#eef0f3; border-radius:4px; overflow:hidden; margin-top:6px; }
.meter > span { display:block; height:100%; background:var(--ok); }
.meter.warn > span { background:var(--warn); } .meter.over > span { background:var(--bad); }
.legend { display:flex; gap:14px; flex-wrap:wrap; font-size:12px; color:var(--ink); margin:6px 0; }
.legend i { display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:5px; vertical-align:-1px; }
.chart rect.bar:hover { opacity:.8; }
.chart text { font-size:11px; fill:var(--muted); }
.chart line { stroke:#e9ecef; }
.tip { position:fixed; pointer-events:none; background:#141a24; color:#fff; font-size:12px; padding:4px 8px; border-radius:4px; display:none; z-index:10; }
.trig { display:grid; grid-template-columns:1fr 200px 200px auto; gap:12px; align-items:center; }
.kind { font-size:11px; text-transform:uppercase; letter-spacing:.05em; padding:2px 7px; border-radius:10px; background:#eef3fd; color:var(--accent); }
.diff-note { font-size:12px; color:var(--muted); }
.two { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.badge-set { color:var(--ok); } .badge-unset { color:var(--bad); }

/* --- v4: review fixes (contrast, focus, components, mobile) --------------------------------- */
:root { --muted:#566070; }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }
.spacer { flex:1; }
.h { margin-top:0; }
.prewrap { white-space:pre-wrap; }
.state { font-size:12px; font-weight:600; margin-right:6px; } .state.on { color:var(--ok); } .state.off { color:var(--off); } .state.bad { color:var(--bad); }
.clickable { cursor:pointer; } .clickable:hover td { background:#f7f9fc; }
td.wide { min-width:260px; } .num { text-align:right; }
.count { display:inline-block; min-width:24px; padding:1px 8px; border-radius:12px; background:#eef0f3; font-weight:700; text-align:center; }
.count.hot { background:var(--bad); color:#fff; }
.allclear { color:var(--ok); font-weight:600; }
ul.actions { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.action { display:flex; gap:14px; align-items:center; justify-content:space-between; background:var(--card); border:1px solid var(--line);
          border-left:4px solid var(--line); border-radius:8px; padding:10px 14px; }
.action-approval, .action-question { border-left-color:var(--wait); } .action-failed, .action-health { border-left-color:var(--bad); }
.action-held, .action-escalated { border-left-color:var(--warn); } .action-paused { border-left-color:var(--off); }
.action .what { flex:1; min-width:0; } .action .meta, .qcard .meta { font-size:12px; color:var(--muted); margin-top:2px; }
.action .do { display:flex; gap:6px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.action .do input[type=text] { width:200px; }
.tag { display:inline-block; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; padding:1px 7px; border-radius:4px; background:#eef0f3; color:var(--ink); }
.tag-wait { background:#efe7fb; color:#5b37b0; } .tag-bad { background:#fbe5e5; color:#a32222; } .tag-warn { background:#fff2dc; color:#8a5200; }
.kindtag { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); background:#eef0f3;
           padding:1px 6px; border-radius:3px; min-width:56px; text-align:center; }
.call-denied, .call-error { background:#fdf1f1; }
.banner { padding:10px 14px; border-radius:8px; margin:6px 0 14px; font-size:14px; }
.banner.warn { background:#fff2dc; border:1px solid #f0d49b; } .banner.bad { background:#fbe5e5; border:1px solid #efb7b7; }
.banner.wait { background:#efe7fb; border:1px solid #d6c5f5; }
.qcard .qtitle { font-size:15px; margin:4px 0 8px; } .do-block { display:flex; flex-direction:column; gap:8px; } .do-block > div { display:flex; gap:8px; }
.choices { display:flex; gap:14px; flex-wrap:wrap; }
.chipf { display:inline-block; padding:3px 10px; border-radius:14px; border:1px solid var(--line); font-size:12px; color:var(--ink); background:#fff; }
.chipf.on { background:var(--accent); border-color:var(--accent); color:#fff; } .chipf:hover { text-decoration:none; border-color:var(--accent); }
.filters { margin-bottom:10px; }
.row .col-main { flex:2; min-width:420px; } .row .col-side { flex:1; min-width:280px; }
a.mini { display:block; padding:5px 0; border-bottom:1px solid var(--line); font-size:13px; color:var(--ink); } a.mini:hover { text-decoration:none; background:#f7f9fc; }
.phases { border:0; padding:0; margin:0; display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.phase { display:flex; flex-direction:column; gap:4px; border:1px solid var(--line); border-radius:8px; padding:10px 12px; cursor:pointer; font-size:13px; }
.phase.on, .phase:has(input:checked) { border-color:var(--accent); background:#f3f7ff; } .phase span { color:var(--muted); }
form.budgets { display:flex; gap:6px; align-items:flex-end; } form.budgets label { font-size:11px; color:var(--muted); display:flex; flex-direction:column; }
form.budgets input { width:80px; }
.unsaved { color:var(--warn); font-weight:600; }
.live-note { color:var(--muted); margin-left:10px; }
header .who { display:flex; align-items:center; gap:12px; }
button:disabled { opacity:.5; cursor:not-allowed; }
.pill.s-dry_run { color:#7a4a00; }

@media (max-width: 760px) {
  header { flex-wrap:wrap; gap:8px; padding:10px 14px; }
  header nav { order:3; width:100%; overflow-x:auto; white-space:nowrap; gap:14px; padding-bottom:4px; }
  header .who { margin-left:auto; } header .who .small { display:none; }
  main { padding:0 12px; margin-top:12px; }
  .tabs { overflow-x:auto; white-space:nowrap; }
  .row { flex-direction:column; } .row > .card, .row .col-main, .row .col-side { min-width:0; width:100%; }
  .two, .conn, .kgrid, .phases, .limits, .form-grid { grid-template-columns:1fr; }
  .form-grid > label { padding-top:0; }
  table { display:block; overflow-x:auto; }
  .agents-table td:nth-child(3), .agents-table th:nth-child(3), .agents-table td:nth-child(4), .agents-table th:nth-child(4) { display:none; }
  .action { flex-direction:column; align-items:stretch; } .action .do { justify-content:flex-start; } .action .do input[type=text] { width:100%; }
  .facts { gap:12px; } .headline h1 { font-size:18px; }
  .runline { grid-template-columns:1fr; }
}
