:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e3e6eb;
  --primary: #2453d4;
  --primary-text: #fff;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --card: #1b1e25;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2c303a;
    --primary: #5b84f0;
    --ok: #4ade80;
    --ok-bg: #12301d;
    --bad: #f87171;
    --bad-bg: #3a1614;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
code { background: var(--bg); padding: 0 .3em; border-radius: 4px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.container { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 440px; margin: 0 auto; padding: 2rem 1rem; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem; overflow-x: auto;
}
.card.accent { border-color: var(--primary); }
.card.live h2 { color: var(--ok); }
.heading { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

.muted { color: var(--muted); font-weight: normal; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .35rem 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { display: block; font-weight: 500; }
label input, label textarea { margin-top: .3rem; font-weight: normal; }
.stack { display: grid; gap: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row input { flex: 1 1 200px; width: auto; }
.row form { margin: 0; }
details { margin-bottom: 1rem; }
summary { cursor: pointer; font-weight: 500; margin-bottom: .75rem; }

.btn {
  display: inline-block; font: inherit; font-weight: 500; cursor: pointer;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { color: var(--bad); }
.btn.big { padding: .8rem 1.4rem; font-size: 1.05rem; }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.link.danger, .danger { color: var(--bad); }

.alert { padding: .7rem .9rem; border-radius: 8px; margin: 0 0 1rem; }
.alert.error { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.tag { font-size: .8rem; padding: .1rem .5rem; border-radius: 99px; background: var(--bg); color: var(--muted); }
.tag.live { background: var(--ok-bg); color: var(--ok); }
.pill { font-size: .85rem; padding: .05rem .55rem; border-radius: 99px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.success { text-align: center; padding: 1rem 0; }
.check {
  width: 84px; height: 84px; margin: 0 auto 1rem; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok); font-size: 3rem; line-height: 84px;
}

/* Projector display */
.display-main { padding: 1.25rem; height: calc(100vh - 52px); }
.display-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; height: 100%; }
.qr-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; display: flex; flex-direction: column; min-height: 0;
}
.qr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.counter { font-size: 3rem; font-weight: 700; line-height: 1; text-align: right; color: var(--ok); font-variant-numeric: tabular-nums; }
.counter small { font-size: 1.5rem; color: var(--muted); }
.counter .muted { font-size: .9rem; font-weight: normal; }
.qr { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 1rem 0; }
.qr svg { height: 100%; width: auto; max-width: 100%; max-height: 70vh; background: #fff; border-radius: 8px; }
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; width: 100%; background: var(--primary); }
.hint { text-align: center; color: var(--muted); margin: .75rem 0 0; }
.feed {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; display: flex; flex-direction: column; min-height: 0;
}
.feed ul { flex: 1; overflow-y: auto; }
.feed li { display: flex; flex-direction: column; border-bottom: 1px solid var(--border); padding: .5rem 0; }
.feed-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding-top: 1rem; }
.feed-actions form { margin: 0; }
@media (max-width: 800px) {
  .display-main { height: auto; }
  .display-grid { grid-template-columns: 1fr; }
  .qr svg { max-height: none; width: 100%; height: auto; }
}

/* v2 additions */
:root { --warn: #b45309; --warn-bg: #fef3c7; }
@media (prefers-color-scheme: dark) { :root { --warn: #fbbf24; --warn-bg: #3a2a0a; } }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 260px; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.flag { color: var(--warn); font-size: .85rem; }
tr.flagged td { background: color-mix(in srgb, var(--warn-bg) 45%, transparent); }
tr.at-risk td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.search { width: 220px; max-width: 100%; padding: .4rem .6rem; }
.heading h2 { margin: 0; }
.card > .heading { margin-bottom: .75rem; }
h2.inline { display: inline; }
summary h2 { font-size: 1.15rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .4rem; }
.choices { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: .7rem; cursor: pointer; font-weight: normal; }
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.choice input { width: auto; margin-top: .3rem; }
.radius { display: flex; align-items: center; gap: .5rem; flex: 1 1 260px; font-weight: normal; }
.radius input { flex: 1; margin: 0; padding: 0; border: 0; }
.map { height: 340px; border-radius: 8px; border: 1px solid var(--border); margin-top: .75rem; z-index: 0; }


/* Display: let the JS size the QR to the largest square that fits. */
.qr { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 1rem 0; overflow: hidden; }
.qr svg { max-width: none; max-height: none; height: auto; width: auto; display: block; background: #fff; border-radius: 10px; }
.feed .empty { border: none; }
.feed li span.muted { font-size: .85rem; }
body.display .container { max-width: none; }
:fullscreen body.display .topbar, body.display:fullscreen .topbar { display: none; }
:fullscreen .display-main { height: 100vh; }
@media (max-width: 800px) {
  .qr { min-height: 70vw; }
}
.row > label { flex: 1 1 200px; }
.row > label > input { width: 100%; }
.container:has(.grid2) { max-width: 1140px; }
@media (max-width: 800px) {
  .counter { font-size: 2rem; white-space: nowrap; }
  .counter small { font-size: 1rem; }
}

.row select { flex: 1 1 200px; width: auto; }
.topbar nav { gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .25rem .9rem; justify-content: flex-end; }
.actions form { margin: 0; }
.copy-link { display: flex; gap: .5rem; }
.copy-link input { font-family: ui-monospace, monospace; font-size: .85rem; }
