/* GivingForce Revenue Centre
   Built on the signed-off GivingForce design system (DESIGN.md, 2026-08-25):
   warm sand ground, Raleway throughout, hairline rules instead of card borders.
   The monospace voice is retired, so labels are Raleway in small caps tracking.

   Two rules from that system that are easy to get wrong and are honoured here:
   brand orange #F16824 is a fill, never a line against sand (2.81:1), so borders
   use --orange-dark; and orange TEXT on light is always --orange-ink. */

:root {
  color-scheme: light;

  /* GivingForce brand tokens, verbatim */
  --orange: #F16824;
  --orange-dark: #BC4A0D;
  --orange-ink: #8A3104;
  --orange-ink-h: #6F2603;
  --gold: #F6A373;
  --tint: #FFF1EA;
  --dark: #2B2622;
  --mid: #3F3833;
  --grey: #4F4A43;
  --muted: #544E47;
  --light-grey: #8C857B; /* non-text only */
  --sand: #F6F3EE;
  --warm-white: #FBF9F5;
  --white: #FFFFFF;
  --border: #EBE5DB;
  --border-soft: #F1ECE4;

  --radius: 16px;
  --radius-sm: 10px;

  /* Validated ordinal ramp, light on sand: monotone lightness, single hue,
     light end clears the surface. Used for the funnel and reach bars. */
  --o1: #F0913F;
  --o2: #DE6A18;
  --o3: #BC4A0D;
  --o4: #8A3104;
  --o5: #5E2003;

  /* Status. State, never identity, and always paired with a word. */
  --ok: #17754F;
  --warn: #8A6A12;
  --bad: #A32B22;
  --ok-bg: #E8F2ED;
  --warn-bg: #F5F0DF;
  --bad-bg: #F7E9E7;

  --track: #E7E1D6;
  --font: 'Raleway', -apple-system, 'Segoe UI', sans-serif;
  --rail: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--sand);
  color: var(--grey);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font);
  color: var(--dark);
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0;
}

a { color: var(--orange-ink); }

:focus-visible {
  outline: 2px solid var(--orange-dark);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Numbers always line up and never wear the display weight alone. */
.num, .stat-value { font-variant-numeric: tabular-nums; }

/* The retired monospace voice becomes a tracked small-caps label. */
.label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

.rail {
  background: var(--warm-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; flex-direction: column; gap: 9px; padding: 4px 8px 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

.brand-mark {
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); flex: none; }
.brand-sub { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--grey);
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.nav-btn:hover { background: var(--tint); color: var(--dark); }

.nav-btn[aria-current='true'] {
  background: var(--tint);
  color: var(--orange-ink);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--orange-dark);
}

.nav-tag { font-size: 0.7rem; font-weight: 600; color: var(--light-grey); font-variant-numeric: tabular-nums; }
.nav-tag.alert { color: var(--bad); }

.rail-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 9px; font-size: 0.76rem; color: var(--muted); }
.rail-foot .credit { color: var(--light-grey); font-size: 0.72rem; }

.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 32px;
  background: rgba(246, 243, 238, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.22rem; }
.topbar-meta { display: flex; align-items: center; gap: 16px; }
.topbar-window { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.btn {
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--grey);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover { background: var(--tint); border-color: var(--orange-dark); color: var(--orange-ink); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--orange-ink); border-color: var(--orange-ink); color: var(--white); }
.btn-primary:hover { background: var(--orange-ink-h); border-color: var(--orange-ink-h); color: var(--white); }

.view { padding: 30px 32px 80px; max-width: 1400px; }
.view[hidden] { display: none; }
.lede { color: var(--muted); max-width: 68ch; margin: 0 0 28px; font-size: 1rem; }

/* ---------- blocks ---------- */
section.block { margin-bottom: 40px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.block-head h2 { font-size: 1.1rem; }
.block-note { color: var(--muted); font-size: 0.92rem; max-width: 76ch; margin: 0 0 18px; }
.block-note b { color: var(--dark); font-weight: 700; }

.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }

