/* KRV OS v0.3.2 — three-page composition · visual register mirrors pulse.krv.co */
/* Adobe Typekit kit lso5kkg loaded via JS in index.html (matches pulse.krv.co pattern) */

:root {
  --bg: #0d1f17;
  --surface: #142d23;
  --surface-2: #1a3829;
  --surface-3: #1f4232;
  --border: rgba(247, 243, 231, 0.08);
  --border-strong: rgba(247, 243, 231, 0.18);
  --fg: #f7f3e7;
  --fg-muted: rgba(247, 243, 231, 0.55);
  --fg-faint: rgba(247, 243, 231, 0.4);
  --fg-quiet: rgba(247, 243, 231, 0.18);

  --accent: #4a8f7e;
  --accent-deep: #1e6b52;
  --accent-soft: rgba(74, 143, 126, 0.10);
  --accent-mid: #2e8068;

  --gold: #c49a2a;
  --gold-soft: rgba(196, 154, 42, 0.15);

  --red: #8b2e2e;
  --red-bright: #c05040;
  --red-soft: rgba(139, 46, 46, 0.18);

  --display: 'miller-display', Georgia, 'Times New Roman', serif;
  --body: 'articulat-cf', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --topbar-h: 72px;
  --meta-h: 28px;
  --ribbon-h: 32px;
  --footer-h: 0px;
  --chrome: calc(var(--topbar-h) + var(--meta-h) + var(--ribbon-h));

  /* aliases so KRV OS and pulse.krv.co share the exact same tokens */
  --card: var(--surface);
  --card2: var(--surface-2);
  --cream: var(--fg);
  --hi: #E7F0EB;
  --accent-lt: #6FB39E;
  --cream-dim: var(--fg-muted);
  --cream-faint: var(--fg-quiet);
  --border-soft: var(--border);

  /* rail + page-max are LOCKED to pulse.krv.co — do not drift */
  --rail: clamp(40px, 5vw, 80px);
  --page-max: 1440px;

  --sans: var(--body);
  --serif: var(--display);
}

/* deck mode collapses meta + ribbon, hides topbar */
body.mode-deck { --meta-h: 0px; --ribbon-h: 0px; }
body.mode-no-ribbon { --ribbon-h: 0px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--fg); }

