/* ===========================================================
   LAYER 1 - Light: the co/efficient collateral palette
   =========================================================== */
:root {
  --ground:      #FAFAF8;
  --ground-image: none;
  --surface:     #FFFFFF;
  --ink:         #0D1B2A;
  --muted:       #4A5568;
  --line:        rgba(13, 27, 42, .12);
  --accent:      #E27124;
  --accent-soft: rgba(226, 113, 36, .12);

  --header-bg:   #023160;
  --header-image: none;
  --header-ink:  #FAFAF8;
  --header-sub:  rgba(250, 250, 248, .72);

  --good: #2E7D4F;  --good-bg: #E7F2EB;
  --warn: #A96A12;  --warn-bg: #FAF0DF;
  --crit: #B23A48;  --crit-bg: #FAE8EA;

  --display: "Inter", system-ui, sans-serif;
  --body:    "Source Sans Pro", system-ui, -apple-system, sans-serif;
  --mono:    "Inter", system-ui, sans-serif;

  --radius: 6px;
  --card-shadow: none;
  --tracking: -0.01em;
}

/* LAYER 2 - Dark by system preference, for the no-JS case */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode]) {
    --ground: #080d14; --surface: #0f1d35; --ink: #FFFFFF;
    --muted: #cbd5e1;  --line: #1e2a3a;    --accent: #ea580c;
    --accent-soft: rgba(234, 88, 12, .16);
    --header-bg: #0a1628; --header-ink: #FFFFFF; --header-sub: #cbd5e1;
    --good: #6DBF8C; --good-bg: #16261C;
    --warn: #D8A455; --warn-bg: #2A2113;
    --crit: #E58592; --crit-bg: #2B1518;
  }
}

/* LAYER 3 - Light, chosen */
:root[data-mode="light"] { /* inherits layer 1 */ }

/* LAYER 4 - Dark, chosen: the co/efficient website palette */
:root[data-mode="dark"] {
  --ground: #080d14; --surface: #0f1d35; --ink: #FFFFFF;
  --muted: #cbd5e1;  --line: #1e2a3a;    --accent: #ea580c;
  --accent-soft: rgba(234, 88, 12, .16);
  --header-bg: #0a1628; --header-ink: #FFFFFF; --header-sub: #cbd5e1;
  --good: #6DBF8C; --good-bg: #16261C;
  --warn: #D8A455; --warn-bg: #2A2113;
  --crit: #E58592; --crit-bg: #2B1518;
}

/* ===========================================================
   LAYER 5 - Glitter. Last, so it wins.
   =========================================================== */
:root[data-mode="glitter"] {
  --ground:      #EFE4FB;
  --ground-image: linear-gradient(170deg, #E6D8FA 0%, #F2E4FB 42%, #FDEBF6 100%);
  --surface:     #FFFFFF;
  --ink:         #3A1050;
  --muted:       #96579B;
  --line:        #F6CCE6;
  --accent:      #D6197D;
  --accent-soft: #FDE7F3;

  --header-bg:   #C4116E;
  --header-image: linear-gradient(100deg, #B60F66 0%, #E32C93 55%, #F468B8 100%);
  --header-ink:  #FFFFFF;
  --header-sub:  #FFD3EC;

  --good: #1E8E6A; --good-bg: #DFF4EC;
  --warn: #B4690E; --warn-bg: #FCEEDA;
  --crit: #D11149; --crit-bg: #FCE1EA;

  --display: "Fredoka", "Inter", system-ui, sans-serif;
  --radius: 16px;
  --card-shadow: 0 4px 18px rgba(198, 30, 130, .10);
  --tracking: 0em;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

body {
  background-color: var(--ground);
  background-image: var(--ground-image);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
  padding: 0 0 72px;
  transition: background-color .3s ease, color .3s ease;
}

#sparkles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity .45s ease;
}

:root[data-mode="glitter"] #sparkles { opacity: 1; }

.page {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1, h2, h3, .stat-value, .pill, .eyebrow, th, .btn, .tab, .step {
  font-family: var(--display);
  letter-spacing: var(--tracking);
}

p { margin: 0; }
a { color: var(--accent); }

/* ---------- header band ---------- */
.band {
  position: relative;
  z-index: 1;
  background-color: var(--header-bg);
  background-image: var(--header-image);
  color: var(--header-ink);
  padding: 20px 0 24px;
  margin-bottom: 24px;
  transition: background-color .3s ease;
}

.band-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.band-brand { display: flex; flex-direction: column; gap: 8px; }
.band-brand img { height: 34px; width: auto; display: block; align-self: flex-start; }

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--header-sub);
  margin: 0;
}

h1 {
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 600;
  line-height: 1.1;
  margin: 2px 0 0;
  text-wrap: balance;
  color: var(--header-ink);
}

.band .subtitle { color: var(--header-sub); font-size: 13.5px; margin-top: 5px; text-wrap: pretty; }

/* ---------- mode toggle ---------- */
.modes {
  display: inline-flex;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  margin-top: 4px;
}

.modes button {
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  width: 38px;
  height: 32px;
  cursor: pointer;
  color: var(--header-ink);
  transition: background-color .2s ease, transform .2s ease, color .2s ease;
}

.modes button svg { width: 16px; height: 16px; display: block; }
.modes button:hover { background: rgba(255,255,255,.18); }
.modes button[aria-pressed="true"] { background: #FFFFFF; color: var(--accent); transform: scale(1.02); }
.modes button:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }

/* ---------- section heads ---------- */
h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 0 0 12px;
}

