/* Tokens, base reset, top-bar/aside/right layout grid. Component
   styles live with their components in P3.2-P3.5. Tokens ported
   verbatim from the legacy valtr dashboard (app.css:10-27) — same
   palette so screenshots stay comparable while we move to Lit. */

@font-face {
  font-family: 'Departure Mono';
  src: url('/static/assets/fonts/DepartureMono-Regular.woff2') format('woff2'),
       url('/static/assets/fonts/DepartureMono-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #080908;
  --panel: #0d0f0d;
  --line: #242824;
  --line-soft: #171a17;
  --text: #d7ded7;
  --muted: #737c73;
  --dim: #4d544d;
  --ok: #91d99d;
  --warn: #d6c178;
  --bad: #d98d8d;
  --accent: #8cb89a;
  /* Gold-ish — used for monetary values so $ scans as cost at a glance. */
  --gold: #c9a85e;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

/* Lock font sizes against mobile-Safari auto-zoom. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Departure Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

metapod-app {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.top-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.layout > .left {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.layout > .right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-title {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.muted { color: var(--muted); }
.dim   { color: var(--dim); }

.status-ok   { color: var(--ok); }
.status-warn { color: var(--warn); }
.status-bad  { color: var(--bad); }
.status-dim  { color: var(--dim); }

/* Boot stub — visible only until <metapod-app> upgrades. */
.boot-stub {
  padding: 24px;
  color: var(--muted);
}

/* Top bar — METAPOD mark left, sse-connected indicator right. */
.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-bar-right { justify-content: flex-end; }
.mark {
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* Lanes panel + lane rows. */
lanes-panel { display: contents; }
.lanes-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.lane-row {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
  cursor: pointer;
  transition: background 80ms;
}
.lane-row:hover         { background: var(--line-soft); }
.lane-row:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.lane-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.lane-name {
  color: var(--text);
  letter-spacing: 0.04em;
}
.lane-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border: 1px solid currentColor;
}
.lane-row-meta {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lane-msg {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lane-row-drawer {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}
.lane-run {
  display: grid;
  grid-template-columns: 100px 80px 1fr;
  gap: 8px;
  align-items: baseline;
}
.lane-run-status { font-size: 10px; text-transform: uppercase; }
.lane-row-expanded { background: var(--line-soft); }

/* Inference panel + run cards. */
inference-panel { display: contents; }
.inference-panel {
  flex: 0 0 auto;
  max-height: 40vh;
}
.inference-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.run-card {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
  cursor: pointer;
  transition: background 80ms;
}
.run-card:hover         { background: var(--line-soft); }
.run-card:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.run-card-head {
  display: grid;
  grid-template-columns: 80px 90px minmax(0, 1fr) 80px;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
}
.run-lane   { color: var(--text); letter-spacing: 0.04em; }
.run-status { font-size: 10px; text-transform: uppercase; text-align: right; }
.run-card-meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.run-tok-in     { color: var(--accent); }
.run-tok-out    { color: var(--accent); }
.run-tok-cached { color: var(--muted); }
.run-tok-dur    { color: var(--muted); }
.run-tok-calls  { color: var(--muted); }
.run-tok-find   { color: var(--muted); }
.run-tok-price  { color: var(--gold); margin-left: auto; }

.run-card-calls {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}
.run-call {
  display: grid;
  grid-template-columns: 32px 90px minmax(0, 1fr) 100px;
  gap: 8px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.call-finish { text-align: right; }
.run-card-expanded { background: var(--line-soft); }

/* SSE-disconnected banner — sticky strip above the top bar. */
.sse-banner {
  flex: 0 0 auto;
  padding: 4px 12px;
  border-bottom: 1px solid var(--bad);
  background: var(--bg);
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.04em;
}

/* Stats bar in the top-right cell. */
stats-bar { display: contents; }
.top-stats-sys {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.top-stat .stat-val {
  color: var(--text);
  margin-left: 2px;
}

/* Lane foot — sticky footer below the lanes list. light DOM means
   styling the element selector applies directly. */
lane-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
lane-foot .foot-clock { color: var(--muted); }

/* Findings — responsive grid of panels (cybersecurity + ai + code). */
.findings-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
  min-height: 0;
}
findings-panel { display: contents; }
.findings-panel { min-height: 0; }
.findings-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* Row tile — one row per finding. */
.row-tile {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
}
.row-tile:hover { background: var(--line-soft); }
.row-tile-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.row-tile-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  padding: 1px 5px;
}
.row-tile-headline {
  flex: 1 1 auto;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.row-tile-headline:hover { color: var(--accent); }
.row-tile-time { font-size: 10px; }
.row-tile-sub {
  margin-top: 2px;
  display: flex;
  gap: 8px;
  font-size: 11px;
}
.row-tile-summary {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* Code-change tile — autovibe finding renderer. */
.code-change-tile {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
}
.code-change-tile:hover { background: var(--line-soft); }
.cc-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.cc-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  padding: 1px 5px;
  white-space: nowrap;
}
.cc-out-ok     { border-color: var(--ok);     color: var(--ok); }
.cc-out-warn   { border-color: var(--warn);   color: var(--warn); }
.cc-out-bad    { border-color: var(--bad);    color: var(--bad); }
.cc-out-accent { border-color: var(--accent); color: var(--accent); }
.cc-out-dim    { border-color: var(--dim);    color: var(--muted); }
.cc-mode       { color: var(--muted); }
.cc-headline {
  flex: 1 1 auto;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.cc-sha {
  font-family: inherit;
  color: var(--gold);
  text-decoration: none;
  font-size: 10px;
  letter-spacing: 0.04em;
}
a.cc-sha:hover { color: var(--accent); }
.cc-loc {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.cc-loc-add { color: var(--ok); }
.cc-loc-rm  { color: var(--bad); }
.cc-repo    { font-size: 10px; }
.cc-task {
  margin-top: 4px;
  font-size: 11px;
}
.cc-files {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
}
.cc-file {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.cc-file-path {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--muted);
}
.cc-file-loc { font-variant-numeric: tabular-nums; }
.cc-file-more button,
.cc-blocker-toggle {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 10px;
  text-decoration: underline;
}
.cc-blocker {
  margin-top: 4px;
  font-size: 11px;
  color: var(--bad);
  white-space: pre-wrap;
}
.cc-summary {
  margin-top: 4px;
  font-size: 11px;
}

/* Card tile — generic placeholder for unknown kinds. */
.card-tile {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
}
.card-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
}
.card-tile-kind { letter-spacing: 0.06em; text-transform: uppercase; }
.card-tile-title { margin-top: 2px; color: var(--text); }
.card-tile-body { margin-top: 2px; font-size: 11px; }
.card-tile-payload {
  margin: 4px 0 0;
  padding: 4px 6px;
  font-size: 10px;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  white-space: pre-wrap;
  max-height: 120px;
  overflow: auto;
}

/* Mobile / narrow: collapse to single column. */
@media (max-width: 900px) {
  .top-bar, .layout { grid-template-columns: 1fr; }
}
