/* Shell styling. Palette from Brian's GAMA build (SRF corporate blues), condition
   ramp replaced: his six bands sat on a 0-200 index that no longer exists, and his
   ramp put blue at "best" against a blue brand. The ramp below runs green to red on
   ASTM D6433's own condition names. */

:root {
  --srf-blue: #0081c6;
  --srf-dark: #00405f;
  --srf-mid: #0e5c85;
  --ink: #23303a;
  --ink-2: #5a6672;
  --ink-3: #8a96a2;
  --edge: #d5dbe0;
  --edge-2: #b8c2cb;
  --panel: #ffffff;
  --page: #eef2f5;

  --good: #1f8a4c;
  --satisfactory: #6cb33f;
  --fair: #d7c61f;
  --poor: #f0a02c;
  --verypoor: #e86a2e;
  --serious: #d63b2f;

  --gold: #ff6a00;
  --grey-road: #aeb6bd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Segoe UI', Lato, -apple-system, system-ui, Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-size: 14px;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- header ---------- */
header {
  background: var(--srf-dark);
  color: #fff;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.brand img { height: 26px; }
.brand small { font-weight: 400; font-size: 12px; color: #a9d6ee; }
.spacer { flex: 1; }

.group { display: flex; align-items: center; gap: 7px; }
.group > label { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: #a9d6ee; }

.toggle { display: inline-flex; border: 1px solid #2c6d90; border-radius: 6px; overflow: hidden; }
.toggle button {
  border: 0; padding: 6px 14px; font-size: 13px; font-weight: 600;
  background: #0d4d70; color: #cde5f2; cursor: pointer;
}
.toggle button[aria-pressed="true"] { background: var(--srf-blue); color: #fff; }

.hbtn {
  background: #0d4d70; border: 1px solid #2c6d90; color: #cde5f2;
  padding: 6px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.hbtn:hover { background: var(--srf-blue); color: #fff; }
.hbtn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #fff; }

/* ---------- layout ---------- */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 10px; gap: 10px; }
.top { display: flex; gap: 10px; height: 56%; min-height: 340px; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 9px; }

#map { flex: 1; border-radius: 9px; border: 1px solid var(--edge-2); background: #dde5ea; }
#side { width: 335px; min-width: 300px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- readout ---------- */
#readout { padding: 11px 13px; }
.ryear { display: flex; align-items: baseline; gap: 9px; }
.ryear b { font-size: 30px; line-height: 1; color: var(--srf-dark); }
.ryear span { font-size: 12px; color: var(--ink-3); }
.stats { display: flex; gap: 20px; margin-top: 9px; }
.stat .k { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 20px; font-weight: 700; color: var(--srf-dark); }
.stat.warn .v { color: var(--serious); }
.stat.good .v { color: var(--good); }
.pm { font-size: 12px; color: var(--ink-2); border-bottom: 1px dotted var(--ink-3); cursor: help; }
.rnote { margin-top: 8px; font-size: 12px; color: var(--ink-2); min-height: 17px; }
.rnote.beat { color: var(--gold); font-weight: 600; }

/* ---------- budget meter ---------- */
#budget { margin-top: 9px; }
.bar { height: 9px; background: #e3e9ee; border-radius: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); width: 0; transition: width .3s ease; }
.brow { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); margin-bottom: 3px; }

/* ---------- cumulative spend ---------- */
#cumulative { padding: 10px 13px; }
#cumulative h3 { margin: 0 0 7px; font-size: 12px; color: var(--srf-dark); text-transform: uppercase; letter-spacing: .4px; }
.cumrow { display: grid; grid-template-columns: 74px 1fr 62px; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 12px; }
.cumrow .lbl { color: var(--ink-2); }
.cumrow.on .lbl { color: var(--srf-dark); font-weight: 700; }
.cumrow .track { height: 11px; background: #e3e9ee; border-radius: 6px; overflow: hidden; }
.cumrow .track > i { display: block; height: 100%; width: 0; transition: width .35s ease; }
.cumrow[data-t="County"] .track > i { background: #7d8b97; }
.cumrow[data-t="PCiQ"] .track > i { background: var(--srf-blue); }
.cumrow .amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- timeline ---------- */
#timeline { padding: 9px 13px 12px; }
.tlrow { display: flex; align-items: center; gap: 10px; }
#scrub { flex: 1; }
.zones { position: relative; height: 15px; margin-top: 5px; font-size: 10.5px; color: var(--ink-3); }
.zones span { position: absolute; transform: translateX(-50%); }
.zonebar { position: relative; height: 5px; border-radius: 3px; background: #dfe6eb; overflow: hidden; }
.zonebar > .checked { position: absolute; left: 0; top: 0; bottom: 0; background: #9dc7dd; }
.zonebar > .estimate { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(45deg, #dfe6eb, #dfe6eb 4px, #cdd7de 4px, #cdd7de 8px); }
.zonelabels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }

/* ---------- tabs ---------- */
.bottom { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.tabs button {
  background: #dde4ea; border: 1px solid var(--edge); border-bottom: 0;
  border-radius: 7px 7px 0 0; padding: 6px 13px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #fff; color: var(--srf-dark); }
.tabwrap { flex: 1; background: #fff; border: 1px solid var(--edge); border-radius: 0 9px 9px 9px; overflow: hidden; display: flex; flex-direction: column; }
.tabtools { display: flex; align-items: center; gap: 11px; padding: 6px 10px; border-bottom: 1px solid var(--edge); font-size: 12px; }
.tabtools input, .tabtools select { border: 1px solid var(--edge-2); border-radius: 5px; padding: 4px 8px; font-size: 12px; }
.tabtools .desc { color: var(--ink-3); font-style: italic; }
.tabtools .grow { flex: 1; }
.tabtools .stat2 { color: var(--srf-dark); font-weight: 600; }
.scroll { flex: 1; overflow: auto; padding: 0; }

table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { padding: 5px 9px; text-align: left; white-space: nowrap; border-bottom: 1px solid #eaeff3; }
th { position: sticky; top: 0; background: var(--srf-dark); color: #fff; cursor: pointer; z-index: 2; font-weight: 600; }
th:hover { background: var(--srf-blue); }
tbody tr:hover { background: #eef7fc; }
tr.sel { background: #d8ecf8 !important; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.sev-blocking { color: var(--serious); font-weight: 700; }
.sev-high { color: var(--verypoor); font-weight: 600; }
.sev-info { color: var(--ink-2); }

.empty { padding: 26px; color: var(--ink-3); font-size: 13px; line-height: 1.6; }
.note { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }

/* ---------- sliders ---------- */
#sliders { display: flex; gap: 18px; align-items: center; padding: 8px 13px; flex-wrap: wrap; }
.slider { display: flex; flex-direction: column; gap: 2px; min-width: 168px; }
.slider .k { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.slider .v { font-size: 13px; font-weight: 700; color: var(--srf-dark); }
.slider .d { font-size: 11px; color: var(--ink-2); }
.slider input { width: 100%; }

/* ---------- modal ---------- */
.modalbk { position: fixed; inset: 0; background: rgba(0, 24, 40, .55); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modalbk[open] { display: flex; }
.modal { background: #fff; border-radius: 11px; max-width: min(1000px, 94vw); max-height: 92vh; overflow: auto; padding: 20px 22px; }
.modal h2 { color: var(--srf-dark); margin: 0 0 4px; font-size: 19px; }
.modal h3 { color: var(--srf-dark); margin: 20px 0 6px; font-size: 14px; }
.modal .sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 12px; }
.modal .x { float: right; cursor: pointer; font-size: 22px; color: var(--ink-3); border: 0; background: none; }
.lut { border-collapse: collapse; font-size: 12px; width: 100%; }
.lut th, .lut td { border: 1px solid var(--edge); padding: 4px 8px; }
.lut th { background: var(--srf-mid); color: #fff; position: static; }

.legend { line-height: 1.7; font-size: 12px; }
.legend i { display: inline-block; width: 15px; height: 9px; margin-right: 7px; border-radius: 2px; vertical-align: middle; }

/* Map roads: the cascade highlight during the projects beat. */
.leaflet-interactive.funding { filter: drop-shadow(0 0 5px rgba(255, 106, 0, .85)); }
.leaflet-interactive.dim { opacity: .5; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
