:root {
  --bg: #eef1f0; --panel: #ffffff; --ink: #1b2421; --muted: #5d6b66; --line: #d9dfdc;
  --accent: #0f766e; --accent-2: #5eada5; --accent-3: #b7dcd7; --accent-soft: #e3f1ef; --warn: #b45309;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 4px; --r-md: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.5; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; font-weight: 750; }
h2 { font-size: 17px; margin: 0 0 var(--s3); font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* shell */
.shell { display: grid; grid-template-columns: 76px 1fr; min-height: 100vh; }
.rail { background: var(--ink); color: #cfd8d5; display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s4) 0; position: sticky; top: 0; height: 100vh; }
.rail .brand { width: 40px; height: 40px; margin-bottom: var(--s4); }
.rail a { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 64px; padding: var(--s2) 0; border-radius: var(--r-md); color: inherit; text-decoration: none; font-size: 11px; }
.rail a svg { width: 22px; height: 22px; }
.rail a:hover { background: #2a3531; color: #fff; }
.rail a.active { background: var(--accent); color: #fff; }
.main { padding: var(--s6) var(--s6) var(--s7); max-width: 1320px; width: 100%; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.pagehead p { margin-top: var(--s1); }
.live { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: var(--s2); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }
.live.fresh .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); transition: box-shadow .4s; }

/* grid + panels */
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(12, 1fr); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5); min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel .sub { font-size: 13px; color: var(--muted); margin: calc(-1 * var(--s2)) 0 var(--s3); }

/* KPI strip: one panel, divided, not four cards */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: var(--s4); }
.kpi { padding: var(--s4) var(--s5); border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi .v { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .l { font-size: 13px; color: var(--muted); }

/* bar chart (HTML blocks: divs, never spans) */
.bars { display: grid; gap: var(--s2); }
.bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 48px; align-items: center; gap: var(--s3); font-size: 14px; }
.bar .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { display: block; height: 14px; background: #edf1ef; border-radius: var(--r-sm); overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: var(--r-sm); min-width: 2px; }
.bar .n { text-align: right; font-weight: 600; }
.bar.alt .fill { background: var(--accent-2); }
.axis { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 48px; gap: var(--s3); font-size: 12px; color: var(--muted); margin-top: var(--s1); }
.axis .scale { display: flex; justify-content: space-between; }
.empty { padding: var(--s5); text-align: center; color: var(--muted); font-size: 14px; }
.loading { padding: var(--s5); color: var(--muted); font-size: 14px; }
.skeleton { height: 14px; border-radius: var(--r-sm); background: linear-gradient(90deg, #edf1ef, #f6f8f7, #edf1ef); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin-bottom: var(--s2); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* the class board: the dashboard's one bold element */
.board { display: grid; gap: 0; }
.slot { display: grid; grid-template-columns: 112px 1fr 220px; gap: var(--s4); align-items: center; padding: var(--s3) var(--s5); border-top: 1px solid var(--line); }
.slot:first-child { border-top: 0; }
.slot .when { font-weight: 700; font-size: 14px; line-height: 1.3; }
.slot .when small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.slot .what b { font-size: 16px; }
.slot .what div { font-size: 13px; color: var(--muted); }
.seats { display: flex; flex-wrap: wrap; gap: 3px; }
.seats i { display: block; width: 9px; height: 14px; border-radius: 2px; background: #e2e8e5; }
.seats i.on { background: var(--accent); }
.seats-l { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag.warn { background: #fdf0e1; color: var(--warn); }
.tag.dim { background: #eceeed; color: var(--muted); }

/* search + suggestions + chips */
.searchbar { display: flex; gap: var(--s2); align-items: center; position: relative; }
.searchbar input { flex: 1; font: inherit; padding: 10px 14px 10px 38px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6b66' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center / 18px; color: var(--ink); }
.searchbar input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 12px 28px rgba(27, 36, 33, .14); padding: var(--s2); max-height: 340px; overflow: auto; }
.suggest .grp { font-size: 12px; color: var(--muted); padding: var(--s2) var(--s2) 2px; }
.suggest button { display: flex; width: 100%; justify-content: space-between; gap: var(--s3); background: none; border: 0; font: inherit; text-align: left; padding: 6px var(--s2); border-radius: var(--r-sm); cursor: pointer; color: var(--ink); }
.suggest button:hover, .suggest button.hi { background: var(--accent-soft); }
.suggest button span:last-child { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); min-height: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; border: 0; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 6px; border-radius: 999px; }
.chip button:hover { background: var(--accent-3); }

/* list */
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--line); background: #f7f9f8; }
.list td { padding: 10px var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list td.num, .list th.num { text-align: right; }
.list td small { display: block; color: var(--muted); }
.listfoot { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.btn { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[disabled] { opacity: .5; cursor: default; }

/* map */
.mapwrap { position: relative; }
.map { height: 460px; width: 100%; background: #dde5e2; }
.maptools { position: absolute; top: var(--s3); left: var(--s3); z-index: 5; display: flex; gap: var(--s2); }
.maptools .btn { box-shadow: 0 2px 8px rgba(27, 36, 33, .15); }
.maphint { position: absolute; bottom: var(--s3); left: var(--s3); z-index: 5; background: rgba(27, 36, 33, .85); color: #fff; font-size: 13px; padding: 6px 10px; border-radius: var(--r-sm); }
.area-del { font: 600 12px system-ui, sans-serif; background: var(--ink); color: #fff; border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.area-del:hover { background: var(--warn); }
.drawing .maplibregl-marker, .drawing .maplibregl-popup, .drawing .area-del { pointer-events: none !important; }
.drawing .maplibregl-canvas-container { touch-action: none; }

/* toasts */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); display: grid; gap: var(--s2); z-index: 50; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #eef3f1; border-radius: var(--r-md); padding: var(--s3) var(--s4); box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 14px; animation: rise .25s ease-out; border-left: 4px solid var(--accent-2); }
.toast b { display: block; font-size: 13px; color: var(--accent-3); font-weight: 600; }
.toast.deleted { border-left-color: var(--warn); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast, .skeleton { animation: none; } }

@media (max-width: 1000px) {
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3) { border-left: 0; }
  .main { padding: var(--s5) var(--s4); }
  .slot { grid-template-columns: 90px 1fr; }
  .slot .meter { grid-column: 2; }
}
@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; height: auto; position: sticky; justify-content: center; padding: var(--s2); z-index: 30; }
  .rail .brand { display: none; }
}
time[data-shown]::after { content: attr(data-shown); }
h1:focus { outline: none; }
