: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 {
    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: 14px;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.brand__mark {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(239, 68, 68, .95), rgba(251, 146, 60, .95));
    font-size: 25px;
    box-shadow: 0 14px 35px rgba(239, 68, 68, .22);
}
.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: 130px 1fr; gap: 12px; background: rgba(2, 6, 23, .18); }
.detail-photo { width: 130px; height: 170px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); background: rgba(2,6,23,.45); }
.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; 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); }
.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 { display: block; width: 230px; max-width: 100%; max-height: 170px; object-fit: cover; margin: 8px 0; border-radius: 12px; border: 1px solid rgba(15, 23, 42, .22); }
.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; }
@media (max-width: 980px) {
    .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: 42px; height: 42px; font-size: 23px; }
    .brand h1 { font-size: 22px; }
    .search-card, .filters, .selected-card { padding: 11px 12px; }
    .metrics { padding: 10px 12px; }
    .selected-card { grid-template-columns: 112px 1fr; }
    .detail-photo { width: 112px; height: 145px; }
    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: 38px; height: 38px; border-radius: 14px; font-size: 21px; }
    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: 94px 1fr; gap: 9px; }
    .detail-photo { width: 94px; height: 126px; border-radius: 13px; }
    .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); }
}
