:root {
    --primary: #1659ef;
    --primary-hover: #1247cc;
    --primary-soft: rgba(22, 89, 239, .08);
    --primary-border: rgba(22, 89, 239, .2);

    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-blur: rgba(255, 255, 255, .92);
    --surface-elevated: rgba(255, 255, 255, .98);

    --text: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --border: #e2e8f0;
    --divider: rgba(15, 23, 42, .06);

    --disponible: #22c55e;
    --apartado: #f59e0b;
    --vendido: #ef4444;
    --reservado: #8b5cf6;
    --mantenimiento: #6b7280;
    --escondido: #1f2937;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, .15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --blur: blur(10px);
    --transition: all .2s ease;
    --transition-slow: all .25s cubic-bezier(.25, .8, .25, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, select, input, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button { cursor: pointer; border: 0; background: none; }

/* ==========================================================
   MAIN APP LAYOUT (map page)
   ========================================================== */

.map-app {
    position: relative;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    background: var(--bg);
}

#map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ==========================================================
   FABS (floating action buttons)
   ========================================================== */

.fabs {
    position: absolute;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 26px;   /* espacio extra para el título debajo de cada botón */
    z-index: 20;
}

.fabs-left { left: 16px; }
.fabs-right { right: 16px; }

.fab {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    transition: var(--transition);
}

.fab:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: var(--primary-border);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.fab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.fab.active:hover {
    background: var(--primary-hover);
    color: #fff;
}

.fab svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* FAB compass: la aguja rota según el bearing del mapa.
   El transform-origin centrado mantiene la aguja anclada. */
#fabCompass .compass-needle {
    transition: transform .12s linear;
    transform-origin: 50% 50%;
}

/* Título permanente debajo de cada FAB, para que se sepa qué hace cada botón
   sin tener que pasar el mouse. Centrado bajo el círculo. */
.fab[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, .78);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .01em;
    padding: 2px 7px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 1;
    pointer-events: none;
    z-index: 30;
}

/* El botón activo resalta también su título */
.fab.active[data-tooltip]::after {
    background: var(--primary);
}

@media (max-width: 600px) {
    #fabGeolocate.active[data-tooltip]::after {
        white-space: pre-line;
        line-height: 1.15;
        text-align: center;
    }
}

/* Hide fab by default, .visible to show */
.fab.hidden { display: none; }

/* ==========================================================
   SIDEBAR (lista de lotes)
   ========================================================== */

.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 360px;
    height: 100vh;
    height: 100svh;
    background: var(--surface);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    box-shadow: var(--shadow-md);
    transform: translateX(-100%);
    transition: var(--transition-slow);
    display: flex;
    flex-direction: column;
    z-index: 30;
    overflow: hidden;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 16px 20px;
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .05);
    z-index: 1;
}

.sidebar-header .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .2px;
}

.sidebar-subtitle {
    font-size: 12px;
    opacity: .85;
}

.sidebar-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #fff;
    transition: var(--transition);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, .15);
}

.sidebar-search {
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: rgba(255, 255, 255, .16);
    backdrop-filter: blur(4px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 13px;
}

.sidebar-search input::placeholder { color: rgba(255, 255, 255, .72); }
.sidebar-search input:focus { border-color: rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .22); }

.sidebar-search svg {
    position: absolute;
    top: 50%;
    left: 11px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, .7);
    pointer-events: none;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--primary-border);
    border-radius: 4px;
}

.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: rgba(22, 89, 239, .4);
}

.sidebar-stats {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-stats strong {
    color: var(--text);
    font-weight: 600;
}

/* ==========================================================
   LOT CARD (en sidebar)
   ========================================================== */

.lot-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lot-card:hover {
    border-color: var(--primary-border);
    background: var(--primary-soft);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.lot-card.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--shadow-sm);
}

.lot-card .title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.lot-card .meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.lot-card .meta .sep { opacity: .5; }

.lot-card .bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
}

.lot-card .price {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.lot-card .area {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================
   ESTADO PILL / CHIP
   ========================================================== */

.estado-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: #fff;
    flex-shrink: 0;
}

/* Chip de sección: mismo pill que el estado, pero con el color del plano
   maestro y texto oscuro (los colores de sección son pastel). El color
   propio evita que el color custom del tooltip lo herede. */
.seccion-chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .2px;
    color: #1f2937;
    white-space: nowrap;
}

