/* Nonprofit Growth 1000 design system.
   One neutral gray scale, 50 to 950, with a faint warmth. Pages use the five role tokens below, not the steps directly. Hierarchy comes from size, weight, space and rules. No accent color, no shadow, no rounding, no all-caps.
   Pages load Geist from Google Fonts: family=Geist:wght@400;500;700
   Components draw with currentColor wherever they can, so anything placed on an inverted surface inverts with it. */

/* ---------- Tokens ---------- */
:root {
  /* Gray scale, Tailwind-style steps. 50 is the paper, 900 the charcoal. The scale stays fixed in dark mode; the roles flip. */
  --gray-50: #f7f7f5;
  --gray-100: #ececea;
  --gray-200: #e0e0dd;
  --gray-300: #d2d2ce;
  --gray-400: #a3a39e;
  --gray-500: #767672;  /* 4.3:1 on 50: large text and marks only */
  --gray-600: #5b5b57;
  --gray-700: #42423f;
  --gray-800: #2a2a28;
  --gray-900: #1c1c1c;
  --gray-950: #131313;

  /* Roles */
  --paper: var(--gray-50);   /* page */
  --wash: var(--gray-100);   /* selected rows, bar tracks */
  --hover: var(--gray-200);  /* row hover */
  --line: var(--gray-300);   /* hairlines between rows and items */
  --muted: var(--gray-600);  /* secondary text, axis labels; 6.4:1 on paper */
  --ink: var(--gray-900);    /* text, heavy rules, bars, box borders; 15.9:1 on paper */

  --font: "Geist", "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* Type scale, roughly 1.333 */
  --text-xs: 13px;
  --text-sm: 15px;
  --text-md: 18px;
  --text-lg: 24px;
  --text-xl: 36px;
  --text-2xl: clamp(40px, 6vw, 64px);
  --text-3xl: clamp(64px, 11vw, 128px);

  /* Spacing, on an 8px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;
  --space-8: 96px;
  --space-9: 128px;

  /* Rules: hairline separates items, heavy opens a section */
  --hair: 1px;
  --heavy: 4px;

  --measure: 68ch;
  --page: 1200px;

  /* Series fills for charts with several parts, told apart by texture rather than color */
  --fill-1: var(--ink);
  --fill-2: repeating-linear-gradient(-45deg, var(--ink) 0 1.5px, var(--paper) 1.5px 5px);
  --fill-3: radial-gradient(circle, var(--ink) 1px, var(--paper) 1.5px) 0 0 / 5px 5px;
  --fill-4: var(--paper);
  --fill-5: repeating-linear-gradient(0deg, var(--ink) 0 1.5px, var(--paper) 1.5px 4px);

  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: var(--gray-950); --wash: var(--gray-800); --hover: var(--gray-800); --line: var(--gray-700); --muted: var(--gray-400); --ink: var(--gray-100); color-scheme: dark; }
}
:root[data-theme="dark"] { --paper: var(--gray-950); --wash: var(--gray-800); --hover: var(--gray-800); --line: var(--gray-700); --muted: var(--gray-400); --ink: var(--gray-100); color-scheme: dark; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 var(--text-sm)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--ink); color: var(--paper); }
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
h1, h2, h3 { font-weight: 700; text-wrap: balance; }
h1 { font-size: var(--text-2xl); line-height: 1; letter-spacing: -0.035em; }
h2 { font-size: var(--text-lg); line-height: 1.15; letter-spacing: -0.015em; }
h3 { font-size: var(--text-md); line-height: 1.25; letter-spacing: -0.01em; }
strong, b { font-weight: 700; }
a { color: inherit; text-decoration-thickness: var(--hair); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92em; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--page); margin: 0 auto; padding: var(--space-7) var(--space-4) var(--space-9); display: grid; gap: var(--space-8); }
.wrap > *, .section > * { min-width: 0; }
.section { border-top: var(--heavy) solid var(--ink); padding-top: var(--space-4); display: grid; gap: var(--space-5); }
.section > header { display: grid; gap: var(--space-2); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: var(--space-5); }

