: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: 10px;
    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[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: rgba(15, 23, 42, .92);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 9px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 30;
}

.fabs-right .fab[data-tooltip]::after {
    left: auto;
    right: calc(100% + 10px);
    transform: translateY(-50%) translateX(4px);
}

.fab:hover[data-tooltip]::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* 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;
}

.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;
}

.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 {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 12px 16px;
    align-items: center;
    margin-bottom: 10px;
}

.admin-section .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 {
    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 {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.admin-section .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;
}

.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;
    }
}

/* 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;
}

.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;
}

.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 .2s ease;
}

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

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

.welcome-panel {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    transform: translateY(16px);
    transition: transform .25s ease;
}

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

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

.welcome-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.2px;
    color: inherit;
}

.welcome-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--welcome-header-color);
    background: rgba(255, 255, 255, .18);
    cursor: pointer;
    transition: var(--transition);
}

.welcome-close:hover {
    background: rgba(255, 255, 255, .28);
    transform: scale(1.05);
}

.welcome-body {
    padding: 20px 26px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.welcome-body h1, .welcome-body h2, .welcome-body h3 {
    margin: 14px 0 8px;
    color: var(--text);
}

.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 10px;
}

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

.welcome-body img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.welcome-body iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.welcome-body ul, .welcome-body ol {
    margin: 0 0 10px;
    padding-left: 22px;
}

.welcome-body li { margin: 4px 0; }

.welcome-body code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.welcome-footer {
    padding: 14px 26px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--divider);
    background: linear-gradient(0deg, rgba(244, 246, 250, .6) 0%, transparent 100%);
    flex-shrink: 0;
}

.welcome-footer .welcome-action {
    background: var(--welcome-btn-bg);
    color: var(--welcome-btn-color);
    border: 1px solid var(--welcome-btn-bg);
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.welcome-footer .welcome-action:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

/* 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;
}

.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;
}

.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%;
    }
}
