:root[data-theme="dark"] {
  --bg: #0E1116; --surface: #161B22; --surface2: #1F2630; --border: #2D3643;
  --text: #E6EDF3; --text2: #9DA7B3;
  --blue: #4C9BFF; --yellow: #FFD43B;
  --red: #FF4D4F; --warn: #F5C518; --green: #2EBD6B; --nodata: #4A5260;
  --red-soft: rgba(255,77,79,.14); --tile-text: #0E1116; --tile-text-nodata: #E6EDF3;
  --grid: rgba(76,155,255,.06); --glow: 0 0 14px rgba(255,77,79,.55);
  --fw-boost: 50; --btn-on-text: #0E1116;
}
:root[data-theme="light"] {
  --bg: #F5F7FA; --surface: #FFFFFF; --surface2: #EEF2F7; --border: #D8DEE6;
  --text: #0F1720; --text2: #4A5563;
  --blue: #0057B7; --yellow: #FFD500;
  --red: #D92D20; --warn: #E0A800; --green: #1E9E57; --nodata: #B8C0CC;
  --red-soft: rgba(217,45,32,.09); --tile-text: #FFFFFF; --tile-text-nodata: #0F1720;
  --grid: rgba(0,87,183,.06); --glow: 0 0 0 rgba(0,0,0,0);
  --fw-boost: 0; --btn-on-text: #FFFFFF;
}
:root.hc[data-theme="dark"] { --bg:#000; --surface:#000; --surface2:#111; --border:#fff; --text:#fff; --text2:#fff; }
:root.hc[data-theme="light"] { --bg:#fff; --surface:#fff; --surface2:#f2f2f2; --border:#000; --text:#000; --text2:#000; }

html, body { background: var(--bg); color: var(--text); }
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif; min-height: 100vh; margin: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}
:root[data-theme="dark"] body { font-weight: 450; }
.mono { font-family: 'IBM Plex Mono', monospace; }

.themed, .themed * { transition: background-color .25s ease, color .25s ease, border-color .25s ease, fill .25s ease, stroke .25s ease; }
.no-motion, .no-motion * { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.panel2 { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; }
.t2 { color: var(--text2); }
.brand-line { height: 3px; background: linear-gradient(90deg, var(--blue) 50%, var(--yellow) 50%); border-radius: 2px; }

.btn {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--blue); }
.btn:focus-visible, .tile:focus-visible, input:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn.on { background: var(--blue); color: var(--btn-on-text); border-color: var(--blue); }
.btn-primary { background: var(--blue); color: var(--btn-on-text); border-color: var(--blue); }

.theme-icon { display: inline-block; transition: transform .3s ease, opacity .3s ease; }
.theme-icon.spin { transform: rotate(180deg) scale(.6); opacity: 0; }

.pill { padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; border: 1px solid; }
.pill-red { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.pill-warn { color: var(--warn); border-color: var(--warn); }

.live-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--green); animation: pulse 2s infinite; }
.off-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--red); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

.tile { cursor: pointer; }
.tile rect { stroke: var(--bg); stroke-width: 3; }
:root.hc .tile rect { stroke: var(--text); stroke-width: 3; }
.tile:hover rect, .tile.sel rect { stroke: var(--blue); stroke-width: 4; }
.tile.dim { opacity: .25; }
.fill-red { fill: var(--red); } .fill-yellow { fill: var(--warn); } .fill-green { fill: var(--green); } .fill-gray { fill: var(--nodata); }
.tile.red rect { animation: alertPulse 2.2s ease-in-out infinite; filter: drop-shadow(var(--glow)); }
@keyframes alertPulse { 0%,100% { fill-opacity: 1 } 50% { fill-opacity: .6 } }
.tile-label { fill: var(--tile-text); font-size: 12px; font-weight: 700; pointer-events: none; }
.tile.gray .tile-label { fill: var(--tile-text-nodata); }
.tile-icon { font-size: 12px; pointer-events: none; }

.alert-item { background: var(--red-soft); border-left: 4px solid var(--red); border-radius: 8px; cursor: pointer; }
.alert-item.yellow { background: transparent; border-left-color: var(--warn); }
.status-red { color: var(--red); } .status-yellow { color: var(--warn); } .status-green { color: var(--green); } .status-gray { color: var(--text2); }

input.search { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; width: 100%; }
input.search::placeholder { color: var(--text2); }
.bar { background: var(--red); border-radius: 2px; }
.scroll { scrollbar-color: var(--border) transparent; }
a { color: var(--blue); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; }