@charset "UTF-8";

/* Tipografías del proyecto (si no, todo cae a Georgia).
   Lo ideal es además un <link> en el <head>; ver instrucciones. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500&family=Spectral:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
    --pergamino: #efe6cf;
    --pergamino-2: #e7dcc0;
    --papel: #fbf7ec;
    --papel-2: #fffdf7;
    --papel-2-transp: rgba(255, 253, 247, .52);
    --papel-borde: #ddcfa9;
    --tinta: #2c2218;
    --tinta-suave: #4b463f;
    --oro: #c8860d;
    --oro-claro: #f5c842;
    --oro-oscuro: #7a6010;
    --rojo: #9d2f22;
    --rojo-claro: #c0432f;
    /* Escala coroplética secuencial (misma familia térrea ocre→siena→sombra
       tostada). El rojo queda reservado SOLO para selección/estado activo. */
    --mapa-1: rgba(196, 150, 64, .34);
    --mapa-2: rgba(178, 120, 42, .52);
    --mapa-3: rgba(150, 92, 30, .70);
    --mapa-4: rgba(120, 66, 26, .86);
    --sombra: rgba(60, 44, 20, .18);
    --sombra-fuerte: rgba(36, 26, 16, .28);
    --fundacion: #90278f;
    --fundacion-claro: #ab5ba9;
    --fundacion-oscuro: #6c1d6b;
    --cabecera-h: 84px;
    --panel-izq: 240px;
    --panel-der: 390px;
    --r: 6px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: "Spectral", Georgia, serif;
    color: var(--tinta);
    background: radial-gradient(circle at 18% -10%, rgba(245, 200, 66, .12), transparent 45%), radial-gradient(circle at 110% 8%, rgba(157, 47, 34, .08), transparent 40%), var(--pergamino);
    overflow: hidden;
}

    /* Grano de papel envejecido (muy sutil, no interfiere con el ratón) */
    body::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 0;
        pointer-events: none;
        opacity: .05;
        mix-blend-mode: multiply;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    }

a {
    color: var(--oro-oscuro);
    text-decoration: none;
}

    a:hover {
        color: var(--rojo);
    }

h1,
h2,
h3 {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    letter-spacing: .2px;
    margin: 0;
}

button,
input,
select {
    font: inherit;
}

.oculto {
    display: none !important;
}

/* Cabecera compacta */

.cabecera {
    position: relative;
    height: var(--cabecera-h);
    background: var(--pergamino) url("../Imagenes/BannerJuanNegrin.png") center / cover no-repeat;
    color: var(--pergamino);
    border-bottom: 2px solid var(--fundacion);
    box-shadow: 0 2px 14px var(--sombra-fuerte);
}


.cabecera-inner {
    height: 100%;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.marca-kicker {
    display: block;
    font-size: .77rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #90278f;
    opacity: 1;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-weight: bold;
}

.marca-titulo {
    margin-top: 2px;
    font-size: 1.35rem;
    line-height: 1.05;
    color: #77787b;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}

.marca-sub {
    display: none; /* se muestra en pantallas anchas (media query abajo) */
    margin-top: 3px;
    font-size: .72rem;
    color: #c9b489;
    letter-spacing: .02em;
}

.nav {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

/* Zona izquierda: botón Inicio + separador + marca */
.cab-izq {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0; /* permite que la marca recorte sin desbordar */
}

.btn-inicio {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font-family: "Fraunces", Georgia, serif;
    font-size: .82rem;
    font-weight: 600;
    color: var(--fundacion);
    background: var(--papel-2-transp);
    border: 1px solid var(--fundacion);
    border-radius: 999px;
    transition: .15s;
}

    .btn-inicio:hover {
        color: var(--fundacion);
        background: var(--papel-2-transp);
        border-color: var(--fundacion);
        transform: translateY(-1px);
        box-shadow: 0 8px 18px var(--sombra);
    }

    .btn-inicio .btn-inicio-ico {
        font-size: 1.05em;
        line-height: 1;
        transition: transform .15s ease;
    }

    .btn-inicio:hover .btn-inicio-ico {
        transform: translateX(-2px);
    }

.cab-sep {
    flex: 0 0 auto;
    width: 1px;
    height: 38px;
    background: linear-gradient(180deg, transparent, rgba(200,134,13,.55), transparent);
}

.nav {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.nav-link {
    font-family: "Fraunces", Georgia, serif;
    font-size: .9rem;
    font-weight: 600;
    color: var(--fundacion);
    padding: 9px 18px;
    border: 1px solid var(--fundacion);
    letter-spacing: 0.03em;
    border-radius: 999px;
    background: var(--papel-2-transp);
    transition: .15s;
}

    .nav-link:hover {
        color: var(--fundacion);
        border-color: var(--fundacion);
        transform: translateY(-1px);
        box-shadow: 0 8px 18px var(--sombra);
    }

    .nav-link.activo {
        color: #fff;
        background: linear-gradient(180deg, var(--fundacion-claro) 0%, var(--fundacion-oscuro) 100%);
        border-color: var(--fundacion-oscuro);
        box-shadow: 0 6px 13px rgba(144, 39, 143, .35);
    }

        .nav-link.activo:hover {
            border: 1px solid var(--fundacion);
            background: var(--papel-2-transp);
            color: var(--fundacion);
            box-shadow: none;
            transform: translateY(-2px);
        }

/* Estructura principal */

.app-shell {
    height: calc(100vh - var(--cabecera-h));
    display: grid;
    grid-template-columns: clamp(230px, 20vw, var(--panel-izq)) minmax(0, 1fr) clamp(300px, 27vw, var(--panel-der));
    gap: 0;
    overflow: hidden;
}

.panel-geo,
.resultados {
    background: rgba(251, 247, 236, .95);
    border-color: var(--papel-borde);
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.panel-geo {
    border-right: 1px solid var(--papel-borde);
    box-shadow: 4px 0 18px rgba(60, 44, 20, .08);
}

.resultados {
    border-left: 1px solid var(--papel-borde);
    box-shadow: -4px 0 18px rgba(60, 44, 20, .08);
}

/* Panel izquierdo */

.panel-geo-cabecera,
.resultados-cabecera {
    padding: 16px 16px 13px;
    border-bottom: 1px solid var(--papel-borde);
    background: linear-gradient(180deg, rgba(255, 253, 247, .98), rgba(245, 236, 216, .92));
}

.panel-kicker {
    display: block;
    margin-bottom: 2px;
    font-size: .65rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--tinta-suave);
    font-weight: 600;
}

.panel-geo-cabecera h2,
.resultados-cabecera h2 {
    font-size: 1.1rem;
    line-height: 1.1;
}

.panel-geo-cabecera p {
    margin: 7px 0 0;
    color: var(--tinta-suave);
    font-size: .84rem;
    line-height: 1.25;
}

.lista-geo {
    height: calc(100% - 96px);
    overflow: auto;
    padding: 10px;
}

.geo-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    padding: 9px 10px;
    border: 1px solid rgba(221, 207, 169, .75);
    border-radius: var(--r);
    background: rgba(255, 253, 247, .72);
    color: var(--tinta);
    cursor: pointer;
    text-align: left;
    transition: .15s ease;
}

    .geo-item:hover {
        border-color: var(--fundacion);
        background: #fff8e4;
        transform: translateX(2px);
    }

    .geo-item.activo {
        border-color: var(--rojo);
        background: rgba(157, 47, 34, .08);
    }

.geo-reset {
    margin-bottom: 12px;
    background: #eadfbe;
    border-color: #c9b474;
}

.geo-nombre {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .92rem;
}

.geo-num {
    flex: 0 0 auto;
    min-width: 32px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--oro-claro);
    color: #2c2218;
    font-size: .78rem;
    text-align: center;
    font-weight: 700;
}

.geo-vacio,
.vacio {
    padding: 14px;
    border: 1px dashed var(--papel-borde);
    border-radius: var(--r);
    color: var(--tinta-suave);
    background: rgba(255, 253, 247, .58);
    font-style: italic;
}

/* Zona central */

.zona-mapa {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    background: linear-gradient(rgba(255, 253, 247, .30), rgba(255, 253, 247, .12)), var(--pergamino);
    position: relative;
}

.barra-filtros {
    z-index: 5;
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: flex-end;
    background: rgba(251, 247, 236, .96);
    border-bottom: 1px solid var(--papel-borde);
    box-shadow: 0 4px 16px rgba(60, 44, 20, .10);
    overflow: hidden;
}

    /* Cada control crece/encoge y, cuando no cabe, salta de línea
       en lugar de desbordarse sobre el panel de documentos. */
    .barra-filtros > .campo {
        flex: 1 1 140px;
        min-width: 130px;
    }

    .barra-filtros > .campo-busqueda {
        flex: 3 1 220px;
        min-width: 190px;
    }

    .barra-filtros > .check,
    .barra-filtros > .btn-limpiar {
        flex: 0 0 auto;
    }

    /* El campo que contiene el rango de años necesita algo más de sitio */
    .barra-filtros > .campo-anios {
        flex: 1 1 170px;
        min-width: 160px;
    }

.campo label {
    display: block;
    margin-bottom: 3px;
    font-size: .62rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--tinta-suave);
    font-weight: 700;
}

.campo input[type="text"],
.campo select,
.rango-num {
    width: 100%;
    height: 34px;
    padding: 6px 8px;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    background: var(--papel-2);
    color: var(--tinta);
    font-size: .88rem;
}

    .campo input:focus,
    .campo select:focus,
    .rango-num:focus {
        outline: none;
        border-color: var(--fundacion);
        box-shadow: 0 0 0 2px #90278f29
    }

.rango {
    display: flex;
    align-items: center;
    gap: 5px;
}

.rango-num {
    text-align: center;
    padding: 5px 4px;
}

.rango-sep {
    color: var(--tinta-suave);
}

.rango-val {
    color: var(--tinta-suave);
    letter-spacing: 0;
    text-transform: none;
    font-weight: 700;
}

.check {
    height: 34px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    background: var(--papel-2);
    color: var(--tinta-suave);
    font-size: .84rem;
    white-space: nowrap;
}

    .check input {
        accent-color: var(--rojo);
    }

.btn-limpiar {
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--oro);
    border-radius: var(--r);
    background: #eadfbe;
    color: var(--tinta);
    cursor: pointer;
    font-weight: 700;
    font-size: .84rem;
}

    .btn-limpiar:hover {
        background: var(--oro-claro);
    }

