/* Tally. ONE design system: every color, size, space and radius is a custom property.
   Styles:  html[data-style=calm|bold|light]  (palette + type scale + spacing + radius)
   Layouts: html[data-layout=top|side|focus]
   Tab accent: [data-tab=home|review|rules|people|outreach|settings] sets --accent.
   To remove a style or a layout: delete its CSS block and its <option> line in index.html. */

/* contrast: --ok on --bg */
/* contrast: --ok on --panel */
/* contrast: --ok on --panel2 */
/* contrast: --warn on --bg */
/* contrast: --warn on --panel */
/* contrast: --warn on --panel2 */
/* contrast: --bad on --bg */
/* contrast: --bad on --panel */
/* contrast: --bad on --panel2 */
/* contrast: --text on --panel2 */
/* contrast: --accent on --panel2 */
/* contrast: --muted on --panel2 */
/* contrast: --on-fill on --accent */
/* contrast: --on-fill on --accent-home */
/* contrast: --on-fill on --accent-review */
/* contrast: --on-fill on --accent-rules */
/* contrast: --on-fill on --accent-people */
/* contrast: --on-fill on --accent-outreach */
/* contrast: --on-fill on --accent-settings */
/* contrast: --on-fill on --ok */
/* contrast: --on-fill on --bad */
/* contrast: --on-fill on --warn */

:root {
  /* fallback palette (same values as Calm dark); the style blocks below override all of it */
  --bg: #0c0d10; --panel: #14161b; --panel2: #1c1f27; --line: #2e323d; --line-strong: #7a8294;
  --text: #eceef2; --muted: #a9afbc; --ok: #5fd3a2; --warn: #f0b84a; --bad: #ff8590; --on-fill: #0c0d10;
  --accent-home: #8ab4ff; --accent-review: #c4a8ff; --accent-rules: #5fd3a2; --accent-people: #ffb36b; --accent-outreach: #6fd6e8; --accent-settings: #a3d95f;
  --accent: var(--accent-home);
  --orb-bg: #0b0f1a;
  --orb-off: #8a93a6; --orb-idle: #46beff; --orb-thinking: #78d7ff; --orb-sending: #3ce1c8; --orb-asking: #ffb840; --orb-alert: #ff4650; --orb-lost: #7b8090;
  --shade: rgba(4, 6, 12, .72);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-base: 15px; --fs-xs: .8rem; --fs-sm: .9rem; --fs-md: 1rem; --fs-lg: 1.2rem; --fs-xl: 1.5rem; --fs-2xl: 2rem;
  --fw-head: 600; --lh: 1.5; --u: .25rem; --r: 8px; --r-lg: 12px; --shadow: 0 10px 40px rgba(0, 0, 0, .5);
  --layout-scale: 1; --side-w: 30rem; --rail-w: 15rem; --hit: 2.3rem; --hit-sm: 2.1rem; --bd: var(--line); --row-bd: var(--line);
  color-scheme: dark;
}

