/* ============================================
   Rumbo - sistema de diseño en DESIGN.md
   ============================================ */

@font-face {
    font-family: 'Overpass';
    src: url('../assets/fonts/overpass-latin-wght-normal.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Overpass';
    src: url('../assets/fonts/overpass-latin-ext-wght-normal.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;

    --surface:    #FBFBFC;
    --surface-2:  #F0F2F5;
    --line:       #DCE0E6;
    --ink:        #14181F;
    --ink-2:      #495260;
    --ink-3:      #646D7B;
    --accent:     #1F5FD1;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(31, 95, 209, 0.12);
    --shadow:     0 6px 20px rgba(20, 30, 50, 0.14), 0 1px 3px rgba(20, 30, 50, 0.10);
    --shadow-sheet: 0 -8px 28px rgba(20, 30, 50, 0.14);

    --sign-blue:   #1D4F9C;
    --sign-red:    #C4302B;
    --sign-green:  #1F7A45;
    --sign-orange: #D9781E;
    --sign-yellow: #F2C230;
    --sev-danger:  var(--sign-red);
    --sev-warning: var(--sign-orange);
    --sev-caution: #9A7B14;
    --sev-good:    #2F8F5B;
    --fuel-gas:    var(--accent);
    --fuel-diesel: #B7791F;

    --font: 'Overpass', ui-sans-serif, sans-serif;
    --mono: 'Overpass', ui-sans-serif, sans-serif; /* cifras: misma familia, tabulares */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);

    --r-plate: 4px;
    --r-ctl: 12px;
    --r-fab: 14px;
    --r-sheet: 20px;

    --z-fab: 10;
    --z-sheet: 20;
    --z-bar: 30;
    --z-toast: 40;
    --z-dialog: 50;

    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --top-offset: 0px;
    --panel-w: 400px;
}

/* Noche: lo activa js/theme.js entre la puesta de sol y el amanecer */
:root[data-theme="dark"] {
    color-scheme: dark;
    --surface:    #15191F;
    --surface-2:  #1E232B;
    --line:       #2B323C;
    --ink:        #ECEFF3;
    --ink-2:      #AEB5C0;
    --ink-3:      #8C95A2;
    --accent:     #7AA5F2;
    --accent-ink: #0B1424;
    --accent-soft: rgba(122, 165, 242, 0.16);
    --shadow:     0 6px 20px rgba(0, 4, 12, 0.45), 0 1px 3px rgba(0, 4, 12, 0.4);
    --shadow-sheet: 0 -8px 28px rgba(0, 4, 12, 0.5);
    --fuel-diesel: #D49A3C;
}

/* ---------- Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--surface-2);
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }

::selection { background: var(--accent); color: var(--accent-ink); }
input { caret-color: var(--accent); }

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

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: currentColor;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

.num {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.hidden { display: none !important; }

/* ---------- Mapa ---------- */
#map {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--surface-2);
}