/* ----- typography ----- */
.eyebrow {
  font-family: var(--body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
}

.eyebrow-muted {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.display-xl {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(36px, 4.4vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
}

.display-lg {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(24px, 2.8vw, 36px);
  line-height: 1.1;
  margin: 8px 0 12px;
}

.body { font-size: 14px; line-height: 1.55; color: var(--fg-muted); margin: 0; }
.body-sm { font-size: 12px; line-height: 1.5; color: var(--fg-muted); margin: 0; }
.tabular { font-variant-numeric: tabular-nums lining-nums; }

/* ===================================================== */
/* TOPBAR · mirrors pulse.krv.co exactly                  */
/* ===================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}
.topbar-inner {
  height: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--rail);
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; }

.tb-wordmark { display: inline-flex; align-items: center; line-height: 0; }
.tb-wordmark img { display: block; height: 32px; width: auto; }

.tb-nav { display: flex; align-items: center; gap: 32px; }
.tb-nav a {
  font-family: var(--body);
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg); text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.tb-nav a:hover { color: var(--accent-lt); }
.tb-nav a.is-active { color: var(--accent); }
.tb-nav a.is-active:hover { color: var(--accent); }

.tb-divider { width: 1px; height: 18px; background: rgba(247,243,231,0.18); margin: 0 24px; }
.tb-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; color: var(--fg); text-decoration: none;
  transition: color 0.15s;
}
.tb-icon:hover { color: var(--accent-lt); }
.tb-icon.is-active { color: var(--accent); }
.tb-icon svg { display: block; width: 16px; height: 16px; }

/* ===================================================== */
/* META STRIP · toggles + issue label                    */
/* ===================================================== */
.meta-strip {
  position: fixed; top: var(--topbar-h); left: 0; right: 0;
  height: var(--meta-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 49;
}
.meta-strip-inner {
  height: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--rail);
  display: flex; align-items: center; justify-content: space-between;
}
.ms-seg {
  font-family: var(--body);
  font-size: 9px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--fg-muted); white-space: nowrap;
}
.ms-seg strong { color: var(--fg); font-weight: 600; }
.ms-seg .accent { color: var(--accent); }
.ms-slash { color: var(--accent); margin: 0 10px; font-family: var(--body); font-weight: 300; }

.ms-toggle {
  font-family: var(--body);
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--fg-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 4px 10px; margin-right: 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ms-toggle:hover { color: var(--fg); border-color: var(--accent); }
.ms-toggle .ms-toggle-label-deck,
.ms-toggle .ms-toggle-label-off { display: none; }
body.mode-deck #modeToggleInline .ms-toggle-label-terminal { display: none; }
body.mode-deck #modeToggleInline .ms-toggle-label-deck { display: inline; color: var(--accent); }
body.mode-no-ribbon #ribbonToggle .ms-toggle-label-on { display: none; }
body.mode-no-ribbon #ribbonToggle .ms-toggle-label-off { display: inline; color: var(--red-bright); }
body.mode-deck #ribbonToggle { display: none; }
body.mode-deck .topbar { display: none; }
body.mode-deck .meta-strip { display: none; }

/* ===================================================== */
/* RIBBON · mirrors pulse.krv.co (lvl/lbl/delta spans)    */
/* ===================================================== */
.ribbon {
  position: fixed; top: calc(var(--topbar-h) + var(--meta-h));
  left: 0; right: 0; height: var(--ribbon-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  display: flex; align-items: center;
  z-index: 49;
  transition: opacity 0.2s;
}
body.mode-deck .ribbon { display: none; }
body.mode-no-ribbon .ribbon { display: none; }

.ribbon-track {
  display: flex; gap: 48px;
  white-space: nowrap;
  animation: ribbon-scroll 90s linear infinite;
  font-family: var(--body);
  font-size: 10px; letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding-left: calc( max(0px, (100vw - var(--page-max)) / 2) + var(--rail) );
}
.ribbon-track > span { display: inline-flex; align-items: center; gap: 10px; }
.ribbon-track > span::before { content: '·'; color: var(--accent); margin-right: 4px; font-size: 14px; }
.ribbon-track .lbl { color: var(--fg-muted); }
.ribbon-track .lvl { color: var(--fg); font-weight: 600; letter-spacing: 0.06em; }
.ribbon-track .delta { font-style: normal; letter-spacing: 1.4px; font-weight: 500; }
.ribbon-track .delta.up { color: var(--accent-lt); }
.ribbon-track .delta.down { color: var(--red-bright); }
.ribbon-track .delta.flat { color: var(--fg-quiet); }
@keyframes ribbon-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ===================================================== */
/* DECK NAV · right-edge dots + mode glyph (Pulse parity) */
/* ===================================================== */
.deck-nav {
  position: fixed; right: 18px; top: 50%;
  transform: translateY(-50%);
  z-index: 9998;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; width: 16px;
  pointer-events: none;
}
.deck-nav .dn-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(247,243,231,0.18);
  transition: background 0.25s, transform 0.25s;
  pointer-events: auto; cursor: pointer;
}
.deck-nav .dn-dot.active { background: var(--fg); transform: scale(1.5); }
.deck-nav .dn-dot:hover { background: var(--accent-lt); }

.mode-glyph {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(247,243,231,0.04);
  border: 1px solid rgba(247,243,231,0.22);
  border-radius: 2px;
  font-family: var(--body);
  font-size: 9px; font-weight: 600; line-height: 1;
  color: var(--fg-muted);
  cursor: pointer; user-select: none;
  padding: 0; margin: 0 0 10px;
  pointer-events: auto;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  box-sizing: border-box;
}
.mode-glyph:hover { color: var(--fg); border-color: var(--accent); background: rgba(74,143,126,0.16); }
.mode-glyph .mg-letter { line-height: 1; }
.mode-glyph .mg-d { display: inline; }
.mode-glyph .mg-t { display: none; }
body.mode-deck .mode-glyph .mg-d { display: none; }
body.mode-deck .mode-glyph .mg-t { display: inline; color: var(--accent); }

.deck-hint {
  position: fixed; left: 18px; bottom: 44px;
  z-index: 9998;
  background: rgba(20,45,35,0.92);
  color: var(--fg-muted);
  font-family: var(--body);
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.16em;
  padding: 7px 12px;
  opacity: 1; transition: opacity 0.6s 4.5s;
  pointer-events: none;
}
.deck-hint.faded { opacity: 0; }
.deck-hint kbd {
  font-family: var(--body); font-weight: 700;
  color: var(--fg);
  background: rgba(247,243,231,0.08);
  padding: 1px 6px; margin: 0 2px;
  font-size: 9px; letter-spacing: 0.08em;
}

/* ===================================================== */
/* PAGES · vertical document scroll (each page flows)     */
/* Chrome stays fixed at top; pages scroll under it.       */
/* ===================================================== */
.pages {
  padding-top: calc(var(--topbar-h) + var(--meta-h) + var(--ribbon-h));
  scroll-behavior: smooth;
  transition: padding-top 0.2s;
}
body.mode-deck .pages { padding-top: 0; }
body.mode-no-ribbon .pages { padding-top: calc(var(--topbar-h) + var(--meta-h)); }

.page {
  min-height: calc(100vh - var(--topbar-h) - var(--meta-h) - var(--ribbon-h));
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
body.mode-deck .page { min-height: 100vh; }
body.mode-no-ribbon .page { min-height: calc(100vh - var(--topbar-h) - var(--meta-h)); }
.page-inner {
  /* rail + page-max LOCKED to pulse.krv.co — wordmark/content sit on same gridline */
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 32px var(--rail);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===================================================== */
/* PAGE 1 · THE PROMISE                                   */
/* ===================================================== */
.p1-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  align-items: center;
  flex: 0 0 auto;
  padding-bottom: 12px;
}

.p1-hero { padding-right: 12px; }
.p1-hero .eyebrow { margin-bottom: 16px; }
.p1-hero h1 { margin: 0 0 14px; }
.north-line {
  font-family: var(--display);
  font-size: clamp(18px, 1.6vw, 22px);
  color: var(--accent);
  margin: 0 0 18px;
  letter-spacing: 0.02em;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  max-width: 560px;
}
.hero-sub {
  color: var(--fg-muted);
  font-size: 14px;
  font-style: normal !important;
  font-family: var(--body) !important;
  font-weight: 300;
  margin: 0;
  max-width: 540px;
  line-height: 1.45;
}

.p1-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.p1-kpi {
  background: var(--surface);
  padding: 18px 18px 16px;
}
.p1-kpi-label {
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.p1-kpi-value {
  font-family: var(--display);
  font-size: 40px;
  line-height: 1;
  color: var(--fg);
}
.p1-kpi-target {
  font-size: 10px;
  color: var(--fg-faint);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* strip layout ---------------------------------------- */
.strip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.strip-rule {
  font-size: 11px;
  color: var(--fg-faint);
  font-style: italic;
  font-family: var(--display);
  text-align: right;
  max-width: 60%;
}

/* page 1 goalposts as horizontal strip */
.p1-goalposts { flex: 0 0 auto; display: flex; flex-direction: column; padding-bottom: 4px; gap: 8px; }
.goalposts-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.goalpost {
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 168px;
}
.goalpost-label {
  font-size: 9px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.goalpost-value {
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
  color: var(--fg);
}
.goalpost-pct {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.goalpost-spark {
  height: 18px;
  width: 100%;
  margin: 0;
}
.goalpost-target {
  font-size: 9.5px;
  color: var(--fg-faint);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: auto;
  line-height: 1.35;
}
.goalpost-target strong { color: var(--fg-muted); font-weight: 500; }
.goalpost-note {
  font-size: 10px;
  font-style: italic;
  color: var(--fg-muted);
  font-family: var(--display);
}

/* page 1 phase clock as compact horizontal strip */
.p1-phaseclock { flex: 0 0 auto; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.phase-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.phase-cell {
  background: var(--surface);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  text-align: left;
  width: 100%;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s;
  outline: none;
}
.phase-cell:hover, .phase-cell:focus-visible { background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.phase-cell.upcoming { border-left: 2px solid var(--accent); }
.phase-cell.active { background: var(--accent-soft); }
.phase-cell-id { font-size: 9px; letter-spacing: 1.4px; color: var(--accent); }
.phase-cell-name { font-family: var(--display); font-size: 14px; line-height: 1.2; }
.phase-cell-window { font-size: 10px; color: var(--fg-faint); }
.phase-cell-bar {
  height: 2px;
  background: rgba(247, 243, 231, 0.08);
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}
.phase-cell-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  height: 100%;
}
.phase-cell-pct {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--fg-muted);
  letter-spacing: 0.06em;
}

/* phase deliverables popover — floats above tile on hover/focus, does not push layout */
.phase-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  box-shadow: 0 12px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(74,143,126,0.15);
  padding: 12px 14px 13px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 40;
  pointer-events: none;
  /* width: at least tile width, expand if content needs */
  min-width: 100%;
  width: max-content;
  max-width: 360px;
}
.phase-popover::after {
  /* arrow */
  content: "";
  position: absolute;
  top: 100%;
  left: 20px;
  border: 6px solid transparent;
  border-top-color: var(--accent);
}
.phase-cell:hover .phase-popover,
.phase-cell:focus-within .phase-popover,
.phase-cell:focus-visible .phase-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.phase-popover-head {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.phase-popover-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.deliverable-row {
  background: var(--surface);
  display: grid;
  grid-template-columns: 14px 1fr 56px;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  font-size: 11px;
}
.d-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(247, 243, 231, 0.18);
  display: inline-block;
}
.d-dot.partial { background: var(--gold); }
.d-dot.done { background: var(--accent); }
.d-label { color: var(--fg); line-height: 1.35; }
.d-weight {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--fg-faint);
  letter-spacing: 0.04em;
  text-align: right;
}
.d-done {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-muted);
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}

/* window progress */
.window-progress { max-width: 100%; }
.window-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.window-bar-meta strong { color: var(--fg); }
.window-bar { height: 3px; background: var(--accent-soft); position: relative; overflow: visible; }
.window-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  width: 0;
  transition: width 0.6s ease-out;
}
.window-bar-marker {
  position: absolute;
  top: -5px; bottom: -5px;
  width: 1px;
  background: var(--gold);
}
/* doors-open marker label is suppressed — the day-counter line already names it */

/* ===================================================== */
/* PAGE 2 · THE PIPELINE                                  */
/* ===================================================== */
.p2-head { flex: 0 0 auto; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.p2-head .eyebrow { margin-bottom: 8px; }
.p2-rule { font-size: 13px; max-width: 760px; }

.p2-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
  flex: 1 1 auto;
  min-height: 0;
}
.p2-funnel { min-height: 0; display: flex; }
.p2-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.funnel {
  border: 1px solid var(--border);
  background: var(--surface);
  width: 100%;
  display: flex;
  flex-direction: column;
}
.funnel-row {
  display: grid;
  grid-template-columns: 28px 1fr 70px 50px;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex: 1 1 auto;
}
.funnel-row:last-child { border-bottom: 0; }
.funnel-row:hover { background: rgba(74, 143, 126, 0.05); }
.funnel-stage-num { font-size: 10px; letter-spacing: 1.4px; color: var(--fg-faint); }
.funnel-name { font-family: var(--display); font-size: 16px; color: var(--fg); }
.funnel-defn {
  display: block;
  font-family: var(--body);
  font-size: 10.5px;
  color: var(--fg-muted);
  margin-top: 2px;
  line-height: 1.35;
}
.funnel-count {
  font-family: var(--display);
  font-size: 22px;
  text-align: right;
  color: var(--fg);
}
.funnel-delta {
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-align: right;
  color: var(--accent);
}
.funnel-delta.zero { color: var(--fg-faint); }
.funnel-row.upstream { background: var(--surface-2); }
.funnel-row.upstream .funnel-name { color: var(--accent); }

/* read-to-recognize panel */
.r2r {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}
.r2r-headline {
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.25;
}
.r2r-stat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.r2r-stat .num { font-family: var(--display); font-size: 22px; display: block; color: var(--fg); }
.r2r-stat .lbl {
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 4px;
  display: block;
}
.r2r-target {
  font-size: 10px;
  color: var(--fg-faint);
  font-family: var(--display);
  font-style: italic;
  line-height: 1.4;
}

/* reader origin map (between r2r and tracks) */
.reader-map {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}
.reader-map .eyebrow { margin: 0; }
.map-canvas {
  width: 100%;
  height: 110px;
  background: rgba(247, 243, 231, 0.015);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 2px 0;
}
.map-canvas svg { width: 100%; height: 100%; display: block; }
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.map-legend .sw {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 5px;
  vertical-align: middle;
  border-radius: 50%;
}
.map-legend .sw.core { background: var(--gold); }
.map-legend .sw.adj { background: var(--accent); }
.map-legend .sw.dia { background: rgba(247, 243, 231, 0.45); }
.map-rank {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.map-rank-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 8.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 2px;
}
.map-rank-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 10.5px;
  color: var(--fg);
  padding: 2px 0;
}
.rank-tier {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.rank-tier.tier-core { background: var(--gold); }
.rank-tier.tier-adjacent { background: var(--accent); }
.rank-tier.tier-diaspora { background: rgba(247, 243, 231, 0.45); }
.rank-name { color: var(--fg); }
.rank-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-muted);
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}

/* tracks compact strip on right column */
.tracks-strip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.track-row {
  background: var(--surface);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  align-items: center;
}
.track-row:hover { background: var(--surface-2); }
.track-row .tr-id {
  font-family: var(--display);
  font-size: 26px;
  line-height: 1;
  color: var(--accent);
}
.track-row .tr-name { font-family: var(--display); font-size: 14px; line-height: 1.2; }
.track-row .tr-aud { font-size: 10px; color: var(--fg-muted); margin-top: 2px; }
.track-row .tr-target {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold);
  text-align: right;
  line-height: 1.4;
}
.track-row .tr-target strong {
  display: block;
  font-family: var(--display);
  font-size: 13px;
  color: var(--fg);
  letter-spacing: normal;
  text-transform: none;
  font-weight: 400;
  margin-top: 2px;
}

/* ===================================================== */
/* PAGE 3 · THE LEDGER                                    */
/* ===================================================== */
.p3-head { flex: 0 0 auto; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.p3-head .eyebrow { margin-bottom: 8px; }

.p3-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.ledger-card {
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}
.ledger-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  min-height: 78px;
  box-sizing: border-box;
}
.ledger-tag {
  font-family: var(--display);
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}
.ledger-name { font-family: var(--display); font-size: 15px; line-height: 1.2; }
.ledger-sub { font-size: 10.5px; color: var(--fg-muted); margin-top: 3px; }
.ledger-source {
  font-size: 8.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold);
  text-align: right;
  line-height: 1.4;
  align-self: center;
}

