/* =========================================================
   Portal de Transparencia · Estatus de Proyectos AMSS
   Sistema de diseño: tokens → base → layout → componentes → mapa.
   Las animaciones solo usan transform/opacity y respetan
   prefers-reduced-motion (ver final del archivo).
========================================================= */

/* ---------- Fuentes (auto-hospedadas) ---------- */
@font-face {
    font-family: "Exo 2";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../lib/exo-2/exo-2-latin-wght-normal.woff2") format("woff2");
    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: "Exo 2";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../lib/exo-2/exo-2-latin-ext-wght-normal.woff2") format("woff2");
    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;

    /* Marca OPAMSS */
    --brand: #001976;
    --brand-strong: #000f4d;
    --brand-accent: #1f4cff;
    --brand-green: #54d335;

    /* Estados (mismos colores en pines, chips y barras) */
    --st-previos: #f2c14e;
    --st-permiso: #54d335;
    --st-recepcion: #1f4cff;
    --st-previos-ink: #7a4f00;
    --st-permiso-ink: #1d6b0b;
    --st-recepcion-ink: #1736b8;

    /* Superficies y texto */
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f8;
    --border: rgba(15, 23, 42, 0.09);
    --border-strong: rgba(15, 23, 42, 0.17);
    --text: #0b1530;
    --text-muted: #4a5672;
    --text-subtle: #5b6680;
    --brand-soft: #eaf0ff;
    --focus: #1f4cff;
    --danger: #d92d20;
    --overlay: rgba(6, 12, 32, 0.45);

    /* Forma */
    --r-xs: 8px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-full: 999px;

    --sh-1: 0 1px 2px rgba(15, 23, 42, 0.06);
    --sh-2: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 18px rgba(15, 23, 42, 0.07);
    --sh-3: 0 10px 30px rgba(15, 23, 42, 0.12);
    --sh-4: 0 24px 60px rgba(15, 23, 42, 0.22);

    /* Movimiento */
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --dur-1: 120ms;
    --dur-2: 200ms;
    --dur-3: 320ms;
    --dur-4: 520ms;

    /* Tipografía y medidas */
    --font: "Exo 2", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --container: 1440px;
    --gutter: clamp(16px, 3vw, 32px);
    --topbar-h: 64px;
    /* Alto de topbar + barra de filtros fija; JS lo ajusta al valor real */
    --sticky-offset: 136px;
}

/* Tema oscuro: por preferencia del sistema o elegido con el botón */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0f1e;
    --surface: #111a2e;
    --surface-2: #152038;
    --surface-3: #1b2843;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.26);
    --text: #e8edf8;
    --text-muted: #a9b4cd;
    --text-subtle: #8f9bb8;
    --brand-soft: rgba(80, 120, 255, 0.16);
    --focus: #7c9cff;
    --st-previos-ink: #ffd772;
    --st-permiso-ink: #8ef070;
    --st-recepcion-ink: #9db4ff;
    --overlay: rgba(0, 0, 0, 0.6);
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sh-2: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 22px rgba(0, 0, 0, 0.35);
    --sh-3: 0 12px 34px rgba(0, 0, 0, 0.45);
    --sh-4: 0 24px 60px rgba(0, 0, 0, 0.6);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--sticky-offset) + 12px);
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 500 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    transition: background-color var(--dur-3) ease, color var(--dur-3) ease;
}

img,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

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

::selection {
    background: rgba(31, 76, 255, 0.22);
}

h1,
h2,
h3,
p {
    margin: 0;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

[hidden] {
    display: none !important;
}

.nowrap {
    white-space: nowrap;
}

mark {
    padding: 0 2px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--st-previos) 45%, transparent);
    color: inherit;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 2000;
    padding: 10px 16px;
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    box-shadow: var(--sh-3);
    translate: 0 -150%;
    transition: translate var(--dur-2) var(--ease-out);
}

    .skip-link:focus {
        translate: 0 0;
    }

/* Barra de progreso superior (carga de datos) */
.topprogress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1500;
    height: 3px;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--dur-3) ease;
}

    .topprogress.is-active {
        opacity: 1;
    }

    .topprogress::before {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, var(--brand-green), var(--brand-accent), var(--brand-green));
        background-size: 200% 100%;
        transform-origin: 0 50%;
        animation: topprogress 1.4s var(--ease-out) infinite;
    }

@keyframes topprogress {
    0% {
        transform: scaleX(0);
        background-position: 0 0;
    }

    60% {
        transform: scaleX(.8);
    }

    100% {
        transform: scaleX(1);
        background-position: 200% 0;
        opacity: 0;
    }
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    height: var(--topbar-h);
    background: rgba(0, 25, 118, 0.94);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
}

.topbar__inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    text-decoration: none;
}

.brand__logo {
    height: 36px;
    width: auto;
}

.brand__divider {
    width: 1px;
    height: 26px;
    background: rgba(255, 255, 255, 0.25);
}

.brand__product {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: .01em;
    opacity: .92;
    white-space: nowrap;
}

.topbar__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Indicador de frescura de los datos */
.live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.live__dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
}

.live[data-state="ok"] .live__dot {
    background: var(--brand-green);
}

    .live[data-state="ok"] .live__dot::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: var(--brand-green);
        animation: livePulse 2s ease-out infinite;
    }

.live[data-state="error"] .live__dot {
    background: var(--st-previos);
}

.live[data-state="loading"] .live__dot {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}

@keyframes livePulse {
    from {
        transform: scale(1);
        opacity: .7;
    }

    to {
        transform: scale(3);
        opacity: 0;
    }
}

.iconbtn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-full);
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    transition: background-color var(--dur-2) ease, transform var(--dur-2) var(--ease-spring);
}

    .iconbtn:hover {
        background: rgba(127, 140, 170, 0.16);
    }

    .iconbtn:active {
        transform: scale(.92);
    }

.topbar .iconbtn:hover {
    background: rgba(255, 255, 255, 0.14);
}

#themeToggle i {
    transition: transform var(--dur-4) var(--ease-spring);
}

:root[data-theme="dark"] #themeToggle i {
    transform: rotate(-30deg);
}

/* ---------- Pantalla de carga: obra en construcción ----------
   Los pisos se levantan según el avance real de la carga (app.js / createSplash).
   Si algo falla, se oculta sola a los 14 s. */
.splash {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(ellipse 80% 70% at 50% 40%, #0a2a9e 0%, #001976 45%, #000c3d 100%);
    color: #fff;
    animation: splashFailsafe .4s ease 14s forwards;
}

    .splash.is-leaving {
        opacity: 0;
        visibility: hidden;
        transition: opacity .6s ease .05s, visibility 0s .7s;
    }

@keyframes splashFailsafe {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Cuadrícula de plano arquitectónico */
.splash__grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(124, 156, 255, 0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(124, 156, 255, 0.16) 1px, transparent 1px), linear-gradient(rgba(124, 156, 255, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(124, 156, 255, 0.07) 1px, transparent 1px);
    background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
    mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 35%, transparent 80%);
    pointer-events: none;
}

.splash__content {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    width: min(540px, 100%);
    transition: transform .6s var(--ease-out);
}

.splash.is-leaving .splash__content {
    transform: translateY(-14px) scale(.98);
}

.splash__scene {
    width: 100%;
    height: auto;
    overflow: visible;
}

/* Contorno punteado del plano: se "dibuja" al aparecer */
.sp-plan {
    fill: none;
    stroke: rgba(168, 200, 255, 0.55);
    stroke-width: 1;
    stroke-dasharray: 4 3;
    animation: spDraw 1.2s var(--ease-out) both;
}

@keyframes spDraw {
    from {
        stroke-dashoffset: 60;
        opacity: 0;
    }
}

/* Cada piso cae a su lugar como si lo colocara la grúa */
.sp-floor {
    opacity: 0;
    transform: translateY(-14px);
    transform-box: fill-box;
    transition: opacity .3s ease, transform .5s var(--ease-spring);
}

    .sp-floor.is-built {
        opacity: 1;
        transform: none;
    }

.sp-slab {
    fill: url(#spBody);
    stroke: rgba(0, 25, 118, 0.18);
    stroke-width: .6;
}

.sp-win {
    fill: rgba(0, 25, 118, 0.32);
    transition: fill .35s ease var(--d, 0s);
}

    .sp-win.is-lit {
        fill: #f2c14e;
    }

/* Al terminar se encienden todas las luces del edificio */
.splash.is-complete .sp-win {
    fill: #ffd76a;
}

.sp-ground {
    stroke: rgba(255, 255, 255, 0.65);
    stroke-width: 1.5;
}

.sp-dim {
    fill: none;
    stroke: rgba(168, 200, 255, 0.5);
    stroke-width: .8;
}

.sp-dim-text {
    fill: rgba(168, 200, 255, 0.75);
    font: 600 7px var(--font);
    letter-spacing: .12em;
}

/* Grúa torre */
.sp-crane {
    fill: none;
    stroke: #f2c14e;
    stroke-width: 1.4;
    stroke-linejoin: round;
}

.sp-crane-solid {
    fill: #f2c14e;
    stroke: none;
}

.sp-cable {
    stroke: rgba(255, 255, 255, 0.7);
    stroke-width: .8;
}

.sp-beam {
    fill: #c9d6ff;
}

.sp-trolley {
    animation: spTrolley 6s ease-in-out infinite alternate;
}

.sp-hook {
    transform-box: fill-box;
    transform-origin: 50% 0;
    animation: spSway 2.6s ease-in-out infinite alternate;
}

.sp-light {
    fill: #ff4d4d;
    animation: spBlink 1.4s steps(2, jump-none) infinite;
}

@keyframes spTrolley {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(86px);
    }
}

@keyframes spSway {
    from {
        transform: rotate(-4deg);
    }

    to {
        transform: rotate(4deg);
    }
}

@keyframes spBlink {
    50% {
        opacity: .15;
    }
}

.splash__counter {
    display: flex;
    align-items: baseline;
    margin-top: 10px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.splash__pct {
    min-width: 2.2ch;
    font-size: 64px;
    text-align: right;
}

.splash__unit {
    margin-left: 4px;
    font-size: 28px;
    color: var(--brand-green);
}

.splash__label {
    min-height: 1.4em;
    font-size: 14.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.78);
    text-align: center;
}

/* Barra tipo cinta métrica */
.splash__ruler {
    position: relative;
    width: 100%;
    height: 10px;
    margin-top: 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

    .splash__ruler::after {
        content: "";
        position: absolute;
        inset: 0;
        background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.35) 0 1px, transparent 1px 10%);
        mask-image: linear-gradient(#000 0 45%, transparent 45%);
        pointer-events: none;
    }

.splash__fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-green), #a8f590);
    box-shadow: 0 0 18px rgba(84, 211, 53, 0.55);
    transform-origin: 0 50%;
    transform: scaleX(0);
}