/* ---------- Barra superior (modo ruta) ---------- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-bar);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(var(--safe-t) + 10px) 16px 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--r-ctl);
    background: var(--surface-2);
    color: var(--ink);
    transition: transform 160ms var(--ease), background-color 160ms var(--ease);
}
.icon-btn:hover { background: var(--line); }
.icon-btn:active { transform: scale(0.96); }

.top-bar-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.tb-eta {
    font-family: var(--mono);
    font-weight: 800;
    font-size: 28px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}
.tb-detail {
    font-size: 14px;
    color: var(--ink-2);
}
.top-bar-weather {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--r-ctl);
    background: var(--surface-2);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 16px;
}

/* ---------- Cartel de orientación ---------- */
.nav-sign {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(var(--safe-t) + 76px);
    z-index: var(--z-bar);
}
.nav-sign-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    /* filete interior blanco (o negro) de los carteles reales */
    box-shadow: var(--shadow), inset 0 0 0 4px var(--sign-bg), inset 0 0 0 6px var(--sign-fg);
    background: var(--sign-bg);
    color: var(--sign-fg);
}
.sign-blue   { --sign-bg: var(--sign-blue);  --sign-fg: #FFFFFF; }
.sign-white  { --sign-bg: #FBFBFC;           --sign-fg: #14181F; }
.sign-arrive { --sign-bg: var(--sign-green); --sign-fg: #FFFFFF; }

.nav-arrow {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: none;
}
.nav-arrow .icon { width: 40px; height: 40px; }
.nav-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-road:empty { display: none; }
.nav-road { display: flex; }
.nav-instruction {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
}
.nav-distance { display: flex; align-items: baseline; gap: 3px; flex: none; }
.nav-dist-val { font-family: var(--mono); font-weight: 800; font-size: 28px; font-variant-numeric: tabular-nums; }
.nav-dist-unit { font-size: 14px; font-weight: 700; }

/* ---------- Placa de carretera ---------- */
.road-plate {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px 1px;
    border-radius: var(--r-plate);
    font-weight: 800;
    font-size: 13px;
    line-height: 1.35;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--plate-bg);
    color: var(--plate-fg);
    box-shadow: inset 0 0 0 1.5px var(--plate-fg);
}
.plate-blue   { --plate-bg: var(--sign-blue);   --plate-fg: #FFFFFF; }
.plate-red    { --plate-bg: var(--sign-red);    --plate-fg: #FFFFFF; }
.plate-green  { --plate-bg: var(--sign-green);  --plate-fg: #FFFFFF; }
.plate-orange { --plate-bg: var(--sign-orange); --plate-fg: #14181F; }
.plate-yellow { --plate-bg: var(--sign-yellow); --plate-fg: #14181F; }
.plate-plain  { --plate-bg: var(--surface-2);   --plate-fg: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Botones flotantes ---------- */
.map-fabs {
    position: fixed;
    right: 16px;
    top: calc(var(--safe-t) + 16px + var(--top-offset));
    z-index: var(--z-fab);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 240ms var(--ease);
}
.fab {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: var(--r-fab);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.fab:active { transform: scale(0.95); }
.fab[aria-pressed="true"] {
    color: var(--accent);
    box-shadow: var(--shadow), inset 0 0 0 2px var(--accent);
}
.fab-primary {
    background: var(--accent);
    color: var(--accent-ink);
}

/* ---------- Velocímetro ---------- */
.speedometer {
    position: fixed;
    left: 16px;
    top: calc(var(--safe-t) + 16px + var(--top-offset));
    z-index: var(--z-fab);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    box-shadow: var(--shadow), inset 0 0 0 4px var(--speed-ring, var(--line));
}
.speedometer.warn { --speed-ring: var(--sev-warning); }
.speedometer.over { --speed-ring: var(--sev-danger); }
.speed-value {
    font-family: var(--mono);
    font-weight: 800;
    font-size: 22px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.speed-unit { font-size: 11px; font-weight: 600; color: var(--ink-3); margin-top: 2px; }

/* ---------- Panel inferior ---------- */
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-sheet);
    max-height: 72dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    box-shadow: var(--shadow-sheet);
    transition: transform 320ms var(--ease);
}
.bottom-sheet.is-collapsed {
    transform: translateY(calc(100% - 30px - var(--safe-b)));
}
/* En modo ruta el panel no sube por encima de los botones flotantes */
.bottom-sheet.in-route {
    max-height: max(45dvh, calc(100dvh - var(--top-offset) - 200px));
}
/* En modo ruta, plegado deja a la vista el resumen del viaje */
.bottom-sheet.is-collapsed.in-route {
    transform: translateY(calc(100% - 96px - var(--safe-b)));
}

.sheet-handle {
    flex: none;
    width: 100%;
    height: 30px;
    display: grid;
    place-items: center;
}
.handle-bar {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: var(--line);
}
.sheet-handle:hover .handle-bar { background: var(--ink-3); }

.sheet-section {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 16px calc(20px + var(--safe-b));
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.sheet-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.app-mark {
    width: 32px;
    height: 32px;
    flex: none;
}
.app-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

/* ---------- Búsqueda ---------- */
.search-inputs {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}
.field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}
.search-row { position: relative; }
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrap > .icon {
    position: absolute;
    left: 14px;
    color: var(--ink-3);
    pointer-events: none;
    transition: color 160ms var(--ease);
}
.search-row.is-set .input-wrap > .icon { color: var(--accent); }
.search-input {
    width: 100%;
    height: 48px;
    padding: 0 14px 0 44px;
    border-radius: var(--r-ctl);
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 16px;
    outline: none;
    transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.search-input.has-action { padding-right: 52px; }
.search-input::placeholder { color: var(--ink-3); }
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.input-action-btn {
    position: absolute;
    right: 4px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--accent);
}
.input-action-btn:hover { background: var(--accent-soft); }

.suggestions {
    display: none;
    list-style: none;
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    background: var(--surface);
    overflow: hidden;
}
.suggestions.active { display: block; }
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 8px 12px;
    text-align: left;
    transition: background-color 120ms var(--ease);
}
.suggestion-item + .suggestion-item { border-top: 1px solid var(--line); }
.suggestion-item:hover, .suggestion-item:focus-visible { background: var(--surface-2); outline: none; }
.sug-icon { color: var(--ink-3); }
.sug-body { min-width: 0; flex: 1; }
.sug-main {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sug-detail {
    font-size: 13px;
    color: var(--ink-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Control segmentado ---------- */
.pref-group { margin-bottom: 16px; }
.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: var(--r-ctl);
    background: var(--surface-2);
}
.segment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 15px;
    color: var(--ink-2);
    transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.segment:hover { color: var(--ink); }
.segment[aria-pressed="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(20, 30, 50, 0.14);
}
.segment[aria-pressed="true"] .icon { color: var(--accent); }

/* ---------- Botones ---------- */
.primary-btn, .secondary-btn {
    position: relative;
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--r-ctl);
    font-weight: 700;
    font-size: 16px;
    overflow: hidden;
    transition: transform 160ms var(--ease), background-color 160ms var(--ease), opacity 160ms var(--ease);
}
.primary-btn { background: var(--accent); color: var(--accent-ink); }
.primary-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.primary-btn:active:not(:disabled), .secondary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { opacity: 0.45; }
.secondary-btn { background: var(--surface-2); color: var(--ink); margin-top: 16px; }
.secondary-btn:hover { background: var(--line); }
.text-btn {
    width: 100%;
    min-height: 44px;
    margin-top: 8px;
    font-weight: 600;
    color: var(--ink-2);
    border-radius: var(--r-ctl);
}
.text-btn:hover { color: var(--ink); background: var(--surface-2); }

/* Carga integrada en el botón */
.primary-btn.is-loading { cursor: progress; }
.primary-btn.is-loading::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40%;
    height: 3px;
    background: var(--accent-ink);
    opacity: 0.7;
    animation: load-slide 1.1s var(--ease) infinite;
}
@keyframes load-slide {
    from { transform: translateX(-100%); }
    to   { transform: translateX(250%); }
}

.inline-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--r-ctl);
    background: color-mix(in srgb, var(--sev-danger) 12%, var(--surface));
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
}
.inline-error .icon { color: var(--sev-danger); margin-top: 1px; }
.inline-error.is-notice { background: color-mix(in srgb, var(--sev-warning) 14%, var(--surface)); }
.inline-error.is-notice .icon { color: var(--sev-warning); }

/* ---------- Resultados ---------- */
.trip-summary {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.trip-main { display: flex; align-items: baseline; gap: 16px; }
.trip-figure {
    font-family: var(--mono);
    font-weight: 800;
    font-size: 28px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.trip-unit { font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--ink-2); margin-left: 3px; }
.trip-meta { display: flex; gap: 8px; }
.trip-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: var(--r-ctl);
    background: var(--surface-2);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
}
.trip-chip .num { color: var(--ink); font-weight: 700; }

.weather-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.wstrip-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--r-ctl);
    border: 1px solid var(--line);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}
.wstrip-item .icon { color: var(--sev-color, var(--ink-3)); }

.sev-good    { --sev-color: var(--sev-good); }
.sev-caution { --sev-color: var(--sev-caution); }
.sev-warning { --sev-color: var(--sev-warning); }
.sev-danger  { --sev-color: var(--sev-danger); }

/* Pestañas */
.tab-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}
.tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    font-weight: 600;
    font-size: 15px;
    color: var(--ink-3);
    box-shadow: inset 0 -2px 0 transparent;
    transition: color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
    color: var(--ink);
    box-shadow: inset 0 -2px 0 var(--accent);
}
.tab[aria-selected="true"] .icon { color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Lista de avisos */
.warning-list { display: grid; gap: 4px; }
.warning-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 10px 8px;
    border-radius: var(--r-ctl);
    text-align: left;
    transition: background-color 120ms var(--ease);
}
.warning-item:hover { background: var(--surface-2); }
.wi-badge {
    width: 36px;
    height: 36px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--sev-color, var(--ink-3));
    color: #FFFFFF;
}
.wi-body { min-width: 0; flex: 1; display: grid; gap: 2px; }
.wi-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wi-title { font-weight: 700; font-size: 15px; }
.wi-desc { font-size: 14px; color: var(--ink-2); }
.wi-source { font-size: 12px; color: var(--ink-3); }

