/* ============================================================
 * Wiman IoT — operator UI
 * ============================================================
 * Design principles:
 *   - Industrial: dense, information-rich, no decorative noise
 *   - Trustworthy: subdued palette, restrained typography
 *   - Operator-first: high contrast for at-a-glance reading
 *   - Status colors used only for state (green/amber/red/gray)
 *
 * Token system below — every spacing/color/shadow comes from a var.
 * ============================================================ */

:root {
  /* Color — neutrals */
  --bg:           #eef1f4;
  --bg-deep:      #e0e6ec;
  --panel:        #ffffff;
  --panel-soft:   #f7f9fb;
  --panel-deep:   #eef1f4;
  --ink:          #11202d;
  --ink-soft:     #4f5d6c;
  --ink-mute:     #8a96a4;
  --line:         #d8dee4;
  --line-soft:    #ecf0f3;
  --line-strong:  #c1c9d2;

  /* Color — brand */
  --brand:         #0d7d76;
  --brand-dark:    #095049;
  --brand-darker:  #053d38;
  --brand-soft:    #e3f1ef;
  --brand-tint:    #f0f8f7;
  --sidebar-bg:    #0d7d76;
  --sidebar-bg-2:  #0a625c;
  --sidebar-ink:   #ffffff;

  /* Color — status */
  --ok:        #1f9d55;
  --ok-soft:   #d8f1e3;
  --warn:      #b88300;
  --warn-soft: #faedc6;
  --crit:      #c1272d;
  --crit-soft: #fbe1e2;
  --info:      #2a5db0;
  --info-soft: #dde9f7;
  --gray:      #92a0b3;

  /* Color — severity (alarm-only) */
  --sev-critical: #c1272d;
  --sev-major:    #d97706;
  --sev-minor:    #b88300;
  --sev-warning:  #5a7da4;

  /* Spacing scale (4-pt grid) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(17, 32, 45, 0.05);
  --shadow-2: 0 2px 4px rgba(17, 32, 45, 0.08);
  --shadow-3: 0 4px 12px rgba(17, 32, 45, 0.10);

  /* Radius */
  --radius:    6px;
  --radius-sm: 4px;
  --radius-lg: 10px;

  /* Layout */
  --sidebar-w: 224px;
  --topbar-h:  56px;

  /* Type */
  --font-sans: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ============================================================
 * Reset + base typography
 * ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; color: var(--ink); letter-spacing: -0.005em; }
h1 { font-size: 18px; }
h2 { font-size: 15px; margin: var(--s-5) 0 var(--s-3); }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); margin: var(--s-4) 0 var(--s-2); font-weight: 700; }
p  { margin: 0 0 var(--s-3); }
a  { color: inherit; text-decoration: none; }

code, .code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--line-soft);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--ink);
}