.splash__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 26px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

    .splash__brand img {
        height: 26px;
        width: auto;
        padding-right: 12px;
        border-right: 1px solid rgba(255, 255, 255, 0.25);
    }

/* ---------- Hero (presentación original) ---------- */
.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: linear-gradient(135deg, #001976 0%, #0b2a9a 55%, #2443b8 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.hero__bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.hero__grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: linear-gradient(90deg, transparent 10%, #000 70%);
}

.hero__inner {
    padding-block: 30px 46px;
}

.hero__title {
    font-size: clamp(28px, 3.4vw, 38px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    animation: slideIn var(--dur-4) var(--ease-out) both;
}

    .hero__title i {
        margin-left: .3em;
        font-size: .82em;
        opacity: .95;
    }

.hero__lead {
    margin-top: 10px;
    font-size: 15.5px;
    font-weight: 500;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.86);
    animation: slideIn var(--dur-4) var(--ease-out) 60ms both;
}

@keyframes slideIn {
    from {
        translate: 0 10px;
    }

    to {
        translate: 0 0;
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        translate: 0 14px;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        scale: .85;
    }

    to {
        opacity: 1;
        scale: 1;
    }
}

/* ---------- Filtros (tarjeta como el portal original) ---------- */
.filters {
    position: relative;
    z-index: 2;
    margin-top: -24px;
}

.filters__card {
    padding: 16px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--sh-3);
}

.filters__grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(200px, 1fr) repeat(2, minmax(150px, 0.8fr)) auto;
    align-items: end;
    gap: 12px;
}

.field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

    .field label {
        padding-left: 2px;
        font-size: 13px;
        font-weight: 700;
        color: var(--text-muted);
    }

.select,
.search input {
    width: 100%;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background-color: var(--surface);
    color: var(--text);
    font-size: 14.5px;
    font-weight: 600;
    transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) ease, background-color var(--dur-2) ease;
}

.select {
    appearance: none;
    padding: 0 38px 0 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235b6680' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    text-overflow: ellipsis;
}

    .select:hover,
    .search input:hover {
        border-color: color-mix(in srgb, var(--brand-accent) 40%, var(--border-strong));
    }

    .select:focus-visible,
    .search input:focus-visible {
        outline: none;
        border-color: var(--brand-accent);
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-accent) 16%, transparent);
    }

    .select.is-set {
        border-color: color-mix(in srgb, var(--brand-accent) 55%, var(--border-strong));
        background-color: var(--brand-soft);
    }

.search {
    position: relative;
}

    .search input {
        padding: 0 74px 0 42px;
        font-size: 15px;
    }

        .search input::placeholder {
            color: var(--text-subtle);
            font-weight: 500;
        }

        .search input::-webkit-search-cancel-button {
            display: none;
        }

.search__icon {
    position: absolute;
    left: 15px;
    top: 50%;
    translate: 0 -50%;
    color: var(--text-subtle);
    pointer-events: none;
    transition: color var(--dur-2) ease;
}

.search:focus-within .search__icon {
    color: var(--brand-accent);
}

.search__kbd,
.search__clear {
    position: absolute;
    right: 10px;
    top: 50%;
    translate: 0 -50%;
}

.search__kbd {
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text-subtle);
    font: 700 12px/1.4 var(--font);
    pointer-events: none;
    transition: opacity var(--dur-2) ease;
}

.search:focus-within .search__kbd,
.search.has-value .search__kbd {
    opacity: 0;
}

.search__clear {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-muted);
    animation: popIn var(--dur-3) var(--ease-spring);
}

    .search__clear:hover {
        background: var(--border-strong);
        color: var(--text);
    }

.filters__actions {
    display: flex;
    gap: 10px;
}

.filters__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.filters__status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    min-width: 0;
}

.results {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
}

    .results strong {
        color: var(--text);
        font-weight: 800;
    }

/* Selector de vista con indicador deslizante */
.segmented {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: 42px;
    padding: 4px;
    border-radius: var(--r-md);
    background: var(--surface-3);
    border: 1px solid var(--border);
}

    .segmented::before {
        content: "";
        position: absolute;
        top: 4px;
        bottom: 4px;
        left: 4px;
        width: calc((100% - 8px) / 3);
        border-radius: var(--r-sm);
        background: var(--surface);
        box-shadow: var(--sh-2);
        transform: translateX(calc(var(--seg-index, 0) * 100%));
        transition: transform var(--dur-3) var(--ease-spring);
    }

.segmented__btn {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    transition: color var(--dur-2) ease;
}

    .segmented__btn:hover {
        color: var(--text);
    }

    .segmented__btn[aria-checked="true"] {
        color: var(--brand);
    }

:root[data-theme="dark"] .segmented__btn[aria-checked="true"] {
    color: #fff;
}

/* Chips de filtros activos */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .chips:empty {
        display: none;
    }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 6px 0 12px;
    border-radius: var(--r-full);
    border: 1px solid color-mix(in srgb, var(--brand-accent) 30%, var(--border));
    background: var(--brand-soft);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    animation: popIn var(--dur-3) var(--ease-spring) both;
}

    .chip b {
        font-weight: 800;
    }

.chip__x {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    transition: background-color var(--dur-2) ease, color var(--dur-2) ease;
}

    .chip__x:hover {
        background: color-mix(in srgb, var(--brand-accent) 18%, transparent);
        color: var(--text);
    }

.chip--clear {
    padding: 0 12px;
    border-style: dashed;
    background: transparent;
    color: var(--text-muted);
}

    .chip--clear:hover {
        color: var(--text);
        border-style: solid;
    }

/* ---------- Bienvenida (antes de buscar) ---------- */
.welcome {
    padding: 40px 28px 32px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand-green) 5%, var(--surface)), var(--surface) 70%);
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    max-width: 1060px;
    margin: 0 auto 40px;
}

.step {
    --c: var(--st-previos);
    --c-ink: #b7791f;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 28px 24px 22px;
    border: 2px solid var(--c);
    border-radius: 20px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--c) 7%, var(--surface)), var(--surface) 65%);
    text-align: left;
    overflow: hidden;
    transition: transform .4s var(--ease-spring), box-shadow .4s ease;
    animation: riseIn .6s var(--ease-out) both;
}

    .step:nth-child(2) {
        --c: #22c55e;
        --c-ink: #15803d;
        animation-delay: 90ms;
    }

    .step:nth-child(3) {
        --c: #3b82f6;
        --c-ink: #1d4ed8;
        animation-delay: 180ms;
    }

    .step:hover {
        transform: translateY(-8px);
        box-shadow: 0 20px 40px color-mix(in srgb, var(--c) 18%, transparent);
    }

:root[data-theme="dark"] .step {
    --c-ink: #ffd772;
}

    :root[data-theme="dark"] .step:nth-child(2) {
        --c-ink: #8ef070;
    }

    :root[data-theme="dark"] .step:nth-child(3) {
        --c-ink: #9db4ff;
    }

.step__num {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 56px;
    font-weight: 900;
    line-height: 1;
    color: var(--text);
    opacity: .07;
    transition: opacity .4s ease, transform .4s ease;
}

.step:hover .step__num {
    opacity: .14;
    transform: scale(1.08);
}

.step__icon {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    margin-bottom: 6px;
    border-radius: 16px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--c) 18%, var(--surface)), color-mix(in srgb, var(--c) 45%, var(--surface)));
    color: var(--c-ink);
    font-size: 24px;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--c) 25%, transparent);
    transition: transform .4s var(--ease-spring);
}

.step:hover .step__icon {
    transform: scale(1.1) rotate(-5deg);
}