.mapa-toolbar {
    z-index: 4;
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: rgba(239, 230, 207, .58);
    border-bottom: 1px solid rgba(221, 207, 169, .75);
}

.miga {
    font-size: .9rem;
    color: var(--tinta-suave);
}

    .miga a {
        font-weight: 700;
        color: var(--fundacion);
    }

    .miga span::before {
        content: "›";
        margin: 0 8px;
        color: var(--tinta-suave);
    }

.leyenda-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--tinta-suave);
    font-size: .72rem;
}

    .leyenda-mini em {
        font-style: normal;
        white-space: nowrap;
    }

    .leyenda-mini span {
        width: 18px;
        height: 8px;
        border: 1px solid rgba(122, 96, 16, .25);
        display: block;
    }

        .leyenda-mini span:nth-child(2) {
            background: var(--mapa-1);
        }

        .leyenda-mini span:nth-child(3) {
            background: var(--mapa-2);
        }

        .leyenda-mini span:nth-child(4) {
            background: var(--mapa-3);
        }

        .leyenda-mini span:nth-child(5) {
            background: var(--mapa-4);
        }

        .leyenda-mini span:nth-child(6) {
            background: var(--mapa-4);
        }

.mapa-stage {
    min-height: 0;
    position: relative;
    overflow: hidden;
}

    .mapa-stage::after {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        background: radial-gradient(ellipse at center, transparent 58%, rgba(60, 44, 20, .10) 100%);
    }

.mapa-wrap {
    position: absolute;
    inset: 0;
    padding: 12px;
}

.mapa-svg {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .mapa-svg svg {
        width: 100%;
        height: 100%;
        max-height: 100%;
        display: block;
        filter: drop-shadow(0 6px 12px rgba(60, 44, 20, .16));
        transform-origin: center center;
        transition: transform .18s ease;
        will-change: transform;
    }

.mapa-stage.mapa-con-zoom {
    cursor: grab;
    touch-action: none;
}

.mapa-stage.mapa-arrastrando {
    cursor: grabbing;
}

    .mapa-stage.mapa-arrastrando .mapa-svg svg {
        transition: none;
    }

.mapa-zoom {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 8;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 7px;
    border: 1px solid rgba(122, 96, 16, .24);
    border-radius: 999px;
    background: rgba(255, 253, 247, .88);
    box-shadow: 0 8px 22px rgba(60, 44, 20, .18);
    backdrop-filter: blur(6px);
}

.mapa-zoom-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(122, 96, 16, .22);
    border-radius: 50%;
    background: var(--papel-2);
    color: var(--tinta);
    font-size: 1.28rem;
    line-height: 1;
    font-weight: 800;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 7px rgba(60, 44, 20, .10);
}

.mapa-zoom-btn:hover {
    background: var(--oro-claro);
}

.mapa-zoom-btn:active {
    transform: translateY(1px);
}

.mapa-zoom-reset {
    font-size: 1rem;
}

