@font-face { font-family: "Geist"; src: url("/static/fonts/Geist-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist"; src: url("/static/fonts/Geist-Medium.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/static/fonts/GeistMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/static/fonts/GeistMono-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --raised: #f8fafc;
  --line: #e9ecf1;
  --line-strong: #dde2e9;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --brand: #2563eb;
  --brand-soft: #eff4ff;
  --normal: #16a34a;
  --normal-soft: #ecfdf3;
  --watch: #d97706;
  --watch-soft: #fffbeb;
  --warning: #dc2626;
  --warning-soft: #fef2f2;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 8px 24px -12px rgb(15 23 42 / 0.10);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font: 400 13px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h2 { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: -0.005em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 10; height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgb(255 255 255 / 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 600; font-size: 14px; }
.wordmark { font-weight: 500; font-size: 14px; }
.crumb { color: var(--text-3); padding-left: 10px; border-left: 1px solid var(--line-strong); }
.top-right { display: flex; align-items: center; gap: 16px; }
.clock { font-family: var(--mono); color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-radius: 999px; font-weight: 500; font-size: 12px; background: var(--raised); border: 1px solid var(--line); }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-pill.warning { color: var(--warning); background: var(--warning-soft); border-color: #fecaca; }
.status-pill.watch { color: var(--watch); background: var(--watch-soft); border-color: #fde68a; }
.status-pill.normal { color: var(--normal); background: var(--normal-soft); border-color: #bbf7d0; }
@media (prefers-reduced-motion: no-preference) {
  .status-pill.warning::before { animation: pulse 2s var(--ease) infinite; }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(220 38 38 / 0.45); } 70%, 100% { box-shadow: 0 0 0 7px rgb(220 38 38 / 0); } }
}
.ghost { height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; color: var(--text-2); font-size: 12px; }
.ghost:hover { background: var(--raised); color: var(--text); }

/* Grid */
.grid { max-width: 1600px; margin: 0 auto; padding: 20px 24px 40px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-3 { grid-column: span 3; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.hint { color: var(--text-3); font-size: 12px; margin-top: 2px; white-space: nowrap; }
.count { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
@media (prefers-reduced-motion: no-preference) {
  .panel, .kpi, .area-card { animation: rise 0.55s var(--ease) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}

/* KPI tiles */
.kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-height: 128px; }
.kpi-label { color: var(--text-3); font-size: 12px; }
.kpi-value { font-size: 28px; line-height: 1.1; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; color: var(--text-3); font-weight: 400; margin-left: 2px; letter-spacing: 0; }
.kpi-sub { color: var(--text-2); font-size: 12px; }
.kpi-viz { margin-top: auto; }
.thermo { position: relative; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #38bdf8, #a3e635 35%, #facc15 55%, #f97316 75%, #dc2626); }
.thermo i { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px #fff; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; }
.stack span { display: block; height: 100%; }
.key { display: flex; gap: 10px; margin-top: 6px; font-size: 11px; color: var(--text-3); }
.key b { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: -0.5px; }
.ring { display: flex; align-items: center; gap: 10px; }
.bars-mini { display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.bars-mini span { flex: 1; border-radius: 3px 3px 0 0; }

/* Trend chart */
.chart-panel { display: flex; flex-direction: column; }
.trend { position: relative; height: 330px; }
.trend svg, .heatmap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.axis { fill: var(--text-3); font: 400 11px var(--mono); }
.gridline { stroke: var(--line); }
.band-watch { fill: #fef3c7; opacity: 0.55; }
.band-warning { fill: #fee2e2; opacity: 0.7; }
.band-label { font: 500 11px var(--sans); opacity: 0.85; }
.series { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; transition: opacity 0.2s var(--ease); }
.series.dim { opacity: 0.12; }
.area-fill { opacity: 0.08; }
.crosshair { stroke: var(--text-3); stroke-dasharray: 3 3; }
@media (prefers-reduced-motion: no-preference) {
  .series.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s var(--ease) forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.legend button { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12px; color: var(--text-2); transition: background-color 0.2s var(--ease), opacity 0.2s var(--ease); }
.legend button:hover { background: var(--raised); }
.legend button.off { opacity: 0.45; }
.legend i { width: 10px; height: 3px; border-radius: 2px; }

.tooltip { position: fixed; z-index: 20; pointer-events: none; min-width: 180px; padding: 10px 12px; border-radius: 10px; background: rgb(15 23 42 / 0.94); color: #f8fafc; font-size: 12px; box-shadow: 0 12px 32px -8px rgb(15 23 42 / 0.4); }
.tooltip .t-time { font-family: var(--mono); color: #94a3b8; margin-bottom: 6px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .t-row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.tooltip i { width: 8px; height: 8px; border-radius: 50%; }
.tooltip b { font-family: var(--mono); font-weight: 500; }

/* Donut mix */
.mix { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 16px; }
.mix svg { width: 170px; height: 170px; }
.mix-center { font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; }
.mix-list { display: grid; gap: 10px; }
.mix-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; }
.mix-row b { width: 10px; height: 10px; border-radius: 3px; }
.mix-row .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.per-area { grid-column: 1 / -1; display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.per-title { color: var(--text-3); font-size: 12px; }
.per-row { display: grid; grid-template-columns: 96px 1fr 24px; gap: 10px; align-items: center; font-size: 12px; }
.per-bar { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.per-bar i { display: block; height: 100%; border-radius: 4px; }
.per-row .v { font-family: var(--mono); text-align: right; }
.mix-row small { grid-column: 2 / -1; color: var(--text-3); font-size: 11px; margin-top: -6px; }

/* Heat map */
.heatmap { min-height: 240px; }
.cell { transition: opacity 0.15s var(--ease); }
.cell:hover { opacity: 0.8; }
.cell-text { font: 500 11px var(--mono); pointer-events: none; }
.row-label { fill: var(--text); font: 500 12px var(--sans); }
.scale-key { display: flex; align-items: center; gap: 8px; font: 400 11px var(--mono); color: var(--text-3); }
.scale-key span { width: 140px; height: 8px; border-radius: 4px; }

/* Alerts */
.alerts-panel { display: flex; flex-direction: column; }
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 300px; overflow: auto; }
.alert { display: grid; grid-template-columns: 4px 1fr auto; gap: 4px 12px; padding: 10px 12px 10px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.alert .sev { grid-row: 1 / span 3; border-radius: 10px 0 0 10px; margin: -11px 0 -11px -1px; }
.alert.warning .sev { background: var(--warning); } .alert.watch .sev { background: var(--watch); }
.alert-title { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.tag.warning { background: var(--warning-soft); color: var(--warning); } .tag.watch { background: var(--watch-soft); color: var(--watch); }
.tag.normal { background: var(--normal-soft); color: var(--normal); }
.alert-meta { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.alert-tags { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.qtag { font: 500 11px var(--mono); padding: 1px 6px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line); color: var(--text-2); }
.alert .act { grid-column: 3; grid-row: 1 / span 2; align-self: center; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background-color 0.15s var(--ease), transform 0.12s var(--ease); }
.alert .act:hover { background: var(--raised); } .alert .act:active { transform: scale(0.97); }
.empty { color: var(--text-3); padding: 24px 8px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 10px; }

/* Area cards */
.areas { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.area-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease); position: relative; overflow: hidden; }
.area-card:hover { border-color: var(--line-strong); }
.area-card.focus { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent), var(--shadow); }
.area-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.area-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.area-name i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.area-temp { font-size: 26px; font-weight: 500; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.area-temp small { font-size: 13px; color: var(--text-3); font-weight: 400; }
.area-card svg { width: 100%; height: 44px; display: block; margin: 6px 0 8px; }
.area-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; }
.area-stats dt { color: var(--text-3); } .area-stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; }
.up { color: var(--warning); } .down { color: var(--normal); }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; position: relative; max-height: 280px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 44px 14px 1fr; gap: 10px; align-items: start; padding: 6px 0; }
.feed time { font-family: var(--mono); color: var(--text-3); font-size: 12px; padding-top: 1px; }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; box-shadow: 0 0 0 3px #fff; position: relative; z-index: 1; }
.feed li:not(:last-child) .dot::after { content: ""; position: absolute; left: 4px; top: 12px; width: 2px; height: 34px; background: var(--line); }
.feed .what { font-weight: 500; } .feed .where { color: var(--text-3); font-size: 12px; }

/* Distance bars */
.gaps { display: grid; gap: 10px; }
.gap-row { display: grid; grid-template-columns: 92px 1fr 52px; gap: 8px; align-items: center; font-size: 12px; }
.gap-track { position: relative; height: 10px; border-radius: 5px; background: var(--raised); border: 1px solid var(--line); overflow: hidden; }
.gap-track span { position: absolute; top: 0; bottom: 0; border-radius: 5px; transition: width 0.6s var(--ease); }
.gap-row .v { font-family: var(--mono); text-align: right; }

/* Form */
.log-form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--text-2); font-size: 12px; }
.field input, .field select { height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); font-variant-numeric: tabular-nums; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; font: 500 12px var(--mono); color: var(--text-2); }
.chips button:hover { border-color: var(--line-strong); color: var(--text); }
.primary { height: 40px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 500; cursor: pointer; box-shadow: 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 6px 16px -6px rgb(37 99 235 / 0.6); transition: background-color 0.15s var(--ease), transform 0.12s var(--ease); }
.primary:hover { background: #1d4ed8; } .primary:active { transform: scale(0.98); }
.error { color: var(--warning); font-size: 12px; min-height: 18px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; padding: 12px 16px; border-radius: 12px; background: var(--text); color: #fff; font-weight: 500; box-shadow: 0 16px 40px -12px rgb(15 23 42 / 0.5); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise 0.35s var(--ease) both; } }

@media (max-width: 1240px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .areas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-8, .span-4, .span-5, .span-3 { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .top { padding: 0 16px; } .crumb, .clock { display: none; }
  .grid { padding: 16px; }
  .kpis, .areas { grid-template-columns: 1fr 1fr; }
  .mix { grid-template-columns: 1fr; justify-items: center; }
}