.step__title {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.3;
    color: var(--text);
}

.step__text {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--text-muted);
}

.step__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 10px;
    width: 100%;
    margin-top: auto;
    padding-top: 8px;
}

.step__badge {
    padding: 6px 14px;
    white-space: nowrap;
    border-radius: 999px;
    background: color-mix(in srgb, var(--c) 15%, transparent);
    color: var(--c-ink);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.step__count {
    display: inline-flex;
    white-space: nowrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    transition: color var(--dur-2) ease;
}

    .step__count i {
        transition: transform var(--dur-3) var(--ease-spring);
    }

.step:hover .step__count {
    color: var(--c-ink);
}

    .step:hover .step__count i {
        transform: translateX(4px);
    }

.welcome__title {
    margin-bottom: 14px;
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-align: center;
    animation: riseIn .6s var(--ease-out) .2s both;
}

    .welcome__title span {
        background: linear-gradient(135deg, #22c55e, #10b981);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }

.welcome__desc {
    max-width: 560px;
    margin: 0 auto 36px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
    animation: riseIn .6s var(--ease-out) .26s both;
}

.cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    max-width: 1060px;
    margin: 0 auto;
    padding: 26px 30px;
    border: 2px solid color-mix(in srgb, #22c55e 45%, transparent);
    border-radius: 20px;
    background: linear-gradient(135deg, color-mix(in srgb, #22c55e 7%, var(--surface)), color-mix(in srgb, #22c55e 15%, var(--surface)));
    animation: riseIn .6s var(--ease-out) .34s both;
}

.cta__content {
    display: flex;
    align-items: center;
    gap: 18px;
}

.cta__icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--surface);
    color: #22c55e;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

.cta__title {
    margin-bottom: 4px;
    font-size: 18px;
    font-weight: 800;
}

.cta__text {
    font-size: 13.5px;
    color: var(--text-muted);
}

.cta__btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 14px 26px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
    transition: transform .3s var(--ease-spring), box-shadow .3s ease;
}

    .cta__btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(34, 197, 94, 0.4);
    }

    .cta__btn i {
        transition: transform .3s var(--ease-spring);
    }

    .cta__btn:hover i {
        transform: translateX(4px);
    }

/* Bienvenida en paneles angostos (vista Mixto, tablet, móvil) */
@container panel (max-width: 760px) {
    .welcome {
        padding: 26px 16px;
    }

    .steps {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 28px;
    }

    .step {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 14px;
        row-gap: 4px;
        padding: 16px;
    }

    .step__icon {
        grid-row: span 3;
        width: 48px;
        height: 48px;
        margin: 0;
        font-size: 19px;
    }

    .step__num {
        font-size: 40px;
    }

    .step__foot {
        padding-top: 4px;
    }

    .cta {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
    }

    .cta__btn {
        justify-content: center;
    }
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: transform var(--dur-2) var(--ease-spring), box-shadow var(--dur-2) ease, background-color var(--dur-2) ease, border-color var(--dur-2) ease;
}

    .btn:active {
        transform: scale(.97);
    }

.btn--primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(0, 25, 118, 0.6);
}

    .btn--primary:hover {
        background: #0a2a9e;
        transform: translateY(-1px);
        box-shadow: 0 10px 22px -8px rgba(0, 25, 118, 0.7);
    }

:root[data-theme="dark"] .btn--primary {
    background: var(--brand-accent);
}

.btn--soft {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

    .btn--soft:hover {
        border-color: color-mix(in srgb, var(--brand-accent) 45%, var(--border-strong));
        background: var(--brand-soft);
    }

.btn--block {
    width: 100%;
}

/* Verde institucional para la acción principal de búsqueda (como el portal original) */
.btn--accent {
    background: linear-gradient(135deg, var(--brand-green), #3fbf22);
    color: #08101f;
    box-shadow: 0 8px 20px -8px rgba(84, 211, 53, 0.65);
}

    .btn--accent:hover {
        transform: translateY(-1px);
        box-shadow: 0 12px 26px -8px rgba(84, 211, 53, 0.75);
    }

.btn.is-busy i {
    animation: spin .8s linear infinite;
}

/* ---------- Paneles de resultados ---------- */
/* Sin flex: 1 a propósito: en un body flex ignoraría el alto fijo de Mixto/Mapa
   (el pie se empuja abajo con margin-top: auto). */
.layout {
    display: grid;
    gap: 16px;
    padding-block: 20px 40px;
}

.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--sh-2);
    overflow: hidden;
}

.panel--list {
    container: panel / inline-size;
}

.panel__header {
    flex-shrink: 0;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, var(--surface)), var(--surface));
}

.panel__title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.panel__hint {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.panel__body {
    flex: 1;
    min-height: 0;
}

.panel__footer {
    flex-shrink: 0;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--brand) 3%, var(--surface));
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

    .legend li {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        font-weight: 700;
        color: var(--text-muted);
    }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--st);
}

/* Sin scroll-margin: el scroll-padding-top del documento ya descuenta la cabecera fija */
.panel--map {
    display: none;
    position: relative;
}

.panel__map {
    position: relative;
    flex: 1;
    min-height: 0;
}

.map {
    position: absolute;
    inset: 0;
}

/* Lista: una tarjeta por fila, a todo el ancho */
.cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
}

    .cards:empty {
        display: none;
    }

/* La fila se limita al alto disponible: sin esto crecía con la lista y el mapa
   medía miles de píxeles (se centraba fuera de la vista). */
.layout[data-view="split"] {
    grid-template-columns: minmax(400px, 1fr) minmax(0, 1.05fr);
    grid-template-rows: minmax(0, 1fr);
    height: calc(100dvh - var(--sticky-offset) - 24px);
    min-height: 600px;
}

    .layout[data-view="split"] .panel__body {
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: var(--border-strong) transparent;
    }

    .layout[data-view="split"] .panel--map {
        display: flex;
    }

/* Mapa: ocupa toda la pantalla disponible bajo la barra fija */
.layout[data-view="map"] {
    grid-template-rows: minmax(0, 1fr);
    height: calc(100dvh - var(--sticky-offset) - 24px);
    min-height: 640px;
}

    .layout[data-view="map"] .panel--list {
        display: none;
    }

    .layout[data-view="map"] .panel--map {
        display: flex;
    }

        /* Todo el alto para el mapa (el conteo y la leyenda ya están dentro de él) */
        .layout[data-view="map"] .panel--map .panel__header {
            display: none;
        }

/* ---------- Tarjeta de proyecto ---------- */
.card {
    --st: var(--st-previos);
    container: card / inline-size;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 20px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--sh-1);
    transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) ease, border-color var(--dur-2) ease;
}

    .card[data-status="permiso"] {
        --st: var(--st-permiso);
    }

    .card[data-status="recepcion"] {
        --st: var(--st-recepcion);
    }

    .card:hover,
    .card.is-hover {
        transform: translateY(-2px);
        box-shadow: var(--sh-3);
        border-color: color-mix(in srgb, var(--st) 40%, var(--border));
    }

    .card.is-active {
        border-color: var(--st);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--st) 25%, transparent), var(--sh-3);
    }

    .card:focus-within {
        border-color: var(--focus);
    }

.card--enter {
    animation: cardIn var(--dur-4) var(--ease-out) both;
    animation-delay: calc(min(var(--i, 0), 10) * 45ms);
}

@keyframes cardIn {
    from {
        opacity: 0;
        translate: 0 16px;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

.card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.card__title {
    font-size: 17.5px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

/* Toda la tarjeta es clicable a través de este botón (accesible por teclado) */
.card__link {
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    font: inherit;
    letter-spacing: inherit;
}

    .card__link::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: var(--r-lg);
    }

    .card__link:focus-visible {
        outline: none;
    }

        .card__link:focus-visible::after {
            outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent);
            outline-offset: 3px;
        }

.card__comercial {
    color: var(--text-muted);
    font-weight: 600;
}

.card__dev {
    margin-top: 4px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: .02em;
}

.badge {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: var(--r-full);
    background: color-mix(in srgb, var(--st) 16%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--st) 40%, transparent);
    color: var(--st-ink, var(--text));
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: help;
}

    .badge::before {
        content: "";
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--st);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--st) 25%, transparent);
    }

[data-status="previos"] {
    --st-ink: var(--st-previos-ink);
}

[data-status="permiso"] {
    --st-ink: var(--st-permiso-ink);
}

[data-status="recepcion"] {
    --st-ink: var(--st-recepcion-ink);
}

.card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

    .card__meta > span {
        display: inline-flex;
        align-items: baseline;
        gap: 8px;
        min-width: 0;
        padding: 5px 12px;
        border-radius: var(--r-full);
        background: var(--surface-2);
        border: 1px solid var(--border);
    }

    .card__meta i {
        color: var(--text-subtle);
    }

/* Progreso en 3 etapas: barra, etapa, estado y descripción (como el original) */
.progress {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 18px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.progress__step {
    --c: var(--st-previos);
    display: grid;
    align-content: start;
    gap: 7px;
    min-width: 0;
}

    .progress__step:nth-child(2) {
        --c: var(--st-permiso);
    }

    .progress__step:nth-child(3) {
        --c: var(--st-recepcion);
    }

.progress__bar {
    position: relative;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
}

    .progress__bar::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: var(--c);
        transform-origin: 0 50%;
        transform: scaleX(var(--fill, 0));
        transition: transform 700ms var(--ease-out);
    }