.small  { font-size: 11px; }
.muted  { color: var(--ink-soft); }
.muted.small, .small.muted { color: var(--ink-mute); }
.right { margin-left: auto; }
.num   { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
[x-cloak] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
 * Login
 * ============================================================ */
.page-login {
  background:
    radial-gradient(at 30% 20%, rgba(13,125,118,0.30), transparent 60%),
    radial-gradient(at 80% 80%, rgba(10,98,92,0.40), transparent 60%),
    linear-gradient(135deg, #061722, #0d3b3c);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: 100%; padding: var(--s-6); }
.login-card {
  display: grid; grid-template-columns: 1fr 1fr;
  max-width: 780px; margin: 0 auto;
  background: var(--panel);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-card__left {
  background: linear-gradient(160deg, var(--brand), var(--brand-darker));
  color: white; padding: 44px 36px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-mark { font-size: 26px; opacity: 0.9; }
.login-brand { margin: var(--s-3) 0 var(--s-2); font-size: 24px; font-weight: 700; }
.login-tagline { opacity: 0.82; font-size: 13px; margin: 0; }
.login-card__right { padding: 44px 36px; }
.login-h2 { margin: 0 0 var(--s-5); font-size: 20px; }
.login-note { margin: var(--s-3) 0 0; font-size: 11px; color: var(--ink-mute); }

/* ============================================================
 * App shell — sidebar + topbar + content
 * ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  box-shadow: 1px 0 0 rgba(0,0,0,0.08);
}
.sidebar__brand {
  padding: 16px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand__mark {
  width: 20px; height: 20px; border-radius: 5px;
  background: white;
  position: relative;
  flex-shrink: 0;
}
.brand__mark::after {
  content: ""; position: absolute; inset: 4px;
  border-radius: 2px; background: var(--brand);
}
.brand__name {
  font-weight: 700; font-size: 14px;
  letter-spacing: 0.01em;
}
.sidebar__nav { flex: 1; padding: var(--s-2) 0 var(--s-4); overflow-y: auto; }
.sidebar__divider {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 6px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  font-weight: 700;
}
.sidebar__divider::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(to right, rgba(255,255,255,0.10), transparent);
}
.sidebar__divider--top { padding-top: 10px; }
.navlink {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 18px 7px 15px;
  color: rgba(255,255,255,0.86);
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.navlink:hover {
  background: rgba(255,255,255,0.06);
  color: #ffffff;
}
.navlink--active {
  background: rgba(0,0,0,0.20);
  border-left-color: white;
  color: #ffffff;
  font-weight: 600;
}
.navlink--sub { padding-left: 32px; font-size: 11px; opacity: 0.85; }
.navlink__label { flex: 1; }
.navlink--disabled { opacity: 0.40; cursor: not-allowed; }
.navlink--disabled:hover { background: transparent; color: rgba(255,255,255,0.86); }
.navlink__tag {
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
  background: rgba(255,255,255,0.14);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 17px; padding: 0 6px;
  background: rgba(0,0,0,0.30); border-radius: 9px;
  font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nav-badge--critical { background: var(--sev-critical); }
.nav-badge--major    { background: var(--sev-major); }
.nav-badge--minor    { background: var(--sev-minor); }
.nav-badge--warning  { background: var(--sev-warning); }
.sidebar__footer {
  padding: 10px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0,0,0,0.12);
}
.sidebar__footer .user { font-weight: 600; opacity: 0.95; }
.sidebar__footer .logout { color: rgba(255,255,255,0.65); font-size: 10px; }
.sidebar__footer .logout:hover { color: #fff; text-decoration: underline; }

/* ----- Content + topbar ----- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  height: var(--topbar-h);
  padding: 0 var(--s-6);
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
}
.topbar__left {
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 0;
}
.topbar__title {
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-mute);
}
.crumbs a:hover { color: var(--brand); }
.crumbs__sep { color: var(--ink-mute); opacity: 0.6; }
.topbar__right {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: 12px;
}
.sys-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--ok-soft); color: #0a5d2e;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
}
.sys-status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 2px rgba(31,157,85,0.20);
  animation: pulse 2s ease-in-out infinite;
}
.sys-status--degraded { background: var(--warn-soft); color: #7a5500; }
.sys-status--degraded .sys-status__dot { background: var(--warn); box-shadow: 0 0 0 2px rgba(184,131,0,0.25); }
.hello { color: var(--ink-soft); }
.hello b { color: var(--ink); font-weight: 600; letter-spacing: 0.02em; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(31,157,85,0.20); }
  50%      { box-shadow: 0 0 0 6px rgba(31,157,85,0.00); }
}

.page {
  padding: var(--s-5) var(--s-6);
}
.page__inner { max-width: 1480px; margin: 0 auto; }

/* ============================================================
 * Dashboard grid
 * ============================================================ */
.dash { display: flex; flex-direction: column; gap: var(--s-3); }
.dash__row {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--s-3);
}
.dash__col--1  { grid-column: span 1; }
.dash__col--2  { grid-column: span 2; }
.dash__col--3  { grid-column: span 3; }
.dash__col--4  { grid-column: span 4; }
.dash__col--5  { grid-column: span 5; }
.dash__col--6  { grid-column: span 6; }
.dash__col--7  { grid-column: span 7; }
.dash__col--8  { grid-column: span 8; }
.dash__col--9  { grid-column: span 9; }
.dash__col--10 { grid-column: span 10; }
.dash__col--11 { grid-column: span 11; }
.dash__col--12 { grid-column: span 12; }
@media (max-width: 1024px) {
  .dash__row { grid-template-columns: repeat(6, 1fr); }
  .dash__col--4, .dash__col--3, .dash__col--2 { grid-column: span 3; }
  .dash__col--8, .dash__col--6, .dash__col--7 { grid-column: span 6; }
}

/* ============================================================
 * Widgets
 * ============================================================ */
.widget {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column;
  min-height: 110px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.widget:hover { border-color: var(--line-strong); }
.widget__title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-mute);
  margin-bottom: var(--s-2);
  font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}

/* Value tile */
.widget--tile { justify-content: space-between; }
.tile__value { display: flex; align-items: baseline; gap: 8px; }
.tile__number {
  font-size: 34px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
  line-height: 1.05;
}
.tile__unit {
  color: var(--ink-soft); font-size: 13px;
  font-weight: 500;
}
.tile__ts {
  font-size: 10px; color: var(--ink-mute); margin-top: 6px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 5px;
}
.tile__ts::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok); display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}
.tile__value--stale .tile__number { color: var(--gray); }
.tile__value--stale + .tile__ts::before { background: var(--gray); animation: none; }

/* Gauge */
.widget--gauge { align-items: center; padding-bottom: var(--s-2); }
.gauge-host { width: 100%; display: flex; flex-direction: column; align-items: center; }
.gauge__svg { width: 78%; max-width: 200px; height: auto; }
.gauge__track {
  fill: none; stroke: var(--line-soft); stroke-width: 10;
  stroke-linecap: round; pathLength: 100;
}
.gauge__fill {
  fill: none; stroke: var(--ok); stroke-width: 10;
  stroke-linecap: round; pathLength: 100;
  transition: stroke-dasharray 0.4s ease, stroke 0.2s;
}
.gauge--amber   .gauge__fill { stroke: var(--warn); }
.gauge--red     .gauge__fill { stroke: var(--crit); }
.gauge--unknown .gauge__fill { stroke: var(--gray); }
.gauge__value { display: flex; align-items: baseline; gap: 4px; margin-top: 4px; }
.gauge__number {
  font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.gauge__unit { color: var(--ink-soft); font-size: 12px; }
.gauge__ts { font-size: 10px; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.gauge--stale .gauge__number { color: var(--gray); }

/* Status lamp */
.widget--lamp { justify-content: center; }
.lamp { display: flex; align-items: center; gap: var(--s-3); }
.lamp__dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
  flex-shrink: 0;
}
.lamp--green .lamp__dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(31,157,85,0.18), 0 0 14px rgba(31,157,85,0.40);
}
.lamp--amber .lamp__dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(184,131,0,0.18), 0 0 14px rgba(184,131,0,0.40);
}
.lamp--red .lamp__dot {
  background: var(--crit);
  box-shadow: 0 0 0 3px rgba(193,39,45,0.18), 0 0 14px rgba(193,39,45,0.45);
}
.lamp__value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lamp__ts { font-size: 10px; color: var(--ink-mute); }
.lamp--stale .lamp__dot { background: var(--gray); box-shadow: 0 0 0 3px rgba(0,0,0,0.04); }
.lamp--inline { display: inline-flex; align-items: center; gap: 6px; }
.lamp--inline .lamp__dot { width: 9px; height: 9px; box-shadow: 0 0 0 2px rgba(0,0,0,0.04); }
.lamp--inline.lamp--green .lamp__dot { box-shadow: 0 0 0 2px rgba(31,157,85,0.20); }
.lamp__label { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; }

/* Data table widget */
.dtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.dtable th {
  text-align: left; color: var(--ink-mute);
  font-weight: 600; padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase; font-size: 9px; letter-spacing: 0.08em;
}
.dtable td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.dtable tr:last-child td { border-bottom: 0; }
.dtable__num { text-align: right; }
.dtable__row--stale { color: var(--gray); }

