/* ─────────────────────────────────────────────────────────────────────────────
   Cairns traffic viewer.

   Committed dark design: the map carries a dark basemap so that bright ramp
   steps read as "high volume", and mixing light chrome against a dark map
   reads worse than either alone. Tokens below are the data-viz reference
   palette's dark column; the two sequential ramps are validated
   lightness-matched (see build notes in README).
   ───────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;

  /* surfaces & ink */
  --page:           #0d0d0d;
  --surface-1:      #1a1a19;
  --surface-2:      #232322;
  --map-surface:    #1c1e21;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255, 255, 255, 0.10);

  /* the two layer identities = categorical slots 1 & 2, dark steps */
  --road:  #3987e5;
  --foot:  #d95926;

  /* no-data */
  --nodata: #55554f;

  /* site marker — a status/attention token, deliberately not on either
     sequential ramp so it can never read as a volume value */
  --site: #d03b3b;

  --radius: 8px;
  --pad: 18px;
  /* Left pane width. Scales up on wide monitors — see the media queries at
     the end of this file; a 3440px ultrawide gets a much wider pane and a
     two-column panel rather than one 340px ribbon beside 3100px of map. */
  --pane: 430px;

  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: var(--pane) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── panel ──────────────────────────────────────────────────────────────── */

#panel {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding: var(--pad);
  border-bottom: 1px solid var(--border);
}
.panel-head h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.block {
  padding: var(--pad);
  border-bottom: 1px solid var(--border);
}
.block h2 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.block-head h2 { margin-bottom: 10px; }

.active-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.hint {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}
.hint em { color: var(--text-secondary); font-style: normal; font-weight: 600; }

/* ── layer rows ─────────────────────────────────────────────────────────── */

.layer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.switch { position: relative; display: block; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  display: block;
  width: 30px; height: 17px;
  border-radius: 999px;
  background: var(--baseline);
  transition: background 120ms;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 120ms, background 120ms;
}
.switch input:checked + .track { background: #2f5d92; }
.switch input:checked + .track::after {
  transform: translateX(13px);
  background: #ffffff;
}
.switch input:focus-visible + .track { outline: 2px solid var(--road); outline-offset: 2px; }

.layer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.layer-btn:hover { background: var(--surface-2); }
.layer-btn.is-active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-primary);
  font-weight: 600;
}
.layer-btn .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: none;
}
.layer-name { flex: 1; }
.layer-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

/* ── segmented metric control ───────────────────────────────────────────── */

.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.seg button:hover { background: var(--surface-2); }
.seg button[aria-selected="true"] {
  background: var(--surface-2);
  border-color: var(--text-muted);
  color: var(--text-primary);
  font-weight: 600;
}

/* ── range sliders ──────────────────────────────────────────────────────── */

.range-wrap { position: relative; height: 26px; }
.range-wrap input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.range-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--baseline);
  margin-top: 11px;
}
.range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 14px; height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--surface-1);
  cursor: grab;
}
.range-wrap input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--road);
  outline-offset: 1px;
}