.card--enter .progress__bar::after {
    animation: barFill 900ms var(--ease-out) both;
    animation-delay: calc(min(var(--i, 0), 10) * 45ms + 200ms);
}

@keyframes barFill {
    from {
        transform: scaleX(0);
    }
}

/* Trámites previos parciales: 4 segmentos de 25 % (CL, LC, FA, RV), uno por trámite favorable.
   Las divisiones van en la barra completa (fijas en 25/50/75 %): si fueran en el relleno,
   se encogerían con él y aparecerían divisiones de más.
   Por encima del enlace de la tarjeta para que muestre su detalle al pasar el cursor. */
.progress__bar--seg {
    z-index: 1;
    cursor: help;
    mask-image: linear-gradient(90deg, #000 calc(25% - 1px), transparent 0 calc(25% + 1px), #000 0 calc(50% - 1px), transparent 0 calc(50% + 1px), #000 0 calc(75% - 1px), transparent 0 calc(75% + 1px), #000 0);
}

.progress__label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

.progress__state {
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-subtle);
    white-space: nowrap;
}

.progress__step.is-on .progress__state {
    background: color-mix(in srgb, var(--c) 18%, var(--surface));
    color: var(--text);
}

.progress__step.is-current .progress__state {
    background: var(--c);
    color: #0b1220;
}

.progress__step:nth-child(3).is-current .progress__state {
    color: #fff;
}

.progress__desc {
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--text-muted);
}

.progress__note {
    display: none;
    grid-column: 1 / -1;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Tarjetas angostas (Mixto, móvil): una sola línea de descripción */
@container card (max-width: 620px) {
    .progress__desc {
        display: none;
    }

    .progress__note {
        display: block;
    }

    .progress__label {
        display: grid;
        justify-items: start;
        gap: 5px;
        font-size: 12px;
    }

    .card__head {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ---------- Esqueleto de carga: misma forma que la tarjeta ---------- */
.card--skeleton {
    pointer-events: none;
    overflow: hidden;
    animation: riseIn .35s var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 60ms);
}

    /* Un solo destello recorre toda la tarjeta (efecto "ola") */
    .card--skeleton::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--surface) 75%, transparent) 45%, transparent 70%);
        transform: translateX(-100%);
        animation: skWave 1.5s ease-in-out infinite;
        animation-delay: calc(var(--i, 0) * 120ms);
    }

@keyframes skWave {
    to {
        transform: translateX(100%);
    }
}

.sk {
    display: block;
    height: 12px;
    border-radius: var(--r-full);
    background: var(--surface-3);
}

.sk-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.sk-col {
    display: grid;
    flex: 1;
    gap: 9px;
}

.sk--title {
    height: 18px;
    width: min(420px, 70%);
    border-radius: 6px;
}

.sk--sub {
    width: min(220px, 40%);
    height: 10px;
}

.sk--pill {
    width: 170px;
    height: 28px;
    flex-shrink: 0;
}

.sk-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .sk-meta .sk {
        height: 28px;
        width: 260px;
    }

        .sk-meta .sk:nth-child(2) {
            width: 190px;
        }

.sk-progress {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

    .sk-progress > div {
        display: grid;
        gap: 9px;
    }

    .sk-progress .sk:first-child {
        height: 8px;
    }

    .sk-progress .sk:nth-child(2) {
        width: 60%;
    }

    .sk-progress .sk:nth-child(3) {
        width: 85%;
        height: 9px;
    }

@container card (max-width: 620px) {
    .sk-row {
        flex-direction: column-reverse;
    }

    .sk--pill {
        width: 150px;
        height: 24px;
    }

    .sk-progress .sk:nth-child(3) {
        display: none;
    }
}

/* Cargar más */
.loadmore {
    display: grid;
    place-items: center;
    padding: 4px 16px 20px;
}

/* Estado vacío */
.empty {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 56px 20px;
    border-radius: var(--r-xl);
    border: 1px dashed var(--border-strong);
    background: var(--surface);
    text-align: center;
    animation: riseIn var(--dur-4) var(--ease-out) both;
}

.empty__icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--brand-soft);
    color: var(--brand-accent);
    font-size: 26px;
}

.empty__title {
    font-size: 19px;
    font-weight: 800;
}

.empty__text {
    max-width: 44ch;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes pulse {
    50% {
        opacity: .45;
    }
}

/* ---------- Tooltip del estado ---------- */
.tt {
    position: fixed;
    z-index: 1600;
    width: 320px;
    padding: 14px;
    border-radius: var(--r-md);
    background: rgba(11, 18, 40, 0.96);
    color: #fff;
    box-shadow: var(--sh-4);
    pointer-events: none;
    opacity: 0;
    translate: 0 6px;
    transition: opacity var(--dur-2) ease, translate var(--dur-2) var(--ease-out);
}

    .tt.is-visible {
        opacity: 1;
        translate: 0 0;
    }

.tt__title {
    font-weight: 800;
    font-size: 14px;
}

.tt__sub {
    margin-top: 2px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.tt__steps {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.tt__step {
    display: grid;
    grid-template-columns: 10px 1fr;
    gap: 10px;
}

    .tt__step i {
        width: 10px;
        height: 10px;
        margin-top: 4px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.25);
    }

    .tt__step.is-on i {
        background: var(--c);
    }

.tt__label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 700;
}

.tt__desc {
    margin-top: 2px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.7);
}

/* ---------- Detalle (diálogo lateral / hoja inferior en móvil) ---------- */
.drawer {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    overflow: hidden;
}

    .drawer::backdrop {
        background: var(--overlay);
        opacity: 0;
        transition: opacity 380ms cubic-bezier(.4, 0, .2, 1);
    }

    .drawer.is-closing::backdrop {
        transition-duration: 280ms;
    }

    .drawer.is-open::backdrop {
        opacity: 1;
    }

.drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    height: 100%;
    background: var(--surface);
    box-shadow: var(--sh-4);
    transform: translateX(105%);
    transition: transform 440ms cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
}

.drawer.is-open .drawer__panel {
    transform: translateX(0);
}

/* Al cerrar acelera hacia fuera y dura menos */
.drawer.is-closing .drawer__panel {
    transition: transform 300ms cubic-bezier(.4, 0, 1, 1);
}

.drawer__handle {
    display: none;
}

.drawer__header {
    position: relative;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--st, var(--brand-accent)) 10%, var(--surface)), var(--surface));
}

.drawer__actions {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 4px;
}

.drawer__title {
    margin-top: 12px;
    padding-right: 120px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

.drawer__title:focus {
    outline: none;
}

.drawer__dev {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.drawer__content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 24px 28px;
    display: grid;
    align-content: start;
    gap: 22px;
}

.drawer__footer {
    display: flex;
    gap: 10px;
    padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

    .drawer__footer .btn {
        flex: 1;
    }

.section-title {
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

/* Línea de etapas vertical */
.timeline {
    position: relative;
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tl {
    --c: var(--st-previos);
    position: relative;
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 14px;
    padding-bottom: 16px;
    animation: drawerItemIn 420ms cubic-bezier(.4, 0, .2, 1) 260ms both;
}

    .tl:nth-child(2) {
        --c: var(--st-permiso);
        animation-delay: 320ms;
    }

    .tl:nth-child(3) {
        --c: var(--st-recepcion);
        animation-delay: 380ms;
    }

@keyframes drawerItemIn {
    from {
        opacity: 0;
        translate: 0 6px;
    }
}

    .tl:not(:last-child)::before {
        content: "";
        position: absolute;
        left: 17px;
        top: 38px;
        bottom: 0;
        width: 2px;
        background: var(--surface-3);
    }

    .tl.is-on:not(:last-child)::before {
        background: linear-gradient(var(--c), color-mix(in srgb, var(--c) 30%, var(--surface-3)));
    }

.tl__dot {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--surface-3);
    background: var(--surface);
    color: var(--text-subtle);
    font-size: 14px;
}

.tl.is-on .tl__dot {
    border-color: var(--c);
    background: var(--c);
    color: #0b1220;
}

.tl:nth-child(3).is-on .tl__dot {
    color: #fff;
}

/* Anillo de la etapa actual: escala y opacidad (lo anima la tarjeta gráfica; animar la sombra
   repintaba el panel en cada cuadro y trababa el deslizamiento). Empieza cuando el panel ya llegó. */
.tl.is-current .tl__dot {
    position: relative;
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 22%, transparent);
}

    .tl.is-current .tl__dot::after {
        content: "";
        position: absolute;
        inset: -2px;
        border-radius: 50%;
        border: 4px solid color-mix(in srgb, var(--c) 30%, transparent);
        pointer-events: none;
        animation: currentRing 2.4s ease-in-out 600ms infinite;
    }

@keyframes currentRing {
    0%, 100% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.45);
    }
}

.tl__body {
    padding-top: 6px;
}

.tl__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.tl__state {
    padding: 2px 9px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-subtle);
    font-size: 11px;
    font-weight: 700;
}