/* ---------- STYLE: Calm dark (like Linear) ---------- */
html[data-style=calm] {
  --bg: #0c0d10; --panel: #14161b; --panel2: #1c1f27; --line: #2e323d; --line-strong: #7a8294;
  --text: #eceef2; --muted: #a9afbc; --ok: #5fd3a2; --warn: #f0b84a; --bad: #ff8590; --on-fill: #0c0d10;
  --accent-home: #8ab4ff; --accent-review: #c4a8ff; --accent-rules: #5fd3a2; --accent-people: #ffb36b; --accent-outreach: #6fd6e8; --accent-settings: #a3d95f;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-base: 15px; --fs-xs: .8rem; --fs-sm: .9rem; --fs-md: 1rem; --fs-lg: 1.2rem; --fs-xl: 1.5rem; --fs-2xl: 2rem;
  --fw-head: 600; --lh: 1.5; --u: .25rem; --r: 8px; --r-lg: 12px; --shadow: 0 10px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- STYLE: Bold cards (like Apple Health) ---------- */
html[data-style=bold] {
  --bg: #000000; --panel: #1c1c1e; --panel2: #2c2c2e; --line: #3a3a3c; --line-strong: #8e8e99;
  --text: #ffffff; --muted: #b4b4bd; --ok: #30d158; --warn: #ffd60a; --bad: #ff6b81; --on-fill: #000000;
  --accent-home: #5aa9ff; --accent-review: #ffa51f; --accent-rules: #ffd60a; --accent-people: #30d158; --accent-outreach: #c98cff; --accent-settings: #7fe0d0;
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --fs-base: 16px; --fs-xs: .85rem; --fs-sm: .95rem; --fs-md: 1.05rem; --fs-lg: 1.4rem; --fs-xl: 2rem; --fs-2xl: 2.8rem;
  --fw-head: 800; --lh: 1.45; --u: .3rem; --r: 14px; --r-lg: 24px; --bd: transparent; --row-bd: transparent; --shadow: 0 14px 50px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- STYLE: Clean light (like Stripe) ---------- */
html[data-style=light] {
  --bg: #f4f6fa; --panel: #ffffff; --panel2: #eceff5; --line: #d5dbe6; --line-strong: #6d7a90;
  --text: #0a2540; --muted: #4a5a72; --ok: #0a6b40; --warn: #8a4b00; --bad: #b3202f; --on-fill: #ffffff;
  --accent-home: #5144d6; --accent-review: #7a35c9; --accent-rules: #0a6b5c; --accent-people: #a34a00; --accent-outreach: #0a6c9c; --accent-settings: #3d5a80;
  --shade: rgba(20, 30, 50, .45);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-base: 15px; --fs-xs: .8rem; --fs-sm: .9rem; --fs-md: 1rem; --fs-lg: 1.15rem; --fs-xl: 1.5rem; --fs-2xl: 1.9rem;
  --fw-head: 600; --lh: 1.5; --u: .26rem; --r: 8px; --r-lg: 12px; --shadow: 0 12px 40px rgba(30, 50, 90, .18);
  color-scheme: light;
}

/* ---------- LAYOUT tokens ---------- */
html[data-layout=focus] { --layout-scale: 1.3; }

/* ---------- TAB accents ---------- */
[data-tab=home] { --accent: var(--accent-home); }
[data-tab=review] { --accent: var(--accent-review); }
[data-tab=rules] { --accent: var(--accent-rules); }
[data-tab=people] { --accent: var(--accent-people); }
[data-tab=runners] { --accent: var(--accent-people); }
[data-tab=outreach] { --accent: var(--accent-outreach); }
[data-tab=settings] { --accent: var(--accent-settings); }

/* ---------- derived spacing ---------- */
:root {
  --sp-1: calc(var(--u) * 1); --sp-2: calc(var(--u) * 2); --sp-3: calc(var(--u) * 3); --sp-4: calc(var(--u) * 4);
  --sp-5: calc(var(--u) * 6); --sp-6: calc(var(--u) * 9);
  --tint-ok: color-mix(in srgb, var(--ok) 16%, transparent);
  --tint-bad: color-mix(in srgb, var(--bad) 16%, transparent);
  --tint-warn: color-mix(in srgb, var(--warn) 16%, transparent);
  --tint-accent: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { font-size: calc(var(--fs-base) * var(--layout-scale)); }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: var(--lh); min-height: 100vh; overflow-x: hidden; }
h1, h2, h3, h4 { margin: 0; font-weight: var(--fw-head); line-height: 1.2; }
h2 { font-size: var(--fs-xl); margin-bottom: var(--sp-2); }
h3 { font-size: var(--fs-lg); margin: var(--sp-5) 0 var(--sp-2); }
h4 { font-size: var(--fs-md); margin: var(--sp-3) 0 var(--sp-1); }
p { margin: var(--sp-2) 0; }
code, pre, textarea.mono { font-family: var(--mono); }
code { background: var(--panel2); padding: .1em .4em; border-radius: var(--r); }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
#app { max-width: 80rem; margin: 0 auto; padding: 0 clamp(.6rem, 3vw, 2rem) var(--sp-6); }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) 0; }
.refresh { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-head); font-size: var(--fs-lg); letter-spacing: .02em; }
.logo { width: 1.7rem; height: 1.7rem; flex: none; }
.logo-bg { fill: var(--accent); }
.logo-mark { fill: none; stroke: var(--on-fill); stroke-width: 2.2; stroke-linecap: round; }
.orb-block { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.orb-wrap { width: 2.9rem; height: 2.9rem; border-radius: 50%; background: var(--orb-bg); flex: none; overflow: hidden; }
#orb { width: 100%; height: 100%; display: block; }
.state { min-width: 0; }
.state-label { font-size: var(--fs-md); letter-spacing: .08em; font-weight: var(--fw-head); line-height: 1.1; }
.state-detail { color: var(--muted); font-size: var(--fs-xs); margin: 0; min-height: 1.1em; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin: var(--sp-1) 0 0; }
.chip { font-size: var(--fs-xs); padding: 0 var(--sp-2); border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text); white-space: nowrap; }
.chip.good { color: var(--ok); border-color: var(--ok); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.bad, .chip.live { color: var(--bad); border-color: var(--bad); }
.chip.muted { color: var(--muted); }
.search { position: relative; flex: 1 1 13rem; max-width: 20rem; min-width: 0; }
.search input { width: 100%; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow); z-index: 60; max-height: 60vh; overflow-y: auto; padding: var(--sp-1); }
.results h4 { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; margin: var(--sp-2) var(--sp-2) var(--sp-1); }
.results button { display: flex; width: 100%; justify-content: space-between; gap: var(--sp-3); text-align: left; font: inherit; color: var(--text); background: none; border: 0; border-radius: var(--r); padding: var(--sp-2) var(--sp-3); cursor: pointer; }
.results button:hover, .results button[aria-selected="true"] { background: var(--panel2); }
.results .sub { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .none { color: var(--muted); padding: var(--sp-3); margin: 0; }
.controls { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: center; margin-left: auto; }
.master { font: inherit; font-weight: 700; cursor: pointer; padding: var(--sp-2) var(--sp-4); border-radius: 999px; border: 2px solid var(--line-strong); background: var(--panel); color: var(--text); }
.master[aria-pressed="true"] { border-color: var(--ok); }
.master:hover { background: var(--panel2); }
.dry { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; position: relative; }
.dry input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dry-track { width: 2.6rem; height: 1.45rem; background: var(--panel2); border: 1px solid var(--line-strong); border-radius: 999px; position: relative; flex: none; }
.dry-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.45rem - 8px); height: calc(1.45rem - 8px); border-radius: 50%; background: var(--text); transition: transform .2s; }
.dry input:checked + .dry-track { background: var(--warn); border-color: var(--warn); }
.dry input:checked + .dry-track::after { transform: translateX(1.15rem); background: var(--on-fill); }
.dry input:focus-visible + .dry-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.dry-text { font-size: var(--fs-sm); }
.switches { display: flex; gap: var(--sp-2); }
.switches select { font-size: var(--fs-xs); padding: var(--sp-1) var(--sp-2); }