/* Alarm count badge */
.widget--alarm-badge { text-align: center; justify-content: center; }
.alarm-badge__num {
  font-size: 42px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ok);
}
.alarm-badge__breakdown {
  list-style: none; padding: 0; margin: var(--s-2) 0 0;
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
}
.sev {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--line-soft);
  color: var(--ink-soft);
  font-weight: 600;
}
.sev--critical { color: var(--crit);   background: var(--crit-soft); }
.sev--major    { color: #9b5808;       background: var(--warn-soft); }
.alarm-badge__note { font-size: 10px; color: var(--ink-mute); margin-top: 6px; font-style: italic; }

/* Line chart */
.widget--chart { padding-bottom: 6px; }
.chartjs { width: 100%; max-height: 240px; }

/* Error widget */
.widget--error { border-left: 3px solid var(--crit); }
.widget-error strong { color: var(--crit); margin-right: 6px; }
.widget-error span { color: var(--ink-soft); font-size: 12px; }

/* Empty state inside widget */
.empty { text-align: center; padding: 40px 16px; color: var(--ink-mute); }

/* ============================================================
 * Page-head: title + summary stats + actions
 * ============================================================ */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  color: var(--ink-soft);
  font-size: 13px;
}
.page-head strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pill--green { background: var(--ok-soft);   color: #0a5d2e; }
.pill--gray  { background: var(--line-soft); color: var(--ink-soft); }
.pill--amber { background: var(--warn-soft); color: #7a5500; }
.pill--red   { background: var(--crit-soft); color: var(--crit); }

/* ============================================================
 * Tables (rtable)
 * ============================================================ */
.rtable {
  width: 100%; border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.rtable th, .rtable td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
.rtable th {
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line);
}
.rtable tbody tr {
  transition: background 0.08s;
}
.rtable tbody tr:hover { background: var(--brand-tint); }
.rtable tbody tr:last-child td { border-bottom: 0; }
.rtable td code {
  background: var(--line-soft);
  font-size: 11.5px;
}
.rtable__num  { text-align: right; font-variant-numeric: tabular-nums; }
.rtable__ts   { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 12px; }
.rtable__sev  { width: 70px; }
.rtable--compact th, .rtable--compact td { padding: 5px 10px; font-size: 12px; }
.rtable--zebra tbody tr:nth-child(even) { background: var(--panel-soft); }
.rtable--zebra tbody tr:hover { background: var(--brand-tint); }
.row--muted td { color: var(--ink-mute); }

.link { color: var(--info); }
.link:hover { text-decoration: underline; }

/* ============================================================
 * Buttons
 * ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit; font-weight: 600; font-size: 13px;
  background: var(--panel-soft); color: var(--ink);
  transition: background 0.1s, border-color 0.1s, transform 0.05s, color 0.1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--line-soft); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(13,125,118,0.25); }

.btn--primary {
  background: var(--brand); color: white; border-color: var(--brand);
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--secondary {
  background: white; color: var(--ink); border-color: var(--line-strong);
}
.btn--secondary:hover { background: var(--panel-soft); }
.btn--ghost {
  background: transparent; color: var(--ink-soft); border-color: transparent;
}
.btn--ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn--danger {
  background: var(--crit); color: white; border-color: var(--crit);
}
.btn--danger:hover { filter: brightness(1.06); }

.btn--small { height: 26px; padding: 0 9px; font-size: 11px; }
.btn--large { height: 38px; padding: 0 18px; font-size: 14px; }

/* ============================================================
 * Filter bar
 * ============================================================ */
.filter-bar {
  display: flex; gap: var(--s-2); margin-bottom: var(--s-3);
  align-items: stretch;
}
.filter-bar input[type="text"],
.filter-bar input[type="number"] {
  flex: 1; padding: 0 12px;
  height: 32px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px;
  background: var(--panel);
}
.filter-bar input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13,125,118,0.12); }
.filter-bar--multi { flex-wrap: wrap; align-items: flex-end; }

/* ============================================================
 * Forms (generic + settings)
 * ============================================================ */
.field { display: block; margin-bottom: var(--s-3); }
.field__label {
  display: block;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--ink-soft); margin-bottom: 5px;
  font-weight: 600;
}
.field input, .field select, .field textarea,
.field--inline input, .field--inline select {
  width: 100%;
  padding: 8px 11px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel);
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.field--inline input:focus, .field--inline select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13,125,118,0.12);
}
.field--inline { display: flex; flex-direction: column; gap: 4px; }
.field--inline select[multiple] { min-width: 320px; min-height: 120px; }
.form-error {
  background: var(--crit-soft); color: var(--crit);
  padding: 8px 12px; border-radius: var(--radius-sm);
}

/* ============================================================
 * Cards
 * ============================================================ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-3);
  box-shadow: var(--shadow-1);
}
.card__header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line-soft);
}
.card--narrow  { max-width: 720px; }
.card--summary .gw-detail__imei {
  font-size: 15px; font-weight: 600;
  background: var(--line-soft); padding: 3px 8px; border-radius: 3px;
  font-family: var(--font-mono);
}

/* KV display list */
.kv {
  display: grid; grid-template-columns: 150px 1fr;
  gap: 6px 18px;
  margin: 0; font-size: 13px;
}
.kv dt { color: var(--ink-soft); font-size: 12px; }
.kv dd { margin: 0; }

.code-block {
  background: #1a1f29; color: #d4d8df;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 11.5px; overflow-x: auto;
  font-family: var(--font-mono);
}

