:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #f8f9fa;
  --line: #e2e5e9;
  --line-2: #cfd4da;
  --text: #1d2125;
  --muted: #5d6670;
  --faint: #8a939c;
  --accent: #2f3a45;
  /* status colors: the only color on the page */
  --empty: #d1342c;
  --low: #ef8a17;
  --medium: #2e9a4b;
  --high: #2c6fbf;
  --full: #7b3fa8;
  --oos: #3a3f45;
  --ok: #2e9a4b;
  --warn: #c77700;
  --bad: #d1342c;
  --limit: #d1342c;
  --mean: #2f3a45;
  /* shared light blue for the summary boxes on Dispatch and Maintenance */
  --box-blue: #e7f1fc;
  --box-blue-line: #c4dbf3;
  /* highlight roles: the same light blue as the summary boxes (no new colours).
     --highlight = hover and selected; --highlight-strong = stronger emphasis
     (borders, underlines, rings). Red problem highlights always win. */
  --highlight: var(--box-blue);
  --highlight-strong: var(--box-blue-line);
  /* red problem rows (unchanged values, now named) */
  --risk-row: #fdeeec;
  --risk-row-high: #f9d6d2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 8px; }
button, select, input { font: inherit; color: inherit; }
select, input[type=number] {
  border: 1px solid var(--line-2); border-radius: 6px; background: #fff; padding: 4px 8px; height: 30px;
}
input[type=number] { width: 64px; }
button {
  border: 1px solid var(--line-2); border-radius: 6px; background: #fff; padding: 4px 10px; height: 30px; cursor: pointer;
}
button:hover { background: var(--highlight); border-color: var(--highlight-strong); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--highlight-strong); border-color: var(--highlight-strong); color: var(--text); }
:focus-visible { outline: 2px solid var(--high); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------------------------------------------------------------- shell */
/* Full-width workspace: navigation wraps above content rather than taking a column. */
.shell { display: flex; flex-direction: column; height: 100dvh; }
.site-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; padding: 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; min-height: 36px; }
.brand-name { font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; white-space: nowrap; }
nav a:hover { background: var(--highlight); }
nav a[aria-current=page] { background: var(--highlight-strong); font-weight: 600; }
nav a svg { flex: none; }
.guide { max-width: 960px; line-height: 1.7; }
.guide h2 { margin: 20px 0 8px; font-size: 18px; }
.guide h2:first-child { margin-top: 0; }
.guide p { margin-bottom: 12px; }
.main { min-height: 0; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; white-space: nowrap; }
.top-controls { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.top-controls label { display: flex; align-items: center; gap: 6px; }
.fresh {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); white-space: nowrap;
}
.fresh .dot { width: 8px; height: 8px; border-radius: 50%; }
main { flex: 1; overflow: auto; padding: 16px 20px 32px; }
main:focus { outline: none; }