.grid { display: grid; gap: 14px; }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---------- stat tiles. Hairline rule above, not a boxed card. ---------- */
.stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.stat::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--border); }
.stat-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 1.95rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.025em; color: var(--dark); }
.stat-note { font-size: 0.84rem; color: var(--muted); }
.stat.is-alarm::before { background: var(--bad); }
.stat.is-alarm .stat-value { color: var(--bad); }
.stat.is-good::before { background: var(--ok); }
.stat.is-good .stat-value { color: var(--ok); }
.stat.is-warn::before { background: var(--warn); }
.stat.is-warn .stat-value { color: var(--warn); }

/* ---------- the board questions ---------- */
.qa { display: grid; gap: 12px; }

.qa-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange-dark);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
}

.qa-q { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.qa-a { font-size: 1.02rem; color: var(--grey); margin: 0; }
.qa-a strong { color: var(--orange-ink); font-weight: 700; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }

th {
  text-align: left;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 15px;
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 12px 15px; border-bottom: 1px solid var(--border-soft); vertical-align: top; color: var(--grey); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--warm-white); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.name { font-weight: 600; color: var(--dark); }
.sub { display: block; color: var(--muted); font-size: 0.79rem; font-weight: 400; margin-top: 3px; }

/* ---------- verdict pills. The word carries the meaning, colour supports it. ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}

.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-worked { color: var(--ok); border-color: rgba(23, 117, 79, 0.32); background: var(--ok-bg); }
.pill-wrongReach { color: var(--warn); border-color: rgba(138, 106, 18, 0.32); background: var(--warn-bg); }
.pill-wrongMessage { color: var(--orange-ink); border-color: rgba(138, 49, 4, 0.28); background: var(--tint); }
.pill-failed { color: var(--bad); border-color: rgba(163, 43, 34, 0.32); background: var(--bad-bg); }
.pill-insufficient { color: var(--muted); border-color: var(--border); background: var(--sand); }

/* ---------- decomposition bar ---------- */
.decomp { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.decomp-track { position: relative; height: 10px; border-radius: 5px; background: var(--track); overflow: hidden; }
.decomp-open { position: absolute; inset: 0 auto 0 0; background: var(--o1); border-radius: 5px; }
/* 2px surface ring keeps the two fills from touching where they overlap. */
.decomp-click { position: absolute; inset: 0 auto 0 0; background: var(--o4); border-radius: 5px; box-shadow: 0 0 0 2px var(--white); }
.decomp-legend { display: flex; gap: 14px; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.decomp-legend b { color: var(--dark); font-weight: 700; }

/* ---------- funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: 7px; }
.funnel-row { display: grid; grid-template-columns: 176px 1fr 96px; align-items: center; gap: 16px; }
.funnel-label { font-size: 0.9rem; color: var(--grey); font-weight: 500; }
.funnel-bar { height: 28px; border-radius: 5px; min-width: 3px; display: flex; align-items: center; padding-left: 10px; }
.funnel-bar span { font-size: 0.78rem; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; }
.funnel-count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--dark); }

/* ---------- callout ---------- */
.callout { border-radius: var(--radius); padding: 20px 24px; border: 1px solid; display: flex; flex-direction: column; gap: 9px; }
.callout-title { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }
.callout p { margin: 0; color: var(--muted); max-width: 78ch; }
.callout.find { background: var(--tint); border-color: rgba(188, 74, 13, 0.3); }
.callout.find .callout-title { color: var(--orange-ink); }
.callout.warn { background: var(--warn-bg); border-color: rgba(138, 106, 18, 0.3); }
.callout.warn .callout-title { color: var(--warn); }
.callout.bad { background: var(--bad-bg); border-color: rgba(163, 43, 34, 0.3); }
.callout.bad .callout-title { color: var(--bad); }

/* ---------- comparison ---------- */
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 28px; align-items: center; max-width: 660px; }
.versus-side { display: flex; flex-direction: column; gap: 5px; }
.versus-side .stat-value { font-size: 2.5rem; }
.versus-mid { text-align: center; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.versus-mid b { display: block; font-size: 1.6rem; letter-spacing: -0.02em; color: var(--orange-ink); font-weight: 800; margin: 2px 0; }

/* ---------- plan ---------- */
.steps { display: flex; flex-direction: column; gap: 12px; counter-reset: step; }

.step {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px 18px 60px;
  position: relative;
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 20px;
  top: 18px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--tint);
  border: 1px solid var(--orange-dark);
  color: var(--orange-ink);
  font-size: 0.76rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.step h3 { font-size: 1rem; margin-bottom: 5px; }
.step p { margin: 0 0 10px; color: var(--muted); max-width: 78ch; }
.step-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 0.81rem; color: var(--muted); }
.step-meta b { color: var(--dark); font-weight: 700; }

/* ---------- trend chart ---------- */
.chart { display: flex; flex-direction: column; gap: 10px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-area { fill: var(--tint); }
.ch-line { fill: none; stroke: var(--o3); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ch-line-partial { stroke-dasharray: 5 4; }
.ch-dot { fill: var(--o3); stroke: var(--white); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ch-dot-end { fill: var(--orange-ink); stroke-width: 2; }
.ch-label { fill: var(--muted); font-size: 11px; font-family: var(--font); font-weight: 600; }
.ch-caption { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.79rem; color: var(--muted); }
.ch-max { font-weight: 700; color: var(--dark); font-variant-numeric: tabular-nums; }

/* ---------- lead scores ---------- */
.scores { display: flex; flex-direction: column; gap: 5px; min-width: 190px; }
.score-row { display: grid; grid-template-columns: 46px 1fr 28px; align-items: center; gap: 8px; }
.score-key { font-size: 0.71rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.score-track { height: 7px; border-radius: 4px; background: var(--track); overflow: hidden; }
.score-fill { height: 100%; border-radius: 4px; }
.sc-fit { background: var(--o4); }
.sc-intent { background: var(--o2); }
.score-val { font-size: 0.78rem; font-weight: 700; color: var(--dark); text-align: right; }

.band {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid;
}

.band-A { color: var(--white); background: var(--ok); border-color: var(--ok); }
.band-B { color: var(--orange-ink); background: var(--tint); border-color: var(--orange-dark); }
.band-C, .band-D, .band-none { color: var(--muted); background: var(--sand); border-color: var(--border); }

/* ---------- cost form ---------- */
.btn-small { padding: 5px 11px; font-size: 0.79rem; }
.cost-form { margin-top: 22px; max-width: 720px; }
.cost-form h3 { font-size: 1rem; }

/* ---------- misc ---------- */
.empty { color: var(--muted); font-style: italic; padding: 24px; text-align: center; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--dark);
  color: var(--warm-white);
  border-radius: var(--radius-sm);
  padding: 13px 17px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 50;
  max-width: 380px;
  box-shadow: 0 8px 24px rgba(43, 38, 34, 0.18);
}

/* Gold is the accent text colour on dark, which is exactly this case. */
.toast.err { color: var(--gold); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 390px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 34px; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 5px; }
.login-card .lead { display: block; color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.field input {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--dark);
  font-family: var(--font);
  font-size: 0.95rem;
}

.field input:focus { border-color: var(--orange-dark); outline: none; background: var(--white); }
.login-err { color: var(--bad); font-size: 0.86rem; min-height: 1.2em; margin: 0 0 12px; font-weight: 600; }

@media (max-width: 900px) {
  :root { --rail: 0px; }
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; width: 100%; }
  .rail-foot { display: none; }
  .view { padding: 22px 16px 64px; }
  .topbar { padding: 13px 16px; }
  .topbar-window { display: none; }
  .versus { grid-template-columns: 1fr; gap: 14px; }
  .funnel-row { grid-template-columns: 116px 1fr 62px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.nav-tag.good { color: var(--ok); font-weight: 700; }

/* ---------- goal ramp ---------- */
.ramp { display: flex; gap: 6px; flex-wrap: nowrap; }
.ramp-step { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 46px; padding: 4px 7px; border-radius: var(--radius-sm); background: var(--sand); border: 1px solid var(--border); }
.ramp-n { font-size: 0.94rem; font-weight: 700; color: var(--dark); font-variant-numeric: tabular-nums; }
.ramp-l { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
