/* Voltify Operations Monitor — dark operations-center theme */

:root {
  --bg: #0a1018;
  --bg-2: #0e1623;
  --panel: #121c2c;
  --panel-2: #16223440;
  --panel-hi: #182539;
  --border: #1f2d44;
  --border-hi: #2b3d5c;
  --text: #e7eef9;
  --text-2: #9fb0c9;
  --text-3: #6b7e9c;
  --accent: #3b82f6;
  --ok: #22c55e;
  --info: #06b6d4;
  --warn: #f59e0b;
  --crit: #ef4444;
  --idle: #a78bfa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  --mono: 'SF Mono', ui-monospace, 'Cascadia Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: radial-gradient(1200px 700px at 80% -10%, #16243a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100vh; }
a { color: inherit; text-decoration: none; }
.icon { display: inline-block; vertical-align: middle; flex: none; }

/* ---------- shell ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 232px; flex: none; background: linear-gradient(180deg, var(--bg-2), #0b121d);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 6px 8px 22px; }
.brand-logo { height: 28px; width: auto; max-width: 168px; object-fit: contain; filter: brightness(0) invert(1); }
.brand-sub { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; transition: .15s; }
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.active { background: linear-gradient(90deg, rgba(59,130,246,.18), rgba(59,130,246,.05));
  color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 12px 10px; }
.src-badge { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.src-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,.18); animation: pulse 2s infinite; }
.src-note { font-size: 11px; color: var(--text-3); margin-top: 4px; padding-left: 16px; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 26px; border-bottom: 1px solid var(--border); background: rgba(10,16,24,.7); backdrop-filter: blur(8px); }
.topbar-left { display: flex; flex-direction: column; }
.site-name { font-size: 15px; font-weight: 600; }
.site-sub { font-size: 12px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px; font-weight: 700; font-size: 13px;
  border: 1px solid var(--border-hi); }
.pill-crit { color: var(--crit); background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.35); }
.pill-warn { color: var(--warn); background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.32); }
.pill.zero { color: var(--text-3); background: transparent; border-color: var(--border); }
.topbar-sep { width: 1px; height: 22px; background: var(--border-hi); }
.live-ind { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--ok); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(34,197,94,.5); animation: pulse 2s infinite; }
.live-ind.flash .live-dot { box-shadow: 0 0 0 5px rgba(34,197,94,.35); }
/* feed-state colours: green=live (default), grey=simulated, red=offline */
.src-badge.sim, .live-ind.sim { color: var(--text-3); }
.src-badge.sim .src-dot, .live-ind.sim .live-dot { background: var(--idle); box-shadow: 0 0 0 3px rgba(148,163,184,.15); animation: none; }
.src-badge.offline, .live-ind.offline { color: var(--crit); }
.src-badge.offline .src-dot, .live-ind.offline .live-dot { background: var(--crit); box-shadow: 0 0 0 3px rgba(239,68,68,.18); animation: none; }
.clock-wrap { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-family: var(--mono); font-size: 13px; }

/* ---------- section + panel ---------- */
.section-title h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.section-title p { margin: 4px 0 0; color: var(--text-3); font-size: 13.5px; }
.panel { background: linear-gradient(180deg, var(--panel), #101a28); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); }
.panel-title .icon { color: var(--text-2); }
.panel-note { font-size: 12px; color: var(--text-3); }
.panel-body { padding: 18px; }

/* ---------- live view toggle (diagram / cards) ---------- */
.live-actions { display: flex; align-items: center; gap: 14px; }
.view-toggle { display: inline-flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.view-toggle button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: none; background: none; color: var(--text-2); cursor: pointer; font: inherit; font-size: 12.5px; border-radius: 6px; }
.view-toggle button .icon { color: var(--text-3); }
.view-toggle button:hover:not(.on) { color: var(--text); }
.view-toggle button.on { background: var(--panel-hi); color: var(--text); }
.view-toggle button.on .icon { color: var(--text); }
.live-cards .kpi-strip { margin-bottom: 16px; }

/* ---------- KPIs ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px; min-height: 92px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; }
.kpi-label .icon { color: var(--text-3); }
.kpi-value { font-size: 26px; font-weight: 700; font-family: var(--mono); letter-spacing: -.5px; line-height: 1; }
.kpi-unit { font-size: 13px; color: var(--text-3); font-weight: 600; margin-left: 5px; }
.kpi-sub { font-size: 11.5px; color: var(--text-3); }
.kpi-gauge { align-items: center; justify-content: center; }

/* ---------- component grid + cards ---------- */
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.comp-card { text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--c, var(--border-hi));
  border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; transition: .15s; }
.comp-card:hover { border-color: var(--border-hi); border-left-color: var(--c); transform: translateY(-2px); background: var(--panel-hi); }
.comp-card.static { cursor: default; }
.comp-card.static:hover { transform: none; }
.comp-card-head { display: flex; align-items: center; gap: 11px; }
.comp-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.comp-card-id { flex: 1; min-width: 0; }
.comp-card-name { font-weight: 600; font-size: 14.5px; }
.comp-card-kind { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); }
.comp-card-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric-chip { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; }
.mc-label { display: block; font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }
.mc-value { display: block; font-size: 15px; font-weight: 600; font-family: var(--mono); margin-top: 2px; }
.comp-card-foot { font-size: 12px; }
.mini-alert { color: var(--warn); font-weight: 600; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 38%, transparent); white-space: nowrap; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge-crit { animation: blink 1.4s infinite; }

/* ---------- charts ---------- */
.chart { display: block; width: 100%; }
.chart-grid { stroke: rgba(255,255,255,.06); stroke-width: 1; }
.chart-grid-v { stroke: rgba(255,255,255,.035); }
.chart-axis { fill: var(--text-2); font-size: 11.5px; font-family: var(--mono); }
.chart-empty { fill: var(--text-3); font-size: 13px; }
.chart-facet-label { font-size: 11px; font-weight: 600; font-family: var(--mono); }
.chart-dot { stroke: rgba(10,16,24,.55); stroke-width: 1; }   /* data-point marker on the line */
.chart-last { stroke: var(--panel); stroke-width: 1.5; }
/* hover crosshair + tooltip */
.chart-wrap { position: relative; width: 100%; }
.chart { display: block; cursor: crosshair; }
.chart-cross { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 4; opacity: .55; }
.chart-cross-dot { stroke: var(--panel); stroke-width: 1.5; }
.chart-brush { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 1; stroke-opacity: .6; }
.chart-tip { position: absolute; display: none; pointer-events: none; z-index: 6; min-width: 132px;
  background: color-mix(in srgb, var(--panel) 92%, #000); border: 1px solid var(--border-hi);
  border-radius: 9px; padding: 8px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.chart-tip .ct-time { color: var(--text-3); font-size: 10.5px; letter-spacing: .3px; margin-bottom: 6px; font-family: var(--mono); }
.chart-tip .ct-row { display: flex; align-items: center; gap: 8px; line-height: 1.75; font-size: 12px; }
.chart-tip .ct-row i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.chart-tip .ct-name { color: var(--text-2); margin-right: 14px; white-space: nowrap; }
.chart-tip .ct-val { color: var(--text); margin-left: auto; font-weight: 600; font-family: var(--mono); }
.spark { display: block; overflow: visible; }
.gauge-value { fill: var(--text); font-size: 26px; font-weight: 700; font-family: var(--mono); }
.gauge-unit { fill: var(--text-3); font-size: 11px; }
.gauge-label { fill: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; justify-content: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend-item i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.hist-norm-note { display: block; margin-top: 6px; text-align: center; color: var(--text-3); font-size: 11px; font-style: italic; }
.hist-hint { text-align: center; color: var(--text-3); font-size: 11px; opacity: .8; }

/* ---------- alerts modal (topbar pills open it; auto-pops on new fault/warning) ---------- */
.pill.clickable { cursor: pointer; }
.pill.clickable:hover { filter: brightness(1.15); }
.amodal-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(4,8,14,0.62); backdrop-filter: blur(2px); }
.amodal-card { width: min(560px, 92vw); max-height: 80vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-hi); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55); overflow: hidden; }
.amodal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.amodal-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; color: var(--text); }
.amodal-x { background: transparent; border: none; color: var(--text-2); font-size: 16px; line-height: 1; cursor: pointer; padding: 6px 9px; border-radius: 7px; }
.amodal-x:hover { background: var(--bg-2); color: var(--text); }
.amodal-list { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.amodal-empty { padding: 30px; text-align: center; color: var(--text-3); }
.amodal-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 9px;
  background: var(--bg-2); border-left: 3px solid transparent; }