.estado-pill.estado-disponible     { background: var(--disponible); }
.estado-pill.estado-apartado       { background: var(--apartado); }
.estado-pill.estado-vendido        { background: var(--vendido); }
.estado-pill.estado-reservado      { background: var(--reservado); }
.estado-pill.estado-mantenimiento  { background: var(--mantenimiento); }
.estado-pill.estado-escondido      { background: var(--escondido); }

/* ==========================================================
   FILTER PANEL (flotante top-center)
   ========================================================== */

.filter-panel {
    position: absolute;
    top: 16px;
    left: 76px;
    transform: translateX(-12px);
    opacity: 0;
    pointer-events: none;
    width: 320px;
    max-width: calc(100% - 92px);
    max-height: calc(100vh - 32px);
    max-height: calc(100svh - 32px);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 25;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filter-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.filter-panel .filter-panel-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.filter-panel-header {
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-panel-header .title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
}

.filter-panel-body {
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-section-title {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin: 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-section-title:first-child { margin-top: 0; }

.filter-section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--primary);
    border-radius: 2px;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
}

.filter-range {
    padding: 4px 4px 12px;
}

.filter-range-values {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-bottom: 12px;
}

.filter-range-values span:first-child { color: var(--text-muted); font-weight: 500; }
.filter-range-values span:last-child  { color: var(--text-muted); font-weight: 500; }
.filter-range-values strong { color: var(--primary); }

.dual-range {
    position: relative;
    height: 22px;
    display: flex;
    align-items: center;
    padding: 0 2px;
}

.dual-range-track {
    position: absolute;
    top: 50%;
    left: 2px;
    right: 2px;
    height: 4px;
    transform: translateY(-50%);
    background: var(--border);
    border-radius: 2px;
    pointer-events: none;
}

.dual-range-fill {
    position: absolute;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    background: var(--primary);
    border-radius: 2px;
    pointer-events: none;
}

.dual-range input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 22px;
    margin: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

/* WebKit thumb */
.dual-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--primary);
    cursor: grab;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
    transition: transform .12s ease, box-shadow .12s ease;
}
.dual-range input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
.dual-range input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.18);
    box-shadow: 0 2px 8px rgba(22, 89, 239, .35);
}

/* Firefox thumb */
.dual-range input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--primary);
    cursor: grab;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}

/* Firefox track (hide default) */
.dual-range input[type="range"]::-moz-range-track {
    background: transparent;
    border: 0;
}

.dual-range-absolute-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-subtle);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.filter-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--divider);
    display: flex;
    justify-content: flex-end;
}

.filter-actions .btn {
    font-size: 12px;
    padding: 6px 12px;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.filter-check:hover {
    background: var(--primary-soft);
}

.filter-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.filter-check .swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.filter-check .label {
    flex: 1;
    font-size: 13px;
    color: var(--text);
}

.filter-check .count {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================
   HOVER TOOLTIP (esquina inferior derecha)
   ========================================================== */

.hover-tooltip {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 220px;
    max-width: 280px;
    padding: 12px 14px;
    background: var(--surface-blur);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .15s ease, transform .15s ease;
    z-index: 15;
}

.hover-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.hover-tooltip .tt-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.hover-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 11.5px;
}

.hover-tooltip .tt-row span { opacity: .6; text-transform: uppercase; letter-spacing: .3px; font-size: 10px; }
.hover-tooltip .tt-row strong { font-weight: 600; font-variant-numeric: tabular-nums; }

@media (hover: none) {
    .hover-tooltip { display: none; }
}

/* ==========================================================
   MAPLIBRE POPUP OVERRIDES
   ========================================================== */

.maplibregl-popup-content {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
    overflow: hidden;
    border: 1px solid var(--border);
}

.maplibregl-popup-close-button {
    font-size: 18px !important;
    padding: 6px 10px !important;
    color: var(--text-muted) !important;
}

.polygon-popup {
    min-width: 240px;
    font-family: inherit;
}

/* Barra del logo del desarrollo, arriba del header. Fondo blanco para que un
   logo a color se lea bien (el header va en el color de marca). */
.polygon-popup .pp-logobar {
    background: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
}

.polygon-popup .pp-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 190px;
    max-height: 42px;
}

.polygon-popup .pp-header {
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
}

.polygon-popup .pp-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.polygon-popup .pp-subtitle {
    font-size: 11px;
    opacity: .85;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.polygon-popup .pp-body {
    padding: 12px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.polygon-popup .pp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    gap: 10px;
}

.polygon-popup .pp-row > span { opacity: .6; text-transform: uppercase; letter-spacing: .3px; font-size: 10px; }
.polygon-popup .pp-row > strong { font-weight: 600; font-variant-numeric: tabular-nums; }

.polygon-popup select {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
    font-size: 13px;
    cursor: pointer;
}

.polygon-popup select:focus {
    border-color: var(--primary);
}

.polygon-popup .pp-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, .08);
    display: flex;
    gap: 8px;
}

