:root {
    --navy: #082f49;
    --blue: #075985;
    --light: #f0f9ff;
    --line: #dbeafe;
    --text: #0f172a;
    --muted: #64748b;
    --card: rgba(255, 255, 255, 0.96);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100dvh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: #e0f2fe;
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    color: white;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    box-shadow: 0 8px 22px rgba(8, 47, 73, .22);
    z-index: 1000;
}

.eyebrow { margin: 0 0 2px; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
h1 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.7rem); }

.connection {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 999px;
    background: rgba(255,255,255,.1);
    font-size: .86rem;
    white-space: nowrap;
}
.connection-dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.2); }
.connection.ok .connection-dot { background: #4ade80; box-shadow: 0 0 0 4px rgba(74,222,128,.18); }
.connection.error .connection-dot { background: #fb7185; box-shadow: 0 0 0 4px rgba(251,113,133,.18); }

.layout { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 370px; }
.map-wrap { position: relative; min-height: 0; }
#map { height: 100%; width: 100%; background: #bae6fd; }

.legend {
    position: absolute;
    left: 14px;
    bottom: 18px;
    z-index: 500;
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid rgba(148,163,184,.35);
    border-radius: 14px;
    background: var(--card);
    box-shadow: 0 12px 26px rgba(15,23,42,.13);
    font-size: .8rem;
}
.legend strong { margin-bottom: 3px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--legend); }

.sidebar {
    overflow-y: auto;
    padding: 18px;
    border-left: 1px solid var(--line);
    background: #f8fafc;
}
.sidebar-placeholder { min-height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); }
.sidebar-placeholder h2 { color: var(--text); margin-bottom: 4px; }
.water-icon { font-size: 4rem; color: #0284c7; line-height: 1; }

.station-head {
    padding: 18px;
    border-radius: 18px;
    color: white;
    background: linear-gradient(135deg, #082f49, #0369a1);
    box-shadow: 0 12px 25px rgba(8,47,73,.18);
}
.station-head p, .station-head h2 { margin: 0; }
.station-head p { margin-top: 5px; opacity: .78; }
.station-status { display: inline-flex; margin-top: 14px; padding: 7px 10px; border-radius: 9px; font-weight: 700; background: var(--status-color); color: var(--status-text); }

.asset-list { display: grid; gap: 10px; margin-top: 16px; }
.asset-card { padding: 14px; border: 1px solid #e2e8f0; border-radius: 15px; background: white; box-shadow: 0 6px 16px rgba(15,23,42,.05); }
.asset-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.asset-name { margin: 0; font-size: 1rem; }
.asset-type { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.status-pill { flex: 0 0 auto; max-width: 155px; padding: 6px 8px; border-radius: 8px; text-align: center; font-size: .76rem; font-weight: 700; background: var(--status-color); color: var(--status-text); }
.asset-note { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid #e2e8f0; font-size: .86rem; }
.asset-meta { display: grid; gap: 3px; margin-top: 10px; color: var(--muted); font-size: .74rem; }

.station-marker { width: 36px; height: 36px; display: grid; place-items: center; border: 4px solid white; border-radius: 50% 50% 50% 15%; transform: rotate(-45deg); background: var(--marker-color); box-shadow: 0 5px 14px rgba(15,23,42,.35); }
.station-marker span { transform: rotate(45deg); color: white; font-size: 16px; font-weight: 900; }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 7px 14px; color: #475569; background: white; border-top: 1px solid #e2e8f0; font-size: .74rem; }

@media (max-width: 820px) {
    .topbar { min-height: 66px; padding: 10px 12px; }
    .connection span:last-child { display: none; }
    .connection { padding: 8px; }
    .layout { grid-template-columns: 1fr; grid-template-rows: minmax(53vh, 1fr) auto; overflow-y: auto; }
    .map-wrap { min-height: 53vh; }
    .sidebar { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 12px; }
    .legend { left: 8px; bottom: 8px; font-size: .7rem; padding: 9px; }
    footer { font-size: .68rem; }
}
footer a { color: #0369a1; font-weight: 700; text-decoration: none; }
footer a:hover { text-decoration: underline; }
