:root {
  --bg: #f7f9fc; --surface: #fff; --ink: #16254f; --muted: #5a6877; --line: #dbe2ee;
  /* Festival logo palette: royal navy, lobster coral, starfish aqua, trumpet gold (matched by eye). */
  --brand: #1f3d8c; --brand-ink: #fff; --accent: #cc3f2d; --accent-ink: #fff; --aqua: #4ec5e0; --gold: #e8c62a;
  --good-bg: #dff3e6; --good: #17633a; --warn-bg: #fdefc8; --warn: #7a5200;
  --bad-bg: #fee2e2; --bad: #a62820; --info-bg: #dcecfb; --info: #1f3d8c; --chip-bg: #edf1f7;
  --radius: 10px; --shadow: 0 1px 2px rgba(15, 35, 50, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1430; --surface: #142050; --ink: #eef2fa; --muted: #a9b6d3; --line: #2b3b74;
    --brand: #16296a; --accent: #f0705f; --accent-ink: #2a0a06;
    --good-bg: #153a26; --good: #8fe0b0; --warn-bg: #43330a; --warn: #f4cf73;
    --bad-bg: #4a1a1a; --bad: #ffb4ad; --info-bg: #20306f; --info: #c5d6ff; --chip-bg: #1c2a5e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.5rem; margin: 0 0 .15rem; line-height: 1.2; }
h2 { font-size: 1.08rem; margin: 0 0 .2rem; line-height: 1.3; }
p { margin: .25rem 0; }
small { display: block; color: var(--muted); font-size: .82rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none; }
.boot, .empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.note { font-size: .92rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: .6rem; }
.notice { background: var(--warn-bg); color: var(--warn); padding: .6rem .8rem; border-radius: var(--radius); }

/* Shell */
.top { background: var(--brand); color: var(--brand-ink); display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .7rem 1rem; }
.brand strong { display: block; font-size: 1.05rem; }
.brand span { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--aqua); }
.who span { display: block; font-size: .8rem; opacity: .8; }
.who { display: flex; align-items: center; gap: .5rem; text-align: right; }
.who strong { font-size: .92rem; }
.nav { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; gap: .25rem; overflow-x: auto; padding: 0 .6rem; position: sticky; top: 0; z-index: 5; }
.nav a { color: var(--muted); text-decoration: none; padding: .8rem .7rem; white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 600; font-size: .93rem; }
.nav a.active { color: var(--ink); border-color: var(--accent); }
.top { border-bottom: 4px solid var(--accent); }
.banner { background: var(--warn-bg); color: var(--warn); padding: .6rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; font-weight: 600; }
main { max-width: 1180px; margin: 0 auto; padding: 1rem; outline: none; }
.view > * + * { margin-top: 1rem; }
.head { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: flex-start; }
.head > div:first-child { flex: 1 1 320px; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.stack > * + * { margin-top: .75rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; }
.filters input { flex: 1 1 220px; }

/* Controls */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; min-height: 2.5rem; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
input:disabled, select:disabled { opacity: .65; }
:focus-visible { outline: 3px solid var(--aqua); outline-offset: 2px; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .85rem; min-height: 2.5rem; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .35); color: inherit; }
.btn.small { min-height: 2rem; padding: .25rem .6rem; }
.btn.wide { width: 100%; }
.btn.recording { background: var(--bad); border-color: var(--bad); color: var(--bad-bg); }
.inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); }