.range-read {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.mini {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.mini:hover { background: var(--surface-2); color: var(--text-primary); }

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.check input { accent-color: var(--road); width: 13px; height: 13px; }
.check:has(input:disabled) { opacity: 0.45; cursor: default; }

#nodata-hint { margin-top: 6px; }

/* ── histogram ──────────────────────────────────────────────────────────── */

.fig { margin: 0; }
.hist {
  display: flex;
  align-items: flex-end;
  gap: 2px;                 /* 2px surface gap between adjacent bars */
  height: 64px;
  border-bottom: 1px solid var(--baseline);   /* solid hairline baseline */
  padding-bottom: 0;
}
.hist .bar {
  flex: 1;
  min-width: 0;
  border-radius: 3px 3px 0 0;  /* rounded data-end, square on the baseline */
  background: var(--road);
  position: relative;
  transition: opacity 120ms;
}
.hist .bar[data-empty="true"] { background: var(--gridline); }
.hist .bar:hover { opacity: 0.75; }
figcaption {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── link type list ─────────────────────────────────────────────────────── */

.lt-list { display: flex; flex-direction: column; gap: 1px; }
.lt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 120ms;
}
.lt:hover { background: var(--surface-2); }
.lt input { accent-color: var(--road); width: 13px; height: 13px; flex: none; }
.lt .lt-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt .lt-n {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.lt.is-off { color: var(--text-muted); }

/* ── stats ──────────────────────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 12px; }
.stat { padding: 5px 0; }
.stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.stat-value {
  display: block;
  margin-top: 1px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.stat-value .unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
}
.stat.is-wide { grid-column: 1 / -1; }

.panel-foot {
  margin-top: auto;
  padding: var(--pad);
  display: flex;
  gap: 6px;
}

/* ── site analysis ──────────────────────────────────────────────────────── */

.block-site {
  background: linear-gradient(180deg, rgba(208, 59, 59, 0.05), transparent 60%);
}
.site-swatch {
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--site);
  border: 1.5px solid #fff;
  vertical-align: baseline;
}

.sub-h {
  margin: 16px 0 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.score-row { display: flex; align-items: flex-start; gap: 12px; }
.score { display: flex; align-items: baseline; gap: 3px; flex: none; }
.score-value {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-primary);
}
.score-of { font-size: 12px; color: var(--text-muted); }
.score-note {
  margin: 0;
  padding-top: 3px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.site-loc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.site-loc input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.site-loc input:focus { outline: none; color: var(--text-primary); }
.site-loc:has(input:focus) { border-color: var(--text-muted); }
.site-loc input.is-bad { color: var(--site); }

.mini.is-armed {
  border-color: var(--site);
  color: var(--site);
  font-weight: 600;
}

/* score components — one series per row, direct-labelled, no legend needed */
.comps { display: flex; flex-direction: column; gap: 9px; }
.comp-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.comp-label { font-size: 12px; color: var(--text-secondary); }
.comp-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.comp-bar {
  height: 5px;
  margin-top: 4px;
  border-radius: 3px;
  background: var(--gridline);
  overflow: hidden;
}
.comp-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--road);
  transition: width 200ms ease-out;
}
.comp-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.comp-weight { flex: none; }

.read { display: flex; flex-direction: column; gap: 7px; }
.read p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.read strong { color: var(--text-primary); font-weight: 600; }
.read em { color: var(--text-muted); font-style: normal; }
.read p:last-child {
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
}

.scrim-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
.scrim-row input[type="range"] {
  flex: 1;
  accent-color: var(--road);
  height: 3px;
}
.scrim-row span { font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }

/* ── map ────────────────────────────────────────────────────────────────── */

#map-wrap { position: relative; background: var(--map-surface); }
#map { position: absolute; inset: 0; }

.maplibregl-ctrl-attrib {
  font-size: 10px !important;
  background: rgba(13, 13, 13, 0.72) !important;
}
.maplibregl-ctrl-attrib a { color: var(--text-muted) !important; }
.maplibregl-ctrl-group { background: var(--surface-1) !important; border: 1px solid var(--border) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--border) !important; }
.maplibregl-ctrl-group button span { filter: invert(1) !important; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--map-surface);
  color: var(--text-secondary);
  font-size: 13px;
  z-index: 5;
  transition: opacity 300ms;
}
#loading.is-done { opacity: 0; pointer-events: none; }
.spin {
  width: 15px; height: 15px;
  border: 2px solid var(--baseline);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── legend ─────────────────────────────────────────────────────────────── */

#legend {
  position: absolute;
  left: 12px; bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 13, 13, 0.86);
  backdrop-filter: blur(8px);
  font-size: 11px;
  z-index: 4;
}
.legend-row {
  display: grid;
  grid-template-columns: 34px 118px auto;
  grid-template-areas: "title ramp ." "title lo hi";
  align-items: center;
  gap: 1px 8px;
  margin-bottom: 7px;
}
.legend-row[hidden] { display: none; }
.legend-title { grid-area: title; color: var(--text-secondary); font-weight: 600; }
.ramp {
  grid-area: ramp;
  height: 7px;
  border-radius: 2px;
}
.legend-lo, .legend-hi {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}
.legend-lo { grid-area: lo; }
.legend-hi { grid-area: hi; justify-self: end; text-align: right; }
.legend-note {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
}
.swatch-nodata {
  width: 14px; height: 3px;
  border-radius: 2px;
  background: var(--nodata);
}

