/* ============================================================================
   re-forge dashboard — matches the re-forge.vercel.app brand exactly.
   Cool paper · Instrument Serif display · Inter Tight UI · JetBrains Mono labels.
   Indigo primary, amber + green-win + red semantics, dark signature panels.
   ========================================================================== */

:root {
  --paper:        #F7F8FA;
  --paper-raised: #FFFFFF;
  --surface:      #FFFFFF;
  --ink:          #14161D;
  --ink-soft:     #515968;
  --ink-faint:    #8B909C;
  --line:         #E6E8EE;
  --line-strong:  #D3D7E0;

  --primary:        #4F46E5;
  --primary-bright: #6D5DFC;
  --primary-tint:   #EEECFB;
  --accent:         #F2A93B;   /* amber — review */
  --accent-tint:    #FBF0DC;
  --danger:         #EF4444;
  --danger-soft:    #B91C1C;
  --danger-tint:    #FBE4E4;
  --win:            #1B8F55;   /* green-win — banked / measured (text-safe) */
  --win-bright:     #35D07F;
  --win-tint:       #E2F6EC;

  --panel-deep:   #11121B;
  --panel-raised: #1C1D2B;
  --panel-line:   #34374F;
  --panel-ink:    #F3F0FF;
  --panel-muted:  #9EA1BD;

  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-ui:      "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-sm: 8px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --maxw: 1200px;
  --shadow:   0 1px 2px rgba(20,22,29,.04), 0 12px 32px -16px rgba(20,22,29,.10);
  --shadow-p: 0 24px 60px -24px rgba(17,18,27,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--primary-tint); }
a { color: var(--primary); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- mono label (the brand's signature) ---------- */
.mono-label {
  font-family: var(--font-mono); font-weight: 700; font-size: 12px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 30;
  background: rgba(247,248,250,.85); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.masthead-in { max-width: var(--maxw); margin: 0 auto; padding: 0 32px; height: 64px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--ink);
  color: #fff; display: grid; place-items: center; font-size: 15px; flex: none;
  box-shadow: 0 2px 6px rgba(20,22,29,.2);
}
.brand .word { font-family: var(--font-ui); font-weight: 700; font-size: 18px; letter-spacing: -.02em; color: var(--ink); white-space: nowrap; }
.brand .tag { font-family: var(--font-mono); font-weight: 700; font-size: 11px; letter-spacing: .14em; color: var(--ink-faint); margin-left: 2px; }
.nav { display: flex; align-items: center; gap: 3px; margin-left: 14px; }
.nav a {
  font-family: var(--font-mono); font-weight: 700; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-faint); text-decoration: none; padding: 7px 9px; border-radius: var(--r-sm);
  white-space: nowrap;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.nav a:hover { color: var(--ink); background: rgba(20,22,29,.04); }
.nav a.active { color: var(--primary); }

/* "More" cluster: secondary views (Agentic · Repo Graph · Heartbeat) stay one click
   away without pushing the masthead past one clean row. Pure <details> — no JS. */
.navmore { position: relative; }
.navmore > summary {
  list-style: none; cursor: pointer; user-select: none;
  font-family: var(--font-mono); font-weight: 700; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-faint); padding: 7px 9px; border-radius: var(--r-sm); white-space: nowrap;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.navmore > summary::-webkit-details-marker { display: none; }
.navmore > summary::marker { content: ""; }
.navmore > summary::after { content: "\25BE"; margin-left: 5px; font-size: 9px; opacity: .65; }
.navmore[open] > summary::after { content: "\25B4"; }
.navmore > summary:hover { color: var(--ink); background: rgba(20,22,29,.04); }
.navmore[open] > summary { color: var(--ink); background: rgba(20,22,29,.06); }
.navmore.on > summary { color: var(--primary); }
.navmore-menu {
  position: absolute; top: calc(100% + 7px); left: 0; min-width: 172px;
  display: flex; flex-direction: column; gap: 1px; padding: 6px;
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: 0 14px 34px -14px rgba(20,22,29,.34);
  z-index: 40;
}
.navmore-menu a { display: block; padding: 8px 10px; }
.spacer { flex: 1; }
.tok { display: flex; align-items: center; gap: 7px; }
.tok .org { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; color: var(--ink-faint); margin-right: 2px; white-space: nowrap; }
/* identity chip: one line, never a 3-row wrap; long names ellipsize */
#whoami { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
/* Signed-in (Supabase session OR a saved device key): the raw key input + Load are
   noise — and the key must never sit on screen. reforge-auth.js stamps .authed. */
.tok.authed input, .tok.authed #load { display: none; }
/* mid-width squeeze: keep one clean row before the collapse. 7 primary tabs + More fit
   at full size well below the old 1360 trigger, so the squeeze starts later and is gentler. */
@media (max-width: 1240px) {
  .nav a, .navmore > summary { font-size: 10.5px; letter-spacing: .05em; padding: 6px 8px; }
  .navmore-menu a { padding: 8px 10px; }
  .tok .org { display: none; }
}
.tok input {
  font-family: var(--font-mono); font-size: 12px; width: 120px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--paper-raised); color: var(--ink);
  transition: border-color .15s, width .25s var(--ease);
}
.tok input:focus { outline: none; border-color: var(--primary); width: 184px; }
.btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px; padding: 8px 16px; border-radius: var(--r-pill);
  cursor: pointer; border: 1px solid var(--line-strong); background: var(--paper-raised); color: var(--ink);
  white-space: nowrap;
  transition: all .15s var(--ease);
}
.btn:hover { border-color: var(--ink-faint); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 10px -2px rgba(79,70,229,.5); }
.btn.primary:hover { background: var(--primary-bright); }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 46px 32px 96px; }
.pagehead { margin-bottom: 36px; }
.pagehead .eyebrow { margin-bottom: 16px; }
.pagehead h1 {
  font-family: var(--font-display); font-weight: 400; font-size: 50px; line-height: 1.0;
  letter-spacing: -.025em; margin: 0 0 12px; color: var(--ink);
}
.pagehead .lede { font-size: 17px; color: var(--ink-soft); margin: 0; max-width: 62ch; line-height: 1.5; }
.pagehead .lede em { font-style: normal; color: var(--ink); }