.mapa-zoom-btn[disabled] {
    opacity: .42;
    cursor: default;
    pointer-events: none;
}

    /* SVG */

    .mapa-svg path {
        vector-effect: non-scaling-stroke;
        transition: fill .16s ease, opacity .16s ease, stroke .16s ease, transform .16s ease;
    }

        path.provincia,
        .mapa-svg path[id] {
            stroke: rgba(44, 34, 24, .48);
            stroke-width: .55;
            cursor: pointer;
        }

            path.provincia[data-nivel="0"],
            .mapa-svg path[data-nivel-muni="0"] {
                fill: rgba(118, 107, 90, .18) !important;
                opacity: .45;
                cursor: default;
            }

            path.provincia[data-nivel="1"],
            .mapa-svg path[data-nivel-muni="1"] {
                fill: var(--mapa-1) !important;
            }

            path.provincia[data-nivel="2"],
            .mapa-svg path[data-nivel-muni="2"] {
                fill: var(--mapa-2) !important;
            }

            path.provincia[data-nivel="3"],
            .mapa-svg path[data-nivel-muni="3"] {
                fill: var(--mapa-3) !important;
            }

            path.provincia[data-nivel="4"],
            .mapa-svg path[data-nivel-muni="4"] {
                fill: var(--mapa-4) !important;
            }

            path.provincia[data-nivel]:not([data-nivel="0"]):hover,
            .mapa-svg path[data-nivel-muni]:not([data-nivel-muni="0"]):hover {
                stroke: #2c2218;
                stroke-width: 1.2;
                filter: brightness(1.05);
            }

        .mapa-svg path.muni-sel {
            stroke: var(--fundacion) !important;
            stroke-width: 2 !important;
            fill: var(--fundacion) !important;
        }

        /* Marca fija de Gran Canaria (isla, no la provincia): siempre en violeta. */
        .mapa-svg #gran-canaria-highlight {
            fill: var(--fundacion) !important;
            opacity: 1 !important;
        }

.aviso {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, 80%);
    padding: 18px 20px;
    background: var(--papel);
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    box-shadow: 0 8px 28px var(--sombra);
    color: var(--tinta-suave);
}

/* Documentos */

.resultados-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.contador-wrap {
    min-width: 62px;
    padding: 6px 8px;
    text-align: center;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    background: #fff8e4;
}

.contador {
    display: block;
    line-height: 1;
    color: var(--fundacion);
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.35rem;
    font-weight: 700;
}

.contador-wrap small {
    display: block;
    margin-top: 1px;
    color: var(--tinta-suave);
    font-size: .7rem;
}

.lista {
    height: calc(100% - 78px);
    overflow: auto;
    padding: 12px;
}

.tarjeta {
    position: relative;
    margin-bottom: 9px;
    padding: 12px 13px 11px;
    background: rgba(255, 253, 247, .9);
    border: 1px solid rgba(221, 207, 169, .85);
    border-left: 3px solid var(--fundacion);
    border-radius: 0 var(--r) var(--r) 0;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(60, 44, 20, .05);
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}

    .tarjeta:hover {
        border-color: var(--fundacion);
        border-left-color: var(--fundacion-oscuro);
        background: #fff8e4;
        transform: translateX(2px);
        box-shadow: 0 4px 12px rgba(60, 44, 20, .12);
    }

.tarjeta-cod {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    padding: 2px 16px;
    border-radius: 999px;
    background: #eadfbe;
    color: var(--oro-oscuro);
    font-size: .82rem;
    font-weight: 700;
}

.tarjeta-pdf {
    position: absolute;
    top: 11px;
    right: 10px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(157, 47, 34, .10);
    border: 1px solid rgba(157, 47, 34, .42);
    color: var(--rojo);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.tarjeta-tit {
    padding-right: 36px;
    color: var(--tinta);
    font-family: "Fraunces", Georgia, serif;
    font-size: .98rem;
    line-height: 1.18;
}

.tarjeta-meta {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 8px;
    margin-top: 7px;
    color: var(--tinta-suave);
    font-size: .83rem;
    line-height: 1.28;
}

/* Modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.modal-fondo {
    position: absolute;
    inset: 0;
    background: rgba(36, 26, 16, .62);
}

.modal-caja {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(900px, calc(100vw - 44px));
    max-height: calc(100vh - 44px);
    overflow: auto;
    padding: 24px;
    background: var(--papel);
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    box-shadow: 0 18px 55px rgba(0, 0, 0, .32);
}

.modal-cerrar {
    position: sticky;
    float: right;
    top: 0;
    width: 34px;
    height: 34px;
    border: 1px solid var(--papel-borde);
    border-radius: 50%;
    background: #fffdf7;
    color: var(--tinta);
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
}

.ficha-cod {
    display: inline-block;
    margin-bottom: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eadfbe;
    color: var(--oro-oscuro);
    font-weight: 700;
}

.ficha-tit {
    margin-bottom: 14px;
    font-size: 1.55rem;
    color: var(--tinta);
}

.ficha-tabla {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
    font-size: .94rem;
}

    .ficha-tabla th,
    .ficha-tabla td {
        padding: 8px 9px;
        border-bottom: 1px solid rgba(221, 207, 169, .8);
        vertical-align: top;
    }

    .ficha-tabla th {
        width: 180px;
        color: var(--tinta-suave);
        text-align: left;
        font-size: .78rem;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

.ficha-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 13px;
    border: 1px solid var(--fundacion-oscuro);
    border-radius: var(--r);
    background: var(--fundacion);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

    .btn:hover {
        color: #fff;
        filter: brightness(.98);
    }

    .btn[disabled] {
        opacity: .55;
        cursor: not-allowed;
    }

    .btn.secundario {
        background: #fffdf7;
        color: var(--fundacion);
        border: 1px solid var(--fundacion);
    }

/* Tooltip */

.tooltip {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    padding: 6px 9px;
    border-radius: var(--r);
    background: rgba(36, 26, 16, .94);
    color: #fff8e4;
    font-size: .82rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .20);
    transition: opacity .08s ease;
}

/* Pie de página */

.pie {
    padding: 10px 18px;
    text-align: center;
    font-size: .76rem;
    color: var(--tinta-suave);
    background: rgba(239, 230, 207, .65);
    border-top: 1px solid var(--papel-borde);
}

/* =========================================================================
   RESPONSIVE — tres niveles
   >1180px : tres columnas (geo · mapa · documentos)
   ≤1180px : dos columnas (mapa arriba a lo ancho; geo y documentos debajo)
   ≤760px  : una columna apilada, la página hace scroll
   ========================================================================= */

