/* ───────────────────────────────────────────────────────────────
   mind-bridge — Mind OS task-bridge dashboard
   Design: Lena. Quietly competent, not festive, not a generic dev artifact.
   Principle: state legible at a glance. Mono for machine data, sans for prose,
   display for brand. Status carries hue + tint + glyph (double-encoded).
   ─────────────────────────────────────────────────────────────── */

:root {
  /* ── surface ladder (dark, cool-neutral) ── */
  --bg:        #0b0c0e;
  --bg-1:      #111316;   /* cards / panels */
  --bg-2:      #15181d;   /* rows */
  --bg-3:      #1b1f26;   /* row hover / inputs */
  --line:      #20242c;   /* hairline */
  --line-2:    #2b313b;   /* stronger divider */

  /* ── ink ── */
  --fg:        #e8ebf0;
  --fg-mute:   #9aa3b2;
  --fg-dim:    #6b7480;
  --fg-faint:  #474e59;

  /* ── brand accent (the task-in-transit cyan) ── */
  --accent:      #7dd3fc;
  --accent-2:    #38bdf8;
  --accent-wash: rgba(125, 211, 252, 0.10);
  --accent-line: rgba(125, 211, 252, 0.32);

  /* ── status palette: foreground hue + matching wash ── */
  --c-pending:      #94a3b8;  --w-pending:      rgba(148, 163, 184, 0.12);
  --c-dispatched:   #fbbf24;  --w-dispatched:   rgba(251, 191, 36, 0.12);
  --c-in_progress:  #60a5fa;  --w-in_progress:  rgba(96, 165, 250, 0.14);
  --c-completed:    #4ade80;  --w-completed:    rgba(74, 222, 128, 0.12);
  --c-failed:       #f87171;  --w-failed:       rgba(248, 113, 113, 0.13);
  --c-blocked:      #fb923c;  --w-blocked:      rgba(251, 146, 60, 0.14);
  --c-wedged:       #e879f9;  --w-wedged:       rgba(232, 121, 249, 0.15);
  --c-abandoned:    #64748b;  --w-abandoned:    rgba(100, 116, 139, 0.10);

  /* ── type ── */
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans:    system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  /* ── geometry ── */
  --r-sm: 5px;  --r: 8px;  --r-lg: 12px;  --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;

  --shadow:    0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.25);
  --maxw:      1120px;
  --ease:      cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 var(--font-sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* faint top wash so the page has depth, not flat black */
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(125,211,252,0.045), transparent 60%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
::selection { background: var(--accent-wash); }

/* thin, on-brand scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }

/* ───── Topbar ───── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 14, 0.82);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.brand-mark { width: 26px; height: 26px; flex: none; display: block; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600; font-size: 16px; letter-spacing: -0.02em;
  color: var(--fg);
}
.brand-name b { color: var(--accent); font-weight: 600; }
.brand-sub {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim);
  padding-left: var(--s-3); margin-left: var(--s-1);
  border-left: 1px solid var(--line-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.daemon-dot {
  width: 7px; height: 7px; border-radius: 999px; background: var(--fg-faint);
  box-shadow: 0 0 0 0 transparent; transition: background .3s var(--ease);
}
.daemon-dot.live   { background: var(--c-completed); box-shadow: 0 0 8px rgba(74,222,128,0.6); }
.daemon-dot.down   { background: var(--c-failed); }

.nav { display: flex; gap: var(--s-1); flex: none; }
.nav a {
  position: relative;
  color: var(--fg-mute); font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--r-sm);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.nav a:hover { color: var(--fg); background: var(--bg-2); }
.nav a.active { color: var(--fg); }
.nav a.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.nav a.back { color: var(--fg-mute); font-family: var(--font-mono); font-size: 12px; }

/* ───── Layout ───── */
.layout { max-width: var(--maxw); margin: 0 auto; padding: var(--s-6) var(--s-5) var(--s-7); }
.view { display: none; animation: viewIn .28s var(--ease); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap;
}
.view-head h2 { font-family: var(--font-display); font-size: 19px; }
.view-head .meta { color: var(--fg-dim); font-size: 12px; font-family: var(--font-mono); }

/* ───── Stat strip (glanceable system state) ───── */
.statbar {
  display: flex; gap: var(--s-2); flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.stat {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg-1); font-size: 12px; color: var(--fg-mute);
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.stat:hover { border-color: var(--line-2); }
.stat .n { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--fg); letter-spacing: -0.02em; }
.stat .lbl { letter-spacing: 0.01em; }
.stat .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--fg-faint); }
.stat.total .n { color: var(--accent); }
.stat.is-zero { opacity: 0.45; }