.polygon-popup .pp-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    justify-content: center;
    transition: var(--transition);
    opacity: .85;
    text-decoration: none;
    font-family: inherit;
}

.polygon-popup .pp-action-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary-border);
    opacity: 1;
    text-decoration: none;
}

.polygon-popup .pp-action-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
    opacity: 1;
}

.polygon-popup .pp-action-btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.polygon-popup .pp-action-btn svg {
    flex-shrink: 0;
}

/* ==========================================================
   MAPLIBRE CONTROLS (override)
   ========================================================== */

.maplibregl-ctrl-group {
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid var(--border) !important;
    overflow: hidden;
}

.maplibregl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
}

.maplibregl-ctrl button:hover {
    background: var(--primary-soft) !important;
}

.maplibregl-ctrl-scale {
    background: var(--surface-blur) !important;
    backdrop-filter: var(--blur);
    border-color: var(--border) !important;
    color: var(--text) !important;
    font-size: 11px !important;
    padding: 3px 6px !important;
    border-radius: 4px !important;
}

.maplibregl-ctrl-attrib {
    background: var(--surface-blur) !important;
    backdrop-filter: var(--blur);
    font-size: 10px !important;
    border-radius: 4px 0 0 0 !important;
}

/* ==========================================================
   TOAST
   ========================================================== */

/* WhatsApp floating button */
.whatsapp-fab {
    position: absolute;
    left: 16px;
    bottom: 40px;
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0 14px 0 0;
    height: 52px;
    border-radius: 999px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, .35);
    cursor: pointer;
    z-index: 20;
    transition: all .25s cubic-bezier(.4, 0, .2, 1);
    max-width: 52px;
    overflow: hidden;
}

.whatsapp-fab:hover {
    max-width: 200px;
    padding-right: 18px;
    box-shadow: 0 6px 20px rgba(37, 211, 102, .45);
    transform: translateY(-2px);
    text-decoration: none;
}

.whatsapp-fab svg {
    flex-shrink: 0;
    margin: 0 13px;
}

.whatsapp-fab-label {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .2s ease .05s;
    letter-spacing: .3px;
}

.whatsapp-fab:hover .whatsapp-fab-label {
    opacity: 1;
}

.whatsapp-fab.hidden { display: none; }

@media (max-width: 640px) {
    .whatsapp-fab {
        bottom: 24px;
        left: 16px;
        height: 48px;
        max-width: 48px;
    }
    .whatsapp-fab svg {
        width: 22px;
        height: 22px;
        margin: 0 12px;
    }
    .whatsapp-fab:hover {
        max-width: 48px;
        padding-right: 0;
    }
    .whatsapp-fab-label { display: none; }
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    padding: 11px 18px;
    background: rgba(15, 23, 42, .95);
    color: #fff;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.err {
    background: #7f1d1d;
}

/* ==========================================================
   GEOLOCATE MARKER (punto pulsante)
   ========================================================== */

.user-location {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--primary), 0 2px 8px rgba(22, 89, 239, .4);
    position: relative;
}

.user-location::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: rgba(22, 89, 239, .3);
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0%   { transform: scale(.6); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* ==========================================================
   LOGIN PAGE
   ========================================================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg) 0%, #e8edf5 100%);
    padding: 24px;
}

.login-box {
    background: var(--surface);
    padding: 32px 30px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}

.login-box h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 22px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.field label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}

.field input[type="text"],
.field input[type="password"] {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition);
}

.field input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.login-box .error {
    color: var(--vendido);
    font-size: 12px;
    margin-top: 4px;
    min-height: 18px;
}

.login-box .hint {
    margin-top: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    font-size: 13px;
}

.btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    text-decoration: none;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
}

.btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn.danger {
    background: transparent;
    color: var(--vendido);
    border-color: var(--vendido);
}

.btn.block {
    display: flex;
    width: 100%;
    padding: 11px 16px;
}

/* ==========================================================
   ADMIN PAGE
   ========================================================== */

.admin-page {
    min-height: 100vh;
    background: var(--bg);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    gap: 20px;
    flex-wrap: wrap;
}