/* --- Nivel 2: tablet / portátil estrecho --- */
@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: minmax(300px, 46vh) minmax(0, 1fr);
        grid-template-areas:
            "mapa mapa"
            "geo  docs";
    }

    .zona-mapa {
        grid-area: mapa;
        border-bottom: 1px solid var(--papel-borde);
    }

    .panel-geo {
        grid-area: geo;
        border-right: 1px solid var(--papel-borde);
        box-shadow: none;
    }

    .resultados {
        grid-area: docs;
        border-left: 0;
        box-shadow: none;
    }
}

/* --- Nivel 3: móvil / ventana muy estrecha --- */
@media (max-width: 760px) {
    body {
        overflow: auto;
    }

    .cabecera {
        height: auto;
        min-height: var(--cabecera-h);
    }

    .cabecera-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .app-shell {
        height: auto;
        min-height: calc(100vh - var(--cabecera-h));
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas:
            "mapa"
            "geo"
            "docs";
    }

    .panel-geo,
    .resultados {
        border: 0;
        border-top: 1px solid var(--papel-borde);
        max-height: 420px;
    }


    .vista-mapa {
        min-height: 82svh;
    }

    .mapa-stage {
        min-height: 62svh;
    }

    .mapa-wrap {
        padding: 14px;
    }

    .mapa-zoom {
        right: 10px;
        bottom: 10px;
        gap: 6px;
        padding: 6px;
    }

    .mapa-zoom-btn {
        width: 40px;
        height: 40px;
        font-size: 1.35rem;
    }
}


/* --- Ajuste extra para pantallas muy pequeñas: filtros de dos en dos --- */
@media (max-width: 480px) {
    .barra-filtros > .campo,
    .barra-filtros > .campo-anios {
        flex: 1 1 45%;
        min-width: 0;
    }

    .barra-filtros > .campo-busqueda {
        flex: 1 1 100%;
    }

    .mapa-stage {
        min-height: 66svh;
        margin: 8px;
    }

    .mapa-wrap {
        padding: 10px;
    }

    .nav {
        flex-wrap: wrap;
    }
}


/* Barras de desplazamiento en la paleta del archivo (WebKit/Blink) */
.lista,
.lista-geo,
.modal-caja {
    scrollbar-width: thin;
    scrollbar-color: var(--oro) transparent;
}

    .lista::-webkit-scrollbar,
    .lista-geo::-webkit-scrollbar,
    .modal-caja::-webkit-scrollbar {
        width: 10px;
    }

    .lista::-webkit-scrollbar-track,
    .lista-geo::-webkit-scrollbar-track,
    .modal-caja::-webkit-scrollbar-track {
        background: transparent;
    }

    .lista::-webkit-scrollbar-thumb,
    .lista-geo::-webkit-scrollbar-thumb,
    .modal-caja::-webkit-scrollbar-thumb {
        background: rgba(200, 134, 13, .55);
        border: 2px solid transparent;
        background-clip: padding-box;
        border-radius: 999px;
    }

        .lista::-webkit-scrollbar-thumb:hover,
        .lista-geo::-webkit-scrollbar-thumb:hover,
        .modal-caja::-webkit-scrollbar-thumb:hover {
            background: var(--oro);
            background-clip: padding-box;
        }

/* =========================================================================
   VISTA CATÁLOGO — galería en cuadrícula + Línea temporal
   ========================================================================= */

.vista-catalogo {
    height: calc(100vh - var(--cabecera-h));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Barra superior: búsqueda, orden, vistas, contador */
.cat-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px 18px;
    background: rgba(251, 247, 236, .96);
    border-bottom: 1px solid var(--papel-borde);
    box-shadow: 0 4px 16px rgba(60, 44, 20, .10);
}

.cat-search {
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 12px;
    background: var(--papel-2);
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
}

    .cat-search input {
        width: 100%;
        border: 0;
        background: transparent;
        outline: none;
        font: inherit;
        color: var(--tinta);
    }

.cat-orden {
    display: flex;
    align-items: center;
    gap: 7px;
}

    .cat-orden label {
        font-size: .62rem;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: var(--tinta-suave);
        font-weight: 700;
    }

    .cat-orden select {
        height: 36px;
        padding: 0 8px;
        border: 1px solid var(--papel-borde);
        border-radius: var(--r);
        background: var(--papel-2);
        color: var(--tinta);
        font: inherit;
        font-size: .88rem;
    }

.cat-views {
    display: flex;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    overflow: hidden;
}

.cat-vb {
    height: 36px;
    padding: 0 13px;
    border: 0;
    background: var(--papel-2);
    color: var(--tinta-suave);
    cursor: pointer;
    font: inherit;
    font-size: .84rem;
}

    .cat-vb + .cat-vb {
        border-left: 1px solid var(--papel-borde);
    }

    .cat-vb.on {
        background: var(--oro-claro);
        color: #241a10;
        font-weight: 700;
    }

.cat-contador-wrap {
    margin-left: auto;
    min-width: 62px;
    text-align: center;
    padding: 5px 10px;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    background: #fff8e4;
}

