/* ARIA Ecosystem Dashboard — flat, dark-mode-safe, CSS-variable design system.
   No gradients. No emoji. Tabler-style outline icons (inline SVG in app.js).
   Metric cards + status pills + lane grid. */

:root {
  /* surfaces */
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2128;
  --bd: #3d444d;       /* component boundary — bumped to clear 3:1 non-text contrast */
  --bd-soft: #2b313a;  /* inner separators — slightly stronger than before */

  /* text — tuned to clear WCAG 4.5:1 body / 3:1 non-text on --bg/--panel */
  --fg: #e6edf3;
  --mut: #9da7b3;   /* was #8b949e (~3.9:1); #9da7b3 ≈ 5.6:1 on --bg */
  --dim: #8b95a3;   /* secondary; ≈ 4.6:1 on --bg — was #6e7681 (fails) */

  /* accents (flat, no gradient) */
  --acc: #58a6ff;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --grey: #6e7681;
  --purple: #bc8cff;

  --radius: 8px;
  --radius-lg: 12px;
  --gap: 14px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa; --panel: #ffffff; --panel-2: #f0f3f6;
    --bd: #c2cad3; --bd-soft: #d8dee4;
    --fg: #1f2328; --mut: #4a525c; --dim: #57606a;
  }
}

* { box-sizing: border-box; }

/* ── reduced motion — clear the whole vestibular-safety failure in one rule ──── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  min-height: 100vh;
}

/* ── auth gate ──────────────────────────────────────────────── */
#gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 100;
}
#gate .box {
  width: 360px; max-width: 90vw; background: var(--panel);
  border: 1px solid var(--bd); border-radius: var(--radius-lg); padding: 28px 26px;
}
#gate h2 { margin: 0 0 6px; font-size: 16px; }
#gate p { margin: 0 0 18px; color: var(--mut); font-size: 12px; line-height: 1.6; }
#gate input {
  width: 100%; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--bd);
  border-radius: var(--radius); color: var(--fg); font: inherit; margin-bottom: 12px;
}
#gate input:focus { outline: none; border-color: var(--acc); }
#gate button {
  width: 100%; padding: 10px; background: var(--acc); border: 0; border-radius: var(--radius);
  color: #04101f; font: inherit; font-weight: 600; cursor: pointer;
}
#gate .err { color: var(--red); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* ── header ─────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--bd); position: sticky; top: 0;
  background: var(--bg); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.brand .sub { color: var(--mut); font-size: 12px; }
.hbar { display: flex; align-items: center; gap: 10px; }

/* ── status pills ───────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--bd); color: var(--mut); background: var(--panel);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grey); }
.pill.ok    { color: var(--green); border-color: rgba(63,185,80,.4); }
.pill.ok .dot    { background: var(--green); }
.pill.warn  { color: var(--amber); border-color: rgba(210,153,34,.4); }
.pill.warn .dot  { background: var(--amber); }
.pill.bad   { color: var(--red); border-color: rgba(248,81,73,.4); }
.pill.bad .dot   { background: var(--red); }
.pill.info  { color: var(--acc); border-color: rgba(88,166,255,.4); }
.pill.info .dot  { background: var(--acc); }
.pill.muted .dot { background: var(--grey); }

/* ── layout ─────────────────────────────────────────────────── */
main { max-width: 1320px; margin: 0 auto; padding: 22px 24px 60px; }

.section { margin-bottom: 26px; }
.section > h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--mut); margin: 0 0 12px; font-weight: 600;
}

/* ── metric cards ───────────────────────────────────────────── */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap);
}
.metric {
  background: var(--panel); border: 1px solid var(--bd); border-radius: var(--radius-lg);
  padding: 16px 18px; position: relative;
}
.metric .ic { position: absolute; top: 14px; right: 14px; color: var(--dim); }
/* the action-driving "User gates" card gets a left accent so it wins the scan */
.metric.primary { border-left: 3px solid var(--acc); }
.metric .val { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--fg); letter-spacing: -.5px; }
.metric .val.ok { color: var(--green); }
.metric .val.warn { color: var(--amber); }
.metric .val.bad { color: var(--red); }
.metric .lbl { font-size: 12px; color: var(--mut); margin-top: 6px; }

