:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7d7c77;
  --accent: #2a78d6;
  --good: #0a7d0a;
  --bad: #c03030;
  --grid: #e6e5e0;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --s6: #008300; --s7: #6250d6; --s8: #e34948; --s9: #8a6d3b; --s10: #5f6b73;
  --band1: #86b6ef; --band2: #5598e7; --band3: #2a78d6; --band4: #1c5cab; --band5: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8e86; --accent: #3987e5;
    --good: #3cc23c; --bad: #e66767; --grid: #2c2c29;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --s6: #008300; --s7: #9085e9; --s8: #e66767; --s9: #a8885a; --s10: #8a959c;
    --band1: #184f95; --band2: #256abf; --band3: #3987e5; --band4: #6da7ec; --band5: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8e86; --accent: #3987e5;
  --good: #3cc23c; --bad: #e66767; --grid: #2c2c29;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --s6: #008300; --s7: #9085e9; --s8: #e66767; --s9: #a8885a; --s10: #8a959c;
  --band1: #184f95; --band2: #256abf; --band3: #3987e5; --band4: #6da7ec; --band5: #b7d3f6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
.muted { color: var(--text-3); font-weight: 400; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-size: 18px; font-weight: 650; }
.freshness { color: var(--text-2); font-size: 12.5px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); margin-right: 8px;
}

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
h2 { font-size: 16px; margin: 0; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.head-ctls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* help (?) icon */
.help {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--text-3); color: var(--text-2); font-size: 11px; font-weight: 700; cursor: help;
}
.help:hover, .help:focus { background: var(--text); color: var(--surface); border-color: var(--text); outline: none; }
.tip {
  position: fixed; z-index: 50; max-width: 340px; padding: 10px 12px; border-radius: 8px;
  background: var(--text); color: var(--surface); font-size: 12.5px; font-weight: 400; line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); pointer-events: none;
}

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin-bottom: 14px; }
.ctl { display: flex; flex-direction: column; gap: 4px; }
.ctl > label { font-size: 11.5px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
select, input[type=search], input[type=date], input[type=month], input[type=text] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; height: 32px;
}
.btn {
  font: inherit; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; height: 32px; }
.seg button {
  font: inherit; border: 0; background: var(--surface); color: var(--text-2); padding: 0 11px; cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--text); color: var(--surface); }
.range-row { display: flex; gap: 6px; align-items: center; }

/* multi-select venue picker */
.picker { position: relative; }
.picker-panel, .combo-panel {
  position: absolute; z-index: 20; top: 36px; left: 0; width: 320px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px;
}
.picker-panel input[type=search] { width: 100%; }
.picker-note { font-size: 12px; color: var(--text-3); padding: 6px 4px 2px; }
.picker-panel ul, .combo-panel ul { list-style: none; margin: 4px 0 0; padding: 0; max-height: 300px; overflow: auto; }
.picker-panel li, .combo-panel li {
  display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 5px; cursor: pointer;
}
.picker-panel li:hover, .combo-panel li:hover, .combo-panel li.active { background: var(--surface-2); }
.picker-panel li.disabled { opacity: .45; cursor: not-allowed; }
.picker-panel li small, .combo-panel li small { color: var(--text-3); margin-left: auto; white-space: nowrap; }

/* single-select venue combobox */
.combo { position: relative; }
.combo input { width: 260px; max-width: 70vw; }
.combo-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-right: 4px; }

.chart-wrap { position: relative; height: 380px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-3); margin: 6px 0 4px; }

.chips { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 6px 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px;
}
.chips li.sel { border-color: var(--text); }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw.dash { background-image: repeating-linear-gradient(90deg, transparent 0 2px, var(--surface) 2px 4px) !important; }
.chips button {
  border: 0; background: transparent; color: var(--text-3); cursor: pointer; font-size: 16px; line-height: 1;
  width: 22px; height: 22px; border-radius: 50%;
}
.chips button:hover { background: var(--surface-2); color: var(--text); }