.empty-state {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 28px 16px;
    text-align: center;
}
.empty-state .icon { width: 32px; height: 32px; color: var(--sev-good); }
.empty-title { font-weight: 700; }
.empty-desc { font-size: 14px; color: var(--ink-2); max-width: 32ch; }

/* Hitos kilométricos */
.weather-timeline-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}
.wt-point {
    flex: none;
    width: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 10px 10px 6px 6px;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
    overflow: hidden;
    scroll-snap-align: start;
    transition: transform 160ms var(--ease);
}
.wt-point:active { transform: scale(0.97); }
.wt-cap {
    width: 100%;
    padding: 6px 4px 4px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.wt-icon { margin: 10px 0 4px; color: var(--sev-color, var(--ink-2)); }
.wt-temp {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 18px;
    padding-bottom: 10px;
    font-variant-numeric: tabular-nums;
}

/* Detalle */
.weather-rows { display: grid; gap: 4px; }
.wcard {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 8px;
    border-radius: var(--r-ctl);
    text-align: left;
    transition: background-color 120ms var(--ease);
}
.wcard:hover { background: var(--surface-2); }
.wcard-icon { color: var(--sev-color, var(--ink-2)); }
.wcard-loc { font-weight: 700; font-size: 15px; }
.wcard-cond { font-size: 14px; color: var(--ink-2); }
.wcard-meta { text-align: right; }
.wcard-temp { font-family: var(--mono); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.wcard-wind { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-3); }

/* ---------- Diálogo de reporte ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-dialog);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 20, 0.5);
}
.modal-sheet {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 12px 16px calc(16px + var(--safe-b));
    background: var(--surface);
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    box-shadow: var(--shadow-sheet);
}
.modal-sheet .handle-bar { margin: 0 auto 16px; }
.modal-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.modal-sub { font-size: 14px; color: var(--ink-2); margin: 2px 0 16px; }
.report-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.rpt-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 76px;
    padding: 10px 4px;
    border-radius: var(--r-ctl);
    background: var(--surface-2);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    transition: transform 160ms var(--ease), background-color 160ms var(--ease), color 160ms var(--ease);
}
.rpt-btn .icon { width: 24px; height: 24px; color: var(--ink); }
.rpt-btn:hover { color: var(--ink); background: var(--line); }
.rpt-btn:active { transform: scale(0.97); }
.rpt-btn[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 2px var(--accent);
}
.rpt-btn[aria-pressed="true"] .icon { color: var(--accent); }
.modal-field { margin-bottom: 12px; }
.modal-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border-radius: var(--r-ctl);
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 16px;
    outline: none;
}
.modal-input::placeholder { color: var(--ink-3); }
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--safe-b));
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 32px);
    padding: 12px 16px;
    border-radius: var(--r-ctl);
    background: var(--ink);
    color: var(--surface);
    font-weight: 600;
    font-size: 15px;
    box-shadow: var(--shadow);
    transform: translateX(-50%);
}
.toast .icon { color: var(--sev-good); }

/* ---------- Marcadores del mapa ---------- */
.mk-warning {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--sev-color, var(--sev-caution));
    color: #FFFFFF;
    box-shadow: 0 0 0 2px #FFFFFF, 0 4px 10px rgba(20, 30, 50, 0.35);
}
.mk-warning .icon { width: 20px; height: 20px; }

