:root {
    --bg: #07101d;
    --bg-soft: #0a1423;
    --sidebar: #080f1b;
    --panel: #0e1929;
    --panel-2: #111e30;
    --panel-hover: #152338;
    --line: #203047;
    --line-soft: rgba(123, 151, 186, .13);
    --text: #e8f0fa;
    --muted: #8293a9;
    --muted-2: #596a80;
    --cyan: #55c2ff;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #fb7185;
    --violet: #a78bfa;
    --radius: 14px;
    --shadow: 0 20px 60px rgba(0, 0, 0, .28);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 72% -10%, rgba(35, 98, 155, .13), transparent 28%), var(--bg); color: var(--text); font-family: "DM Sans", sans-serif; font-size: 14px; }
button, select, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 248px; display: flex; flex-direction: column; padding: 0 13px 18px; background: linear-gradient(180deg, #080f1a 0%, #070e19 100%); border-right: 1px solid var(--line-soft); }
.brand { height: 73px; display: flex; align-items: center; gap: 11px; padding: 0 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 19px; }
.brand-mark { width: 37px; height: 37px; border-radius: 11px; display: grid; place-items: center; color: #06101c; background: linear-gradient(135deg, #69d5ff, #3b82f6); box-shadow: 0 8px 25px rgba(59, 130, 246, .25); }
.brand-mark svg { width: 22px; }
.brand strong { display: block; font-size: 18px; letter-spacing: .02em; line-height: 19px; }
.brand small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .18em; }
.sidebar-label { padding: 0 13px 9px; color: #56677b; font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.category-nav { display: grid; gap: 3px; overflow: auto; scrollbar-width: thin; }
.category-button { width: 100%; min-height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 11px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #8899ad; cursor: pointer; text-align: left; transition: .18s ease; }
.category-button:hover { color: #cbd8e6; background: rgba(83, 117, 153, .08); }
.category-button.active { color: #eaf6ff; background: linear-gradient(90deg, rgba(45, 145, 218, .16), rgba(37, 99, 235, .05)); border-color: rgba(85, 194, 255, .12); box-shadow: inset 3px 0 var(--category-color, var(--cyan)); }
.category-button .nav-icon { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 7px; color: var(--category-color, var(--cyan)); background: color-mix(in srgb, var(--category-color, var(--cyan)) 11%, transparent); }
.category-button svg { width: 16px; height: 16px; }
.category-button span:nth-child(2) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-button small { min-width: 22px; padding: 2px 5px; border-radius: 9px; background: rgba(130, 147, 169, .09); color: #61748a; font: 9px "JetBrains Mono", monospace; text-align: center; }
.sidebar-spacer { flex: 1; min-height: 16px; }
.network-card { margin: 6px 3px 10px; padding: 13px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(17, 30, 48, .6); }
.network-card strong, .network-card small { display: block; }
.network-card strong { font-size: 12px; }
.network-card small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.network-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(52, 211, 153, .08), 0 0 16px rgba(52, 211, 153, .55); }
.sidebar-admin { height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border-radius: 8px; color: #6f8197; text-decoration: none; font-size: 12px; }
.sidebar-admin:hover { color: #b9c8da; background: var(--panel-2); }
.sidebar-admin svg { width: 15px; }
.sidebar-close { display: none !important; margin-left: auto; }

.main-content { width: calc(100% - 248px); margin-left: 248px; min-width: 0; }
.topbar { height: 58px; padding: 0 25px; display: flex; align-items: center; justify-content: space-between; background: rgba(7, 16, 29, .78); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 20; }
.topbar-left, .topbar-right, .breadcrumbs { display: flex; align-items: center; }
.breadcrumbs { gap: 8px; color: var(--muted-2); font-size: 12px; }
.breadcrumbs svg { width: 13px; }
.breadcrumbs strong { color: #aab9ca; font-weight: 500; }
.topbar-right { gap: 16px; }
.live-badge { padding: 5px 8px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(52, 211, 153, .16); border-radius: 6px; color: #68e3b7; background: rgba(52, 211, 153, .06); font: 600 9px "JetBrains Mono", monospace; letter-spacing: .12em; }
.live-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.clock { color: #73859a; font: 11px "JetBrains Mono", monospace; }
.menu-button { display: none !important; margin-right: 10px; }
.icon-button { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--panel-2); }
.icon-button svg { width: 18px; }

.workspace { max-width: 1680px; margin: 0 auto; padding: 29px 29px 50px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.eyebrow, .panel-kicker { display: block; margin-bottom: 8px; color: var(--cyan); font: 600 9px "JetBrains Mono", monospace; letter-spacing: .13em; }
.page-heading h1 { margin: 0 0 4px; font-size: clamp(25px, 2.3vw, 34px); line-height: 1.2; letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; gap: 8px; }
.button { min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: #bdcadd; font-weight: 600; font-size: 12px; cursor: pointer; transition: .18s ease; }
.button:hover { transform: translateY(-1px); border-color: #344966; color: #fff; }
.button svg { width: 15px; height: 15px; }
.button.primary { border-color: rgba(85, 194, 255, .2); color: #07111d; background: linear-gradient(135deg, #62d0ff, #3b9eea); box-shadow: 0 8px 22px rgba(38, 147, 217, .18); }
.button.ghost { background: transparent; }
.button.compact { min-height: 32px; padding: 0 10px; }
.button[aria-pressed="false"] { color: #607187; }

.filter-bar { min-height: 75px; padding: 12px 14px; display: flex; align-items: flex-end; gap: 13px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: rgba(13, 24, 40, .76); box-shadow: 0 10px 45px rgba(0, 0, 0, .12); }
.control { min-width: 145px; display: grid; gap: 6px; }
.control > span, .range-control > span { color: #63758a; font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.control select, .control input { height: 36px; padding: 0 32px 0 10px; border: 1px solid #263750; border-radius: 7px; outline: none; color: #cbd7e5; background: #0b1626; }
.control select:focus, .control input:focus { border-color: rgba(85, 194, 255, .55); box-shadow: 0 0 0 3px rgba(85, 194, 255, .07); }
.station-control { min-width: 215px; }
.range-control { display: grid; gap: 6px; }
.segmented { min-height: 36px; height: auto; display: flex; flex-wrap: wrap; padding: 3px; border: 1px solid #263750; border-radius: 7px; background: #0b1626; }
.segmented button { min-width: 38px; padding: 0 8px; border: 0; border-radius: 5px; color: #718399; background: transparent; font: 500 10px "JetBrains Mono", monospace; cursor: pointer; }
.segmented button:hover { color: #c8d6e6; }
.segmented button.active { color: #dff5ff; background: rgba(85, 194, 255, .13); box-shadow: inset 0 0 0 1px rgba(85, 194, 255, .12); }
.segmented svg { width: 13px; }
.custom-range { display: flex; align-items: flex-end; gap: 8px; }
.custom-range .control { min-width: 180px; }
.column-picker-wrap { position: relative; margin-left: auto; }
.field-button { height: 36px; background: #0b1626; }
.field-button b { min-width: 19px; height: 19px; display: grid; place-items: center; border-radius: 10px; color: var(--cyan); background: rgba(85, 194, 255, .12); font: 10px "JetBrains Mono", monospace; }
.column-picker { position: absolute; right: 0; top: 44px; z-index: 50; width: 300px; max-height: 420px; overflow: auto; padding: 8px; border: 1px solid #2b3f5a; border-radius: 11px; background: #0c1727; box-shadow: var(--shadow); }
.picker-head { height: 39px; padding: 0 7px 6px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.picker-head strong { font-size: 12px; }
.picker-head button { border: 0; color: var(--cyan); background: transparent; font-size: 11px; cursor: pointer; }
.metric-option { min-height: 47px; padding: 7px; display: flex; align-items: center; gap: 9px; border-radius: 7px; cursor: pointer; }
.metric-option:hover { background: var(--panel-hover); }
.metric-option input { accent-color: var(--cyan); }
.metric-option-color { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 9px currentColor; }
.metric-option div { min-width: 0; flex: 1; }
.metric-option strong, .metric-option small { display: block; }
.metric-option strong { font-size: 11px; font-weight: 600; }
.metric-option small { margin-top: 2px; color: var(--muted-2); font: 9px "JetBrains Mono", monospace; }

.view-tabs { margin: 20px 0 15px; display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); }
.view-tabs button { height: 39px; padding: 0 13px; display: flex; align-items: center; gap: 7px; border: 0; border-bottom: 2px solid transparent; color: #687a90; background: transparent; font-size: 11px; font-weight: 600; cursor: pointer; }
.view-tabs button:hover { color: #b6c4d5; }
.view-tabs button.active { color: #d8e8f8; border-color: var(--cyan); }
.view-tabs svg { width: 14px; }
.view { display: none; }
.view.active { display: block; animation: viewIn .24s ease; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin-bottom: 12px; }
.stat-card { min-height: 92px; padding: 16px; display: flex; align-items: center; gap: 13px; border: 1px solid var(--line-soft); border-radius: 11px; background: linear-gradient(135deg, rgba(17, 30, 48, .86), rgba(12, 23, 39, .86)); }
.stat-icon { width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; }
.stat-icon svg { width: 18px; }
.stat-icon.cyan { color: var(--cyan); background: rgba(85, 194, 255, .1); }
.stat-icon.violet { color: var(--violet); background: rgba(167, 139, 250, .1); }
.stat-icon.green { color: var(--green); background: rgba(52, 211, 153, .1); }
.stat-icon.amber { color: var(--amber); background: rgba(251, 191, 36, .1); }
.stat-card div { min-width: 0; }
.stat-card small, .stat-card em { display: block; color: var(--muted); font-style: normal; }
.stat-card small { font-size: 10px; }
.stat-card strong { display: inline-block; margin: 3px 0 1px; font: 600 22px "JetBrains Mono", monospace; letter-spacing: -.04em; }
.stat-card em { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 9px; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.panel { border: 1px solid var(--line-soft); border-radius: 12px; background: linear-gradient(145deg, rgba(15, 27, 45, .96), rgba(10, 21, 36, .96)); box-shadow: 0 15px 45px rgba(0, 0, 0, .1); overflow: hidden; }
.chart-panel { min-height: 330px; }
.chart-panel.wide { grid-column: 1 / -1; }
.panel-header { min-height: 62px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line-soft); }
.panel-kicker { margin-bottom: 3px; color: #54677e; font-size: 8px; }
.panel-header h2 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-value { text-align: right; }
.panel-value strong { display: block; font: 600 17px "JetBrains Mono", monospace; }
.panel-value small { color: var(--muted-2); font: 9px "JetBrains Mono", monospace; }
.chart-toolbar { display: flex; align-items: center; gap: 5px; }
.chart-kind { height: 27px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; color: #7f91a6; background: #0a1524; font-size: 9px; }
.chart-reset { width: 27px; height: 27px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: #66798f; background: transparent; cursor: pointer; }
.chart-reset svg { width: 12px; }
.chart-area { position: relative; height: 260px; padding: 14px 13px 11px 8px; }
.series-summary { min-height: 38px; padding: 7px 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 15px; border-bottom: 1px solid var(--line-soft); background: rgba(7, 16, 29, .28); }
.latest-series { display: inline-flex; align-items: baseline; gap: 5px; color: #7f91a6; font-size: 9px; }
.latest-series i { width: 7px; height: 7px; align-self: center; border-radius: 50%; background: var(--series-color); box-shadow: 0 0 8px color-mix(in srgb, var(--series-color) 65%, transparent); }
.latest-series b { color: #91a3b7; font-weight: 500; }
.latest-series strong { color: var(--series-color); font: 600 11px "JetBrains Mono", monospace; }
.latest-series small { color: #56697f; font: 8px "JetBrains Mono", monospace; }
.station-empty { height: 100%; display: grid; place-content: center; justify-items: center; gap: 5px; color: #65778d; text-align: center; }
.station-empty svg { width: 24px; color: #3d536d; }
.station-empty strong { color: #91a2b5; font-size: 11px; }
.station-empty span { max-width: 300px; font-size: 9px; }
.empty-state { min-height: 290px; grid-column: 1 / -1; display: grid; place-items: center; text-align: center; border: 1px dashed #243751; border-radius: 12px; color: #6d7f95; }
.empty-state svg { width: 30px; height: 30px; margin-bottom: 8px; color: #3b526d; }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: #a3b2c4; }
.empty-state span { margin-top: 4px; font-size: 11px; }

.map-panel { min-height: 0; }
.inline-map-panel { height: 300px; max-height: 300px; margin-bottom: 12px; }
.inline-map-panel .panel-header { min-height: 60px; height: 60px; }
.map-legend { display: flex; gap: 15px; color: var(--muted); font-size: 10px; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend i { width: 7px; height: 7px; border-radius: 50%; background: #6c7c90; }
.map-legend i.online { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, .5); }
#stationMap { width: 100%; height: 240px; max-height: 240px; background: #0a1421; }
/* Leaflet core fallback: păstrează harta funcțională dacă CSS-ul CDN nu se încarcă. */
.leaflet-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow,
.leaflet-tile-container, .leaflet-pane > svg, .leaflet-pane > canvas,
.leaflet-zoom-box, .leaflet-image-layer, .leaflet-layer { position: absolute; left: 0; top: 0; }
.leaflet-container { overflow: hidden; -webkit-tap-highlight-color: transparent; }
.leaflet-tile { visibility: hidden; user-select: none; -webkit-user-drag: none; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control { float: left; clear: both; }
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }
.leaflet-bar a { width: 28px; height: 28px; display: block; border-bottom: 1px solid #30445e; color: #b9c9da; background: #101d2e; text-align: center; text-decoration: none; line-height: 28px; }
.leaflet-bar a:first-child { border-radius: 6px 6px 0 0; }
.leaflet-bar a:last-child { border-bottom: 0; border-radius: 0 0 6px 6px; }
.leaflet-popup { position: absolute; margin-bottom: 20px; text-align: center; }
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 13px 18px; line-height: 1.4; }
.leaflet-popup-tip-container { width: 40px; height: 20px; position: absolute; left: 50%; margin-left: -20px; overflow: hidden; pointer-events: none; }
.leaflet-popup-tip { width: 17px; height: 17px; margin: -10px auto 0; transform: rotate(45deg); }
.leaflet-container a.leaflet-popup-close-button { position: absolute; top: 0; right: 0; z-index: 2; padding: 4px 4px 0 0; border: 0; color: #91a3b7; background: transparent; text-decoration: none; }
.leaflet-container { font-family: "DM Sans", sans-serif; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { color: var(--text); background: #111d2e; }
.leaflet-popup-content { min-width: 190px; }
.map-popup strong { display: block; margin-bottom: 3px; font-size: 14px; }
.map-popup span { display: block; color: #93a4b7; font-size: 11px; line-height: 1.6; }
.map-popup button { margin-top: 9px; padding: 6px 9px; border: 0; border-radius: 6px; color: #07111d; background: var(--cyan); font-weight: 700; font-size: 10px; cursor: pointer; }
.station-marker { width: 14px !important; height: 14px !important; margin: -7px 0 0 -7px !important; border: 2px solid #b8f0d8; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(52, 211, 153, .12), 0 0 12px rgba(52, 211, 153, .5); }
.station-marker.inactive { border-color: #798ba1; background: #516176; box-shadow: 0 0 0 4px rgba(103, 120, 143, .12); }

.table-panel { min-height: 560px; }
.data-table-wrap { max-height: 610px; overflow: auto; }
.data-table-wrap::-webkit-scrollbar, .category-nav::-webkit-scrollbar { width: 8px; height: 8px; }
.data-table-wrap::-webkit-scrollbar-thumb, .category-nav::-webkit-scrollbar-thumb { border-radius: 5px; background: #253750; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; height: 40px; padding: 0 14px; border-bottom: 1px solid #293b54; color: #71849b; background: #0e1a2b; text-align: left; font: 600 9px "JetBrains Mono", monospace; letter-spacing: .07em; text-transform: uppercase; }
td { height: 42px; padding: 0 14px; border-bottom: 1px solid rgba(116, 144, 177, .08); color: #aab9ca; font: 10px "JetBrains Mono", monospace; }
tbody tr:hover td { color: #dce7f3; background: rgba(85, 194, 255, .025); }
.table-footer { min-height: 51px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 10px; }
.pagination { display: flex; align-items: center; gap: 10px; }
.pagination button { width: 29px; height: 29px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: #8193a8; background: #0b1625; cursor: pointer; }
.pagination button:disabled { opacity: .35; cursor: default; }
.pagination svg { width: 13px; }

.loading-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 13px; background: rgba(4, 10, 18, .58); backdrop-filter: blur(4px); }
.loading-overlay strong { color: #b9c7d7; font-size: 12px; }
.loader { width: 35px; height: 35px; border: 3px solid rgba(85, 194, 255, .12); border-top-color: var(--cyan); border-radius: 50%; animation: spin .7s linear infinite; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 110; max-width: 380px; padding: 12px 15px; border: 1px solid rgba(251, 113, 133, .22); border-radius: 9px; color: #fecdd3; background: #2a1520; box-shadow: var(--shadow); font-size: 12px; }
.toast.success { border-color: rgba(52, 211, 153, .22); color: #b7f7df; background: #102820; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .4; } }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar { flex-wrap: wrap; }
    .column-picker-wrap { margin-left: 0; }
    .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
    .sidebar.open { transform: none; }
    .sidebar-close, .menu-button { display: inline-grid !important; }
    .main-content { width: 100%; margin-left: 0; }
    .workspace { padding: 22px 16px 40px; }
    .page-heading { align-items: flex-start; }
    .filter-bar { align-items: stretch; }
    .station-control { width: 100%; }
    .range-control { flex: 1; }
    .segmented button { flex: 1; }
    .custom-range { width: 100%; flex-wrap: wrap; }
    .custom-range .control { flex: 1; min-width: 155px; }
}

@media (max-width: 560px) {
    .topbar { padding: 0 13px; }
    .breadcrumbs > span, .clock { display: none; }
    .page-heading { display: block; }
    .heading-actions { margin-top: 16px; }
    .heading-actions .button { flex: 1; }
    .filter-bar { display: grid; }
    .segmented button { min-width: 0; padding: 0 7px; }
    .column-picker-wrap, .field-button { width: 100%; }
    .column-picker { left: 0; right: auto; width: min(100%, 340px); }
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 78px; }
    .chart-panel { min-height: 300px; }
    .chart-area { height: 230px; }
    .panel-header { align-items: flex-start; }
    .map-legend { display: none; }
    .inline-map-panel { height: 280px; max-height: 280px; }
    #stationMap { height: 220px; max-height: 220px; }
}