/* Messages */
.msg {
  padding: 9px 13px; border-radius: var(--radius-sm); margin-bottom: var(--s-2);
  font-size: 13px; border-left: 3px solid transparent;
}
.msg--success { background: var(--ok-soft);   color: #0a5d2e;     border-color: var(--ok); }
.msg--warning { background: var(--warn-soft); color: #7a5500;     border-color: var(--warn); }
.msg--error   { background: var(--crit-soft); color: var(--crit); border-color: var(--crit); }
.msg--info    { background: var(--info-soft); color: var(--info); border-color: var(--info); }

/* Trend page controls */
.trend-controls {
  display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-end;
  margin-bottom: var(--s-3);
  padding: var(--s-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ============================================================
 * Alarms — severity chips, badges, alarm rows, state pills
 * ============================================================ */
.sev-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sev-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--panel); color: var(--ink-soft);
  border: 1px solid var(--line);
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.sev-chip b {
  font-variant-numeric: tabular-nums;
  background: var(--line-soft); padding: 0 6px; border-radius: 8px;
}
.sev-chip:hover { border-color: var(--brand); color: var(--brand); }
.sev-chip--active { background: var(--brand); color: white; border-color: var(--brand); }
.sev-chip--active b { background: rgba(255,255,255,0.25); color: white; }
.sev-chip--critical { color: var(--sev-critical); border-color: var(--sev-critical); }
.sev-chip--critical.sev-chip--active { background: var(--sev-critical); color: white; }
.sev-chip--major    { color: var(--sev-major); border-color: var(--sev-major); }
.sev-chip--major.sev-chip--active { background: var(--sev-major); color: white; }
.sev-chip--minor    { color: var(--sev-minor); border-color: var(--sev-minor); }
.sev-chip--minor.sev-chip--active { background: var(--sev-minor); color: white; }
.sev-chip--warning  { color: var(--sev-warning); border-color: var(--sev-warning); }
.sev-chip--warning.sev-chip--active { background: var(--sev-warning); color: white; }

.sev-badge {
  display: inline-block;
  padding: 3px 9px; border-radius: 3px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--line-soft); color: var(--ink-soft);
}
.sev-badge--critical { background: var(--sev-critical); color: white; }
.sev-badge--major    { background: var(--sev-major);    color: white; }
.sev-badge--minor    { background: var(--sev-minor);    color: white; }
.sev-badge--warning  { background: var(--sev-warning);  color: white; }

.state-pill {
  display: inline-block;
  padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.state-pill--firing  { background: var(--crit);      color: white; }
.state-pill--pending { background: var(--warn);      color: white; }
.state-pill--acked   { background: var(--line-soft); color: var(--ink-soft); }

.rtable--alarms tbody tr { border-left: 3px solid transparent; }
.alarm-row--critical { border-left-color: var(--sev-critical); }
.alarm-row--major    { border-left-color: var(--sev-major); }
.alarm-row--minor    { border-left-color: var(--sev-minor); }
.alarm-row--warning  { border-left-color: var(--sev-warning); }
.alarm-row--acked    { opacity: 0.75; }
.alarm-row--pending  td { background: rgba(184,131,0,0.04); }

.event-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.event-tag--raised       { background: var(--crit-soft); color: var(--crit); }
.event-tag--cleared      { background: var(--ok-soft);   color: var(--ok); }
.event-tag--acked        { background: var(--info-soft); color: var(--info); }
.event-tag--auto_cleared { background: var(--line-soft); color: var(--ink-soft); }

.inline-ack { display: inline-flex; align-items: center; gap: 6px; position: relative; }
.inline-ack__pop {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px;
  display: flex; gap: 6px; align-items: center;
  z-index: 20;
  box-shadow: var(--shadow-3);
  white-space: nowrap;
}
.inline-ack__pop input {
  width: 200px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 3px;
}

/* ============================================================
 * Empty state cards (full-page)
 * ============================================================ */
.empty-state {
  text-align: center; padding: 40px 16px;
}
.empty-state__lamp { display: inline-flex; padding: 12px; }
.empty-state h3 {
  margin: 10px 0 4px; font-size: 16px; color: var(--ink);
  text-transform: none; letter-spacing: 0;
}

/* ============================================================
 * Device cards (FRONTEND devices index)
 * ============================================================ */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-3);
}
.device-card {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
  color: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.05s;
}
.device-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-3);
}
.device-card:active { transform: translateY(1px); }
.device-card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.device-card__type {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-mute);
  background: var(--line-soft);
  padding: 3px 8px; border-radius: 3px;
}
.device-card--energy_meter .device-card__type { color: #0a7a4a; background: var(--ok-soft); }
.device-card--dg          .device-card__type { color: #8c4316; background: var(--warn-soft); }
.device-card--transformer .device-card__type { color: #214a82; background: var(--info-soft); }
.device-card--compressor  .device-card__type { color: #b34244; background: var(--crit-soft); }
.device-card__title {
  font-size: 15px; font-weight: 600; color: var(--ink);
  margin-bottom: 2px;
}
.device-card__sub {
  font-size: 11px; color: var(--ink-soft);
  margin-bottom: var(--s-3);
  word-break: break-all;
}
.device-card__sub code {
  background: transparent; padding: 0; font-size: 11px;
}
.device-card__foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto;
  padding-top: var(--s-2);
  border-top: 1px solid var(--line-soft);
}
.device-card__count {
  font-size: 11px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.device-card__arrow {
  font-size: 16px; color: var(--brand); font-weight: 600;
}

/* Device dashboard top bar */
.device-detail__bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: var(--s-3);
  font-size: 12px;
}
.device-detail__meta { display: flex; gap: 10px; align-items: center; }
.device-detail__meta code { font-size: 12px; }
.device-detail__actions { display: flex; gap: 6px; }

/* ============================================================
 * Settings form (device/gateway editors)
 * ============================================================ */
.settings-wrap { max-width: 920px; }
.settings-form { display: flex; flex-direction: column; gap: var(--s-3); }

.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.settings-card__header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  padding: 11px 18px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
}
.settings-card__header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-transform: none;
}
.settings-card__hint { font-size: 11px; color: var(--ink-mute); }
.settings-card__hint--link { color: var(--info); }
.settings-card__hint--link:hover { text-decoration: underline; }

.kv-form {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 18px;
  padding: 14px 18px;
  margin: 0;
  font-size: 13px;
}
.kv-form dt {
  color: var(--ink-soft);
  font-size: 12px;
  padding-top: 2px;
}
.kv-form dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.kv-form dd code { font-size: 12.5px; }

.form-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 18px;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
}
.form-row:first-of-type { border-top: 0; }
.form-row__label {
  padding-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.form-row__label--check {
  display: flex; align-items: center; gap: 8px;
  padding-top: 0;
}
.form-row__label--check input { transform: scale(1.1); }
.form-row__input { display: flex; flex-direction: column; gap: 4px; }
.settings-form input[type="text"],
.settings-form input[type="number"],
.settings-form textarea,
.settings-form select {
  width: 100%;
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.settings-form input:focus,
.settings-form textarea:focus,
.settings-form select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13,125,118,0.12);
}
.settings-form textarea { resize: vertical; min-height: 72px; }
.form-row__help { font-size: 11px; color: var(--ink-mute); line-height: 1.45; }
.form-row__error {
  font-size: 11px; color: var(--crit);
  background: var(--crit-soft);
  padding: 4px 8px; border-radius: 3px;
}
.form-row--split { grid-template-columns: 1fr 1fr; }
.form-row--split > div > .form-row__label {
  padding-top: 0; display: block; margin-bottom: 6px;
}

.settings-actions {
  position: sticky; bottom: 0;
  padding: var(--s-3) 0 0;
  display: flex; justify-content: flex-end; gap: 8px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

/* ============================================================
 * Stage 5.7 — Parameter Profile suggestions
 * Device settings: slot-grid · slot-card
 * Map-unmapped:    quickpick chips
 * ============================================================ */

/* slot-grid: 2-column responsive list of canonical params per device-type */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  padding: 12px 14px;
}
.slot-grid__footer {
  padding: 10px 18px;
  font-size: 11px;
  background: var(--panel-soft);
  border-top: 1px solid var(--line-soft);
}
.slot-grid__footer code {
  background: transparent;
  font-size: 10.5px;
  color: var(--ink-mute);
}