.mk-weather {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface);
    color: var(--sev-color, var(--ink-2));
    box-shadow: 0 0 0 1px var(--line), 0 3px 8px rgba(20, 30, 50, 0.25);
}

.mk-fuel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 26px;
    padding: 0 8px;
    border-radius: 7px;
    background: var(--fuel-color, var(--fuel-gas));
    color: #FFFFFF;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    box-shadow: 0 0 0 2px #FFFFFF, 0 3px 8px rgba(20, 30, 50, 0.3);
}
.mk-fuel.is-diesel { --fuel-color: var(--fuel-diesel); color: #14181F; }

.mk-endpoint {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #FFFFFF;
    box-shadow: 0 0 0 3px #FFFFFF, 0 4px 10px rgba(20, 30, 50, 0.35);
}
.mk-origin { background: var(--accent); color: var(--accent-ink); }
.mk-dest { background: var(--ink); color: var(--surface); }

.gps-marker {
    position: relative;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
}
.gps-dot {
    position: relative;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px #FFFFFF, 0 2px 8px rgba(20, 30, 50, 0.4);
}
.gps-dot::after {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0;
}
/* Con rumbo conocido: flecha de navegación girada hacia la marcha */
.gps-arrow {
    position: absolute;
    inset: 4px;
    width: 40px;
    height: 40px;
    display: none;
    fill: var(--accent);
    stroke: #FFFFFF;
    stroke-width: 3.5;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 4px rgba(20, 30, 50, 0.45));
    transform: rotate(var(--heading, 0deg));
    transition: transform 600ms var(--ease);
}
.gps-marker.has-heading .gps-arrow { display: block; }
.gps-marker.has-heading .gps-dot { display: none; }