.nav { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); }
.nav button { font: inherit; flex: 1 1 0; min-width: 0; padding: var(--sp-3) var(--sp-1); border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); cursor: pointer; border-radius: var(--r) var(--r) 0 0; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.nav button::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); flex: none; }
.nav button:hover { color: var(--text); background: var(--panel); }
.nav button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: var(--fw-head); }
.nav .badge { background: var(--warn); color: var(--on-fill); border-radius: 999px; padding: 0 .45em; font-size: var(--fs-xs); font-weight: 700; line-height: 1.4; }
.main { min-width: 0; outline: none; }
.tab-title { display: none; }
.screen > h2:first-child { margin-top: 0; }

/* ---------- LAYOUT: side menu ---------- */
@media (min-width: 901px) {
  html[data-layout=side] #app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); gap: 0 var(--sp-5); max-width: 90rem; }
  html[data-layout=side] .rail { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-3) 0; }
  html[data-layout=side] .topbar { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  html[data-layout=side] .controls { margin-left: 0; flex-direction: column; align-items: stretch; }
  html[data-layout=side] .rail { min-width: 0; overflow-x: hidden; }
  html[data-layout=side] .topbar > * { min-width: 0; }
  html[data-layout=side] .search { max-width: none; flex: none; }
  html[data-layout=side] .switches { flex-direction: column; }
  html[data-layout=side] .controls { width: 100%; }
  html[data-layout=side] .controls .master { width: 100%; }
  html[data-layout=side] .chip { white-space: normal; }
  html[data-layout=side] .topbar, html[data-layout=side] .orb-block, html[data-layout=side] .state, html[data-layout=side] .controls { max-width: 100%; }
  html[data-layout=side] .orb-wrap { width: 3.6rem; height: 3.6rem; }
  html[data-layout=side] .nav { flex-direction: column; border-bottom: 0; margin: var(--sp-2) 0 0; }
  html[data-layout=side] .nav button { flex: none; justify-content: flex-start; border-bottom: 0; border-left: 3px solid transparent; border-radius: 0 var(--r) var(--r) 0; padding: var(--sp-3) var(--sp-4); }
  html[data-layout=side] .nav button[aria-current="page"] { border-left-color: var(--accent); background: var(--panel); }
  html[data-layout=side] .main { padding-top: var(--sp-3); }
}

/* ---------- LAYOUT: focus (one tab at a time, very large) ---------- */
html[data-layout=focus] #app { max-width: 52rem; }
html[data-layout=focus] .nav { gap: var(--sp-2); flex-wrap: wrap; border: 0; }
html[data-layout=focus] .nav button { flex: 1 1 auto; border: 2px solid var(--line); border-radius: 999px; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-md); }
html[data-layout=focus] .nav button[aria-current="page"] { border-color: var(--accent); background: var(--tint-accent); }
html[data-layout=focus] .tab-title { display: block; font-size: var(--fs-2xl); color: var(--accent); margin: var(--sp-4) 0 var(--sp-4); font-weight: var(--fw-head); }
html[data-layout=focus] .cols2 { grid-template-columns: minmax(0, 1fr); }
html[data-layout=focus] .quick { grid-template-columns: minmax(0, 1fr); }
html[data-layout=focus] .cards { grid-template-columns: minmax(0, 1fr); }
html[data-layout=focus] .side { width: 100%; }
html[data-layout=focus] body.side-open #app { padding-right: clamp(.6rem, 3vw, 2rem); }