.tl.is-on .tl__state {
    background: color-mix(in srgb, var(--c) 20%, var(--surface));
    color: var(--text);
}

.tl__desc {
    margin-top: 4px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Trámites previos: CL, LC, FA, RV */

.facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.fact {
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.fact--wide {
    grid-column: 1 / -1;
}

.fact dt {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.fact dd {
    margin: 4px 0 0;
    font-weight: 700;
    word-break: break-word;
}

    .fact dd a {
        color: var(--brand-accent);
        text-decoration: none;
    }

        .fact dd a:hover {
            text-decoration: underline;
        }

:root[data-theme="dark"] .fact dd a {
    color: #9db4ff;
}

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1700;
    display: grid;
    gap: 8px;
    width: min(440px, calc(100% - 32px));
    translate: -50% 0;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    background: rgba(11, 18, 40, 0.95);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--sh-4);
    pointer-events: auto;
    animation: toastIn var(--dur-3) var(--ease-spring) both;
}

    .toast.is-leaving {
        animation: toastOut var(--dur-2) ease forwards;
    }

    .toast i {
        color: var(--brand-green);
    }

.toast--warn i {
    color: var(--st-previos);
}

.toast__action {
    margin-left: auto;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--r-sm);
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

    .toast__action:hover {
        background: rgba(255, 255, 255, 0.12);
    }

@keyframes toastIn {
    from {
        opacity: 0;
        translate: 0 16px;
        scale: .96;
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        translate: 0 8px;
    }
}

/* ---------- Botones flotantes ---------- */
.fab {
    position: fixed;
    right: 22px;
    z-index: 1050;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    box-shadow: var(--sh-3);
    transition: transform var(--dur-3) var(--ease-spring), box-shadow var(--dur-3) ease, opacity var(--dur-3) ease;
}

    .fab:hover {
        transform: translateY(-3px) scale(1.05);
        box-shadow: var(--sh-4);
    }


.fab--top {
    bottom: 90px;
    width: 46px;
    height: 46px;
    right: 27px;
    background: var(--surface);
    color: var(--brand);
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(12px) scale(.9);
    pointer-events: none;
}

    .fab--top.is-visible {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

:root[data-theme="dark"] .fab--top {
    color: #fff;
}

/* ---------- Página de error ---------- */
.errorpage {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 64px 0;
}

/* =========================================================
   MAPA: pines, clusters, popups y controles
========================================================= */
#map {
    font-family: var(--font);
    background: var(--surface-3);
}

#map .leaflet-bar,
#map .leaflet-control-layers {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    color: var(--text);
    box-shadow: var(--sh-3);
    overflow: hidden;
}

#map .leaflet-bar a {
    width: 38px;
    height: 38px;
    line-height: 38px;
    background: transparent;
    color: var(--brand);
    border-bottom-color: var(--border);
    transition: background-color var(--dur-2) ease, color var(--dur-2) ease;
}

:root[data-theme="dark"] #map .leaflet-bar a {
    color: #c7d4ff;
}

#map .leaflet-bar a:hover {
    background: var(--brand-soft);
    color: var(--brand-accent);
}

#map .leaflet-bar a:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
}

.mapTools__btn i {
    font-size: 15px;
}

.mapTools__btn.is-busy i {
    animation: spin .9s linear infinite;
}

#map .leaflet-control-layers-toggle {
    width: 40px;
    height: 40px;
    background-size: 22px 22px;
}

:root[data-theme="dark"] #map .leaflet-control-layers-toggle {
    filter: invert(1) hue-rotate(180deg);
}

#map .leaflet-control-layers-expanded {
    padding: 10px 14px 10px 10px;
    font: 600 13px/1.5 var(--font);
}

#map .leaflet-control-layers label {
    margin: 3px 0;
    cursor: pointer;
}

#map .leaflet-control-scale-line {
    border-color: color-mix(in srgb, var(--text) 45%, transparent);
    background: color-mix(in srgb, var(--surface) 75%, transparent);
    color: var(--text);
    font: 600 11px var(--font);
}

#map .leaflet-control-attribution {
    font-size: 10.5px;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    color: var(--text-muted);
    border-top-left-radius: 8px;
}

    #map .leaflet-control-attribution a {
        color: var(--brand-accent);
    }

/* Pines */
.mapPinWrap,
.mapClusterWrap,
.mapUserWrap {
    background: none;
    border: 0;
}

    .mapPinWrap:focus-visible {
        outline: none;
    }

.mapPin {
    position: relative;
    display: block;
    width: 30px;
    height: 40px;
    transform-origin: 50% 100%;
    transition: transform var(--dur-2) var(--ease-spring);
    filter: drop-shadow(0 3px 4px rgba(15, 23, 42, 0.3));
}

    .mapPin svg {
        display: block;
        overflow: visible;
        transform-origin: 50% 100%;
        animation: mapPinDrop .5s var(--ease-spring) both;
    }

.mapPin__body {
    fill: var(--pin);
    stroke: #fff;
    stroke-width: 2.5;
}

.mapPin__dot {
    fill: #fff;
}

.mapPinWrap:hover .mapPin,
.mapPinWrap:focus-visible .mapPin,
.mapPin.is-hover {
    transform: translateY(-3px) scale(1.15);
}

.mapPinWrap:focus-visible .mapPin__body {
    stroke: var(--focus);
    stroke-width: 3.5;
}

.mapPin.is-selected {
    transform: scale(1.3);
}

    .mapPin.is-selected::after {
        content: "";
        position: absolute;
        left: 50%;
        bottom: -4px;
        width: 22px;
        height: 8px;
        margin-left: -11px;
        border-radius: 50%;
        background: var(--pin);
        z-index: -1;
        animation: mapPinPulse 1.6s ease-out infinite;
    }

/* Sin coordenadas registradas: ubicación aproximada por geocodificación */
.mapPin.is-approx .mapPin__body {
    fill-opacity: .7;
    stroke-dasharray: 3 2.5;
}

@keyframes mapPinDrop {
    0% {
        translate: 0 -16px;
        scale: .5;
        opacity: 0;
    }

    60% {
        opacity: 1;
    }

    100% {
        translate: 0 0;
        scale: 1;
        opacity: 1;
    }
}

@keyframes mapPinPulse {
    0% {
        opacity: .55;
        scale: .6;
    }

    100% {
        opacity: 0;
        scale: 2.4;
    }
}

/* Clusters: anillo con la proporción de estados */
.mapCluster {
    width: 100%;
    height: 100%;
    padding: 4px;
    border-radius: 50%;
    background: var(--ring);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28);
    transition: transform var(--dur-2) var(--ease-spring);
    animation: mapClusterIn .35s ease-out both;
}

    .mapCluster span {
        display: grid;
        place-items: center;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background: var(--surface);
        color: var(--text);
        font: 800 14px/1 var(--font);
    }

.mapClusterWrap:hover .mapCluster {
    transform: scale(1.1);
}

@keyframes mapClusterIn {
    from {
        scale: .4;
        opacity: 0;
    }

    to {
        scale: 1;
        opacity: 1;
    }
}

/* Tooltip al pasar sobre un pin */
.leaflet-tooltip.mapTooltip {
    width: max-content;
    max-width: 260px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: rgba(11, 18, 40, 0.94);
    color: #fff;
    font: 700 12px/1.3 var(--font);
    white-space: normal;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}

.leaflet-tooltip-top.mapTooltip::before {
    border-top-color: rgba(11, 18, 40, 0.94);
}

/* Popup */
/* El aire va como relleno de la caja: con margen en el contenido, los márgenes se salían (colapso) */
.mapPopupWrap .leaflet-popup-content-wrapper {
    padding: 20px 20px 18px;
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--sh-4);
    transform-origin: 50% 100%;
    animation: mapPopupIn .28s cubic-bezier(.2, .9, .3, 1.2) both;
}

.mapPopupWrap .leaflet-popup-tip {
    background: var(--surface);
    box-shadow: none;
}

.mapPopupWrap .leaflet-popup-content {
    margin: 0;
    font-family: var(--font);
}

.mapPopupWrap a.leaflet-popup-close-button {
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-subtle);
    font: 400 20px/26px var(--font);
    transition: background-color var(--dur-2) ease, color var(--dur-2) ease;
}

    .mapPopupWrap a.leaflet-popup-close-button:hover {
        background: var(--surface-3);
        color: var(--text);
    }

@keyframes mapPopupIn {
    from {
        opacity: 0;
        translate: 0 8px;
        scale: .96;
    }

    to {
        opacity: 1;
        translate: 0 0;
        scale: 1;
    }
}

.mapPopup__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--st) 45%, transparent);
    background: color-mix(in srgb, var(--st) 18%, var(--surface));
    color: var(--text);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .02em;
}

    .mapPopup__status::before {
        content: "";
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--st);
    }

.mapPopup__title {
    margin: 12px 28px 4px 0;
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
}

.mapPopup__dev {
    margin-bottom: 12px;
    color: var(--text-subtle);
    font-size: 12.5px;
    font-weight: 600;
}

.mapPopup__row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}

    .mapPopup__row i {
        width: 14px;
        margin-top: 2px;
        color: var(--text-subtle);
        text-align: center;
    }

