:root {
    color-scheme: dark;
    --bg: #0b1220;
    --panel: rgba(15, 23, 42, .96);
    --panel-2: rgba(30, 41, 59, .9);
    --text: #e5edf7;
    --muted: #93a4b8;
    --line: rgba(148, 163, 184, .22);
    --sky: #38bdf8;
    --blue: #2563eb;
    --orange: #f97316;
    --danger: #ef4444;
    --radius: 22px;
    --shadow: 0 22px 60px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, rgba(56, 189, 248, .16), transparent 32%),
        radial-gradient(circle at 90% 0%, rgba(251, 146, 60, .13), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}
.shell {
    display: grid;
    grid-template-columns: 430px 1fr;
    min-height: 100vh;
    padding: 16px;
    gap: 16px;
}
.panel {
    position: relative;
    z-index: 30;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 32px);
}
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.brand__mark {
    width: 38px;
    height: 38px;
    border-radius: 0;
    display: grid;
    place-items: center;
    background: transparent;
    overflow: visible;
    box-shadow: none;
    flex: 0 0 auto;
}
.brand__mark--button {
    border: 0;
    padding: 0;
    background: transparent;
}
.brand__mark--button:hover { transform: scale(1.04); }
.brand__text { flex: 1 1 auto; min-width: 0; }
.brand__mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: .02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.search-card,
.filters,
.list-wrap,
.selected-card { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.input-label { display: block; color: var(--muted); font-size: 12px; margin: 0 0 6px; font-weight: 800; }
.search-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 12px;
    background: rgba(2, 6, 23, .65);
    color: var(--text);
    outline: none;
}
input:focus, select:focus { border-color: rgba(56, 189, 248, .7); box-shadow: 0 0 0 4px rgba(56, 189, 248, .12); }
button {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(30, 41, 59, .95);
    color: var(--text);
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 800;
    white-space: nowrap;
}
button:hover { border-color: rgba(56, 189, 248, .55); }
button.active, #go-btn { background: linear-gradient(135deg, rgba(14, 165, 233, .95), rgba(37, 99, 235, .95)); border-color: transparent; }
button.secondary { background: rgba(15, 23, 42, .72); }
.panel-handle {
    display: none;
    border-radius: 0;
    padding: 10px 12px;
    border-left: 0;
    border-right: 0;
    background: linear-gradient(135deg, rgba(14, 165, 233, .95), rgba(37, 99, 235, .95));
    color: #fff;
    font-size: 13px;
    letter-spacing: .02em;
    box-shadow: 0 10px 24px rgba(14, 165, 233, .18);
}
.status-line { color: var(--muted); font-size: 12px; margin-top: 8px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.metric { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 11px; }
.metric span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.metric strong { font-size: 24px; }
.selected-card { display: grid; grid-template-columns: 148px 1fr; gap: 12px; background: rgba(2, 6, 23, .18); }
.detail-photo { width: 148px; height: 148px; object-fit: contain; border-radius: 0; border: 1px solid var(--line); background: rgba(255,255,255,.96); cursor: zoom-in; }
.detail-data h2 { margin: 0 0 3px; color: #e0f2fe; font-size: 18px; line-height: 1.15; }
.detail-data p { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.detail-row { font-size: 12px; line-height: 1.35; margin: 3px 0; color: #dbeafe; }
.detail-row b { color: #bae6fd; }
.badge { display: inline-block; background: rgba(56, 189, 248, .12); border: 1px solid rgba(56, 189, 248, .22); color: #bae6fd; border-radius: 999px; padding: 2px 7px; font-size: 11px; font-weight: 900; margin: 3px 4px 0 0; }
.photo-status { color: var(--muted); font-size: 11px; margin-top: 5px; }
.filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items:end; margin-bottom: 11px; }
.toggle-row { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; font-weight: 800; padding: 11px 0; }
.toggle-row input { width: auto; margin: 0; }
.photo-checks {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px 10px;
    background: rgba(2, 6, 23, .46);
}
.photo-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-size: 12px;
    font-weight: 850;
}
.photo-checks input { width: auto; margin: 0; accent-color: var(--sky); }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.list-wrap { flex: 1; overflow: hidden; display: flex; flex-direction: column; border-bottom: 0; min-height: 130px; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.list-head h2 { font-size: 15px; margin: 0; }
.list-head span { background: rgba(56, 189, 248, .12); color: #bae6fd; border: 1px solid rgba(56, 189, 248, .22); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 900; }
.hydrant-list { overflow: auto; padding-right: 4px; }
.hydrant-item { background: rgba(2, 6, 23, .35); border: 1px solid var(--line); border-radius: 15px; padding: 10px 11px; margin-bottom: 8px; cursor: pointer; }
.hydrant-item:hover { border-color: rgba(56, 189, 248, .45); background: rgba(15, 23, 42, .8); }
.hydrant-title { font-weight: 900; margin-bottom: 3px; }
.hydrant-meta { color: var(--muted); font-size: 12px; line-height: 1.35; }
.map-area { position: relative; z-index: 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: #111827; }
#map { width: 100%; height: 100%; min-height: calc(100vh - 32px); }
#map.leaflet-container { overflow: hidden; }
.suggestions { position: absolute; z-index: 1100; background: rgba(15, 23, 42, .98); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; width: min(380px, calc(100vw - 36px)); margin-top: 6px; }
.suggestion { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.suggestion:hover { background: rgba(56,189,248,.12); }
.suggestion b { color: #bae6fd; }
.suggestion small { color: var(--muted); }
.hidden { display: none !important; }
.error-box { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 999; max-width: 860px; background: rgba(127, 29, 29, .95); color: #fee2e2; padding: 14px 18px; border-radius: 16px; border: 1px solid rgba(252, 165, 165, .25); box-shadow: var(--shadow); }
.popup-title { font-weight: 900; font-size: 15px; margin-bottom: 5px; }
.popup-row { margin: 3px 0; }
.popup-label { font-weight: 800; }
.popup-photo-link { display:block; }
.popup-photo { display: block; width: 230px; max-width: 100%; height: 230px; object-fit: contain; margin: 8px 0; border-radius: 0; border: 1px solid rgba(15, 23, 42, .22); background: #fff; }
.leaflet-popup-content { min-width: 230px; }
.cluster-custom { background: rgba(14, 165, 233, .88); border: 3px solid rgba(255, 255, 255, .88); color: white; border-radius: 999px; text-align: center; font-weight: 900; box-shadow: 0 12px 26px rgba(0, 0, 0, .33); }
.cluster-custom div { width: 34px; height: 34px; line-height: 29px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin-right: 5px; }

.overlay-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
}
.overlay-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, .82);
}
.overlay-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(94vw, 980px);
    max-height: 92vh;
    overflow: auto;
    background: #0f172a;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 18px 18px 20px;
}
.overlay-modal__dialog--photo {
    width: min(96vw, 1200px);
    padding: 10px;
    background: rgba(2,6,23,.98);
}
.overlay-modal__dialog h2 {
    margin: 0 0 12px;
    color: #e0f2fe;
    font-size: 24px;
}
.overlay-modal__content {
    color: #dbeafe;
    font-size: 15px;
    line-height: 1.55;
}
.overlay-modal__content ul { padding-left: 18px; }
.overlay-modal__content li { margin: 8px 0; }
.overlay-modal__close {
    position: sticky;
    top: 0;
    float: right;
    min-width: 42px;
    padding: 8px 10px;
    font-size: 24px;
    line-height: 1;
    border-radius: 12px;
    z-index: 2;
}
.overlay-modal__image {
    display: block;
    width: 100%;
    max-height: 82vh;
    object-fit: contain;
    background: #fff;
    border-radius: 0;
}
.overlay-modal__caption {
    color: #cbd5e1;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.summary-card {
    background: rgba(2, 6, 23, .35);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
}
.summary-card h3 { margin: 0 0 8px; font-size: 15px; color: #bae6fd; }
.summary-card ul { margin: 0; padding-left: 18px; }
.summary-card li { margin: 4px 0; }

@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; padding: 0; gap: 0; min-height: 100vh; }
    .panel { border-radius: 0; min-height: auto; max-height: 52vh; overflow: auto; transition: max-height .22s ease, min-height .22s ease; }
    .panel-handle { display: block; position: sticky; top: 0; z-index: 700; }
    .map-area { border-radius: 0; min-height: 48vh; }
    #map { min-height: 48vh; }
    .brand { padding: 12px 14px; }
    .brand__mark { width: 36px; height: 36px; }
    .brand h1 { font-size: 22px; }
    .search-card, .filters, .selected-card { padding: 11px 12px; }
    .metrics { padding: 10px 12px; }
    .selected-card { grid-template-columns: 120px 1fr; }
    .detail-photo { width: 120px; height: 120px; }
    body.panel-collapsed .panel { max-height: 72px; min-height: 72px; overflow: hidden; }
    body.panel-collapsed .brand { padding: 10px 14px; border-bottom: 0; }
    body.panel-collapsed .brand p { display: none; }
    body.panel-collapsed .brand__mark { width: 34px; height: 34px; border-radius: 0; }
    body.panel-collapsed .brand h1 { font-size: 20px; }
    body.panel-collapsed .search-card,
    body.panel-collapsed .metrics,
    body.panel-collapsed .selected-card,
    body.panel-collapsed .filters,
    body.panel-collapsed .list-wrap { display: none; }
    body.panel-collapsed .map-area { min-height: calc(100vh - 110px); }
    body.panel-collapsed #map { min-height: calc(100vh - 110px); }
}
@media (max-width: 560px) {
    .panel { max-height: 58vh; }
    .map-area { min-height: 42vh; }
    #map { min-height: 42vh; }
    .search-row { grid-template-columns: 1fr auto; }
    #clear-btn { grid-column: 1 / 3; padding: 8px 10px; }
    .metrics { grid-template-columns: repeat(3, 1fr); gap: 7px; }
    .metric { padding: 8px; }
    .metric strong { font-size: 19px; }
    .filters-grid { grid-template-columns: 1fr; }
    .button-grid { grid-template-columns: 1fr 1fr; }
    .selected-card { grid-template-columns: 96px 1fr; gap: 9px; }
    .detail-photo { width: 96px; height: 96px; border-radius: 0; }
    .detail-data h2 { font-size: 15px; }
    .detail-row { font-size: 11px; }
    body.panel-collapsed .map-area { min-height: calc(100vh - 108px); }
    body.panel-collapsed #map { min-height: calc(100vh - 108px); }
}

@media (max-width: 560px) { .overlay-modal__dialog{ width:100vw; max-height:100vh; min-height:100vh; border-radius:0; padding:14px 14px 18px;} .overlay-modal__dialog--photo{padding:8px; min-height:100vh;} .overlay-modal__image{max-height:88vh;} }


.help-block {
    background: rgba(2, 6, 23, .24);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 13px;
    margin: 10px 0;
}
.help-block h3 {
    margin: 0 0 6px;
    color: #bae6fd;
    font-size: 16px;
}
.help-block p {
    margin: 0;
}
.modal-note {
    margin-top: 14px;
    padding: 12px 13px;
    border-radius: 14px;
    background: rgba(56, 189, 248, .10);
    border: 1px solid rgba(56, 189, 248, .24);
    color: #dbeafe;
    font-weight: 800;
}
.summary-lead {
    margin: 0 0 14px;
    color: #dbeafe;
}
.summary-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 10px;
    margin: 12px 0 16px;
}
.summary-kpi {
    background: linear-gradient(135deg, rgba(14, 165, 233, .14), rgba(37, 99, 235, .14));
    border: 1px solid rgba(56, 189, 248, .25);
    border-radius: 16px;
    padding: 13px;
}
.summary-kpi span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.summary-kpi strong {
    display: block;
    margin-top: 4px;
    color: #fff;
    font-size: 26px;
}
.summary-card--wide {
    margin-top: 12px;
}



.help-qr-block {
    margin: 16px 0 12px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(56, 189, 248, .25);
    background: rgba(2, 6, 23, .30);
    text-align: center;
}
.help-qr-block h3 {
    margin: 0 0 6px;
    color: #bae6fd;
    font-size: 16px;
}
.help-qr-block p {
    margin: 0 0 10px;
    color: #dbeafe;
}
.help-qr-img {
    display: block;
    width: min(220px, 72vw);
    height: auto;
    margin: 8px auto 10px;
    padding: 10px;
    background: #fff;
    border-radius: 0;
    border: 1px solid rgba(255,255,255,.18);
}
.help-qr-link {
    display: inline-block;
    color: #bae6fd;
    font-weight: 800;
    font-size: 13px;
    word-break: break-all;
    text-decoration: none;
}
.help-qr-link:hover {
    text-decoration: underline;
}


/* M075I - Ajustes solo celular / safe area.
   No toca la lógica del mapa ni bloquea el movimiento. */
@media (max-width: 760px) {
    body {
        overflow-x: hidden;
    }
    .shell {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .panel {
        width: 100%;
        max-width: 100vw;
        position: relative;
        z-index: 30;
    }
    .map-area {
        width: 100%;
        max-width: 100vw;
        z-index: 1;
        overflow: visible;
    }
    #map.leaflet-container {
        overflow: visible;
    }
    .leaflet-popup {
        max-width: calc(100vw - 32px);
    }
    .leaflet-control-container .leaflet-top.leaflet-left {
        margin-top: 6px;
        margin-left: max(6px, env(safe-area-inset-left));
    }
    .leaflet-control-container .leaflet-top.leaflet-right {
        margin-top: 6px;
        margin-right: max(6px, env(safe-area-inset-right));
    }
    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 34px);
        max-height: min(72vh, 520px);
        overflow: hidden;
        overflow-y: auto;
    }
    .leaflet-popup-content {
        width: min(250px, calc(100vw - 64px)) !important;
        min-width: 0;
        max-width: calc(100vw - 58px);
        margin: 10px 12px;
        overflow-wrap: anywhere;
    }
    .popup-photo {
        width: 100%;
        height: auto;
        max-width: calc(100vw - 74px);
        max-height: min(34vh, 210px);
    }
    .suggestions {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: calc(100vw - 24px);
    }
}

@media (max-width: 560px) {
    .brand {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    .search-card,
    .filters,
    .selected-card,
    .list-wrap {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    .panel-handle {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        z-index: 31;
    }
}

html, body { overflow-x: hidden; }