/* Cards & chips */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card > * + * { margin-top: .7rem; }
.card-head { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: flex-start; }
.card-head > div:first-child { flex: 1 1 280px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--chip-bg); border-radius: 999px; padding: .12rem .6rem; font-size: .8rem; font-weight: 600; display: inline-block; vertical-align: middle; }
.chip.good, .status.live, .status.done { background: var(--good-bg); color: var(--good); }
.chip.warn, .status.pending, .status.open { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.status.recheck { background: var(--info-bg); color: var(--info); }
.chip.info, .chip.power, .status.wired, .status.in_progress { background: var(--info-bg); color: var(--info); }
select.status { font-weight: 700; border-color: transparent; }
.task.done h2 { text-decoration: line-through; color: var(--muted); }

/* Booth map */
.booths { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: .5rem; }
.booth { position: relative; border: 1px dashed var(--line); border-radius: 8px; padding: .5rem .6rem; min-height: 3.6rem; }
.booth strong { display: block; font-variant-numeric: tabular-nums; }
.booth span { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.booth.taken { border-style: solid; border-color: var(--info); background: var(--info-bg); }
.booth.taken span { color: var(--info); font-weight: 600; }
.booth .x { position: absolute; top: 2px; right: 2px; width: 1.7rem; height: 1.7rem; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; border-radius: 6px; }
.booth .x:hover { color: var(--bad); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.stat strong { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }

/* Electrical grid */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .93rem; }
.grid th, .grid td { text-align: left; vertical-align: top; padding: .55rem .6rem; border-top: 1px solid var(--line); }
.grid thead th { border-top: 0; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.grid tbody th { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid tr.open td { font-style: italic; }
.grid input[type=text] { width: 100%; min-width: 150px; }
@media (max-width: 760px) {
  .grid thead { display: none; }
  .grid, .grid tbody, .grid tr, .grid th, .grid td { display: block; width: 100%; }
  .grid tr { border-top: 2px solid var(--line); padding: .5rem 0; }
  .grid th, .grid td { border: 0; padding: .2rem 0; }
  .grid tbody th { font-size: 1.05rem; }
  .grid td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
  .who > div { display: none; }
}

/* Tasks */
.notes { list-style: none; margin: .5rem 0 0; padding: 0; border-left: 3px solid var(--line); }
.notes li { padding: .3rem .7rem; }
.note-form { display: flex; gap: .5rem; }
.note-form input { flex: 1; min-width: 0; }
.draft { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; gap: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
@media (max-width: 760px) { .draft { grid-template-columns: 1fr 1fr; } .draft input { grid-column: 1 / -1; } }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .6rem 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }

/* Dialogs & forms */
dialog.modal { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 1.2rem; width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); }
dialog.modal.small { width: min(440px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(8, 20, 28, .55); }
.modal input[type=text] { width: 100%; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: .8rem; }
.field { grid-column: 1 / -1; display: grid; gap: .25rem; }
.field.half { grid-column: auto; }
.field > span { font-size: .86rem; font-weight: 600; }
.field input, .field select { width: 100%; }
.check { grid-column: 1 / -1; display: flex; gap: .5rem; align-items: center; }
.check input { width: 1.2rem; height: 1.2rem; }
@media (max-width: 480px) { .field.half { grid-column: 1 / -1; } }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.form-error { color: var(--bad); font-weight: 600; min-height: 1.2rem; margin: .5rem 0 0; }
.form-error:empty { display: none; }

/* Sign in */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--brand); }
.signin-card { background: var(--surface); border-radius: 14px; padding: 1.6rem; width: min(420px, 100%); }
.signin-card form { display: grid; gap: .8rem; margin-top: 1rem; }
.signin-card h1 { color: var(--accent); }
.signin-card h1 span { display: block; color: var(--brand); letter-spacing: .12em; text-transform: uppercase; font-size: 1.05rem; margin-top: .15rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 700; color: var(--muted); margin: 0 0 .3rem; }
.small-print { font-size: .85rem; margin-top: 1rem; }

/* Offline snapshot is read-only: hide anything that writes. */
body.offline .write { display: none !important; }

#toasts { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 50; width: min(440px, calc(100vw - 2rem)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: .65rem .9rem; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.toast.err { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .18s ease-out; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Panel load meter */
.panel { flex: 0 1 260px; min-width: 200px; }
.panel-line { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; font-variant-numeric: tabular-nums; }
.panel progress { width: 100%; height: .6rem; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--chip-bg); accent-color: var(--good); }
.panel progress::-webkit-progress-bar { background: var(--chip-bg); }
.panel progress::-webkit-progress-value { background: var(--good); }
.panel progress::-moz-progress-bar { background: var(--good); }
.panel.warn progress::-webkit-progress-value { background: var(--warn); }
.panel.warn progress::-moz-progress-bar { background: var(--warn); }
.panel.bad progress::-webkit-progress-value { background: var(--bad); }
.panel.bad progress::-moz-progress-bar { background: var(--bad); }
.panel.warn small, .panel.warn strong { color: var(--warn); }
.panel.bad small, .panel.bad strong { color: var(--bad); font-weight: 700; }
p.chips { margin: .35rem 0; }
input[type=date] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; min-height: 2.5rem; }
@media (prefers-color-scheme: dark) { .signin-card h1 span { color: var(--aqua); } }