/* ---------- cards, rows, lists ---------- */
.card { background: var(--panel); border: 1px solid var(--bd); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin: 0 0 var(--sp-4); }
.card > h3:first-child, .card > .card-head h3 { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.card-head h3 { margin: 0; }
.count { background: var(--accent); color: var(--on-fill); border-radius: 999px; padding: 0 .6em; font-size: var(--fs-sm); font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
.cards > .card { margin: 0; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
.cols2 > .card { margin: 0; }
.lrow { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--row-bd); min-width: 0; }
.lrow:last-child { border-bottom: 0; }
.r-main { flex: 1 1 0; min-width: 0; display: flex; align-items: baseline; gap: var(--sp-3); text-align: left; font: inherit; color: var(--text); background: none; border: 0; padding: var(--sp-1) 0; cursor: pointer; overflow: hidden; }
.r-main:hover strong { text-decoration: underline; }
.r-main strong { flex: 0 1 auto; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-head); }
.r-main .phrase { flex: 1 1 0; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.r-actions { display: flex; gap: var(--sp-2); flex: none; align-items: center; }
/* A Home row of the person cards: the name on its own line, the description under it on up to two lines, in the small size. */
.lrow.two .r-main { flex-direction: column; align-items: stretch; gap: 2px; }
.lrow.two .r-main strong { max-width: 100%; }
.lrow.two .r-main .phrase { flex: none; width: 100%; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; font-size: var(--fs-xs); line-height: 1.35; }
.scroll-x { overflow-x: auto; }
.lrow.on-row { background: var(--tint-accent); }
.listbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin: var(--sp-2) 0 var(--sp-3); }
.listbar input[type="search"] { flex: 1 1 12rem; }
.more-row { padding-top: var(--sp-3); }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.fchip { font: inherit; font-size: var(--fs-sm); padding: var(--sp-1) var(--sp-3); border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); cursor: pointer; }
.fchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-fill); font-weight: 700; }
.quick { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); margin: var(--sp-4) 0; }
.qbtn { font: inherit; display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-1); text-align: left; padding: var(--sp-4); border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); cursor: pointer; min-height: 5.2rem; }
.qbtn:hover { border-color: var(--accent); background: var(--panel2); }
.qbtn strong { font-size: var(--fs-md); font-weight: var(--fw-head); }
.qbtn span { color: var(--muted); font-size: var(--fs-xs); }
.clear { text-align: center; padding: var(--sp-6) var(--sp-4); }
.clear h2 { color: var(--ok); font-size: var(--fs-2xl); }
.clear p { color: var(--muted); }
details.more { margin-top: var(--sp-5); }
details.more > summary { display: inline-block; cursor: pointer; font-weight: var(--fw-head); color: var(--accent); padding: var(--sp-2) 0; }
details.more > .more-body { margin-top: var(--sp-2); }
details.fold { border: 1px solid var(--line); border-radius: var(--r); padding: .1rem var(--sp-4); margin: var(--sp-3) 0; background: var(--panel); }
details.fold > summary { cursor: pointer; padding: var(--sp-3) 0; color: var(--text); font-weight: 500; }
details.fold[open] > summary { margin-bottom: var(--sp-1); }
details.fold.wide { border: 0; background: none; padding: 0; flex-basis: 100%; }
details.fold.wide > summary { color: var(--muted); font-size: var(--fs-sm); padding: var(--sp-1) 0; }
details.lazy > .lazy-body > section > h2:first-child { display: none; }
details.lazy > .lazy-body > section { padding: 0; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---------- side panel ---------- */
.side { position: fixed; top: 0; right: 0; bottom: 0; width: var(--side-w); max-width: 100vw; background: var(--panel); border-left: 1px solid var(--line-strong); z-index: 40; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
.side-head h2 { margin: 0; font-size: var(--fs-lg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-body { padding: var(--sp-4); overflow-y: auto; flex: 1 1 auto; }
.side-body > section { padding: 0; border: 0; }
@media (min-width: 1101px) {
  body.side-open #app { padding-right: calc(var(--side-w) + clamp(.6rem, 3vw, 2rem)); }
}
@media (max-width: 1100px) { .side { width: 100%; z-index: 70; } }

/* ---------- messages, forms, buttons ---------- */
.help { color: var(--muted); margin: 0 0 var(--sp-3); max-width: 70ch; }
.empty { color: var(--muted); padding: var(--sp-4); border: 1px dashed var(--line-strong); border-radius: var(--r); text-align: center; margin: var(--sp-2) 0; }
.note { background: var(--panel2); border-left: 4px solid var(--warn); padding: var(--sp-3) var(--sp-4); border-radius: var(--r); margin: var(--sp-3) 0; }
.note.bad { border-color: var(--bad); }
.note.ok { border-color: var(--ok); }
button.btn, a.btn { font: inherit; cursor: pointer; padding: var(--sp-2) var(--sp-4); border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--panel2); color: var(--text); min-height: 2.3rem; }
button.btn:hover { border-color: var(--accent); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-fill); font-weight: 700; }
button.btn.danger { border-color: var(--bad); color: var(--bad); }
button.btn.danger-fill { background: var(--bad); border-color: var(--bad); color: var(--on-fill); font-weight: 700; }
button.btn.good { background: var(--ok); border-color: var(--ok); color: var(--on-fill); font-weight: 700; }
button.btn.bad { background: var(--bad); border-color: var(--bad); color: var(--on-fill); font-weight: 700; }
button.btn.small { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); min-height: 2rem; }
button.btn.big { padding: var(--sp-4); font-size: var(--fs-lg); font-weight: 700; }
button.btn:disabled { opacity: .55; cursor: not-allowed; }
button.btn.prepare { background: transparent; border: 1px dashed var(--warn); color: var(--warn); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; text-align: left; }
input[type="text"], input[type="number"], input[type="password"], input[type="time"], input[type="search"], select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r); padding: var(--sp-2) var(--sp-3); max-width: 100%; min-height: 2.3rem;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="number"] { width: 8rem; }
input[type="checkbox"] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 1px solid var(--accent); }
textarea { width: 100%; resize: vertical; }
textarea.editor { min-height: 22rem; font-size: var(--fs-sm); line-height: 1.55; tab-size: 2; white-space: pre; }
textarea.big-box { min-height: 9rem; font-size: var(--fs-lg); line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: var(--sp-1); margin: var(--sp-3) 0; }
.field-label { font-size: var(--fs-sm); color: var(--muted); }
.field-label.strong { color: var(--text); font-weight: 600; }
.hint { font-size: var(--fs-sm); color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin: var(--sp-3) 0; }
.row.end { justify-content: flex-end; }
.row.tight { margin: 0; }
.status { color: var(--ok); font-size: var(--fs-sm); }
.status.err { color: var(--bad); }
.status-slot { min-height: 1.4em; flex-basis: 100%; }
.checks { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.checks label, label.checks { display: inline-flex; align-items: center; gap: var(--sp-2); }
.meter { height: .5rem; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: var(--sp-2) 0; }
.meter span { display: block; height: 100%; background: var(--ok); }
.meter.hot span { background: var(--bad); }
.big-num { font-size: var(--fs-2xl); font-weight: var(--fw-head); line-height: 1.1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-1) var(--sp-4); margin: var(--sp-3) 0; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- tables, badges ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }
th, td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge-pill { display: inline-block; border-radius: 999px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border: 1px solid var(--line-strong); white-space: nowrap; color: var(--text); }
.badge-pill.confirmed { color: var(--ok); border-color: var(--ok); }
.badge-pill.default { color: var(--warn); border-color: var(--warn); }
.badge-pill.bad { color: var(--bad); border-color: var(--bad); }
.item { border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-4); margin: var(--sp-3) 0; background: var(--panel); }
.item-head { display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; align-items: center; }
.val { color: var(--muted); margin: var(--sp-1) 0; word-break: break-word; }
.wrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.wmain { min-width: 0; flex: 1 1 14rem; }