.eyebrow {
  font-family: var(--font-mono); font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 18px; display: flex; align-items: center; gap: 10px;
}
/* Decorative brand accent before a section eyebrow — NOT a live/online status.
   Uses the brand indigo (--primary), never the semantic win-green (--win-bright),
   so a viewer cannot read this purely-decorative dot as a connection/health signal
   the page does not actually compute. (honesty-labels R-006.) A genuine status dot
   that IS server-checked keeps its semantic colour locally — e.g. the post-mint
   "Workspace ready" dot via signup's .ok-eyebrow .dot override, and the audit-chain
   dot on / driven by /api/audit/verify. */
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex: none; }
.eyebrow.line::after { content: ""; flex: 1; height: 1px; background: var(--line); margin-left: 4px; }
section.block { margin-top: 46px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.pad { padding: 26px 28px; }

/* ---------- dark signature panel (the hero) ---------- */
.panel {
  position: relative; background: var(--panel-deep); border-radius: var(--r-xl);
  box-shadow: var(--shadow-p); color: var(--panel-ink); overflow: hidden;
  border: 1px solid #20222F;
}
.panel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 88% -10%, rgba(109,93,252,.22), transparent 60%);
}
.panel-in { position: relative; padding: 26px 30px 30px; }
.panel-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.tl { width: 11px; height: 11px; border-radius: 50%; }
.tl.r { background: #ff5f57; } .tl.y { background: #febc2e; } .tl.g { background: #28c840; }
.panel-bar .lbl { font-family: var(--font-mono); font-weight: 700; font-size: 11px; letter-spacing: .16em; color: var(--panel-muted); margin-left: auto; }
.panel .lab { font-family: var(--font-mono); font-weight: 700; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--panel-muted); }
.panel .big { font-family: var(--font-display); font-weight: 400; font-size: 76px; line-height: .9; letter-spacing: -.03em; color: #fff; font-variant-numeric: tabular-nums; margin: 10px 0 0; }
.panel .sub { font-family: var(--font-mono); font-size: 12.5px; color: var(--panel-muted); margin-top: 14px; letter-spacing: .02em; }
.panel .sub b { color: var(--win-bright); font-weight: 500; }
.panel .sub .amber { color: var(--accent); }

/* KPI grid */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 22px; transition: border-color .15s, transform .15s var(--ease); }
.kpi:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kpi .lab { font-family: var(--font-mono); font-weight: 700; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 12px; }
.kpi .val { font-family: var(--font-display); font-weight: 400; font-size: 36px; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; line-height: .95; }
.kpi .val.green { color: var(--win); }
.kpi .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; line-height: 1.4; }
.kpi .sub .pos { color: var(--win); font-weight: 600; }

