* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: #1a1d22;
    color: #e3e6ea;
    font-size: 13px;
}

button {
    font-family: inherit;
    font-size: 13px;
    background: #3a78c2;
    color: #fff;
    border: 0;
    padding: 7px 12px;
    border-radius: 4px;
    cursor: pointer;
}
button:hover { background: #4a8bd8; }
button.btn-ghost {
    background: transparent;
    border: 1px solid #4a525c;
    color: #cfd3d8;
}
button.btn-ghost:hover { background: #2a2e35; }

input, select, textarea {
    font-family: inherit;
    font-size: 13px;
    background: #25292f;
    color: #e3e6ea;
    border: 1px solid #3a3f47;
    border-radius: 3px;
    padding: 6px 8px;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #4a8bd8;
}
input[type="checkbox"] {
    width: auto;
    margin-right: 4px;
}
textarea { resize: vertical; }
label {
    display: block;
    margin: 8px 0;
    color: #b9bdc4;
    font-size: 12px;
}
label.inline {
    display: inline-flex;
    align-items: center;
    margin: 0 0 0 8px;
    white-space: nowrap;
}
fieldset {
    border: 1px solid #2f343b;
    border-radius: 4px;
    margin: 10px 0;
    padding: 6px 10px 10px;
}
legend {
    color: #b9bdc4;
    font-size: 11px;
    padding: 0 4px;
}

.hidden { display: none !important; }

/* ------------------ Login ------------------ */
.login-screen {
    position: fixed;
    inset: 0;
    background: #14171b;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.login-card {
    background: #1f2329;
    border: 1px solid #2f343b;
    border-radius: 8px;
    padding: 32px 28px;
    width: 320px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.login-card h1 {
    margin: 0;
    font-size: 22px;
    color: #fff;
    letter-spacing: 1px;
}
.login-card .subtitle {
    color: #8a9099;
    margin: 4px 0 20px;
    font-size: 12px;
}
.login-card button {
    width: 100%;
    margin-top: 12px;
    padding: 9px;
}
.login-error {
    color: #ff7676;
    margin-top: 10px;
    font-size: 12px;
    min-height: 16px;
}

/* ------------------ Layout principal ------------------ */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    height: 48px;
    background: #14171b;
    border-bottom: 1px solid #2f343b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex: 0 0 auto;
}
.brand {
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
#cliente-nombre {
    color: #b9bdc4;
    font-size: 13px;
}

.main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.panel-left {
    width: 320px;
    flex: 0 0 320px;
    background: #1c2025;
    border-right: 1px solid #2f343b;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.filtros {
    padding: 12px 14px;
    border-bottom: 1px solid #2f343b;
    flex: 0 0 auto;
    overflow-y: auto;
    max-height: 50%;
}
.filtros h3,
.panel-right h3 {
    margin: 0 0 8px;
    font-size: 13px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}
.botonera {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.botonera button { flex: 1; }

.tabla-wrap {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.tabla-header {
    padding: 8px 12px;
    border-bottom: 1px solid #2f343b;
    color: #b9bdc4;
    font-size: 12px;
}
.tabla-scroll {
    flex: 1 1 auto;
    overflow: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
thead th {
    position: sticky;
    top: 0;
    background: #25292f;
    color: #cfd3d8;
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #2f343b;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
thead th.num { text-align: right; }
thead th .arrow {
    color: #4a8bd8;
    margin-left: 4px;
    font-size: 10px;
}
tbody td {
    padding: 5px 8px;
    border-bottom: 1px solid #23272d;
    color: #cfd3d8;
}
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #232830; }
tbody tr.selected { background: #2a3a55 !important; }

.estado-pill {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
}

/* ------------------ Mapa ------------------ */
.map {
    flex: 1 1 auto;
    min-width: 0;
    background: #0f1115;
    position: relative;   /* necesario para los hijos con position:absolute */
}

/* ------------------ Panel derecho ------------------ */
.panel-right {
    width: 320px;
    flex: 0 0 320px;
    background: #1c2025;
    border-left: 1px solid #2f343b;
    overflow-y: auto;
    padding: 14px;
    position: relative;
}
.panel-right section {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2a2e35;
}
.panel-right section:last-child { border-bottom: 0; }

.btn-cerrar {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    color: #cfd3d8;
    font-size: 20px;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 3px;
}
.btn-cerrar:hover { background: #2a2e35; }

.kv {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 4px 10px;
    margin: 6px 0 10px;
}
.kv dt {
    color: #8a9099;
    font-size: 12px;
}
.kv dd {
    margin: 0;
    color: #e3e6ea;
    font-size: 12px;
    word-break: break-word;
}

.info {
    color: #8a9099;
    font-size: 11px;
    font-style: italic;
    margin: 4px 0 10px;
}

.checks {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 6px 0 10px;
}
.checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: #cfd3d8;
    font-size: 12px;
}
.checks input[type="checkbox"] { width: auto; }
.checks label.tipo-no-residuo {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed #3a4049;
    color: #f0b86c;
    font-weight: 600;
}

.ok-msg {
    display: inline-block;
    margin-left: 10px;
    color: #6dd58c;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}
.ok-msg.show { opacity: 1; }

/* MapLibre popup oscuro */
.maplibregl-popup-content {
    background: #25292f !important;
    color: #e3e6ea !important;
    border: 1px solid #3a3f47;
    font-size: 12px;
}
.maplibregl-popup-tip { border-top-color: #25292f !important; }

/* ------------------ Overlay sin datos ------------------ */
.overlay-sin-datos {
    position: absolute;
    inset: 0;
    background: rgba(14, 16, 20, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    text-align: center;
    pointer-events: none;
    backdrop-filter: blur(2px);
}
.overlay-sin-datos div {
    background: #1f2329;
    border: 1px solid #3a3f47;
    border-radius: 8px;
    padding: 24px 32px;
    max-width: 360px;
}
.overlay-sin-datos p {
    margin: 6px 0;
    color: #cfd3d8;
    font-size: 14px;
}
.overlay-sin-datos strong { color: #4a8bd8; }

/* ------------------ Toast global ------------------ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    max-width: 420px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    transition: opacity 0.3s;
}
.toast.toast-ok     { background: #1e4d2b; border: 1px solid #27ae60; color: #6dd58c; }
.toast.toast-error  { background: #4d1e1e; border: 1px solid #c0392b; color: #ff8080; }
.toast.toast-info   { background: #1e3450; border: 1px solid #2980b9; color: #7ec8f7; }

/* ------------------ Selector de capas base ------------------ */
.layer-switcher {
    position: absolute;
    bottom: 28px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}
.layer-btn {
    background: rgba(28, 32, 37, 0.92);
    color: #cfd3d8;
    border: 1px solid #3a3f47;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    transition: background 0.15s, color 0.15s;
}
.layer-btn:hover {
    background: rgba(42, 48, 58, 0.97);
    color: #fff;
}
.layer-btn.active {
    background: #3a78c2;
    border-color: #4a8bd8;
    color: #fff;
}
/* Toggle visibilidad capa — en la topbar */
.btn-toggle-capa {
    border-color: #4a8bd8;
    color: #7ec8f7;
}
.btn-toggle-capa.active {
    background: #1e3a5a;
    border-color: #4a8bd8;
    color: #7ec8f7;
}
.btn-toggle-capa:not(.active) {
    background: transparent;
    border-color: #555;
    color: #666;
    text-decoration: line-through;
}
.btn-toggle-capa:hover {
    background: #2a4a6a !important;
    color: #a8d8f8 !important;
    text-decoration: none;
}

/* Botón Dibujar */
.btn-dibujar { border-color: #ff9800; color: #ffb74d; }
.btn-dibujar.active { background: #5a3500; border-color: #ff9800; color: #ffb74d; }
.btn-dibujar:hover { background: #3a2200 !important; color: #ffcc80 !important; }

/* Botón pequeño */
button.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Botón de eliminar */
button.btn-danger {
    background: #7a2020;
    border: 1px solid #c0392b;
    color: #ffaaaa;
}
button.btn-danger:hover { background: #9a2020; }

/* Checkbox erróneo */
.erroneo-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 6px;
    color: #ff9999;
    font-size: 13px;
    cursor: pointer;
}
.erroneo-label input[type="checkbox"] { width: auto; accent-color: #ff6600; }
.erroneo-label strong { color: #ff6600; }

/* Toggle detecciones en estado "oculto" (selector capas, por si se usa) */
.layer-btn-toggle:not(.active) {
    background: rgba(28, 32, 37, 0.75);
    border-color: #555;
    color: #888;
    text-decoration: line-through;
}
.layer-sep {
    border: none;
    border-top: 1px solid #3a3f47;
    margin: 2px 0;
}

/* ── Control de año PNOA ────────────────────────────────────────────────── */
.ctrl-año {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 20, 25, 0.88);
    backdrop-filter: blur(6px);
    color: #e3e6ea;
    padding: 10px 18px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 9999;
    min-width: 340px;
    max-width: 480px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.5);
    user-select: none;
    pointer-events: all;
}
.año-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
}
.año-icono { font-size: 16px; }
.año-display {
    font-weight: 600;
    font-size: 13px;
    color: #ffe066;
    min-width: 160px;
    text-align: center;
}
.año-slider-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.año-extremo {
    font-size: 11px;
    color: #8a9199;
    white-space: nowrap;
}
.año-slider-wrap input[type="range"] {
    flex: 1;
    height: 4px;
    background: #3a3f47;
    border: none;
    border-radius: 2px;
    padding: 0;
    cursor: pointer;
    accent-color: #ffe066;
}
.año-slider-wrap input[type="range"]::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    background: #ffe066;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(255,224,102,0.25);
}
.año-ticks {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 0 2px;
}
.año-tick {
    font-size: 9px;
    color: #555c66;
    text-align: center;
    flex: 1;
}
.año-tick.decada {
    color: #8a9199;
    font-weight: 600;
}

/* ──────────────── Botones extra ──────────────── */
.btn-primario {
    background: #0065B3;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primario:hover { background: #004A82; }
.btn-primario:disabled { background: #6c757d; cursor: not-allowed; }

.btn-secundario {
    background: transparent;
    color: #0065B3;
    border: 1.5px solid #0065B3;
    padding: 7px 13px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-secundario:hover { background: #D6EDFB; }

/* ──────────────── Modal de informe ──────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none !important; }

.modal-content {
    background: #1f2228;
    color: #e3e6ea;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    position: relative;
    border: 1px solid rgba(255,255,255,0.08);
}
/* Cabecera fija del modal */
.modal-header {
    flex: 0 0 auto;
    padding: 22px 28px 0;
}
/* Cuerpo scrollable */
.modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 28px 8px;
    min-height: 0;
}
.modal-content h2 {
    color: #4DA3E0;
    margin: 0 0 12px;
    font-size: 20px;
    border-bottom: 2px solid #0065B3;
    padding-bottom: 8px;
}
.modal-cerrar {
    position: absolute;
    top: 12px; right: 14px;
    background: transparent;
    border: none;
    color: #cfd3d8;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
}
.modal-cerrar:hover { background: rgba(255,255,255,0.08); color: #fff; }

.modal-info {
    background: rgba(77,163,224,0.08);
    border-left: 3px solid #4DA3E0;
    padding: 10px 14px;
    border-radius: 4px;
    margin: 10px 0 16px;
    font-size: 14px;
    line-height: 1.6;
}

.modal-opciones { margin: 16px 0; }
.opcion-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 8px;
}
.opcion-check input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

.opcion-anos { margin-top: 10px; padding: 12px; background: rgba(255,255,255,0.04); border-radius: 6px; }
.opcion-anos.hidden { display: none; }
.anos-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.ano-chip {
    background: rgba(255,255,255,0.08);
    color: #cfd3d8;
    border: 1.5px solid rgba(255,255,255,0.12);
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.12s;
}
.ano-chip:hover { border-color: #4DA3E0; }
.ano-chip.activo {
    background: #0065B3;
    color: #fff;
    border-color: #4DA3E0;
}
/* Años con cobertura parcial: borde discontinuo y color amarillento */
.ano-chip.ano-chip-dudoso {
    border-style: dashed;
    border-color: rgba(255, 193, 7, 0.4);
    color: #b8b090;
}
.ano-chip.ano-chip-dudoso:hover { border-color: #ffc107; }
.ano-chip.ano-chip-dudoso.activo {
    background: #5a4a00;
    color: #ffe066;
    border-color: #ffc107;
    border-style: dashed;
}

.modal-preview-wrap {
    background: #15171b;
    border-radius: 8px;
    padding: 12px;
    margin: 16px 0;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(255,255,255,0.1);
}
.modal-preview-wrap .spinner {
    color: #4DA3E0;
    font-size: 14px;
    padding: 30px 0;
}
#modal-preview-iframe {
    width: 100%;
    height: 500px;
    min-height: 300px;
    border: none;
    border-radius: 4px;
    background: #fff;
    display: block;
}

.modal-acciones {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 28px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: #1f2228;
    flex-wrap: wrap;
}
/* ══════════════════ LAYOUT MÓVIL / TABLET ══════════════════ */
/* En móvil los paneles laterales se ocultan */
@media (max-width: 900px) {
    .panel-left  { display: none !important; }
    .panel-right { display: none !important; }
    .topbar-right { gap: 6px; }
    #btn-importar,
    #btn-toggle-detecciones { display: none !important; }
    .brand { font-size: 14px; }
    #cliente-nombre { display: none; }
    .main { position: relative; }
    #map { height: calc(100vh - 48px - 64px); } /* topbar + mobile-nav */
}
/* ── Barra de navegación inferior ── */
.mobile-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: #14171b;
    border-top: 1px solid #2f343b;
    display: flex;
    z-index: 200;
}
.mobile-nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #6a7280;
    padding: 8px 0;
    font-size: 11px;
    transition: color 0.15s;
}
.mobile-nav-btn .mnav-icon { font-size: 20px; line-height: 1; }
.mobile-nav-btn .mnav-label { font-size: 10px; }
.mobile-nav-btn.active { color: #4a8bd8; }
.mobile-nav-btn:hover { color: #cfd3d8; background: transparent; }
/* ── Botón flotante de geolocalización ── */
.btn-geolocate {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #1f2329;
    border: 1px solid #3a3f47;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(0,0,0,0.5);
    z-index: 150;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-geolocate:hover { background: #2a3040; }
.btn-geolocate.localizando { animation: pulsar 1s infinite; border-color: #4a8bd8; }
@keyframes pulsar {
    0%, 100% { box-shadow: 0 3px 12px rgba(0,0,0,0.5); }
    50%       { box-shadow: 0 0 0 8px rgba(74,139,216,0.25); }
}
/* ── Botón flotante de edición (FAB) ── */
.btn-fab {
    position: fixed;
    bottom: 80px;
    left: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #3a78c2;
    border: none;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 150;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn-fab:hover { background: #4a8bd8; transform: scale(1.05); }
/* ── Panel deslizante inferior (bottom sheet) ── */
.mobile-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 300;
    backdrop-filter: blur(2px);
}
.mobile-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-height: 85vh;
    background: #1c2025;
    border-top: 1px solid #3a3f47;
    border-radius: 16px 16px 0 0;
    z-index: 310;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}
.mobile-sheet.abierto {
    transform: translateY(0);
}
.sheet-handle {
    flex: 0 0 auto;
    width: 40px;
    height: 4px;
    background: #3a3f47;
    border-radius: 2px;
    margin: 10px auto 6px;
}
.sheet-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 16px 80px; /* 80px para no quedar bajo la nav */
    -webkit-overflow-scrolling: touch;
}
/* ── Vista de lista en móvil (ocupa todo el espacio del mapa) ── */
#mobile-lista-view {
    position: fixed;
    top: 48px; /* altura topbar */
    bottom: 64px; /* altura mobile-nav */
    left: 0; right: 0;
    background: #1c2025;
    z-index: 100;
    overflow-y: auto;
    display: none;
    -webkit-overflow-scrolling: touch;
}
#mobile-lista-view.visible { display: block; }
/* ── Vista de filtros en móvil ── */
#mobile-filtros-view {
    position: fixed;
    top: 48px;
    bottom: 64px;
    left: 0; right: 0;
    background: #1c2025;
    z-index: 100;
    overflow-y: auto;
    display: none;
    padding: 12px 16px 24px;
    -webkit-overflow-scrolling: touch;
}
#mobile-filtros-view.visible { display: block; }
/* ── Tabla mobile: cards en vez de tabla ── */
.mobile-card {
    background: #1f2329;
    border: 1px solid #2f343b;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 8px 12px;
    cursor: pointer;
    transition: background 0.12s;
}
.mobile-card:active { background: #2a3040; }
.mobile-card.selected { border-color: #4a8bd8; background: #1a2840; }
.mobile-card-ref {
    font-size: 13px;
    font-weight: 600;
    color: #e3e6ea;
    margin-bottom: 4px;
}
.mobile-card-meta {
    font-size: 11px;
    color: #8a9099;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.mobile-card-estado {
    margin-top: 6px;
}
/* ── Vista de acciones rápidas en móvil ── */
#mobile-acciones-view {
    position: fixed;
    top: 48px;
    bottom: 64px;
    left: 0; right: 0;
    background: #1c2025;
    z-index: 100;
    overflow-y: auto;
    display: none;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}
#mobile-acciones-view.visible { display: block !important; }
.mobile-accion-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    font-size: 15px;
    color: #e3e6ea;
    border-bottom: 1px solid #2f343b;
    cursor: pointer;
    transition: background 0.12s;
}
.mobile-accion-item:active { background: #2a3040; }
.mobile-accion-item span:first-child { font-size: 22px; width: 32px; text-align: center; }
@media (max-width: 900px) {
    input, select, textarea {
        font-size: 16px !important; /* evita zoom automático en iOS */
        padding: 10px 12px;
        min-height: 44px;
    }
    button { min-height: 44px; padding: 10px 14px; }
    .sheet-content label { font-size: 14px; }
    .sheet-content .kv dt,
    .sheet-content .kv dd { font-size: 13px; }
    .sheet-content h3 { font-size: 14px; }
    .ctrl-año { bottom: 72px; min-width: 280px; } /* sobre la nav bar */
}
/* ══════════════════ MODO RUTA ══════════════════ */
/* Botón activo en topbar */
.btn-modo-ruta.activo {
    background: #3a78c2;
    color: #fff;
    border-color: #4a8bd8;
}
/* Cursor especial en modo ruta */
.modo-ruta-activo .maplibregl-canvas {
    cursor: crosshair !important;
}
/* Panel flotante de ruta */
.panel-ruta {
    position: fixed;
    top: 60px;
    right: 16px;
    width: 300px;
    max-height: calc(100vh - 140px);
    background: #1c2025;
    border: 1px solid #3a3f47;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 120;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.panel-ruta-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #2f343b;
    flex: 0 0 auto;
}
.panel-ruta-titulo {
    font-size: 13px;
    font-weight: 600;
    color: #e3e6ea;
}
.btn-cerrar-ruta {
    background: transparent;
    border: none;
    color: #6a7280;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    min-height: unset;
}
.btn-cerrar-ruta:hover { color: #e3e6ea; }
.ruta-aviso {
    background: #2a2010;
    border-bottom: 1px solid #5a4010;
    color: #f0a030;
    font-size: 11px;
    padding: 8px 14px;
    line-height: 1.4;
    flex: 0 0 auto;
}
.ruta-lista {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1 1 auto;
}
.ruta-lista li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid #2f343b;
    font-size: 12px;
    color: #cfd3d8;
}
.ruta-lista li:last-child { border-bottom: none; }
.ruta-num {
    background: #3a78c2;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex: 0 0 auto;
}
.ruta-info {
    flex: 1 1 auto;
    overflow: hidden;
}
.ruta-ref {
    font-size: 11px;
    color: #8a9099;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ruta-municipio {
    font-size: 10px;
    color: #6a7280;
    margin-top: 1px;
}
.btn-quitar-parada {
    background: transparent;
    border: none;
    color: #6a7280;
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    min-height: unset;
    flex: 0 0 auto;
}
.btn-quitar-parada:hover { color: #e74c3c; }
.panel-ruta-footer {
    padding: 10px 14px;
    border-top: 1px solid #2f343b;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#ruta-contador {
    font-size: 11px;
    color: #8a9099;
    text-align: center;
}
.ruta-botones {
    display: flex;
    gap: 8px;
}
.ruta-botones button {
    flex: 1;
    font-size: 12px;
    padding: 8px;
}
/* Marcadores numerados en el mapa */
.marker-ruta {
    background: #3a78c2;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    cursor: pointer;
}
/* En móvil el panel va abajo */
@media (max-width: 900px) {
    .panel-ruta {
        top: auto;
        bottom: 72px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 50vh;
    }
}

/* ── Modo añadir puntos: toolbar y lista guardadas ───────────── */
.panel-ruta-toolbar {
    display: flex;
    gap: 6px;
    padding: 8px 14px;
    border-bottom: 1px solid #2f343b;
    flex: 0 0 auto;
}
.panel-ruta-toolbar button { flex: 1; font-size: 11px; padding: 6px 8px; }
.panel-ruta-toolbar .btn-anadir-on {
    background: #2d8a4e;
    color: #fff;
    border-color: #3aa462;
}

.rutas-guardadas {
    border-top: 1px solid #2f343b;
    background: #15181c;
    flex: 0 0 auto;
    max-height: 180px;
    overflow-y: auto;
}
.rutas-guardadas-titulo {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #8a9099;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.rutas-guardadas-lista {
    list-style: none;
    margin: 0;
    padding: 0;
}
.rutas-guardadas-lista li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
    color: #cfd3d8;
    border-top: 1px solid #2f343b;
}
.rutas-guardadas-lista .ruta-nombre {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.rutas-guardadas-lista .ruta-nombre:hover { color: #fff; }
.rutas-guardadas-lista .ruta-meta {
    font-size: 10px;
    color: #6a7280;
}
.rutas-guardadas-lista .btn-eliminar-ruta {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #ff8a80;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    min-height: unset;
    line-height: 1;
    flex: 0 0 auto;
}
.rutas-guardadas-lista .btn-eliminar-ruta:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

/* Marker punto libre (sin parcela) */
.marker-ruta.libre { background: #f39c12; }

/* ══════════════════ REPORTAJE FOTOGRÁFICO ══════════════════ */
.fotos-galeria {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 6px;
    margin-top: 10px;
}
.foto-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    overflow: hidden;
    background: #2a2f36;
    cursor: pointer;
    border: 1px solid #3a4049;
}
.foto-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.foto-thumb .foto-del {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 13px;
    line-height: 22px;
    cursor: pointer;
    padding: 0;
}
.foto-thumb .foto-del:hover { background: #e74c3c; }
.foto-preview {
    margin-top: 10px;
    padding: 8px;
    background: #20242a;
    border: 1px solid #3a4049;
    border-radius: 8px;
}
.foto-preview img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    margin-bottom: 8px;
}
.foto-vacia {
    grid-column: 1 / -1;
    color: #8a9099;
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
}

/* ══════════════════ LIGHTBOX ══════════════════ */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox.hidden { display: none; }
.lightbox img {
    max-width: 92vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 6px;
}
.lightbox-cerrar {
    position: absolute;
    top: 14px;
    right: 18px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
}
.lightbox-borrar {
    position: absolute;
    top: 14px;
    right: 72px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(231,76,60,0.75);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.lightbox-borrar:hover { background: #e74c3c; }
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 64px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 34px;
    cursor: pointer;
    border-radius: 8px;
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-info {
    position: absolute;
    bottom: 16px;
    left: 0; right: 0;
    text-align: center;
    color: #e3e6ea;
    font-size: 13px;
    padding: 0 12px;
}

/* ══════════════════ PANEL DIBUJAR CAMINANDO ══════════════════ */
.panel-caminar {
    position: fixed;
    left: 50%;
    bottom: 84px;
    transform: translateX(-50%);
    width: min(360px, 92vw);
    background: #1c2025;
    border: 1px solid #3a4049;
    border-radius: 12px;
    padding: 14px 16px;
    z-index: 1200;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.panel-caminar.hidden { display: none; }
.panel-caminar-titulo { font-weight: 700; color: #e3e6ea; margin-bottom: 6px; }
.panel-caminar-info { font-size: 12px; color: #8a9099; margin-bottom: 8px; }
.panel-caminar-stats { font-size: 13px; color: #cfd3d8; margin-bottom: 10px; }
.btn-dibujar-gps.activo,
.btn-dibujar.activo {
    background: #3a78c2;
    color: #fff;
    border-color: #4a8bd8;
}

/* ══════════════════ ENVÍO POR EMAIL (modal informe) ══════════════════ */
.modal-email {
    border-top: 1px solid #2f343b;
    padding: 12px 28px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.modal-email .info { flex: 1 1 100%; margin: 0; }
.modal-email input[type="email"] {
    flex: 1 1 200px;
    min-height: 40px;
}
