/* Cortex dashboard — implements the Claude Design canvas ("Cortex Dashboard.dc.html").
   Light, calm control room: Geist / Geist Mono, ink #16181D, accent #3D63DD. */
:root {
  --ink: #16181d; --body: #5c6470; --body2: #4a5160; --muted: #8a919e; --faint: #9aa0a8;
  --canvas: #f7f7f5; --card: #fff; --line: #e6e8ec; --line2: #eef0f2; --line3: #f2f3f5;
  --accent: #3d63dd; --accent-deep: #2c4bc0; --accent-bg: #e5ebfb; --accent-bg2: #e9ecf9;
  --ok: #1a9e57; --ok-deep: #178d4f; --ok-bg: #effaf3;
  --warn: #b7791f; --warn-deep: #9a6414; --warn-bg: #fdf3e2;
  --attn: #e07b39; --attn-deep: #b25c14; --attn-bg: #fbeeda; --attn-card: #fffaf4; --attn-line: #f3ddc2;
  --err: #d43d3d; --err-deep: #b32e2e; --err-bg: #fbeaea; --err-row: #fdf7f7; --err-line: #efd4d4;
  --purple: #7857d6; --purple-bg: #f1ecfb;
  --input: #d8dade;
  --sans: Geist, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--canvas); color: var(--ink); font: 400 13px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input, textarea, select { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--input); border-radius: 7px; padding: 7px 11px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,99,221,.12); }