/* ── tooltip ────────────────────────────────────────────────────────────── */

#tooltip {
  position: absolute;
  z-index: 6;
  min-width: 168px;
  max-width: 250px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 13, 13, 0.94);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  font-size: 12px;
  transform: translate(12px, 12px);
}
#tooltip[hidden] { display: none; }
.tt-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.tt-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tt-name { font-weight: 600; color: var(--text-primary); }
.tt-type { font-size: 10px; color: var(--text-muted); }
.tt-grid { display: grid; grid-template-columns: auto auto; gap: 2px 12px; }
.tt-k { color: var(--text-muted); font-size: 11px; }
.tt-v {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.tt-v.is-primary { color: var(--text-primary); font-weight: 600; }
.tt-v.is-nodata { color: var(--text-muted); font-style: italic; }

/* ── table modal ────────────────────────────────────────────────────────── */

#table-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 32px;
}
#table-modal[hidden] { display: none; }
.modal-card {
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  overflow: hidden;
}
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--pad);
}
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot {
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.modal-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-primary);
}
.modal-scroll { overflow: auto; }
#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#data-table th, #data-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
#data-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: right;
}
#data-table th:first-child, #data-table td:first-child { text-align: left; }
#data-table td.is-nodata { color: var(--text-muted); font-style: italic; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 45vh 55vh; }
  #panel { border-right: none; border-bottom: 1px solid var(--border); }
}


/* ── site appraisal extras ──────────────────────────────────────────────── */

.btn-row { display: flex; gap: 5px; }