.cat-contador {
    display: block;
    line-height: 1;
    color: var(--fundacion);
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.cat-contador-wrap small {
    display: block;
    margin-top: 1px;
    color: var(--tinta-suave);
    font-size: .68rem;
}

/* Cuerpo: raíl de filtros + zona principal */
.cat-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.cat-rail {
    flex: 0 0 220px;
    padding: 16px;
    overflow: auto;
    border-right: 1px solid var(--papel-borde);
    background: rgba(251, 247, 236, .6);
}

.cat-grp {
    margin-bottom: 14px;
}

    .cat-rail > label,
    .cat-grp > label {
        margin-bottom: 4px;
        font-size: .62rem;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: var(--tinta-suave);
        font-weight: 700;
    }

.cat-rail select,
.cat-rail .rango-num {
    width: 100%;
    height: 34px;
    padding: 6px 8px;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    background: var(--papel-2);
    color: var(--tinta);
    font: inherit;
    font-size: .88rem;
}

.cat-rail .rango {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cat-rail .check {
    margin-bottom: 12px;
}

.cat-rail .btn-limpiar {
    width: 100%;
}

.cat-main {
    flex: 1 1 auto;
    min-width: 0;
    overflow: auto;
    padding: 16px 18px;
}

/* Cuadrícula */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.cat-card {
    position: relative;
    padding: 13px 13px 12px;
    background: rgba(255, 253, 247, .9);
    border: 1px solid rgba(221, 207, 169, .85);
    border-left: 3px solid var(--fundacion);
    border-radius: 0 var(--r) var(--r) 0;
    cursor: pointer;
    transition: .15s ease;
}

    .cat-card:hover {
        background: #fff8e4;
        border-color: var(--fundacion);
        border-left-color: var(--fundacion);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(60, 44, 20, .12);
    }

.cat-cod {
    display: inline-block;
    margin-bottom: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #eadfbe;
    color: var(--oro-oscuro);
    font-size: .72rem;
    font-weight: 700;
}

.cat-pdf {
    position: absolute;
    top: 11px;
    right: 10px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(157, 47, 34, .10);
    border: 1px solid rgba(157, 47, 34, .42);
    color: var(--rojo);
    font-size: .66rem;
    font-weight: 700;
}

.cat-tit {
    padding-right: 34px;
    font-family: "Fraunces", Georgia, serif;
    font-size: 1rem;
    line-height: 1.18;
    color: var(--tinta);
}

.cat-meta {
    margin-top: 7px;
    color: var(--tinta-suave);
    font-size: .83rem;
    line-height: 1.3;
}

.cat-vacio {
    padding: 28px;
    text-align: center;
    color: var(--tinta-suave);
    font-style: italic;
}

/* Línea temporal */
.cat-timeline {
    position: relative;
    margin-left: 12px;
    padding-left: 26px;
    border-left: 2px solid #90278f7a;
}

.tl-grupo {
    position: relative;
    margin-bottom: 22px;
}

.tl-punto {
    position: absolute;
    left: -32px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--fundacion);
    border: 2px solid var(--papel);
}

.tl-eje {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.tl-anio {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--tinta);
}

.tl-num {
    padding: 1px 8px;
    border-radius: 999px;
    background: #eadfbe;
    color: var(--oro-oscuro);
    font-size: .72rem;
    font-weight: 700;
}

.tl-docs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tl-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: 1px solid rgba(221, 207, 169, .8);
    border-radius: var(--r);
    background: rgba(255, 253, 247, .8);
    cursor: pointer;
    font: inherit;
    transition: .15s ease;
}

    .tl-item:hover {
        border-color: var(--fundacion);
        background: #fff8e4;
    }

.tl-cod {
    padding: 1px 6px;
    border-radius: 999px;
    background: #eadfbe;
    color: var(--oro-oscuro);
    font-size: .68rem;
    font-weight: 700;
}

.tl-tit {
    font-family: "Fraunces", Georgia, serif;
    font-size: .92rem;
    color: var(--tinta);
}

.tl-meta {
    color: var(--tinta-suave);
    font-size: .78rem;
}

/* Catálogo responsive */
@media (max-width: 760px) {
    .vista-catalogo {
        height: auto;
        min-height: calc(100vh - var(--cabecera-h));
    }

    .cat-body {
        flex-direction: column;
    }

    .cat-rail {
        flex: 0 0 auto;
        border-right: 0;
        border-bottom: 1px solid var(--papel-borde);
    }

    .cat-main {
        overflow: visible;
    }

    .cat-contador-wrap {
        margin-left: 0;
    }
}

/* =========================================================================
   Descripción en tarjetas + ficha destacada + vista previa de PDF
   ========================================================================= */