.mapPopup__track {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 14px 0 4px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.mapPopup__step {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--text-subtle);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
}

    .mapPopup__step i {
        display: block;
        height: 6px;
        border-radius: 999px;
        background: var(--surface-3);
    }

    .mapPopup__step.is-on {
        color: var(--text);
    }

        .mapPopup__step.is-on i {
            background: var(--st);
        }

    .mapPopup__step.is-current i {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--st) 28%, transparent);
    }

.mapPopup__note {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--st-previos) 18%, var(--surface));
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.mapPopup__actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.leaflet-container .mapPopup__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: 700 13px var(--font);
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur-2) ease, transform var(--dur-2) ease, box-shadow var(--dur-2) ease;
}

    .leaflet-container .mapPopup__btn:hover {
        transform: translateY(-1px);
        box-shadow: var(--sh-2);
    }

.leaflet-container .mapPopup__btn--primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

:root[data-theme="dark"] .leaflet-container .mapPopup__btn--primary {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
}

/* Enfoque de un proyecto ("Ver en el mapa" / clic en tarjeta) */
.mapPinWrap,
.mapClusterWrap {
    transition: opacity .45s ease, filter .45s ease;
}

#map.is-focusing .mapPinWrap:not(:has(.is-selected)),
#map.is-focusing .mapClusterWrap {
    opacity: .3;
    filter: saturate(.4);
}

.mapFocusWrap {
    background: none;
    border: 0;
    pointer-events: none;
}

/* Ondas sobre el suelo (elipses) con el color de la etapa */
.mapFocus {
    position: relative;
    display: block;
    width: 160px;
    height: 160px;
    transform: scaleY(.55);
}

    .mapFocus i {
        position: absolute;
        inset: 0;
        border: 3px solid var(--pin);
        border-radius: 50%;
        background: color-mix(in srgb, var(--pin) 30%, transparent);
        box-shadow: 0 0 18px color-mix(in srgb, var(--pin) 55%, transparent);
        opacity: 0;
        transform: scale(.08);
        animation: mapFocusPing 1.7s cubic-bezier(.15, .7, .3, 1) forwards;
    }

        .mapFocus i:nth-child(2) {
            animation-delay: .3s;
        }

        .mapFocus i:nth-child(3) {
            animation-delay: .6s;
        }

@keyframes mapFocusPing {
    0% {
        opacity: .95;
        transform: scale(.08);
    }

    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* Rebote del pin al llegar */
.mapPin.is-arriving svg {
    animation: mapPinArrive .9s var(--ease-spring) both;
}

@keyframes mapPinArrive {
    0% {
        translate: 0 -34px;
        scale: .9 1.12;
    }

    40% {
        translate: 0 0;
        scale: 1.18 .82;
    }

    62% {
        translate: 0 -10px;
        scale: .96 1.05;
    }

    80% {
        translate: 0 0;
        scale: 1.04 .96;
    }

    100% {
        translate: 0 0;
        scale: 1;
    }
}

/* Conteo + leyenda interactiva (filtra por estado dentro del mapa) */
.mapInfo {
    max-width: calc(100vw - 120px);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    backdrop-filter: blur(8px);
    box-shadow: var(--sh-3);
    color: var(--text);
    font-family: var(--font);
    transition: opacity .25s ease, translate .25s ease;
}

    .mapInfo.is-hidden {
        opacity: 0;
        translate: 0 8px;
        pointer-events: none;
    }

.mapInfo__count {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
}

    .mapInfo__count strong {
        color: var(--text);
        font-size: 15px;
        font-weight: 800;
    }

.mapInfo__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mapChip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border: 1px solid color-mix(in srgb, var(--st) 45%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--st) 14%, var(--surface));
    color: var(--text);
    font: 700 12px var(--font);
    cursor: pointer;
    transition: opacity .2s ease, background-color .2s ease, transform .15s ease;
}

    .mapChip:hover {
        transform: translateY(-1px);
    }

.mapChip__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--st);
    box-shadow: 0 0 0 2px var(--surface);
}

.mapChip__n {
    color: var(--text-muted);
    font-weight: 800;
}

.mapChip.is-off {
    opacity: .5;
    border-color: var(--border);
    background: var(--surface-2);
}

    .mapChip.is-off .mapChip__dot {
        background: var(--border-strong);
    }

    .mapChip.is-off .mapChip__label {
        text-decoration: line-through;
    }

/* Estado vacío / cargando sobre el mapa */
.mapOverlay {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 16px;
    background: radial-gradient(ellipse at center, color-mix(in srgb, var(--bg) 60%, transparent), transparent 70%);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s;
}

    .mapOverlay.is-visible {
        opacity: 1;
        visibility: visible;
    }

.mapOverlay__card {
    max-width: 360px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: var(--sh-4);
    color: var(--text);
    text-align: center;
    pointer-events: auto;
    translate: 0 10px;
    transition: translate .35s cubic-bezier(.2, .9, .3, 1.2);
}

.mapOverlay.is-visible .mapOverlay__card {
    translate: 0 0;
}

.mapOverlay__icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 16px;
    background: var(--brand-soft);
    color: var(--brand-accent);
    font-size: 22px;
}

.mapOverlay.is-loading .mapOverlay__icon i {
    animation: spin 1s linear infinite;
}

.mapOverlay__title {
    font-size: 17px;
    font-weight: 800;
}

.mapOverlay__text {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

.mapOverlay__btn {
    margin: 14px auto 0;
}

    .mapOverlay__btn[hidden] {
        display: none;
    }

/* Aviso breve dentro del mapa */
.mapNotice {
    position: absolute;
    top: 14px;
    left: 50%;
    z-index: 1001;
    max-width: calc(100% - 140px);
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(11, 18, 40, 0.94);
    color: #fff;
    font: 700 12.5px/1.3 var(--font);
    text-align: center;
    box-shadow: var(--sh-3);
    pointer-events: none;
    opacity: 0;
    translate: -50% -8px;
    transition: opacity .25s ease, translate .25s ease;
}

    .mapNotice.is-visible {
        opacity: 1;
        translate: -50% 0;
    }

/* Ubicación del usuario */
.mapUser {
    display: block;
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #2563eb;
    animation: mapUserPulse 2s ease-out infinite;
}

@keyframes mapUserPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    }

    100% {
        box-shadow: 0 0 0 16px rgba(37, 99, 235, 0), 0 2px 6px rgba(0, 0, 0, 0.3);
    }
}

/* Pantalla completa */
.panel--map:fullscreen {
    border-radius: 0;
}

/* Indicador "Ubicando en el mapa…" */
.mapBusy {
    position: absolute;
    left: 50%;
    bottom: 18px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    box-shadow: var(--sh-3);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    translate: -50% 0;
    animation: popIn var(--dur-3) var(--ease-spring) both;
}

    .mapBusy[hidden] {
        display: none;
    }

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--text) 20%, transparent);
    border-top-color: var(--text);
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Transiciones de vista (View Transitions API) ---------- */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 260ms;
    animation-timing-function: var(--ease-out);
}

/* Cambio de tema: revelado circular (la animación la define app.js) */
html.theme-vt::view-transition-old(root),
html.theme-vt::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

html.theme-vt::view-transition-new(root) {
    z-index: 2;
}

/* =========================================================
   Responsive
========================================================= */
@media (max-width: 1180px) {
    .filters__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .field--search {
        grid-column: 1 / -1;
    }

    .filters__actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 1024px) {
    /* Mixto en tablet/móvil: mapa arriba (fijo) y lista debajo con el scroll de la página */
    .layout[data-view="split"] {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        height: auto;
        min-height: 0;
    }

        .layout[data-view="split"] .panel--map {
            position: sticky;
            top: var(--sticky-offset);
            z-index: 5;
            order: -1;
            height: 44dvh;
            min-height: 300px;
        }

        .layout[data-view="split"] .panel--map .panel__header {
            display: none;
        }

        .layout[data-view="split"] .panel__body {
            overflow: visible;
        }
}

@media (max-width: 720px) {
    :root {
        --topbar-h: 58px;
    }

    .brand__logo {
        height: 30px;
    }

    .live__text {
        display: none;
    }

    .live {
        padding: 8px;
    }

    .hero__inner {
        padding-block: 22px 40px;
    }

    .hero__lead br {
        display: none;
    }

    .filters__card {
        padding: 12px;
    }

    .filters__grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* Distrito ocupa la fila completa (admite varios); Tipo y Estado van lado a lado */
    .filters__grid .field:nth-child(2) {
        grid-column: 1 / -1;
    }

    .filters__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .filters__bar {
        flex-direction: column;
        align-items: stretch;
    }

    .segmented {
        width: 100%;
    }

    .cards {
        padding: 12px;
    }

    .panel__header,
    .panel__footer {
        padding-inline: 14px;
    }

    .facts {
        grid-template-columns: 1fr;
    }

    /* Detalle como hoja inferior */
    .drawer__panel {
        top: auto;
        bottom: 0;
        width: 100%;
        height: auto;
        max-height: 92dvh;
        border-radius: 22px 22px 0 0;
        transform: translateY(105%);
        transition-duration: 460ms;
    }

    .drawer.is-open .drawer__panel {
        transform: translateY(0);
    }

    .drawer__handle {
        display: block;
        width: 44px;
        height: 5px;
        margin: 10px auto 0;
        border-radius: 99px;
        background: var(--border-strong);
    }

    .drawer__header {
        padding: 12px 18px 14px;
    }

    .drawer__title {
        font-size: 19px;
        padding-right: 112px;
    }

    .drawer__content {
        padding: 16px 18px 22px;
    }

    .drawer__footer {
        padding-inline: 18px;
    }

    .fab--top {
        right: 19px;
        bottom: 78px;
    }

    .toasts {
        bottom: 84px;
    }

    .mapChip__label {
        display: none;
    }

    .mapInfo {
        padding: 8px 10px;
    }

    .mapInfo__count {
        margin-bottom: 6px;
        font-size: 12px;
    }

    .splash__pct {
        font-size: 52px;
    }
}