::placeholder { color: var(--muted); }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
@keyframes shim { 0% { background-position: -260px 0 } 100% { background-position: 260px 0 } }
.pulse { animation: pulse 1.6s infinite; }
.shimmer { height: 3px; border-radius: 999px; background: linear-gradient(90deg, var(--accent-bg) 25%, #c3d1f6 40%, var(--accent-bg) 55%); background-size: 260px 100%; animation: shim 1.6s linear infinite; }

/* ---------- shell ---------- */
#app { display: flex; min-height: 100vh; }
nav.side { width: 220px; flex: none; background: var(--canvas); border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 10px 16px; }
.brand .logo { width: 20px; height: 20px; border-radius: 6px; background: var(--ink); display: flex; align-items: center; justify-content: center; }
.brand .logo i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid #fff; }
.brand b { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; }
.brand .health-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
nav.side .items { display: flex; flex-direction: column; gap: 2px; }
nav.side .item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--body); }
nav.side .item svg { flex: none; }
nav.side .item.active { background: var(--accent-bg2); color: var(--accent-deep); }
nav.side .item:hover:not(.active) { background: #efefec; }
nav.side .item .nbadge { margin-left: auto; background: var(--attn); color: #fff; border-radius: 999px; font-size: 10.5px; font-weight: 700; padding: 1px 6px; line-height: 1.4; }
nav.side .spacer { flex: 1; }
.palette-hint { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.palette-hint kbd { margin-left: auto; font: 500 10.5px var(--mono); border: 1px solid #e0e2e6; border-radius: 5px; padding: 1px 5px; background: #fff; color: var(--body); }
.who { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-top: 1px solid var(--line); margin-top: 6px; }
.who .avatar { width: 24px; height: 24px; border-radius: 50%; background: #e2e5ea; color: var(--body2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 650; }
.who .nm { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.who .rl { font-size: 10.5px; color: var(--muted); line-height: 1.3; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 32px; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.topbar h1 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.topbar .count { font-size: 12px; color: var(--muted); }
.topbar .sp { flex: 1; }
.topbar .clock { font-size: 12px; color: var(--muted); }
.content { flex: 1; padding: 24px 32px; overflow-y: auto; }
.narrow { max-width: 980px; margin: 0 auto; }

/* ---------- primitives ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--input); border-radius: 7px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--ink); }
.btn:hover { border-color: #b9bdc4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.danger { color: var(--err-deep); border-color: #ecc8c8; }
.btn.lg { padding: 7px 16px; font-size: 12.5px; }
.btn.sm { padding: 3px 9px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.pill.idle { background: #eef0f3; color: var(--body); }
.pill.running { background: var(--accent-bg); color: var(--accent-deep); }
.pill.draft { background: #fff; color: var(--muted); border: 1px dashed #c3c7cd; }
.pill.disabled { background: #f2f2f0; color: var(--faint); text-decoration: line-through; }
.pill.error { background: var(--err-bg); color: var(--err-deep); }
.pill.needskey { background: var(--warn-bg); color: var(--warn-deep); }
.pill.live { background: var(--accent-bg); color: var(--accent-deep); font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 3px 9px; }
.pill.expiry { background: var(--warn-bg); color: var(--attn-deep); font-size: 11px; padding: 3px 10px; }
.mono { font-family: var(--mono); }
.cost-chip { font: 500 10.5px var(--mono); color: #6d7480; background: #f2f2f0; border-radius: 5px; padding: 1px 6px; }
.sect-label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.card-label { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.avatar-sq { border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.meter { height: 4px; border-radius: 999px; background: var(--line2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* tabs (agent detail / approvals) */
.tabs { display: flex; gap: 22px; font-size: 12.5px; font-weight: 600; }
.tabs .tab { color: var(--muted); padding-bottom: 9px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs .tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* tables */
.trow { display: flex; gap: 11px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line3); font-size: 12.5px; }
.trow:last-child { border-bottom: none; }
.thead { display: flex; gap: 11px; padding: 8px 16px; background: #fafafa; border-bottom: 1px solid var(--line2); font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.trow.failed-row { background: var(--err-row); }

/* stat tiles */
.tiles { display: flex; gap: 10px; flex-wrap: wrap; }
.tile { flex: 1; min-width: 130px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.tile .v { font-size: 13.5px; font-weight: 600; margin-top: 5px; }

/* chat bubbles */
.bubble-me { align-self: flex-end; max-width: 75%; background: var(--ink); color: #fff; border-radius: 12px 12px 3px 12px; padding: 11px 15px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble-bot { align-self: flex-start; max-width: 82%; background: #fff; border: 1px solid var(--line); border-radius: 12px 12px 12px 3px; padding: 11px 15px; font-size: 13px; line-height: 1.55; color: #3c434e; white-space: pre-wrap; word-break: break-word; }
.bubble-sys { align-self: center; font-size: 11.5px; color: var(--muted); }

/* transcript event cards */
.ev { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; align-items: center; gap: 9px; font-size: 12.5px; flex-wrap: wrap; }
.ev .tool-name { font: 500 12px var(--mono); }
.ev .io { width: 100%; font: 400 11px/1.6 var(--mono); color: var(--body2); background: #fafafa; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 11px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow-y: auto; }

/* toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; border-radius: 10px; padding: 11px 16px; font-size: 12.5px; display: flex; align-items: center; gap: 12px; box-shadow: 0 6px 24px rgba(16,18,24,.25); max-width: 420px; }
.toast .undo { color: #9db4f5; font-weight: 650; cursor: pointer; }
.toast .bar { height: 2px; border-radius: 999px; background: #3a3f4a; position: absolute; }

/* command palette + modals */
.overlay { position: fixed; inset: 0; background: rgba(16,18,24,.35); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette { width: 560px; max-width: 92vw; background: #fff; border-radius: 14px; box-shadow: 0 24px 80px rgba(16,18,24,.3); overflow: hidden; }
.palette input { width: 100%; border: none; border-bottom: 1px solid var(--line2); border-radius: 0; padding: 15px 18px; font-size: 14px; }
.palette input:focus { box-shadow: none; }
.palette .plist { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette .pitem { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.palette .pitem.sel { background: var(--accent-bg2); color: var(--accent-deep); }
.palette .pitem .hint { margin-left: auto; font-size: 11px; color: var(--muted); }
.modal { width: 480px; max-width: 92vw; background: #fff; border-radius: 14px; box-shadow: 0 24px 80px rgba(16,18,24,.3); padding: 22px 24px; }
.modal h3 { font-size: 15px; font-weight: 650; margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--body2); margin: 12px 0 5px; }
.modal input, .modal textarea, .modal select { width: 100%; }

/* login — #app is a flex row, so this must claim the full width itself,
   otherwise it shrinks to its content and the centering does nothing. */
.login-wrap { flex: 1; width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--canvas); padding: 24px; }
.login-box { width: 360px; max-width: 92vw; }
.login-card { background: #fff; border: 1px solid #e2e4e8; border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(16,18,24,.04); }

/* agents grid */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; transition: border-color .12s; }
.agent-card:hover { border-color: #c9cdd4; }
.agent-card.is-running { border-color: #ccd6f4; box-shadow: 0 1px 4px rgba(61,99,221,.08); }
.agent-card.is-error { border-color: var(--err-line); }
.agent-card.is-disabled { background: #fafaf9; opacity: .75; }
.agent-card .foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.new-agent-cta { border: 1.5px dashed #d4d6da; border-radius: 12px; display: flex; align-items: center; justify-content: center; min-height: 104px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.new-agent-cta:hover { border-color: var(--accent); color: var(--accent); }

/* home attention */
.attn-box { background: var(--attn-card); border: 1px solid var(--attn-line); border-radius: 10px; overflow: hidden; }
.attn-box .hd { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--attn-line); font-size: 12px; font-weight: 650; color: #9a5214; }
.attn-box .row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #f8ecdc; font-size: 13px; }
.attn-box .row:last-child { border-bottom: none; }

/* log console */
.console { background: var(--ink); border-radius: 10px; padding: 14px 16px; font: 400 10.8px/1.8 var(--mono); color: #9aa3b2; overflow-x: auto; max-height: 420px; overflow-y: auto; }
.console .t { color: #5c6470; } .console .i { color: #5ee39a; } .console .w { color: #e8c268; } .console .e { color: #f28b82; }

/* filter chips */
.chip { font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.chip.on { font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--input); }

/* memory editor */
.memo-editor { width: 100%; border: none; padding: 16px 18px; font: 400 12px/1.75 var(--mono); color: #3c434e; min-height: 320px; resize: vertical; border-radius: 0; }
.memo-editor:focus { box-shadow: none; }

/* proposal card */
.proposal { background: #fff; border: 1px solid #ccd6f4; border-radius: 14px; box-shadow: 0 2px 10px rgba(61,99,221,.08); overflow: hidden; }
.proposal .p-sec { padding: 12px 20px; border-bottom: 1px solid var(--line2); }
.proposal .p-tag { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--accent-deep); background: var(--accent-bg); border-radius: 4px; padding: 1px 6px; }

/* mobile */
nav.tabbar { display: none; }
@media (max-width: 820px) {
  nav.side { display: none; }
  #app { flex-direction: column; }
  main { padding-bottom: 76px; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  nav.tabbar { display: block; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 40; }
  nav.tabbar .cells { display: flex; }
  nav.tabbar .cell { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 3px; font-size: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
  nav.tabbar .cell.active { color: var(--accent-deep); }
  nav.tabbar .cell .ico { position: relative; display: flex; }
  nav.tabbar .cell .nbadge { position: absolute; top: -5px; right: -11px; background: var(--attn); color: #fff; border-radius: 999px; font-size: 9px; font-weight: 700; padding: 1px 5px; line-height: 1.3; }
  nav.tabbar .handle { display: flex; justify-content: center; padding: 4px 0 7px; }
  nav.tabbar .handle i { width: 120px; height: 4px; border-radius: 999px; background: #d8d9dc; }
}

/* streaming bubble: blinking caret while tokens arrive */
@keyframes caret { 0%, 100% { opacity: 1 } 50% { opacity: 0 } }
.bubble-bot.live::after { content: '▍'; color: var(--accent); animation: caret 1s infinite; margin-left: 2px; }