.admin-header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.admin-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.admin-nav a {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.admin-nav a:hover {
    background: var(--primary-soft);
    color: var(--primary);
    text-decoration: none;
}

.admin-nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

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

.admin-header .user-badge {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 500;
}

.admin-header .user-badge.super {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #78350f;
}

/* Admin section cards (panels de configuración) */
.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.admin-section h2 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
}

.admin-section .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}

.admin-section .form-row,
.modal-panel .form-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 12px 16px;
    align-items: center;
    margin-bottom: 10px;
}

.admin-section .form-row label,
.modal-panel .form-row label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.admin-section .form-row input[type="text"],
.admin-section .form-row input[type="url"],
.admin-section .form-row input[type="number"],
.admin-section .form-row select,
.admin-section .form-row textarea,
.modal-panel .form-row input[type="text"],
.modal-panel .form-row input[type="url"],
.modal-panel .form-row input[type="number"],
.modal-panel .form-row select,
.modal-panel .form-row textarea {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    width: 100%;
    font-family: inherit;
    transition: var(--transition);
}

.admin-section .form-row input:focus,
.admin-section .form-row select:focus,
.admin-section .form-row textarea:focus,
.modal-panel .form-row input:focus,
.modal-panel .form-row select:focus,
.modal-panel .form-row textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.admin-section .form-row input[type="color"],
.modal-panel .form-row input[type="color"] {
    width: 64px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    padding: 3px;
}

/* Modal: layout responsivo en móvil — labels arriba en lugar de columna 200px */
@media (max-width: 700px) {
    .modal-panel .form-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

/* Help text dentro de form-row del modal — mismo styling que admin-section */
.modal-panel .form-row .help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
}

.admin-section .actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.admin-section .help {
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 3px;
}

@media (max-width: 720px) {
    .admin-section .form-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Toggle group (admin) — botones segmentados estilo iOS */
.toggle-group {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.toggle-group .toggle-btn {
    flex: 1;
    padding: 8px 18px;
    background: transparent;
    color: var(--text-muted);
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all .15s ease;
    white-space: nowrap;
}
.toggle-group .toggle-btn:hover {
    color: var(--text);
}
.toggle-group .toggle-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
}

.modal-panel {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 26px;
    border-bottom: 1px solid var(--divider);
    background: linear-gradient(180deg, var(--surface) 0%, rgba(244, 246, 250, .5) 100%);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.modal-header .sidebar-close {
    color: var(--text-muted);
    background: transparent;
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.modal-header .sidebar-close:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.modal-panel form {
    overflow-y: auto;
    flex: 1;
    padding: 22px 26px 0;
    display: flex;
    flex-direction: column;
}

/* Cuando dentro del form hay form-rows, el último antes de actions
   no debería pegarse al footer */
.modal-panel form > .form-row:last-of-type {
    margin-bottom: 8px;
}

/* Footer de acciones del modal: separador + fondo sutil + sticky bottom */
.modal-panel form .actions {
    margin: 18px -26px 0;
    padding: 14px 26px;
    border-top: 1px solid var(--divider);
    background: linear-gradient(180deg, transparent 0%, rgba(244, 246, 250, .4) 100%);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* En mobile el footer apila botones con full-width y el primario primero */
@media (max-width: 700px) {
    .modal-panel form .actions {
        flex-direction: column-reverse;
    }
    .modal-panel form .actions .btn {
        width: 100%;
    }
}

.modal-section {
    padding: 18px 26px;
    border-bottom: 1px solid var(--divider);
}

.modal-section:last-of-type {
    border-bottom: 0;
}

.modal-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--primary);
    border-radius: 2px;
}

@media (min-width: 701px) {
    .modal-panel .form-row {
        grid-template-columns: 150px 1fr;
    }
}

.modal-panel .actions {
    padding: 16px 26px;
    border-top: 1px solid var(--divider);
    background: rgba(244, 246, 250, .5);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin: 0;
    flex-shrink: 0;
}

/* Color input with swatch preview */
.color-input-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.color-input-wrap input[type="color"] {
    width: 34px !important;
    height: 28px !important;
    border: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    background: transparent;
}

.color-input-wrap .hex-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    min-width: 60px;
}

/* Inline row of inputs (for range sliders etc.) */
.inline-fields {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-fields input[type="number"] {
    max-width: 90px;
}

.inline-fields small {
    font-size: 11px;
    color: var(--text-muted);
}

textarea {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    transition: var(--transition);
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* States editor (admin/estados.php) */
.state-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    gap: 18px;
    flex-wrap: wrap;
    transition: var(--transition);
}

.state-row:hover {
    border-color: var(--primary-border);
    box-shadow: var(--shadow-sm);
}

.state-row-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 200px;
}

.state-swatch {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid transparent;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

.state-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.state-info strong {
    font-size: 14px;
    color: var(--text);
}

.state-code {
    font-size: 11px;
    color: var(--text-subtle);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.state-fields {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.state-fields label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.state-fields .visible-toggle {
    align-items: center;
    flex-direction: column;
}

/* Fields check grid (admin forms) */
.fields-check-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 12px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.fields-check-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.fields-check-grid label:hover {
    background: var(--primary-soft);
}

.fields-check-grid input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

@media (max-width: 720px) {
    .fields-check-grid { grid-template-columns: 1fr; }
}

/* Welcome popup modal (map) */
.welcome-modal {
    --welcome-header-bg: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    --welcome-header-color: #ffffff;
    --welcome-btn-bg: var(--primary);
    --welcome-btn-color: #ffffff;

    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s cubic-bezier(.4, 0, .2, 1);
}

.welcome-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.welcome-modal .welcome-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
}

.welcome-panel {
    position: relative;
    background: var(--surface);
    border-radius: 18px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .8) inset,
        0 20px 60px -12px rgba(15, 23, 42, .25),
        0 8px 24px -8px rgba(15, 23, 42, .15);
    width: 100%;
    max-width: 460px;
    /* Stack de fallbacks para iOS Chrome/Safari (URL bars dinámicas):
       svh = small viewport height (la más conservadora — siempre cabe).
       dvh = dynamic viewport height (cambia con la URL bar).
       vh  = legacy fallback. */
    max-height: 85vh;
    max-height: 85dvh;
    max-height: 85svh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, .8);
    transform: translateY(20px) scale(.97);
    opacity: 0;
    transition:
        transform .35s cubic-bezier(.34, 1.56, .64, 1),
        opacity .25s ease-out;
}

.welcome-modal.visible .welcome-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Barra del logo del desarrollo, arriba del header. Fondo blanco para que un
   logo a color se lea bien (el header va en el color de marca). */
.welcome-logobar {
    background: #ffffff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
}

.welcome-logobar[hidden] { display: none; }

.welcome-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 260px;
    max-height: 60px;
}