/* ------------------------------------------------------------ building blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card-b { padding: 12px 14px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; align-content: start; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.howto { font-size: 12px; color: var(--muted); border-left: 3px solid var(--line-2); padding: 2px 0 2px 10px; margin: 8px 0 0; }
.kpi { padding: 14px; }
.kpi .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; border: 1px solid var(--line-2); background: #fff; white-space: nowrap;
}
.badge.warn { border-color: var(--warn); color: #8a5200; }
.badge.bad { border-color: var(--bad); color: #a51d16; }
.badge.ok { border-color: var(--ok); color: #1f6e35; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
tbody tr:hover { background: var(--highlight); }
.table-wrap { overflow: auto; max-height: 560px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 14px; }
.tabs button {
  border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; height: 38px; padding: 0 12px; color: var(--muted);
}
.tabs button[aria-selected=true] { color: var(--text); background: var(--highlight); border-bottom-color: var(--highlight-strong); font-weight: 600; }
.tabs button:hover { background: var(--highlight); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12px; color: var(--muted); }
.legend .item { display: inline-flex; align-items: center; gap: 5px; }

.state { padding: 48px; text-align: center; color: var(--muted); }
.state.error { color: #a51d16; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: #1d2125; color: #fff; font-size: 12px;
  padding: 6px 8px; border-radius: 6px; max-width: 280px; box-shadow: 0 4px 12px rgba(0,0,0,.2); white-space: pre-line;
}

/* ----------------------------------------------------------------- map page */
.map-layout { display: grid; grid-template-columns: 240px 1fr auto; gap: 16px; }
.filters { padding: 14px; display: grid; gap: 14px; align-content: start; overflow: auto; }
.filters fieldset { border: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.filters legend { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; padding: 0; }
.filters label { display: flex; align-items: center; gap: 6px; }
.map-card { display: flex; flex-direction: column; min-height: 0; }
.map-svg { flex: 1; min-height: 0; width: 100%; background: #fbfbfc; border-radius: 0 0 var(--radius) var(--radius); }
.station { cursor: pointer; }
.station:hover .mk, .station.sel .mk { stroke: #111; stroke-width: .5; }
.side { width: 300px; padding: 0; overflow: auto; }
.side dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
.side dt { color: var(--muted); }
.side dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.fillbar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.fillbar > div { height: 100%; }

.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 560px; }
.leaflet-box { height: 560px; background: #e9eef2; position: relative; }
.map-wrap .side { border-left: 1px solid var(--line); overflow: auto; max-height: 560px; }
.map-banner { position: absolute; z-index: 500; left: 12px; right: 12px; top: 12px; background: #fff7e6; border: 1px solid var(--warn); border-radius: 6px; padding: 6px 10px; font-size: 12px; }
.stn-icon, .van-icon, .district-label { background: none; border: none; }
.district-label span { display: block; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #4b5560; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; white-space: nowrap; }
.van-badge { display: inline-grid; place-items: center; min-width: 26px; height: 16px; padding: 0 3px; border-radius: 4px; background: #fff; border: 1.5px solid #3a3f45; color: #3a3f45; font-size: 10px; font-weight: 800; }
.leaflet-container { font: inherit; }
/* soften the street map (roads, buildings, parks, water) so station markers pop */
.leaflet-tile-pane { filter: saturate(.25) brightness(1.12) contrast(.78); opacity: .8; }

/* ------------------------------------------------------------------ heatmap */
.heat { width: 100%; }
.heat text { font-size: 10px; fill: var(--muted); }

/* --------------------------------------------------------------- dock grid */
.docks { display: flex; flex-wrap: wrap; gap: 3px; max-width: 360px; }
.dock { width: 18px; height: 18px; border-radius: 3px; display: grid; place-items: center; font-size: 11px; font-weight: 700; line-height: 1; }
.dock.bike { background: var(--high); color: #fff; }
.dock.bike_disabled { background: repeating-linear-gradient(45deg, var(--low), var(--low) 3px, #fff 3px, #fff 5px); border: 1px solid var(--low); }
.dock.open { background: #fff; border: 1.5px solid var(--line-2); }
.dock.faulty { background: var(--empty); color: #fff; }
.dock.bike_stuck { background: var(--full); color: #fff; }
.dock.never_locks { background: var(--oos); color: #fff; }

/* ---------------------------------------------------------------- dispatch */
.dispatch { grid-template-columns: 1.1fr 1.2fr .9fr; align-items: start; }
.move { border: 1px solid var(--line); border-radius: 6px; padding: 10px; display: grid; gap: 6px; }
.move + .move { margin-top: 8px; }
.loadbar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.loadbar > div { height: 100%; background: var(--accent); }
.list { display: grid; gap: 8px; }
.task { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: grid; gap: 4px; }
.task.done { opacity: .55; }

.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-blue { background: var(--box-blue); border-color: var(--box-blue-line); }
.card-h .subhead { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.kpi .v2 { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: -2px; }
.hazard { display: inline-block; width: 20px; }
.warn-icon { color: #b26a00; font-size: 15px; cursor: help; }
.indent { margin-left: 20px; }
.badge.purple { border-color: var(--full); color: #5e2a87; }
table.forecast tr.risk td { background: var(--risk-row); }
table.forecast tr.risk-high td { background: var(--risk-row-high); }
table.forecast tr.risk-high td:first-child, table.forecast tr.risk td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
table.forecast tr.risk:hover td { background: var(--risk-row); }
table.forecast tr.risk-high:hover td { background: var(--risk-row-high); }
table.forecast td.hit { color: #a51d16; font-weight: 700; }
.swatch { display: inline-block; width: 14px; height: 12px; border-radius: 3px; border: 1px solid #e3b5b0; }
.swatch.risk { background: var(--risk-row); }
.swatch.risk-high { background: var(--risk-row-high); box-shadow: inset 3px 0 0 var(--bad); }
.manual-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px 12px; align-items: end; }
.manual-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.manual-form select, .manual-form input { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- overview */
a.brand-name { color: var(--text); text-decoration: none; border-radius: 4px; }
a.brand-name:hover { text-decoration: underline; }
.brand-short { display: none; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.topbar { height: auto; min-height: 56px; flex-wrap: wrap; row-gap: 6px; padding-top: 8px; padding-bottom: 8px; }
.title-block { flex: 1 1 300px; min-width: 0; }
.page-sub { margin: 0; font-size: 12px; color: var(--muted); }
.page-sub[hidden] { display: none; }
.ov-stat .v { font-size: 34px; line-height: 1.1; }
.ov-stat .l { font-size: 13px; color: var(--text); }
.ov-stat .l span { font-size: 11px; color: var(--muted); }
.ov-risk { border-color: #e9b8b2; box-shadow: 0 2px 8px rgba(209, 52, 44, .08); }
.ov-risk h2 { font-size: 17px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { filter: brightness(.97); }
tr.clickable:focus-visible { outline: 2px solid var(--high); outline-offset: -2px; }
.ov-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.page-card { position: relative; display: grid; gap: 6px; align-content: space-between; padding: 12px 14px; min-height: 104px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-decoration: none; transition: border-color .12s, box-shadow .12s, transform .12s; }
.page-card:hover, .page-card:focus-visible { background: var(--highlight); border-color: var(--highlight-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.page-card:focus-visible { outline: 2px solid var(--high); outline-offset: 2px; }
.pc-title { font-weight: 600; font-size: 13px; }
.pc-line { font-size: 12px; color: var(--muted); }
.pc-num { font-size: 18px; font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; padding-right: 18px; }
.pc-num small { font-size: 11px; font-weight: 500; color: var(--muted); }
.pc-arrow { position: absolute; right: 12px; bottom: 10px; color: var(--muted); font-size: 16px; }
.page-card:hover .pc-arrow { color: var(--text); }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .axis { stroke: var(--line-2); }
.chart .grid { stroke: var(--line); }
.chart-notes { margin-top: 10px; align-items: start; }
.formula { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.calc-in { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.calc-in input { width: 90px; }
.result { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.blocks { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.with-filters { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
.two-one { grid-template-columns: 2fr 1fr; align-items: start; }

@media (max-width: 1100px) {
  .cols-4, .cols-5 { grid-template-columns: repeat(2, 1fr); }
  .ov-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-form { grid-template-columns: 1fr 1fr; }
  .cols-3, .dispatch, .two-one { grid-template-columns: 1fr; }
  .map-wrap { grid-template-columns: 1fr; }
  .map-wrap .side { border-left: none; border-top: 1px solid var(--line); max-height: none; }
}
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; }
  .top-controls { flex-wrap: wrap; }
  main { padding: 12px 16px 24px; }
  .cols-2, .cols-4, .map-layout, .with-filters { grid-template-columns: 1fr; }
  .site-header { padding: 8px 16px; }
  .card-h { flex-wrap: wrap; }
  .table-wrap { max-width: calc(100vw - 32px); }
}

/* Guides use the workspace width, with inset copy and responsive visual panels. */
.guide { width: 100%; max-width: none; padding: clamp(16px, 2.5vw, 42px); }
.guide-intro { margin-bottom: 28px; padding: 12px 0 8px; }
.guide-intro h2 { font-size: clamp(26px, 3vw, 40px); letter-spacing: -.025em; margin: 8px 0 12px; line-height: 1.2; }
.guide-intro p { font-size: 16px; max-width: 85ch; }
.guide-eyebrow { color: var(--high); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.docs-visuals, .docs-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-bottom: 26px; }
.guide-figure { margin: 0; padding: 24px; min-width: 0; }
.guide-figure figcaption { margin-bottom: 20px; }
.guide-figure figcaption b { display: block; font-size: 18px; }
.guide-figure figcaption span { color: var(--muted); font-size: 12px; }
.guide-figure > p { margin-top: 18px; font-size: 13px; }
.docs-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.docs-kpis .kpi { border: 1px solid var(--box-blue-line); border-radius: var(--radius); }
.docs-station-sample { display: grid; gap: 12px; margin-top: 20px; }
.docs-station-sample > div { display: flex; align-items: center; gap: 12px; }
.docs-station-sample small { display: block; color: var(--muted); }
.docs-forecast, .docs-record { grid-column: 1 / -1; }
.guide-step { padding: 26px 30px; min-width: 0; }
.guide-step h2 { display: flex; align-items: center; gap: 12px; margin-top: 0; }
.step-number { background: var(--box-blue); color: var(--high); border-radius: 8px; padding: 5px 9px; font-size: 13px; }
.guide ul { padding-left: 24px; margin: 14px 0 0; }
.guide li { padding-left: 4px; margin-bottom: 9px; }
.guide ul ul { margin: 8px 0 14px; color: var(--muted); list-style-type: circle; }
.guide-notice { background: var(--box-blue); padding: 20px; border-radius: 8px; margin-bottom: 24px; }
.team-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; align-items: stretch; }
.team-card { overflow: hidden; min-width: 0; }
.team-card img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; object-position: center 30%; }
.team-bio { padding: 24px; }
.team-bio h2 { font-size: 22px; margin: 8px 0 14px; text-transform: none; }
.team-bio p { color: var(--muted); line-height: 1.75; }
.about-footer { margin-top: 26px; padding: 28px; background: var(--box-blue); border-color: var(--box-blue-line); }
.about-footer h2 { margin-top: 0; }
@media (max-width: 1150px) {
  .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .docs-visuals, .docs-steps, .team-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-step, .guide-figure { padding: 22px; }
  .guide .table-wrap { max-width: 100%; }
}

/* Match the actual dashboard components inside the illustrated guide. */
.guide-section-title { margin: 28px 0 20px; }
.docs-preview-grid, .formula-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.docs-map { height: 340px; border: 1px solid var(--line); border-radius: 8px; z-index: 0; }
.docs-heat-preview { grid-column: 1 / -1; min-width: 0; }
.docs-heat-preview .card-h { flex-wrap: wrap; gap: 12px; }
.docs-dock-rows { display: grid; gap: 18px; margin-top: 24px; }
.docs-dock-rows .docks { margin: 8px 0; }
.formula-card { padding: 26px 30px; min-width: 0; }
.formula-card h3 { color: var(--high); margin-bottom: 18px; }
.formula-equation { font-family: Cambria, Georgia, serif; font-size: 21px; padding: 16px; margin-bottom: 14px; background: var(--box-blue); border-left: 3px solid var(--high); border-radius: 4px; overflow-wrap: anywhere; }
.formula-example { color: var(--muted); font-size: 13px; }
.about-guide .guide-intro p { max-width: none; }
@media (min-width: 1250px) {
  .about-guide .guide-intro p { white-space: nowrap; font-size: clamp(13px, 1.1vw, 16px); }
}
@media (max-width: 760px) {
  .docs-preview-grid, .formula-grid { grid-template-columns: minmax(0, 1fr); }
  .formula-card { padding: 22px; }
  .docs-map { height: 280px; }
}

/* Native mathematical notation: scalable fractions, radicals and accents. */
.formula-equation { overflow-x: auto; overflow-wrap: normal; }
.formula-equation math { font-family: 'Cambria Math', 'STIX Two Math', math; font-size: clamp(19px, 1.6vw, 25px); text-align: left; margin: 10px 0; }
.formula-equation math + math { margin-top: 22px; }
/* Keep portraits and names visible sooner, without hiding any biography. */
.about-guide { padding-top: 0; }
.about-guide .guide-intro { margin-bottom: 8px; padding-top: 0; padding-bottom: 0; }
.about-guide .guide-intro h2 { margin-top: 4px; margin-bottom: 6px; }
.team-card img { height: clamp(260px, 35vh, 350px); aspect-ratio: auto; object-position: center 30%; }
.team-bio { padding: 16px 20px 22px; }
.team-bio h2 { margin: 5px 0 10px; }
@media (max-width: 760px) {
  .team-card img { height: auto; aspect-ratio: 1; }
}