.slot-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  background: var(--panel);
  display: flex; flex-direction: column;
  gap: 6px;
  min-height: 70px;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.slot-card--mapped {
  border-left: 3px solid var(--ok);
  background: #f8fcfa;
}
.slot-card--unmapped {
  border-left: 3px solid var(--line);
  border-style: dashed;
  background: var(--panel-soft);
  opacity: 0.92;
}
.slot-card--unmapped:hover {
  border-color: var(--brand);
  opacity: 1;
  box-shadow: var(--shadow-1);
}
.slot-card__head { display: flex; align-items: flex-start; gap: 6px; }
.slot-card__status {
  font-size: 14px; line-height: 1;
  color: var(--ok);
  flex-shrink: 0;
  padding-top: 2px;
}
.slot-card--unmapped .slot-card__status { color: var(--ink-mute); }
.slot-card__title { flex: 1; min-width: 0; }
.slot-card__name {
  font-size: 12.5px; font-weight: 600;
  color: var(--ink);
}
.slot-card__slug {
  display: block;
  font-size: 10px;
  color: var(--ink-mute);
  background: transparent;
  padding: 0;
  margin-top: 1px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.slot-card__body {
  padding-left: 22px;
  font-size: 11.5px;
}
.slot-card__from {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-soft);
}
.slot-card__from code {
  background: var(--ok-soft);
  color: #0a5d2e;
  font-weight: 600;
}
.slot-card__edit {
  margin-left: auto;
  color: var(--ink-mute);
  text-decoration: none;
  font-size: 13px;
  padding: 0 4px;
}
.slot-card__edit:hover { color: var(--brand); }
.slot-card__suggested-key {
  font-size: 10px;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-card__suggested-key code {
  background: transparent;
  padding: 0;
  font-size: 10px;
  color: var(--ink-mute);
}
.slot-card__pick {
  display: inline-block;
  margin-top: 2px;
  padding: 3px 8px;
  background: var(--brand);
  color: white;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
}
.slot-card__pick:hover { background: var(--brand-dark); }

/* Quick-pick chips inside the map-unmapped page */
.quickpick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
}
.quickpick__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.05s;
}
.quickpick__chip:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.quickpick__chip:active { transform: translateY(1px); }
.quickpick__chip--active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.quickpick__chip--active .quickpick__unit { color: rgba(255,255,255,0.85); }
.quickpick__slot {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
}
.quickpick__unit {
  color: var(--ink-mute);
  font-size: 10px;
  padding: 1px 5px;
  background: var(--line-soft);
  border-radius: 3px;
}

/* ============================================================
 * Tag-mapping editor — compact source strip + equation preview +
 * caret toggle (advanced collapsible) + danger zone
 * ============================================================ */
.src-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  font-size: 12px;
}
.src-strip__label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-right: 4px;
}
.src-strip__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink);
}
.src-strip__chip i {
  font-style: normal;
  color: var(--ink-mute);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.src-strip__chip code {
  background: transparent;
  padding: 0;
  font-size: 11px;
}
.src-strip__chip--field {
  background: #fff8d6;
  border-color: #f1d877;
}
.src-strip__chip--field code { color: #6f4d00; font-weight: 600; }
.src-strip__spacer { flex: 1; }
.src-strip__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--ok-soft);
  color: #0a5d2e;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.src-strip__live b { font-variant-numeric: tabular-nums; }
.src-strip__live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px rgba(31,157,85,0.6);
  animation: pulse 2s ease-in-out infinite;
}
.src-strip__live--stale {
  background: var(--line-soft);
  color: var(--ink-mute);
  font-weight: 500;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(1.2); }
}

/* Tag key — non-editable but copyable */
.tag-key-chip {
  display: inline-block;
  padding: 5px 10px;
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--ink);
  user-select: all;
}

/* Equation preview */
.eq-preview {
  margin: 8px 18px 14px;
  padding: 12px 14px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.eq-preview__title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.eq-preview__line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.eq-preview__raw {
  padding: 4px 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-soft);
}
.eq-preview__var {
  padding: 4px 9px;
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info);
  border-radius: 4px;
  font-weight: 600;
}
.eq-preview__op { color: var(--ink-mute); font-weight: 700; }
.eq-preview__result {
  margin-left: auto;
  padding: 4px 12px;
  background: var(--brand);
  color: white;
  border-radius: 4px;
  font-size: 16px;
}
.eq-preview__result b { font-weight: 700; }
.eq-preview__result .muted { color: rgba(255,255,255,0.7); margin-left: 4px; font-size: 12px; }
.eq-preview__note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-mute);
  font-style: italic;
}

/* Caret for collapsible cards */
.settings-card__header--toggle {
  cursor: pointer;
  user-select: none;
}
.settings-card__header--toggle:hover { background: var(--line-soft); }
.caret {
  display: inline-block;
  margin-right: 6px;
  color: var(--ink-mute);
  transition: transform 0.15s ease;
}
.caret--open { transform: rotate(90deg); color: var(--brand); }