h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }

/* ---------- stat tiles ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-radius .3s ease, box-shadow .3s ease, border-color .3s ease;
}

.tile-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.stat-value {
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.tile-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- cards / tables ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  transition: border-radius .3s ease, box-shadow .3s ease;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition: border-radius .3s ease, box-shadow .3s ease;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; color: var(--ink); }

th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.rowlink { cursor: pointer; }
tbody tr.rowlink:hover { background: var(--accent-soft); }
td.date, td.num { font-family: var(--mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill.ok    { background: var(--good-bg); color: var(--good); }
.pill.risk  { background: var(--warn-bg); color: var(--warn); }
.pill.block { background: var(--crit-bg); color: var(--crit); }
.pill.info  { background: var(--accent-soft); color: var(--accent); }
.pill.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s ease, border-radius .3s ease;
}

.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.small { font-size: 12.5px; padding: 6px 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- forms ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 18px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }

.field label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.field .hint { font-size: 12.5px; color: var(--muted); text-wrap: pretty; }

.src {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: .02em;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good);
}

.req { color: var(--crit); font-weight: 700; }

input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="date"],
select, textarea {
  font-family: var(--body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * .75);
  padding: 9px 12px;
  width: 100%;
  transition: border-color .15s ease;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
textarea.tall { min-height: 220px; }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.check .check-label { font-size: 14px; text-wrap: pretty; }
.check .check-note { font-size: 12.5px; color: var(--muted); text-wrap: pretty; }

/* ---------- stage stepper ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 8px; }

.step {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s ease;
}

.step.done { background: var(--good-bg); color: var(--good); border-color: transparent; }
.step.now { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }
.step.skip { opacity: .38; text-decoration: line-through; cursor: default; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); }

.tab {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  cursor: pointer;
  margin-bottom: -1px;
}

.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- callout ---------- */
.callout {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 15px 18px;
  font-size: 14px;
  text-wrap: pretty;
}

.callout .eyebrow { color: var(--accent); margin-bottom: 4px; }

/* ---------- fec results ---------- */
.fec-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.fec-result:last-child { border-bottom: 0; }
.fec-result .fec-name { font-weight: 600; font-size: 14.5px; }
.fec-result .fec-meta { font-size: 12.5px; color: var(--muted); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.save-status { font-size: 12.5px; color: var(--good); min-height: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }

/* ---------- print worksheet ---------- */
.print-only { display: none; }

@media print {
  body { background: #FFFFFF; color: #0D1B2A; padding: 0; }
  .band, .modes, .no-print, #sparkles { display: none !important; }
  .print-only { display: block; }
  .page { max-width: none; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .ws-missing { background: #FAF0DF !important; }
}

.ws-table { min-width: 0; }
.ws-table td { font-size: 14px; }
.ws-table td.ws-label { width: 38%; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.ws-missing { background: var(--warn-bg); }
.ws-missing-note { color: var(--warn); font-weight: 600; font-size: 12.5px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
