/* ═══════════════════════════════════════════════════════════════════════
   Quilla Fleet — hoja de estilo única.
   Tokens en :root son el ÚNICO sitio con valores de color literales.
   Ver DESIGN.md.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* superficies y texto */
  --bg:        oklch(0.185 0.028 248);
  --surface:   oklch(0.232 0.030 248);
  --surface-2: oklch(0.285 0.030 248);
  --fg:        oklch(0.965 0.007 247);
  --muted:     oklch(0.735 0.020 247);
  --border:    oklch(0.335 0.026 248);

  /* acento único + estados reservados
     Luminosidades elegidas para que el texto de estado alcance 4.5:1
     sobre --bg y 3:1 como marca gráfica sobre --surface. */
  --accent: oklch(0.795 0.115 190);
  --amber:  oklch(0.805 0.145 78);
  --danger: oklch(0.720 0.150 25);
  --ok:     oklch(0.775 0.135 158);

  /* series de datos — validadas para superficie oscura */
  --data-1: oklch(0.658 0.112 188);
  --data-2: oklch(0.632 0.157 265);
  --data-3: oklch(0.652 0.137 343);

  /* derivados */
  --accent-soft: color-mix(in oklch, var(--accent) 16%, transparent);
  --amber-soft:  color-mix(in oklch, var(--amber) 16%, transparent);
  --danger-soft: color-mix(in oklch, var(--danger) 18%, transparent);
  --ok-soft:     color-mix(in oklch, var(--ok) 16%, transparent);
  --fg-soft:     color-mix(in oklch, var(--fg) 7%, transparent);

  /* tipografía */
  --font-display: 'Iowan Old Style', 'Charter', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --fs-h1: clamp(28px, 2.6vw, 38px);
  --fs-h2: clamp(21px, 1.7vw, 26px);
  --fs-h3: 16px;
  --fs-body: 15px;
  --fs-meta: 13px;

  /* rejilla de 8 */
  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 20px;
  --gap-lg: 32px;
  --gap-xl: 56px;
  --radius: 10px;
  --radius-lg: 16px;

  --rail: 244px;
  --topbar: 60px;
  --dur: 150ms;
}

/* ─── reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--bg);
  padding: 10px 16px; border-radius: var(--radius); font-weight: 600;
  transition: top var(--dur) ease;
}
.skip-link:focus { top: 12px; }

/* ─── tipografía ─────────────────────────────────────────────────────── */
.h1, h1 { font-family: var(--font-display); font-size: var(--fs-h1); line-height: 1.1; letter-spacing: -0.02em; font-weight: 600; }
.h2, h2 { font-family: var(--font-display); font-size: var(--fs-h2); line-height: 1.2; letter-spacing: -0.015em; font-weight: 600; }
.h3, h3 { font-size: var(--fs-h3); font-weight: 600; line-height: 1.35; }
.lead { font-size: 15px; color: var(--muted); max-width: 62ch; }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.eyebrow-accent { color: var(--accent); }
.meta { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

/* ─── shell ──────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 30;
}
.rail-head { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; flex: none; color: var(--accent); }
.brand-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.rail-nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.rail-group { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.navlink {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 10px; border-radius: var(--radius);
  border-left: 2px solid transparent;
  color: var(--fg); font-size: 14px; text-align: left;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.navlink svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.navlink:hover { background: var(--surface-2); }
.navlink[aria-current="page"] {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}
.navlink[aria-current="page"] svg { color: var(--accent); }
.navlink .badge-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: var(--amber-soft); color: var(--amber);
  padding: 1px 7px; border-radius: 999px;
}
.rail-foot { padding: 14px 18px; border-top: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px;
}

/* ─── topbar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--gap-md);
  min-height: var(--topbar); padding: 10px 24px;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-search { position: relative; flex: 1; max-width: 380px; }
.topbar-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.topbar-search .input { padding-left: 34px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--gap-xs); }
.demo-flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--amber);
  background: var(--amber-soft); border: 1px solid color-mix(in oklch, var(--amber) 34%, transparent);
  padding: 4px 10px; border-radius: 999px;
}
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--fg); background: transparent;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--muted); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rail-toggle { display: none; }
.dot-alert { position: relative; }
.dot-alert::after {
  content: ''; position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 999px; background: var(--amber);
  border: 2px solid var(--bg);
}

/* ─── vistas ─────────────────────────────────────────────────────────── */
.view { padding: 24px 24px 64px; }
.view[hidden] { display: none; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--gap-md); flex-wrap: wrap; margin-bottom: var(--gap-md);
}
.view-head .lead { margin-top: 6px; }
.view-actions { display: flex; align-items: center; gap: var(--gap-xs); flex-wrap: wrap; }