.amodal-row.crit { border-left-color: #ef4444; }
.amodal-row.warn { border-left-color: #f59e0b; }
.amodal-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.amodal-row-main { flex: 1; min-width: 0; }
.amodal-row-msg { color: var(--text); font-size: 13px; }
.amodal-row-sub { color: var(--text-3); font-size: 11px; margin-top: 2px; }
.amodal-row-time { color: var(--text-3); font-size: 11px; font-family: var(--mono); flex: none; }

/* ---------- tag table ---------- */
.tagtable { display: flex; flex-direction: column; gap: 12px; }
.tt-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tt-search-wrap { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; color: var(--text-3); }
.tt-search { flex: 1; background: none; border: none; color: var(--text); font: inherit; padding: 10px 0; outline: none; }
.tt-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-2); cursor: pointer; font: inherit; }
.tt-toggle.on { color: var(--warn); border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.08); }
.tt-count { font-size: 12px; color: var(--text-3); font-family: var(--mono); margin-left: auto; }
.tt-scroll { max-height: 460px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tt-table thead th { position: sticky; top: 0; background: var(--bg-2); text-align: left; padding: 10px 14px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); border-bottom: 1px solid var(--border); z-index: 1; }
.tt-table td { padding: 9px 14px; border-bottom: 1px solid rgba(31,45,68,.5); vertical-align: middle; }
.tt-row:hover { background: rgba(255,255,255,.025); }
.tt-row.alarm { background: rgba(239,68,68,.07); }
.tt-tagname { display: block; font-family: var(--mono); font-size: 12px; color: var(--text); word-break: break-all; }
.tt-tagh { display: block; font-size: 11px; color: var(--text-3); }
.tt-number { font-family: var(--mono); font-weight: 600; }
.tt-bool { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.tt-bool.false { color: var(--text-3); background: rgba(255,255,255,.05); }
.tt-bool.true { color: var(--info); background: rgba(6,182,212,.12); }
.tt-bool.on { color: var(--crit); background: rgba(239,68,68,.16); }
.tt-unit { color: var(--text-2); font-family: var(--mono); }
.tt-type { color: var(--text-3); font-size: 12px; }
.tt-doc { color: var(--text-2); font-size: 12px; max-width: 320px; }
.tt-more { align-self: center; padding: 8px 18px; border-radius: 20px; background: var(--panel-hi); border: 1px solid var(--border-hi);
  color: var(--text-2); cursor: pointer; font: inherit; }
.tt-more:hover { color: var(--text); border-color: var(--accent); }

/* ---------- alerts ---------- */
.alerts { display: flex; flex-direction: column; gap: 14px; }
.alert-filters { display: flex; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 18px; cursor: pointer; font: inherit;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-2); }
.chip.on { color: #fff; border-color: var(--accent); background: rgba(59,130,246,.14); }
.chip-count { font-family: var(--mono); font-size: 11px; background: rgba(255,255,255,.08); padding: 1px 7px; border-radius: 10px; }
.alert-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.alert-row { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px 13px 18px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); position: relative; }
.alert-row.resolved { opacity: .55; }
.alert-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c);
  border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.alert-ic { color: var(--c); display: grid; place-items: center; flex: none; margin-top: 1px; }