/* =========================================================
   Movimiento reducido: sin animaciones decorativas
========================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }

    .live[data-state="ok"] .live__dot::after,
    .tl.is-current .tl__dot::after,
    .mapPin.is-selected::after,
    .mapUser,
    .sp-trolley,
    .sp-hook,
    .sp-light,
    .card--skeleton::after {
        animation: none !important;
    }

    /* La protección de la pantalla de carga sigue activa */
    .splash {
        animation: splashFailsafe .4s ease 14s forwards !important;
    }
}

/* =========================================================
   Filtros fijos al hacer scroll
   Al quedar arriba, las etiquetas pasan bajo la barra superior (con el propio scroll)
   y el fondo de la tarjeta se recorta hasta los campos. Nada cambia de tamaño: así la
   página no se reacomoda en el umbral y la barra no parpadea.
========================================================= */
.filters {
    position: sticky;
    top: calc(var(--topbar-h) - var(--filters-tuck, 0px));
    z-index: 1000;
}

/* El fondo de la tarjeta es una capa aparte para poder recortarlo sin tocar el contenido */
.filters__card {
    position: relative;
    isolation: isolate;
    border: 0;
    background: none;
    box-shadow: none;
}

    .filters__card::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        border: 1px solid var(--border);
        border-radius: var(--r-lg);
        background: var(--surface);
        box-shadow: var(--sh-3);
        transition: top var(--dur-3) var(--ease-out), bottom var(--dur-3) var(--ease-out), border-radius var(--dur-3) ease, box-shadow var(--dur-3) ease;
    }

.filters.is-stuck .filters__card::before {
    top: var(--filters-tuck, 0px);
    bottom: var(--filters-clip, 0px);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    box-shadow: 0 18px 36px -16px rgba(15, 23, 42, 0.4);
}

.filters__bar {
    transition: opacity var(--dur-2) ease, visibility var(--dur-2);
}

/* Fija solo muestra los campos y los botones; el resto deja pasar los clics */
.filters.is-stuck {
    pointer-events: none;
}

    .filters.is-stuck .filters__grid {
        pointer-events: auto;
    }

    .filters.is-stuck .filters__bar {
        opacity: 0;
        visibility: hidden;
    }

/* El mapa crea su propio contexto: sus controles no pasan por encima de los filtros */
.panel--map {
    isolation: isolate;
}

/* El área de resultados recibe el foco del enlace "Saltar a los resultados": sin recuadro */
#resultados:focus {
    outline: none;
}

/* =========================================================
   Selectores tipo Select2 (Tom Select con el estilo del portal)
========================================================= */
.ts-wrapper {
    --ts-pr-caret: 30px;
    --ts-pr-min: 12px;
    position: relative;
    min-width: 0;
}

    .ts-wrapper .ts-control,
    .ts-wrapper.single.input-active .ts-control {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 5px;
        min-height: 44px;
        padding: 6px 12px;
        border: 1px solid var(--border-strong);
        border-radius: 12px;
        background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235b6680' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
        color: var(--text);
        font: 600 14.5px/1.3 var(--font);
        box-shadow: none;
        cursor: pointer;
        transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) ease, background-color var(--dur-2) ease;
    }

    .ts-wrapper:hover .ts-control {
        border-color: color-mix(in srgb, var(--brand-accent) 40%, var(--border-strong));
    }

    .ts-wrapper.focus .ts-control {
        border-color: var(--brand-accent);
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-accent) 16%, transparent);
    }

    .ts-wrapper.dropdown-active .ts-control {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 6.5 6 1.5l5 5' fill='none' stroke='%231f4cff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    }

    .ts-wrapper.is-set .ts-control {
        border-color: color-mix(in srgb, var(--brand-accent) 55%, var(--border-strong));
        background-color: var(--brand-soft);
    }

.ts-control > input {
    color: var(--text);
    font: inherit;
    min-width: 6rem;
}

    .ts-control > input::placeholder {
        color: var(--text-subtle);
        font-weight: 500;
    }

.ts-wrapper.single .ts-control > .item {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Distritos elegidos: el primero como chip y "+N" (la barra de abajo los muestra todos) */
.ts-wrapper.multi .ts-control {
    flex-wrap: nowrap;
}

    .ts-wrapper.multi .ts-control > .item ~ .item {
        display: none;
    }

    .ts-wrapper.multi .ts-control > input {
        order: 2;
        min-width: 3rem;
    }

    .ts-wrapper.multi .ts-control[data-extra]::after {
        content: attr(data-extra);
        order: 1;
        flex-shrink: 0;
        padding: 3px 9px;
        border-radius: 999px;
        background: var(--brand-accent);
        color: #fff;
        font-size: 12px;
        font-weight: 800;
        animation: popIn var(--dur-3) var(--ease-spring);
    }

/* Chip del distrito dentro del control */
.ts-wrapper.multi .ts-control > div.item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 3px 3px 3px 10px;
    border: 1px solid color-mix(in srgb, var(--brand-accent) 35%, transparent);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 700;
    min-width: 0;
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    animation: popIn var(--dur-3) var(--ease-spring) both;
}

/* El nombre se recorta con "…" sin empujar la × ni el "+N" */
.ts-control .item .pk-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-wrapper.plugin-remove_button .item .remove,
.ts-wrapper.multi .ts-control[data-extra]::after {
    flex-shrink: 0;
}

/* Con distritos elegidos y sin foco, el cuadro de búsqueda no ocupa espacio */
.ts-wrapper.multi.has-items:not(.focus) .ts-control > input {
    flex: 0 0 0;
    min-width: 0;
    width: 0 !important;
    padding: 0;
}

    .ts-wrapper.multi .ts-control > div.item.active {
        background: color-mix(in srgb, var(--brand-accent) 18%, var(--surface));
        color: var(--text);
    }

.ts-wrapper.plugin-remove_button .item .remove {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-left: 2px;
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    color: var(--text-subtle);
    font-size: 15px;
    line-height: 1;
    text-decoration: none;
    transition: background-color var(--dur-2) ease, color var(--dur-2) ease;
}

    .ts-wrapper.plugin-remove_button .item .remove:hover {
        background: color-mix(in srgb, var(--brand-accent) 18%, transparent);
        color: var(--text);
    }

.ts-dropdown {
    min-width: 270px;
    z-index: 1300;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: 600 14px/1.3 var(--font);
    box-shadow: var(--sh-4);
    overflow: hidden;
    transform-origin: 50% 0;
    animation: pickerIn .18s var(--ease-out);
}

@keyframes pickerIn {
    from {
        opacity: 0;
        translate: 0 -6px;
        scale: .98;
    }
}

.ts-dropdown .ts-dropdown-content {
    max-height: 320px;
    padding: 6px;
    overscroll-behavior: contain;
}

.ts-dropdown .option,
.ts-dropdown .no-results {
    padding: 9px 10px;
    border-radius: 10px;
    opacity: 1;
}

.ts-dropdown .option {
    cursor: pointer;
    transition: background-color var(--dur-1) ease;
}

    .ts-dropdown .option.active {
        background: var(--brand-soft);
        color: var(--text);
    }

    .ts-dropdown .option.selected {
        font-weight: 800;
    }

.ts-dropdown [data-disabled],
.ts-dropdown [data-disabled] [data-selectable].option {
    opacity: .4;
    cursor: not-allowed;
}

.ts-dropdown .no-results {
    color: var(--text-subtle);
    font-weight: 600;
}

.pk-opt {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pk-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pk-count {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-subtle);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.option.active .pk-count {
    background: var(--surface);
}

.pk-check {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    background: var(--surface);
    transition: background-color var(--dur-2) ease, border-color var(--dur-2) ease;
}

.option.selected .pk-check {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
}

    .option.selected .pk-check::after {
        content: "";
        width: 9px;
        height: 5px;
        border: 2px solid #fff;
        border-top: 0;
        border-right: 0;
        rotate: -45deg;
        translate: 0 -1px;
        animation: popIn var(--dur-2) var(--ease-spring);
    }

.pk-dot {
    display: inline-block;
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--st);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--st) 22%, transparent);
}

.ts-control .pk-dot {
    margin-right: 9px;
}

/* =========================================================
   Detalle: avance general en 3 bloques (una por etapa)
========================================================= */
.overall {
    display: grid;
    gap: 9px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.overall__head {
    display: grid;
    gap: 2px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
}

.overall__stage {
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
}

.overall__bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    height: 10px;
}