/* ── generic card ───────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--gap); }
.card {
  background: var(--panel); border: 1px solid var(--bd); border-radius: var(--radius-lg); padding: 16px 18px;
}
.card h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--mut);
  margin: 0 0 12px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--bd-soft);
}
.row:last-child { border-bottom: 0; }
.row .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .name b { font-weight: 600; }
.row .name .meta { color: var(--dim); font-size: 11px; }
.mono { font-family: var(--mono); font-size: 11.5px; color: var(--mut); word-break: break-word; }

/* ── lane / product grid ────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.tile {
  background: var(--panel); border: 1px solid var(--bd); border-radius: var(--radius-lg);
  padding: 14px 15px; display: flex; flex-direction: column; gap: 8px;
}
.tile.reserved { border-style: dashed; opacity: .72; }
.tile .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tile .nm { font-weight: 600; font-size: 13px; line-height: 1.3; }
.tile .ln { color: var(--dim); font-size: 11px; font-family: var(--mono); }
.tile a { color: var(--acc); text-decoration: none; font-size: 11px; }
.tile a:hover { text-decoration: underline; }
.tile .socket { color: var(--dim); font-size: 11px; font-family: var(--mono); }

/* loop status mini-chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel-2); border: 1px solid var(--bd); border-radius: var(--radius);
  padding: 6px 10px; font-size: 12px; color: var(--mut);
}
.chip b { color: var(--fg); }

/* gates */
.gate {
  border: 1px solid rgba(210,153,34,.35); background: rgba(210,153,34,.06);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.gate .g-sum { color: var(--amber); font-size: 13px; }
.gate .g-ev { margin-top: 4px; }

.empty { color: var(--dim); font-size: 12px; padding: 6px 0; }

footer {
  border-top: 1px solid var(--bd); color: var(--dim); font-size: 11px;
  text-align: center; padding: 16px 24px; max-width: 1320px; margin: 0 auto;
}
footer.err { color: var(--red); }
.hidden { display: none !important; }
svg.ic { display: inline-block; vertical-align: middle; }

/* ── explicit RED data-absent banner (fail-safe state) ──────────────────────── */
#data-absent {
  max-width: 1320px; margin: 18px auto 0; padding: 14px 18px;
  background: rgba(248,81,73,.08); border: 1px solid rgba(248,81,73,.5);
  border-left: 4px solid var(--red); border-radius: var(--radius);
  color: var(--red); font-size: 13px; line-height: 1.6;
}
#data-absent code { font-family: var(--mono); color: var(--fg); }
body.data-absent .metric,
body.data-absent .tile,
body.data-absent .card { opacity: .35; }

/* ── responsive: small screens ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  main { padding: 16px 14px 48px; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .cards { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
}


/* ════════════════════════════════════════════════════════════
   MISSION CONTROL v1 appendix — tabs, approvals, feed, needs-you,
   inbox. Mobile-first: bottom tab bar, thumb-sized actions.
   Same flat design system; no gradients, no emoji.
   ════════════════════════════════════════════════════════════ */

/* ── tab panes ─────────────────────────────────────────────── */
.tabpane { display: none; }
.tabpane.active { display: block; }
.tab-intro { color: var(--mut); margin: 4px 0 14px; max-width: 640px; }

/* ── bottom tab bar (fixed, thumb-reachable) ───────────────── */
#tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--panel);
  border-top: 1px solid var(--bd);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 40;
}
body { padding-bottom: 76px; } /* keep content clear of the bar */
#gate ~ * #tabs { display: none; }
.tab-btn {
  appearance: none;
  background: none;
  border: 0;
  color: var(--mut);
  font: 11px/1.2 var(--sans);
  padding: 8px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  min-height: 56px;
}
.tab-btn .ic { width: 20px; height: 20px; }
.tab-btn.active { color: var(--acc); }
.tab-btn .badge {
  position: absolute;
  top: 4px; right: calc(50% - 22px);
  min-width: 17px; height: 17px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px; font-weight: 700;
  line-height: 17px;
  text-align: center;
  padding: 0 4px;
}
.badge.hidden { display: none; }