/* A · variance table */
.variance-table {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 0;
}
.variance-row {
  display: grid;
  grid-template-columns: 1fr 64px 64px 84px;
  gap: 8px;
  align-items: center;
  padding: 5px 14px;
  border-bottom: 1px solid var(--border);
}
.variance-row:last-child { border-bottom: 0; }
.variance-row.head {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: var(--surface-2);
}
.variance-line { font-size: 11px; color: var(--fg); }
.variance-line.section {
  font-family: var(--display);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.variance-num {
  font-family: var(--mono);
  font-size: 10px;
  text-align: right;
  color: var(--fg);
  font-variant-numeric: tabular-nums lining-nums;
}
.variance-bar-cell {
  height: 14px;
  background: rgba(247, 243, 231, 0.04);
  position: relative;
  border-left: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
}
.variance-bar {
  position: absolute;
  top: 3px; bottom: 3px;
  min-width: 2px;
  opacity: 0.55;
}
.variance-bar.neg { background: var(--red-bright); right: 50%; }
.variance-bar.pos { background: var(--accent); left: 50%; }
.variance-bar-pct {
  position: relative;
  z-index: 2;
  width: 100%;
  text-align: right;
  padding-right: 6px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* B · 13-week cash flow */
.cashflow-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 8px;
  overflow: visible;
}
.cashflow-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.cashflow-summary-tile { padding: 5px 8px; background: var(--surface-2); }
.cashflow-summary-tile .lbl {
  font-size: 8.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.cashflow-summary-tile .val {
  font-family: var(--display);
  font-size: 16px;
  color: var(--fg);
  font-variant-numeric: tabular-nums lining-nums;
  margin-top: 2px;
}
.cashflow-summary-tile .val.warn { color: var(--gold); }
.cashflow-summary-tile .val.ok { color: var(--accent); }

.cashflow-chart {
  display: flex;
  align-items: stretch;
  gap: 3px;
  height: 220px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
  flex: 0 0 auto;
}
.cashflow-chart::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-strong);
  z-index: 1;
}
.cf-week {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
}
.cf-half {
  flex: 1 1 0;
  display: flex;
  position: relative;
}
.cf-half.top { align-items: flex-end; }
.cf-half.bot { align-items: flex-start; }
.cf-bar {
  width: 100%;
  display: block;
  z-index: 2;
}
.cf-bar.in { background: var(--accent); }
.cf-bar.out { background: var(--red-bright); }
.cf-week .week-lbl {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-family: var(--mono);
  color: var(--fg-faint);
  letter-spacing: 0.04em;
}
.cf-week.alert .cf-bar.out { background: var(--red); }