.draw-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.mini-lg { padding: 6px 11px; font-size: 12px; }
.mini:disabled { opacity: 0.4; cursor: default; }
.draw-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.read-inline {
  margin: 0 0 4px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.read-inline strong { color: var(--text-primary); font-weight: 600; }

/* cashflow table */
.cf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cf-table td { padding: 4px 0; }
.cf-table td:last-child { text-align: right; white-space: nowrap; }
.cf-table .cf-group td { color: var(--text-primary); font-weight: 600; }
.cf-table .cf-sub td {
  padding-top: 0;
  font-size: 10.5px;
  color: var(--text-muted);
}
.cf-table .cf-neg td { color: var(--text-secondary); }
.cf-table .cf-total td {
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-primary);
}
.cf-table .cf-total.is-pos td:last-child { color: #0ca30c; }
.cf-table .cf-total.is-neg td:last-child { color: var(--site); }

.cf-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px 12px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* editable assumptions */
.assumes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
}
.assume {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label label" "input suffix";
  align-items: center;
  gap: 1px 4px;
}
.assume-label {
  grid-area: label;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.assume input {
  grid-area: input;
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.assume input:focus { outline: none; border-color: var(--road); }
.assume-suffix { grid-area: suffix; font-size: 10px; color: var(--text-muted); }

/* SA2 contribution + generic mini tables */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.mini-table th {
  text-align: right;
  padding: 3px 4px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table td {
  padding: 3px 4px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--gridline);
}

/* suburb hotspots */
.seg-sm button { padding: 3px 7px; font-size: 11px; }

.hot {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.hot:hover { background: var(--surface-2); border-color: var(--border); }
.hot-rank {
  flex: none;
  width: 17px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.hot-body { flex: 1; min-width: 0; }
.hot-name {
  display: block;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hot-bar {
  display: block;
  height: 4px;
  margin: 4px 0 3px;
  border-radius: 2px;
  background: var(--gridline);
  overflow: hidden;
}
.hot-bar span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--foot);
}
.hot-meta {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── wide-monitor layout ────────────────────────────────────────────────────
   On a 3440x1440 ultrawide a single 430px ribbon beside 3000px of map wastes
   the panel and makes every table cramped. Past 2000px the pane widens and the
   panel itself goes two-column, so the appraisal and the map are both readable
   without scrolling a mile.
   ───────────────────────────────────────────────────────────────────────── */

@media (min-width: 1800px) {
  :root { --pane: 520px; }
}

@media (min-width: 2400px) {
  :root { --pane: 680px; --pad: 22px; }
  html, body { font-size: 15px; }
  /* Two columns inside the panel: sections flow into a masonry-ish grid. */
  #panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 0;
  }
  .panel-head, .block-site, .panel-foot { grid-column: 1 / -1; }
  .block { border-right: 1px solid var(--border); }
  /* The appraisal block is the long one — give it internal columns too. */
  .block-site {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
  }
  .block-site .block-head,
  .block-site .score-row,
  .block-site .draw-row,
  .block-site #draw-hint,
  .block-site #poly-summary { grid-column: 1 / -1; }
  .assumes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .score-value { font-size: 52px; }
}

@media (min-width: 3200px) {
  :root { --pane: 820px; }
  #legend { font-size: 12px; }
  .legend-row { grid-template-columns: 44px 170px auto; }
}

/* ── map-mode legends + progress ─────────────────────────────────────────── */

.swatch-unreach {
  width: 14px; height: 3px;
  margin-left: 10px;
  border-radius: 2px;
  background: #7a3b3b;
}

#legend-success { margin-bottom: 7px; }
.legend-div { display: flex; align-items: center; gap: 8px; }
.div-ramp {
  flex: 1;
  height: 7px;
  border-radius: 2px;
  /* Discrete bands, because the map paints steps not a gradient — a smooth
     legend would promise a continuous scale the marks do not deliver. */
  background: linear-gradient(90deg,
    #9d3437 0 16.6%, #c5494c 16.6% 33.3%, #d55859 33.3% 50%,
    #383835 50% 55%,
    #3987e5 55% 70%, #6fa6ec 70% 85%, #9fc4f4 85% 100%);
}
/* The SA2 gap layer is a large-area fill drawn under both link ramps, so it
   cannot borrow the success surface's blue: that blue is already the road
   volume ramp. Violet<->teal is the third pair clear of road 215° and foot 30°.
   Kept in lockstep with GAP_COLORS in app.js. */
.div-ramp-gap {
  background: linear-gradient(90deg,
    #2f7d63 0 16.6%, #4f9a80 16.6% 33.3%, #7bb8a4 33.3% 50%,
    #383835 50% 55%,
    #6a3fa8 55% 70%, #8a63c7 70% 85%, #b199de 85% 100%);
}
.flow-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  color: var(--ink-3);
}
.flow-key .dot { width: 6px; height: 6px; border-radius: 50%; }
.legend-fine {
  margin: 3px 0 0;
  font-size: 9px;
  line-height: 1.35;
  color: var(--ink-4, #7d8590);
  max-width: 210px;
}
.div-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  padding-left: 42px;
  font-size: 9.5px;
  color: var(--text-muted);
}
/* Hub arcs. Warm near-white, kept in lockstep with ARC_INK in arcs.js — the
   swatch is a line, not a dot, because the encoding is width not area. */
.arc-swatch {
  width: 14px; height: 3px;
  border-radius: 2px;
  background: #efe4d4;
}
.flow-key .dot-hollow {
  background: transparent;
  box-shadow: inset 0 0 0 1.2px #efe4d4;
}

.prog {
  display: inline-block;
  width: 90px; height: 4px;
  vertical-align: middle;
  border-radius: 2px;
  background: var(--gridline);
  overflow: hidden;
}
.prog span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--road);
  transition: width 120ms linear;
}

/* ── layer stack + competition ───────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.stack-row {
  display: grid;
  grid-template-columns: 16px 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
  cursor: pointer;
}
.stack-row:hover { border-color: var(--text-muted); }
.stack-row.is-base { opacity: 0.55; cursor: default; }
.stack-n {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.stack-row input { accent-color: var(--road); width: 13px; height: 13px; margin: 0; }
.stack-row.is-base .stack-n { grid-column: 1; }
.stack-row.is-base .stack-name { grid-column: 3; }
.stack-name { color: var(--text-primary); }
.stack-desc { font-size: 10px; color: var(--text-muted); text-align: right; }

.comp-add {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.assume-inline { width: 78px; }
.is-unreach { color: var(--site); font-style: italic; }
#comp-list input.comp-fte {
  width: 56px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
#comp-list .mini { padding: 1px 6px; line-height: 1.2; }