/* Descripción dentro de las tarjetas (mapa y catálogo): 2 líneas máx. */
.tarjeta-desc,
.cat-desc {
    margin-top: 7px;
    color: var(--tinta);
    font-size: .86rem;
    line-height: 1.34;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Descripción destacada en el modal (justo bajo el título) */
.ficha-desc {
    margin: 0 0 16px;
    color: var(--tinta);
    font-size: 1.04rem;
    line-height: 1.5;
}

/* Vista previa del documento en el modal */
.ficha-preview {
    margin: 0 0 18px;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    overflow: hidden;
    background: var(--pergamino);
}

    .ficha-preview iframe {
        display: block;
        width: 100%;
        height: clamp(220px, 42vh, 380px);
        border: 0;
    }

/* =========================================================================
   MODAL COMPACTO DE FICHA CARTOGRÁFICA
   ========================================================================= */

.modal-caja {
    width: min(1180px, calc(100vw - 32px));
    height: min(870px, calc(100vh - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modalContenido {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.modal-cerrar {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
    float: none;
}

/* Cabecera */

.ficha-head {
    flex: 0 0 auto;
    padding: 22px 68px 14px 24px;
    border-bottom: 1px solid rgba(221, 207, 169, .85);
    background: linear-gradient(180deg, #fffdf7 0%, var(--papel) 100%);
}

.ficha-cod {
    margin: 0 0 7px;
}

.ficha-tit {
    margin: 0;
    color: var(--tinta);
    font-size: clamp(1.22rem, 2vw, 1.55rem);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ficha-desc {
    margin: 9px 0 0;
    color: var(--tinta);
    font-size: .95rem;
    line-height: 1.38;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Cuerpo */

.ficha-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 24px;
    overflow: auto;
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(380px, 1.05fr);
    gap: 16px;
    align-items: stretch;
}

    .ficha-body.sin-preview {
        grid-template-columns: minmax(0, 920px);
        justify-content: center;
    }

/* Metadatos compactos */

.ficha-meta-grid {
    align-self: start;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.ficha-dato {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid rgba(221, 207, 169, .85);
    border-radius: 12px;
    background: rgba(255, 253, 247, .82);
}

    .ficha-dato.ancho {
        grid-column: 1 / -1;
    }

    .ficha-dato span {
        display: block;
        margin-bottom: 3px;
        color: var(--tinta-suave);
        font-size: .68rem;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .ficha-dato strong {
        display: block;
        min-width: 0;
        color: var(--tinta);
        font-size: .9rem;
        font-weight: 650;
        line-height: 1.28;
        overflow-wrap: anywhere;
    }

/* Preview PDF */

.ficha-preview {
    margin: 0;
    min-height: 0;
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    overflow: hidden;
    background: var(--pergamino);
}

    .ficha-preview iframe {
        display: block;
        width: 100%;
        height: 100%;
        min-height: 360px;
        border: 0;
    }

/* Botonera siempre visible */

.ficha-acciones {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
    padding: 12px 24px;
    border-top: 1px solid rgba(221, 207, 169, .9);
    background: #fffdf7;
}

/* Responsive */

@media (max-width: 920px) {
    .modal-caja {
        width: calc(100vw - 18px);
        height: calc(100vh - 18px);
        max-height: calc(100vh - 18px);
    }

    .ficha-head {
        padding: 18px 58px 12px 16px;
    }

    .ficha-body {
        padding: 14px 16px;
        grid-template-columns: 1fr;
    }

    .ficha-preview iframe {
        height: 260px;
        min-height: 260px;
    }

    .ficha-acciones {
        padding: 11px 16px;
        justify-content: stretch;
    }

        .ficha-acciones .btn {
            flex: 1 1 180px;
        }
}

@media (max-width: 620px) {
    .ficha-meta-grid {
        grid-template-columns: 1fr;
    }

    .ficha-dato.ancho {
        grid-column: auto;
    }

    .ficha-desc {
        -webkit-line-clamp: 1;
    }
}

@media (max-height: 700px) {
    .ficha-head {
        padding-top: 16px;
        padding-bottom: 10px;
    }

    .ficha-desc {
        -webkit-line-clamp: 1;
    }

    .ficha-preview iframe {
        min-height: 280px;
    }

    .ficha-dato {
        padding: 7px 9px;
    }
}


/* Loader del PDF dentro del modal */

.ficha-preview {
    position: relative;
}

.pdf-loader {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(180deg, #fffdf7 0%, var(--pergamino) 100%);
    color: var(--tinta-suave);
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-align: center;
    transition: opacity .25s ease, visibility .25s ease;
}

.pdf-spinner {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 4px solid rgba(122, 96, 16, .18);
    border-top-color: var(--oro);
    animation: girarPdf 0.8s linear infinite;
}

.ficha-preview.pdf-cargado .pdf-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ficha-preview.cargando-pdf iframe {
    opacity: 0;
}

.ficha-preview.pdf-cargado iframe {
    opacity: 1;
}

.ficha-preview iframe {
    transition: opacity .2s ease;
}

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

.pdf-loader-link {
    margin-top: 2px;
    color: var(--oro-oscuro);
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    border-bottom: 1px solid rgba(122, 96, 16, .35);
}

    .pdf-loader-link:hover {
        color: var(--tinta);
        border-bottom-color: var(--tinta);
    }

/* Evitar que títulos largos se salgan de las tarjetas */
.tarjeta-tit,
.cat-tit,
.tl-tit {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
}

@media (min-width: 920px) {
    .marca-sub {
        display: block;
    }
}

@media (max-width: 760px) {
    .cab-izq {
        gap: 10px;
    }

    .cab-sep {
        display: none;
    }

    .nav {
        width: 100%;
    }

    .nav-link {
        flex: 1 1 auto;
        text-align: center;
        font-size: .84rem;
        padding: 8px 12px;
    }
}

.app-shell {
    padding: 14px;
    gap: 14px;
    background: radial-gradient(circle at 50% 20%, rgba(255, 253, 247, .34), transparent 48%), var(--pergamino);
}

.panel-geo,
.resultados,
.zona-mapa {
    border: 1px solid rgba(221, 207, 169, .9);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(60, 44, 20, .10);
}

.panel-geo {
    border-right: 1px solid rgba(221, 207, 169, .9);
}

.resultados {
    border-left: 1px solid rgba(221, 207, 169, .9);
}

.mapa-stage {
    margin: 12px;
    border: 1px solid rgba(122, 96, 16, .22);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 253, 247, .58), rgba(239, 230, 207, .42)), var(--papel);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35), 0 12px 30px rgba(60, 44, 20, .12);
}

.mapa-wrap {
    padding: 22px;
}

.tarjeta,
.cat-card {
    border-left-width: 5px;
    border-radius: 12px;
    padding: 14px 15px 13px;
    background: linear-gradient(180deg, rgba(255, 253, 247, .96), rgba(251, 247, 236, .88));
}

    .tarjeta:hover,
    .cat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 24px rgba(60, 44, 20, .15);
    }

.tarjeta-tit,
.cat-tit {
    font-size: 1.03rem;
    line-height: 1.22;
}

.tarjeta-meta,
.cat-meta {
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid rgba(221, 207, 169, .55);
}

.campo input[type="text"],
.campo select,
.rango-num,
.cat-orden select,
.cat-rail select,
.cat-rail .rango-num {
    height: 38px;
    padding: 7px 11px;
    border-radius: 10px;
    background: linear-gradient(180deg, #fffdf7, #fbf7ec);
}

.campo label,
.cat-grp > label,
.cat-orden label {
    margin-bottom: 5px;
}

.barra-filtros,
.cat-bar {
    padding: 13px 16px;
}

.cabecera-inner {
    max-width: 1920px;
    margin: 0 auto;
}

.marca-titulo {
    font-size: clamp(1.2rem, 1.5vw, 1.55rem);
}

.nav-link {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.modal-fondo {
    background: radial-gradient(circle at center, rgba(36, 26, 16, .48), rgba(20, 14, 8, .76));
    backdrop-filter: blur(3px);
}

.modal-caja {
    border-radius: 18px;
    border: 1px solid rgba(221, 207, 169, .95);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .36), inset 0 1px 0 rgba(255, 255, 255, .42);
}

.ficha-head {
    background: linear-gradient(90deg, rgba(157, 47, 34, .06), transparent 38%), linear-gradient(180deg, #fffdf7 0%, var(--papel) 100%);
}

.ficha-dato {
    border-radius: 14px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
}

.geo-item.activo,
.tarjeta.activa,
.cat-card.activa {
    border-color: var(--fundacion);
    background: linear-gradient(180deg, #90278f14, rgba(255, 253, 247, .92));
    box-shadow: 0 0 0 2px rgba(157, 47, 34, .08);
}

    .geo-item.activo .geo-num {
        background: var(--fundacion);
        color: #fff8e4;
    }

.cabecera-inner {
    display: flex;
    align-items: center;
    gap: 22px;
}

.cab-logo-fundacion {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    text-decoration: none;
}

.cab-logo-fundacion img {
    height: 58px;
    max-width: 180px;
    object-fit: contain;
    display: block;
}

.nav {
    margin-left: 12px;
}

.mapa-svg path.provincia-sel {
    stroke: var(--fundacion) !important;
    stroke-width: 2 !important;
    fill: var(--fundacion) !important;
}

.btn-volver-mapa {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font-family: "Fraunces", Georgia, serif;
    font-size: .82rem;
    font-weight: 600;
    color: var(--fundacion);
    background: var(--papel-2-transp);
    border: 1px solid var(--fundacion);
    border-radius: 999px;
    transition: .15s;
}

    .btn-volver-mapa:hover {
        color: var(--fundacion);
        background: var(--papel-2-transp);
        border-color: var(--fundacion);
        transform: translateY(-1px);
        box-shadow: 0 8px 18px var(--sombra);
        cursor: pointer;
    }

    .btn-volver-mapa .btn-volver-ico {
        font-size: 1.05em;
        line-height: 1;
        transition: transform .15s ease;
    }

    .btn-volver-mapa:hover .btn-volver-ico {
        transform: translateX(-2px);
    }

/* ===========================================================================
   BARRAS DE SCROLL GLOBALES — estilo archivo / pergamino
   =========================================================================== */

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(200, 134, 13, .65) rgba(255, 253, 247, .35);
}

    /* Chrome, Edge, Safari */
    *::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    *::-webkit-scrollbar-track {
        background: rgba(255, 253, 247, .35);
        border-radius: 999px;
    }

    *::-webkit-scrollbar-thumb {
        background: rgba(200, 134, 13, .58);
        border: 2px solid rgba(255, 253, 247, .55);
        background-clip: padding-box;
        border-radius: 999px;
    }

        *::-webkit-scrollbar-thumb:hover {
            background: var(--oro);
            background-clip: padding-box;
        }

    *::-webkit-scrollbar-corner {
        background: transparent;
    }
/* =========================================================================
   REORDENACIÓN 2026-06 — mapa, catálogo y Línea temporal comparten filtros
   e índice territorial. Catálogo y timeline ocupan la zona central del mapa.
   ========================================================================= */

.zona-mapa {
    grid-template-rows: auto minmax(0, 1fr);
}

.vista-central {
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.vista-mapa {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.vista-contenido {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(rgba(255, 253, 247, .30), rgba(255, 253, 247, .12)), var(--pergamino);
}

.cat-bar-integrada {
    flex: 0 0 auto;
    border-bottom: 1px solid var(--papel-borde);
}

.cat-titulo-wrap {
    min-width: 0;
    flex: 1 1 auto;
}

.cat-titulo-wrap h2 {
    font-size: 1.12rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.vista-contenido .cat-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px 18px;
}

.vista-contenido .cat-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.vista-contenido .cat-vacio {
    grid-column: 1 / -1;
    background: rgba(255, 253, 247, .72);
    border: 1px dashed var(--papel-borde);
    border-radius: var(--r);
}

/* En Catálogo y Línea temporal se oculta el panel derecho de documentos:
   el contenido principal ya es el catálogo/timeline y puede ocupar más aire. */
.app-shell.modo-catalogo .zona-mapa,
.app-shell.modo-timeline .zona-mapa {
    grid-column: 2 / 4;
}

.app-shell.modo-catalogo .resultados,
.app-shell.modo-timeline .resultados {
    display: none;
}

/* El panel territorial ahora tiene subtítulo también en catálogo/timeline. */
.lista-geo {
    height: calc(100% - 118px);
}

.panel-geo-cabecera p#panelGeoSub {
    margin: 7px 0 0;
    color: var(--tinta-suave);
    font-size: .82rem;
    line-height: 1.25;
}

.geo-reset .geo-num {
    min-width: 28px;
}

.cat-card .cat-cod {
    margin-right: 42px;
}

.cat-timeline {
    max-width: 1100px;
}

@media (max-width: 1180px) {
    .app-shell.modo-catalogo,
    .app-shell.modo-timeline {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(220px, 36vh);
        grid-template-areas:
            "mapa"
            "geo";
    }

    .app-shell.modo-catalogo .zona-mapa,
    .app-shell.modo-timeline .zona-mapa {
        grid-column: auto;
        grid-area: mapa;
    }

    .app-shell.modo-catalogo .panel-geo,
    .app-shell.modo-timeline .panel-geo {
        grid-area: geo;
        border-right: 0;
        border-top: 1px solid var(--papel-borde);
    }
}

@media (max-width: 760px) {
    .app-shell.modo-catalogo,
    .app-shell.modo-timeline {
        grid-template-rows: none;
        grid-template-areas:
            "mapa"
            "geo";
    }

    .vista-contenido {
        min-height: 70vh;
    }

    .cat-bar-integrada {
        align-items: flex-start;
    }

    .cat-contador-wrap {
        margin-left: 0;
    }
}

.ficha-nota-asterisco {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    padding: 9px 11px;
    border-left: 3px solid var(--fundacion);
    background: rgba(255, 253, 247, .72);
    color: var(--tinta-suave);
    font-size: 1rem;
    line-height: 1.3;
}

.ficha-nota-marca {
    margin-left: 1px;
    color: var(--fundacion);
    font-weight: 700;
}

.ficha-notas {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    padding: 9px 11px;
    border-left: 3px solid var(--fundacion);
    border-radius: 0 12px 12px 0;
    background: rgba(255, 253, 247, .72);
    font-size: .85rem;
    line-height: 1.35;
}

    .ficha-notas summary {
        cursor: pointer;
        color: var(--tinta-suave);
        font-size: .68rem;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .ficha-notas p {
        margin: 6px 0 0;
        color: var(--tinta);
    }

    .ficha-notas p:first-of-type {
        margin-top: 8px;
    }

.btn-limpiar-icono {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3px;
}

    .btn-limpiar-icono img {
        width: 18px;
        height: 18px;
        display: block;
        object-fit: contain;
    }

.ficha-preview-miniatura {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    background: rgba(255, 253, 247, .72);
    border: 1px solid var(--papel-borde);
    border-radius: var(--r);
    overflow: hidden;
}

    .ficha-preview-miniatura a {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

.pdf-thumb {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    box-shadow: 0 8px 24px rgba(60, 44, 20, .22);
    background: white;
}
/* Ajuste final: más altura útil del mapa en móvil y botones de zoom por encima de reglas posteriores. */
@media (max-width: 760px) {

    .mapa-wrap {
        padding: 14px;
    }

    .mapa-zoom {
        right: 10px;
        bottom: 10px;
        gap: 6px;
        padding: 6px;
    }

    .mapa-zoom-btn {
        width: 40px;
        height: 40px;
        font-size: 1.35rem;
    }
}

@media (max-width: 480px) {
    .mapa-stage {
        min-height: 66svh;
        margin: 8px;
    }

    .mapa-wrap {
        padding: 10px;
    }
}


/* =========================================================================
   RESPONSIVE FINAL — desde 1180px se usa ya el layout móvil
   ========================================================================= */

@media (max-width: 1180px) {
    body {
        overflow: auto;
    }

    .cabecera {
        height: auto;
        min-height: var(--cabecera-h);
    }

    .cabecera-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .cab-izq {
        gap: 10px;
    }

    .cab-sep {
        display: none;
    }

    .nav {
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
    }

    .nav-link {
        flex: 1 1 auto;
        text-align: center;
        font-size: .84rem;
        padding: 8px 12px;
    }

    .cab-logo-fundacion {
        margin-left: 0;
    }

    .app-shell {
        height: auto;
        min-height: calc(100vh - var(--cabecera-h));
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas:
            "mapa"
            "geo"
            "docs";
    }

    .zona-mapa {
        grid-area: mapa;
        border-bottom: 0;
    }

    .panel-geo {
        grid-area: geo;
    }

    .resultados {
        grid-area: docs;
    }

    .panel-geo,
    .resultados {
        border: 0;
        border-top: 1px solid var(--papel-borde);
        max-height: 420px;
        box-shadow: 0 10px 28px rgba(60, 44, 20, .10);
    }

    .vista-mapa {
        grid-template-rows: auto auto;
        align-content: start;
    }

    .mapa-stage {
        min-height: 0;
        aspect-ratio: 1360 / 820;
    }

    .mapa-wrap {
        padding: 14px;
    }

    .mapa-zoom {
        right: 10px;
        bottom: 10px;
        gap: 6px;
        padding: 6px;
    }

    .mapa-zoom-btn {
        width: 40px;
        height: 40px;
        font-size: 1.35rem;
    }

    .app-shell.modo-catalogo,
    .app-shell.modo-timeline {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas:
            "mapa"
            "geo";
    }

        .app-shell.modo-catalogo .zona-mapa,
        .app-shell.modo-timeline .zona-mapa {
            grid-column: auto;
            grid-area: mapa;
        }

        .app-shell.modo-catalogo .panel-geo,
        .app-shell.modo-timeline .panel-geo {
            grid-area: geo;
            border-right: 0;
            border-top: 1px solid var(--papel-borde);
        }

    .vista-contenido {
        min-height: 70vh;
    }

    .cat-bar-integrada {
        align-items: flex-start;
    }

    .cat-contador-wrap {
        margin-left: 0;
    }

    .vista-catalogo {
        height: auto;
        min-height: calc(100vh - var(--cabecera-h));
    }

    .cat-body {
        flex-direction: column;
    }

    .cat-rail {
        flex: 0 0 auto;
        border-right: 0;
        border-bottom: 1px solid var(--papel-borde);
    }

    .cat-main {
        overflow: visible;
    }
}

/* El SVG móvil tiene una proporción algo distinta a la de escritorio */
@media (max-width: 760px) {
    .mapa-stage {
        aspect-ratio: 1160 / 720;
    }
}

/* =========================================================================
   Rótulo territorial flotante del mapa — estilo archivo / cartografía
   ========================================================================= */

.mapa-rotulo {
    position: absolute;
    z-index: 7;
    max-width: min(460px, calc(100% - 130px));
    padding: 13px 18px 14px 20px;
    border: 1px solid rgba(221, 207, 169, .92);
    border-left: 5px solid var(--fundacion);
    border-radius: 0 16px 16px 0;
    background: linear-gradient(90deg, rgba(157, 47, 34, .055), transparent 44%), linear-gradient(180deg, rgba(255, 253, 247, .96), rgba(251, 247, 236, .90));
    box-shadow: 0 10px 26px rgba(60, 44, 20, .15), inset 0 1px 0 rgba(255, 255, 255, .48);
    pointer-events: none;
}

    .mapa-rotulo::after {
        content: "";
        display: block;
        width: 54px;
        height: 1px;
        margin-top: 8px;
        background: linear-gradient(90deg, var(--fundacion), transparent);
        opacity: .75;
    }

.mapa-rotulo-prov {
    font-family: "Fraunces", Georgia, serif;
    font-size: clamp(1.55rem, 2.35vw, 2.35rem);
    line-height: 1.02;
    font-weight: 650;
    letter-spacing: .01em;
    color: var(--tinta);
    text-shadow: 0 1px 0 rgba(255, 253, 247, .75);
    overflow-wrap: anywhere;
}

.mapa-rotulo-muni {
    position: relative;
    margin-top: 8px;
    padding-top: 7px;
    font-family: "Spectral", Georgia, serif;
    font-size: clamp(0.7rem, 1.25vw, 0.9rem);
    line-height: 1.14;
    font-weight: 600;
    color: var(--fundacion);
    overflow-wrap: anywhere;
}

    .mapa-rotulo-muni::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 42px;
        height: 1px;
        background: rgba(157, 47, 34, .35);
    }

/* Posiciones */

.mapa-rotulo-arriba-izq {
    top: 18px;
    left: 18px;
}

.mapa-rotulo-arriba-der {
    top: 18px;
    right: 18px;
    text-align: right;
    border-left-width: 5px;
    border-radius: 16px 16px 16px 16px;
}

    .mapa-rotulo-arriba-der::after,
    .mapa-rotulo-abajo-der::after {
        margin-left: auto;
        background: linear-gradient(270deg, var(--fundacion), transparent);
    }

    .mapa-rotulo-arriba-der .mapa-rotulo-muni::before,
    .mapa-rotulo-abajo-der .mapa-rotulo-muni::before {
        left: auto;
        right: 0;
    }

.mapa-rotulo-abajo-izq {
    bottom: 18px;
    left: 18px;
}

.mapa-rotulo-abajo-der {
    right: 18px;
    bottom: 18px;
    text-align: right;
    border-left-width: 1px;
    border-right: 5px solid var(--oro);
    border-radius: 16px 0 0 16px;
}

/* Evita choque visual con el botón de volver si el rótulo cae arriba izquierda */
.mapa-rotulo-arriba-izq {
    top: 66px;
}

/* Responsive */

@media (max-width: 1180px) {
    .mapa-rotulo {
        max-width: calc(100% - 92px);
        padding: 11px 14px 12px 16px;
        border-left-width: 4px;
    }

    .mapa-rotulo-arriba-der,
    .mapa-rotulo-abajo-der {
        border-right-width: 4px;
    }

    .mapa-rotulo::before {
        font-size: .58rem;
        letter-spacing: .13em;
    }

    .mapa-rotulo-prov {
        font-size: clamp(1.32rem, 4.8vw, 2rem);
    }

    .mapa-rotulo-muni {
        font-size: clamp(.96rem, 3.3vw, 1.16rem);
    }

    .mapa-rotulo-arriba-izq {
        top: 58px;
        left: 12px;
    }

    .mapa-rotulo-arriba-der {
        top: 12px;
        right: 12px;
    }

    .mapa-rotulo-abajo-izq {
        bottom: 12px;
        left: 12px;
    }

    .mapa-rotulo-abajo-der {
        right: 12px;
        bottom: 12px;
    }
}

@media (max-width: 480px) {
    .mapa-rotulo {
        max-width: calc(100% - 74px);
        padding: 10px 12px 11px 14px;
    }

        .mapa-rotulo::before {
            margin-bottom: 3px;
            font-size: .54rem;
        }

        .mapa-rotulo::after {
            margin-top: 6px;
            width: 42px;
        }
}

/* Optimización: al hacer zoom, se eliminan efectos caros del SVG */
.mapa-stage.mapa-con-zoom .mapa-svg svg {
    filter: none;
}

.mapa-stage.mapa-con-zoom .mapa-svg path {
    transition: none;
}

.mapa-stage.mapa-arrastrando .mapa-svg svg {
    transition: none;
}

/* Ocultar botones de zoom en escritorio/tablet */
.mapa-zoom {
    display: none;
}

/* Mostrar botones solo en móvil */
@media (max-width: 760px) {
    .mapa-zoom {
        display: flex;
    }
}