/* ==========================================================================
   Components — panels, controls, cards, tables, charts, feeds

   Two rules govern colour here, and they are worth stating because every
   decision below follows from them:

   TEAL is the colour of the system working — active states, primary actions,
   live routes, anything the software is doing on your behalf.

   GOLD is the colour of significance — an optimised result, the winning
   number in a comparison, the selected thing. It is deliberately rare. If
   every card had a gold edge, gold would mean nothing.

   Everything else is white, hairline borders and deep navy type.
   ========================================================================== */

/* ----------------------------------------------------------------- panel */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.panel + .panel { margin-top: 0; }

.panel-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-3) 9px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.panel-head h2, .panel-head h3 {
  margin: 0; font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: .13em;
  text-transform: uppercase; color: var(--text-dim);
  white-space: nowrap;
  /* The title keeps its width; the subtitle is what gives way when the
     header is tight, because the identifier is the part you must read. */
  flex: 0 0 auto;
}
.panel-head .eyebrow {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; flex: 0 1 auto;
}
.panel-head .spacer { flex: 1; }
.panel-body { padding: var(--sp-3); }
.panel-body.tight { padding: var(--sp-2); }
.panel-body.flush { padding: 0; }

.panel--accent { border-color: var(--teal-soft); }
.panel--accent .panel-head { background: var(--teal-wash); }
.panel--warn { border-color: var(--gold-soft); }
.panel--warn .panel-head { background: var(--gold-wash); }
.panel--danger { border-color: var(--danger-soft); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 500;
  box-shadow: var(--shadow-1);
  transition: background var(--dur-1), border-color var(--dur-1),
              color var(--dur-1), transform var(--dur-1), box-shadow var(--dur-1);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn svg { width: 13px; height: 13px; flex: none; }

.btn--primary {
  background: var(--teal);
  border-color: var(--teal-deep);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(7, 99, 106, .24), 0 4px 12px rgba(7, 99, 106, .16);
}
.btn--primary:hover:not(:disabled) { background: var(--teal-deep); border-color: var(--teal-dark); color: #ffffff; }
.btn--info { border-color: var(--teal-soft); color: var(--teal-deep); background: var(--teal-wash); box-shadow: none; }
.btn--info:hover:not(:disabled) { background: var(--teal-soft); color: var(--teal-dark); border-color: var(--teal); }
.btn--danger { border-color: var(--danger-soft); color: var(--danger); background: var(--danger-soft); box-shadow: none; }
.btn--danger:hover:not(:disabled) { background: #f3d2cf; border-color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn--sm { padding: 4px 9px; font-size: 9.5px; }
.btn--block { width: 100%; }
.btn--lg { padding: 11px 20px; font-size: 12px; letter-spacing: .14em; }

/* The headline control. It has to look like the most important thing here —
   and because it produces the optimised plan, it is the one place gold is
   allowed to sit next to teal at full strength. */
.btn-optimize {
  position: relative;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--teal-dark);
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 58%, var(--teal-dark) 100%);
  color: #ffffff;
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18),
              0 2px 6px rgba(4, 67, 75, .22),
              0 10px 28px rgba(4, 67, 75, .18);
  overflow: hidden;
  transition: transform var(--dur-1), box-shadow var(--dur-2), filter var(--dur-2);
}
/* A single gold hairline across the top edge: the mark of the thing that
   produces the result, not a decorative glow. */
.btn-optimize::before {
  content: ''; position: absolute; left: 14px; right: 14px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  opacity: .85;
}
.btn-optimize:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22),
              0 3px 8px rgba(4, 67, 75, .26),
              0 16px 38px rgba(4, 67, 75, .22);
}
.btn-optimize:active:not(:disabled) { transform: translateY(1px); }
.btn-optimize:disabled { cursor: progress; filter: saturate(.85); }
.btn-optimize::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .22), transparent);
  transform: translateX(-100%);
}
.btn-optimize:disabled::after { animation: sweep 1.25s linear infinite; }
@keyframes sweep { to { transform: translateX(100%); } }

.btn-optimize .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ segmented */

.segmented {
  display: flex; gap: 2px; padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.segmented button {
  flex: 1;
  padding: 5px 8px;
  border-radius: 5px;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  transition: background var(--dur-1), color var(--dur-1), box-shadow var(--dur-1);
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); background: rgba(255, 255, 255, .7); }
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--teal-deep);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--teal-soft);
}

/* -------------------------------------------------------------- sliders */

