/* Haulage Radar v2.0 -- application shell.
   Identity kept: motorway blue, plate yellow, Overpass (road-sign DNA).
   Structure changed: dark filter rail + light workspace, SaaS-grade rhythm. */

:root {
  --blue: #2563c4;
  --blue-bright: #4a86e8;
  --ink: #16191d;
  --rail: #16191d;
  --rail-2: #1e2329;
  --rail-text: #c8cfd6;
  --rail-muted: #7d868f;
  --ground: #f0f2f4;
  --panel: #ffffff;
  --line: #e0e4e8;
  --plate-yellow: #f7c82b;
  --green: #0a7a46;
  --red: #c0341d;
  --amber: #c8920b;
  --muted: #5a6268;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 12px 28px -18px rgba(16, 24, 40, 0.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Overpass", system-ui, sans-serif;
  font-feature-settings: "tnum";
  background: var(--ground);
  color: var(--ink);
  line-height: 1.45;
}

.shell { display: grid; grid-template-columns: 288px 1fr; min-height: 100vh; }

/* ================= RAIL ================= */
.rail {
  background: linear-gradient(180deg, var(--rail-2) 0%, var(--rail) 220px);
  color: var(--rail-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: #3a424b transparent;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 16px; border-bottom: 1px solid #262c33; }
.route-marker {
  font-family: "Overpass Mono", monospace; font-weight: 700;
  border: 2.5px solid var(--plate-yellow); color: var(--plate-yellow);
  border-radius: 8px; padding: 3px 9px 0; font-size: 1.05rem; letter-spacing: 0.04em;
}
.brand h1 { margin: 0; font-size: 1.12rem; font-weight: 900; color: #fff; letter-spacing: 0.01em; }
.brand p { margin: 2px 0 0; font-size: 0.7rem; color: var(--rail-muted); }

.railbody { padding: 6px 18px 24px; display: flex; flex-direction: column; }
.fgroup { padding: 14px 0 4px; border-bottom: 1px solid #23292f; }
.fgroup:last-child { border-bottom: 0; }
.flabel {
  margin: 0 0 10px; font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--rail-muted);
}

.rail input[type="search"], .rail input[type="text"], .rail input[type="number"], .rail select {
  width: 100%; font: inherit; font-size: 0.85rem; color: #eef1f4;
  background: #23292f; border: 1px solid #333b44; border-radius: 8px;
  padding: 9px 10px; margin-bottom: 8px;
}
.rail input::placeholder { color: #6f7881; }
.rail input:focus, .rail select:focus { outline: 2px solid var(--blue-bright); outline-offset: 0; border-color: var(--blue-bright); }
.rail select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8a939c 50%), linear-gradient(135deg, #8a939c 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
#pc { text-transform: uppercase; }
.geo { display: grid; grid-template-columns: 1fr 92px; gap: 8px; }
.pc-status { margin: -4px 0 6px; font-size: 0.7rem; color: var(--rail-muted); min-height: 1em; }

.fleetrow { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.fleetrow input { margin-bottom: 0 !important; }
.minilabel { font-size: 0.78rem; font-weight: 700; color: var(--rail-text); }
.sep { font-size: 0.72rem; color: var(--rail-muted); }

.scorerow { display: grid; grid-template-columns: 1fr 84px 26px; gap: 8px; align-items: center; font-size: 0.78rem; font-weight: 700; margin-bottom: 10px; color: var(--rail-text); }
.scorerow input[type="range"] { accent-color: var(--blue-bright); width: 100%; }
.scorerow output { font-family: "Overpass Mono", monospace; text-align: right; color: #fff; }

.check { display: flex; gap: 8px; align-items: center; font-size: 0.8rem; font-weight: 600; margin-bottom: 9px; color: var(--rail-text); }
.check input { width: 15px; height: 15px; accent-color: var(--blue-bright); }
.starcount { color: var(--plate-yellow); font-weight: 800; }

.bandslider { margin-bottom: 12px; }
.bandhead { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.78rem; font-weight: 700; color: var(--rail-text); margin-bottom: 2px; }
.bandhead em { font-style: normal; font-weight: 600; font-size: 0.64rem; color: var(--amber); margin-left: 5px; }
.bandhead output { font-family: "Overpass Mono", monospace; color: #fff; font-size: 0.76rem; }
.dual { position: relative; height: 24px; --lo: 0%; --hi: 100%; }
.dual::before {
  content: ""; position: absolute; top: 10px; left: 0; right: 0; height: 4px; border-radius: 99px;
  background: linear-gradient(to right, #333b44 var(--lo), var(--blue-bright) var(--lo), var(--blue-bright) var(--hi), #333b44 var(--hi));
}
.dual input[type="range"] {
  position: absolute; inset: 0; width: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: none; pointer-events: none; height: 24px;
}
.dual input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue-bright); cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); margin-top: 5px;
}
.dual input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue-bright); cursor: grab;
}

.railfoot { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }
.railbtn {
  font: inherit; font-size: 0.78rem; font-weight: 700; text-align: left;
  color: var(--rail-text); background: #23292f; border: 1px solid #333b44;
  border-radius: 8px; padding: 9px 12px; cursor: pointer;
}
.railbtn:hover { border-color: var(--blue-bright); color: #fff; }
.railbtn:focus-visible { outline: 2px solid var(--plate-yellow); }

.railtoggle { display: none; }

/* ================= WORKSPACE ================= */
.work { padding: 22px 26px 40px; min-width: 0; }

.overview { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 15px 13px; min-height: 104px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
}
.stat.big { border-top: 3px solid var(--plate-yellow); }
.stat.gauge { align-items: center; justify-content: center; padding: 8px; }
.stat-num { font-family: "Overpass Mono", monospace; font-weight: 700; font-size: 1.8rem; line-height: 1.05; }
.stat-num.accent { color: var(--green); }
.stat-label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.stat-label em { display: block; font-style: normal; color: #a4adb3; font-size: 0.62rem; text-transform: none; letter-spacing: 0.02em; }

.workbar { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 12px; }
.count { margin: 0; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.sortwrap { font-size: 0.78rem; font-weight: 700; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.sortwrap select { font: inherit; font-size: 0.85rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* result cards */
.row {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 18px 13px; margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: start;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--line);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.row.tier-hot { border-left-color: var(--green); }
.row.tier-warm { border-left-color: var(--plate-yellow); }
@media (prefers-reduced-motion: no-preference) {
  .row:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: #c9d2da; }
}
.row h2 { margin: 0; font-size: 1.02rem; font-weight: 800; letter-spacing: -0.005em; }
.namebtn { font: inherit; font-weight: 800; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.namebtn:hover, .namebtn:focus { color: var(--blue); text-decoration: underline; }
.rowmeta { font-family: "Overpass Mono", monospace; font-size: 0.74rem; color: var(--muted); margin: 3px 0 0; }
.rationale { grid-column: 1 / -1; margin: 5px 0 0; font-size: 0.88rem; color: #363d43; }
.flags { grid-column: 1 / -1; margin-top: 7px; display: flex; flex-wrap: wrap; gap: 6px; }
.flag { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; padding: 2px 9px; border-radius: 999px; background: #fbeae6; color: var(--red); border: 1px solid #eec6bd; }
.flag.ok { background: #e7f3ec; color: var(--green); border-color: #bfdccb; }

.plates { display: flex; gap: 8px; align-items: center; }
.plate {
  font-family: "Overpass Mono", monospace; font-weight: 700; font-size: 1.02rem;
  padding: 4px 10px 2px; border-radius: 6px; border: 2px solid var(--ink);
  min-width: 60px; text-align: center; line-height: 1.15; background: #fff;
}
.plate small { display: block; font-size: 0.52rem; font-weight: 700; letter-spacing: 0.1em; }
.plate.sell { background: var(--plate-yellow); }
.star { font-size: 1.25rem; line-height: 1; background: none; border: 0; cursor: pointer; color: #d4d9de; padding: 2px 4px; }
.star.on { color: var(--plate-yellow); text-shadow: 0 0 1px var(--ink); }
.star:hover { color: var(--plate-yellow); }

.more { font: inherit; font-weight: 700; color: #fff; background: var(--blue); border: 0; border-radius: 8px; padding: 12px 28px; cursor: pointer; }
.more:hover { background: #1d4fa0; }
.load-more-wrap { text-align: center; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 44px 20px; text-align: center; color: var(--muted); }

.glossary { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.glossary h2 { margin: 0 0 8px; font-size: 1rem; font-weight: 800; color: var(--blue); }
.glossary dt { font-weight: 800; font-size: 0.88rem; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; font-size: 0.86rem; color: #363d43; }

footer { margin-top: 30px; font-size: 0.72rem; color: var(--muted); max-width: 90ch; }

/* modal + gauges + tiles */
.modal { position: fixed; inset: 0; background: rgba(13, 17, 22, 0.6); display: flex; align-items: flex-start; justify-content: center; padding: 44px 16px; overflow-y: auto; z-index: 50; backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border-radius: 14px; border-top: 5px solid var(--plate-yellow); max-width: 780px; width: 100%; padding: 26px 28px; position: relative; box-shadow: 0 24px 60px -20px rgba(10, 20, 35, 0.55); }
.modal-card h2 { margin: 0 40px 4px 0; font-size: 1.3rem; font-weight: 900; }
.modal-card h3 { font-size: 0.95rem; margin: 0; }
.modal-close { position: absolute; top: 10px; right: 14px; font-size: 1.6rem; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--ink); }
.gaugehead { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; }
.gaugehead h3 { display: flex; flex-direction: column; }
.gaugehead h3 small { font-weight: 600; color: var(--muted); font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase; }
.breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.breakdown ul { list-style: none; margin: 0; padding: 0; }
.breakdown li { display: grid; grid-template-columns: 1fr 66px 32px; align-items: center; gap: 8px; font-size: 0.83rem; padding: 5px 0; border-bottom: 1px solid var(--ground); }
.breakdown li b { font-family: "Overpass Mono", monospace; color: var(--green); white-space: nowrap; }
.plabel { font-size: 0.83rem; }
.pbar { height: 6px; background: var(--ground); border-radius: 99px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.donut-num { font-family: "Overpass Mono", monospace; font-weight: 700; font-size: 1.35rem; fill: var(--ink); }
.donut-sub { font-family: "Overpass", sans-serif; font-weight: 800; font-size: 0.5rem; letter-spacing: 0.1em; fill: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .donut-arc { transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
  .modal .donut-arc { animation: sweep 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
  @keyframes sweep { from { stroke-dashoffset: 300; } }
  .pbar i { animation: grow 0.5s ease-out; } @keyframes grow { from { width: 0 !important; } }
}
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.tile { background: var(--ground); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-family: "Overpass Mono", monospace; font-size: 1.1rem; }
.tile b i { font-style: normal; font-size: 0.7em; color: var(--muted); }
.tile span { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tile.filed { border-left: 3px solid var(--green); }
.tile.est { border-left: 3px solid var(--amber); }
.tile.est b::after { content: " est."; font-size: 0.6em; color: var(--amber); font-family: "Overpass", sans-serif; }
.modal-links { font-size: 0.84rem; margin-top: 16px; }
.modal-links a { color: var(--blue); font-weight: 700; }

/* ================= RESPONSIVE ================= */
@media (max-width: 960px) { .overview { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 40; width: min(320px, 88vw); height: 100vh; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: 24px 0 60px -30px rgba(0,0,0,0.5); }
  .rail.open { transform: translateX(0); }
  .railtoggle {
    display: inline-block; font: inherit; font-weight: 800; font-size: 0.82rem;
    background: var(--ink); color: var(--plate-yellow); border: 0; border-radius: 8px;
    padding: 10px 16px; margin-bottom: 14px; cursor: pointer;
  }
  .work { padding: 16px 14px 40px; }
}
@media (max-width: 560px) { .overview { grid-template-columns: repeat(2, 1fr); } .tiles { grid-template-columns: repeat(2, 1fr); } .row { grid-template-columns: 1fr; } .plates { order: -1; } }
