/* TERMIUS — светлая тема в духе RESURSCONTROL:
   белые панели на спокойном светлом фоне, тонкие линии, выровненная
   типографика, много воздуха; акцент — аптечный бирюзово-зелёный. */
:root {
  color-scheme: light;
  --bg: #F3F6F4;
  --bg2: #FFFFFF;
  --panel: #FFFFFF;
  --panel2: #F1F5F2;
  --border: #E1E8E2;
  --border2: #C9D6CC;
  --text-primary: #16251F;
  --text-secondary: #466053;
  --text-muted: #6A7F74;
  --accent: #1B8F80;
  --accent-soft: rgba(27, 143, 128, .10);
  --series-t: #1B8F80;
  --series-rh: #D3860F;
  --st-good: #2A9B54;
  --st-warn: #D3860F;
  --st-crit: #D94343;
  --st-off: #8A9A90;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  /* совместимость */
  --surface-1: var(--panel);
  --surface-2: var(--panel2);
  --hairline: var(--border);
  --page: var(--bg);
  --cyan: var(--accent);
  --blue: var(--accent);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px; line-height: 1.5;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #CBD6CE; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ── шапка ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 26px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 28px; height: 28px; }
.brand-name { font-weight: 700; letter-spacing: 2px; font-size: 17px; color: var(--text-primary); }
.brand-sub { font-size: 10.5px; color: var(--text-muted); letter-spacing: .4px; margin-top: 1px; }
.tabs { display: flex; gap: 2px; }
.tabs button {
  background: none; border: none; border-radius: 9px;
  padding: 8px 15px; color: var(--text-muted); font-weight: 500; font-size: 13.5px;
  transition: .16s;
}
.tabs button:hover { color: var(--text-primary); background: var(--panel2); }
.tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.badge {
  background: var(--st-crit); color: #fff; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; margin-left: 5px;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.scenarios { display: flex; align-items: center; gap: 6px; }
.scenarios-label { color: var(--text-muted); font-size: 11px; letter-spacing: .8px; text-transform: uppercase; }
.scenarios button {
  background: var(--panel); border: 1px solid var(--border2);
  border-radius: 999px; padding: 5px 12px; font-size: 11.5px; font-weight: 500; color: var(--text-secondary);
  transition: .15s;
}
.scenarios button:hover { border-color: var(--accent); color: var(--accent); }
.scenarios .sc-normal { color: var(--st-good); }
.conn {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary);
  border: 1px solid var(--border); background: var(--panel);
  padding: 6px 13px; border-radius: 999px; white-space: nowrap;
}
.conn #clock { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-off); display: inline-block; flex: none; }
.dot.on { background: var(--st-good); }

main { padding: 18px 24px 30px; max-width: 1600px; margin: 0 auto; }

/* ── светофор ──────────────────────────────────────── */
.tl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.tl-ok { background: var(--st-good); }
.tl-warning { background: var(--st-warn); }
.tl-error { background: var(--st-crit); box-shadow: 0 0 0 3px rgba(217, 67, 67, .15); animation: pulse 1.4s infinite; }
.tl-offline { background: var(--st-off); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ── мониторинг: список + карта ────────────────────── */
.mon-grid { display: flex; gap: 16px; align-items: stretch; height: calc(100vh - 110px); min-height: 520px; }
.mon-side {
  flex: 0 0 360px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.mon-head { padding: 18px 20px 10px; }
.mon-head h2 { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.mon-sum { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.mon-filter { display: flex; gap: 6px; padding: 8px 20px 14px; border-bottom: 1px solid var(--border); }
.mon-filter button {
  background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 11px; font-size: 11.5px; color: var(--text-muted); transition: .15s;
}
.mon-filter button:hover { border-color: var(--border2); color: var(--text-primary); }
.mon-filter button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.mon-tree { flex: 1; overflow-y: auto; padding: 10px 8px; }
.mon-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 9px; font-size: 13px;
}
.mon-region { font-weight: 600; font-size: 13.5px; }
.mon-cat { color: var(--text-secondary); font-weight: 600; font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; margin-top: 10px; }
.mon-cat .tl-dot { width: 7px; height: 7px; }
.mon-site { padding-left: 28px; cursor: pointer; transition: background .15s; color: var(--text-primary); }
.mon-site:hover { background: var(--panel2); }
.mon-site.selected { background: var(--accent-soft); }
.mon-site.mon-dim { opacity: .38; }
.mon-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-val { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); flex: none; }
.mon-region .mon-val, .mon-cat .mon-val { font-family: inherit; }
.mon-open {
  flex: none; width: 24px; height: 24px; border: none; border-radius: 7px;
  background: none; color: var(--text-muted); font-size: 16px; line-height: 1;
  opacity: 0; transition: .15s;
}
.mon-site:hover .mon-open, .mon-site.selected .mon-open { opacity: 1; }
.mon-open:hover { background: var(--accent-soft); color: var(--accent); }
.mon-foot { padding: 12px 20px; border-top: 1px solid var(--border); }
.ghost-btn {
  width: 100%; background: none; border: 1px solid var(--border2); border-radius: 9px;
  padding: 8px 14px; font-size: 12.5px; font-weight: 500; color: var(--text-secondary); transition: .15s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.mon-map {
  flex: 1; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; display: flex;
}
#map { flex: 1; border-radius: 8px; background: #E9EDE9; position: relative; z-index: 0; }
.osm-tiles { filter: saturate(.75) contrast(.97); }
.leaflet-container { font-family: 'Space Grotesk', sans-serif; }
.leaflet-control-zoom a { background: #fff !important; color: var(--text-secondary) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: rgba(255, 255, 255, .8) !important; color: var(--text-muted) !important; font-size: 9px !important; }

/* маркеры карты */
.tk-wrap, .mk-wrap { background: none; border: none; }
.tk-chip {
  width: 178px; background: rgba(255, 255, 255, .96); border: 1.4px solid var(--border2);
  border-radius: 11px; padding: 8px 11px;
  box-shadow: 0 6px 20px rgba(22, 37, 31, .14); position: relative;
}
.tk-chip::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 7px solid transparent; border-bottom: none; border-top: 7px solid var(--border2);
}
.tk-chip.tk-ok { border-color: var(--st-good); }
.tk-chip.tk-ok::after { border-top-color: var(--st-good); }
.tk-chip.tk-warning { border-color: var(--st-warn); }
.tk-chip.tk-warning::after { border-top-color: var(--st-warn); }
.tk-chip.tk-error { border-color: var(--st-crit); animation: pulse 1.4s infinite; }
.tk-chip.tk-error::after { border-top-color: var(--st-crit); }
.tk-chip.tk-offline { border-color: var(--st-off); }
.tk-chip.tk-offline::after { border-top-color: var(--st-off); }
.tk-name { font-size: 11px; font-weight: 600; color: var(--text-primary); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.tk-truck { color: var(--accent); }
.tk-vals { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.tk-sp { font-size: 9.5px; color: var(--text-muted); font-family: var(--mono); }
.tk-vals b { font-size: 15px; font-weight: 700; font-family: var(--mono); color: var(--text-primary); }
.tk-error .tk-vals b { color: var(--st-crit); }
.tk-warning .tk-vals b { color: var(--st-warn); }
.tk-dev { font-size: 10px; font-weight: 600; margin-top: 2px; }
.tk-ok .tk-dev { color: var(--st-good); }
.tk-warning .tk-dev { color: var(--st-warn); }
.tk-error .tk-dev { color: var(--st-crit); }
.tk-offline .tk-dev { color: var(--st-off); }

.mk-chip {
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: 210px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--border2);
  border-radius: 10px; padding: 6px 10px;
  box-shadow: 0 4px 14px rgba(22, 37, 31, .12); cursor: pointer; transition: .15s;
}
.mk-chip:hover { border-color: var(--accent); }
.mk-chip.mk-error { border-color: var(--st-crit); animation: pulse 1.6s infinite; }
.mk-chip.mk-warning { border-color: var(--st-warn); }
.mk-icon { width: 19px; height: 19px; flex: none; color: var(--accent); }
.mk-name { font-size: 10.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.mk-sub { font-size: 9.5px; color: var(--text-muted); font-family: var(--mono); }
.mk-error .mk-sub { color: var(--st-crit); }
.mk-warning .mk-sub { color: var(--st-warn); }

/* ── объект: план ──────────────────────────────────── */
.site-tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.site-tabs button {
  background: none; border: 1px solid transparent; border-radius: 9px;
  padding: 7px 13px; color: var(--text-muted); display: flex; gap: 8px; align-items: center;
  font-size: 13px; transition: .15s;
}
.site-tabs button:hover { color: var(--text-primary); background: var(--panel); }
.site-tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.site-tabs .dot { width: 8px; height: 8px; }

.site-grid { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.site-grid .plan-wrap { flex: 1 1 660px; min-width: 0; }

.plan-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.plan-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.plan-toolbar .title { font-weight: 600; font-size: 14px; }
.plan-toolbar .spacer { flex: 1; }
.legend { display: flex; gap: 13px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.edit-btn {
  background: none; border: 1px solid var(--border2); border-radius: 999px;
  padding: 6px 14px; font-size: 11.5px; font-weight: 500; color: var(--text-secondary); transition: .15s;
}
.edit-btn:hover { color: var(--accent); border-color: var(--accent); }
.edit-btn.on { color: var(--st-warn); border-color: var(--st-warn); background: rgba(211, 134, 15, .07); }
.plan-svg { width: 100%; display: block; user-select: none; }

/* полы */
.zfloor { fill: #FAFBFA; }
.zfloor.cold { fill: #F0F6F9; }
.zfloor.freeze { fill: #EFF2FA; }
.zfloor.ambient { fill: #F8F9F6; }
.zfloor.service { fill: #F3F4F1; }

/* подкраска статусом */
.ztint.zt-ok { fill: rgba(42, 155, 84, .045); }
.ztint.zt-warning { fill: rgba(211, 134, 15, .07); }
.ztint.zt-error { fill: rgba(217, 67, 67, .09); animation: pulse 2s infinite; }
.ztint.zt-offline { fill: rgba(138, 154, 144, .06); }

/* стены — тонкие, спокойный серо-зелёный графит */
.wall { stroke: #9FB0A6; stroke-width: 3.5; stroke-linecap: butt; }
.wall-ins { stroke: #8FA4B8; stroke-width: 9; }
.wall-ins-core { stroke: #FFFFFF; stroke-width: 3; stroke-dasharray: 6 5; }

/* двери и ворота */
.door-leaf { stroke: #7B8F84; stroke-width: 2; }
.door-arc { stroke: #B9C6BD; stroke-width: 1; fill: none; stroke-dasharray: 3 3; }
.dock-door { stroke: #7B8F84; stroke-width: 3; stroke-dasharray: 8 4; }
.dock-chev { stroke: #AEBDB2; stroke-width: 1.8; fill: none; }
.dock-label { fill: var(--text-muted); font-size: 10.5px; letter-spacing: .4px; }

/* стеллажи и агрегаты */
.rack rect { fill: #EEF1ED; stroke: #CFD9D1; stroke-width: 1; }
.rack line { stroke: #DCE3DD; stroke-width: 1; }
.cunit rect { fill: #EAF1F6; stroke: #9FB4C6; stroke-width: 1.2; }
.cunit-fan { fill: none; stroke: #7D96AC; stroke-width: 1.3; }
.cunit-blade { stroke: #7D96AC; stroke-width: 1; }

/* связи */
.hub-link { stroke: var(--text-muted); stroke-width: 1; opacity: 0; fill: none; transition: opacity .3s; }
.hub-link.radio { stroke-dasharray: 4 5; }
.editing .hub-link { opacity: .4; }

/* панели зон на плане */
.zp-bg { fill: rgba(255, 255, 255, .93); stroke: var(--border2); stroke-width: 1; }
.zp-bg.zp-warning { stroke: var(--st-warn); }
.zp-bg.zp-error { stroke: var(--st-crit); }
.zp-name { fill: var(--text-primary); font-size: 13px; font-weight: 600; }
.zp-sp { fill: var(--text-muted); font-size: 10.5px; font-family: var(--mono); }
.zp-cur { font-size: 19px; font-weight: 700; font-family: var(--mono); fill: var(--text-primary); }
.zp-st { font-size: 11px; font-weight: 600; }
.zpc-ok { fill: var(--st-good); color: var(--st-good); }
.zp-cur.zpc-ok { fill: var(--text-primary); }
.zpc-warning { fill: var(--st-warn); color: var(--st-warn); }
.zpc-error { fill: var(--st-crit); color: var(--st-crit); }
.zpc-offline { fill: var(--st-off); color: var(--st-off); }
.zone-nosens { fill: var(--text-muted); font-size: 12px; font-style: italic; }

/* датчики */
.marker { cursor: pointer; }
.m-chip { fill: rgba(255, 255, 255, .97); stroke-width: 1.4; }
.marker.ok .m-chip { stroke: var(--st-good); }
.marker.warning .m-chip { stroke: var(--st-warn); }
.marker.error .m-chip { stroke: var(--st-crit); }
.marker.offline .m-chip { stroke: var(--st-off); stroke-dasharray: 4 3; }
.m-pulse { fill: none; stroke: var(--st-crit); stroke-width: 2; animation: mpulse 1.2s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes mpulse { 0% { opacity: .7; transform: scale(1); } 100% { opacity: 0; transform: scale(1.55); } }
.m-dev rect { fill: #F1F5F2; stroke: #A9BAAE; stroke-width: 1.1; }
.m-led { fill: var(--st-good); }
.marker.warning .m-led { fill: var(--st-warn); }
.marker.error .m-led { fill: var(--st-crit); }
.marker.offline .m-led { fill: var(--st-off); }
.m-ant { stroke: #8FA396; stroke-width: 1.2; fill: none; }
.m-t { fill: var(--text-primary); font-size: 14px; font-weight: 700; font-family: var(--mono); }
.marker.error .m-t { fill: var(--st-crit); }
.m-rh { fill: var(--text-muted); font-size: 10.5px; font-family: var(--mono); }
.m-name { fill: var(--text-muted); font-size: 10px; }
.marker.selected .m-chip { stroke-width: 2.4; }
.marker.dragging { opacity: .7; }

/* контроллер */
.hub-marker { cursor: pointer; }
.h-body { fill: rgba(255, 255, 255, .97); stroke: var(--accent); stroke-width: 1.6; }
.hub-marker.offline .h-body { stroke: var(--st-off); stroke-dasharray: 4 3; }
.h-ant { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.h-bars { stroke: var(--accent); stroke-width: 2.2; fill: none; }
.h-led { fill: var(--st-good); }
.hub-marker.offline .h-led { fill: var(--st-off); }
.h-label { fill: var(--text-secondary); font-size: 10.5px; }

/* сводка по зонам */
.zone-summary { flex: 0 0 320px; display: flex; flex-direction: column; gap: 10px; }
.zs-title { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-muted); margin: 4px 2px 0; font-weight: 600; }
.zs-card {
  background: var(--panel); border: 1px solid var(--border);
  border-left-width: 3px; border-radius: 10px; padding: 12px 15px;
}
.zs-card.zs-ok { border-left-color: var(--st-good); }
.zs-card.zs-warning { border-left-color: var(--st-warn); }
.zs-card.zs-error { border-left-color: var(--st-crit); }
.zs-card.zs-offline { border-left-color: var(--st-off); }
.zs-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.zs-zone { font-weight: 600; font-size: 12.5px; }
.zchip { font-size: 11px; font-weight: 600; white-space: nowrap; }
.zc-ok { color: var(--st-good); }
.zc-warning { color: var(--st-warn); }
.zc-error { color: var(--st-crit); }
.zc-offline { color: var(--st-off); }
.zs-setline { font-size: 11.5px; color: var(--text-muted); margin: 3px 0 7px; }
.zs-setline b { color: var(--text-secondary); font-family: var(--mono); font-size: 11px; }
.zs-setline b.zc-ok { color: var(--text-primary); }
.zs-sensor {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  padding: 4px 7px; margin: 0 -7px; border-radius: 7px; cursor: pointer;
  color: var(--text-secondary); transition: .15s;
}
.zs-sensor:hover { background: var(--panel2); color: var(--text-primary); }
.zs-sensor b { margin-left: auto; color: var(--text-primary); font-family: var(--mono); font-size: 11.5px; font-weight: 500; }
.zs-sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* маршрут */
.route-box { margin-top: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.route-path { stroke: var(--border2); stroke-width: 3; fill: none; stroke-linecap: round; }
.route-done { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linecap: round; }
.route-stop { fill: #fff; stroke: var(--text-muted); stroke-width: 2; }
.route-label { fill: var(--text-secondary); font-size: 12px; }
.truck-dot { fill: var(--accent); }
.route-meta { color: var(--text-secondary); font-size: 12px; margin-top: 6px; display: flex; gap: 18px; font-family: var(--mono); flex-wrap: wrap; }

/* ── события ───────────────────────────────────────── */
.events-table {
  width: 100%; border-collapse: collapse;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.events-table th {
  text-align: left; padding: 11px 18px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .9px; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border);
}
.events-table td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-secondary); }
.events-table tr:last-child td { border-bottom: none; }
.events-table tr:hover td { background: var(--panel2); }
.events-table td.ts { color: var(--text-muted); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.sev { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: .3px; }
.sev.info { background: rgba(27, 143, 128, .1); color: var(--accent); }
.sev.warning { background: rgba(211, 134, 15, .12); color: var(--st-warn); }
.sev.error { background: rgba(217, 67, 67, .1); color: var(--st-crit); }
tr.evt-new { animation: rowFlash 2.5s ease; }
@keyframes rowFlash { 0% { background: rgba(217, 67, 67, .1); } 100% { background: transparent; } }

/* ── оповещения ────────────────────────────────────── */
.alerts-head { margin: 4px 2px 10px; }
.alerts-head:not(:first-child) { margin-top: 26px; }
.alerts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.alert-ok-card {
  grid-column: 1 / -1; text-align: center; padding: 28px;
  background: rgba(42, 155, 84, .05); border: 1px dashed rgba(42, 155, 84, .4);
  border-radius: var(--radius); color: var(--st-good); font-weight: 600;
}
.alert-card {
  background: var(--panel); border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 10px; padding: 13px 15px; cursor: pointer; transition: .18s;
}
.alert-card:hover { border-color: var(--border2); box-shadow: 0 4px 14px rgba(22, 37, 31, .08); }
.alert-card.al-error { border-left-color: var(--st-crit); }
.alert-card.al-warning { border-left-color: var(--st-warn); }
.alert-card.al-offline { border-left-color: var(--st-off); }
.al-top { display: flex; justify-content: space-between; align-items: center; }
.al-val { font-family: var(--mono); font-size: 15px; }
.al-error .al-val { color: var(--st-crit); }
.al-warning .al-val { color: var(--st-warn); }
.al-name { font-weight: 600; font-size: 13px; margin-top: 6px; }
.al-site { font-size: 11px; color: var(--text-muted); }
.al-detail { font-size: 11.5px; color: var(--text-secondary); margin-top: 5px; line-height: 1.5; }

/* ── боковая панель ────────────────────────────────── */
.panel[hidden] { display: none; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 30; display: flex; flex-direction: column;
  box-shadow: -14px 0 40px rgba(22, 37, 31, .12);
  animation: panelIn .25s ease;
}
@keyframes panelIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 13px; border-bottom: 1px solid var(--border); }
.panel-title { font-weight: 600; font-size: 15px; }
.panel-sub { color: var(--text-muted); font-size: 11.5px; margin-top: 3px; }
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); font-size: 14px; padding: 4px 9px; transition: .15s;
}
.icon-btn:hover { color: var(--st-crit); border-color: var(--st-crit); }
.panel-body { padding: 16px 20px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; margin-bottom: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-secondary); }
.big-vals { display: flex; gap: 12px; margin-bottom: 16px; }
.big-val { flex: 1; background: var(--panel2); border-radius: 10px; padding: 12px 14px; }
.big-val .v { font-size: 23px; font-weight: 700; font-family: var(--mono); }
.big-val .l { font-size: 10.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.big-val .l i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.range-btns { display: flex; gap: 6px; margin: 4px 0 12px; }
.range-btns button {
  background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 11px; font-size: 11px; color: var(--text-muted); transition: .15s;
}
.range-btns button.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chart-box { margin-bottom: 16px; }
.chart-title { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.chart-title i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
canvas.chart { width: 100%; height: 150px; display: block; background: #FDFEFD; border: 1px solid var(--border); border-radius: 9px; }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 40; display: none;
  background: #fff; border: 1px solid var(--border2); border-radius: 8px;
  padding: 7px 11px; font-size: 11.5px; color: var(--text-secondary);
  font-family: var(--mono); white-space: nowrap;
  box-shadow: 0 6px 18px rgba(22, 37, 31, .12);
}
.chart-tip b { color: var(--text-primary); }

/* ── модал ─────────────────────────────────────────── */
.modal-bg[hidden] { display: none; }
.modal-bg {
  position: fixed; inset: 0; background: rgba(22, 37, 31, .35); backdrop-filter: blur(3px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
}
.modal {
  width: 580px; max-width: 94vw; max-height: 86vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(22, 37, 31, .25);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 11px; padding: 16px 20px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.modal-head h3 { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.modal-x {
  margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: none; color: var(--text-muted); font-size: 13px; transition: .15s;
}
.modal-x:hover { color: var(--st-crit); border-color: var(--st-crit); }
.modal-body { padding: 16px 20px; }
.th-block { margin-bottom: 20px; }
.th-head { display: flex; align-items: center; gap: 9px; font-size: 13px; flex-wrap: wrap; }
.th-head .muted { font-size: 11px; }
.th-now { margin-left: auto; font-family: var(--mono); font-size: 16px; font-weight: 700; }
.th-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); margin: 7px 0 9px; }
.th-stats b { color: var(--text-secondary); font-family: var(--mono); font-weight: 500; }

/* ── toast ─────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 10px; width: 330px; }
.toast {
  background: #fff; border: 1px solid var(--border2); border-left: 3px solid var(--accent);
  border-radius: 11px; padding: 11px 14px; font-size: 12px; color: var(--text-secondary);
  box-shadow: 0 10px 30px rgba(22, 37, 31, .16);
  animation: toastIn .35s ease;
}
.toast b { color: var(--text-primary); display: block; margin-bottom: 2px; font-size: 12px; }
.toast.warning { border-left-color: var(--st-warn); }
.toast.error { border-left-color: var(--st-crit); }
@keyframes toastIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: none; } }

.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 10px; line-height: 1.6; }

@media (max-width: 920px) {
  .mon-grid { flex-direction: column; height: auto; }
  .mon-side { flex: none; max-height: 44vh; }
  .mon-map { min-height: 420px; }
}