.welcome-header {
    position: relative;
    padding: 32px 28px 22px;
    background: var(--welcome-header-bg);
    color: var(--welcome-header-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    overflow: hidden;
}

/* Decorative glow blob in the header for premium feel */
.welcome-header::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .25) 0%, transparent 65%);
    pointer-events: none;
}

.welcome-header::after {
    content: '';
    position: absolute;
    bottom: -50%;
    left: -10%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 0, 0, .1) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-header h2 {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.4px;
    line-height: 1.25;
    color: inherit;
    /* En navegadores que lo soporten, balancear el wrap si se va a 2 líneas */
    text-wrap: balance;
    -webkit-text-wrap: balance;
}

.welcome-close {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--welcome-header-color);
    background: rgba(255, 255, 255, .15);
    backdrop-filter: blur(6px);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, .2);
}

.welcome-close:hover {
    background: rgba(255, 255, 255, .28);
    transform: scale(1.08) rotate(90deg);
}

.welcome-body {
    padding: 24px 28px 18px;
    overflow-y: auto;
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--text);
}

.welcome-body h1, .welcome-body h2, .welcome-body h3 {
    margin: 18px 0 10px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -.2px;
}

.welcome-body h1:first-child, .welcome-body h2:first-child, .welcome-body h3:first-child,
.welcome-body p:first-child {
    margin-top: 0;
}

.welcome-body p {
    margin: 0 0 12px;
    color: var(--text);
}

.welcome-body a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color .15s ease;
}

.welcome-body a:hover {
    border-bottom-color: var(--primary);
}

.welcome-body img {
    max-width: 100%;
    border-radius: 10px;
    margin: 10px 0;
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, .12);
}

.welcome-body iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 10px;
    margin: 10px 0;
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, .12);
}