/* Danger card */
.settings-card--danger { border-color: var(--crit-soft); }
.settings-card--danger .settings-card__header {
  background: #fff5f5;
  border-bottom-color: var(--crit-soft);
}
.settings-card--danger .settings-card__header .danger {
  color: var(--crit);
}
.danger-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.danger-body p { margin: 0; font-size: 13px; line-height: 1.55; }
.danger-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.danger-form .form-row__label { padding-top: 0; }
.danger-form input[type="text"] {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  width: 140px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.danger-form input[type="text"]:focus {
  border-color: var(--crit);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(193,39,45,0.15);
}
.btn--danger {
  background: var(--crit);
  color: white;
  border: 1px solid var(--crit);
  padding: 7px 14px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
}
.btn--danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn--danger:not(:disabled):hover { background: #a01f24; }

/* ============================================================
 * Build-info pill in topbar — boot · tpl · now
 * Tiny diagnostic so the owner can tell whether a deploy actually
 * shipped new code (tpl changed) vs just bounced the process (boot only).
 * ============================================================ */
.build-pill {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  background: #15202b;
  color: #d4d8df;
  border-radius: 999px;
  padding: 3px 4px;
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-right: var(--s-3);
  user-select: none;
}
.build-pill__seg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  position: relative;
  white-space: nowrap;
}
.build-pill__seg + .build-pill__seg::before {
  content: "·";
  position: absolute;
  left: -1px;
  color: rgba(255,255,255,0.25);
  font-size: 12px;
  top: 50%;
  transform: translateY(-52%);
}
.build-pill__seg i {
  font-style: normal;
  color: #f3b94a;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.build-pill__seg:last-child i { color: #6fcf97; }
.build-pill__seg:first-child i { color: #f3b94a; }
.build-pill__seg:nth-child(2) i { color: #5bb6ff; }

@media (max-width: 1180px) {
  .build-pill { font-size: 10px; }
  .build-pill__seg { padding: 3px 7px; }
}
@media (max-width: 900px) {
  .build-pill__seg:nth-child(-n+2) { display: none; }
}

/* ============================================================
 * Responsive — three tiers
 *   ≤ 1180px : tighten label column + card padding (sidebar still 224px)
 *   ≤  960px : stack labels on top of inputs (sidebar still 224px)
 *   ≤  900px : sidebar collapses to icon-only 64px (last resort)
 * ============================================================ */

/* Tier 1 — most desktops with the platform open in a half-screen window */
@media (max-width: 1180px) {
  .settings-wrap { max-width: 100%; }
  .kv-form,
  .form-row { grid-template-columns: 160px 1fr; gap: 6px 14px; padding: 12px 14px; }
  .settings-card__header { padding: 9px 14px; }
  .settings-card__header { flex-wrap: wrap; }
  .settings-card__hint { flex-basis: 100%; }
  .form-row__label { padding-top: 7px; font-size: 11.5px; }
  .settings-form input[type="text"],
  .settings-form input[type="number"],
  .settings-form textarea,
  .settings-form select { padding: 7px 10px; font-size: 12.5px; }
  .form-row__help { line-height: 1.4; }
}

/* Tier 2 — narrow content area: stack labels above inputs */
@media (max-width: 960px) {
  .kv-form,
  .form-row { grid-template-columns: 1fr; gap: 4px 0; padding: 10px 14px; }
  .form-row__label { padding-top: 0; }
  .form-row--split { grid-template-columns: 1fr 1fr; gap: 10px; }
  .settings-card__header h2 { font-size: 12.5px; }
  .settings-form { gap: var(--s-2); }
  .settings-actions { padding-bottom: var(--s-3); }
}

/* Tier 3 — true narrow viewport: sidebar collapses to icons */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 64px 1fr; }
  .sidebar__brand .brand__name,
  .sidebar__divider,
  .navlink__label { display: none; }
  .navlink { justify-content: center; padding: 10px 0; position: relative; }
  .navlink--sub { padding-left: 0; }
  .nav-badge { position: absolute; top: 4px; right: 6px; }
  .sidebar__footer { padding: 8px 4px; font-size: 9px; }
  .sidebar__footer .logout { display: none; }
  .topbar { padding: 0 var(--s-3); }
  .page { padding: var(--s-3); }
  .form-row--split { grid-template-columns: 1fr; }
}

/* ============================================================
 * Topology page — FDM-style communication tree
 * server → broker → gateways → slaves
 * ============================================================ */

.topo {
  display: flex; flex-direction: column; align-items: center;
  gap: 0;
  padding: var(--s-4) 0;
}

.topo__tier {
  display: flex; gap: var(--s-4); flex-wrap: wrap; justify-content: center;
  width: 100%;
}
.topo__tier--gateways { gap: var(--s-5); align-items: flex-start; }

.topo__node {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s-3) var(--s-4) var(--s-4);
  box-shadow: var(--shadow-2);
  text-align: center;
  min-width: 220px;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.topo__node--server { border-color: #3a4a5c; }
.topo__node--broker { border-color: var(--brand); }
.topo__node--gateway { min-width: 280px; max-width: 360px; text-align: left; align-items: stretch; }
.topo__node--gateway.is-online  { box-shadow: 0 0 0 1px rgba(31,157,85,0.3), var(--shadow-2); }
.topo__node--gateway.is-offline { opacity: 0.85; border-color: var(--line-strong); }

.topo__icon { margin-bottom: 6px; line-height: 0; }
.topo__icon--gw { align-self: center; }

.topo__node-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.topo__node-type {
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 700; color: var(--ink-mute);
}

.topo__title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  margin-bottom: 4px;
  display: block;
}
.topo__title:hover { color: var(--brand); }
.topo__sub {
  font-size: 11px; color: var(--ink-soft);
  margin-bottom: var(--s-2);
  line-height: 1.5;
}
.topo__sub code { font-size: 11px; }
.topo__chips {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 2px;
  justify-content: center;
}
.topo__node--gateway .topo__chips { justify-content: flex-start; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 10px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip--warn { background: var(--warn-soft); color: #7a5500; border-color: transparent; }
.chip__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gray); flex-shrink: 0;
}
.chip__dot--green { background: var(--ok); box-shadow: 0 0 0 2px rgba(31,157,85,0.18); }

/* Vertical connectors between tiers */
.topo__connector {
  width: 2px;
  height: 32px;
  background: linear-gradient(to bottom, var(--brand), var(--line-strong));
  margin: 0 auto;
  position: relative;
}
.topo__connector::after {
  content: ""; position: absolute; left: -3px; bottom: -1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--panel);
}

/* Horizontal bus line above gateway row */
.topo__bus {
  position: relative;
  width: 80%; max-width: 1100px;
  height: 2px;
  background: var(--brand);
  margin: var(--s-3) 0 var(--s-3);
}
.topo__bus::before, .topo__bus::after {
  content: ""; position: absolute; top: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
}
.topo__bus::before { left: -4px; }
.topo__bus::after  { right: -4px; }
.topo__bus-label {
  position: absolute; left: 50%; top: -22px;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}

/* RS485 rail under each gateway */
.topo__rs485 {
  position: relative;
  margin: var(--s-4) -8px var(--s-3);
  height: 2px;
  background: #4f5d6c;
  border-radius: 1px;
}
.topo__rs485::before, .topo__rs485::after {
  content: ""; position: absolute; top: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #4f5d6c;
}
.topo__rs485::before { left: -4px; }
.topo__rs485::after  { right: -4px; }
.topo__rs485-label {
  position: absolute; left: 12px; top: -22px;
  background: var(--panel);
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

/* Slave devices fanning out under a gateway */
.topo__slaves {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.topo__slave {
  display: flex; flex-direction: column; align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
  color: inherit;
  transition: border-color 0.1s, transform 0.05s, background 0.1s;
}
.topo__slave:hover { border-color: var(--brand); background: var(--brand-tint); }
.topo__slave:active { transform: translateY(1px); }
.topo__slave--energy_meter { border-top: 3px solid var(--ok); }
.topo__slave--dg           { border-top: 3px solid var(--warn); }
.topo__slave--transformer  { border-top: 3px solid var(--info); }
.topo__slave--compressor   { border-top: 3px solid var(--crit); }
.topo__slave--temp         { border-top: 3px solid #b34244; }
.topo__slave--flow         { border-top: 3px solid #2a8b8b; }
.topo__slave--generic      { border-top: 3px solid var(--gray); }

.topo__slave-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  margin-bottom: 4px;
  font-size: 9px;
}
.topo__slave-sid {
  font-weight: 700; letter-spacing: 0.06em; color: var(--ink-soft);
}
.topo__slave-icon { margin-bottom: 4px; line-height: 0; }
.topo__slave-title {
  font-size: 11px; font-weight: 600; color: var(--ink);
  margin-bottom: 2px;
  line-height: 1.2;
}
.topo__slave-sub {
  font-size: 9px; color: var(--ink-mute);
  line-height: 1.3;
}

/* Bullet list inside a settings-card */
.settings-list {
  padding: 14px 18px 14px 38px;
  margin: 0;
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.6;
}
.settings-list li { margin: 2px 0; }
.settings-list code { font-size: 11.5px; }
.settings-list em { color: var(--brand); font-style: normal; font-weight: 600; }

/* Compact row actions (edit/toggle/delete buttons in tables) */
.rtable__actions {
  white-space: nowrap;
  text-align: right;
}
.rtable__actions form,
.rtable__actions .btn {
  vertical-align: middle;
  margin-left: 2px;
}

/* ============================================================================
 * Stage 9 — Tenancy-specific styles + global compact pass
 * (appended to wiman.css after Stage 5.7)
 *
 * COMPACT PASS rationale:
 *   - Settings forms had too much vertical whitespace (40-50% wasted)
 *   - Inputs stretched edge-to-edge on wide screens — hard to scan
 *   - Section headers + cards had heavy padding
 * Tightening rules below apply to ALL settings pages (tenancy + Stage 5.6),
 * so device_settings.html / gateway_settings.html benefit automatically.
 * ========================================================================== */


/* ---------- Compact settings cards (global override) -------------------- */

.settings-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: var(--s-3, 12px) var(--s-2, 8px);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-3, 12px);
}

.settings-card {
  background: #fff;
  border: 1px solid var(--border, #e6e9ec);
  border-radius: var(--radius, 8px);
  box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,.04));
  padding: var(--s-2, 8px) var(--s-4, 16px) var(--s-3, 12px);
}

.settings-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3, 12px);
  padding: var(--s-2, 8px) 0 var(--s-2, 8px);
  margin: 0 0 var(--s-2, 8px);
  border-bottom: 1px solid var(--border-soft, #f0f2f4);
}