.overall__seg {
    position: relative;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

    .overall__seg::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: var(--c);
        transform-origin: 0 50%;
        transform: scaleX(var(--fill, 0));
        animation: barFill 520ms cubic-bezier(.4, 0, .2, 1) 380ms both;
    }

    /* Se llenan en orden, como el avance real */
    .overall__seg:nth-child(2)::after {
        animation-delay: 620ms;
    }

    .overall__seg:nth-child(3)::after {
        animation-delay: 860ms;
    }

.overall__labels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-subtle);
}

    .overall__labels span {
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

        .overall__labels span::before {
            content: "";
            flex-shrink: 0;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--border-strong);
        }

        .overall__labels span.is-on {
            color: var(--text);
        }

            .overall__labels span.is-on::before {
                background: var(--c);
            }

/* =========================================================
   Barras de desplazamiento finas y bloqueo del fondo con el detalle abierto
========================================================= */
html {
    scrollbar-gutter: stable;
}

    html.has-drawer {
        overflow: hidden;
    }

* {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--text) 24%, transparent) transparent;
}

/* Navegadores sin scrollbar-color (Safari antiguo) */
@supports not (scrollbar-color: auto) {
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    ::-webkit-scrollbar-thumb {
        border: 3px solid transparent;
        border-radius: 999px;
        background: color-mix(in srgb, var(--text) 24%, transparent) padding-box;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* Sombras suaves arriba/abajo del detalle que indican que hay más contenido */
.drawer__content {
    background:
        linear-gradient(var(--surface) 30%, transparent) top / 100% 36px no-repeat local,
        linear-gradient(transparent, var(--surface) 70%) bottom / 100% 36px no-repeat local,
        radial-gradient(farthest-side at 50% 0, rgba(15, 23, 42, 0.14), transparent) top / 100% 12px no-repeat scroll,
        radial-gradient(farthest-side at 50% 100%, rgba(15, 23, 42, 0.14), transparent) bottom / 100% 12px no-repeat scroll,
        var(--surface);
    scrollbar-gutter: stable;
}

/* =========================================================
   WhatsApp: ondas, saludo tipo chat y etiqueta al pasar el cursor
========================================================= */
.wa {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

    .wa > * {
        pointer-events: auto;
    }

.wa__btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 58px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2bdc70, #128c7e);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 12px 28px -8px rgba(18, 140, 126, 0.6);
    transition: transform .35s var(--ease-spring), box-shadow .35s ease;
    animation: waIn .8s var(--ease-spring) 1.2s both;
}

    .wa__btn:hover,
    .wa__btn:focus-visible {
        transform: translateY(-3px);
        box-shadow: 0 18px 36px -10px rgba(18, 140, 126, 0.7);
    }

    /* Ondas que se expanden alrededor del botón */
    .wa__btn::before,
    .wa__btn::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        border: 2px solid #25d366;
        pointer-events: none;
        animation: waRipple 2.8s ease-out 2s infinite;
    }

    .wa__btn::after {
        animation-delay: 3.4s;
    }

.wa__icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    font-size: 30px;
    animation: waWiggle 6s ease-in-out 3s infinite;
}

.wa__label {
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    font-size: 14.5px;
    font-weight: 700;
    white-space: nowrap;
    transition: max-width .45s var(--ease-out), opacity .3s ease, padding .45s var(--ease-out);
}

.wa__btn:hover .wa__label,
.wa__btn:focus-visible .wa__label {
    max-width: 140px;
    padding-right: 22px;
    opacity: 1;
}

@keyframes waIn {
    from {
        opacity: 0;
        scale: .3;
        rotate: -90deg;
    }

    to {
        opacity: 1;
        scale: 1;
        rotate: 0deg;
    }
}

@keyframes waRipple {
    from {
        opacity: .65;
        scale: 1;
    }

    to {
        opacity: 0;
        scale: 1.55;
    }
}

@keyframes waWiggle {
    0%, 84%, 100% {
        rotate: 0deg;
        scale: 1;
    }

    86% {
        rotate: -16deg;
        scale: 1.12;
    }

    89% {
        rotate: 13deg;
        scale: 1.12;
    }

    92% {
        rotate: -8deg;
    }

    95% {
        rotate: 5deg;
    }
}

/* Saludo */
.wa__bubble {
    position: relative;
    width: min(290px, calc(100vw - 40px));
    padding: 12px 40px 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px 18px 4px 18px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--sh-4);
    cursor: pointer;
    opacity: 0;
    translate: 0 12px;
    scale: .94;
    transform-origin: 100% 100%;
    transition: opacity .35s ease, translate .45s var(--ease-spring), scale .45s var(--ease-spring);
}

    .wa__bubble.is-visible {
        opacity: 1;
        translate: 0 0;
        scale: 1;
    }

.wa__from {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
    color: #075e54; /* verde azulado de WhatsApp con contraste AA sobre blanco */
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
}

:root[data-theme="dark"] .wa__from {
    color: #4fe08c;
}

.wa__online {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}

.wa__title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.wa__text {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

.wa__msg {
    display: none;
}

.wa__bubble.is-typed .wa__msg {
    display: block;
    animation: riseIn .35s var(--ease-out) both;
}

.wa__bubble.is-typed .wa__typing {
    display: none;
}

.wa__typing {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--surface-3);
}

    .wa__typing span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--text-subtle);
        animation: waTyping 1s ease-in-out infinite;
    }

        .wa__typing span:nth-child(2) {
            animation-delay: .15s;
        }

        .wa__typing span:nth-child(3) {
            animation-delay: .3s;
        }

@keyframes waTyping {
    0%, 60%, 100% {
        translate: 0 0;
        opacity: .5;
    }

    30% {
        translate: 0 -4px;
        opacity: 1;
    }
}

.wa__close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-subtle);
    font-size: 13px;
    transition: background-color var(--dur-2) ease, color var(--dur-2) ease;
}

    .wa__close:hover {
        background: var(--surface-3);
        color: var(--text);
    }

/* "Volver arriba" encima del botón de WhatsApp; se aparta mientras está el saludo */
.fab--top {
    right: 28px;
    bottom: 94px;
}

.wa:has(.wa__bubble.is-visible) + .fab--top {
    opacity: 0;
    pointer-events: none;
}

/* =========================================================
   Pie de página
========================================================= */
.footer {
    margin-top: auto;
    padding: 0;
    background: linear-gradient(180deg, #001976 0%, var(--brand-strong) 100%);
    color: rgba(255, 255, 255, 0.78);
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
}

.footer__main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 22px 40px;
    padding-block: 26px 22px;
}

/* El botón de WhatsApp queda fijo abajo a la derecha: los enlaces no se meten debajo */
@media (min-width: 721px) and (max-width: 1659px) {
    .footer__main {
        padding-right: 92px;
    }
}

.footer__brand {
    display: flex;
    align-items: center;
    gap: 18px;
}

    .footer__brand img {
        height: 34px;
        width: auto;
        padding-right: 18px;
        border-right: 1px solid rgba(255, 255, 255, 0.2);
    }

    .footer__brand p {
        max-width: 30ch;
        font-size: 13.5px;
        line-height: 1.4;
        color: rgba(255, 255, 255, 0.82);
    }

.footer__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

    .footer__nav a {
        display: inline-flex;
        align-items: center;
        gap: 9px;
        padding: 9px 14px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.06);
        color: #fff;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        transition: background-color var(--dur-2) ease, border-color var(--dur-2) ease, transform var(--dur-2) var(--ease-spring);
    }

        .footer__nav a:hover {
            transform: translateY(-2px);
            border-color: rgba(255, 255, 255, 0.3);
            background: rgba(255, 255, 255, 0.12);
        }

        .footer__nav a i {
            color: var(--brand-green);
        }

.footer__bottom {
    padding: 14px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
}

@media (max-width: 720px) {
    .filters {
        position: static;
    }

    .wa {
        right: 16px;
        bottom: 16px;
    }

    .wa__btn,
    .wa__icon {
        height: 54px;
    }

    .wa__icon {
        width: 54px;
        font-size: 28px;
    }

    .fab--top {
        right: 20px;
        bottom: 82px;
    }

    .footer__main {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer__brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

        .footer__brand img {
            padding-right: 0;
            border-right: 0;
        }
}

@media (max-width: 720px) {
    /* Ficha compacta: en el teléfono el mapa es bajo y el pin debe verse debajo de ella */
    .mapPopupWrap .leaflet-popup-content-wrapper {
        padding: 14px 16px;
    }

    .mapPopup__title {
        margin-top: 8px;
        font-size: 15px;
    }

    .mapPopup__dev {
        margin-bottom: 6px;
    }

    .mapPopup__row--place {
        display: none;
    }

    .mapPopup__track {
        margin-top: 10px;
        padding-top: 10px;
    }

    .mapPopup__actions {
        margin-top: 12px;
    }

    .leaflet-container .mapPopup__btn {
        padding: 9px 10px;
    }

    #map .leaflet-control {
        transition: opacity var(--dur-2) ease;
    }

    #map.has-popup .leaflet-control:not(.leaflet-control-attribution) {
        opacity: 0;
        pointer-events: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wa__btn::before,
    .wa__btn::after,
    .wa__icon,
    .wa__typing span {
        animation: none !important;
    }
}