/* ---------- Popups de Leaflet ---------- */
.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-popup-content-wrapper {
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--r-ctl);
    box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.45; min-width: 200px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); width: 32px; height: 32px; font-size: 20px; line-height: 30px; }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--ink); }

.popup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
    padding-right: 20px;
}
.popup-title .icon { color: var(--sev-color, var(--ink-2)); }
.popup-detail { color: var(--ink-2); margin-top: 4px; }
.popup-temp { font-family: var(--mono); font-weight: 700; font-size: 24px; margin-top: 4px; }
.popup-road { margin-top: 8px; }
.popup-source { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

.warning-vote {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}
.vote-label { font-size: 13px; font-weight: 600; color: var(--ink-2); flex: 1; }
.vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 9px;
    background: var(--surface-2);
    font-size: 13px;
    font-weight: 700;
}
.vote-btn:hover { background: var(--line); }
.vote-thanks { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* Popup de gasolinera */
.fuel-popup { display: grid; gap: 10px; }
.fp-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-right: 18px; }
.fp-name { font-weight: 800; font-size: 15px; }
.fp-badge { font-family: var(--mono); font-weight: 700; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.fp-prices { display: grid; gap: 2px; }
.fp-row {
    display: grid;
    grid-template-columns: 10px 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
}
.fp-selected { background: var(--surface-2); }
.fp-dot { width: 10px; height: 10px; border-radius: 3px; }
.fp-label { font-weight: 600; }
.fp-value { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.fp-unit { font-size: 12px; color: var(--ink-3); }
.fp-addr { font-size: 13px; color: var(--ink-2); }
.fp-sched { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* Controles de Leaflet */
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution {
    background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
    color: var(--ink-3) !important;
    font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--ink-2) !important; }
.leaflet-bottom.leaflet-right { margin-bottom: 32px; }

/* ---------- Escritorio ---------- */
@media (min-width: 900px) {
    .bottom-sheet {
        left: 16px;
        right: auto;
        top: 16px;
        bottom: 16px;
        width: var(--panel-w);
        max-height: none;
        border-radius: var(--r-sheet);
        box-shadow: var(--shadow);
    }
    .bottom-sheet.is-collapsed, .bottom-sheet.is-collapsed.in-route { transform: none; }
    .bottom-sheet.in-route { max-height: none; }
    .sheet-handle { display: none; }
    .sheet-section { padding-top: 20px; }

    .top-bar {
        left: calc(var(--panel-w) + 32px);
        right: 16px;
        top: 16px;
        padding: 10px 12px;
        border-radius: var(--r-sheet);
    }
    .nav-sign {
        left: calc(var(--panel-w) + 32px);
        right: auto;
        width: min(520px, calc(100% - var(--panel-w) - 48px));
        top: 96px;
    }
    .speedometer { left: auto; right: 80px; }
    .leaflet-control-zoom { display: block; }
    .leaflet-bottom.leaflet-right { margin-bottom: 0; }

    .modal { align-items: center; }
    .modal-sheet { border-radius: var(--r-sheet); padding-top: 24px; }
    .modal-sheet .handle-bar { display: none; }
}

/* ---------- Movimiento (solo si el usuario lo permite) ---------- */
@media (prefers-reduced-motion: no-preference) {
    .nav-sign.is-entering .nav-sign-inner {
        animation: sign-drop 320ms var(--ease) both;
    }
    @keyframes sign-drop {
        from { transform: translateY(-16px); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }

    .sheet-section.is-entering { animation: panel-in 240ms var(--ease) both; }
    @keyframes panel-in {
        from { transform: translateY(12px); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }

    .stagger > * { animation: row-in 280ms var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
    @keyframes row-in {
        from { transform: translateY(8px); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }

    .toast { animation: toast-in 240ms var(--ease) both; }
    @keyframes toast-in {
        from { transform: translate(-50%, 12px); opacity: 0; }
        to   { transform: translate(-50%, 0); opacity: 1; }
    }

    .modal:not(.hidden) .modal-sheet { animation: panel-in 240ms var(--ease) both; }

    .gps-dot::after { animation: gps-pulse 2.4s var(--ease) infinite; }
    @keyframes gps-pulse {
        0%   { transform: scale(0.4); opacity: 0.35; }
        100% { transform: scale(1.4); opacity: 0; }
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
        animation-iteration-count: 1 !important;
    }
    .primary-btn.is-loading::after { transform: none; width: 100%; opacity: 0.4; }
}

/* Elementos de texto dentro de botones */
.sug-main, .sug-detail, .wcard-loc, .wcard-cond, .wcard-temp { display: block; }
.tb-weather-icon { display: flex; color: var(--sev-color, var(--ink-2)); }