/* Cash flow bar hover tooltip */
.cf-week { cursor: pointer; }
.cf-week .cf-bar { transition: opacity 120ms ease; }
.cf-week:hover .cf-bar,
.cf-week:focus-within .cf-bar { opacity: 0.65; }
.cf-tooltip {
  position: absolute;
  bottom: calc(50% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  background: #081610;
  border: 1px solid var(--accent);
  padding: 10px 12px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
  box-shadow: 0 6px 22px rgba(0,0,0,0.6);
}
.cf-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--accent);
}
.cf-tooltip::before {
  content: '';
  position: absolute;
  top: calc(100% - 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #081610;
  z-index: 1;
}
.cf-week:hover .cf-tooltip,
.cf-week:focus-within .cf-tooltip { opacity: 1; }

/* Edge clamping — shift tooltip inward when bar is near chart edges */
.cf-week:nth-child(1) .cf-tooltip,
.cf-week:nth-child(2) .cf-tooltip {
  left: 0;
  transform: translateX(0);
}
.cf-week:nth-child(1) .cf-tooltip::after,
.cf-week:nth-child(1) .cf-tooltip::before,
.cf-week:nth-child(2) .cf-tooltip::after,
.cf-week:nth-child(2) .cf-tooltip::before {
  left: 20px;
  transform: translateX(0);
}
.cf-week:nth-last-child(1) .cf-tooltip,
.cf-week:nth-last-child(2) .cf-tooltip {
  left: auto;
  right: 0;
  transform: translateX(0);
}
.cf-week:nth-last-child(1) .cf-tooltip::after,
.cf-week:nth-last-child(1) .cf-tooltip::before,
.cf-week:nth-last-child(2) .cf-tooltip::after,
.cf-week:nth-last-child(2) .cf-tooltip::before {
  left: auto;
  right: 20px;
  transform: translateX(0);
}
.cf-tt-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.cf-tt-month {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-family: var(--mono);
}
.cf-tt-cal {
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--mono);
}
.cf-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  font-family: var(--body);
  padding: 2px 0;
}
.cf-tt-row.net {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 6px;
}
.cf-tt-lbl {
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 9px;
}
.cf-tt-val { font-variant-numeric: tabular-nums lining-nums; font-weight: 500; }
.cf-tt-val.in  { color: var(--accent-lt); }
.cf-tt-val.out { color: var(--red-bright); }