/* section 2 */
.s2-head { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; margin-bottom: 12px; }
.s2-title { font-size: 18px; font-weight: 650; }
.s2-meta { color: var(--text-2); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 16px; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.kpi .k { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; color: var(--text-2); }
.s2-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.hour-wrap { position: relative; height: 170px; }

.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--border); }
th { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; text-align: right; vertical-align: bottom; line-height: 1.3; }
th:first-child, td:first-child { text-align: left; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 650; border-bottom: 0; border-top: 1.5px solid var(--text-3); }
th.grp { text-align: center; border-bottom: 1px solid var(--border); color: var(--text-2); }
td.sep, th.sep { border-left: 1px solid var(--border); }
.band-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: 0; }
.share-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-mini { width: 64px; height: 8px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bar-mini > i { display: block; height: 100%; background: var(--accent); border-radius: 0 2px 2px 0; }
.up { color: var(--good); } .down { color: var(--bad); } .flat { color: var(--text-3); }
.spark { display: block; margin-left: auto; }
.note { font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* section 3 strip */
.strips { display: grid; gap: 8px; margin-bottom: 14px; }
.strip-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: center; }
.strip-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip { display: flex; height: 22px; gap: 2px; }
.strip > div { height: 100%; display: grid; place-items: center; font-size: 11px; color: #fff; overflow: hidden; }
.strip > div:first-child { border-radius: 4px 0 0 4px; }
.strip > div:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-bottom: 10px; }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .card { padding: 14px 14px; }
  .chart-wrap { height: 300px; }
  .strip-row { grid-template-columns: 1fr; gap: 4px; }
}
.help.sm { width: 15px; height: 15px; font-size: 10px; margin-left: 2px; text-transform: none; }
.chart-wrap.small { height: 300px; }
.kpi-range { grid-column: 1 / -1; font-size: 13px; color: var(--text-2); margin-bottom: -4px; }

/* ---------- responsive type & density ---------- */
body { font-size: clamp(12.5px, 0.35vw + 9.5px, 14px); }
h2 { font-size: clamp(14px, 0.4vw + 10.5px, 16px); }
.brand { font-size: clamp(16px, 0.5vw + 12px, 18px); }
.kpi .v { font-size: clamp(16px, 0.8vw + 9px, 20px); }
.s2-title { font-size: clamp(15px, 0.6vw + 10px, 18px); }
select, input[type=search], input[type=date], input[type=text], .btn, .seg button { font-size: inherit; }
.picker-panel, .combo-panel { font-size: 12.5px; }
.picker-panel li, .combo-panel li { padding: 5px 6px; line-height: 1.3; }
.picker-panel li span, .combo-panel li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-panel li small, .combo-panel li small { font-size: 11px; }
.picker-panel input[type=checkbox] { margin: 0; flex: none; }
.picker-panel input[type=search] { height: 30px; }
.chips li { font-size: 12.5px; }
table { font-size: 12.5px; }
th { font-size: 10.5px; }

@media (max-width: 900px) {
  .seg button { padding: 0 8px; }
  .combo input { width: 210px; }
  .range-row { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  main { padding: 12px 10px 40px; gap: 14px; }
  .controls { gap: 10px 12px; }
  .ctl { max-width: 100%; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg button { padding: 0 7px; white-space: nowrap; }
  select, input[type=search], input[type=date], input[type=text], .btn, .seg { height: 30px; }
  .range-row input[type=date] { width: 132px; }
  .head-ctls, .combo { width: 100%; }
  .combo input { width: 100%; max-width: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-wrap.small { height: 240px; }
  .hour-wrap { height: 140px; }
  .freshness { font-size: 11.5px; }
  .kpi { padding: 8px 10px; }
  .kpi .k { font-size: 10px; }
  .kpi .d { font-size: 11px; }
}

/* ---------- login, user bar, admin page ---------- */
input[type=password], input[type=url], input[type=file] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; height: 32px;
}
input[type=file] { height: auto; }
.userbar { font-size: 12.5px; color: var(--text-2); display: flex; gap: 10px; align-items: baseline; }
.userbar a { color: var(--accent); text-decoration: none; }
.userbar a:hover { text-decoration: underline; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12.5px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-card label, .form label { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.login-card input { width: 100%; }
.form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 12px 0 4px; }
.form label.check { display: flex; align-items: center; gap: 6px; height: 32px; }
.msg { font-size: 13px; min-height: 18px; }
.msg.err { color: var(--bad); } .msg.ok { color: var(--good); }
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #fff; margin-left: 6px; }
.admin td, .admin th { text-align: left; }
.admin td.num, .admin th.num { text-align: right; }