/* ───── Tables / rows ───── */
.table { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--bg-1); }
.table-head {
  display: grid; gap: var(--s-3);
  padding: 9px var(--s-4); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-dim);
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.row {
  display: grid; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  position: relative;
  transition: background .14s var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg-2); }
.row > a { display: contents; color: inherit; }
/* left status edge — quietly reinforces row state without shouting */
.row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--row-accent, transparent);
  opacity: 0; transition: opacity .14s var(--ease);
}
.row:hover::before { opacity: 1; }

/* runs: status | id+summary | project | time */
.row-runs, .table-head.runs { grid-template-columns: 116px minmax(0, 1fr) 148px 70px; align-items: center; }
/* projects: name | runs | status spread */
.row-projects, .table-head.projects { grid-template-columns: minmax(0,1fr) 92px auto; align-items: center; }
/* audit: time | event | detail */
.row-audit, .table-head.audit { grid-template-columns: 96px 150px minmax(0,1fr); align-items: center; }

.cell-stack { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cell-id {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-summary {
  font-size: 12.5px; color: var(--fg-mute); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-mute { color: var(--fg-mute); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cell-ts { color: var(--fg-dim); font-family: var(--font-mono); font-size: 11.5px; text-align: right; white-space: nowrap; }
.cell-ts[title] { cursor: default; }

/* project tag chip */
.proj-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--bg-3); border: 1px solid var(--line-2);
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.proj-chip.none { background: transparent; border-style: dashed; color: var(--fg-faint); }

/* ───── Status pills (the legibility core) ───── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 8px; border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.01em;
  border: 1px solid transparent; white-space: nowrap;
  color: var(--c-pending); background: var(--w-pending);
  border-color: color-mix(in srgb, var(--c-pending) 26%, transparent);
}
.pill .glyph { width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex: none; }
.pill-pending     { color: var(--c-pending);     background: var(--w-pending);     border-color: color-mix(in srgb, var(--c-pending) 26%, transparent); }
.pill-dispatched  { color: var(--c-dispatched);  background: var(--w-dispatched);  border-color: color-mix(in srgb, var(--c-dispatched) 26%, transparent); }
.pill-in_progress { color: var(--c-in_progress); background: var(--w-in_progress); border-color: color-mix(in srgb, var(--c-in_progress) 30%, transparent); }
.pill-completed   { color: var(--c-completed);   background: var(--w-completed);   border-color: color-mix(in srgb, var(--c-completed) 26%, transparent); }
.pill-failed      { color: var(--c-failed);      background: var(--w-failed);      border-color: color-mix(in srgb, var(--c-failed) 30%, transparent); }
.pill-blocked     { color: var(--c-blocked);     background: var(--w-blocked);     border-color: color-mix(in srgb, var(--c-blocked) 32%, transparent); }
.pill-wedged      { color: var(--c-wedged);      background: var(--w-wedged);      border-color: color-mix(in srgb, var(--c-wedged) 34%, transparent); }
.pill-abandoned   { color: var(--c-abandoned);   background: var(--w-abandoned);   border-color: color-mix(in srgb, var(--c-abandoned) 22%, transparent); opacity: 0.8; }

/* meaningful motion: in_progress breathes (live), wedged pulses (unresolved anomaly).
   blocked is deliberately STATIC — it's parked on a human, not failing live. */
.pill-in_progress .glyph { animation: breathe 1.8s var(--ease) infinite; }
.pill-wedged .glyph { animation: pulseRing 1.6s var(--ease) infinite; }
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c-wedged) 70%, transparent); }
  70%  { box-shadow: 0 0 0 5px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* status → row left-edge accent (set inline via --row-accent) */

.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.legend .pill { cursor: default; }

/* ───── Panels (run detail) ───── */
.run-detail { display: grid; gap: var(--s-4); }
.panel {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-5); background: var(--bg-1);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.panel-head h2 { font-family: var(--font-mono); font-size: 16px; color: var(--fg); word-break: break-all; }
.panel h3 {
  font-family: var(--font-mono); font-size: 11px; margin-bottom: var(--s-3);
  color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: var(--s-2);
}
.panel.attn { border-color: color-mix(in srgb, var(--c-blocked) 40%, var(--line)); background: linear-gradient(0deg, var(--w-blocked), transparent), var(--bg-1); }
.panel.attn.wedge { border-color: color-mix(in srgb, var(--c-wedged) 40%, var(--line)); background: linear-gradient(0deg, var(--w-wedged), transparent), var(--bg-1); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: var(--s-2) var(--s-4); font-size: 13px; margin: 0; }
.kv dt { color: var(--fg-dim); font-size: 12px; }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: 12.5px; color: var(--fg); word-break: break-word; }