.welcome-body ul {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.welcome-body ul li {
    padding: 8px 12px;
    margin: 4px 0;
    line-height: 1.5;
    background: rgba(15, 23, 42, .03);
    border-radius: 8px;
    transition: background .15s ease;
}

.welcome-body ul li:hover {
    background: rgba(15, 23, 42, .05);
}

.welcome-body ol {
    counter-reset: welcome-counter;
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.welcome-body ol li {
    counter-increment: welcome-counter;
    position: relative;
    padding: 6px 0 6px 36px;
    margin: 4px 0;
}

.welcome-body ol li::before {
    content: counter(welcome-counter);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-body code {
    background: var(--primary-soft);
    color: var(--primary);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 12.5px;
    font-weight: 500;
}

.welcome-body strong {
    color: var(--text);
    font-weight: 700;
}

/* ── Legend (estados con bullet de color) ── */
/* Una sola columna: los nombres de sección llevan descripción al lado y
   en dos columnas se partían a media palabra ("Cardone / 400"). */
.welcome-body .welcome-legend {
    margin: 8px 0 16px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.welcome-body .welcome-legend li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, .03);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.35;
    border: 0;
    margin: 0;
}

/* El nombre de la sección nunca se parte; la descripción sí puede fluir. */
.welcome-body .welcome-legend li > strong {
    white-space: nowrap;
}

.welcome-body .welcome-legend li:hover {
    background: rgba(15, 23, 42, .05);
}

.welcome-body .welcome-legend .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    /* Alinea ópticamente con la primera línea del texto, aunque envuelva */
    margin-top: 3px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 1px 3px rgba(0, 0, 0, .2);
}

.welcome-body .welcome-legend strong {
    font-weight: 700;
    color: var(--text);
}

/* ── Tips (FABs con icono SVG) ── */
.welcome-body .welcome-tips {
    margin: 8px 0 16px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.welcome-body .welcome-tips li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, .03);
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.4;
    border: 0;
    margin: 0;
}

.welcome-body .welcome-tips li:hover {
    background: rgba(15, 23, 42, .05);
}

.welcome-body .welcome-tips .icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.welcome-body .welcome-tips .icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.welcome-body .welcome-tips strong {
    font-weight: 700;
    color: var(--text);
    margin-right: 4px;
}

/* Intro paragraph estilo "lead" */
.welcome-body .lead {
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.55;
    margin: 0 0 18px;
}

/* Hint card destacado: tip de interacción (ej. "toca un lote") */
.welcome-body .welcome-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 6px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, rgba(255, 255, 255, .4) 100%);
    border: 1px solid var(--primary-border);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
}

.welcome-body .welcome-hint .hint-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.welcome-body .welcome-hint .hint-icon svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.4;
}

/* Footer-style closing line dentro del body */
.welcome-body .welcome-cta {
    margin: 18px 0 0;
    padding: 14px 14px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, rgba(255, 255, 255, .5) 100%);
    border: 1px solid var(--primary-border);
    border-radius: 10px;
    font-size: 13.5px;
    color: var(--text);
    text-align: center;
}

.welcome-body .welcome-cta a {
    color: var(--primary);
    font-weight: 700;
    border-bottom: 0;
}

.welcome-footer {
    padding: 16px 28px 22px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    background: linear-gradient(0deg, rgba(248, 250, 252, .85) 0%, rgba(248, 250, 252, 0) 100%);
}

.welcome-footer .welcome-action {
    background: var(--welcome-btn-bg);
    color: var(--welcome-btn-color);
    border: 0;
    padding: 11px 26px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .25) inset,
        0 4px 12px -3px var(--welcome-btn-bg);
    letter-spacing: .1px;
}

.welcome-footer .welcome-action:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .3) inset,
        0 6px 16px -3px var(--welcome-btn-bg);
}

.welcome-footer .welcome-action:active {
    transform: translateY(0);
    filter: brightness(.95);
}