/* ---------- rules, diff, history ---------- */
.split { display: grid; grid-template-columns: 13rem 1fr; gap: var(--sp-5); }
.filelist { display: flex; flex-direction: column; gap: var(--sp-1); }
.filelist button { font: inherit; text-align: left; padding: var(--sp-2) var(--sp-3); border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--panel2); color: var(--text); cursor: pointer; }
.filelist button[aria-current="true"] { border-color: var(--accent); background: var(--tint-accent); font-weight: 600; }
pre.diff { margin: var(--sp-3) 0; padding: var(--sp-3); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); max-height: 22rem; overflow: auto; font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; }
.dl.add { color: var(--ok); background: var(--tint-ok); display: block; }
.dl.del { color: var(--bad); background: var(--tint-bad); display: block; }
.dl.same { color: var(--muted); display: block; }
.box { border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-4); margin: var(--sp-4) 0; background: var(--panel2); }
.warnlist { margin: var(--sp-2) 0; padding-left: 1.2rem; color: var(--warn); }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.hist .when { color: var(--muted); font-size: var(--fs-sm); min-width: 9rem; }
.rcard { border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-3) var(--sp-4); margin: var(--sp-3) 0; background: var(--panel2); }
.rcard.off { border-style: dashed; }
.rcard.changed { border-color: var(--warn); }
.rcard p { margin: var(--sp-1) 0; }
.rtext { white-space: pre-wrap; }
.msg-text { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-3); margin: var(--sp-2) 0; }
.msg-text.draft { border-color: var(--accent); }
.outcome { font-weight: 600; margin: var(--sp-3) 0 var(--sp-1); }
.outcome.ask { color: var(--warn); }
.outcome.bad { color: var(--bad); }
.dry-note { margin: 0; font-weight: 700; }
.dry-note.on { color: var(--warn); }
.dry-note.ok { color: var(--ok); }
.dry-note.live { color: var(--bad); }
.pre-line { white-space: pre-line; }
.tpl h4 { margin: var(--sp-3) 0 var(--sp-1); }
.tpl-part { margin: var(--sp-2) 0 var(--sp-1); color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }
.tpl-line { margin: var(--sp-1) 0; padding-left: var(--sp-3); border-left: 2px solid var(--line-strong); }
.menu summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); }
.menu .mrow { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin: var(--sp-2) 0; }
.menu .mrow span.hint { flex: 1 1 14rem; }
.rolegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); }
.rolegrid select { width: 100%; }
.rolegrid .field { margin: 0; }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--sp-4); }
.chart { border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-4); background: var(--panel); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; margin-top: var(--sp-3); }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bars .bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars small { color: var(--muted); font-size: var(--fs-xs); margin-top: var(--sp-1); }
.hbar { display: grid; grid-template-columns: minmax(5rem, 9rem) 1fr 5rem; gap: var(--sp-3); align-items: center; margin: var(--sp-2) 0; font-size: var(--fs-sm); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: .6rem; background: var(--panel2); border-radius: 999px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; background: var(--accent); }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- modal, toasts, auth ---------- */
.modal-back { position: fixed; inset: 0; background: var(--shade); display: grid; place-items: center; z-index: 90; padding: var(--sp-4); }
.modal { background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: var(--sp-5); max-width: 28rem; width: 100%; box-shadow: var(--shadow); }
.modal-text { margin: 0 0 var(--sp-4); font-size: var(--fs-md); }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); z-index: 95; width: max-content; max-width: min(26rem, calc(100vw - 2rem)); pointer-events: none; }
.toast { background: var(--panel2); color: var(--text); border: 1px solid var(--ok); border-radius: var(--r); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); }
.toast.err { border-color: var(--bad); }
.toast button { pointer-events: auto; }
.auth { position: fixed; inset: 0; background: var(--shade); display: grid; place-items: center; z-index: 100; padding: var(--sp-4); }
.auth-box { background: var(--panel); border: 1px solid var(--bad); border-radius: var(--r-lg); padding: var(--sp-6); max-width: 34rem; }
.auth-box h1 { color: var(--bad); margin-bottom: var(--sp-3); }
.auth-box p { font-size: var(--fs-md); margin: 0; }