/* wide screens: KEEP the fixed bottom bar (tablet landscape is a primary
   surface) — just let the buttons breathe and center the strip */
@media (min-width: 900px) {
  #tabs {
    grid-template-columns: repeat(5, minmax(0, 160px));
    justify-content: center;
  }
  .tab-btn { flex-direction: row; gap: 8px; font-size: 13px; min-height: 50px; }
  .tab-btn .badge { position: static; margin-left: 2px; }
}

/* ── approvals ─────────────────────────────────────────────── */
.appr-card {
  background: var(--panel);
  border: 1px solid var(--bd);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.appr-what { font-size: 17px; font-weight: 700; line-height: 1.35; margin-bottom: 8px; }
.appr-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.appr-row { margin: 6px 0; color: var(--fg); }
.appr-row b { color: var(--mut); font-weight: 600; margin-right: 4px; }
.ok-line b, .ok-line { color: var(--green); }
.ok-line b { color: var(--green); opacity: .85; }
.bad-line, .bad-line b { color: var(--red); }
.warn-line { color: var(--amber); }
.appr-preview {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--acc); text-decoration: none;
  margin: 8px 0 4px; font-size: 13px;
}
.appr-preview:hover { text-decoration: underline; }
.appr-actions { display: flex; gap: 12px; margin-top: 12px; }
.btn-approve, .btn-deny {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px;
  border-radius: 10px;
  font-size: 15px; font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  transition: filter .15s ease, background .15s ease;
}
.btn-approve { background: var(--green); color: #08130a; }
.btn-deny { background: none; color: var(--red); border-color: var(--red); }
.btn-approve.armed { background: #2ea043; color: #fff; outline: 3px solid rgba(63,185,80,.35); }
.btn-deny.armed { background: var(--red); color: #fff; outline: 3px solid rgba(248,81,73,.35); }
.allclear {
  display: flex; gap: 12px; align-items: center;
  background: var(--panel);
  border: 1px solid var(--bd-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: var(--fg);
}
.allclear .ic { color: var(--green); width: 26px; height: 26px; flex: none; }

/* ── feed ──────────────────────────────────────────────────── */
.feed-item {
  display: flex; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--bd-soft);
}
.feed-item:last-child { border-bottom: 0; }
.f-ic { color: var(--mut); flex: none; margin-top: 2px; }
.f-text { line-height: 1.45; }
.f-time { margin-top: 2px; }

/* ── needs-you markdown ────────────────────────────────────── */
.md { padding: 16px 18px; overflow-x: auto; }
.md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.3; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15px; color: var(--acc); }
.md p { margin: 7px 0; line-height: 1.55; }
.md ul { margin: 6px 0; padding-left: 22px; }
.md li { margin: 4px 0; line-height: 1.5; }
.md blockquote {
  margin: 8px 0; padding: 6px 12px;
  border-left: 3px solid var(--bd);
  color: var(--mut);
}
.md code { background: var(--panel-2); border: 1px solid var(--bd-soft); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.md pre { background: var(--panel-2); border: 1px solid var(--bd-soft); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px; }
.md hr { border: 0; border-top: 1px solid var(--bd-soft); margin: 16px 0; }
.md a { color: var(--acc); }
.md del { color: var(--dim); }
.md .cb { font-family: var(--mono); color: var(--amber); }
.md .cb.done { color: var(--green); }
.md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 480px; }
.md th, .md td { border: 1px solid var(--bd-soft); padding: 6px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); }

/* ── inbox ─────────────────────────────────────────────────── */
#inbox-text {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  color: var(--fg);
  font: 15px/1.5 var(--sans);
  padding: 12px;
  resize: vertical;
}
#inbox-text:focus { outline: 2px solid var(--acc); border-color: var(--acc); }
#inbox-send {
  margin-top: 10px;
  min-height: 50px;
  width: 100%;
  background: var(--acc);
  color: #06121f;
  border: 0;
  border-radius: 10px;
  font: 700 15px var(--sans);
  cursor: pointer;
}
#inbox-send:active { filter: brightness(.9); }
.inbox-note { margin-top: 10px; min-height: 20px; }
#inbox-recent { margin-top: 18px; }
#inbox-recent h3 { color: var(--mut); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
@media (min-width: 900px) {
  #inbox-text, #inbox-send { max-width: 640px; display: block; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ARIA HQ v2 additions (5-tab layout) — appended to the v1 design system.
   Reuses existing tokens (--panel, --bd, --green, --amber, --red, --acc, etc.).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Today: 5 hero numbers ─────────────────────────────────── */
.heroes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--gap);
}
.hero {
  background: var(--panel);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  text-align: center;
}
.hero.primary { border-color: var(--acc); }
.hero-val {
  font: 700 30px/1.05 var(--sans);
  letter-spacing: -.5px;
  margin-bottom: 6px;
  word-break: break-word;
}
.hero-val.ok    { color: var(--green); }
.hero-val.warn  { color: var(--amber); }
.hero-val.bad   { color: var(--red); }
.hero-val.info  { color: var(--acc); }
.hero-val.muted { color: var(--dim); }
.hero-lbl { font-size: 12px; font-weight: 600; color: var(--fg); }
.hero-sub { font-size: 11px; color: var(--mut); margin-top: 3px; }