/* ── Responsive: ajustes para móvil ── */
@media (max-width: 520px) {
    .welcome-modal {
        padding: 8px;
        /* Anclar arriba en mobile en vez de centrar — así el título siempre
           se ve aunque el viewport sea bajo (URL bar visible) */
        align-items: flex-start;
    }
    .welcome-panel {
        /* Triple fallback: vh → dvh → svh (la más conservadora gana) */
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        max-height: calc(100svh - 16px);
        border-radius: 14px;
        margin-top: 8px;
    }
    .welcome-header {
        padding: 16px 16px 12px;
        gap: 10px;
    }
    .welcome-header h2 {
        font-size: 17px;
        letter-spacing: -.3px;
        line-height: 1.2;
    }
    /* Quitar los blobs decorativos que ocupan espacio visual en mobile */
    .welcome-header::before,
    .welcome-header::after {
        display: none;
    }
    .welcome-close {
        width: 26px;
        height: 26px;
    }
    .welcome-close svg {
        width: 14px;
        height: 14px;
    }
    .welcome-body {
        padding: 14px 16px 10px;
        font-size: 13px;
    }
    .welcome-body h3 {
        margin: 12px 0 6px;
        font-size: 14px;
    }
    .welcome-body .lead {
        margin-bottom: 12px;
        font-size: 12.5px;
    }
    .welcome-footer {
        padding: 10px 16px 14px;
    }
    .welcome-footer .welcome-action {
        width: 100%;
        padding: 12px 20px;
    }
    /* La grid de estados en móvil queda 2 columnas pero con menos gap */
    .welcome-body .welcome-legend {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
        margin: 6px 0 12px;
    }
    .welcome-body .welcome-legend li {
        padding: 7px 9px;
        font-size: 12px;
        gap: 8px;
    }
    .welcome-body .welcome-legend .dot {
        width: 10px;
        height: 10px;
    }
    .welcome-body .welcome-tips {
        gap: 4px;
    }
    .welcome-body .welcome-tips li {
        padding: 8px 10px;
        font-size: 12px;
        gap: 10px;
    }
    .welcome-body .welcome-tips .icon {
        width: 26px;
        height: 26px;
    }
    .welcome-body .welcome-tips .icon svg {
        width: 14px;
        height: 14px;
    }
    .welcome-body .welcome-hint {
        padding: 10px 12px;
        margin: 2px 0 4px;
        font-size: 12px;
    }
    .welcome-body .welcome-hint .hint-icon {
        width: 24px;
        height: 24px;
    }
    .welcome-body .welcome-cta {
        padding: 10px 12px;
        font-size: 12.5px;
        margin-top: 12px;
    }
}

/* En pantallas muy estrechas, las legend cards van a 1 columna */
@media (max-width: 360px) {
    .welcome-body .welcome-legend {
        grid-template-columns: 1fr;
    }
}

/* File input estético */
input[type="file"] {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: var(--transition);
}

input[type="file"]:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Setting toggles */
.setting-toggle {
    border-bottom: 1px solid var(--divider);
    padding: 4px 0;
}
.setting-toggle:last-child { border-bottom: 0; }

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 4px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-item:hover {
    background: var(--primary-soft);
    border-radius: var(--radius-sm);
    margin: 0 -8px;
    padding: 14px 12px;
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.toggle-info strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.toggle-info span {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Apple-style switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    transition: .25s;
    border-radius: 999px;
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: .25s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Action buttons column on table */
.markers .row-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.markers .row-actions .btn {
    padding: 5px 10px;
    font-size: 12px;
}

.markers .cell-center {
    text-align: center;
}

/* Drag handle para reordenar capas (admin/capas.php) */
.layers-table .drag-handle-cell {
    width: 32px;
    padding: 0 6px;
    text-align: center;
    vertical-align: middle;
}
.layers-table .drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
    transition: background .15s, color .15s;
}
.layers-table .drag-handle:hover {
    background: var(--bg-soft, #f1f5f9);
    color: var(--text);
}
.layers-table .drag-handle:active {
    cursor: grabbing;
}
.layers-table .drag-handle svg {
    fill: currentColor;
    pointer-events: none;  /* el drag inicia en el span, no en el SVG */
}
.layers-table tr.row-dragging {
    opacity: .35;
}
.layers-table tr.drop-indicator td {
    padding: 0;
    border: 0;
    height: 0;
}
.layers-table tr.drop-indicator .drop-indicator-line {
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    margin: -1.5px 0;
}

.markers .cell-truncate {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-muted);
}


.admin-body {
    padding: 24px;
    max-width: 1800px;
    margin: 0 auto;
}

.admin-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.admin-filters select,
.admin-filters input {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    min-width: 180px;
    outline: none;
    transition: var(--transition);
}

.admin-filters select:focus,
.admin-filters input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.admin-filters .info {
    color: var(--text-muted);
    font-size: 13px;
    margin-left: auto;
}

table.markers {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

table.markers th,
table.markers td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--divider);
    font-size: 13px;
}

table.markers th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-size: 11px;
}

table.markers tr:last-child td { border-bottom: 0; }
table.markers tr:hover { background: var(--primary-soft); }

table.markers td select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
}

table.markers td select:focus {
    border-color: var(--primary);
}

.precio-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

table.markers td input[data-precio] {
    background: var(--surface);
    color: var(--text);
    border: 1px solid transparent;
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 600;
    outline: none;
    transition: var(--transition);
    width: 130px;
    font-family: inherit;
    font-size: inherit;
    text-align: right;
    cursor: text;
}