/* ---------- Text ---------- */
.lede { font-size: var(--text-md); line-height: 1.45; max-width: var(--measure); }
.prose { display: grid; gap: var(--space-3); align-content: start; max-width: var(--measure); }
.prose ul { padding-left: 1.1em; display: grid; gap: var(--space-2); }
.sub, .note, .asof { font-size: var(--text-xs); line-height: 1.45; color: var(--muted); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.num { text-align: right; }

/* ---------- Surfaces ---------- */
.box { border: var(--hair) solid var(--ink); }
.panel { padding: var(--space-4); display: grid; gap: var(--space-3); align-content: start; min-width: 0; }
.panel > h3 { padding-bottom: var(--space-2); border-bottom: var(--hair) solid var(--line); }
/* An inverted surface re-derives the grays so components inside it still read */
.invert {
  background: var(--ink); color: var(--paper);
  --muted: color-mix(in srgb, var(--paper) 68%, var(--ink));
  --line: color-mix(in srgb, var(--paper) 28%, var(--ink));
  --wash: color-mix(in srgb, var(--paper) 16%, var(--ink));
  --hover: color-mix(in srgb, var(--paper) 22%, var(--ink));
}
.invert ::selection { background: var(--paper); color: var(--ink); }

/* Softer callout. Remaps the roles locally, so everything inside draws from the new surface. */
/* Tint: a light gray panel with charcoal text */
.tint { --paper: var(--gray-200); --ink: var(--gray-900); --muted: var(--gray-600); --line: var(--gray-400); --wash: var(--gray-50); --hover: var(--gray-100); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tint { --paper: var(--gray-800); --ink: var(--gray-100); --muted: var(--gray-400); --line: var(--gray-600); --wash: var(--gray-700); --hover: var(--gray-700); }
}
:root[data-theme="dark"] .tint { --paper: var(--gray-800); --ink: var(--gray-100); --muted: var(--gray-400); --line: var(--gray-600); --wash: var(--gray-700); --hover: var(--gray-700); }
.tint { background: var(--paper); color: var(--ink); }

/* ---------- Stats: cells divided by hairlines ---------- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--hair); background: var(--ink); border: var(--hair) solid var(--ink);
}
.stat { background: var(--paper); padding: var(--space-4); display: grid; gap: var(--space-3); align-content: space-between; min-width: 0; }
.stat b { font-size: var(--text-xl); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--text-xs); }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
input[type=search], input[type=text], select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: var(--hair) solid var(--ink); border-radius: 0; height: 40px; padding: 0 var(--space-3);
  min-width: 0; max-width: 100%; appearance: none;
}
input::placeholder { color: var(--muted); opacity: 1; }
select {
  padding-right: var(--space-6); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: right 21px center, right 16px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.controls input[type=search] { flex: 1 1 280px; }
input:focus-visible, select:focus-visible { outline-offset: 0; outline-width: 2px; }
input[type=checkbox] {
  appearance: none; margin: 0; width: 16px; height: 16px; flex: none;
  border: var(--hair) solid var(--ink); background: var(--paper); cursor: pointer;
}
input[type=checkbox]:checked { background: var(--ink); box-shadow: inset 0 0 0 3px var(--paper); }
label.check { display: inline-flex; gap: var(--space-2); align-items: center; cursor: pointer; }
.count { font-size: var(--text-xs); margin-left: auto; font-variant-numeric: tabular-nums; }

.btn {
  font: 500 var(--text-sm)/1 var(--font); color: var(--ink); background: var(--paper);
  border: var(--hair) solid var(--ink); border-radius: 0; height: 40px; padding: 0 var(--space-4); cursor: pointer;
}
/* Primary action: an outlined button with an offset shadow. Secondary actions: button.link. A plain .btn is for utility controls only. */
.btn:hover { background: var(--hover); }
.btn.primary { box-shadow: 3px 3px 0 var(--ink); }
.btn.primary:hover { background: var(--paper); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn.primary:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
/* Text link action: a hairline underline; on hover a 2px line draws across it from the left */
button.link {
  all: unset; cursor: pointer; font-weight: 500; padding-bottom: 3px;
  background:
    linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 100% var(--hair) no-repeat;
}
button.link:hover, button.link:focus-visible { background-size: 100% 2px, 100% var(--hair); }
button.link:active { background-size: 100% 3px, 100% var(--hair); }
button.link:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* ---------- Tables ---------- */
.tablebox { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: var(--space-3); text-align: left; vertical-align: top; border-bottom: var(--hair) solid var(--line); }
th { font-size: var(--text-xs); font-weight: 700; white-space: nowrap; border-bottom: 2px solid var(--ink); vertical-align: bottom; }
th.num, td.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: var(--space-1); align-items: center; }
th button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
th[aria-sort] button::after { content: "↓"; }
th[aria-sort="ascending"] button::after { content: "↑"; }
td.rank { width: 4em; font-weight: 700; }
td.org { min-width: 240px; }
td.org a { font-weight: 700; text-decoration: none; }
td.org .sub { margin-top: 2px; }
/* Rows that open something */
table.rows tbody tr { cursor: pointer; }
/* Hover: a fine halftone dot screen over the hover gray. .is-hover shows the state without a pointer. */
table.rows tbody tr:hover td, table.rows tbody tr.is-hover td { background: radial-gradient(circle, var(--line) .6px, transparent .9px) 0 0 / 5px 5px, var(--hover); }
table.rows tbody tr:hover td.org a { text-decoration: underline; }
tr.marked td { background: var(--wash); font-weight: 500; }
.empty { padding: var(--space-6) var(--space-3); text-align: center; }

/* ---------- Data marks ---------- */
/* Growth bar: a solid fill on a gray track */
.gbar { display: grid; grid-template-columns: 1fr 5em; gap: var(--space-3); align-items: center; min-width: 180px; }
.track { height: 8px; background: var(--wash); }
.fill { height: 100%; background: currentColor; }
.gbar b { text-align: right; font-weight: 700; }

/* Flag: an outlined label, never filled */
.chip { display: inline-block; margin-top: var(--space-2); padding: 1px var(--space-2); border: var(--hair) solid currentColor; font-size: var(--text-xs); font-weight: 500; line-height: 1.5; }

/* Rank: the largest type on a profile */
.rankbadge { font-size: var(--text-3xl); font-weight: 700; line-height: .82; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.rankbadge small { display: block; margin-top: var(--space-3); font-size: var(--text-xs); font-weight: 400; letter-spacing: 0; line-height: 1.4; }

/* Logo: a right triangle with equal legs (a 45° ramp), drawn in currentColor so it follows any surface.
   The mark sits on an 8 × 8 grid. In square or circular tiles, shift it up and left by 1/12 of its size:
   halfway from its bounding-box center to its centroid, which reads as centered at every size. */
.mark { display: block; flex: none; fill: currentColor; }
/* In a lockup the triangle sits on the text baseline at cap height, at whole-pixel sizes so its legs stay sharp. */
.logo { display: inline-flex; align-items: baseline; gap: 8px; font-size: var(--text-md); font-weight: 700; letter-spacing: -0.02em; line-height: 1; color: inherit; text-decoration: none; }
.logo .mark { width: 13px; height: 13px; }
.logo.lg { gap: 14px; font-size: var(--text-xl); letter-spacing: -0.03em; }
.logo.lg .mark { width: 26px; height: 26px; }

/* Facts: labeled fields in a row, divided by hairlines. Use under a title instead of loose meta text. */
.facts { display: flex; flex-wrap: wrap; row-gap: var(--space-3); margin: 0; }
.facts > div { display: grid; gap: 2px; align-content: start; padding: 0 var(--space-4); border-left: var(--hair) solid var(--line); min-width: 0; }
.facts > div:first-child { padding-left: 0; border-left: 0; }
.facts dt { font-size: var(--text-xs); color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Part-to-whole bar and its key */
.mix { display: flex; height: 20px; border: var(--hair) solid var(--ink); }
.mix span { height: 100%; }
.mix span + span { border-left: var(--hair) solid var(--ink); }
.swatch { display: inline-block; width: 12px; height: 12px; border: var(--hair) solid var(--ink); margin-right: var(--space-2); vertical-align: -1px; }
.kv { display: grid; grid-template-columns: 1fr auto; font-variant-numeric: tabular-nums; }
.kv dt, .kv dd { padding: var(--space-2) 0; border-bottom: var(--hair) solid var(--line); }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.kv dd { margin: 0; text-align: right; font-weight: 500; padding-left: var(--space-4); }

/* Charts: solid ink bars on an ink baseline, values in ink, axis labels muted */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart rect { fill: var(--ink); }
.chart line { stroke: var(--ink); stroke-width: 1; }
.chart text { fill: var(--muted); font: 400 11px var(--font); font-variant-numeric: tabular-nums; }
.chart text.value { fill: var(--ink); font-weight: 700; }

/* ---------- Depth and texture ----------
   Depth comes from flat offsets and grain, never from blur or soft shadows. */

/* Solid offset card: the primary button's shadow, a step deeper, for things that open */
.box.offset { box-shadow: 4px 4px 0 var(--ink); }
.box.offset:hover { box-shadow: 7px 7px 0 var(--ink); transform: translate(-2px, -2px); }
.box.offset:active { box-shadow: 0 0 0 var(--ink); transform: translate(4px, 4px); }
a.box { display: block; text-decoration: none; color: inherit; }


/* Paper grain: sparse dark and light flecks over a faint even tooth, like recycled stock.
   Dark and light marks balance, so the surface keeps its tone in both modes.
   Callouts only: never on the page background or other surfaces. */
:root { --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f0' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='1' seed='21' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 .05 .1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23f0%29'/%3E%3Cfilter id='f1' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='1' seed='22' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 .06 .12'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23f1%29'/%3E%3Cfilter id='f2' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 0 0 .55 1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23f2%29'/%3E%3Cfilter id='f3' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 0 0 .6 1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23f3%29'/%3E%3C/svg%3E"); }
.grain { background-image: var(--grain); }

@media (prefers-reduced-motion: no-preference) {
  button.link { transition: background-size .2s ease; }
  .btn, .box.offset { transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease; }
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .wrap { padding: var(--space-5) var(--space-3) var(--space-8); gap: var(--space-7); }
  th, td { padding: var(--space-2) var(--space-2); }
  .stat { padding: var(--space-3); }
  .stat b { font-size: var(--text-lg); }
  .panel { padding: var(--space-3); }
  .cols { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
  .facts > div, .facts > div:first-child { padding: var(--space-2) 0 0; border-left: 0; border-top: var(--hair) solid var(--line); }
  .facts > .wide { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) { .fill { transition: width .25s ease; } }