.alert-main { flex: 1; min-width: 0; }
.alert-msg { font-weight: 500; font-size: 13.5px; line-height: 1.45; }
.alert-meta { display: flex; gap: 12px; margin-top: 3px; flex-wrap: wrap; }
.alert-comp { font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.alert-tag { font-size: 11px; color: var(--text-3); font-family: var(--mono); word-break: break-all; }
.alert-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; padding-right: 14px; flex: none; }
.sev-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 5px; }
.sev-tag.sev-critical { color: var(--crit); background: rgba(239,68,68,.14); }
.sev-tag.sev-warning { color: var(--warn); background: rgba(245,158,11,.14); }
.sev-tag.sev-info { color: var(--accent); background: rgba(59,130,246,.14); }
.alert-time { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.resolved-tag { font-size: 10px; color: var(--ok); text-transform: uppercase; letter-spacing: .5px; }
.empty { text-align: center; color: var(--text-3); padding: 28px; font-size: 13.5px; }

/* ---------- history ---------- */
.history { display: flex; flex-direction: column; gap: 16px; }
.hist-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hist-scope { display: flex; align-items: center; gap: 8px; }
.hist-scope label { font-size: 12px; color: var(--text-3); }
.hist-select { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 12px; font: inherit; outline: none; cursor: pointer; }
.hist-select:focus { border-color: var(--accent); }
.hist-select-sm { padding: 9px 10px; font-size: 12.5px; }
.hist-select-sm:disabled { opacity: .45; cursor: not-allowed; }
.hist-agg { gap: 6px; }
.hist-windows { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
/* custom date-time range row (collapsible) */
.hist-custom { display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.hist-custom.open { display: flex; }
.hist-dt-l { font-size: 12px; color: var(--text-3); }
.hist-dt { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 8px 10px; font: inherit; outline: none; color-scheme: dark; }
.hist-dt:focus { border-color: var(--accent); }
.hist-apply { background: rgba(59,130,246,.16); border: 1px solid var(--accent); color: #fff; border-radius: var(--radius-sm);
  padding: 8px 16px; font: inherit; cursor: pointer; }
.hist-apply:hover { background: rgba(59,130,246,.26); }
.hist-custom-msg { font-size: 12px; color: var(--crit); }
.hist-picker { position: relative; }
.hist-picker-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 9px 13px; cursor: pointer; font: inherit; }
.hist-picker-btn:hover { border-color: var(--border-hi); }
.hist-picker-pop { position: absolute; top: 110%; left: 0; z-index: 20; width: 360px; max-width: 80vw; background: var(--panel);
  border: 1px solid var(--border-hi); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px; display: none; }
.hist-picker-pop.open { display: block; }
.pick-search-wrap { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 10px; color: var(--text-3); margin-bottom: 10px; }
.pick-search { flex: 1; background: none; border: none; color: var(--text); font: inherit; padding: 8px 0; outline: none; }
.pick-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.pick-row:hover { background: var(--panel-hi); }
.pick-row.on { background: rgba(59,130,246,.1); }
.pick-name { flex: 1; font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.pick-unit { color: var(--text-3); font-family: var(--mono); }
.hist-chart { width: 100%; position: relative; }
/* one plot box per selected parameter, responsive grid */
.hist-charts { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.hist-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 6px; min-width: 0; }
.hist-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.hist-card-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.hist-card-name { font-size: 12px; color: var(--text-2); font-weight: 600; letter-spacing: .2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-card-zoom { margin-left: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; font-size: 10.5px; color: var(--text-2); background: var(--panel-hi); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; flex: none; }
.hist-card-zoom:hover { border-color: var(--border-hi); color: var(--text-1); }
.hist-card-val { margin-left: auto; padding-left: 10px; font-family: var(--mono); font-size: 12.5px; color: var(--text-1); flex: none; }
.hist-card-ctl { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.hist-card-ctl-l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-right: 2px; }
.hist-card-ctl .hist-select-sm { flex: none; }
.hist-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: color-mix(in srgb, var(--panel) 72%, transparent); backdrop-filter: blur(1px); border-radius: 8px; }
.hist-loading .spinner { width: 30px; height: 30px; border-width: 3px; }
.hist-loading span { font-size: 12px; color: var(--text-2); letter-spacing: .3px; }
.hist-legend { display: flex; justify-content: center; }

/* ---------- fixed monitoring wall (last-hour trends per component) ---------- */
.fixed-trends { display: flex; flex-direction: column; gap: 14px; }
.ft-row { display: grid; grid-template-columns: 176px 1fr; gap: 16px; align-items: stretch;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.ft-row-head { display: flex; flex-direction: column; justify-content: center; gap: 6px; border-right: 1px solid var(--border); padding-right: 14px; }
.ft-row-title { display: flex; align-items: center; gap: 8px; }
.ft-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.ft-row-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: .2px; }
.ft-row-sub { font-family: var(--mono); font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }
.ft-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.ft-chart { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px 4px; min-width: 0; }
.ft-chart-title { font-size: 11px; font-weight: 600; color: var(--text-2); letter-spacing: .2px; margin-bottom: 3px; }
.ft-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 2px; }
.ft-legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.ft-legend-item i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.ft-legend-name { color: var(--text-3); }
.ft-legend-val { font-family: var(--mono); color: var(--text-1); }
@media (max-width: 820px) {
  .ft-row { grid-template-columns: 1fr; }
  .ft-row-head { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 8px; flex-direction: row; align-items: baseline; gap: 12px; }
}

/* ---------- drawer ---------- */
.drawer-root { position: fixed; inset: 0; z-index: 100; }
.scrim { position: absolute; inset: 0; background: rgba(4,8,14,.55); opacity: 0; transition: .2s; }
.drawer-root.show .scrim { opacity: 1; }
.drawer { position: absolute; top: 0; right: 0; height: 100%; width: min(820px, 94vw); background: var(--bg);
  border-left: 1px solid var(--border-hi); box-shadow: -20px 0 60px rgba(0,0,0,.5); transform: translateX(100%); transition: transform .22s ease;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.drawer-root.show .drawer { transform: translateX(0); }
.drawer-head { position: sticky; top: 0; z-index: 3; background: var(--bg); display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--border); color: var(--text-2); }
.drawer-titles { flex: 1; min-width: 0; }
.drawer-titles h2 { margin: 0; font-size: 19px; }
.drawer-sub { font-size: 12px; color: var(--text-3); font-family: var(--mono); margin-top: 2px; }
.drawer-close { background: var(--panel); border: 1px solid var(--border); color: var(--text-2); width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.drawer-close:hover { color: #fff; border-color: var(--crit); }
.drawer-body { padding: 20px 22px 50px; display: flex; flex-direction: column; gap: 18px; }
.drawer-desc { color: var(--text-2); font-size: 13.5px; margin: 0; line-height: 1.5; }
.drawer-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.no-telemetry { text-align: center; color: var(--text-3); padding: 30px 20px; }
.no-telemetry .icon { color: var(--text-3); }
.no-telemetry h3 { margin: 12px 0 6px; color: var(--text-2); }
.no-telemetry p { max-width: 460px; margin: 0 auto; line-height: 1.5; font-size: 13px; }

/* ---------- diagram ---------- */
.diagram-wrap { position: relative; width: 100%; max-width: 1100px; margin-inline: auto;
  background: radial-gradient(700px 400px at 50% 0%, #14213380, transparent), #0b1320;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.diagram { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.diagram image { -webkit-user-drag: none; user-drag: none; }
/* fullscreen toggle button */
.diagram-fs { position: absolute; top: 10px; right: 10px; z-index: 3; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  background: #0b1320cc; border: 1px solid var(--border); border-radius: 8px; color: var(--text-2); }
.diagram-fs:hover { color: var(--text); border-color: var(--border-hi); background: #0b1320; }
/* expanded: fill the screen and scale the diagram to the available height */
.system-diagram:fullscreen { background: var(--bg); padding: 18px; display: flex; flex-direction: column; }
.system-diagram:fullscreen .diagram-wrap { flex: 1; min-height: 0; max-width: none; display: flex; align-items: center; justify-content: center; }
.system-diagram:fullscreen .diagram { width: 100%; height: 100%; max-height: 100%; }
.link { stroke-width: 2.5; stroke-linecap: round; opacity: .85; }
.link.ac, .link.dc { stroke: rgba(138,160,184,.55); }
.link.muted { stroke: rgba(71,85,105,.5); opacity: .6; }
/* Live power-flow overlay: hidden unless the link is actually flowing, then a
   green moving dash + a green arrowhead pointing in the real flow direction. */
.link-flow { stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 12; opacity: 0; }
.link-flow.on { opacity: .95; stroke: #22c55e; }
.link-flow.on.fwd { animation: flow 1s linear infinite; }
.link-flow.on.rev { animation: flowRev 1s linear infinite; }
.link-flow.muted { display: none; }
.link.wireless { stroke: var(--idle); stroke-width: 2; stroke-dasharray: 5 7; opacity: .7; animation: flow 1.4s linear infinite; }
.link.comm { stroke: #4fb0a5; stroke-width: 1.8; stroke-dasharray: 6 6; opacity: .2; }
.link-badge { fill: #0b1320; stroke-width: 1; }
.link-badge.ac, .link-badge.dc { stroke: rgba(138,160,184,.6); }
.link-label { font-size: 10px; font-weight: 700; font-family: var(--mono); }
.link-label.ac, .link-label.dc { fill: #c3d0e0; }
.link-label.wl { fill: var(--idle); letter-spacing: 1px; }
.wifi-ic { color: var(--idle); }
.wifi-badge { animation: pulse 2.2s infinite; }

.node { cursor: grab; color: var(--text); --c: #475569; touch-action: none; }
.node.dragging { cursor: grabbing; }
.node.dragging .node-ring { stroke-width: 3; filter: drop-shadow(0 0 8px var(--c)); }
.node.dragging .node-body { fill: var(--panel-hi); }
.node-ring { fill: none; stroke: var(--c); stroke-width: 2; opacity: .9; }
.node-body { fill: #131f30; stroke: var(--border); stroke-width: 1; }
.node:hover .node-body { fill: var(--panel-hi); }
.node:hover .node-ring { stroke-width: 2.5; filter: drop-shadow(0 0 6px var(--c)); }
.node:focus { outline: none; }
.node:focus .node-ring { stroke-width: 3; }
.node-icon { color: var(--c); }
.batt-soc-fill { transition: width .4s ease, fill .4s ease; }
.node-dot { stroke: #0b1320; stroke-width: 2; }
.node-name { fill: var(--text); font-size: 13.5px; font-weight: 600; }
.node-metric { fill: var(--text-2); font-size: 11px; font-family: var(--mono); }
.node-nodata { fill: var(--text-3); font-size: 10.5px; font-style: italic; }
.node.unmon { opacity: .42; }
.node.unmon:hover { opacity: .72; }
.node.unmon .node-body { fill: #0f1826; stroke-dasharray: 4 4; }
.node.unmon .node-name { fill: var(--text-2); }
.node.is-fault .node-ring { animation: faultpulse 1.1s infinite; }
.node.wireless-node .node-body { stroke: var(--idle); stroke-dasharray: 3 4; }

/* microgrid: equipment artwork sits directly on the (dark) stage, no box.
   The black line-art is inverted to white so it reads on the dark background.
   The tile rect is invisible but kept as a click target + status ring. */
.mg-node .mg-tile { fill: transparent; stroke: none; transition: stroke-width .15s ease; }
.mg-node:hover .mg-tile { stroke: var(--c); stroke-width: 2; opacity: .85; filter: drop-shadow(0 0 6px var(--c)); }
.mg-node.dragging .mg-tile { stroke: var(--c); stroke-width: 2.5; filter: drop-shadow(0 0 9px var(--c)); }
.mg-node:focus { outline: none; }
.mg-node:focus .mg-tile { stroke: var(--c); stroke-width: 2.5; }
.mg-node.is-fault .mg-tile { stroke: var(--c); stroke-width: 2.5; animation: faultpulse 1.1s infinite; }
.mg-photo { pointer-events: none; filter: invert(1); }
.mg-name { fill: var(--text); font-size: 12.5px; font-weight: 700; }
.mg-metric { fill: var(--text-2); font-size: 10.5px; font-family: var(--mono); }
.mg-metric.is-nodata { fill: var(--text-3); font-style: italic; }
.mg-node.unmon { opacity: .55; }
.mg-node.unmon:hover { opacity: .85; }
/* live SoC battery glyph beside the BESS */
.mg-batt { pointer-events: none; }
.mg-batt-body { fill: #0b1320; stroke: var(--text-2); stroke-width: 1.5; }
.mg-batt-cap { fill: var(--text-2); }
.mg-batt-fill { transition: y .6s ease, height .6s ease, fill .6s ease; }
.mg-batt-lbl { fill: var(--text-2); font-size: 9.5px; font-family: var(--mono); }
.mg-batt-cap-lbl { fill: var(--text-3); font-size: 9px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }

/* ---------- locomotive (VMS) diagram ---------- */
.loco-diagram .node { cursor: pointer; }

/* ---- locomotive studio stage + live effects ---- */
.loco-stage {
  background:
    radial-gradient(120% 80% at 50% 32%, rgba(45,62,105,.30), rgba(13,19,32,0) 60%),
    radial-gradient(80% 60% at 50% 96%, rgba(40,56,96,.34), rgba(13,19,32,0) 70%),
    linear-gradient(180deg, #0c1220 0%, #0a0f1b 60%, #070b14 100%);
  border-radius: var(--radius);
  overflow: hidden;
}
/* health glow + front lights are always on (open or closed) */
.loco-photo { pointer-events: none; transition: opacity .6s ease, filter .8s ease; }
.loco-diagram { --glow: rgba(59,130,246,.42); }
.loco-diagram .loco-photo { filter: drop-shadow(0 6px 16px var(--glow)); }

/* contact wire is always shown; only the travelling energy pulse is gated on
   the pantograph being raised (energised). */
.loco-wire { stroke: rgba(150,170,210,.24); stroke-width: 1.6; stroke-linecap: round; opacity: 1; transition: opacity .5s ease; }
.loco-pulse { fill: #bcd2ff; opacity: 0; filter: drop-shadow(0 0 5px #6ea8ff); }
.loco-diagram.is-running .loco-pulse { animation: locoPulse 6s linear infinite; }
@keyframes locoPulse {
  0% { transform: translateX(20px); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateX(1060px); opacity: 0; }
}

/* pantograph arc/spark — only while energised */
.loco-spark { opacity: 0; }
.loco-arc-glow { fill: #aaccff; filter: drop-shadow(0 0 8px #7db4ff); }
.loco-arc-core { fill: #fff; }
.loco-diagram.is-running .loco-spark { animation: locoSpark 4.5s ease-in-out infinite; }
@keyframes locoSpark {
  0%, 12%, 100% { opacity: 0; }
  4% { opacity: .9; }
  6% { opacity: .2; }
  8% { opacity: .7; }
}
@media (prefers-reduced-motion: reduce) {
  .loco-pulse, .loco-spark { animation: none !important; }
}
.loco-shadow { fill: url(#locoShadow); }
.loco-rail { stroke: #36425a; stroke-width: 3; stroke-linecap: round; }
.loco-bogie { fill: url(#locoMetal); stroke: #4a5773; stroke-width: 1.4; }
.loco-wheel { fill: #0d1626; stroke: #6577a0; stroke-width: 3.2; }
.loco-wheel-hub { fill: #28344f; stroke: #6577a0; stroke-width: 1.4; }
.loco-spring { fill: none; stroke: #6f7e9c; stroke-width: 1.6; }
.loco-body-main { stroke: #6679df; stroke-width: 1.6; stroke-linejoin: round; }
.loco-face { stroke: #5666c8; stroke-width: 1.2; stroke-linejoin: round; }
.loco-livery-white { fill: #eef2fb; }
.loco-chevron-blue { fill: #2a3aa0; opacity: .92; }
.loco-logo { filter: brightness(0) invert(1); opacity: .96; }
.loco-sheen { fill: none; stroke: rgba(255,255,255,.22); stroke-width: 2; stroke-linecap: round; }
.loco-panel { fill: none; stroke: rgba(255,255,255,.10); stroke-width: 1.2; }
.loco-glass { fill: #0c1730; stroke: #9fb4e6; stroke-width: 1.4; opacity: .9; }
.loco-door { fill: rgba(255,255,255,.04); stroke: rgba(255,255,255,.16); stroke-width: 1.2; }
.loco-louver { stroke: rgba(255,255,255,.20); stroke-width: 1.3; }
.loco-chevron { fill: #eef2ff; opacity: .9; }
.loco-detail { fill: none; stroke: #6b7b9c; stroke-width: 1.4; stroke-linecap: round; opacity: .8; }
.loco-headlight { fill: #fde6a0; }
.loco-text { fill: #e7edff; font-family: var(--mono); font-weight: 700; letter-spacing: 3px; font-size: 19px; opacity: .92; }
.loco-roofbox { fill: #232d54; stroke: #46538c; stroke-width: 1.2; }
.loco-uframe { fill: #141b2c; stroke: #3a466a; stroke-width: 1.3; }
.loco-buffer { fill: #28344f; stroke: #6577a0; stroke-width: 1.3; }
.loco-panto { fill: none; stroke: #cdd8f2; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.loco-panto-joint { fill: #cdd8f2; }
.loco-wire { stroke: rgba(150,170,210,.35); stroke-width: 1.4; stroke-dasharray: 1 6; stroke-linecap: round; }
.loco-leader { stroke: #5d6e84; stroke-width: 1.5; stroke-dasharray: 3 4; opacity: .75; }
.loco-tap { stroke: #0b1320; stroke-width: 2; }

/* 3D model viewer (VMS page) */
.loco-3d { position: relative; width: 100%; }
.loco-mv { width: 100%; height: 560px; display: block;
  background: radial-gradient(900px 460px at 50% 8%, #16223680, transparent), #0b1320;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  --poster-color: transparent;
  /* keep on-surface hotspots fully visible & interactive (model-viewer otherwise
     dims/occludes a hotspot sitting on the geometry it's attached to) */
  --min-hotspot-opacity: 1; }
.loco-mv-hint { position: absolute; left: 12px; bottom: 12px; color: var(--text-3);
  font-size: 11.5px; font-style: italic; pointer-events: none;
  background: #0b1320aa; padding: 3px 8px; border-radius: 6px; }
.loco-mv-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 13px; pointer-events: none; }
.loco-mv-fallback.err { color: var(--warn); padding: 0 24px; text-align: center; }
.loco-hotspot { border: none; background: none; padding: 0; cursor: default; }
.loco-hot-logo { width: 70px; height: auto; display: block; filter: drop-shadow(0 1px 2px #0008); pointer-events: none; }
/* paint-parts toolbar */
.loco-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 24px); }
.loco-tool-btn { background: #0b1320cc; border: 1px solid var(--border); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 6px 11px; font: inherit; font-size: 12px; cursor: pointer; }
.loco-tool-btn:hover { color: var(--text); border-color: var(--border-hi); }
.loco-tool-btn.on { color: #0b1320; background: var(--text); border-color: var(--text); font-weight: 600; }
.loco-color-input { width: 28px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: #0b1320; cursor: pointer; }
.loco-sel { background: #0b1320cc; border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 9px; font: inherit; font-size: 12px; cursor: pointer; max-width: 220px; }
.loco-sel:hover { border-color: var(--border-hi); }
.loco-bg-ctl { display: flex; align-items: center; gap: 7px; background: #0b1320cc; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 6px 4px 10px; cursor: pointer; }
.loco-bg-ctl:hover { border-color: var(--border-hi); }
.loco-bg-lbl { font-size: 12px; color: var(--text-2); }
/* VMS peripheral hotspots on the 3D model — anchor dot + leader line + offset card */
.loco-hot { position: relative; width: 0; height: 0; }
.loco-hot-anchor { position: absolute; left: 0; top: 0; width: 12px; height: 12px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--c, #22c55e); pointer-events: none;
  box-shadow: 0 0 0 3px #0b1320cc, 0 0 9px var(--c, #22c55e);
  animation: hotHalo 2.6s ease-in-out infinite; }
/* pulsing halo around the on-loco anchor — "live connection" point */
@keyframes hotHalo {
  0%, 100% { box-shadow: 0 0 0 3px #0b1320cc, 0 0 6px var(--c, #22c55e); }
  50%      { box-shadow: 0 0 0 3px #0b1320cc, 0 0 14px var(--c, #22c55e), 0 0 26px var(--c, #22c55e); }
}
.loco-hot-line { position: absolute; left: 0; top: 0; height: 2px; transform-origin: 0 50%; overflow: hidden;
  background: var(--c, #22c55e);
  background: linear-gradient(90deg, var(--c, #22c55e), color-mix(in srgb, var(--c, #22c55e) 40%, transparent));
  opacity: .85; pointer-events: none; }
/* a bright pulse travels from the loco anchor toward the card — live data flow */
.loco-hot-line::after { content: ''; position: absolute; top: 0; bottom: 0; left: -36%; width: 36%;
  background: linear-gradient(90deg, transparent, #ffffffe6, transparent);
  animation: hotFlow 2.2s linear infinite; animation-delay: var(--flow-delay, 0s); }
@keyframes hotFlow { to { left: 110%; } }
.loco-hot-card { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; gap: 2px;
  background: #0b1320e6; border: 1px solid var(--c, #22c55e); border-radius: 9px; padding: 5px 10px;
  color: var(--text); font: inherit; font-size: 11.5px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 9px #0008, 0 0 0 0 var(--c, #22c55e); animation: hotCardGlow 2.3s ease-in-out infinite; }
/* card border breathes in sync with the anchor halo — stronger + faster */
@keyframes hotCardGlow {
  0%, 100% { box-shadow: 0 2px 9px #0008, 0 0 4px 0 var(--c, #22c55e); }
  50%      { box-shadow: 0 2px 9px #0008, 0 0 22px 4px var(--c, #22c55e); }
}
.loco-hot-card:hover { background: #0b1320; box-shadow: 0 0 0 2px var(--c, #22c55e); }
.loco-hot-head { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.loco-hot-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #22c55e); flex: none; }
.loco-hot-metric { color: var(--text-2); font-size: 10.5px; font-weight: 500; }
/* edit mode: only the label card is draggable */
.loco-3d.editing .loco-hot-card { cursor: grab; outline: 1px dashed var(--c, #22c55e); outline-offset: 3px; animation: none; }
.loco-3d.editing .loco-hot-card:active { cursor: grabbing; }

.diagram-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 12px; padding: 0 6px; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; }
.lg-line { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.lg-line.ac, .lg-line.dc { background: #8aa0b8; }
.lg-line.comm { background: none; height: 0; border-radius: 0; border-top: 3px dashed #4fb0a5; }
.legend-sep { width: 1px; height: 16px; background: var(--border-hi); }
.legend-hint { margin-left: auto; color: var(--text-3); font-size: 11.5px; font-style: italic; }
.diagram-reset { background: var(--bg-2); border: 1px solid var(--border); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer; }
.diagram-reset:hover { color: var(--text); border-color: var(--border-hi); }

/* ---------- system health ---------- */
.sys-actions { display: flex; align-items: center; gap: 12px; }
.sys-toggle { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; font: inherit; font-size: 12.5px; }
.sys-toggle:hover { color: var(--text); border-color: var(--border-hi); }
.sys-toggle .icon { transition: transform .18s; }
.sys-toggle.open .icon { transform: rotate(90deg); }
.sys-details { margin-top: 2px; }
.sys-details .kpi-strip { margin-bottom: 4px; }
.sys-subhead { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-3);
  font-weight: 700; margin: 22px 0 11px; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.sys-conns { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.sys-conn { display: flex; align-items: center; gap: 11px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px; }
.sys-conn-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.sys-conn-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sys-conn-name { font-size: 13px; font-weight: 600; }
.sys-conn-detail { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.sys-conn-state { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.sys-link { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px; }
.sys-link-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- loading / fatal ---------- */
.loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 80px 20px; color: var(--text-3); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.fatal { background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.3); border-radius: var(--radius); padding: 24px; }
.fatal pre { white-space: pre-wrap; font-size: 12px; color: var(--text-2); background: var(--bg-2); padding: 12px; border-radius: 8px; overflow: auto; }

/* ---------- animations ---------- */
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); } 50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); } }
@keyframes blink { 50% { opacity: .55; } }
@keyframes flow { to { stroke-dashoffset: -14; } }
@keyframes flowRev { to { stroke-dashoffset: 14; } }
@keyframes faultpulse { 0%,100% { opacity: 1; stroke-width: 2; } 50% { opacity: .4; stroke-width: 3.5; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .brand-sub, .nav-link span, .sidebar-foot { display: none; }
  .brand-logo { height: 24px; max-width: 44px; object-fit: cover; object-position: left center; }
  .nav-link { justify-content: center; }
  .content { padding: 16px; }
}
@media (max-width: 620px) {
  .comp-card-metrics { grid-template-columns: repeat(3, 1fr); }
  .hist-windows { margin-left: 0; }
  .topbar { padding: 12px 16px; }
}