/* ---------- person cards: colour that means something, clear tags and buttons, more room ---------- */
#app { max-width: 88rem; }
.card { padding: var(--sp-5); margin-bottom: var(--sp-5); }
/* Home sections: one colour per kind. */
.card[data-sec] { border-left: 4px solid var(--sec); }
.card[data-sec] .count { background: var(--sec); }
[data-sec=money_out] { --sec: var(--bad); }
[data-sec=mgm_due], [data-sec=redep_wait] { --sec: var(--warn); }
[data-sec=waiting] { --sec: var(--accent); }
[data-sec=leadership] { --sec: var(--ok); }
/* The leadership panel: three target lines, five tiles in one row. */
.card[data-sec=leadership] { padding: var(--sp-4) var(--sp-5); }
.lead-targets { margin: 0 0 var(--sp-3); padding-left: 1.3em; line-height: 1.4; }
.lead-targets li { margin: 0; }
.lead-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); }
@media (max-width: 760px) { .lead-tiles { grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); } }
.lead-tile { background: var(--panel2); border-radius: var(--r); padding: var(--sp-2) var(--sp-3); min-width: 0; }
.lead-tile .big-num { font-size: var(--fs-xl); display: block; }
.lead-tile .what { display: block; font-size: var(--fs-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-tile .delta { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
/* Rows: room, a hover, and an arrow that says "this opens". */
.lrow.two { padding: var(--sp-3); margin: 0 calc(-1 * var(--sp-3)); border-radius: var(--r); }
.lrow.two:hover, .lrow.two:focus-within { background: var(--panel2); }
.lrow.two .r-main { gap: var(--sp-1); }
.lrow.two .r-main strong::after { content: " \203A"; color: var(--muted); font-weight: 400; }
.lrow.two .r-main:hover strong::after { color: var(--accent); }
.lrow.two .r-main .phrase { font-size: var(--fs-sm); line-height: 1.45; }
.r-actions { gap: var(--sp-2) var(--sp-3); }
.lrow.two .r-actions { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; }
/* Parts of a description. */
.t-key { color: var(--text); }
.t-bad { color: var(--bad); font-weight: 600; }
.t-warn { color: var(--warn); }
.t-info { color: var(--accent); }
.t-good { color: var(--ok); }
td.t-bad, td.t-good { font-weight: 600; }
/* Tags: filled, one colour per meaning. */
.chip { border-color: transparent; background: color-mix(in srgb, var(--line-strong) 22%, transparent); padding: .12rem var(--sp-3); font-weight: 500; cursor: default; }
.chip.good { background: var(--tint-ok); }
.chip.warn { background: var(--tint-warn); }
.chip.bad, .chip.live { background: var(--tint-bad); }
.chip.bad.solid { background: var(--bad); color: var(--on-fill); font-weight: 700; }
/* Buttons: the main action of a row stands out, the snooze list stays quiet. */
button.btn { transition: background .12s, border-color .12s, color .12s; }
button.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 14%, transparent); }
button.btn.primary:hover:not(:disabled), button.btn.good:hover:not(:disabled), button.btn.bad:hover:not(:disabled), button.btn.danger-fill:hover:not(:disabled) { filter: brightness(1.12); }
button.btn.primary:hover:not(:disabled) { background: var(--accent); }
button.btn.good:hover:not(:disabled) { background: var(--ok); }
button.btn.bad:hover:not(:disabled), button.btn.danger-fill:hover:not(:disabled) { background: var(--bad); }
button.btn.done { border-color: var(--accent); color: var(--accent); background: transparent; font-weight: 600; }
button.btn.done::before { content: "\2713\00a0"; }
button.btn.done:hover:not(:disabled) { background: var(--accent); color: var(--on-fill); }
select.quiet { background: transparent; border-color: var(--line); color: var(--muted); }
select.quiet:hover { border-color: var(--line-strong); color: var(--text); }
/* A switch that is on: filled, with a tick. */
.fchip:hover { border-color: var(--accent); }
.fchip[aria-pressed="true"]::before { content: "\2713\00a0"; }
.fchip[aria-pressed="false"] { color: var(--muted); }
/* The side card: wider, and its table fits. */
:root { --side-w: 38rem; }
.side-body table { font-size: var(--fs-sm); }
.side-body th { letter-spacing: 0; text-transform: none; white-space: normal; vertical-align: bottom; }
.side-body th, .side-body td { padding: var(--sp-2); }
.side-body .lrow { align-items: baseline; }
/* Beside the open side card the list is narrow: the tags and buttons of a row go under its text. */
body.side-open .lrow.two { flex-wrap: wrap; }
body.side-open .lrow.two .r-main { flex-basis: 100%; }
body.side-open .lrow.two .r-actions { justify-content: flex-start; }
@media (max-width: 900px) { .lrow.two { flex-wrap: wrap; } .lrow.two .r-main { flex-basis: 100%; } .lrow.two .r-actions { justify-content: flex-start; } }
.note > .card-head { margin-bottom: 0; }
.note > .card-head h3 { margin: 0; }

/* ---------- narrow ---------- */
@media (max-width: 900px) {
  .cols2, .cards { grid-template-columns: minmax(0, 1fr); }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  html { font-size: var(--fs-base); }
  .topbar { gap: var(--sp-2) var(--sp-3); }
  .search { flex-basis: 100%; max-width: none; order: 3; }
  .controls { margin-left: 0; width: 100%; justify-content: space-between; order: 4; }
  .nav button { font-size: var(--fs-xs); padding-left: 0; padding-right: 0; flex-direction: column; gap: var(--sp-1); }
  .nav button::before { display: none; }
  .split { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: minmax(4rem, 6rem) 1fr 4rem; }
  .rolegrid { grid-template-columns: minmax(0, 1fr); }
  .quick { grid-template-columns: minmax(0, 1fr); }
  button.btn, input, select, textarea { min-height: 2.6rem; }
  .r-main { flex-direction: column; gap: 0; }
  .r-main strong { max-width: 100%; }
  .r-main .phrase { width: 100%; flex: none; }
  .card { padding: var(--sp-4); }
  .state-detail { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* less noise in Bold: fewer borders and pills */
html[data-style=bold] .chip { border-color: transparent; }
html[data-style=bold] .nav button::before { display: none; }
html[data-style=bold] .badge-pill { border-color: transparent; padding: 0; }
html[data-style=bold] .nav { border-bottom-color: transparent; }
html[data-style=bold] .lrow { padding: var(--sp-3) 0; }
html[data-style=bold] .lrow.two { padding: var(--sp-3); }
/* hit targets and disabled controls */
button.btn, a.btn, input[type="text"], input[type="number"], input[type="password"], input[type="time"], input[type="search"], select, textarea { min-height: var(--hit); }
button.btn.small { min-height: var(--hit-sm); }
button:disabled, button.btn:disabled { opacity: 1; cursor: not-allowed; color: var(--muted); background: var(--panel2); border: 1px dashed var(--line-strong); }
.why { color: var(--muted); font-size: var(--fs-sm); }
.info { border-left: 4px solid var(--line-strong); padding: var(--sp-2) var(--sp-4); margin: var(--sp-3) 0; background: var(--panel2); border-radius: var(--r); }
.info p { margin: var(--sp-1) 0; }
.info .hint { margin: 0; }
html[data-layout=side] .chips { flex-direction: column; align-items: flex-start; }
@media (max-width: 640px) { :root { --hit: 2.7rem; --hit-sm: 2.5rem; } }

/* ---------- v2 page: four tabs ---------- */
#problems .note { font-size: var(--fs-md); font-weight: 600; margin: 0 0 var(--sp-3); }
.ok-line { color: var(--ok); margin: var(--sp-1) 0; }
.bad-line { color: var(--bad); margin: var(--sp-1) 0; }
.screen .card .item { background: var(--panel2); }
.screen .big-box { min-height: 9rem; }

/* ---------- Runners tab: tiles, vertical columns, money cards ---------- */
.rn-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--sp-4); margin: 0 0 var(--sp-4); }
.rn-tile { background: var(--panel); border: 1px solid var(--bd); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); min-width: 0; }
.rn-tile-big { font-size: var(--fs-2xl); font-weight: var(--fw-head); line-height: 1.1; font-variant-numeric: tabular-nums; }
.rn-tile-label { font-weight: 600; margin-top: var(--sp-1); }
.rn-tile-ctx { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-1); }
.rn-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
@media (min-width: 1700px) { .rn-pair { grid-template-columns: auto minmax(22rem, 1fr); } }
.rn-pair > * { min-width: 0; }
.rn-pair .card, .rn-boardwrap .rn-shot { margin: 0; }
.rn-boardwrap .row { margin-bottom: var(--sp-3); }
.rn-shot { width: 760px; box-sizing: border-box; background: var(--panel); border: 1px solid var(--bd); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); }
.rn-shot h3 { margin: 0 0 var(--sp-3); }
.rn-cols { display: flex; gap: var(--sp-3); align-items: flex-start; }
.rn-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); text-align: center; }
.rn-plot { height: 11rem; width: 100%; box-sizing: border-box; padding-top: 1.6rem; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.rn-bar { position: relative; display: block; width: 70%; max-width: 3.5rem; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.rn-bar.light { background: color-mix(in srgb, var(--accent) 45%, var(--panel)); }
.rn-num { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 2px; font-weight: var(--fw-head); font-variant-numeric: tabular-nums; }
.rn-name { max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; font-size: var(--fs-sm); line-height: 1.25; }
.rn-change { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.rn-change.t-good { color: var(--ok); }
.rn-change.t-bad { color: var(--bad); }
.rn-total { display: flex; gap: var(--sp-3); align-items: baseline; border-top: 1px solid var(--line); margin-top: var(--sp-3); padding-top: var(--sp-2); }
.rn-spark { display: inline-flex; align-items: flex-end; gap: 2px; width: 48px; height: 20px; vertical-align: middle; }
.rn-spark span { flex: 1; min-height: 2px; background: var(--accent); border-radius: 1px 1px 0 0; }
.rn-spark span:not(:last-child) { background: color-mix(in srgb, var(--accent) 45%, var(--panel)); }
.rn-mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-4); align-items: start; margin-top: var(--sp-3); }
.rn-mcard { background: var(--panel2); border-radius: var(--r-lg); padding: var(--sp-4); min-width: 0; }
.rn-mcard h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); }
.rn-sums { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); margin-bottom: var(--sp-3); }
.rn-sum-big { font-size: var(--fs-xl); font-weight: var(--fw-head); line-height: 1.1; font-variant-numeric: tabular-nums; }
.rn-sum .hint { margin: 0; }
.rn-mcard details.fold { background: var(--panel); }
tr.t-dim td { color: var(--muted); font-size: var(--fs-xs); }