table.markers td input[data-precio]:hover {
    border-color: var(--border);
    background: var(--bg);
}

table.markers td input[data-precio]:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
    font-weight: 500;
    text-align: left;
}

table.markers td input[data-precio]:disabled {
    opacity: 0.5;
    cursor: wait;
}

table.markers td input[data-precio]::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.precio-unit {
    color: var(--text-muted);
    font-size: 0.82em;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.counter {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.counter.counter-warn {
    background: #fef3c7;
    color: #92400e;
}

.counter.counter-danger {
    background: #fee2e2;
    color: #991b1b;
}

.pager {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    align-items: center;
}

.pager .info {
    color: var(--text-muted);
    font-size: 12px;
}

/* ==========================================================
   EXPORT / ENTREGA (admin/entregar.php)
   ========================================================== */

.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 12px;
}

.export-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.export-card__head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.export-card__icon {
    font-size: 28px;
    line-height: 1;
    background: var(--primary-soft);
    padding: 10px 12px;
    border-radius: 10px;
}

.export-card__head h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
}

.export-card__head p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.45;
}

.export-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.export-form input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    text-transform: none;
    letter-spacing: normal;
    transition: var(--transition);
}

.export-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.export-checkbox {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 13px !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-weight: 500 !important;
    color: var(--text) !important;
    cursor: pointer;
    padding: 6px 0;
}

.export-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.export-checkbox code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.btn.block {
    width: 100%;
    justify-content: center;
}

.export-card__details {
    border-top: 1px solid var(--divider);
    padding-top: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.export-card__details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    user-select: none;
}

.export-card__details ul,
.export-card__details ol {
    margin: 6px 0 0 0;
    padding-left: 20px;
    line-height: 1.6;
}

.export-card__details code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text);
}

/* ==========================================================
   MOBILE
   ========================================================== */

@media (max-width: 640px) {
    .fab {
        width: 42px;
        height: 42px;
    }
    .fab svg {
        width: 18px;
        height: 18px;
    }
    .sidebar {
        width: 100%;
        border-radius: 0;
    }
    .hover-tooltip {
        display: none;
    }
    .filter-panel {
        left: 12px;
        width: calc(100% - 24px);
        max-width: calc(100% - 24px);
    }
    .admin-body {
        padding: 12px;
    }
    .admin-filters select,
    .admin-filters input {
        min-width: 100%;
    }
}

/* ==========================================================
   LEYENDA DE SECCIONES — acompaña a la vista por sección
   ========================================================== */

.seccion-legend {
    position: fixed;
    right: 76px;
    bottom: 24px;
    z-index: 18;
    background: var(--surface-blur, rgba(255, 255, 255, .94));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(15, 23, 42, .07);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .8) inset,
        0 12px 30px -12px rgba(15, 23, 42, .28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
}

.seccion-legend.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.seccion-legend-title {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--text-muted, #64748b);
    margin-bottom: 8px;
}

.seccion-legend ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.seccion-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text, #0f172a);
    white-space: nowrap;
}

.seccion-legend i {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    flex: none;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .14);
}

@media (max-width: 600px) {
    .seccion-legend {
        right: 12px;
        bottom: 84px;
        padding: 10px 12px;
    }
    .seccion-legend li { font-size: 11.5px; }
}

/* ==========================================================
   FAB CICLADOR DE VISTAS — muestra el ícono del modo activo
   ========================================================== */

.fab-view svg { display: none; }
.fab-view[data-view="inventario"] svg[data-view-icon="inventario"],
.fab-view[data-view="seccion"]    svg[data-view-icon="seccion"],
.fab-view[data-view="neutral"]    svg[data-view-icon="neutral"] {
    display: block;
}

/* La vista neutral es la única "apagada": se marca como activa para que
   se note que el mapa no está mostrando información. */
.fab-view[data-view="neutral"] {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ==========================================================
   INDICADORES DIRECCIONALES A POIs (cerro, mar)
   Botones estilo FAB en la columna izquierda; dentro, una flecha que
   apunta al punto real. Heredan de .fab el círculo y el título abajo.
   ========================================================== */

.poi-fab .poi-arrow {
    /* El giro (rotate) lo pone el JS inline según el rumbo al POI. */
    transition: transform .2s ease;
}

/* El color de la flecha (café = cerro, azul = mar) va inline por POI; aquí
   solo aseguramos que el hover del FAB no lo pise con el color primario. */
.poi-fab:hover .poi-arrow {
    filter: brightness(.92);
}