/* ───── Phase timeline ───── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-step { display: grid; grid-template-columns: 22px 1fr auto; gap: var(--s-3); align-items: start; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-node {
  width: 11px; height: 11px; border-radius: 999px; margin-top: 3px;
  background: var(--bg); border: 2px solid var(--accent); flex: none;
}
.tl-step.live .tl-node { background: var(--accent); box-shadow: 0 0 10px var(--accent-line); animation: breathe 1.8s var(--ease) infinite; }
.tl-step.done .tl-node { background: var(--accent); border-color: var(--accent); }
.tl-line { width: 2px; flex: 1; min-height: 14px; background: var(--line-2); margin: 2px 0; }
.tl-step:last-child .tl-line { display: none; }
.tl-body { padding-bottom: var(--s-4); min-width: 0; }
.tl-name { font-family: var(--font-mono); font-size: 13px; color: var(--fg); }
.tl-note { font-size: 12px; color: var(--fg-mute); margin-top: 2px; }
.tl-meta { text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); white-space: nowrap; }
.tl-dur { color: var(--accent); opacity: 0.8; }
.tl-step.enter { animation: stepIn .3s var(--ease); }
@keyframes stepIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

ul.clean { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
ul.clean li { font-size: 13px; color: var(--fg); }
ul.clean li::marker { color: var(--accent); }

pre.output {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  background: var(--bg); padding: var(--s-3) var(--s-4); border-radius: var(--r);
  border: 1px solid var(--line); margin: 0;
  overflow-x: auto; max-height: 480px; white-space: pre-wrap; word-break: break-word;
  color: var(--fg-mute);
}

/* ───── Empty / loading states ───── */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-7) var(--s-5); text-align: center;
  color: var(--fg-mute); background: var(--bg-1);
}
.empty.boxed { border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty .ico { opacity: 0.5; }
.empty .title { color: var(--fg); font-size: 14px; font-weight: 500; }
.empty .hint { font-size: 12.5px; color: var(--fg-dim); max-width: 380px; }
.empty .hint code { font-family: var(--font-mono); background: var(--bg-3); padding: 1px 6px; border-radius: 4px; color: var(--fg-mute); }
.empty.error .title { color: var(--c-failed); }

.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
  border-radius: var(--r); height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.loading-rows { display: grid; gap: 1px; }
.loading-rows .sk-row { padding: var(--s-3) var(--s-4); background: var(--bg-1); }

/* audit event tag */
.evt {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: var(--r-sm);
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-mute);
  white-space: nowrap;
}
.evt.task_seen        { color: var(--c-pending);     border-color: color-mix(in srgb, var(--c-pending) 30%, transparent); }
.evt.task_dispatched  { color: var(--c-dispatched);  border-color: color-mix(in srgb, var(--c-dispatched) 30%, transparent); }
.evt.reconciled_terminal,
.evt.task_terminal,
.evt.task_completed   { color: var(--c-completed);    border-color: color-mix(in srgb, var(--c-completed) 30%, transparent); }
.evt.task_failed      { color: var(--c-failed);       border-color: color-mix(in srgb, var(--c-failed) 30%, transparent); }
.evt.task_blocked     { color: var(--c-blocked);      border-color: color-mix(in srgb, var(--c-blocked) 30%, transparent); }
.evt.task_wedged      { color: var(--c-wedged);       border-color: color-mix(in srgb, var(--c-wedged) 30%, transparent); }
.evt.daemon_start     { color: var(--accent); }
.evt.daemon_stop      { color: var(--fg-dim); }

/* ───── Responsive — desktop-first, but don't fall apart on a narrow window ───── */
@media (max-width: 720px) {
  .layout { padding: var(--s-5) var(--s-4) var(--s-6); }
  .brand-sub { display: none; }
  .row-runs, .table-head.runs { grid-template-columns: 96px minmax(0,1fr) 60px; }
  .row-runs .proj-chip, .table-head.runs .col-project { display: none; }
  .row-audit, .table-head.audit { grid-template-columns: 70px 1fr; }
  .row-audit .cell-mute, .table-head.audit .col-detail { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px var(--s-3); }
  .kv dt { margin-top: var(--s-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