.cashflow-legend {
  display: flex;
  gap: 16px;
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding-top: 8px;
}
.cashflow-legend .swatch {
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 6px;
  vertical-align: middle;
}
.cashflow-legend .swatch.in { background: var(--accent); }
.cashflow-legend .swatch.out { background: var(--red-bright); }

.priority-waterfall {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-top: 6px;
}
.priority-head {
  display: grid;
  grid-template-columns: 16px 1fr 90px 90px;
  gap: 8px;
  background: var(--surface);
  padding: 4px 10px;
  align-items: center;
}
.priority-col-hd {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: right;
  font-family: var(--body);
}
.priority-row {
  display: grid;
  grid-template-columns: 16px 1fr 90px 90px;
  gap: 8px;
  background: var(--surface);
  padding: 4px 10px;
  align-items: center;
  font-size: 10px;
  position: relative;
  cursor: pointer;
}
.priority-rank {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--accent);
}
.priority-label { color: var(--fg); }
.priority-amount,
.priority-avg {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-muted);
  text-align: right;
}

/* Sum rows (Total Inflows / Total Outflows) */
.priority-row.sum {
  cursor: default;
  background: var(--surface-2);
  padding: 6px 10px;
}
.priority-row.sum .priority-label {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.priority-row.sum-in  .priority-amount,
.priority-row.sum-in  .priority-avg  { color: var(--accent-lt); font-weight: 500; }
.priority-row.sum-out .priority-amount,
.priority-row.sum-out .priority-avg  { color: var(--red-bright); font-weight: 500; }

/* Priority-of-payments hover popover (anchored above row, like phase tiles) */
.priority-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 16px;
  width: max-content;
  min-width: calc(100% - 32px);
  max-width: calc(100vw - 64px);
  background: #081610;
  border: 1px solid var(--accent);
  padding: 8px 12px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
  box-shadow: 0 6px 22px rgba(0,0,0,0.6);
  white-space: nowrap;
}
.priority-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 24px;
  border: 5px solid transparent;
  border-top-color: var(--accent);
}
.priority-row:hover .priority-popover,
.priority-row:focus-within .priority-popover { opacity: 1; }
.priority-row.no-popover { cursor: default; }
/* Priority popover — styled to match .cf-tooltip:
   mono labels in uppercase 9px, body values 11px, tight rows, accent on right column. */