/* lever rows — dot meters */
.lever { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; padding: 18px 0; border-top: 1px solid var(--line); align-items: baseline; }
.lever:first-child { border-top: 0; padding-top: 4px; }
.lever .name { font-size: 15.5px; color: var(--ink); font-weight: 600; }
.lever .usd { font-family: var(--font-mono); font-size: 15px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.lever .usd .up { color: var(--ink-faint); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; margin-right: 5px; }
.lever .meta { grid-column: 1 / 2; font-size: 13px; color: var(--ink-soft); margin-top: 4px; line-height: 1.45; }
.lever .dots { grid-column: 1 / 3; margin-top: 11px; letter-spacing: 3px; font-size: 8px; line-height: 1; user-select: none; }
.lever .dots b { color: var(--primary); }
.lever .dots i { color: var(--line-strong); }

/* pills */
.pill { display: inline-block; font-family: var(--font-mono); font-weight: 700; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 9px; border-radius: var(--r-pill); vertical-align: middle; margin-left: 9px; }
.pill.bound    { background: var(--accent-tint); color: #9a6a14; }
.pill.recur    { background: var(--primary-tint); color: var(--primary); }
.pill.dedup    { background: #EEF0F4; color: var(--ink-soft); }
.pill.measured { background: var(--win-tint); color: var(--win); }
.pill.cap      { background: var(--danger-tint); color: var(--danger-soft); }

/* charts */
.chart-box { position: relative; height: 290px; }
.chart-box.short { height: 220px; }
.chart-box > canvas { max-width: 100% !important; max-height: 100% !important; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-faint); font-size: 13.5px; }

/* tables */
table.ed { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ed th { text-align: left; font-family: var(--font-mono); font-weight: 700; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); padding: 0 12px 11px; border-bottom: 1px solid var(--line); }
table.ed th.r, table.ed td.r { text-align: right; }
table.ed td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ed tbody tr { transition: background .12s; }
table.ed tbody tr:hover td { background: var(--paper); }
table.ed .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* anomaly list */
.anoms { margin: 0; }
.anom { display: flex; gap: 13px; align-items: flex-start; padding: 13px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink); line-height: 1.45; }
.anom:first-child { border-top: 0; }
.anom .sev { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }

/* helpers */
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 22px; }
.muted { color: var(--ink-soft); }
.foot { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; margin-top: 14px; max-width: 80ch; }
.foot em { font-style: normal; color: var(--ink); font-weight: 600; }
.more { font-size: 13px; color: var(--ink-soft); margin-top: 18px; font-family: var(--font-mono); }
.more a { color: var(--primary); text-decoration: none; }
.more a:hover { text-decoration: underline; }

@media (max-width: 880px) {
  .grid2 { grid-template-columns: 1fr; }
  .wrap { padding-left: 18px; padding-right: 18px; }
  /* Two-row masthead: brand + identity on top, the nav on its own full-width row below.
     Was `display:none`, which left every page but Overview unreachable on a phone. */
  .masthead-in {
    padding: 9px 18px; height: auto; flex-wrap: wrap; row-gap: 8px;
  }
  /* The nav becomes a single swipeable strip holding EVERY destination. The "More"
     grouping is dissolved with display:contents so its links join the strip inline
     rather than opening a dropdown that a scroll container would clip. Pure CSS, no JS. */
  .nav {
    order: 3; width: 100%; margin-left: 0; gap: 2px;
    overflow-x: auto; flex-wrap: nowrap;
    scroll-snap-type: x proximity;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .navmore, .navmore-menu { display: contents; }
  .navmore > summary { display: none; }
  .nav > a, .navmore-menu a { flex: 0 0 auto; scroll-snap-align: start; }
  .navmore-menu a { padding: 7px 9px; }   /* strip sizing, not the dropdown's block padding */
  .panel .big { font-size: 58px; }
  .pagehead h1 { font-size: 38px; }
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .55s var(--ease) both; }
.rise.d1 { animation-delay: .05s; } .rise.d2 { animation-delay: .1s; } .rise.d3 { animation-delay: .16s; } .rise.d4 { animation-delay: .22s; }

.connect { text-align: center; padding: 90px 20px; }
.connect h2 { font-family: var(--font-display); font-weight: 400; font-size: 30px; color: var(--ink); margin: 0 0 8px; letter-spacing: -.02em; }
.connect p { color: var(--ink-soft); font-size: 15px; }