.objective {
  display: grid;
  grid-template-columns: 76px 1fr 38px;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px 0;
}
.objective .name {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.objective .val {
  font-family: var(--font-mono); font-size: 11px; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--ink);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 99px;
  background: linear-gradient(90deg, var(--track-color, var(--teal)) var(--fill, 0%), var(--line) var(--fill, 0%));
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 99px; background: var(--line);
}
input[type="range"]::-moz-range-progress {
  height: 3px; border-radius: 99px; background: var(--track-color, var(--teal));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -5.5px;
  border-radius: 99px;
  background: var(--surface);
  border: 3px solid var(--track-color, var(--teal));
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-1), box-shadow var(--dur-1);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 99px;
  background: var(--surface);
  border: 3px solid var(--track-color, var(--teal));
  box-shadow: var(--shadow-1);
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.14); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring-teal); }

/* ---------------------------------------------------------------- toggle */

.layer-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 5px 7px; border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--dur-1);
}
.layer-row:hover { background: var(--surface-2); }
.layer-row input { position: absolute; opacity: 0; pointer-events: none; }
.layer-row .box {
  width: 14px; height: 14px; flex: none;
  border-radius: 4px; border: 1px solid var(--line-strong);
  background: var(--surface);
  display: grid; place-items: center;
  transition: background var(--dur-1), border-color var(--dur-1);
}
.layer-row .box svg { width: 9px; height: 9px; opacity: 0; transition: opacity var(--dur-1); }
.layer-row input:checked + .box { background: var(--teal); border-color: var(--teal-deep); }
.layer-row input:checked + .box svg { opacity: 1; color: #ffffff; }
.layer-row input:focus-visible + .box { outline: 2px solid var(--teal); outline-offset: 2px; }
.layer-row .txt { font-size: 11.5px; color: var(--text-dim); }
.layer-row .swatch { width: 3px; height: 14px; border-radius: 99px; margin-left: auto; }

/* ----------------------------------------------------------------- chips */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip .dot { width: 5px; height: 5px; border-radius: 99px; background: currentColor; }
.chip--green  { color: var(--success);   border-color: #bfe4d6; background: var(--success-soft); }
.chip--cyan   { color: var(--teal-deep); border-color: var(--teal-soft); background: var(--teal-wash); }
.chip--amber  { color: var(--gold-deep); border-color: #e8d6ab; background: var(--gold-wash); }
.chip--orange { color: var(--copper);    border-color: #ecd3b8; background: #fbf1e6; }
.chip--red    { color: var(--danger);    border-color: #eec7c3; background: var(--danger-soft); }
.chip--violet { color: var(--teal-dark); border-color: #bcd4d6; background: #e5f0f1; }
.chip--gold   { color: var(--gold-deep); border-color: var(--gold); background: var(--gold-wash); }

/* ---------------------------------------------------------- vehicle card */

.fleet-list { display: flex; flex-direction: column; gap: 6px; }

.vcard {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 3px 1fr auto;
  gap: 9px;
  transition: border-color var(--dur-1), background var(--dur-1),
              box-shadow var(--dur-1), transform var(--dur-1);
  position: relative;
  overflow: hidden;
}
.vcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
/* Selection is gold: the one vehicle you are looking at, out of many. */
.vcard[aria-current="true"] {
  border-color: var(--gold);
  background: var(--gold-wash);
  box-shadow: var(--ring-gold);
}
.vcard .bar { border-radius: 99px; background: var(--vc, var(--teal)); }
.vcard .main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vcard .row1 { display: flex; align-items: center; gap: 7px; }
.vcard .row1 .chip { flex: none; }
.vcard .cs {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: .06em; color: var(--ink);
}
.vcard .type { font-size: 9.5px; color: var(--faint); font-family: var(--font-mono); letter-spacing: .06em; }
.vcard .row2 { display: flex; gap: 10px; font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); }
.vcard .row2 b { color: var(--text-dim); font-weight: 500; }
.vcard .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; justify-content: center; }
.vcard .eta { font-family: var(--font-mono); font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.vcard .eta small { font-size: 8.5px; color: var(--faint); letter-spacing: .1em; display: block; text-align: right; }

.meter {
  height: 3px; border-radius: 99px; background: var(--surface-3);
  overflow: hidden; width: 100%;
}
.meter > i {
  display: block; height: 100%; border-radius: 99px;
  background: var(--meter-color, var(--teal));
  transition: width var(--dur-3) var(--ease-out);
}
.meter-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.meter-label {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .08em;
  color: var(--faint); margin-bottom: 2px;
}

/* ------------------------------------------------------------- key/value */

.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px var(--sp-3); }
.kv dt {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .07em;
  color: var(--muted); text-transform: uppercase;
  align-self: center;
}
.kv dd {
  margin: 0; text-align: right;
  font-family: var(--font-mono); font-size: 12px;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.kv dd small { font-size: 9.5px; color: var(--faint); }
.kv--rows { grid-template-columns: 1fr auto; }
.kv-divider { grid-column: 1 / -1; height: 1px; background: var(--line-soft); margin: 5px 0; }

/* ---------------------------------------------------------------- tables */

.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tbl th {
  text-align: left;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 8px 9px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td {
  padding: 7px 9px; border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.tbl tbody tr { transition: background var(--dur-1); }
.tbl tbody tr:hover { background: var(--teal-wash); }
.tbl tbody tr[aria-selected="true"] { background: var(--gold-wash); box-shadow: inset 2px 0 0 var(--gold); }
/* The winning number in a comparison — this is exactly what gold is for. */
.tbl td.best { color: var(--gold-deep); font-weight: 600; }
.tbl td.best::after { content: ' \25c6'; font-size: 7px; vertical-align: middle; color: var(--gold); }
.tbl .name { color: var(--ink); font-family: var(--font-sans); }

/* ------------------------------------------------------------- explainer */

.explain {
  border-left: 2px solid var(--teal);
  padding: var(--sp-3);
  background: linear-gradient(90deg, var(--teal-wash), transparent 78%);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.explain p { margin: 0 0 6px; font-size: 12.5px; line-height: 1.6; color: var(--text-dim); }
.explain p:last-child { margin-bottom: 0; }
.explain .why-title {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--teal-deep); margin-bottom: 6px;
}

.drivers { display: flex; flex-direction: column; gap: 4px; margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.drivers li {
  display: grid; grid-template-columns: 12px 1fr; gap: 8px;
  font-size: 12px; line-height: 1.45;
}
.drivers .sign {
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; line-height: 1.3;
}
.drivers li[data-sign="+"] .sign { color: var(--success); }
.drivers li[data-sign="-"] .sign { color: var(--copper); }
.drivers .d-label { color: var(--ink); }
.drivers .d-detail { display: block; color: var(--muted); font-size: 10.5px; font-family: var(--font-mono); }

.basis {
  margin-top: var(--sp-3); padding-top: var(--sp-2);
  border-top: 1px dashed var(--line-strong);
  font-size: 10px; color: var(--faint); line-height: 1.5;
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------- deltas */

.delta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
}
.delta-cell { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.delta-cell .k { font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.delta-cell .vals { display: flex; align-items: baseline; gap: 7px; font-family: var(--font-mono); }
.delta-cell .before { font-size: 11px; color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.delta-cell .after { font-size: 15px; font-weight: 600; color: var(--ink); }
.delta-cell .chg { font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; }
.delta-cell[data-dir="good"] .chg { color: var(--success); }
.delta-cell[data-dir="bad"] .chg { color: var(--danger); }
.delta-cell[data-dir="flat"] .chg { color: var(--faint); }
.delta-bar { height: 2px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 3px; }
.delta-bar > i { display: block; height: 100%; }
.delta-cell[data-dir="good"] .delta-bar > i { background: var(--success); }
.delta-cell[data-dir="bad"] .delta-bar > i { background: var(--danger); }

/* ------------------------------------------------------------ event feed */

.feed { display: flex; flex-direction: column; }
.feed-item {
  display: grid; grid-template-columns: 62px 10px 1fr;
  gap: var(--sp-2);
  padding: 5px 0;
  font-size: 11.5px;
  border-left: 1px solid transparent;
  animation: feed-in var(--dur-3) var(--ease-out);
}
@keyframes feed-in { from { opacity: 0; transform: translateX(-6px); } }
.feed-item .t { font-family: var(--font-mono); font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.feed-item .m { color: var(--text-dim); line-height: 1.45; }
.feed-item .g {
  width: 7px; height: 7px; border-radius: 99px; margin-top: 5px;
  background: var(--line-strong); position: relative;
}
.feed-item .g::after {
  content: ''; position: absolute; left: 3px; top: 9px; bottom: -12px;
  width: 1px; background: var(--line);
}
.feed-item:last-child .g::after { display: none; }
.feed-item[data-kind="optimize"] .g { background: var(--teal); }
.feed-item[data-kind="plan"] .g { background: var(--gold); }
.feed-item[data-kind="detect"] .g { background: var(--copper); }
.feed-item[data-kind="exception"] .g { background: var(--danger); }
.feed-item[data-kind="delivery"] .g { background: var(--success); }
.feed-item[data-kind="scenario"] .g { background: var(--teal-dark); }
.feed-item[data-kind="error"] .g { background: var(--danger); }

/* --------------------------------------------------------------- alerts */

.alert-list { display: flex; flex-direction: column; gap: 5px; }
.alert {
  width: 100%; text-align: left;
  display: grid; grid-template-columns: 3px 1fr auto; gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-1);
}
.alert:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.alert .sev { border-radius: 99px; }
.alert[data-sev="high"] { border-color: #eec7c3; background: #fdf7f6; }
.alert[data-sev="high"] .sev { background: var(--danger); }
.alert[data-sev="medium"] .sev { background: var(--gold); }
.alert[data-sev="low"] .sev { background: var(--teal); }
.alert .title { display: block; font-size: 12px; color: var(--ink); line-height: 1.35; }
.alert .detail { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.alert .sev-tag {
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .12em;
  color: var(--faint); align-self: flex-start;
}
.alert[data-sev="high"] .sev-tag { color: var(--danger); }
.alert[data-sev="medium"] .sev-tag { color: var(--gold-deep); }

/* ------------------------------------------------------------- progress */

.progress {
  height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden;
}
.progress > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-bright));
  transition: width 120ms linear;
}
.progress-label {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em;
  color: var(--muted); margin-bottom: 4px; text-transform: uppercase;
}

/* ---------------------------------------------------------------- charts */

.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { display: block; width: 100%; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .07em;
  color: var(--muted); margin-top: var(--sp-2);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: block; }

.bar-rows { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 116px 1fr 74px; gap: var(--sp-2); align-items: center; }
.bar-row .bl { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bl small { display: block; font-size: 9px; color: var(--faint); font-family: var(--font-mono); }
.bar-row .bt {
  height: 14px; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--line-soft); overflow: hidden;
}
.bar-row .bt > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-bright));
  transition: width var(--dur-3) var(--ease-out);
}
.bar-row .bv { font-family: var(--font-mono); font-size: 11px; text-align: right; color: var(--ink); }

/* --------------------------------------------------------------- scatter */

.scatter-tip {
  position: absolute; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 7px 9px;
  font-family: var(--font-mono); font-size: 10px; line-height: 1.5;
  box-shadow: var(--shadow-3); z-index: 5;
  white-space: nowrap; color: var(--text-dim);
}
.scatter-tip b { color: var(--gold-deep); }

/* ------------------------------------------------------------- scenario */

.sc-group { display: flex; flex-direction: column; gap: 7px; }
.sc-group + .sc-group { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line-soft); }
.sc-title {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 7px;
}
.sc-title .n {
  width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center;
  background: var(--teal-wash); color: var(--teal-deep); font-size: 9px;
}

.staged {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: var(--sp-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  min-height: 38px;
  align-items: center;
}
.staged:empty::after {
  content: 'No changes staged';
  font-family: var(--font-mono); font-size: 10px; color: var(--faint); letter-spacing: .08em;
}

/* --------------------------------------------------------------- replan */

.replan-stages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.replan-stage {
  flex: 1; min-width: 92px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
  transition: color var(--dur-2), border-color var(--dur-2), background var(--dur-2);
  text-align: center;
}
.replan-stage[data-state="active"] {
  color: var(--teal-deep); border-color: var(--teal); background: var(--teal-wash);
}
.replan-stage[data-state="done"] { color: var(--success); border-color: #bfe4d6; background: var(--success-soft); }

/* ---------------------------------------------------------------- misc */

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4);
  text-align: center; color: var(--muted);
}
.empty-state svg { width: 26px; height: 26px; opacity: .45; color: var(--teal); }
.empty-state p { margin: 0; font-size: 12.5px; max-width: 42ch; line-height: 1.6; }
.empty-state .hint { font-size: 10.5px; font-family: var(--font-mono); color: var(--faint); }

.hr { height: 1px; background: var(--line-soft); margin: var(--sp-3) 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-3); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }

/* ---------------------------------------------------------------- toast */

.toast-stack {
  position: fixed; bottom: var(--sp-4); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 300;
  pointer-events: none; align-items: center;
}
.toast {
  pointer-events: auto;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: 10px 16px;
  box-shadow: var(--shadow-3);
  font-size: 12px; color: var(--ink);
  display: flex; align-items: center; gap: 9px;
  animation: toast-in var(--dur-3) var(--ease-out);
  max-width: min(520px, 92vw);
}
.toast[data-tone="good"] { border-left: 3px solid var(--success); }
.toast[data-tone="bad"] { border-left: 3px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------------- tooltip */

.map-tip {
  position: absolute; z-index: 6;
  pointer-events: none;
  background: var(--glass); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  box-shadow: var(--shadow-map);
  font-size: 11.5px; line-height: 1.45;
  max-width: 240px;
}
.map-tip .tt { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; color: var(--teal-deep); text-transform: uppercase; }
.map-tip .tm { color: var(--ink); margin-top: 2px; }
.map-tip .ts { color: var(--muted); font-family: var(--font-mono); font-size: 10px; margin-top: 3px; }

/* --------------------------------------------------- keyboard help sheet */

dialog.sheet {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-lg);
  padding: 0;
  max-width: 560px; width: calc(100vw - 32px);
  box-shadow: var(--shadow-3);
}
dialog.sheet::backdrop { background: rgba(14, 34, 48, .34); backdrop-filter: blur(3px); }
dialog.sheet .panel-body { max-height: 70vh; overflow: auto; }

kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; color: var(--text-dim);
  min-width: 20px; display: inline-block; text-align: center;
}

.key-rows { display: grid; grid-template-columns: auto 1fr; gap: 7px var(--sp-4); align-items: center; }
.key-rows .d { font-size: 12px; color: var(--text-dim); }

/* ==========================================================================
   Forms, tables and page furniture
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .11em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 4px;
}
.field-label .req { color: var(--danger); }
.field-hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.form-grid { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 720px; }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); }

.input {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 12.5px;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.input:hover { border-color: var(--muted); }
.input:focus { border-color: var(--teal); outline: none; box-shadow: var(--ring-teal); }
.input::placeholder { color: var(--faint); }
.input--num { font-family: var(--font-mono); }
.input--inline { width: auto; min-width: 150px; padding: 6px 9px; font-size: 11.5px; }
select.input { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 28px;
}
input[type="time"].input { font-family: var(--font-mono); }

.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix .suffix {
  position: absolute; right: 11px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--faint);
  pointer-events: none;
}
.input-suffix .input { padding-right: 40px; }

/* ------------------------------------------------------ location picker */

.lookup { display: flex; flex-direction: column; gap: 6px; position: relative; }
.lookup-row { display: flex; gap: var(--sp-2); align-items: stretch; }
.lookup-row .input { flex: 1; min-width: 0; }
.lookup-row .btn { flex: none; }

.lookup-results {
  position: absolute; top: 42px; left: 0; right: 0; z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  max-height: 260px; overflow-y: auto;
}
.lookup-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--dur-1);
}
.lookup-item:last-child { border-bottom: none; }
.lookup-item:hover, .lookup-item:focus-visible { background: var(--teal-wash); }
.lookup-title { display: block; font-size: 12.5px; color: var(--ink); }
.lookup-sub { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-empty { padding: 10px 12px; font-size: 11.5px; color: var(--muted); }

.lookup-chosen {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px 8px 12px;
  border: 1px solid var(--teal-soft);
  background: var(--teal-wash);
  border-radius: var(--r-sm);
}
.lookup-chosen > span:first-child { color: var(--teal); display: flex; flex: none; }
.lookup-chosen-text { min-width: 0; flex: 1; }
.lookup-chosen-text strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-chosen-text small { display: block; font-size: 10px; color: var(--muted); font-family: var(--font-mono); }

/* ------------------------------------------------------------- tiles */

.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--sp-2); }
.stat-tile {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-value {
  font-family: var(--font-mono); font-size: 21px; font-weight: 600;
  display: flex; align-items: baseline; gap: 4px; color: var(--ink);
  letter-spacing: -.02em;
}
.stat-value small { font-size: 10.5px; font-weight: 500; color: var(--muted); }
.stat-label {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
}
.stat-tile[data-tone="green"] .stat-value { color: var(--success); }
.stat-tile[data-tone="amber"] .stat-value { color: var(--gold-deep); }
.stat-tile[data-tone="red"] .stat-value { color: var(--danger); }
.stat-tile[data-tone="red"] { border-color: #eec7c3; }
/* The headline figure of a result — gold, and only where it is earned. */
.stat-tile[data-tone="gold"] { border-color: var(--gold-soft); background: var(--gold-wash); }
.stat-tile[data-tone="gold"] .stat-value { color: var(--gold-deep); }

/* ------------------------------------------------------------ notices */

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--teal-soft);
  background: var(--teal-wash);
  border-radius: var(--r-md);
}
.notice > span:first-child { color: var(--teal); flex: none; margin-top: 1px; display: flex; }
.notice p { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--text-dim); }
.notice--bad { border-color: #eec7c3; background: var(--danger-soft); }
.notice--bad > span:first-child { color: var(--danger); }
.notice--gold { border-color: var(--gold-soft); background: var(--gold-wash); }
.notice--gold > span:first-child { color: var(--gold); }

/* ------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table-wrap .tbl th { background: var(--surface-2); }
.th-sort {
  color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
  padding: 0; cursor: pointer;
}
.th-sort:hover { color: var(--teal-deep); }

.row-lead { display: flex; align-items: center; gap: 8px; }
.row-swatch { width: 3px; height: 22px; border-radius: 99px; flex: none; display: block; }
.row-lead strong { display: block; font-size: 12px; color: var(--ink); }
.row-lead small { display: block; font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }

.meter-cell { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; min-width: 56px; }
.meter-cell .meter { width: 52px; }

/* --------------------------------------------------------- mini rows */

.mini-row {
  display: grid; grid-template-columns: 3px 1fr; gap: 9px; align-items: center;
  width: 100%; text-align: left;
  padding: 7px 9px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-1);
}
.mini-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.mini-row[aria-current="true"] { border-color: var(--gold); background: var(--gold-wash); }
.mini-bar { align-self: stretch; border-radius: 99px; }
.mini-text { min-width: 0; }
.mini-text strong { display: block; font-size: 11.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-text small { display: block; font-size: 10px; color: var(--muted); font-family: var(--font-mono); }

/* ------------------------------------------------------ provider grid */

.provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-2); }
.provider {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-1);
}
.provider:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.provider[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-wash); box-shadow: var(--ring-teal); }
.provider-swatch {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, #16202c, #253546);
}
.provider-swatch[data-theme="light"] { background: linear-gradient(135deg, #f7f9f9, #dde5e6); }
/* The satellite swatch reads as terrain rather than as a colour chip. */
.provider-swatch[data-theme="imagery"] {
  background:
    radial-gradient(60% 50% at 25% 30%, #4b6b45 0%, transparent 70%),
    radial-gradient(50% 60% at 78% 68%, #7d7350 0%, transparent 72%),
    linear-gradient(140deg, #2f4b57, #1d3b45);
}
.provider strong { display: block; font-size: 12px; color: var(--ink); }
.provider small { display: block; font-size: 9.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

/* ------------------------------------------------------ date and time */

.datetime { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.datetime .row { gap: 6px; }
.input--date { flex: 1 1 58%; min-width: 0; font-family: var(--font-mono); font-size: 12px; }
.input--time { flex: 0 0 auto; width: 104px; font-family: var(--font-mono); }
/* The day counter is the point of the control, so it is not a whisper. */
.day-note {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em;
  color: var(--teal-deep);
}

/* ---------------------------------------------------------- skeletons */

/*
 * Placeholders shaped like the answer, so the layout does not jump when the
 * real content lands. The shimmer is slow and low-contrast on purpose: it
 * should read as "working", not as a thing demanding attention.
 */
.sk {
  display: block;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
  background-size: 300% 100%;
  animation: sk-sweep 1.6s var(--ease-in-out) infinite;
  animation-delay: var(--skeleton-delay, 0ms);
}
@keyframes sk-sweep { from { background-position: 140% 0; } to { background-position: -40% 0; } }

.sk-title  { width: 42%; height: 13px; }
.sk-pill   { width: 64px; height: 13px; border-radius: var(--r-pill); }
.sk-line   { width: 68%; height: 9px; margin-top: 2px; }
.sk-metric { height: 26px; }

.route-option.is-skeleton { pointer-events: none; box-shadow: none; }
.route-option.is-skeleton .ro-metrics { margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  /* No shimmer, but the shapes still hold the layout open. */
  .sk { animation: none; background: var(--surface-2); }
}

/* A long title plus a chip must wrap rather than push the chip off the edge. */
.panel-head { flex-wrap: wrap; row-gap: 4px; }
.panel-head h2, .panel-head h3 { white-space: normal; }

/* In a narrow rail a stat tile gets two lines, not a broken word. */
.stat-value { flex-wrap: wrap; row-gap: 0; }
.stat-value small { white-space: nowrap; }
