/* Aurum Command — refined styles.
   Mode: Operate. Identity kept (dark rail, gold accent, Space Grotesk + Inter);
   precision over decoration. Spacing on a 4px scale. */
:root {
  --ink: #14161A;
  --ink-2: #3E434D;
  --muted: #5A5F6B;
  --line: #E3E5E9;
  --line-2: #EEF0F3;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --hover: #F9F9FA;
  --nav: #111318;
  --nav-2: #1B1E25;
  --nav-ink: #E8E9EC;
  --nav-muted: #A3A7B0;
  --gold: #D4A62A;
  --gold-ink: #8A6400;
  --gold-soft: #FBF3DC;
  --good: #2E7D4F;
  --good-soft: #E3F3E9;
  --warn: #9A4F00;
  --warn-soft: #FDF0DE;
  --bad: #B3261E;
  --bad-soft: #FBE7E5;
  --blue: #1F4E9A;
  --blue-soft: #E6EEFB;
  --radius: 12px;
  --radius-sm: 8px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: #C9CDD4 transparent;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
::selection { background: var(--gold-soft); color: var(--ink); }
input, textarea { caret-color: var(--gold-ink); }
h1, h2, h3 { font-family: "Space Grotesk", Inter, system-ui, sans-serif; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 600; line-height: 1.15; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { text-wrap: pretty; }
a { color: var(--gold-ink); text-underline-offset: 3px; }
a:hover { color: #5E4400; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 6px; }
.nav :focus-visible { outline-color: var(--gold); }
.num, td, .stat-value, .nav-count { font-variant-numeric: tabular-nums; }

/* ---------- layout */
.app { min-height: 100vh; display: flex; flex-wrap: wrap; }
.nav { flex: 1 1 240px; max-width: 100%; background: var(--nav); color: var(--nav-ink); padding: 24px 12px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; background: var(--gold); color: var(--nav); display: grid; place-items: center; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 18px; }
.brand-name { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 16px; white-space: nowrap; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--nav-muted); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); color: #D5D7DC; background: none; border: 0; text-align: left; cursor: pointer; font-size: 14px; transition: background-color 150ms ease, color 150ms ease; }
.nav-item[aria-current="page"] { background: #2A2410; color: #F2CE6B; font-weight: 600; }
.nav-count { font-size: 12px; color: var(--nav-muted); }
.nav-foot { margin-top: auto; padding: 12px; border-radius: var(--radius-sm); background: var(--nav-2); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.nav-foot .muted { color: var(--nav-muted); font-size: 12px; }
.nav-foot button { align-self: flex-start; margin-top: 6px; background: none; border: 1px solid #3A3E48; color: var(--nav-ink); border-radius: 6px; padding: 0 10px; min-height: 32px; cursor: pointer; transition: background-color 150ms ease, transform 160ms var(--ease-out); }
.main { flex: 999 1 560px; min-width: 0; padding: 32px 40px 64px; display: flex; flex-direction: column; gap: 24px; max-width: 1480px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; padding-bottom: 4px; }
.page-head .titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head .sub { margin: 0; color: var(--muted); font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.grow { flex: 999 1 480px; min-width: 0; }
.side { flex: 1 1 300px; min-width: 0; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }

/* ---------- surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.small { font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }
.list { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; gap: 12px; align-items: flex-start; }
.list .meta { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; }
.dot.good { background: var(--good); } .dot.bad { background: var(--bad); } .dot.warn { background: #C77800; } .dot.next { background: var(--gold); } .dot.idle { background: #B8BCC4; }

/* summary strip (replaces the big-number tiles) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--card); padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; text-align: left; border: 0; border-radius: 0; color: inherit; min-height: 88px; }
button.stat { cursor: pointer; transition: background-color 150ms ease; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-family: "Space Grotesk", sans-serif; font-size: 24px; font-weight: 600; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat.alert .stat-value { color: var(--bad); }
button.stat .stat-label::after { content: " →"; color: var(--muted); opacity: 0; transition: opacity 150ms ease; }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; background: #F1F2F4; color: var(--ink-2); }
.badge.idea, .badge.planned, .badge.not_started, .badge.not_live, .badge.question { background: #F1F2F4; color: var(--ink-2); }
.badge.specced, .badge.in_progress, .badge.building, .badge.decision { background: var(--blue-soft); color: var(--blue); }
.badge.testing { background: var(--gold-soft); color: #6B4E00; }
.badge.live, .badge.healthy, .badge.connected, .badge.done, .badge.decided { background: var(--good-soft); color: var(--good); }
.badge.paused, .badge.retired, .badge.not_needed, .badge.closed { background: #ECEDEF; color: var(--muted); }
.badge.warning, .badge.risk { background: var(--warn-soft); color: var(--warn); }
.badge.failing, .badge.broken, .badge.blocked { background: var(--bad-soft); color: var(--bad); }
.prio { flex: 0 0 auto; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-weight: 700; font-size: 12px; background: #F1F2F4; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.prio.p1 { background: var(--gold); color: var(--nav); }
.prio.p2 { background: var(--gold-soft); color: #6B4E00; }

/* ---------- bars */
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar-rows { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr) 40px; gap: 10px 16px; align-items: center; font-size: 14px; }
.bar-rows .n { text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.seg-idea { background: #C9CDD4; } .seg-specced { background: #7FA8E0; } .seg-building { background: #2F5FA8; } .seg-testing { background: var(--gold); } .seg-live { background: var(--good); } .seg-paused { background: #8A8F99; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }

/* ---------- roadmap timeline (no boxes inside boxes) */
.timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; }
.tl { border-top: 3px solid var(--line); padding: 12px 0 4px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl.in_progress { border-top-color: var(--gold); }
.tl.done { border-top-color: var(--good); }
.tl.blocked { border-top-color: var(--bad); }
.tl .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl .title { font-weight: 600; font-size: 14px; }
.tl .badge { align-self: flex-start; margin-top: 2px; }
.tl .meta { font-size: 12px; color: var(--muted); }

/* ---------- tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th button { background: none; border: 0; padding: 0; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 12px; }
td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; transition: background-color 120ms ease; }
td .name { font-weight: 600; }
td .meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- controls */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); min-width: 0; }
.field input, .field select, .field textarea { min-height: 40px; padding: 8px 12px; border: 1px solid #D5D8DE; border-radius: var(--radius-sm); background: #fff; color: var(--ink); font-size: 14px; font-weight: 400; width: 100%; transition: border-color 150ms ease, box-shadow 150ms ease; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold-ink); box-shadow: 0 0 0 3px rgba(212, 166, 42, 0.25); }
.field input[readonly], .field textarea[readonly], .field select:disabled { background: var(--bg); color: var(--ink-2); }
.field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.field.check { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; min-height: 40px; }
.field.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--gold-ink); }
.btn { min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid #D5D8DE; background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: background-color 150ms ease, border-color 150ms ease, transform 160ms var(--ease-out); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.danger { color: var(--bad); border-color: #F0C2BE; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn:active:not(:disabled), .nav-foot button:active, .nav-item:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--gold-ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.row-link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; text-align: left; cursor: pointer; text-decoration: none; font-size: inherit; line-height: inherit; }

/* ---------- side sheet (agent and record editor) */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--card); }
dialog.sheet { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(640px, 100vw); max-width: 100vw; border-radius: 16px 0 0 16px; box-shadow: -12px 0 40px rgba(17, 19, 24, 0.16);
  transition: transform 300ms var(--ease-drawer), opacity 200ms ease, overlay 300ms allow-discrete, display 300ms allow-discrete; }
dialog.sheet:not([open]) { transform: translateX(32px); opacity: 0; }
@starting-style { dialog.sheet[open] { transform: translateX(32px); opacity: 0; } }
dialog::backdrop { background: rgba(17, 19, 24, 0.40); transition: background-color 200ms ease, overlay 200ms allow-discrete, display 200ms allow-discrete; }
@starting-style { dialog[open]::backdrop { background: rgba(17, 19, 24, 0); } }
.dlg { display: flex; flex-direction: column; height: 100%; }
.dlg-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-head .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; font-family: Inter, sans-serif; margin-top: 2px; }
.dlg-body { flex: 1; padding: 20px 24px 28px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; align-content: start; }
.dlg-body .wide { grid-column: 1 / -1; }
.dlg-body > .dlg-section:first-child { border-top: 0; padding-top: 0; }
.dlg-section { grid-column: 1 / -1; font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.dlg-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; background: var(--card); }
.dlg-msg { margin: 0; align-self: center; font-size: 13px; color: var(--ink-2); flex: 1 1 200px; }
.dlg-msg[data-kind="error"] { color: var(--bad); font-weight: 600; }
.dlg-msg:empty { display: none; }
.dlg-foot .right { display: flex; gap: 10px; margin-left: auto; }
.close-x { background: none; border: 0; cursor: pointer; color: var(--muted); width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center; transition: background-color 150ms ease, transform 160ms var(--ease-out); }
.close-x:active { transform: scale(0.95); }

/* ---------- banners, auth, toast */
.banner { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.banner.demo { background: var(--gold-soft); color: #5E4400; border: 1px solid #EBD48E; }
.banner.error { background: var(--bad-soft); color: var(--bad); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--nav); }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand-name { color: var(--ink); }
.auth-card .brand-sub { color: var(--muted); }
.qr { width: 200px; height: 200px; align-self: center; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.secret { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 6px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22); z-index: 50;
  transition: opacity 300ms ease, transform 300ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translateY(8px); } }
.toast[hidden] { display: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--nav); color: var(--nav-ink); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre; margin: 0; }

/* ---------- hover only where a real pointer exists */
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: var(--nav-2); }
  .nav-foot button:hover { background: var(--nav-2); }
  .btn:hover:not(:disabled) { background: #F3F4F6; }
  .btn.primary:hover:not(:disabled) { background: #2B2E35; }
  .btn.danger:hover { background: var(--bad-soft); }
  button.stat:hover { background: var(--hover); }
  button.stat:hover .stat-label::after { opacity: 1; }
  tr.clickable:hover td { background: var(--hover); }
  .row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
  .close-x:hover { background: var(--bg); }
}

/* ---------- reduced motion: keep fades, drop movement */
@media (prefers-reduced-motion: reduce) {
  dialog.sheet, dialog.sheet:not([open]), .toast { transform: none !important; }
  @starting-style { dialog.sheet[open], .toast { transform: none; } }
  .btn:active, .nav-item:active, .nav-foot button:active, .close-x:active { transform: none; }
}

/* ---------- phones */
@media (max-width: 760px) {
  .nav { flex-basis: 100%; padding: 14px 12px 10px; gap: 10px; position: sticky; top: 0; z-index: 20; }
  .nav-list { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; scrollbar-width: none; }
  .nav-item { flex: 0 0 auto; white-space: nowrap; min-height: 44px; gap: 8px; }
  .nav-foot { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 8px 10px; margin-top: 0; }
  .nav-foot .muted { display: none; }
  .nav-foot button { margin-top: 0; }
  .main { padding: 20px 16px 48px; gap: 20px; }
  h1 { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-rows { grid-template-columns: minmax(100px, 140px) minmax(0, 1fr) 32px; }
  dialog.sheet { width: 100vw; border-radius: 0; }
  .dlg-foot .btn { min-height: 44px; }
}