/* ── System: surface link chips ────────────────────────────── */
.linkchips { display: flex; flex-wrap: wrap; gap: 10px; }
a.linkchip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border: 1px solid var(--bd); border-radius: 999px;
  background: var(--panel); color: var(--fg); text-decoration: none; font-size: 13px;
}
a.linkchip:hover { border-color: var(--acc); }
a.linkchip .pill { padding: 0; border: 0; background: transparent; }
a.linkchip .pill .dot { margin: 0; }

/* small colour helpers reused by the Money rows */
.mono.ok  { color: var(--green); }
.mono.warn{ color: var(--amber); }
.mono.bad { color: var(--red); }

/* ── Control tier: estate power (HALT / RESUME) ────────────── */
.power-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.btn-danger, .btn-safe {
  padding: 12px 20px; border-radius: var(--radius); font: 600 14px var(--sans);
  cursor: pointer; border: 1px solid transparent;
}
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-safe { background: var(--panel-2); color: var(--fg); border-color: var(--bd); }
.btn-safe:hover { border-color: var(--acc); }

/* red type-to-confirm overlay */
.halt-modal {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(120, 8, 8, .78); padding: 20px;
}
.halt-modal.resume { background: rgba(6, 60, 20, .80); }
.halt-modal.hidden { display: none; }
.halt-box {
  width: 420px; max-width: 94vw; background: var(--panel); border: 2px solid var(--red);
  border-radius: var(--radius-lg); padding: 26px 24px; text-align: center;
}
.halt-modal.resume .halt-box { border-color: var(--green); }
.halt-mark {
  font: 800 34px/1 var(--sans); letter-spacing: 4px; color: var(--red); margin-bottom: 14px;
}
.halt-modal.resume .halt-mark { color: var(--green); }
.halt-box h2 { margin: 0 0 8px; font-size: 18px; }
.halt-box p { margin: 0 0 16px; color: var(--mut); font-size: 13px; line-height: 1.6; }
.halt-box label { display: block; font-size: 12px; color: var(--fg); margin-bottom: 8px; }
.halt-box input {
  width: 100%; padding: 12px; background: var(--panel-2); border: 1px solid var(--bd);
  border-radius: var(--radius); color: var(--fg); font: 600 16px var(--mono);
  text-align: center; letter-spacing: 2px; margin-bottom: 18px;
}
.halt-box input:focus { outline: none; border-color: var(--red); }
.halt-modal.resume .halt-box input:focus { border-color: var(--green); }
.halt-actions { display: flex; gap: 12px; }
.halt-actions button { flex: 1; }