.settings-card__header h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .045em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text, #1d2226);
}

.settings-card__hint {
  font-size: 11.5px;
  color: var(--muted, #7a8086);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- Compact form rows ------------------------------------------- */

.form-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--s-2, 8px) var(--s-3, 12px);
  align-items: start;
  padding: var(--s-1, 4px) 0;
  margin: 0;
}

.form-row + .form-row {
  border-top: none;        /* no internal dividers — too noisy */
  padding-top: var(--s-2, 8px);
}

.form-row__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1d2226);
  padding-top: 6px;                /* aligns label with input baseline */
  margin: 0;
  line-height: 1.4;
}

.form-row__label--check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-top: 0;
  font-weight: 500;
  font-size: 13px;
}

.form-row__label--check input[type="checkbox"] {
  margin: 0;
}

.form-row__input {
  min-width: 0;
}

.form-row__input .form-control,
.form-row__input .form-select,
.form-row__input input[type="text"],
.form-row__input input[type="email"],
.form-row__input input[type="number"],
.form-row__input input[type="date"],
.form-row__input input[type="password"],
.form-row__input select,
.form-row__input textarea {
  max-width: 480px;
  width: 100%;
  padding: 6px 10px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid var(--border, #d5d9dd);
  border-radius: var(--radius-sm, 4px);
  background: #fff;
  color: var(--text, #1d2226);
  transition: border-color .12s ease, box-shadow .12s ease;
}

.form-row__input input:focus,
.form-row__input select:focus,
.form-row__input textarea:focus {
  outline: none;
  border-color: var(--saga-darkest, #347f8c);
  box-shadow: 0 0 0 3px rgba(52, 127, 140, .12);
}

.form-row__input textarea {
  max-width: 600px;
  resize: vertical;
  min-height: 60px;
}

.form-row__help {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted, #7a8086);
  line-height: 1.5;
  max-width: 600px;
}

.form-row__error {
  margin-top: 3px;
  font-size: 12px;
  color: #b51a1a;
  font-weight: 500;
}

/* ---------- Compact split row (2-col side-by-side) ---------------------- */

.form-row--split {
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2, 8px) var(--s-4, 16px);
}

.form-row--split > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row--split .form-row__label {
  padding-top: 0;
}

.form-row--split .form-control,
.form-row--split input,
.form-row--split select,
.form-row--split textarea {
  max-width: none;     /* let split inputs fill their half */
}

/* ---------- Three-up rows (e.g. SMS / Email / Monthly checkboxes) ------- */

.form-row--triple {
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--s-2, 8px) var(--s-3, 12px);
}

/* ---------- Field placeholders look softer ------------------------------ */

.form-row__input ::placeholder {
  color: #adb2b8;
  font-size: 13px;
}

/* ---------- Settings actions bar (sticky bottom) ------------------------ */

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2, 8px);
  padding: var(--s-3, 12px) var(--s-4, 16px);
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(245,247,249,0) 0%, rgba(245,247,249,1) 35%);
  margin: var(--s-2, 8px) calc(-1 * var(--s-2, 8px)) 0;
}

/* ---------- KV form (read-only field pairs) ----------------------------- */

.kv-form {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 4px var(--s-3, 12px);
  margin: 0;
  padding: var(--s-1, 4px) 0;
}

.kv-form dt {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted, #7a8086);
  padding-top: 2px;
  line-height: 1.5;
}

.kv-form dd {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text, #1d2226);
}


/* ---------- Responsive collapse ----------------------------------------- */

@media (max-width: 720px) {
  .form-row,
  .kv-form {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .form-row__label,
  .kv-form dt {
    padding-top: 0;
    font-weight: 600;
  }
  .form-row--split,
  .form-row--triple {
    grid-template-columns: 1fr;
  }
}


/* ============================================================================
 * TENANCY-specific bits (home tiles + state pills + help section)
 * ========================================================================== */

/* ---------- Tenancy home tiles ----------------------------------------- */

.tenancy-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3, 12px);
  margin: var(--s-3, 12px) 0 var(--s-4, 16px);
  max-width: 920px;
}

.tenancy-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-3, 12px) var(--s-2, 8px);
  background: #fff;
  border: 1px solid var(--border, #e6e9ec);
  border-radius: var(--radius, 8px);
  box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,.04));
  color: inherit;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.tenancy-tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2, 0 3px 10px rgba(0,0,0,.08));
  border-color: var(--saga-mint, #3eb6a1);
}

.tenancy-tile__icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 4px;
  opacity: .85;
}

.tenancy-tile__count {
  font-size: 26px;
  font-weight: 600;
  color: var(--saga-darkest, #347f8c);
  line-height: 1.1;
}

.tenancy-tile__label {
  margin-top: 4px;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text, #1d2226);
}

.tenancy-tile__hint {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted, #7a8086);
}

/* ---------- Help section + page intro ---------------------------------- */

.tenancy-help {
  margin: var(--s-4, 16px) 0;
  padding: var(--s-3, 12px) var(--s-4, 16px);
  background: #fff;
  border: 1px solid var(--border, #e6e9ec);
  border-radius: var(--radius, 8px);
  box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,.04));
  max-width: 920px;
}

.tenancy-help h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted, #7a8086);
  margin: 0 0 6px;
}

.tenancy-help h2:not(:first-child) {
  margin-top: var(--s-3, 12px);
}

