:root {
  --chassis: #e4e7ec;
  --panel: #ffffff;
  --ink: #17202e;
  --muted: #566073;
  --rule: #c5cbd6;
  --air: #d93a4f;
  --led: #17a567;
  --focus: #1f4fd8;
  --font-head: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chassis: #141a24;
    --panel: #1c2432;
    --ink: #e8ecf3;
    --muted: #9aa5b8;
    --rule: #33405a;
    --air: #ff5d72;
    --led: #3ddc97;
    --focus: #8fb0ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--chassis); color: var(--ink); font: 400 16px/1.55 var(--font-body); }
h1, h2, h3, .brand { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.1; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.brand { font-size: 1.05rem; margin: 0 0 1.5rem; }
.brand a { text-decoration: none; }

/* buttons */
.btn { font: 600 .95rem var(--font-body); padding: .6rem 1rem; border-radius: 5px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.btn-primary { background: var(--ink); color: var(--chassis); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--chassis)); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* tally light: the one memorable element */
.tally { display: inline-flex; align-items: center; gap: .6rem; font: 600 .95rem var(--font-body); padding: .45rem .8rem; border: 1.5px solid var(--rule); border-radius: 999px; background: var(--panel); }
.lamp { width: .85rem; height: .85rem; border-radius: 50%; background: var(--rule); flex: none; }
.tally.live { border-color: var(--air); }
.tally.live .lamp { background: var(--air); box-shadow: 0 0 0 4px color-mix(in srgb, var(--air) 25%, transparent), 0 0 14px var(--air); }

/* landing */
.landing-grid { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.landing-copy { padding: clamp(1.5rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.landing-copy h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); margin-bottom: 1rem; }
.lede { max-width: 34rem; font-size: 1.15rem; color: var(--muted); margin: 0 0 2rem; }
.fine { max-width: 34rem; font-size: .85rem; color: var(--muted); margin-top: 1.5rem; }
.landing-stage { background: var(--ink); color: var(--chassis); display: flex; flex-direction: column; justify-content: space-between; padding: 2rem; }
.landing-stage .tally { align-self: flex-start; background: transparent; color: var(--chassis); border-color: var(--air); }
.landing-stage .lamp { background: var(--air); box-shadow: 0 0 0 4px color-mix(in srgb, var(--air) 25%, transparent), 0 0 14px var(--air); }
.stage-caption { font: 700 clamp(1.4rem, 3vw, 2.2rem)/1.2 var(--font-head); text-align: center; margin: 0 0 3rem; }

/* dashboard shell */
.shell { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 2rem; max-width: 72rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.shell-admin { grid-template-columns: minmax(0, 1fr); max-width: 56rem; }
.rail { position: sticky; top: 1.5rem; align-self: start; display: flex; flex-direction: column; gap: 1rem; }
.who-name { font: 700 1.4rem var(--font-head); margin: 0; overflow-wrap: anywhere; }
.who-meta { margin: 0; color: var(--muted); text-transform: capitalize; }
.rail-note { font-size: .9rem; color: var(--air); margin: 0; }
.rail-actions { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.lede-sm { color: var(--muted); margin: 0 0 1.5rem; }

/* modules */
.modules { display: flex; flex-direction: column; gap: 1rem; }
.module { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; }
.module-head { display: flex; gap: 1rem; align-items: flex-start; padding: 1rem 1.25rem; }
.module-title { flex: 1; min-width: 0; }
.module-title h2 { margin: 0; }
.module-title p { margin: .15rem 0 0; color: var(--muted); font-size: .95rem; }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: .05rem .5rem; border: 1px solid var(--rule); border-radius: 4px; color: var(--muted); margin-left: .5rem; vertical-align: middle; }
.switch { display: inline-flex; align-items: center; gap: .55rem; background: none; border: 0; padding: .25rem; font: 600 .9rem var(--font-body); color: var(--ink); cursor: pointer; }
.switch[disabled] { opacity: .5; cursor: not-allowed; }
.switch .track { width: 2.6rem; height: 1.4rem; border-radius: 4px; border: 1.5px solid var(--ink); background: var(--chassis); position: relative; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(50% - 2px); height: calc(100% - 4px); background: var(--ink); border-radius: 2px; transition: transform .12s; }
.switch[aria-checked="true"] .track::after { transform: translateX(100%); background: var(--led); }
.switch[aria-checked="true"] .track { border-color: var(--led); }
.module-body { border-top: 1px solid var(--rule); padding: 1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }
.module-toggle { margin: 0 1.25rem 1rem; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
legend { font: 700 1rem var(--font-head); padding: 0 0 .5rem; }
.field { display: flex; flex-direction: column; gap: .2rem; max-width: 34rem; }
.field label { font-weight: 600; }
.field .hint { color: var(--muted); font-size: .88rem; }
.field.check { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: .6rem; }
.field.check .hint { flex-basis: 100%; padding-left: 1.6rem; }
input[type=text], input[type=number], input[type=password], select, textarea { font: inherit; padding: .5rem .6rem; border: 1.5px solid var(--rule); border-radius: 5px; background: var(--chassis); color: var(--ink); width: 100%; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
textarea { min-height: 6rem; resize: vertical; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--air); }
.error { color: var(--air); font-size: .9rem; font-weight: 600; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 12rem; }
.linkbox { display: flex; flex-direction: column; gap: .3rem; max-width: 40rem; }
.linkbox label { font-weight: 600; }
.actions { display: flex; flex-direction: column; gap: .6rem; max-width: 40rem; }

/* admin */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 1.25rem; margin-top: 1.25rem; display: flex; flex-direction: column; gap: .75rem; align-items: flex-start; }
.help { color: var(--muted); font-size: .92rem; margin: 0; max-width: 40rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; color: var(--muted); font-size: .9rem; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: var(--chassis); padding: .7rem 1.1rem; border-radius: 6px; max-width: min(32rem, 92vw); font-weight: 600; z-index: 10; }
.toast.bad { background: var(--air); color: #fff; }

@media (max-width: 760px) {
  .landing-grid { grid-template-columns: 1fr; }
  .landing-stage { min-height: 16rem; }
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; }
}
@media (prefers-reduced-motion: reduce) { .switch .track::after { transition: none; } }
