* { box-sizing: border-box; }
html,body { margin: 0; height: 100%; }
body { display: grid; grid-template-rows: auto minmax(0,1fr); height: 100dvh; font: 15px/1.5 var(--ui-font); color: var(--ink); background: #fff; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:where(button,select):focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.map-frame { position: relative; overflow: hidden; min-width: 0; min-height: 0; isolation: isolate; }
#globe { position: absolute; inset: 0; overflow: hidden; }
.map-tools { position: absolute; z-index: 2; top: clamp(12px,2.5vh,24px); left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding-inline: clamp(12px,3vw,48px); pointer-events: none; }
.map-tools .city-select { pointer-events: auto; }
#map-error { background: white; color: var(--ink); padding: 4px 8px; }
.controls, .map-legend { background: rgba(255,255,255,.96); border: 1px solid var(--line); box-shadow: 0 3px 14px rgb(0 0 0 / 6%); }
.map-legend { position: absolute; left: max(clamp(12px,3vw,48px),env(safe-area-inset-left)); bottom: max(18px,var(--content-safe-bottom)); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 9px 14px; border-radius: 14px; font-size: 12px; }
.map-legend span { display: flex; align-items: center; gap: 7px; }
.map-legend .line { width: 21px; border-top: 2px solid #333537; }
.map-legend .orders { border-color: #bc392a; }
.controls { position: absolute; right: max(clamp(12px,3vw,48px),env(safe-area-inset-right)); bottom: max(18px,var(--content-safe-bottom)); display: flex; border-radius: var(--pill); padding: 2px; }
.controls button, .close-sheet { display: grid; place-items: center; background: transparent; border: 0; padding: 0; width: 41px; height: 40px; border-radius: var(--pill); }
.controls button:hover { background: var(--soft); color: var(--ink); }
.controls button:active, .close-sheet:is(:hover, :active) { background: var(--ink); color: white; }
.controls svg, .close-sheet svg { display: block; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.station-sheet { width: min(420px, calc(100% - 28px)); max-height: min(80dvh, 760px); position: fixed; inset: auto 32px 78px auto; margin: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 24px; padding: 0; color: var(--ink); background: #fff; box-shadow: 0 16px 65px rgb(0 0 0 / 16%); }
.station-sheet[open] { display: flex; flex-direction: column; }
.station-sheet::backdrop { background: rgb(0 0 0 / .13); }
.sheet-heading { flex: none; padding: 23px 23px 0; }
.sheet-scroll { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; margin: 0 6px 8px; padding: 0 17px 15px; scrollbar-width: thin; scrollbar-color: #a6a6a6 transparent; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#station-role { color: var(--ink); font-weight: 650; font-size: 14px; }
.close-sheet { width: 34px; height: 34px; background: var(--soft); color: var(--ink); }
.station-sheet h1 { font-size: clamp(23px,4vw,33px); line-height: 1.12; margin: 7px 0; letter-spacing: -.04em; }
.station-period,.station-note { color: var(--muted); font-size: 13px; line-height: 1.45; }
.station-period { margin: 4px 0 18px; }
.metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0; gap: 6px 14px; }
.metrics div { border-top: 1px solid var(--line); padding: 11px 0; }
.metrics dt { font-size: 13px; color: var(--muted); }
.metrics dd { margin: 2px 0 0; font-size: clamp(17px,2.7vw,23px); font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.03em; overflow-wrap: anywhere; }
#categories h2 { font-size: 17px; margin: 16px 0 10px; }
.category-list { list-style: none; padding: 0; margin: 0; }
.category-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 8px 0; font-size: 14px; }
.category-list i { grid-column: 1/-1; height: 3px; background: var(--line); border-radius: 4px; overflow: hidden; }
.category-list b { display: block; height: 100%; background: var(--ink); }
.station-note { margin: 16px 0 0; }
@media(max-width:650px) {
  .map-tools { top: 8px; padding-inline: 8px; }
  .map-legend {
    left: 8px; bottom: max(10px,var(--content-safe-bottom));
    row-gap: 2px; column-gap: clamp(6px, 1.8vw, 11px);
    padding: clamp(3px, 1vw, 6px) clamp(7px, 2vw, 12px);
    font-size: clamp(10px, 2.6vw, 12px); line-height: 1.25;
  }
  .map-legend span { gap: clamp(4px, 1.1vw, 6px); white-space: nowrap; }
  .map-legend .line { width: clamp(10px, 3vw, 17px); }
  .controls { right: 8px; bottom: max(10px,var(--content-safe-bottom)); padding: 1px; }
  .controls button {
    position: relative;
    width: clamp(30px, 8.25vw, 39px); height: clamp(29px, 7.8vw, 37px);
  }
  .controls button::after { content: ""; position: absolute; inset: -3px 0; }
  .controls svg { width: clamp(15px, 3.9vw, 18px); height: auto; }
  .station-sheet { inset: auto 0 0; width: 100%; max-width: 100%; max-height: 79dvh; border-radius: 22px 22px 0 0; }
  .sheet-heading { padding: 18px 19px 0; }
  .sheet-scroll { margin: 0 3px; padding: 0 16px max(20px,env(safe-area-inset-bottom)); }
}
@media (max-width: 340px) {
  .map-legend { flex-direction: column; align-items: flex-start; }
}