.topology-tree {
  margin: 0;
  padding: 10px 12px;
  background: var(--saga-pale, #f5fbf9);
  border: 1px solid var(--saga-mint-2, #c8eae3);
  border-radius: var(--radius-sm, 4px);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  color: var(--text, #1d2226);
}

.workflow {
  margin: 0;
  padding-left: 22px;
  line-height: 1.5;
  font-size: 13px;
}

.workflow li {
  margin: 2px 0;
}

.workflow strong {
  color: var(--saga-darkest, #347f8c);
}

.page-intro {
  margin: 4px 0 var(--s-3, 12px);
  max-width: 720px;
  line-height: 1.5;
}

.page-intro .muted {
  color: var(--muted, #7a8086);
  font-size: 13px;
}

/* ---------- State pill variants used by tenancy lists ------------------ */

.state-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
}

.state-pill--ok     { background: #e6f6ef; color: #0a7c3e; }
.state-pill--info   { background: #e6f0fa; color: #1959a8; }
.state-pill--brand  { background: var(--saga-pale, #ddf3ee); color: var(--saga-darkest, #347f8c); }
.state-pill--muted  { background: #eef0f2; color: #6b7178; }
.state-pill--danger { background: #fdecea; color: #b51a1a; }

/* ---------- Sidebar sub-divider ---------------------------------------- */

.sidebar__divider--sub {
  margin-top: var(--s-2, 8px);
  opacity: .55;
  font-size: 10px;
  letter-spacing: .12em;
}

/* ---------- Mobile tweaks ---------------------------------------------- */

@media (max-width: 720px) {
  .tenancy-tiles {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .tenancy-tiles {
    grid-template-columns: 1fr;
  }
}
/* ============================================================================
 * Gateway tabbed dashboard — single page per gateway, slaves as tabs.
 * Matches the AKS Cold Storage layout (Location tabs + green/yellow cards).
 * Appended to wiman.css after the Stage 9 tenancy block.
 * ========================================================================== */

.gw-dash {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--s-2, 8px);
}

/* ---------- Status strip ----------------------------------------------- */

.gw-dash__strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3, 12px);
  padding: var(--s-2, 8px) var(--s-3, 12px);
  margin: var(--s-2, 8px) 0 var(--s-3, 12px);
  background: #fff;
  border: 1px solid var(--border, #e6e9ec);
  border-radius: var(--radius, 8px);
  font-size: 12.5px;
}

.gw-dash__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3f5f7;
  font-weight: 600;
  letter-spacing: .04em;
  font-size: 11.5px;
}

.gw-dash__lamp {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.gw-dash__lamp--online   { background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.18); }
.gw-dash__lamp--offline  { background: #e74c3c; box-shadow: 0 0 0 3px rgba(231,76,60,.18); }
.gw-dash__lamp--unknown  { background: #95a5a6; box-shadow: 0 0 0 3px rgba(149,165,166,.18); }

.gw-dash__meta {
  font-size: 12.5px;
  color: var(--text, #1d2226);
}

/* ---------- Slave tabs (the "Location 1 | 2 | 3 …" row) ---------------- */

.slave-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 2px solid var(--border, #e6e9ec);
  margin: 0 0 var(--s-3, 12px);
  background: #fff;
  border-top-left-radius: var(--radius, 8px);
  border-top-right-radius: var(--radius, 8px);
  overflow-x: auto;
}

.slave-tab {
  background: none;
  border: 0;
  padding: var(--s-3, 12px) var(--s-4, 16px);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted, #7a8086);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;            /* overlap the parent's border-bottom */
  transition: color .12s ease, border-color .12s ease, background .12s ease;
  white-space: nowrap;
}

.slave-tab:hover {
  color: var(--text, #1d2226);
  background: rgba(52, 127, 140, 0.05);
}

.slave-tab--active {
  color: var(--saga-darkest, #347f8c);
  border-bottom-color: var(--saga-darkest, #347f8c);
}

/* ---------- Slave panel (only active is visible) ----------------------- */

.slave-panel {
  display: none;
  animation: fadeIn .12s ease-in;
}
.slave-panel--active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slave-panel__footer {
  margin-top: var(--s-3, 12px);
  padding-top: var(--s-2, 8px);
  border-top: 1px dashed var(--border, #e6e9ec);
}

/* ---------- Cards inside a panel (Temperature + Humidity style) -------- */

.storage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s-4, 16px);
  margin-top: var(--s-2, 8px);
}

.storage-card {
  background: #fff;
  border: 1px solid var(--border, #e6e9ec);
  border-radius: var(--radius, 8px);
  overflow: hidden;
  box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,.05));
  transition: transform .12s ease, box-shadow .12s ease;
}

.storage-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2, 0 4px 12px rgba(0,0,0,.08));
}

.storage-card__head {
  padding: 14px 18px;
  font-weight: 600;
  letter-spacing: .04em;
  font-size: 14px;
  text-transform: uppercase;
  color: #fff;
  text-align: center;
  background: var(--saga-darkest, #347f8c);
}

/* Card colors by parameter kind (kind set server-side) */
.storage-card--temperature .storage-card__head { background: #43a047; }   /* green */
.storage-card--humidity    .storage-card__head { background: #c0ca33; }   /* lime/yellow */
.storage-card--pressure    .storage-card__head { background: #1976d2; }   /* blue */
.storage-card--flow        .storage-card__head { background: #00897b; }   /* teal */
.storage-card--voltage     .storage-card__head { background: #ef6c00; }   /* orange */
.storage-card--current     .storage-card__head { background: #ad1457; }   /* magenta */
.storage-card--power       .storage-card__head { background: #5e35b1; }   /* purple */
.storage-card--generic     .storage-card__head { background: var(--saga-darkest, #347f8c); }

.storage-card__body {
  padding: 28px 18px 18px;
  text-align: center;
  background: #fff;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Override the default tile__value layout inside our storage cards
   so the number is BIG and the unit subtle, matching the screenshot. */
.storage-card__body .tile__value {
  font-size: 38px;
  font-weight: 700;
  color: var(--text, #1d2226);
  line-height: 1.1;
  letter-spacing: -.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.storage-card__body .tile__number {
  font-variant-numeric: tabular-nums;
}

.storage-card__body .tile__unit {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted, #7a8086);
  text-transform: lowercase;
}

.storage-card__body .tile__value--stale {
  color: var(--muted, #95a5a6);
  opacity: .55;
}

.storage-card__body .tile__ts {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted, #95a5a6);
  letter-spacing: .04em;
}

/* ---------- Empty state ------------------------------------------------ */

.empty-state {
  padding: var(--s-5, 24px);
  text-align: center;
  background: #fff;
  border: 1px dashed var(--border, #d5d9dd);
  border-radius: var(--radius, 8px);
  color: var(--muted, #7a8086);
  margin: var(--s-3, 12px) 0;
}

/* ---------- Mobile ----------------------------------------------------- */

@media (max-width: 720px) {
  .storage-cards {
    grid-template-columns: 1fr;
  }
  .slave-tab {
    padding: var(--s-2, 8px) var(--s-3, 12px);
    font-size: 11.5px;
  }
  .gw-dash__strip {
    gap: var(--s-2, 8px);
    font-size: 11.5px;
  }
}