.pp-head {
  display: grid;
  grid-template-columns: 220px 88px 88px 44px;
  gap: 14px;
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-family: var(--mono);
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.pp-head-col { text-align: right; }
.pp-row {
  display: grid;
  grid-template-columns: 220px 88px 88px 44px;
  gap: 14px;
  font-size: 11px;
  font-family: var(--body);
  padding: 2px 0;
  align-items: baseline;
}
.pp-lbl {
  color: var(--fg);
  font-size: 11px;
  font-family: var(--body);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp-val {
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
  font-size: 11px;
  color: var(--fg);
  text-align: right;
}
/* Line-item rows: inflows accent-lt green; outflows STAY WHITE/CREAM (parens carry sign).
   Only the Total row gets the red treatment — matches the referenced waterfall table
   where only sum rows are colored. Consistency with the table the popover explains. */
.pp-val.in  { color: var(--accent-lt); }
.pp-val.out { color: var(--fg); }
.pp-pct {
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
  font-size: 11px;
  color: var(--accent);
  text-align: right;
}
.pp-row.pp-total {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 6px;
}
.pp-row.pp-total .pp-lbl { color: var(--fg); font-weight: 500; }
.pp-row.pp-total .pp-pct { color: var(--fg); font-weight: 500; }
.pp-row.pp-total .pp-val.in  { color: var(--accent-lt); font-weight: 500; }
.pp-row.pp-total .pp-val.out { color: var(--red-bright); font-weight: 500; }
.pp-empty {
  font-size: 10px;
  color: var(--fg-faint);
  font-style: italic;
  padding: 4px 0;
}

/* C · sources & uses */
.sources-uses {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 10px;
  overflow-y: auto;
}
.su-section { display: flex; flex-direction: column; gap: 4px; }
.su-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.su-section-head .lbl {
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
}
.su-section-head .total {
  font-family: var(--display);
  font-size: 16px;
  color: var(--fg);
  font-variant-numeric: tabular-nums lining-nums;
}
.su-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 12px;
  align-items: center;
}
.su-row .name {
  font-size: 10px;
  color: var(--fg);
  line-height: 1.25;
}
.su-row .sub {
  font-size: 8.5px;
  color: var(--fg-muted);
  display: block;
  margin-top: 1px;
  line-height: 1.25;
}
.su-row .amt {
  font-family: var(--mono);
  font-size: 10.5px;
  text-align: right;
  color: var(--fg);
  font-variant-numeric: tabular-nums lining-nums;
}
.su-bar-track {
  height: 3px;
  background: rgba(247, 243, 231, 0.06);
  position: relative;
  margin-top: 2px;
  grid-column: 1 / -1;
}
.su-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent);
}
.su-bar-fill.uses { background: var(--gold); }
.su-balance {
  margin-top: 4px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.su-balance .lbl {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.su-balance .val {
  font-family: var(--display);
  font-size: 14px;
  color: var(--accent);
  font-variant-numeric: tabular-nums lining-nums;
}

/* ===================================================== */
/* FIXED FOOTER                                           */
/* ===================================================== */
.footer-fixed {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  background: rgba(13, 31, 23, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--fg-muted);
  z-index: 50;
}
.footer-links a { margin-left: 18px; color: var(--accent); }
.footer-links .kraion-mark { margin-left: 18px; color: var(--fg-faint); }

/* ===================================================== */
/* KRV BRAND RULE: Miller Display is ALWAYS italic        */
/* Applies to every selector using var(--display)         */
/* ===================================================== */
.display-xl,
.display-lg,
.north-line,
.strip-rule,
.p1-kpi-value,
.goalpost-value,
.goalpost-note,
.phase-cell-name,
.funnel-name,
.funnel-count,
.r2r-headline,
.r2r-stat .num,
.r2r-target,
.track-row .tr-id,
.track-row .tr-name,
.track-row .tr-target strong,
.ledger-tag,
.ledger-name,
.variance-line.section,
.cashflow-summary-tile .val,
.su-section-head .total,
.su-balance .val { font-style: italic; }

/* ===================================================== */
/* PAGE VISIBILITY · hide P1 + P2 for now (MCR brief)     */
/* DO NOT DELETE — preserved for post-launch              */
/* ===================================================== */
.page.p-hidden { display: none; }

/* ===================================================== */
/* RESPONSIVE                                             */
/* ===================================================== */
@media (max-width: 1100px) {
  .page-inner { padding: 24px var(--rail); }
  .p1-grid { grid-template-columns: 1fr; gap: 24px; }
  .p2-grid { grid-template-columns: 1fr; }
  .p3-grid { grid-template-columns: 1fr; }
  .pager { display: none; }
}
