:root {
  color-scheme: light;
  --bg: #f5f6f0;
  --paper: #fff;
  --ink: #202b26;
  --muted: #58665e;
  --border: #dde3db;
  --forest: #204a3a;
  --green: #2f7458;
  --pale: #edf4ec;
  --mint: #dcece2;
  --blue: #2d7294;
  --amber: #a66425;
  --radius: 18px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #38865e; outline-offset: 3px; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
a { color: var(--forest); }
[hidden] { display: none !important; }
h1,h2,h3,p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { --icon: url('./vendor/icons/info.svg'); display: inline-block; flex: 0 0 auto; width: 16px; height: 16px; background-color: currentColor; mask: var(--icon) center / contain no-repeat; vertical-align: middle; }
.route { --icon: url('./vendor/icons/route.svg'); }
.pin { --icon: url('./vendor/icons/map-pin.svg'); }
.waves { --icon: url('./vendor/icons/waves.svg'); }
.sun { --icon: url('./vendor/icons/sun.svg'); }
.snow { --icon: url('./vendor/icons/snowflake.svg'); }
.clock { --icon: url('./vendor/icons/clock.svg'); }
.layers { --icon: url('./vendor/icons/layers.svg'); }
.database { --icon: url('./vendor/icons/database.svg'); }
.locate { --icon: url('./vendor/icons/locate-fixed.svg'); }
.play .icon.play { --icon: url('./vendor/icons/play.svg'); }
.pause { --icon: url('./vendor/icons/pause.svg'); }
.navigation { --icon: url('./vendor/icons/navigation.svg'); }
.alert { --icon: url('./vendor/icons/triangle-alert.svg'); }
.stop { --icon: url('./vendor/icons/circle-stop.svg'); }
.footprints { --icon: url('./vendor/icons/footprints.svg'); }
.bike { --icon: url('./vendor/icons/bike.svg'); }
.close-icon { --icon: url('./vendor/icons/x.svg'); }
.reset { --icon: url('./vendor/icons/rotate-ccw.svg'); }

.topbar { height: 69px; padding: 0 clamp(18px, 4.2vw, 67px); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 17px; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: #26362d; font-size: 21px; font-weight: 750; letter-spacing: -.07em; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; background: var(--forest); color: #d8eecd; border-radius: 11px; }
.brand-mark .icon { width: 19px; height: 19px; }
.brand-accent { color: var(--green); }
.topline { display: inline-flex; align-items: center; gap: 6px; margin-left: 2px; padding-left: 17px; border-left: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--muted); }
.topline .icon { width: 13px; height: 13px; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.top-actions .button { white-space: nowrap; }
.button { display: inline-flex; min-height: 35px; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; background: var(--paper); color: var(--forest); font-size: 12px; font-weight: 650; }
.button:hover { border-color: #9cb8a8; background: #f7faf6; }
.live-button { border-color: #d3e4d4; background: #f1f7ee; }
.live-dot, .map-title-dot { border-radius: 50%; height: 7px; width: 7px; background: #528162; }
.live-dot { box-shadow: 0 0 0 3px #dcebdd; margin-inline: 3px; }

.workspace { max-width: 1540px; padding: 25px clamp(18px, 4.2vw, 67px) 0; margin: 0 auto; }
.workspace-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.location { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 680; letter-spacing: .055em; text-transform: uppercase; color: #496550; margin-bottom: 7px; }
.location .icon { width: 13px; height: 13px; }
h1 { font-size: clamp(27px, 3.1vw, 45px); letter-spacing: -.07em; line-height: 1.03; font-weight: 740; }
.modes { display: flex; gap: 4px; padding: 4px; border: 1px solid #dce3d8; border-radius: 12px; background: #eaede5; flex-shrink: 0; }
.mode { border: 1px solid transparent; background: transparent; color: #485b50; padding: 9px 14px; min-height: 38px; border-radius: 8px; display: inline-flex; align-items: center; gap: 7px; font-weight: 680; font-size: 13px; }
.mode:hover { background: #f5f8f3; }
.mode[aria-pressed="true"] { background: var(--forest); color: #fff; border-color: var(--forest); box-shadow: 0 1px 3px #22312922; }

.dashboard { display: grid; grid-template-columns: minmax(0, 2.18fr) minmax(310px, 1fr); align-items: start; gap: 16px; }
.map-card, .details { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 32px #253e2908; overflow: hidden; }
.map-frame { position: relative; height: clamp(365px, 55vh, 690px); background: #e3ebe5; isolation: isolate; }
#map { height: 100%; background: #e4eae2; font-family: inherit; }
.city-basemap { filter: saturate(.73); }
.map-overlays { pointer-events: none; position: absolute; z-index: 500; inset: 14px 14px auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 5px; }
.map-overlays > *, .map-actions > * { pointer-events: auto; }
.map-title, .map-button, .map-legend { background: #fffefc; border: 1px solid #dbe2d9; box-shadow: 0 2px 8px #32493614; }
.map-title { display: flex; align-items: center; gap: 7px; padding: 8px 10px; min-height: 34px; border-radius: 8px; font-size: 11px; color: var(--forest); font-weight: 680; }
.map-title-dot { width: 6px; height: 6px; }
.map-button[aria-pressed="true"] { border-color: #4a805e; background: #e7f2e7; }
.map-actions { z-index: 500; position: absolute; right: 14px; bottom: 91px; display: grid; gap: 6px; pointer-events: none; }
.focus-button { padding: 6px; width: 35px; min-height: 35px; }
.map-legend { position: absolute; z-index: 500; bottom: 24px; left: 14px; list-style: none; margin: 0; padding: 6px 9px; display: flex; flex-wrap: wrap; max-width: calc(100% - 76px); gap: 6px 12px; border-radius: 8px; }
.map-legend li { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: #48564d; font-weight: 660; }
.legend-symbol { background: var(--swatch, #4d7660); width: 14px; height: 3px; border-radius: 3px; }
.legend-symbol.is-dashed { background: none; border-top: 2px dashed var(--swatch, #6d766f); }
.legend-symbol.is-dot { border-radius: 50%; width: 8px; height: 8px; }
.leaflet-container .leaflet-control-zoom { margin-right: 14px; margin-bottom: 16px; border: 1px solid #dbe2d9; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px #32493614; }
.leaflet-control-zoom a { color: var(--forest) !important; }
.leaflet-container .leaflet-control-attribution { font-size: 9px; background: #fffffff5; }
.leaflet-popup-content { margin: 12px 15px; font-size: 12px; }
.leaflet-popup-content p { margin: 5px 0 0; }
.endpoint { display: grid; place-items: center; width: 25px; height: 25px; border: 2px solid #fff; border-radius: 50%; color: #fff; background: #254c3c; font-weight: 750; font-size: 12px; box-shadow: 0 1px 5px #20382a5c; }
.endpoint-dest { background: #345b75; }
.sensor-label { color: #1f536c; padding: 3px 6px; border: 1px solid #a7cbd9; border-radius: 5px; font-weight: 730; }
.leaflet-tooltip.sensor-label:before { display: none; }

.timeline { padding: 14px 15px 13px; border-top: 1px solid var(--border); }
.timeline-top { display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: 12px; }
.timeline-title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--forest); }
.timeline-title .icon { width: 14px; height: 14px; }
#timeline-time { font-weight: 750; font-variant-numeric: tabular-nums; }
.timeline-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
button.play { display: grid; place-items: center; border: 0; border-radius: 8px; background: var(--forest); color: white; width: 36px; height: 34px; flex: 0 0 auto; }
button.play:hover { background: #31684f; }
button.play .icon { width: 16px; height: 16px; }
.slider-wrap { flex: 1 1 auto; min-width: 0; }
#timeline-slider { display: block; width: 100%; height: 21px; margin: 0; accent-color: var(--forest); cursor: ew-resize; }
.slider-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; line-height: 13px; }
.chapters { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 0 48px; }
.chapter { background: #f6f8f4; color: var(--forest); border: 1px solid #e5eae3; border-radius: 5px; padding: 4px 7px; font-size: 10px; font-weight: 650; }
.chapter:hover, .chapter[aria-pressed="true"] { background: #e8f1e7; border-color: #bbd3c0; }

.details { padding: 17px; display: grid; gap: 13px; }
.scenario { display: grid; gap: 5px; }
.scenario-kicker { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.scenario-icon { display: grid; place-items: center; background: #eaf2f5; color: #336f89; width: 29px; height: 29px; border-radius: 8px; }
.scenario-icon[data-mode="heat"] { background: #fff1de; color: #9b5b1b; }
.scenario-icon[data-mode="winter"] { background: #edf0fb; color: #4b648e; }
.scenario-type { color: #52695a; font-size: 10px; font-weight: 730; text-transform: uppercase; letter-spacing: .065em; }
.scenario h2 { font-size: clamp(22px, 2.36vw, 33px); letter-spacing: -.063em; font-weight: 750; line-height: 1.06; }
.scenario-date { font-size: 11px; color: #506658; font-weight: 700; margin-top: 1px; }
.scenario-description { color: var(--muted); font-size: 12px; line-height: 1.42; margin-top: 3px; }
.decision { display: flex; align-items: flex-start; gap: 9px; padding: 10px; background: #edf5ec; border: 1px solid #dcead9; border-radius: 10px; }
.decision[data-tone="caution"] { background: #fbf3e6; border-color: #f0e1cb; }
.decision[data-tone="stop"] { background: #fbedea; border-color: #f1d9d1; }
.decision-icon { border-radius: 6px; background: #dcebd9; color: #3d6549; width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; }
.decision-icon .icon { width: 13px; height: 13px; }
[data-tone="caution"] .decision-icon { background: #f3e4cb; color: #915622; }
[data-tone="stop"] .decision-icon { background: #f7dcd5; color: #963e30; }
.decision h3 { font-size: 13px; line-height: 1.28; font-weight: 750; }
.decision p { font-size: 11px; line-height: 1.38; color: #515e54; margin-top: 3px; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.metric { border: 1px solid #e3e8e0; background: #fbfcf9; padding: 8px 9px; border-radius: 9px; min-width: 0; }
.metric-value { font-size: clamp(15px, 1.7vw, 22px); font-variant-numeric: tabular-nums; line-height: 1.14; font-weight: 750; letter-spacing: -.04em; color: #294b39; overflow-wrap: anywhere; }
.metric-label { font-size: 10px; line-height: 1.3; color: var(--muted); margin-top: 3px; }
.trace { border-top: 1px solid #e6ebe3; padding-top: 10px; min-width: 0; }
.trace-head { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; }
.trace-head h3, .graph-summary strong { font-size: 12px; font-weight: 740; }
.trace-head span, .trace-foot { font-size: 10px; color: var(--muted); }
.trace canvas { width: 100%; height: 100px; display: block; margin-block: 4px 1px; }
.graph-summary { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid #e7ebe4; }
.graph-summary p { font-size: 10px; line-height: 1.35; color: var(--muted); margin-top: 2px; }
.graph-badge { display: grid; min-width: 26px; height: 26px; place-items: center; border-radius: 6px; background: #edf0e8; color: #48644c; font-weight: 750; font-size: 12px; }
.trip-mode { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 5px; gap: 5px; }
.trip-mode > span { font-size: 10px; color: var(--muted); font-weight: 650; }
.trip-mode button { display: inline-flex; align-items: center; gap: 3px; padding: 4px 6px; background: #fff; border: 1px solid var(--border); border-radius: 6px; font-size: 10px; }
.trip-mode .icon { width: 12px; height: 12px; }
.trip-mode button[aria-pressed="true"] { background: #edf3eb; border-color: #bfd2bf; color: var(--forest); font-weight: 700; }
.footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 1px 14px; font-size: 10px; line-height: 1.45; color: #58665c; }

.dialog { border: 1px solid var(--border); width: min(570px, 92vw); border-radius: 17px; padding: 20px; color: var(--ink); max-height: 80vh; box-shadow: 0 15px 70px #21312850; }
.dialog::backdrop { background: #1b2c25aa; }
.dialog header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 13px; }
.dialog h2 { font-size: 25px; line-height: 1.12; letter-spacing: -.045em; }
.dialog header p, .source-list p { font-size: 12px; line-height: 1.45; color: var(--muted); margin-top: 4px; }
.close { padding: 5px; width: 35px; }
.source-list { display: grid; gap: 7px; }
.source-item { padding: 9px 10px; border: 1px solid var(--border); background: #fafcf8; border-radius: 8px; }
.source-item strong { font-size: 12px; }
.source-item a { display: inline-block; margin: 5px 7px 0 0; font-size: 11px; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 900px) {
  .workspace, .topbar { padding-inline: 17px; }
  .dashboard { grid-template-columns: minmax(0, 1.65fr) minmax(270px, 1fr); gap: 12px; }
  .details { padding: 13px; gap: 10px; }
}
@media (max-width: 690px) {
  .topbar { height: 59px; gap: 8px; }
  .top-actions { gap: 5px; }
  .top-actions .button { padding-inline: 8px; }
  .topline { display: none; }
  .workspace { padding-top: 17px; }
  .workspace-head { display: grid; gap: 12px; margin-bottom: 13px; }
  .modes { justify-self: start; }
  .mode { min-height: 33px; padding: 6px 12px; }
  .dashboard { display: flex; flex-direction: column; gap: 10px; }
  .map-card, .details { width: 100%; }
  .map-frame { height: clamp(280px, 46vh, 430px); }
  .trace canvas { height: 105px; }
  .footer { align-items: flex-start; }
}
@media (max-width: 365px) {
  .top-actions .button { padding-inline: 7px; }
  .source-button span { display: none; }
}