/* ─── botones ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 38px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-size: 14px; font-weight: 500; letter-spacing: -0.005em;
  transition: background var(--dur) ease, border-color var(--dur) ease, transform 60ms ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 84%, white); border-color: color-mix(in oklch, var(--accent) 84%, white); color: var(--bg); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted); color: var(--fg); }
.btn-ghost { background: transparent; color: var(--fg); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border); }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

/* ─── superficies ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-pad-0 { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap-sm); padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-body { padding: 18px; }
.rule { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ─── rejillas ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--gap-md); }
.stack { display: flex; flex-direction: column; gap: var(--gap-md); }
.stack-sm { display: flex; flex-direction: column; gap: var(--gap-xs); }
.row { display: flex; align-items: center; gap: var(--gap-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-sm); }
.row-wrap { flex-wrap: wrap; }

/* ─── KPI ────────────────────────────────────────────────────────────── */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.kpi-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-family: var(--font-display); font-size: 34px; line-height: 1.05; letter-spacing: -0.03em; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 0.48em; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.trend { font-family: var(--font-mono); font-size: 12px; display: inline-flex; align-items: center; gap: 3px; }
.trend-up { color: var(--ok); }
.trend-down { color: var(--amber); }

/* ─── chips de estado (color + glifo + texto) ────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.chip::before { content: attr(data-glyph); font-size: 10px; line-height: 1; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in oklch, var(--ok) 32%, transparent); }
.chip-warn { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in oklch, var(--amber) 32%, transparent); }
.chip-crit { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklch, var(--danger) 38%, transparent); }
.chip-idle { background: var(--fg-soft); color: var(--muted); border-color: var(--border); }
.chip-info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklch, var(--accent) 32%, transparent); }
.tag {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 12px; color: var(--muted);
}

/* ─── controles de formulario ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field-label { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; min-height: 38px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); font-size: 14px;
  transition: border-color var(--dur) ease, background var(--dur) ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.field-error { font-size: 13px; color: var(--danger); display: flex; align-items: center; gap: 6px; }
.field-error:empty { display: none; }

/* filtros segmentados */
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); flex-wrap: wrap; }
.segmented button {
  padding: 6px 12px; min-height: 32px; border-radius: 7px;
  font-size: 13px; color: var(--muted);
  transition: background var(--dur) ease, color var(--dur) ease;
}
.segmented button:hover { background: var(--surface-2); color: var(--fg); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ─── tablas ─────────────────────────────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; }
.ds-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ds-table caption { text-align: left; padding: 0 18px 10px; color: var(--muted); font-size: 13px; }
.ds-table th, .ds-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ds-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--muted); font-weight: 500;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
.ds-table tbody tr { transition: background var(--dur) ease; }
.ds-table tbody tr:hover { background: var(--surface-2); }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table .num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ds-table .id-col { font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.ds-table tr[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.empty-row td { color: var(--muted); text-align: center; padding: 32px 14px; }

/* ─── barra de ocupación ─────────────────────────────────────────────── */
.meter { display: block; height: 7px; border-radius: 999px; background: var(--fg-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 250ms ease, background var(--dur) ease; }
.meter.is-warn > span { background: var(--amber); }
.meter.is-over > span { background: var(--danger); }
.meter-row { display: grid; grid-template-columns: 92px minmax(0,1fr) 82px; gap: 10px; align-items: center; font-size: 13px; }
.meter-row .meter-label { color: var(--muted); }
.meter-row .meter-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

/* ─── mapa operativo ─────────────────────────────────────────────────── */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 328px; gap: var(--gap-md); align-items: start; }
.map-frame {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.map-svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.map-zone { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.map-water { fill: color-mix(in oklch, var(--data-2) 16%, var(--bg)); stroke: none; }
.map-green { fill: color-mix(in oklch, var(--ok) 12%, var(--surface-2)); stroke: none; }
.map-road { fill: none; stroke: var(--border); stroke-width: 5; stroke-linecap: round; }
.map-road-minor { fill: none; stroke: var(--border); stroke-width: 2; stroke-linecap: round; opacity: 0.8; }
.map-zone-label { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.map-route { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0.5; transition: opacity var(--dur) ease, stroke-width var(--dur) ease; }
.map-route.is-active { opacity: 1; stroke-width: 4.5; }
.map-route.is-dimmed { opacity: 0.16; }
.map-stop { fill: var(--surface); stroke: var(--fg); stroke-width: 1.5; }
.map-stop-num { fill: var(--fg); font-family: var(--font-mono); font-size: 9px; text-anchor: middle; dominant-baseline: central; }
.map-pin { cursor: pointer; }
.map-pin:focus { outline: none; }
.map-pin:focus-visible .map-pin-ring { stroke: var(--accent); stroke-width: 3; opacity: 1; }
.map-pin-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: 0; transition: opacity var(--dur) ease; }
.map-pin[aria-pressed="true"] .map-pin-ring { opacity: 1; }
.map-pin:hover .map-pin-body { stroke: var(--fg); }
.map-pin-body { stroke-width: 1.5; transition: stroke var(--dur) ease; }
.map-depot { fill: var(--accent); }
.map-legend {
  position: absolute; left: 14px; bottom: 14px;
  display: flex; flex-direction: column; gap: 6px;
  background: color-mix(in oklch, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px;
}
.map-legend-item { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.map-scale { position: absolute; right: 14px; bottom: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.map-scale-bar { width: 54px; height: 1px; background: var(--muted); position: relative; }
.map-scale-bar::before, .map-scale-bar::after { content: ''; position: absolute; width: 1px; height: 6px; background: var(--muted); top: -3px; }
.map-scale-bar::before { left: 0; }
.map-scale-bar::after { right: 0; }

.pulse { transform-box: fill-box; transform-origin: center; animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { opacity: 0.55; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(2.4); } }

.fleet-list { max-height: 420px; overflow-y: auto; }
.fleet-item {
  display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 10px;
  align-items: center; width: 100%; text-align: left;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.fleet-item:hover { background: var(--surface-2); }
.fleet-item[aria-pressed="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
.fleet-item:last-child { border-bottom: 0; }
.fleet-glyph {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px;
}
.fleet-plate { font-family: var(--font-mono); font-size: 13px; }
.fleet-sub { font-size: 12px; color: var(--muted); }

/* ─── planificador ───────────────────────────────────────────────────── */
.planner { display: grid; grid-template-columns: 232px minmax(0,1fr) 312px; gap: var(--gap-md); align-items: start; }
.route-item {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.route-item:hover { background: var(--surface-2); }
.route-item[aria-current="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
.route-item:last-child { border-bottom: 0; }

.stop-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.stop {
  display: grid;
  grid-template-columns: 30px minmax(0,1fr) auto auto;
  gap: 12px; align-items: center;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur) ease, background var(--dur) ease, transform var(--dur) ease;
}
.stop:hover { border-color: var(--muted); }
.stop.is-grabbed { border-color: var(--accent); background: var(--surface-2); box-shadow: 0 0 0 1px var(--accent); }
.stop.is-dragging { opacity: 0.5; }
.stop.is-drop-target { border-color: var(--accent); border-style: dashed; }
.stop.just-moved { background: var(--accent-soft); }
.stop-seq {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums;
}
.stop.is-anchor .stop-seq { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.stop-name { font-size: 14px; font-weight: 500; }
.stop-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.stop-window { font-family: var(--font-mono); font-size: 12px; text-align: right; white-space: nowrap; }
.stop-eta { display: block; color: var(--muted); font-size: 11px; }
.stop-eta.is-late { color: var(--amber); }
.stop-handle {
  display: flex; align-items: center; gap: 2px;
}
.stop-move {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; color: var(--muted);
  transition: background var(--dur) ease, color var(--dur) ease;
}
.stop-move svg { width: 14px; height: 14px; }
.stop-move:hover { background: var(--surface-2); color: var(--fg); }
.stop-move:disabled { opacity: 0.35; cursor: not-allowed; }
.stop-move:disabled:hover { background: transparent; color: var(--muted); }
.stop-grip { cursor: grab; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); }
.stop-grip:hover { background: var(--surface-2); color: var(--fg); }
.stop-grip:active { cursor: grabbing; }

.calc-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.calc-line:last-of-type { border-bottom: 0; }
.calc-line dt { color: var(--muted); }
.calc-line dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.calc-total { border-top: 1px solid var(--fg); margin-top: 6px; padding-top: 12px; }
.calc-total dd { font-family: var(--font-display); font-size: 26px; letter-spacing: -0.02em; }
.callout {
  display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius);
  font-size: 13px; line-height: 1.45;
  background: var(--fg-soft); border: 1px solid var(--border);
}
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.callout-warn { background: var(--amber-soft); border-color: color-mix(in oklch, var(--amber) 34%, transparent); color: var(--amber); }
.callout-crit { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 40%, transparent); color: var(--danger); }
.callout-ok { background: var(--ok-soft); border-color: color-mix(in oklch, var(--ok) 32%, transparent); color: var(--ok); }

/* ─── cargas ─────────────────────────────────────────────────────────── */
.load-layout { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: var(--gap-md); align-items: start; }
.ship-item {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center;
  width: 100%; text-align: left; padding: 11px 14px;
  border-bottom: 1px solid var(--border); border-left: 2px solid transparent;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.ship-item:hover { background: var(--surface-2); }
.ship-item[aria-pressed="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
.ship-item:last-child { border-bottom: 0; }
.vehicle-load { display: flex; flex-direction: column; gap: 12px; }
.assigned-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px;
}
.assigned-chip button {
  width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; line-height: 1;
  transition: background var(--dur) ease, color var(--dur) ease;
}
.assigned-chip button:hover { background: var(--danger-soft); color: var(--danger); }

/* ─── incidencias / mantenimiento ────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.tl-row {
  display: grid; grid-template-columns: 84px 18px minmax(0,1fr) auto;
  gap: 14px; align-items: start; padding: 14px 0;
  border-top: 1px solid var(--border);
}
.tl-row:first-child { border-top: 0; }
.tl-dot { width: 10px; height: 10px; border-radius: 999px; margin-top: 6px; background: var(--muted); }
.tl-dot.is-warn { background: var(--amber); }
.tl-dot.is-crit { background: var(--danger); }
.tl-dot.is-ok { background: var(--ok); }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before { content: ''; position: absolute; top: 16px; bottom: -20px; width: 1px; background: var(--border); }
.tl-row:last-child .tl-rail::before { display: none; }

/* ─── gráficos ───────────────────────────────────────────────────────── */
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.chart-value-label { fill: var(--fg); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-target { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chart-mark { transition: opacity var(--dur) ease; }
.chart-crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.legend { display: flex; gap: var(--gap-md); flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 11px;
  font-size: 13px; box-shadow: 0 8px 24px color-mix(in oklch, var(--bg) 70%, transparent);
  min-width: 132px;
}
.chart-tip[hidden] { display: none; }
.chart-tip-title { font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.chart-tip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 5px; }
.chart-tip-row .num { font-size: 13px; }
.chart-wrap { position: relative; }

/* ─── diálogo ────────────────────────────────────────────────────────── */
.dialog {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: color-mix(in oklch, var(--bg) 74%, transparent);
  backdrop-filter: blur(4px);
}
.dialog[hidden] { display: none; }
.dialog-panel {
  width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px color-mix(in oklch, var(--bg) 80%, transparent);
}
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: var(--gap-sm); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--gap-xs); padding: 14px 20px; border-top: 1px solid var(--border); }

/* ─── toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 70; display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 18px; font-size: 14px;
  box-shadow: 0 12px 32px color-mix(in oklch, var(--bg) 76%, transparent);
}
.toast[hidden] { display: none; }
.toast svg { width: 16px; height: 16px; color: var(--accent); }

/* ─── pie ────────────────────────────────────────────────────────────── */
.pagefoot { padding: 20px 24px 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pagefoot .row-between { flex-wrap: wrap; gap: var(--gap-sm); }

/* ═══ responsive ═════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
  .planner { grid-template-columns: 200px minmax(0,1fr) 280px; }
  .map-layout { grid-template-columns: minmax(0,1fr) 300px; }
}
@media (max-width: 1100px) {
  .planner { grid-template-columns: minmax(0,1fr) 300px; }
  .planner > .planner-routes { grid-column: 1 / -1; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 84vw);
    transform: translateX(-102%);
    transition: transform 220ms ease;
    box-shadow: 0 0 40px color-mix(in oklch, var(--bg) 80%, transparent);
  }
  .rail.is-open { transform: translateX(0); }
  .rail-toggle { display: grid; }
  .rail-scrim { position: fixed; inset: 0; z-index: 25; background: color-mix(in oklch, var(--bg) 70%, transparent); }
  .rail-scrim[hidden] { display: none; }
  .grid-2, .grid-3, .grid-4, .map-layout, .planner, .load-layout { grid-template-columns: minmax(0,1fr); }
  .view { padding: 20px 16px 56px; }
  .topbar { padding: 10px 16px; }
  .topbar-search { max-width: none; }
  .fleet-list { max-height: none; }
  .btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .stop-move, .stop-grip { width: 36px; height: 36px; }
}
@media (max-width: 720px) {
  .topbar-search { order: 3; flex-basis: 100%; }
  .topbar { flex-wrap: wrap; }
  .stop { grid-template-columns: 30px minmax(0,1fr); row-gap: 8px; }
  .stop-window { grid-column: 2; text-align: left; }
  .stop-handle { grid-column: 2; justify-content: flex-start; }
  .tl-row { grid-template-columns: 18px minmax(0,1fr); }
  .tl-row > .tl-date { grid-column: 2; }
  .tl-row > .tl-action { grid-column: 2; }
  .meter-row { grid-template-columns: 76px minmax(0,1fr); }
  .meter-row .meter-val { grid-column: 2; text-align: left; }

  /* tablas a tarjetas apiladas */
  .table-wrap.is-stackable .ds-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-wrap.is-stackable .ds-table,
  .table-wrap.is-stackable .ds-table tbody,
  .table-wrap.is-stackable .ds-table tr,
  .table-wrap.is-stackable .ds-table td { display: block; width: 100%; }
  .table-wrap.is-stackable .ds-table tr {
    border-bottom: 1px solid var(--border); padding: 12px 14px;
  }
  .table-wrap.is-stackable .ds-table td {
    display: grid; grid-template-columns: 40% minmax(0,1fr); gap: 12px;
    border-bottom: 0; padding: 4px 0; text-align: left;
  }
  .table-wrap.is-stackable .ds-table td::before {
    content: attr(data-label);
    font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--muted);
  }
  .table-wrap.is-stackable .ds-table td.num-col { text-align: left; }
}

/* ═══ movimiento reducido ════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .pulse { display: none; }
}

/* ═══ contraste forzado ══════════════════════════════════════════════ */
@media (forced-colors: active) {
  .navlink[aria-current="page"], .chip, .btn { border: 1px solid CanvasText; }
  .meter > span { forced-color-adjust: none; }
}
