:root {
  --brand: #0b63ad;
  --accent: #e30613;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #17202b;
  --muted: #5c6878;
  --line: #dde3ea;
  --good: #2e9e5b;
  --mid: #f0b429;
  --bad: #d64545;
  --passive: #a7b1bd;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  body.app {
    --bg: #11161c; --surface: #1a2129; --text: #e6ebf0; --muted: #9aa6b4; --line: #2c3540;
    --brand: #5aa8ec; --passive: #66717e;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0 0 .4rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- shell --- */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--text); font-weight: 600; }
.brand img { height: 30px; background: #fff; border-radius: 4px; padding: 2px 4px; }
.topbar nav { display: flex; gap: .3rem; flex: 1; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: .4rem .7rem; border-radius: 6px; }
.topbar nav a.on, .topbar nav a:hover { color: var(--text); background: var(--bg); }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.who form { margin: 0; }
.role { color: var(--muted); font-size: .8rem; border: 1px solid var(--line); border-radius: 99px; padding: 0 .5rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }

/* --- forms & buttons --- */
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: .5rem .6rem; width: 100%; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .4rem; }
label.check input { width: auto; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
button { font: inherit; cursor: pointer; }
.primary, .btn { border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: 7px; padding: .5rem .9rem; text-decoration: none; display: inline-block; font-size: .9rem; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.link { background: none; border: none; color: var(--brand); padding: 0; }
button:disabled { opacity: .5; cursor: wait; }
.alert { background: #fdecec; color: #8a1c1c; border-radius: 7px; padding: .6rem .8rem; margin: .6rem 0; }
.alert.ok { background: #e7f5ec; color: #1d5e37; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.event-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: .8rem; align-items: end; }
.event-form .wide { grid-column: span 2; }
.event-form button { height: 2.45rem; }
@media (max-width: 760px) { .event-form { grid-template-columns: 1fr; } .event-form .wide { grid-column: auto; } }
.report-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; margin-top: .8rem; }
.report-form label:not(.check) { min-width: 150px; }
.report-form label.check { padding-bottom: .55rem; }
.report-form button { height: 2.45rem; }
.preview { margin: .9rem 0 0; padding: .6rem .8rem; background: var(--bg); border-radius: 7px; }
.roles { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .8rem; margin-top: 1rem; }
.roles dt { font-weight: 600; } .roles dd { margin: 0; }

/* --- tables --- */
table { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: .4rem .5rem; }
.list td { border-bottom: 1px solid var(--line); padding: .5rem; vertical-align: middle; }
.list tr:last-child td { border-bottom: none; }
.list td:first-child { white-space: nowrap; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.events { overflow-x: auto; }
@media (max-width: 760px) { .list.events thead { display: none; } .list.events tr { display: grid; grid-template-columns: 1fr 1fr; padding: .5rem 0; border-bottom: 1px solid var(--line); } .list.events td { border: none; padding: .2rem .3rem; } .list.events .actions { grid-column: span 2; justify-content: flex-start; } }
tr.fresh { animation: flash 2s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--mid) 35%, transparent); } to { background: transparent; } }
.note { font-size: .8rem; color: var(--muted); }
.badge { border: 1px solid; border-radius: 99px; padding: .1rem .6rem; font-size: .8rem; background: transparent; }
.badge.on { color: var(--good); } .badge.off { color: var(--muted); }

/* --- dashboard --- */
.filters { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label:first-child { flex: 1; min-width: 240px; }
#panel.htmx-request { opacity: .6; transition: opacity .2s; }
.panel-head { margin-bottom: 1rem; }
.kpis { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.2rem; display: flex; flex-direction: column; min-width: 150px; }
.kpi.hero { flex: 1; min-width: 240px; }
.kpi-label { font-size: .8rem; color: var(--muted); }
.kpi-value { font-size: 2.2rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi.hero .kpi-value { font-size: 3rem; }
.kpi-value.pos { color: var(--good); } .kpi-value.neg { color: var(--bad); }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 > .card { margin-bottom: 1rem; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.stackbar { display: flex; height: 22px; border-radius: 5px; overflow: hidden; background: var(--line); gap: 2px; margin-bottom: .8rem; }
.seg { display: block; height: 100%; }
.promoters, .happy { background: var(--good); }
.passives { background: var(--passive); }
.neutral { background: var(--mid); }
.detractors, .unhappy { background: var(--bad); }
.neutral-bar { background: var(--brand); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .5rem; vertical-align: baseline; }
.groups td { padding: .3rem 0; }
.cols { display: flex; align-items: stretch; gap: 6px; height: 190px; }
.cols.small { height: 150px; }
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.col-bar { width: 100%; max-width: 56px; border-radius: 3px 3px 0 0; min-height: 1px; }
.col-n { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-x { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 2px; }

/* --- toasts --- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: .5rem; z-index: 10; }
.toast { background: var(--text); color: var(--surface); padding: .6rem .9rem; border-radius: 7px; animation: fade 5s forwards; }
.toast.error { background: var(--bad); color: #fff; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* --- kiosk --- */
body.kiosk { background: #fff; color: #17202b; user-select: none; -webkit-user-select: none; touch-action: manipulation; overflow: hidden; }
.kiosk-shell { height: 100vh; display: flex; flex-direction: column; }
.kiosk-top { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 2rem; }
.kiosk-logo { height: clamp(40px, 8vh, 90px); }
.kiosk-exit { border: none; background: transparent; color: #c5ccd4; font-size: 1.6rem; width: 56px; height: 56px; border-radius: 50%; }
.kiosk-exit:hover { background: #f1f3f5; }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 2rem 2rem; text-align: center; }
.question { font-size: clamp(1.6rem, 4vw, 3rem); max-width: 22ch; margin-bottom: 6vh; line-height: 1.2; font-weight: 600; }
.vote { width: 100%; max-width: 1400px; }
.smiley-row { display: flex; justify-content: center; gap: 6vw; }
.smiley-btn { border: none; background: none; padding: 0; width: clamp(110px, 20vw, 260px); border-radius: 50%; transition: transform .12s; }
.smiley-btn:active, .nps-btn:active { transform: scale(.92); }
.smiley-btn svg { width: 100%; display: block; }
.nps-row { display: grid; grid-template-columns: repeat(11, 1fr); gap: clamp(4px, 1vw, 14px); }
.nps-btn { aspect-ratio: 1; border: none; border-radius: 14px; font-size: clamp(1.2rem, 3.4vw, 3rem); font-weight: 700; color: #fff; background: hsl(var(--hue) 62% 45%); transition: transform .12s; }
.nps-scale { display: flex; justify-content: space-between; color: #5c6878; margin-top: .8rem; font-size: clamp(.9rem, 1.6vw, 1.3rem); }
.thanks svg { width: clamp(120px, 18vw, 220px); animation: pop .35s ease-out; }
.thanks h1 { font-size: clamp(1.8rem, 4vw, 3rem); }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.closed h1 { font-size: clamp(1.5rem, 3vw, 2.4rem); }
.kiosk-foot { text-align: center; color: #b6bec8; font-size: .8rem; padding: .6rem; }
.pinpad { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.pin-display { font-size: 2rem; text-align: center; letter-spacing: .4em; width: 260px; border: 2px solid #dde3ea; border-radius: 10px; color: #17202b; background: #fff; }
.pin-error { color: var(--bad); margin: 0; }
.keys { display: grid; grid-template-columns: repeat(3, 80px); gap: 12px; margin-top: 1rem; }
.keys button { height: 80px; font-size: 1.8rem; border: 1px solid #dde3ea; border-radius: 12px; background: #f6f8fa; color: #17202b; }
.keys .ok { background: var(--brand); color: #fff; border-color: var(--brand); }
.back { border: none; background: none; color: var(--brand); font-size: 1rem; margin-top: 1rem; }
