*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #18181f;
  --surface3: #212130;
  --surface4: #2a2a3a;
  --surface5: #333348;
  --accent: #3b82f6;
  --accent-dim: rgba(59,130,246,0.15);
  --accent-glow: rgba(59,130,246,0.28);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.14);
  --amber: #f59e0b;
  --amber-dim: rgba(245,158,11,0.14);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.14);
  --text: #eeeef5;
  --text-muted: #8080a8;
  --text-dim: #3e3e5c;
  --border: rgba(255,255,255,0.055);
  --border-mid: rgba(255,255,255,0.10);
  --border-soft: rgba(255,255,255,0.04);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --group-color: #6b7280; /* default — overridden per group class */
}

/* ── Per-group accent colors ── */
.grp-weather  { --group-color: #38bdf8; }
.grp-energy   { --group-color: #f59e0b; }
.grp-climate  { --group-color: #f97316; }
.grp-lighting { --group-color: #fbbf24; }
.grp-airq     { --group-color: #2dd4bf; }
.grp-security { --group-color: #ef4444; }
.grp-water    { --group-color: #60a5fa; }
.grp-garden   { --group-color: #4ade80; }
.grp-media    { --group-color: #a78bfa; }
.grp-persons  { --group-color: #fb923c; }
.grp-system   { --group-color: #6b7280; }
.grp-other    { --group-color: #6b7280; }
.grp-forbruk      { --group-color: #fb923c; }
.grp-automations  { --group-color: #a78bfa; }

html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface4); }

/* ── TOPBAR ── */
.topbar {
  position: sticky; top: 0; z-index: 100; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: rgba(10,10,15,0.90);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.topbar-logo {
  font-size: 1.25rem; font-weight: 900; letter-spacing: -0.6px;
  background: linear-gradient(130deg, #fff 0%, #c8c8e8 40%, #3b82f6 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  text-decoration: none; user-select: none;
}
.topbar-meta {
  display: flex; align-items: center; gap: 10px; font-size: 0.73rem; color: var(--text-muted);
  font-weight: 500;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 2px var(--green-dim); flex-shrink: 0;
}
.status-dot.stale { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }

/* ── DASHBOARD WRAPPER ── */
.dashboard {
  max-width: 1600px; margin: 0 auto;
  padding: 14px 16px 64px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ── ALWAYS-VISIBLE WEATHER STRIP ── */
.weather-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(14,20,40,0.95) 0%, rgba(10,16,32,0.90) 100%);
  border: 1px solid rgba(56,189,248,0.18);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}
.weather-strip-emoji {
  font-size: 1.6rem; line-height: 1; flex-shrink: 0;
}
.weather-strip-temp {
  font-size: 1.55rem; font-weight: 900; letter-spacing: -1px; line-height: 1;
  color: var(--text); flex-shrink: 0;
}
.weather-strip-unit {
  font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-left: 2px;
}
.weather-strip-detail {
  font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.weather-strip-condition {
  margin-left: auto;
  font-size: 0.8rem; font-weight: 700; color: rgba(56,189,248,0.85);
  text-transform: uppercase; letter-spacing: 0.6px;
}

/* ── SUMMARY BAR ── */
.summary-bar {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 6px;
}
.summary-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.76rem; font-weight: 700; padding: 5px 12px;
  border-radius: 100px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); white-space: nowrap;
}
.summary-chip .chip-value { color: var(--text); }
.summary-chip.alert { border-color: rgba(239,68,68,0.35); color: var(--red); }

/* ── WEATHER HERO ── */
.weather-hero {
  background: linear-gradient(140deg, #0d1828 0%, #0a1020 100%);
  border: 1px solid rgba(56,189,248,0.20);
  border-radius: var(--radius-lg); padding: 22px 26px;
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  position: relative; overflow: hidden;
}
.weather-hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 80% 50%, rgba(56,189,248,0.06) 0%, transparent 60%);
  pointer-events: none;
}
.weather-temp { font-size: 3.2rem; font-weight: 900; letter-spacing: -2px; line-height: 1; }
.weather-temp .unit { font-size: 1.2rem; font-weight: 600; color: var(--text-muted); }
.weather-condition { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; margin: 6px 0; }
.weather-details { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.weather-detail { font-size: 0.78rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.weather-detail strong { color: var(--text); font-weight: 700; }
.weather-icon { font-size: 3.8rem; line-height: 1; filter: drop-shadow(0 0 20px rgba(56,189,248,0.25)); }

/* ── GROUP SECTION ── */
.section { border-radius: var(--radius-lg); overflow: hidden; }

.section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 6px 8px; cursor: pointer; user-select: none;
  border-radius: var(--radius-sm); transition: background 0.15s ease;
}
.section-header:hover { background: var(--surface2); }
.section-icon { font-size: 1rem; width: 26px; text-align: center; flex-shrink: 0; }
.section-title { font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); flex: 1; }
.section-count { font-size: 0.68rem; font-weight: 700; color: var(--text-dim); padding: 1px 7px; background: var(--surface3); border-radius: 100px; }
.section-chevron { color: var(--text-dim); font-size: 0.7rem; transition: transform 0.2s ease; }
.section-chevron.open { transform: rotate(90deg); }

/* ── DEVICE GRID ── */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 4px 0 8px;
}
.device-grid.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.device-grid.full { grid-template-columns: 1fr; }

/* ── DEVICE CARD ── */
.device-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.14s ease, box-shadow 0.18s ease;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
}
.device-card:hover {
  border-color: var(--border-mid);
  border-left-color: var(--border-mid);
  background: var(--surface3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
.device-card.unavailable { opacity: 0.35; pointer-events: none; }
.device-card.active { border-left-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim) inset; }
.device-card.on { border-left-color: var(--amber); box-shadow: 0 0 0 1px rgba(245,158,11,0.12) inset; }
.device-card.alert { border-left-color: var(--red); box-shadow: 0 0 0 1px rgba(239,68,68,0.14) inset; }

/* Device header row */
.device-header {
  display: flex; align-items: center; gap: 8px;
}
.device-card-icon { font-size: 1.1rem; flex-shrink: 0; }
.device-name {
  font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.device-status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--green); box-shadow: 0 0 0 2px var(--green-dim);
}
.device-status-dot.off { background: var(--text-dim); box-shadow: none; }
.device-status-dot.warn { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }

/* Essential metrics row */
.device-metrics {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end;
}
.metric { display: flex; flex-direction: column; gap: 1px; }
.metric-value {
  font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1;
  color: var(--text);
}
.metric-value .decimal { color: #b8b8d8; font-size: 0.82em; font-weight: 700; }
.metric-value.small { font-size: 1rem; }
.metric-value .unit { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.metric-label { font-size: 0.65rem; color: var(--text-dim); font-weight: 600; }

/* State badge */
.state-badge {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.3px;
  padding: 3px 9px; border-radius: 100px; display: inline-block;
}
.state-badge.on { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,0.25); }
.state-badge.off { background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border); }
.state-badge.heat { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,0.25); }
.state-badge.cool { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-glow); }
.state-badge.alert { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.state-badge.ok { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }

/* ── LIGHT CARD: CARD-LEVEL TOGGLE + DIMMER ── */

/* Light cards are slightly taller to fit the slider */
.device-card.light-card { padding-bottom: 12px; }

/* Toggle pill in the card header — compact version */
.card-toggle {
  flex-shrink: 0;
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--surface4); border: 1px solid var(--border-mid);
  position: relative; cursor: pointer;
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}
.card-toggle.is-on {
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 10px rgba(245,158,11,0.35);
}
.card-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.card-toggle.is-on .card-toggle-knob { transform: translateX(18px); }

/* Dimmer row below the header */
.card-dim-row {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0;
}
.dim-label {
  font-size: 0.68rem; font-weight: 700; color: var(--text-dim);
  width: 30px; text-align: right; flex-shrink: 0;
  transition: color 0.2s;
}
.card-dim-row:has(.dim-slider:not(.dim-off)) .dim-label { color: var(--amber); }

/* Custom range slider */
.dim-slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 4px; border-radius: 2px; outline: none; cursor: pointer;
  background: linear-gradient(
    to right,
    var(--amber) 0%,
    var(--amber) var(--fill, 80%),
    var(--surface4) var(--fill, 80%),
    var(--surface4) 100%
  );
  transition: opacity 0.2s;
}
.dim-slider.dim-off {
  opacity: 0.35;
  background: var(--surface4);
  cursor: default;
}
.dim-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--amber);
  box-shadow: 0 0 6px rgba(245,158,11,0.4);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.dim-slider.dim-off::-webkit-slider-thumb {
  border-color: var(--text-dim);
  box-shadow: none;
  cursor: default;
}
.dim-slider:not(.dim-off)::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 10px rgba(245,158,11,0.6);
}
.dim-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--amber);
  cursor: pointer;
}

/* ── DEVICE DRAWER ── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.60);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; bottom: 0; left: 50%; z-index: 201;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--surface) 0%, #0e0e16 100%);
  border-top: 1px solid var(--border-mid);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  max-height: 82vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 520px; width: 100%;
  box-shadow: 0 -12px 48px rgba(0,0,0,0.5);
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(48px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
/* Drag handle hint */
.drawer-header::before {
  content: '';
  position: absolute;
  top: 10px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px;
  background: var(--surface4);
  border-radius: 2px;
}
.drawer-icon { font-size: 1.5rem; }
.drawer-title { font-size: 1rem; font-weight: 800; flex: 1; }
.drawer-close {
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 50%; width: 32px; height: 32px;
  font-size: 0.75rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.12s; flex-shrink: 0;
}
.drawer-close:hover { background: var(--surface4); color: var(--text); transform: scale(1.08); }

.drawer-body {
  overflow-y: auto; padding: 6px 0 28px;
  flex: 1;
}

.drawer-entity {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s ease;
}
.drawer-entity:last-child { border-bottom: none; }
.drawer-entity:hover { background: var(--surface2); }
.drawer-entity.unavailable { opacity: 0.38; }

.drawer-entity-left { flex: 1; min-width: 0; }
.drawer-entity-name {
  font-size: 0.875rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.drawer-entity-updated { font-size: 0.65rem; color: var(--text-dim); margin-top: 2px; display: block; }

.drawer-entity-right { flex-shrink: 0; text-align: right; }

/* Big numeric value in drawer */
.drawer-big-value {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text); display: inline-flex; align-items: baseline; gap: 2px;
}
.drawer-big-value .decimal { color: #b8b8d8; font-size: 0.84em; font-weight: 700; }
.drawer-unit { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); }

/* ── CLIMATE CONTROL IN DRAWER ── */
.drawer-climate-control {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}

.drawer-measured-temp {
  font-size: 2rem; font-weight: 900; letter-spacing: -1.5px;
  color: var(--text); display: inline-flex; align-items: baseline; gap: 2px;
}

.drawer-temp-control {
  display: flex; align-items: center; gap: 4px;
}
.temp-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface3); border: 1px solid var(--border-mid);
  color: var(--text); font-size: 1.2rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.14s, transform 0.1s, box-shadow 0.14s;
  user-select: none; line-height: 1;
}
.temp-btn:hover:not(:disabled) {
  background: var(--surface4); transform: scale(1.10);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.temp-btn:active:not(:disabled) { transform: scale(0.93); }
.temp-btn:disabled { opacity: 0.30; cursor: default; }

.temp-setpoint {
  min-width: 74px; text-align: center;
  font-size: 1.2rem; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text);
}

/* ── LIGHT TOGGLE ── */
.drawer-light {
  display: flex; align-items: center; gap: 10px;
}

/* Pill-shaped on/off toggle switch */
.light-toggle {
  position: relative;
  width: 52px; height: 28px;
  border-radius: 14px;
  border: 1.5px solid var(--border-mid);
  background: var(--surface4);
  cursor: pointer;
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  flex-shrink: 0;
  padding: 0;
  outline: none;
}
.light-toggle:focus-visible {
  box-shadow: 0 0 0 3px rgba(251,191,36,0.35);
}
.light-toggle.is-on {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  border-color: rgba(251,191,36,0.5);
  box-shadow: 0 0 14px rgba(245,158,11,0.35);
}
.light-toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.22s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  pointer-events: none;
}
.light-toggle.is-on .light-toggle-knob {
  transform: translateX(24px);
  background: #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
}

.light-brightness {
  font-size: 0.78rem; font-weight: 700; color: var(--amber);
  letter-spacing: 0.2px;
}

.drawer-entity-value-text { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.drawer-entity-value-text.muted { color: var(--text-dim); }

.drawer-unavail-label {
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-dim); padding: 14px 20px 6px;
}

/* Light brightness bar */
.brightness-bar { width: 100%; height: 2px; border-radius: 1px; background: var(--surface3); margin-top: 6px; overflow: hidden; }
.brightness-fill { height: 100%; border-radius: 1px; background: linear-gradient(90deg, var(--amber) 0%, #fff 100%); transition: width 0.4s ease; }

/* Toggle unavailable */
.unavail-toggle {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 0.68rem; font-weight: 700; color: var(--text-dim);
  padding: 3px 9px; border-radius: 100px; background: var(--surface3); border: 1px solid var(--border);
  transition: all 0.15s; user-select: none; margin-top: 4px; align-self: flex-start;
}
.unavail-toggle:hover { color: var(--text-muted); border-color: var(--border-mid); }

/* Loading skeletons */
.skeleton-row { display: flex; gap: 8px; }
.skeleton {
  border-radius: var(--radius); background: var(--surface2);
  background-image: linear-gradient(90deg, var(--surface2) 0%, var(--surface3) 40%, var(--surface2) 80%);
  background-size: 300% 100%; animation: shimmer 1.6s infinite ease-in-out;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Error boundary */
.blazor-error-boundary { padding: 1rem; color: var(--red); background: var(--red-dim); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius); }

/* ── GROUP OVERVIEW TILES (Level 1) ── */
.group-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  grid-auto-rows: 90px;
  gap: 8px;
}

.group-tile {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--group-color);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.14s ease, box-shadow 0.18s ease;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 0; overflow: hidden;
  position: relative;
}
.group-tile:hover {
  background: var(--surface3);
  border-color: rgba(255,255,255,0.12);
  border-left-color: var(--group-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.24),
              0 0 18px -6px var(--group-color);
}
.group-tile.selected {
  background: var(--surface3);
  border-color: rgba(255,255,255,0.10);
  border-left-color: var(--group-color);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset,
              0 4px 24px rgba(0,0,0,0.3),
              0 0 18px -4px var(--group-color);
}

/* ── Tile slot wrapper (drag + resize) ── */
.tile-slot {
  position: relative;
  display: flex; flex-direction: column;
  user-select: none;
}
.tile-slot > .group-tile { flex: 1; }
.tile-slot.is-dragging { opacity: 0.35; }
.tile-slot.drag-over > .group-tile {
  outline: 2px solid var(--border-mid);
  outline-offset: -2px;
  border-radius: var(--radius);
}

/* Drag grip — appears on hover */
.tile-drag-grip {
  position: absolute; top: 5px; left: 5px;
  font-size: 0.7rem; line-height: 1;
  color: var(--text-muted); cursor: grab;
  opacity: 0; transition: opacity 0.2s ease, transform 0.15s ease;
  z-index: 3; user-select: none; touch-action: none;
}
.tile-slot:hover .tile-drag-grip { opacity: 0.65; }
.tile-drag-grip:hover { opacity: 1 !important; transform: scale(1.15); }
.tile-slot.is-dragging .tile-drag-grip { opacity: 1 !important; cursor: grabbing; }

/* Resize handle — bottom-right corner bracket */
.tile-resize-handle {
  position: absolute; bottom: 5px; right: 5px;
  width: 13px; height: 13px;
  cursor: nwse-resize; z-index: 3;
  opacity: 0; transition: opacity 0.2s ease, transform 0.15s ease;
  touch-action: none;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  border-radius: 0 0 3px 0;
}
.tile-resize-handle::after {
  content: '';
  position: absolute;
  right: 2px; bottom: 2px;
  width: 5px; height: 5px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  border-radius: 0 0 2px 0;
}
.tile-slot:hover .tile-resize-handle { opacity: 0.55; }
.tile-resize-handle:hover { opacity: 1 !important; transform: scale(1.2); }
.tile-slot.is-resizing .tile-resize-handle { opacity: 1 !important; }

/* Empty drop-target slot */
.tile-empty-slot {
  min-height: 90px;
  border: 2px dashed transparent;
  border-radius: var(--radius);
  transition: border-color 0.18s, background 0.18s;
}
.tile-empty-slot.drag-active {
  border-color: var(--border-mid);
  background: var(--surface2);
}
.tile-empty-slot.drag-over {
  border-color: var(--amber);
  background: rgba(245,158,11,0.08);
  box-shadow: inset 0 0 0 1px rgba(245,158,11,0.3);
}

/* ── RESIZE FEEDBACK ── */
.tile-slot.is-resizing { z-index: 5; }
.tile-slot.is-resizing > .group-tile {
  outline: 1.5px solid rgba(59,130,246,0.35);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px rgba(59,130,246,0.07),
              0 16px 48px rgba(0,0,0,0.5) !important;
}

/* Floating size badge shown during drag */
.resize-badge {
  position: absolute; bottom: 28px; right: 6px;
  background: rgba(6,6,18,0.96);
  border: 1px solid rgba(59,130,246,0.28);
  color: #8fb4ff;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.5px;
  padding: 2px 8px 3px; border-radius: 6px;
  pointer-events: none; z-index: 20;
  box-shadow: 0 2px 10px rgba(0,0,0,0.55);
  white-space: nowrap;
}

/* Snap bounce — plays each time the tile crosses a column/row boundary */
@keyframes snap-pulse {
  0%   { transform: scale(1.025); }
  100% { transform: scale(1); }
}
.tile-slot.snap-pulse {
  animation: snap-pulse 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

.group-tile-top {
  display: flex; align-items: center; gap: 6px;
}
.group-tile-icon { font-size: 1rem; flex-shrink: 0; }
.group-tile-name {
  font-size: 0.72rem; font-weight: 800; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.group-tile.selected .group-tile-name {
  color: var(--text);
}
.group-tile-sub {
  font-size: 0.62rem; color: var(--text-dim); flex-shrink: 0;
}

.group-tile-stat {
  display: flex; align-items: baseline; gap: 3px;
}
.group-tile-stat.has-toggle {
  align-items: center;
  justify-content: space-between;
}

/* Compact toggle variant for tile stat row */
.tile-toggle {
  width: 36px !important; height: 20px !important; border-radius: 10px !important;
  flex-shrink: 0;
}
.tile-toggle .card-toggle-knob {
  width: 14px !important; height: 14px !important;
}
.tile-toggle.is-on .card-toggle-knob { transform: translateX(16px) !important; }
.group-stat-value {
  font-size: 1.5rem; font-weight: 900; letter-spacing: -1px; color: var(--text); line-height: 1;
}
.group-stat-value .decimal { color: #b8b8d8; font-size: 0.82em; font-weight: 800; }
.group-stat-unit {
  font-size: 0.7rem; font-weight: 600; color: var(--text-muted);
}

/* ── DEVICE PANEL (Level 2) ── */
.group-device-panel {
  animation: panelIn 0.2s cubic-bezier(0.34, 1.20, 0.64, 1);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.group-device-panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 2px 8px;
  font-size: 0.8rem; font-weight: 800; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .device-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .device-grid.wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .weather-hero { padding: 16px 18px; }
  .weather-temp { font-size: 2.6rem; }
}

@media (max-width: 600px) {
  .dashboard { padding: 10px 10px 44px; }
  .device-grid { grid-template-columns: repeat(2, 1fr); }
  .device-grid.wide { grid-template-columns: repeat(2, 1fr); }
  .weather-hero { grid-template-columns: 1fr; }
  .weather-icon { display: none; }
  .topbar { padding: 0 14px; }
  .metric-value { font-size: 1.15rem; }
  .weather-strip { gap: 10px; padding: 10px 14px; }
  .weather-strip-temp { font-size: 1.3rem; }
  .group-tiles { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .group-tile { padding: 10px 12px; }
  .group-tiles { grid-auto-rows: 82px; }
  .tile-empty-slot { min-height: 82px; }
  .group-stat-value { font-size: 1.2rem; }
  /* Keep grid items within bounds on narrow screens */
  .tile-slot { grid-column: span 1 !important; }
  .tile-slot[style*="span 2"] { grid-column: span 2 !important; }
  .tile-slot[style*="span 3"] { grid-column: 1 / -1 !important; }
}

@media (max-width: 380px) {
  .device-grid, .device-grid.wide { grid-template-columns: 1fr; }
  .group-tiles { grid-template-columns: repeat(2, 1fr); }
  .weather-strip-condition { display: none; }
}

/* On touch-only devices, always show the handles */
@media (hover: none) {
  .tile-resize-handle { opacity: 0.42; }
  .tile-drag-grip { opacity: 0.42; }
}


.power-row {
  display: grid;
  grid-template-columns: 18px minmax(0,1fr) 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
}
.power-row:last-child { border-bottom: none; }
.power-row:hover { background: var(--surface2); }

.power-row-icon { font-size: 0.68rem; text-align: center; line-height: 1; opacity: 0.7; }
.power-row-name {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.power-bar-track {
  height: 4px; border-radius: 2px;
  background: var(--surface3); overflow: hidden;
}
.power-bar {
  height: 100%; border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.power-bar.bar-high  { background: linear-gradient(90deg, #f97316, #fbbf24); box-shadow: 0 0 8px rgba(249,115,22,0.5); }
.power-bar.bar-mid   { background: linear-gradient(90deg, var(--amber), #fcd34d); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.power-bar.bar-low   { background: var(--amber); }
.power-bar.bar-zero  { background: transparent; }

.power-row-val {
  font-size: 0.8rem; font-weight: 800; color: var(--text-dim);
  min-width: 54px; text-align: right; white-space: nowrap;
}
.power-row-val.val-on { color: var(--amber); }

/* Offline / unavailable row */
.power-row-offline { opacity: 0.35; cursor: default; }
.power-row-offline:hover { background: transparent; }
.power-row-dash {
  grid-column: 3 / 5; font-size: 0.75rem; color: var(--text-dim);
  text-align: right;
}
/* ── AUTOMATIONS PANEL ── */
.automation-loading {
  padding: 20px; color: var(--text-dim); font-size: 0.82rem;
}

/* "Next upcoming" summary block at the top */
.automation-next-block {
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(167,139,250,0.07);
}
.automation-next-label {
  display: block;
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.8px; color: #a78bfa; margin-bottom: 6px;
}
.automation-next-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.automation-next-name {
  font-size: 0.9rem; font-weight: 700; color: var(--text); flex: 1;
}
.automation-next-schedule {
  font-size: 0.72rem; color: #a78bfa; font-weight: 700;
}
.automation-next-time {
  font-size: 0.8rem; font-weight: 800; color: #c4b5fd;
  white-space: nowrap;
}

/* Section header */
.automation-section-label {
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-dim);
  padding: 10px 16px 3px;
}

/* Automation row (list) */
.automation-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center; gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.automation-row:last-child { border-bottom: none; }
/* Highlight the row that is "next" */
.automation-row-is-next { background: rgba(167,139,250,0.06); }
.automation-row-icon { font-size: 0.82rem; opacity: 0.7; }
.automation-row-info {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.automation-row-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 5px;
}
.automation-next-badge {
  font-size: 0.55rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; color: #a78bfa;
  background: rgba(167,139,250,0.15); border-radius: 3px;
  padding: 1px 4px; flex-shrink: 0;
}
.automation-row-schedule {
  font-size: 0.62rem; color: var(--text-dim); font-weight: 600;
}
.automation-row-time {
  font-size: 0.68rem; color: var(--text-dim); font-weight: 600;
  white-space: nowrap; text-align: right;
}

/* Expand / disabled toggle */
.automation-expand-btn {
  display: block; width: 100%;
  padding: 8px 16px; text-align: left;
  background: transparent; border: none; border-top: 1px solid var(--border-soft);
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  cursor: pointer; transition: color 0.12s, background 0.12s;
}
.automation-expand-btn:hover { color: var(--text); background: var(--surface2); }
.automation-disabled-toggle { color: var(--text-dim); }

.power-offline-label {
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-dim);
  padding: 8px 16px 2px;
}

/* Power detail drawer content */
.power-detail-current {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.power-detail-now-label {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted);
}
.power-detail-now-val {
  font-size: 2rem; font-weight: 900; letter-spacing: -1px; color: var(--amber);
}

.power-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 16px 20px 24px;
}
.power-detail-item {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.power-detail-label {
  font-size: 0.65rem; font-weight: 800; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.power-detail-value {
  font-size: 1.15rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px;
}
.power-detail-unit { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }

/* ── AUTH PAGES (login / change-password) ── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 30%, rgba(59,130,246,0.06) 0%, transparent 60%);
}
.auth-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
  display: flex; flex-direction: column; gap: 20px;
}
.auth-logo {
  font-size: 1.6rem; font-weight: 900; letter-spacing: -1px; text-align: center;
  background: linear-gradient(130deg, #fff 0%, #b0b0d0 50%, #3b82f6 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  user-select: none;
}
.auth-subtitle {
  font-size: 0.82rem; color: var(--text-muted); text-align: center; line-height: 1.5;
  margin-top: -8px;
}
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.2px; }
.auth-input {
  background: var(--surface2); border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 10px 14px; font-size: 0.9rem; outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.auth-input:focus { border-color: var(--accent); }
.auth-select { cursor: pointer; }
.auth-btn {
  background: var(--accent); border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 0.9rem; font-weight: 700;
  padding: 11px; cursor: pointer; width: 100%;
  transition: opacity 0.15s, transform 0.12s;
}
.auth-btn:hover:not(:disabled) { opacity: 0.88; }
.auth-btn:active:not(:disabled) { transform: scale(0.98); }
.auth-btn:disabled { opacity: 0.45; cursor: default; }
.auth-btn-sm { width: auto; padding: 9px 20px; }
.auth-error {
  background: var(--red-dim); border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 0.82rem; color: var(--red);
}
.auth-success {
  background: var(--green-dim); border: 1px solid rgba(34,197,94,0.3);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 0.82rem; color: var(--green);
}
.auth-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Topbar extras */
.topbar-link, .topbar-logout {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem; padding: 2px 4px;
  border-radius: 4px; transition: color 0.15s;
  text-decoration: none; display: inline-flex; align-items: center;
}
.topbar-link:hover, .topbar-logout:hover { color: var(--text); }

/* ── ADMIN PAGE ── */
.admin-header { padding: 4px 0 8px; }
.admin-title { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.5px; }
.admin-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.admin-card-title { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.admin-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.admin-form .auth-input { flex: 1; min-width: 160px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.admin-table th { text-align: left; padding: 8px 12px; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); color: var(--text-muted); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface2); }
.admin-row-self td { color: var(--text); }
.admin-delete-btn {
  background: var(--red-dim); border: 1px solid rgba(239,68,68,0.3);
  color: var(--red); border-radius: var(--radius-sm); font-size: 0.72rem; font-weight: 700;
  padding: 4px 10px; cursor: pointer; transition: background 0.15s;
}
.admin-delete-btn:hover { background: rgba(239,68,68,0.25); }
.role-badge { font-size: 0.68rem; font-weight: 800; padding: 2px 8px; border-radius: 100px; }
.role-admin { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-glow); }
.role-user  { background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border); }



/* ══ AGENT: TILES ══ */
/* Level-1 tile grid: key stat + tone + secondary cues. Overrides earlier rules; the
   drag/resize slot machinery (.tile-slot, grips, handles) is untouched. */

/* ── Grid rhythm: one more row of content per tile ── */
.group-tiles { grid-auto-rows: 106px; gap: 10px; }
.tile-empty-slot { min-height: 106px; }
/* Never let nowrap tile content widen the grid past the viewport */
.tile-slot, .group-tile { min-width: 0; }

/* ── Tile shell ── */
.group-tile {
  padding: 11px 13px 10px 14px;
  gap: 3px;
  background: linear-gradient(165deg, var(--surface2) 0%, var(--surface) 100%);
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
/* Soft group-colour wash in the top-right corner */
.group-tile::before {
  content: '';
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(140px 80px at 100% 0%,
              color-mix(in srgb, var(--group-color) 13%, transparent), transparent 72%);
  opacity: 0.75;
  transition: opacity 0.2s ease;
}
.group-tile:hover::before,
.group-tile.selected::before { opacity: 1; }

/* Press affordance + keyboard focus */
.group-tile:active { transform: translateY(0) scale(0.985); transition-duration: 0.08s; }
.group-tile:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

/* Clear selected state: brighter frame, group-coloured underline, chevron rotates to "open below" */
.group-tile.selected {
  background: linear-gradient(165deg, var(--surface3) 0%, var(--surface2) 100%);
  border-color: color-mix(in srgb, var(--group-color) 40%, var(--border-mid));
  border-left-color: var(--group-color);
}
.group-tile.selected::after {
  content: '';
  position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--group-color), transparent);
  border-radius: 2px 2px 0 0;
  opacity: 0.9;
}
/* Chevron is only rendered while selected: points down to the panel that opened below */
.group-tile-chevron {
  flex-shrink: 0;
  width: 14px; height: 14px; line-height: 13px; text-align: center;
  font-size: 0.8rem; font-weight: 800;
  color: var(--group-color);
  transform: rotate(90deg);
  animation: chevron-in 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes chevron-in {
  from { opacity: 0; transform: rotate(0deg) scale(0.6); }
  to   { opacity: 1; transform: rotate(90deg) scale(1); }
}
/* Give the name room back while selected: the neutral count badge is redundant with the open panel */
.group-tile.selected .tile-badge:not(.warn):not(.alert) { display: none; }

/* ── Header row ── */
.group-tile-top { gap: 7px; min-height: 18px; }
.group-tile-icon { font-size: 0.95rem; line-height: 1; }
.group-tile-name { font-size: 0.68rem; letter-spacing: 0.65px; }
.group-tile-badges { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }
.tile-badge {
  font-size: 0.58rem; font-weight: 800; line-height: 1.45; letter-spacing: 0.2px;
  padding: 1px 6px; border-radius: 100px;
  background: var(--surface4); color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.tile-badge.warn  { background: var(--amber-dim); color: var(--amber); }
.tile-badge.alert { background: var(--red-dim);   color: var(--red); }

/* ── Key stat ── */
.group-tile-stat { margin-top: auto; gap: 4px; min-height: 28px; }
.group-stat-value {
  font-size: 1.6rem; letter-spacing: -1.2px; line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.25s ease;
}
.group-stat-value.is-text  { font-size: 1.2rem; letter-spacing: -0.4px; padding-bottom: 2px; }
.group-stat-value.is-empty { color: var(--text-dim); font-weight: 700; }
.group-stat-unit { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.2px; }

/* ── Secondary cues ── */
.group-tile-cues {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; min-height: 14px; overflow: hidden; white-space: nowrap;
}
.tile-cue {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.66rem; font-weight: 600; line-height: 1.2;
  color: var(--text-muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.tile-cue:first-child { flex-shrink: 0; }
/* Text node inside an inline-flex cannot ellipsize; the inner span can */
.tile-cue .cue-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-cue + .tile-cue { position: relative; padding-left: 10px; }
.tile-cue + .tile-cue::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 1px; height: 9px; transform: translateY(-50%);
  background: var(--border-mid);
}
.cue-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-dim);
}
.tile-cue.tone-ok     .cue-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green-dim); }
.tile-cue.tone-warn   .cue-dot { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }
.tile-cue.tone-alert  .cue-dot { background: var(--red);   box-shadow: 0 0 0 2px var(--red-dim); animation: cue-pulse 1.4s ease-in-out infinite; }
.tile-cue.tone-active .cue-dot { background: var(--group-color); box-shadow: 0 0 6px -1px var(--group-color); }
.tile-cue.tone-off    .cue-dot { background: var(--text-dim); }
.tile-cue.tone-warn   { color: var(--amber); }
.tile-cue.tone-alert  { color: var(--red); font-weight: 700; }
.tile-cue.tone-active { color: var(--text); }
.tile-cue.tone-off    { color: var(--text-dim); }
@keyframes cue-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--red-dim); }
  50%      { box-shadow: 0 0 0 5px rgba(239,68,68,0.05); }
}

/* ── Tile-level state tones (set from the key stat) ── */
.group-tile.tone-warn  { border-left-color: var(--amber); }
.group-tile.tone-warn  .group-stat-value { color: var(--amber); }
.group-tile.tone-warn  .group-stat-value .decimal { color: color-mix(in srgb, var(--amber) 70%, var(--text)); }
.group-tile.tone-warn::before {
  background: radial-gradient(140px 80px at 100% 0%, rgba(245,158,11,0.14), transparent 72%);
}

.group-tile.tone-alert { border-left-color: var(--red); border-color: rgba(239,68,68,0.28); }
.group-tile.tone-alert .group-stat-value { color: var(--red); }
.group-tile.tone-alert .group-stat-value .decimal { color: color-mix(in srgb, var(--red) 70%, var(--text)); }
.group-tile.tone-alert::before {
  background: radial-gradient(160px 90px at 100% 0%, rgba(239,68,68,0.20), transparent 72%);
  opacity: 1;
}
.group-tile.tone-alert .group-tile-icon { animation: tile-alert-bob 1.2s ease-in-out infinite; }
@keyframes tile-alert-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1px) scale(1.08); } }

.group-tile.tone-active .group-stat-value { color: var(--group-color); }
.group-tile.tone-active .group-stat-value .decimal { color: color-mix(in srgb, var(--group-color) 70%, var(--text)); }
.group-tile.tone-active .group-tile-icon { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--group-color) 60%, transparent)); }

.group-tile.tone-off { border-left-color: color-mix(in srgb, var(--group-color) 35%, transparent); }
.group-tile.tone-off .group-stat-value { color: var(--text-muted); }
.group-tile.tone-off .group-tile-icon { opacity: 0.55; filter: grayscale(0.5); }
.group-tile.tone-off::before { opacity: 0.35; }
.group-tile.tone-off:hover::before { opacity: 0.6; }

/* Lighting toggle sits on the stat row; keep it clear of the value */
.group-tile-stat.has-toggle { gap: 8px; }
.group-tile-stat.has-toggle .tile-toggle { margin-left: auto; }

/* ── Loading skeleton: shaped like a real tile ── */
.group-tiles-loading { pointer-events: none; }
.skeleton.skeleton-tile {
  background: var(--surface2);
  background-image: none;
  animation: none;
  border: 1px solid var(--border);
  border-left: 3px solid var(--surface4);
  padding: 12px 14px 11px;
  display: flex; flex-direction: column; gap: 7px;
}
.sk-line {
  border-radius: 6px;
  background: var(--surface3);
  background-image: linear-gradient(90deg, var(--surface3) 0%, var(--surface4) 45%, var(--surface3) 85%);
  background-size: 300% 100%;
  animation: shimmer 1.6s infinite ease-in-out;
  animation-delay: var(--d, 0ms);
}
.sk-title { width: 52%; height: 9px; }
.sk-value { width: 38%; height: 24px; margin-top: auto; border-radius: 7px; }
.sk-cue   { width: 68%; height: 8px; opacity: 0.7; }

/* ── Attention strip (SummaryChips) ── */
.summary-bar {
  gap: 6px; padding: 0 0 2px;
  animation: panelIn 0.25s ease;
}
.summary-chip {
  font-size: 0.72rem; font-weight: 700; gap: 6px; padding: 4px 11px 4px 9px;
  border: 1px solid var(--border);
  transition: background 0.18s ease, border-color 0.18s ease;
}
.summary-chip .chip-icon { font-size: 0.78rem; line-height: 1; }
.summary-chip .chip-value { font-weight: 800; }
.summary-chip.ok    { color: var(--green); background: var(--green-dim); border-color: rgba(34,197,94,0.22); }
.summary-chip.ok    .chip-value { color: color-mix(in srgb, var(--green) 60%, var(--text)); }
.summary-chip.warn  { color: var(--amber); background: var(--amber-dim); border-color: rgba(245,158,11,0.30); }
.summary-chip.alert {
  color: var(--red); background: var(--red-dim); border-color: rgba(239,68,68,0.40);
  animation: chip-alert 1.6s ease-in-out infinite;
}
.summary-chip.info  { color: var(--accent); background: var(--accent-dim); border-color: rgba(59,130,246,0.28); }
button.summary-chip.is-link { cursor: pointer; font-family: inherit; line-height: inherit; appearance: none; }
button.summary-chip.is-link:hover { filter: brightness(1.15); border-color: currentColor; }
button.summary-chip.is-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes chip-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.0); }
  50%      { box-shadow: 0 0 0 4px rgba(239,68,68,0.10); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  /* minmax(0,1fr): plain 1fr has an auto minimum and overflows the phone width */
  .group-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 98px; gap: 7px; }
  .tile-empty-slot { min-height: 98px; }
  .group-tile { padding: 9px 10px 8px 12px; }
  .group-stat-value { font-size: 1.3rem; letter-spacing: -0.8px; }
  .group-stat-value.is-text { font-size: 1.05rem; }
  .group-stat-unit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .group-tile-name { font-size: 0.62rem; letter-spacing: 0.4px; }
  .tile-cue { font-size: 0.62rem; }
  .tile-toggle { width: 32px !important; height: 18px !important; }
  .tile-toggle .card-toggle-knob { width: 12px !important; height: 12px !important; }
  .tile-toggle.is-on .card-toggle-knob { transform: translateX(14px) !important; }
  .summary-chip { font-size: 0.68rem; padding: 3px 9px 3px 8px; }
}
/* Phones: two columns so names, key stat and cues stay legible (3 columns gives ~115px tiles) */
@media (max-width: 480px) {
  .group-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .tile-cue + .tile-cue { display: none; }
  .group-tile-badges .tile-badge:not(.warn):not(.alert) { display: none; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .group-tile, .group-tile-chevron, .group-stat-value { transition: none; }
  .tile-cue.tone-alert .cue-dot, .group-tile.tone-alert .group-tile-icon,
  .summary-chip.alert, .sk-line { animation: none; }
}



/* ══ AGENT: PANELS ══ */
/* Forbruk panel, Weather hero and Automations panel. All selectors below are new
   (energy-*, wx-*, auto-*) or override earlier rules; nothing above is edited. */

/* ── FORBRUK: live overview ─────────────────────────────────────────────── */
.energy-overview {
  display: flex; flex-direction: column; gap: 8px;
  padding: 2px 0 10px;
}
.energy-hero {
  display: grid; grid-template-columns: minmax(240px, 1.1fr) minmax(0, 1.6fr);
  gap: 10px 22px; align-items: stretch;
  background: linear-gradient(140deg, #171410 0%, #121016 60%, var(--surface2) 100%);
  border: 1px solid rgba(245,158,11,0.18);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-lg);
  padding: 18px 22px 16px;
  position: relative; overflow: hidden;
}
.energy-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 12% 20%, rgba(245,158,11,0.10) 0%, transparent 55%);
}
.energy-hero-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; }
.energy-eyebrow {
  font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-muted);
}
.energy-hero-value {
  font-size: 3.4rem; font-weight: 900; letter-spacing: -2.5px; line-height: 0.95;
  color: var(--text); font-variant-numeric: proportional-nums;
  display: flex; align-items: baseline; gap: 6px;
}
.energy-hero-unit { font-size: 1.15rem; font-weight: 700; letter-spacing: 0; color: var(--amber); }

/* Load meter: one-hue track with a fixed scale and today's peak marker */
.energy-load { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.energy-load-track {
  position: relative; height: 8px; border-radius: 4px;
  background: var(--surface3); overflow: visible;
}
.energy-load-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
  background: var(--amber);
}
.energy-load-fill.load-none { background: var(--surface4); }
.energy-load-fill.load-low  { background: var(--green); box-shadow: 0 0 10px rgba(34,197,94,0.35); }
.energy-load-fill.load-mid  { background: linear-gradient(90deg, #d97706, var(--amber)); box-shadow: 0 0 10px rgba(245,158,11,0.35); }
.energy-load-fill.load-high { background: linear-gradient(90deg, var(--amber), #f97316); box-shadow: 0 0 12px rgba(249,115,22,0.45); }
.energy-load-fill.load-max  { background: linear-gradient(90deg, #f97316, var(--red)); box-shadow: 0 0 12px rgba(239,68,68,0.45); }
.energy-load-peak {
  position: absolute; top: -3px; width: 2px; height: 14px; border-radius: 1px;
  background: var(--text); opacity: 0.55; transform: translateX(-1px);
}
.energy-load-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 0.68rem; font-weight: 600; color: var(--text-muted);
}
.energy-load-level { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: var(--text); }
.energy-load-level i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); display: inline-block; }
.energy-load-level.load-none i { background: var(--surface5); }
.energy-load-level.load-low  i { background: var(--green); }
.energy-load-level.load-mid  i { background: var(--amber); }
.energy-load-level.load-high i { background: #f97316; }
.energy-load-level.load-max  i { background: var(--red); }
.energy-load-peakval { color: var(--text-muted); }
.energy-load-scale { margin-left: auto; color: var(--text-dim); font-weight: 700; }

/* KPI tiles */
.energy-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 6px; align-content: start; position: relative;
}
.energy-stat {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(255,255,255,0.025); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0;
}
.energy-stat-label {
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.energy-stat-value {
  font-size: 1.3rem; font-weight: 800; letter-spacing: -0.6px; color: var(--text); line-height: 1.1;
  display: flex; align-items: baseline; gap: 3px;
}
.energy-stat-value small { font-size: 0.66rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; }
.energy-stat-sub { font-size: 0.64rem; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.energy-stat-sub.up   { color: #fb923c; }
.energy-stat-sub.down { color: var(--green); }

/* Secondary cards: phases + EV */
.energy-secondary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px;
}
.energy-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px 14px;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.energy-card-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-muted);
}
.energy-card-hint { font-size: 0.62rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-dim); }

.energy-phases { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.energy-phase { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.energy-phase-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.energy-phase-name { font-size: 0.66rem; font-weight: 800; color: var(--text-dim); letter-spacing: 0.4px; }
.energy-phase-val { font-size: 1rem; font-weight: 800; letter-spacing: -0.4px; color: var(--text); }
.energy-phase-val small { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); margin-left: 2px; }
.energy-phase-val.volt-warn { color: var(--amber); }
.energy-phase-val.volt-bad  { color: var(--red); }
.energy-phase-track { position: relative; height: 5px; border-radius: 3px; background: var(--surface3); overflow: hidden; }
.energy-phase-nominal { position: absolute; left: 50%; top: -2px; width: 1px; height: 9px; background: rgba(255,255,255,0.35); z-index: 1; }
.energy-phase-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.5s ease; }
.energy-phase-fill.volt-warn { background: var(--amber); }
.energy-phase-fill.volt-bad  { background: var(--red); }
.energy-phase-amp { font-size: 0.64rem; font-weight: 700; color: var(--text-muted); }

.energy-ev { border-left: 3px solid var(--surface4); }
.energy-ev.ev-charging { border-left-color: var(--green); }
.energy-ev.ev-waiting  { border-left-color: var(--amber); }
.energy-ev.ev-done     { border-left-color: var(--accent); }
.energy-ev.ev-error    { border-left-color: var(--red); }
.energy-ev-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.4px; text-transform: none;
  padding: 2px 8px; border-radius: 100px; background: var(--surface3); color: var(--text-muted);
}
.energy-ev-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }
.ev-charging .energy-ev-badge { background: var(--green-dim); color: var(--green); }
.ev-charging .energy-ev-badge i { background: var(--green); animation: evPulse 1.6s ease-in-out infinite; }
.ev-waiting  .energy-ev-badge { background: var(--amber-dim); color: var(--amber); }
.ev-waiting  .energy-ev-badge i { background: var(--amber); }
.ev-done     .energy-ev-badge { background: var(--accent-dim); color: var(--accent); }
.ev-done     .energy-ev-badge i { background: var(--accent); }
.ev-error    .energy-ev-badge { background: var(--red-dim); color: var(--red); }
.ev-error    .energy-ev-badge i { background: var(--red); }
@keyframes evPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.energy-ev-body { display: flex; align-items: baseline; gap: 10px; }
.energy-ev-power { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.8px; color: var(--text); }
.energy-ev-power small { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); margin-left: 3px; letter-spacing: 0; }
.energy-ev-session { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); }

/* ── FORBRUK: device rows wrapped in a card ───────────────────────────── */
.energy-devices {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.energy-devices-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px 6px;
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-muted);
}
.energy-devices-sum { font-size: 0.64rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
.energy-empty { padding: 16px; color: var(--text-dim); font-size: 0.82rem; }
.energy-devices .power-row { grid-template-columns: 20px minmax(0, 1.2fr) 1fr 72px; }
.energy-devices .power-row-icon { font-size: 0.8rem; }
.energy-devices .power-row-name { color: var(--text); }
.energy-devices .power-bar-track { height: 6px; border-radius: 3px; }
.energy-devices .power-bar.bar-high,
.energy-devices .power-bar.bar-mid,
.energy-devices .power-bar.bar-low { box-shadow: none; background: var(--amber); }
.energy-devices .power-bar.bar-high { background: linear-gradient(90deg, var(--amber), #f97316); }
.energy-devices .power-bar.bar-rest {
  background: repeating-linear-gradient(135deg, var(--surface4) 0 4px, var(--surface3) 4px 8px);
}
.power-row-rest { cursor: default; }
.power-row-rest:hover { background: transparent; }
.power-row-rest .power-row-name,
.power-row-rest .power-row-icon { color: var(--text-muted); font-style: italic; }
.power-row-rest .power-row-val { color: var(--text-muted); }

/* ── WEATHER HERO ─────────────────────────────────────────────────────── */
.weather-hero.wx {
  display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  padding: 20px 24px 18px;
  background:
    radial-gradient(ellipse at 90% 0%, var(--wx-glow, rgba(56,189,248,0.10)) 0%, transparent 50%),
    linear-gradient(140deg, #0d1828 0%, #0a1020 100%);
  border-color: rgba(56,189,248,0.20);
}
.weather-hero.wx::before { display: none; }
.wx-sunny  { --wx-glow: rgba(251,191,36,0.14); }
.wx-night  { --wx-glow: rgba(167,139,250,0.14); }
.wx-partly { --wx-glow: rgba(125,211,252,0.12); }
.wx-rain   { --wx-glow: rgba(56,189,248,0.14); }
.wx-snow   { --wx-glow: rgba(226,232,240,0.14); }
.wx-cloudy { --wx-glow: rgba(148,163,184,0.10); }

.wx-top {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 26px;
}
.wx-icon {
  flex: 0 0 auto;
  font-size: 4rem; line-height: 1;
  filter: drop-shadow(0 0 22px rgba(56,189,248,0.25));
}
.wx-main { flex: 0 1 auto; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wx-main .weather-temp { font-size: 3.4rem; font-variant-numeric: proportional-nums; }
.wx-condition { font-size: 0.95rem; font-weight: 600; color: #bae6fd; letter-spacing: 0.1px; }
.wx-outdoor {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 0.74rem; font-weight: 600; color: var(--text-muted); margin-top: 2px;
}
.wx-outdoor strong { color: var(--text); font-weight: 800; }
.wx-outdoor-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--green-dim); }
.wx-delta { font-size: 0.66rem; font-weight: 700; padding: 1px 7px; border-radius: 100px; background: var(--surface3); color: var(--text-muted); }
.wx-delta.warm { color: #fb923c; background: rgba(251,146,60,0.12); }
.wx-delta.cold { color: #7dd3fc; background: rgba(125,211,252,0.12); }

.wx-metrics {
  flex: 1 1 340px; min-width: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 6px; align-self: center;
}
.wx-metric {
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03); border: 1px solid rgba(56,189,248,0.10);
  min-width: 0;
}
.wx-metric-label { font-size: 0.58rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); }
.wx-metric-value {
  font-size: 1.12rem; font-weight: 800; letter-spacing: -0.4px; color: var(--text); line-height: 1.15;
  display: flex; align-items: baseline; gap: 3px;
}
.wx-metric-value small { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; }
.wx-metric-sub { font-size: 0.62rem; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-metric-sub.uv-low  { color: var(--green); }
.wx-metric-sub.uv-mid  { color: var(--amber); }
.wx-metric-sub.uv-high { color: var(--red); }
.wx-arrow {
  display: inline-block; font-size: 0.95rem; line-height: 1; color: #7dd3fc;
  transform-origin: 50% 50%; margin-right: 2px; align-self: center;
}

/* Forecast strip with temperature curve */
.wx-forecast {
  position: relative;
  border-top: 1px solid rgba(56,189,248,0.12);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.wx-forecast-head {
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted);
}
.wx-curve {
  width: 100%; height: 34px; display: block; overflow: visible;
  margin-bottom: -6px;
}
.wx-forecast-items { display: grid; gap: 4px; }
.wx-fc {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px 6px; border-radius: var(--radius-sm); min-width: 0;
}
.wx-fc.first { background: rgba(56,189,248,0.07); }
.wx-fc-when { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); white-space: nowrap; }
.wx-fc.first .wx-fc-when { color: #7dd3fc; }
.wx-fc-icon { font-size: 1.15rem; line-height: 1.2; }
.wx-fc-temp { font-size: 0.9rem; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.wx-fc-rain { font-size: 0.6rem; font-weight: 700; color: #7dd3fc; white-space: nowrap; }
.wx-fc-rain.none { color: var(--text-dim); }

/* ── AUTOMATIONS PANEL ────────────────────────────────────────────────── */
.auto-panel {
  background: var(--surface2); border: 1px solid var(--border);
  border-left: 3px solid #a78bfa;
  border-radius: var(--radius); overflow: hidden;
}
.auto-loading { display: flex; align-items: center; gap: 8px; }
.auto-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(167,139,250,0.25); border-top-color: #a78bfa;
  animation: spin 0.8s linear infinite;
}

.auto-summary {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 12px 16px 10px;
}
.auto-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.68rem; font-weight: 700; padding: 4px 10px;
  border-radius: 100px; background: var(--surface3); border: 1px solid var(--border);
  color: var(--text-muted); white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.auto-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.auto-chip-on  { color: #c4b5fd; border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.10); }
.auto-chip-on  i { background: #a78bfa; box-shadow: 0 0 0 2px rgba(167,139,250,0.2); }
.auto-chip-off i { background: transparent; border: 1.5px solid var(--text-dim); }
.auto-chip-muted { color: var(--text-dim); border-color: transparent; background: transparent; padding-left: 4px; }

/* Next-run spotlight */
.auto-next {
  margin: 0 12px 6px;
  padding: 12px 16px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(167,139,250,0.16) 0%, rgba(167,139,250,0.05) 100%);
  border: 1px solid rgba(167,139,250,0.28);
  position: relative; overflow: hidden;
}
.auto-next::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px;
  border-radius: 50%; background: radial-gradient(circle, rgba(167,139,250,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.auto-next-eyebrow {
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.9px;
  color: #a78bfa; margin-bottom: 6px;
}
.auto-next-body { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.auto-next-countdown {
  font-size: 1.7rem; font-weight: 900; letter-spacing: -1px; line-height: 1;
  color: #ede9fe; white-space: nowrap;
}
.auto-next-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.auto-next-name { font-size: 0.98rem; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-next-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); }
.auto-next-clock { color: #c4b5fd; font-weight: 800; }

/* Shared tokens */
.auto-sched {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.3px;
  padding: 1px 7px; border-radius: 100px;
  background: rgba(167,139,250,0.14); color: #c4b5fd;
  white-space: nowrap;
}
.auto-last { font-size: 0.64rem; font-weight: 600; color: var(--text-dim); white-space: nowrap; }

/* Timeline */
.auto-timeline { display: flex; flex-direction: column; padding: 4px 0 6px; }
.auto-bucket {
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-dim); padding: 8px 16px 2px 16px;
}
.auto-item {
  display: grid; grid-template-columns: 74px 18px minmax(0, 1fr);
  gap: 0 8px; align-items: center;
  padding: 7px 16px 7px 16px;
  position: relative;
  transition: background 0.12s;
}
.auto-item:hover { background: rgba(255,255,255,0.02); }
.auto-item-time { display: flex; flex-direction: column; gap: 1px; text-align: right; }
.auto-clock { font-size: 0.9rem; font-weight: 800; color: var(--text); letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }
.auto-rel { font-size: 0.6rem; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-item.no-time .auto-clock { color: var(--text-dim); }

/* Rail: a continuous vertical line through the dots */
.auto-item-rail { position: relative; align-self: stretch; display: flex; align-items: center; justify-content: center; }
.auto-item-rail::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--surface4);
}
.auto-item:first-of-type .auto-item-rail::before,
.auto-bucket + .auto-item .auto-item-rail::before { top: 50%; }
.auto-item:last-child .auto-item-rail::before { bottom: 50%; }
.auto-dot {
  position: relative; z-index: 1;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface2); border: 2px solid var(--text-dim);
}
.auto-item.is-next .auto-dot {
  width: 11px; height: 11px;
  background: #a78bfa; border-color: #a78bfa;
  box-shadow: 0 0 0 4px rgba(167,139,250,0.22);
  animation: autoPulse 2s ease-in-out infinite;
}
@keyframes autoPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(167,139,250,0.22); }
  50%      { box-shadow: 0 0 0 7px rgba(167,139,250,0.08); }
}
.auto-item.is-next { background: rgba(167,139,250,0.05); }
.auto-item.is-next .auto-clock { color: #c4b5fd; }

.auto-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.auto-item-name {
  font-size: 0.86rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auto-item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Disabled rows */
.auto-timeline-off { padding-bottom: 8px; }
.auto-item.is-off .auto-item-name { color: var(--text-muted); font-weight: 600; }
.auto-item.is-off .auto-dot { border-style: dashed; opacity: 0.7; }
.auto-item.is-off .auto-sched { background: var(--surface3); color: var(--text-dim); }
.auto-off-badge {
  font-size: 0.55rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); border: 1px solid var(--border-mid);
  border-radius: 3px; padding: 1px 5px; flex-shrink: 0;
}
.auto-panel .automation-expand-btn { border-top: 1px solid var(--border-soft); }

/* ── PANELS: responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .energy-hero { grid-template-columns: 1fr; gap: 14px; padding: 16px 18px 14px; }
  .energy-hero-value { font-size: 2.9rem; }
  .wx-metrics { flex-basis: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wx-icon { font-size: 3.2rem; }
  .wx-main .weather-temp { font-size: 2.8rem; }
}

@media (max-width: 600px) {
  .energy-hero { padding: 14px 14px 12px; border-radius: var(--radius); }
  .energy-hero-value { font-size: 2.6rem; letter-spacing: -1.8px; }
  .energy-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .energy-stat-value { font-size: 1.15rem; }
  .energy-phases { gap: 8px; }
  .energy-devices .power-row { grid-template-columns: 18px minmax(0, 1fr) 0.8fr 64px; padding: 9px 12px; }
  .energy-devices-head { padding: 10px 12px 6px; }

  .weather-hero.wx { padding: 14px 14px 12px; gap: 10px; }
  .wx-top { gap: 8px 14px; }
  .wx-icon { font-size: 2.6rem; display: block; }
  .wx-main .weather-temp { font-size: 2.5rem; }
  .wx-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .wx-metric { padding: 7px 8px; }
  .wx-metric-value { font-size: 1rem; }
  .wx-forecast-items { grid-auto-flow: column; overflow-x: auto; }
  .wx-fc-icon { font-size: 1rem; }

  .auto-summary { padding: 10px 12px 8px; }
  .auto-chip-muted { display: none; }
  .auto-next { margin: 0 8px 6px; padding: 10px 12px 12px; }
  .auto-next-countdown { font-size: 1.4rem; }
  .auto-item { grid-template-columns: 58px 16px minmax(0, 1fr); padding: 7px 12px; }
  .auto-clock { font-size: 0.82rem; }
  .auto-bucket { padding-left: 12px; }
}

@media (max-width: 380px) {
  .energy-stats { grid-template-columns: 1fr 1fr; }
  .wx-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wx-forecast-items { gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .auto-item.is-next .auto-dot, .ev-charging .energy-ev-badge i { animation: none; }
}


/* ══ AGENT: DEVICES ══ */
/* Level 2 (device cards in the group panel) and level 3 (device drawer).
   Overrides are appended here rather than edited in place to keep merges clean. */

/* ── Panel header (level 2) ── */
.group-device-panel-header {
  gap: 8px; padding: 8px 2px 10px; flex-wrap: wrap;
}
.panel-header-icon { font-size: 1rem; line-height: 1; }
.panel-header-title { color: var(--text); }
.panel-header-count {
  font-size: 0.66rem; font-weight: 800; color: var(--group-color);
  background: color-mix(in srgb, var(--group-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--group-color) 30%, transparent);
  padding: 1px 8px; border-radius: 100px; letter-spacing: 0;
}
.panel-header-hint {
  margin-left: auto; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.2px;
  text-transform: none; color: var(--text-dim);
}

/* Unavailable toggle → real button, same look everywhere */
button.unavail-toggle {
  font: inherit; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.2px; text-transform: none;
  margin: 0; align-self: center; line-height: 1.2;
  min-height: 26px; padding: 3px 10px 3px 8px;
  color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border);
  border-radius: 100px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
button.unavail-toggle:hover { color: var(--text); border-color: var(--border-mid); background: var(--surface3); }
button.unavail-toggle.is-open { color: var(--text); background: var(--surface3); border-color: var(--border-mid); }
.unavail-toggle-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0;
}
button.unavail-toggle.is-open .unavail-toggle-dot { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }

/* ── Device grid: a touch more breathing room ── */
.device-grid { gap: 10px; padding: 2px 0 10px; }

/* ── Device card ── */
.device-card {
  padding: 13px 14px 12px;
  gap: 10px;
  border-left-width: 1px;                      /* state is shown by the pill, not a stripe */
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%);
  min-height: 108px;
}
.device-card:hover {
  border-left-color: var(--border-mid);
  background: linear-gradient(180deg, var(--surface3) 0%, var(--surface2) 100%);
}
.device-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Colour the whole card edge by state */
.device-card.on,
.device-card.heating  { border-left: 3px solid var(--amber); box-shadow: inset 0 0 0 1px rgba(245,158,11,0.10), 0 0 24px -14px var(--amber); }
.device-card.cooling  { border-left: 3px solid var(--accent); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.device-card.active   { border-left: 3px solid var(--accent); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.device-card.alert    {
  border-left: 3px solid var(--red); border-color: rgba(239,68,68,0.35);
  box-shadow: inset 0 0 0 1px rgba(239,68,68,0.14), 0 0 28px -10px var(--red);
  animation: devAlertPulse 1.6s ease-in-out infinite;
}
@keyframes devAlertPulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(239,68,68,0.14), 0 0 28px -10px var(--red); }
  50%      { box-shadow: inset 0 0 0 1px rgba(239,68,68,0.30), 0 0 34px -6px var(--red); }
}

/* Unavailable: still tappable (so you can see which entity is gone), clearly "asleep" */
.device-card.unavailable {
  opacity: 0.6; pointer-events: auto;
  border-style: dashed; border-color: var(--border-mid); border-left-width: 1px;
  background: var(--surface);
  filter: saturate(0.4);
}
.device-card.unavailable:hover { opacity: 0.85; transform: none; box-shadow: none; }
.device-card.unavailable .device-name { color: var(--text-dim); }

/* Header */
.device-header { gap: 9px; min-height: 30px; }
.device-card-icon {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1;
  background: color-mix(in srgb, var(--group-color) 13%, var(--surface3));
  border: 1px solid color-mix(in srgb, var(--group-color) 22%, transparent);
}
.device-card.unavailable .device-card-icon { background: var(--surface3); border-color: var(--border); }
.device-name { font-size: 0.86rem; font-weight: 700; color: var(--text); }

/* Status pill (top-right, non-light cards) */
.device-status {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase;
  padding: 3px 8px 3px 7px; border-radius: 100px;
  background: var(--surface3); border: 1px solid var(--border); color: var(--text-muted);
  max-width: 50%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.device-status .device-status-dot { width: 6px; height: 6px; box-shadow: none; }
.device-status.ok     { color: var(--green); background: var(--green-dim); border-color: rgba(34,197,94,0.22); }
.device-status.ok     .device-status-dot { background: var(--green); }
.device-status.idle   { color: var(--text-muted); }
.device-status.idle   .device-status-dot { background: var(--text-muted); }
.device-status.heat   { color: var(--amber); background: var(--amber-dim); border-color: rgba(245,158,11,0.25); }
.device-status.heat   .device-status-dot { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.device-status.cool   { color: var(--accent); background: var(--accent-dim); border-color: var(--accent-glow); }
.device-status.cool   .device-status-dot { background: var(--accent); }
.device-status.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent-glow); }
.device-status.active .device-status-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.device-status.alert  { color: var(--red); background: var(--red-dim); border-color: rgba(239,68,68,0.35); }
.device-status.alert  .device-status-dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
.device-status.off    { color: var(--text-dim); }
.device-status.off    .device-status-dot { background: var(--text-dim); }

/* Battery cue in header */
.device-battery {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 0.62rem; font-weight: 700; color: var(--text-muted);
}
.device-battery-body {
  position: relative; width: 18px; height: 9px; border-radius: 2.5px;
  border: 1px solid var(--text-muted); overflow: hidden; background: transparent;
}
.device-battery-body::after {
  content: ''; position: absolute; right: -3px; top: 2px; width: 2px; height: 3px;
  background: var(--text-muted); border-radius: 0 1px 1px 0;
}
.device-battery-fill { display: block; height: 100%; background: var(--green); transition: width 0.4s; }
.device-battery.mid .device-battery-fill { background: var(--amber); }
.device-battery.mid { color: var(--amber); }
.device-battery.low .device-battery-fill { background: var(--red); }
.device-battery.low { color: var(--red); }
.device-battery.low .device-battery-body { border-color: var(--red); }

/* ── Metric typography contract ── */
.device-metrics { gap: 6px 18px; align-items: flex-end; }
.metric { gap: 3px; min-width: 0; }
.metric-value {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.6px; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.metric-value .decimal { font-size: 0.72em; font-weight: 700; color: var(--text-muted); }
.metric-value .unit { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); margin-left: 3px; letter-spacing: 0; }
.metric-value.small { font-size: 1.05rem; letter-spacing: -0.2px; }
.metric-value.val-warn { color: var(--amber); }
.metric-value.val-bad  { color: var(--red); }
.metric-label {
  font-size: 0.6rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.state-badge.idle { background: var(--surface3); color: var(--text-muted); border: 1px solid var(--border-mid); }

/* ── Climate card: measured temp + inline setpoint control ── */
.card-climate {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.card-climate-now { display: flex; flex-direction: column; gap: 3px; }
.card-climate-set {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px; border-radius: 100px;
  background: var(--surface3); border: 1px solid var(--border);
}
.card-temp-btn.temp-btn {
  width: 34px; height: 34px; font-size: 1.15rem;
  background: var(--surface4); border-color: transparent;
}
.card-temp-btn.temp-btn:hover:not(:disabled) { background: var(--surface5); transform: scale(1.06); box-shadow: none; }
.card-temp-btn.temp-btn:active:not(:disabled) { transform: scale(0.94); }
.card-climate-target {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 52px; padding: 0 2px;
}
.card-climate-target-value {
  font-size: 1.05rem; font-weight: 800; letter-spacing: -0.3px; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--text);
  transition: color 0.15s;
}
.card-climate-target-value .unit { font-size: 0.7rem; color: var(--text-muted); margin-left: 1px; }
.card-climate-target-value.pending { color: var(--amber); }
.card-climate-target .metric-label { font-size: 0.52rem; }
.device-card.heating .card-climate-target-value:not(.pending) { color: var(--amber); }
.device-card.cooling .card-climate-target-value:not(.pending) { color: var(--accent); }

/* ── Light card ── */
.device-card .card-toggle {
  width: 46px; height: 26px; border-radius: 13px;
}
.device-card .card-toggle .card-toggle-knob { width: 20px; height: 20px; }
.device-card .card-toggle.is-on .card-toggle-knob { transform: translateX(20px); }
.device-card .card-toggle:focus-visible { box-shadow: 0 0 0 3px rgba(251,191,36,0.35); }

.card-light-body { display: flex; flex-direction: column; gap: 6px; cursor: default; }
.card-light-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-light-pct {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.6px; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--text-dim); transition: color 0.2s;
}
.card-light-pct.is-on { color: var(--amber); }
.card-light-pct .unit { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.card-light-off { font-size: 1.05rem; font-weight: 800; color: var(--text-dim); }
.card-light-count { font-size: 0.6rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

/* Bigger thumb + track = easier to grab on a phone */
.card-dim-row { padding: 6px 0 2px; }
.dim-slider { height: 6px; border-radius: 3px; }
.dim-slider::-webkit-slider-thumb { width: 22px; height: 22px; border-width: 2.5px; }
.dim-slider::-moz-range-thumb { width: 22px; height: 22px; border-width: 2.5px; }
.dim-slider.dim-off { opacity: 0.5; cursor: pointer; }
.dim-slider.dim-off::-webkit-slider-thumb { cursor: pointer; }

/* Stale footer */
.device-stale {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.6rem; font-weight: 700; color: var(--amber); letter-spacing: 0.2px;
  margin-top: -2px;
}
.device-stale-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }

/* ── Drawer (level 3) ── */
.drawer { max-width: 560px; }
.drawer-header { padding: 22px 20px 14px; gap: 14px; position: relative; }
.drawer-icon {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.45rem; line-height: 1;
  background: var(--surface3); border: 1px solid var(--border-mid);
  box-shadow: 0 6px 18px -8px rgba(0,0,0,0.6);
}
.drawer-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.drawer-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-subtitle {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 0.7rem; font-weight: 600; color: var(--text-muted);
}
.drawer-sub-sep { color: var(--text-dim); }
.drawer-avail { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.drawer-avail-dot { width: 6px; height: 6px; border-radius: 50%; }
.drawer-avail.ok { color: var(--green); }
.drawer-avail.ok .drawer-avail-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green-dim); }
.drawer-avail.off { color: var(--text-dim); }
.drawer-avail.off .drawer-avail-dot { background: var(--text-dim); }
.drawer-close { width: 34px; height: 34px; }

.drawer-body { padding: 4px 0 30px; }
.drawer-section-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-dim); padding: 14px 20px 4px;
}
.drawer-section-label::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.drawer-section-count {
  font-size: 0.6rem; font-weight: 800; color: var(--text-dim);
  background: var(--surface3); padding: 0 6px; border-radius: 100px;
}
.drawer-entity { padding: 12px 20px; gap: 16px; }
.drawer-entity.is-control { padding: 14px 20px; }
.drawer-entity-name { font-size: 0.88rem; }
.drawer-entity-updated { font-size: 0.64rem; }
.drawer-entity.unavailable { opacity: 0.5; }
.drawer-entity.unavailable .drawer-entity-name { color: var(--text-muted); }

.drawer-big-value { font-variant-numeric: tabular-nums; }
.drawer-big-value .decimal { color: var(--text-muted); font-size: 0.72em; }
.drawer-big-value.val-warn { color: var(--amber); }
.drawer-big-value.val-bad  { color: var(--red); }

/* Climate in drawer: bigger buttons, labelled setpoint */
.drawer-climate-top { display: flex; align-items: center; gap: 10px; }
.drawer-measured-temp { font-variant-numeric: tabular-nums; }
.drawer-measured-temp .decimal { color: var(--text-muted); font-size: 0.7em; font-weight: 700; }
.drawer-temp-control {
  gap: 6px; padding: 4px; border-radius: 100px;
  background: var(--surface2); border: 1px solid var(--border);
}
.temp-btn { width: 44px; height: 44px; font-size: 1.35rem; }
.temp-setpoint {
  min-width: 70px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 1.25rem; line-height: 1; font-variant-numeric: tabular-nums; transition: color 0.15s;
}
.temp-setpoint.pending { color: var(--amber); }
.temp-setpoint-label { font-size: 0.52rem; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-dim); }

/* Light in drawer: toggle + its own brightness slider */
.drawer-light { flex-direction: column; align-items: flex-end; gap: 8px; }
.drawer-light-row { display: flex; align-items: center; gap: 10px; }
.light-brightness { font-size: 0.85rem; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.light-brightness.off { color: var(--text-dim); }
.dim-slider.drawer-dim { width: 190px; flex: none; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .device-grid { gap: 8px; }
  .device-card { padding: 12px 12px 11px; min-height: 100px; }
  .device-name { font-size: 0.82rem; }
  .device-status { font-size: 0.6rem; padding: 3px 7px 3px 6px; }
  .device-status.ok .device-status-label,
  .device-status.idle .device-status-label { display: none; } /* keep calm states to a dot on tiny cards */
  .metric-value { font-size: 1.3rem; }
  .card-light-pct { font-size: 1.3rem; }
  .card-temp-btn.temp-btn { width: 32px; height: 32px; font-size: 1.05rem; }
  .card-climate-target { min-width: 46px; }
  .panel-header-hint { display: none; }
  .drawer { max-height: 88vh; }
  .drawer-header { padding: 20px 16px 12px; }
  .drawer-entity, .drawer-entity.is-control { padding: 12px 16px; }
  .drawer-section-label { padding: 12px 16px 4px; }
  .dim-slider.drawer-dim { width: 150px; }
  .temp-btn { width: 42px; height: 42px; }
}
@media (max-width: 380px) {
  .device-status .device-status-label { display: inline; } /* single column → room for the word again */
  .dim-slider.drawer-dim { width: 130px; }
}
@media (hover: none) {
  .device-card:hover { transform: none; }
}

/* Device name: wrap to two lines instead of truncating to "Varmepum…" */
.device-name {
  white-space: normal; overflow: hidden; text-overflow: clip;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  line-height: 1.2; word-break: break-word;
}
/* Status pill: sentence case keeps it narrow; bare dot has no chrome */
.device-status { text-transform: none; letter-spacing: 0.1px; font-size: 0.68rem; max-width: 46%; }
.device-status.dot-only { background: transparent; border-color: transparent; padding: 3px 2px; max-width: none; }

/* Phone (two-column grid): the card is ~160px wide, so the status pill collapses to a
   coloured dot (the card edge + amber setpoint still show "heating"); alerts keep their word. */
@media (max-width: 600px) {
  .device-card-icon { width: 26px; height: 26px; font-size: 0.9rem; border-radius: 8px; }
  .device-header { gap: 7px; }
  .device-status:not(.alert) .device-status-label { display: none; }
  .device-status:not(.alert) { background: transparent; border-color: transparent; padding: 3px 2px; max-width: none; }
  .device-status:not(.alert) .device-status-dot { width: 8px; height: 8px; }
  .device-status.heat .device-status-dot, .device-status.active .device-status-dot { box-shadow: 0 0 8px currentColor; }
}
@media (max-width: 380px) {
  /* single column again → room for the word */
  .device-status:not(.alert) .device-status-label { display: inline; }
  .device-status:not(.alert) { background: var(--surface3); border-color: var(--border); padding: 3px 8px 3px 7px; }
  .device-status.ok   { background: var(--green-dim); border-color: rgba(34,197,94,0.22); }
  .device-status.heat { background: var(--amber-dim); border-color: rgba(245,158,11,0.25); }
  .device-status.cool, .device-status.active { background: var(--accent-dim); border-color: var(--accent-glow); }
  .device-status:not(.alert) .device-status-dot { width: 6px; height: 6px; }
}

/* ══ STALE / OFFLINE SENSORS ══
   A sensor that stopped reporting keeps its last value in HA. These rules make that
   visibly different from a live reading (see StalenessRules). */
.metric.is-stale .metric-value { color: var(--text-muted); }
.metric.is-stale .metric-value .unit { color: var(--text-dim); }
.metric.is-stale .metric-label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.device-card { position: relative; }
.device-card.is-offline { border-color: rgba(245,158,11,0.35); }
.device-card.is-offline::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(245,158,11,0.035) 10px 12px);
}
.device-stale.offline { color: var(--amber); font-weight: 700; }
.device-stale.offline .device-stale-dot { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); animation: assistantPulse 1.6s ease-in-out infinite; }
.energy-hero-value.is-stale { color: var(--text-muted); }
.energy-eyebrow { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drawer-entity-updated .stale-pill { margin-left: 6px; vertical-align: middle; }
.energy-per-device { margin-top: 12px; }

/* ══ FEATURE: PRICES ══ */
.price-card {
  margin-top: 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
  --price-accent: var(--text-muted);
}
.price-card.tone-ok    { --price-accent: var(--green); }
.price-card.tone-warn  { --price-accent: var(--amber); }
.price-card.tone-alert { --price-accent: var(--red); }

.price-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.price-head-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.price-title { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); }
.price-now { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.price-now-value {
  font-size: 2rem; font-weight: 800; letter-spacing: -1.2px; line-height: 1;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.price-now-unit { font-size: 0.95rem; font-weight: 700; color: var(--price-accent); }
.price-now-unit small { font-size: 0.65rem; font-weight: 600; color: var(--text-muted); margin-left: 1px; }

.price-pill {
  display: inline-flex; align-items: center; align-self: center;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
  border-radius: 999px; padding: 2px 8px; line-height: 1.4; white-space: nowrap; margin-left: 4px;
  color: var(--text-muted); background: var(--surface4); border: 1px solid var(--border-mid);
}
.price-pill.price-level-very_cheap,
.price-pill.price-level-cheap          { color: var(--green); background: var(--green-dim); border-color: rgba(34,197,94,0.3); }
.price-pill.price-level-expensive      { color: var(--amber); background: var(--amber-dim); border-color: rgba(245,158,11,0.35); }
.price-pill.price-level-very_expensive { color: var(--red);   background: var(--red-dim);   border-color: rgba(239,68,68,0.35); }

/* I dag | I morgen */
.price-tabs { display: inline-flex; background: var(--surface3); border: 1px solid var(--border); border-radius: 999px; padding: 2px; flex-shrink: 0; }
.price-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted); padding: 4px 11px; border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.price-tab:hover:not(:disabled) { color: var(--text); }
.price-tab.active { background: var(--surface5); color: var(--text); }
.price-tab:disabled { cursor: not-allowed; color: var(--text-dim); }
.price-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Lav / Snitt / Høy */
.price-stats { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.price-stat { display: inline-flex; align-items: baseline; gap: 5px; }
.price-stat-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-muted); }
.price-stat-value { font-size: 0.9rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.price-stat-unit { font-size: 0.62rem; font-weight: 600; color: var(--text-dim); margin-left: auto; }

/* 24 hourly bars — pure CSS */
.price-chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 92px; padding-bottom: 14px; position: relative; min-width: 0;
  border-bottom: 1px solid var(--border-soft);
}
.price-bar {
  flex: 1 1 0; min-width: 0; height: 100%; position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  border-radius: 3px; cursor: default;
}
.price-bar:hover { background: var(--border-soft); }
.price-bar-fill {
  width: 100%; border-radius: 3px 3px 1px 1px; min-height: 3px;
  background: var(--surface5);
  transition: height 0.35s ease, opacity 0.2s ease;
}
.price-bar.price-level-very_cheap .price-bar-fill,
.price-bar.price-level-cheap .price-bar-fill          { background: linear-gradient(180deg, var(--green) 0%, color-mix(in srgb, var(--green) 55%, var(--surface3)) 100%); }
.price-bar.price-level-normal .price-bar-fill         { background: linear-gradient(180deg, #8a8ab0 0%, var(--surface5) 100%); }
.price-bar.price-level-expensive .price-bar-fill      { background: linear-gradient(180deg, var(--amber) 0%, color-mix(in srgb, var(--amber) 55%, var(--surface3)) 100%); }
.price-bar.price-level-very_expensive .price-bar-fill { background: linear-gradient(180deg, var(--red) 0%, color-mix(in srgb, var(--red) 55%, var(--surface3)) 100%); }
.price-bar.is-past .price-bar-fill { opacity: 0.32; }
.price-bar.is-now .price-bar-fill { box-shadow: 0 0 0 1px var(--text), 0 0 10px -2px var(--price-accent); opacity: 1; }
.price-bar.is-now::after {
  content: ''; position: absolute; left: 50%; bottom: -3px; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--text);
}
.price-bar-hour {
  position: absolute; left: 0; bottom: -14px; font-size: 0.56rem; font-weight: 600;
  color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap;
}

.price-hint { font-size: 0.74rem; color: var(--text-dim); }

/* Cheapest 3 h window */
.price-window { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-muted); min-width: 0; }
.price-window-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--green); box-shadow: 0 0 0 2px var(--green-dim); }
.price-window-text { min-width: 0; }
.price-window-text strong { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }

/* Forbruk tile cue */
.tile-cue.price-cue { flex-shrink: 1; }

@media (max-width: 600px) {
  .price-card { padding: 12px 12px; gap: 10px; }
  .price-now-value { font-size: 1.7rem; }
  .price-chart { gap: 2px; height: 76px; }
  .price-bar { border-radius: 2px; }
  .price-stats { gap: 10px; }
  .price-stat-unit { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .price-bar-fill, .price-tab { transition: none; }
}

/* ══ FEATURE: ALERTS ══ */
/* Topbar bell (AlertBell.razor), its dropdown / phone sheet, and the history timeline (AlertLog.razor). */
.alert-bell-wrap { position: relative; display: inline-flex; align-items: center; }
.alert-bell {
  position: relative; background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 1rem; line-height: 1; padding: 4px 6px; border-radius: 8px;
  display: inline-flex; align-items: center; transition: color 0.15s, background 0.15s;
}
.alert-bell:hover, .alert-bell.is-open { color: var(--text); background: var(--surface3); }
.alert-bell-icon { filter: grayscale(1) brightness(1.35); transition: filter 0.2s; }
.alert-bell:has(.alert-badge) .alert-bell-icon, .alert-bell.is-open .alert-bell-icon { filter: none; }
.alert-badge {
  position: absolute; top: -3px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 100px; font-size: 0.62rem; font-weight: 800; line-height: 16px; text-align: center;
  color: #fff; background: var(--amber); box-shadow: 0 0 0 2px var(--bg);
}
.alert-badge.critical { background: var(--red); }
.alert-badge.is-unread { animation: alert-badge-pulse 1.8s ease-in-out infinite; }
.alert-badge.critical.is-unread { animation-name: alert-badge-pulse-red; }
@keyframes alert-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 0 rgba(245,158,11,0); }
  50%      { box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px rgba(245,158,11,0.28); }
}
@keyframes alert-badge-pulse-red {
  0%, 100% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 0 rgba(239,68,68,0); }
  50%      { box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px rgba(239,68,68,0.30); }
}

/* Dropdown (desktop: anchored card under the bell) */
.alert-panel {
  position: absolute; top: calc(100% + 12px); right: -8px; width: 360px; max-width: calc(100vw - 32px);
  max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border-mid); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
  color: var(--text); font-size: 0.8rem; font-weight: 500; text-align: left; z-index: 120;
  animation: alert-panel-in 0.18s ease;
}
@keyframes alert-panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.alert-panel-header {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px;
  position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 1px solid var(--border-soft);
}
.alert-panel-title { font-weight: 900; font-size: 0.95rem; letter-spacing: -0.3px; color: var(--text); }
.alert-panel-count { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; }
.alert-panel-close {
  margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 0.9rem; line-height: 1; padding: 4px 7px; border-radius: 6px;
}
.alert-panel-close:hover { color: var(--text); background: var(--surface3); }
.alert-empty { display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: var(--green); font-weight: 700; }
.alert-empty-icon {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; font-size: 0.85rem;
  display: inline-flex; align-items: center; justify-content: center; background: var(--green-dim);
}

/* Active list + history share the row anatomy: severity dot · icon · body · time */
.alert-list, .alert-log { list-style: none; margin: 0; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.alert-item, .alert-log-item {
  display: grid; grid-template-columns: 8px auto minmax(0, 1fr) auto; align-items: start; gap: 10px;
  padding: 9px 8px; border-radius: var(--radius-sm);
}
.alert-item:hover { background: var(--surface2); }
.alert-sev-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.sev-warn .alert-sev-dot { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }
.sev-critical .alert-sev-dot { background: var(--red); box-shadow: 0 0 0 2px var(--red-dim); animation: alert-dot-pulse 1.6s ease-in-out infinite; }
@keyframes alert-dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.alert-item-icon { font-size: 1rem; line-height: 1.2; }
.alert-item-body, .alert-log-body { min-width: 0; }
.alert-item-title { font-weight: 800; font-size: 0.82rem; color: var(--text); }
.sev-critical .alert-item-title { color: var(--red); }
.sev-warn .alert-item-title { color: var(--amber); }
.alert-item-detail, .alert-log-detail { color: var(--text-muted); font-size: 0.74rem; margin-top: 2px; overflow-wrap: anywhere; }
.alert-item-time, .alert-log-time {
  color: var(--text-dim); font-size: 0.68rem; font-weight: 600; white-space: nowrap; margin-top: 3px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right;
}

/* History (collapsed <details> at the bottom of the panel) */
.alert-history { border-top: 1px solid var(--border-soft); margin-top: 4px; }
.alert-history > summary {
  cursor: pointer; padding: 10px 16px; list-style: none; display: flex; align-items: center; gap: 8px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted);
}
.alert-history > summary::-webkit-details-marker { display: none; }
.alert-history > summary::before { content: '›'; display: inline-block; font-size: 0.95rem; line-height: 1; transition: transform 0.15s; }
.alert-history[open] > summary::before { transform: rotate(90deg); }
.alert-history > summary:hover { color: var(--text); }
.alert-log { padding-top: 0; }
.alert-log-item { grid-template-columns: 8px minmax(0, 1fr) auto; padding: 7px 8px; }
.alert-log-item.is-resolved { opacity: 0.55; }
.alert-log-item.is-resolved .alert-sev-dot { animation: none; background: var(--text-dim); box-shadow: none; }
.alert-log-title { font-weight: 700; font-size: 0.78rem; color: var(--text); }
.alert-log-resolved { color: var(--green); }
.alert-log-open { color: var(--amber); }
.alert-log-empty { padding: 10px 16px 14px; color: var(--text-dim); font-size: 0.74rem; }

/* Phones: the dropdown becomes a full-width sheet hanging from the topbar */
@media (max-width: 600px) {
  .alert-bell-wrap { position: static; }
  .alert-panel {
    position: fixed; top: 56px; left: 0; right: 0; width: auto; max-width: none;
    max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg); border-left: none; border-right: none;
  }
  .alert-item, .alert-log-item { padding: 10px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .alert-badge, .alert-panel, .sev-critical .alert-sev-dot { animation: none; }
}

/* ══ FEATURE: CONTROL ══
   Quick actions bar (qa-), light controls (lc-) and the persons panel (persons-). */

/* ── Quick actions ── */
.qa-bar { position: relative; margin: -2px 0 0; }
.qa-bar::after {
  /* right-edge fade hinting that the row scrolls */
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; pointer-events: none;
  background: linear-gradient(to right, transparent, var(--bg));
  opacity: 0.9;
}
.qa-scroll {
  display: flex; gap: 8px; align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding: 2px 28px 4px 0;
}
.qa-scroll::-webkit-scrollbar { display: none; }
.qa-pill {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px 0 11px; border-radius: 999px;
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  border: 1px solid var(--border-mid); color: var(--text);
  font: inherit; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1px; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 4px 14px rgba(0,0,0,0.25);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease, color 0.18s ease;
}
.qa-pill:hover { border-color: rgba(59,130,246,0.45); background: linear-gradient(180deg, var(--surface3), var(--surface2)); }
.qa-pill:active { transform: scale(0.97); }
.qa-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qa-pill:disabled { cursor: progress; }
.qa-icon { font-size: 0.95rem; line-height: 1; width: 1.2em; text-align: center; filter: saturate(0.9); }
.qa-label { line-height: 1; }
.qa-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; margin-left: 2px;
  background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,0.3);
  font-size: 0.68rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.qa-pill.qa-script .qa-icon { color: var(--accent); }
.qa-pill.qa-builtin { border-style: dashed; }
.qa-pill.qa-builtin.is-on { border-style: solid; border-color: rgba(245,158,11,0.45); background: linear-gradient(180deg, rgba(245,158,11,0.16), rgba(245,158,11,0.06)); color: #fcd38d; }
.qa-pill.is-pending { color: var(--text-muted); border-color: var(--border-mid); }
.qa-pill.is-pending .qa-icon { animation: qaSpin 0.9s linear infinite; }
.qa-pill.is-done {
  border-color: rgba(34,197,94,0.5); color: #9ff0b8;
  background: linear-gradient(180deg, rgba(34,197,94,0.18), rgba(34,197,94,0.06));
  box-shadow: 0 0 0 3px rgba(34,197,94,0.10), 0 4px 14px rgba(0,0,0,0.25);
}
.qa-pill.is-done .qa-icon { color: var(--green); font-weight: 900; }
.qa-pill.is-failed { border-color: rgba(239,68,68,0.5); color: #fca5a5; background: var(--red-dim); }
@keyframes qaSpin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  .qa-scroll { gap: 7px; scroll-snap-type: x mandatory; padding-right: 24px; }
  .qa-pill { min-height: 42px; font-size: 0.78rem; }
}
@media (prefers-reduced-motion: reduce) { .qa-pill, .qa-pill .qa-icon { transition: none; animation: none; } }

/* ── Light controls ── */
.lc { display: flex; flex-direction: column; gap: 6px; cursor: default; }
.lc-compact { width: 100%; }
.lc-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lc-pct {
  font-size: 1.25rem; font-weight: 800; letter-spacing: -0.4px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.lc-pct.is-on { color: var(--amber); }
.lc-pct .unit { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.lc-off { font-size: 1.05rem; font-weight: 800; color: var(--text-dim); }
.lc-sub { font-size: 0.6rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.lc input[type="range"] { width: 100%; min-height: 24px; margin: 0; }
.lc-compact .dim-slider { height: 6px; }

.lc-full { width: 100%; max-width: 300px; gap: 8px; padding: 2px 0; }
.lc-head { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.lc-head .lc-pct { margin-right: auto; font-size: 1.1rem; }
.lc-kelvin-text {
  font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border-mid);
  color: var(--text); background: var(--surface3);
}
.lc-row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 10px; }
.lc-label { font-size: 0.66rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.lc-row .dim-slider.lc-brightness { height: 6px; }

/* Kelvin slider: fixed warm-to-cold gradient track; the thumb carries the chosen temperature */
.lc-kelvin {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; border-radius: 4px; outline: none; cursor: pointer;
  background: linear-gradient(to right, #ffb15c 0%, #ffd9a6 30%, #fff5e4 52%, #e8f1ff 72%, #bcd4ff 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
  transition: opacity 0.2s;
}
.lc-kelvin.dim-off { opacity: 0.4; }
.lc-kelvin::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--surface5);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35), 0 0 10px rgba(255,255,255,0.25);
  cursor: pointer; transition: transform 0.1s ease;
}
.lc-kelvin::-webkit-slider-thumb:hover { transform: scale(1.2); }
.lc-kelvin::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--surface5); cursor: pointer;
}
.lc-kelvin-scale {
  display: flex; justify-content: space-between; margin: -4px 0 0 86px;
  font-size: 0.58rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px;
}
.drawer-entity:has(.lc-full) { flex-wrap: wrap; }
.drawer-entity .drawer-entity-right:has(.lc-full) { flex: 1 1 100%; display: flex; justify-content: flex-end; }
@media (max-width: 600px) {
  .lc-full { max-width: none; }
  .lc-row { grid-template-columns: 68px 1fr; }
  .lc-kelvin-scale { margin-left: 78px; }
  .lc input[type="range"] { min-height: 32px; }
}

/* ── Persons panel ── */
.persons-panel { display: flex; flex-direction: column; gap: 12px; padding: 2px 0 10px; }
.persons-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 0 2px; }
.persons-count { font-size: 0.95rem; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.persons-count-num { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.8px; color: var(--text-muted); margin-right: 2px; }
.persons-count.has-home .persons-count-num { color: var(--green); text-shadow: 0 0 14px rgba(34,197,94,0.35); }
.persons-sub { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.persons-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.persons-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  border: 1px solid var(--border); min-height: 84px;
  transition: border-color 0.18s ease, transform 0.12s ease;
}
.persons-card.is-home { border-color: rgba(34,197,94,0.22); }
.persons-card.is-away, .persons-card.is-unknown { opacity: 0.82; }
.persons-avatar {
  position: relative; flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface4); color: var(--text); font-weight: 800; font-size: 1rem; letter-spacing: 0.3px;
  border: 2px solid var(--surface5);
}
.persons-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.persons-avatar.is-home { border-color: rgba(34,197,94,0.6); box-shadow: 0 0 0 3px var(--green-dim), 0 0 16px rgba(34,197,94,0.25); }
.persons-avatar.is-zone { border-color: rgba(59,130,246,0.6); box-shadow: 0 0 0 3px var(--accent-dim); }
.persons-dot {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-dim); border: 2px solid var(--surface);
}
.persons-avatar.is-home .persons-dot { background: var(--green); }
.persons-avatar.is-zone .persons-dot { background: var(--accent); }
.persons-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.persons-name { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persons-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.persons-pill {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase;
  background: var(--surface3); color: var(--text-muted); border: 1px solid var(--border-mid);
}
.persons-pill.is-home { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,0.3); }
.persons-pill.is-zone { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-glow); text-transform: none; }
.persons-since { font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.persons-source { display: flex; align-items: center; gap: 5px; font-size: 0.68rem; color: var(--text-dim); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persons-source-icon { font-size: 0.7rem; opacity: 0.8; }
.persons-acc { color: var(--text-dim); font-weight: 500; }
@media (max-width: 600px) {
  .persons-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .persons-card { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .persons-body { width: 100%; }
}
@media (max-width: 380px) { .persons-grid { grid-template-columns: 1fr; } }

/* ══ FEATURE: HISTORY ══ */
/* Trend card (Forbruk panel), entity trend (drawer) and the reusable sparkline. */
.trend-card {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px;
  margin-top: 8px; min-width: 0;
}
.trend-section {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px 12px;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.trend-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-muted);
}
.trend-head .stale-pill { text-transform: none; letter-spacing: 0; }
.trend-title { white-space: nowrap; }
.trend-hint {
  font-size: 0.62rem; font-weight: 600; text-transform: none; letter-spacing: 0;
  color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.trend-empty { font-size: 0.78rem; color: var(--text-muted); padding: 10px 0 4px; }

.trend-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  padding-top: 8px; border-top: 1px solid var(--border-soft);
}
.trend-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trend-stat-label { font-size: 0.58rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.trend-stat-value {
  font-size: 0.98rem; font-weight: 800; letter-spacing: -0.4px; color: var(--text); line-height: 1.1;
  display: flex; align-items: baseline; gap: 3px; white-space: nowrap;
}
.trend-stat-value small { font-size: 0.6rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; }
.trend-stat.is-now .trend-stat-value { color: var(--amber); }
.trend-stat.is-now.is-stale .trend-stat-value { color: var(--text-muted); }

/* Skeleton while the recorder answers */
.trend-skel { display: flex; flex-direction: column; gap: 10px; padding: 2px 0; }
.trend-skel-plot { height: 110px; border-radius: 10px; }
.trend-skel-plot.is-small { height: 72px; }
.trend-skel-row { height: 22px; width: 70%; }

/* 7-day bars */
.trend-bars {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  align-items: end; padding: 6px 0 0; min-width: 0;
}
.trend-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.trend-bar-val { font-size: 0.6rem; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend-bar-track {
  width: 100%; height: 96px; display: flex; align-items: flex-end;
  border-bottom: 1px solid var(--border-mid);
}
.trend-bar-fill {
  width: 100%; min-height: 2px; border-radius: 4px 4px 0 0;
  background: rgba(245,158,11,0.38); transition: height 0.4s ease;
}
.trend-bar-col.is-today .trend-bar-fill { background: var(--amber); box-shadow: 0 0 14px rgba(245,158,11,0.28); }
.trend-bar-col.is-today .trend-bar-val,
.trend-bar-col.is-today .trend-bar-day { color: var(--text); }
.trend-bar-col.no-data .trend-bar-val { color: var(--text-dim); }
.trend-bar-day { font-size: 0.6rem; font-weight: 700; text-transform: lowercase; color: var(--text-muted); white-space: nowrap; }

/* Drawer */
.entity-trend {
  margin: 0 20px 4px; padding: 10px 14px 10px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}

/* Sparkline */
.spark { position: relative; width: 100%; min-width: 0; --spark-color: var(--accent); }
.spark-plot { position: relative; width: 100%; height: var(--spark-h, 64px); }
.spark-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.spark-line { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { stroke: none; }
.spark-ref { stroke: var(--border-mid); stroke-width: 1px; stroke-dasharray: 2 4; }
.spark-now { stroke: var(--spark-color); stroke-width: 1px; stroke-dasharray: 2 3; opacity: 0.55; }
.spark-hit { fill: transparent; cursor: crosshair; }
.spark-hit:hover { fill: rgba(255,255,255,0.05); }
.spark-dot {
  position: absolute; width: 9px; height: 9px; border-radius: 50%; pointer-events: none;
  background: var(--spark-color); border: 2px solid var(--surface2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spark-color) 25%, transparent);
  transform: translate(-50%, -50%);
}
.spark-now-label {
  position: absolute; pointer-events: none; transform: translate(8px, -50%);
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.3px; color: var(--text);
  background: var(--surface3); border: 1px solid var(--border-mid); border-radius: 999px; padding: 1px 7px;
  white-space: nowrap;
}
.spark-now-label.is-right { transform: translate(calc(-100% - 10px), -50%); }
.spark-ext {
  position: absolute; pointer-events: none; font-size: 0.6rem; font-weight: 700; color: var(--text-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.spark-ext.is-max { transform: translate(-50%, calc(-100% - 4px)); }
.spark-ext.is-min { transform: translate(-50%, 4px); }
.spark-axis { display: flex; justify-content: space-between; margin-top: 4px; font-size: 0.6rem; font-weight: 600; color: var(--text-dim); }
.spark.is-empty .spark-plot { display: flex; align-items: center; justify-content: center; }
.spark-empty-line { stroke: var(--border-mid); stroke-width: 1.5px; stroke-dasharray: 4 5; }
.spark-empty-text {
  position: relative; font-size: 0.68rem; font-weight: 600; color: var(--text-dim);
  background: var(--surface2); padding: 0 8px;
}

@media (max-width: 760px) {
  .trend-card { grid-template-columns: minmax(0, 1fr); }
  .entity-trend { margin: 0 14px 4px; }
}
@media (max-width: 380px) {
  .trend-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-bar-val { font-size: 0.55rem; }
}
@media (prefers-reduced-motion: reduce) {
  .trend-bar-fill { transition: none; }
}

/* ══ FEATURE: TOP CONSUMERS ══ */
/* «Mest strøm brukt» (TopConsumersCard.razor, Forbruk panel): devices ranked by kWh over 24 t / 7 d / 30 d. Mirrors .energy-per-device. */
.tc-card {
  margin-top: 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.tc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tc-head-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 140px; }
.tc-title { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); }
.tc-hint {
  font-size: 0.66rem; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* 24 t | 7 d | 30 d */
.tc-seg { display: inline-flex; background: var(--surface3); border: 1px solid var(--border); border-radius: 999px; padding: 2px; flex-shrink: 0; }
.tc-seg-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted); padding: 4px 11px; border-radius: 999px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
  transition: background 0.15s ease, color 0.15s ease;
}
.tc-seg-btn:hover { color: var(--text); }
.tc-seg-btn.active { background: var(--surface5); color: var(--text); }
.tc-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Rows */
.tc-list { display: flex; flex-direction: column; }
.tc-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; min-width: 0;
  border-bottom: 1px solid var(--border-soft);
}
.tc-row:last-child { border-bottom: none; }
.tc-rank {
  width: 14px; flex-shrink: 0; text-align: right;
  font-size: 0.66rem; font-weight: 800; color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.tc-row.is-top .tc-rank { color: var(--amber); }
.tc-icon { font-size: 1.1rem; width: 28px; text-align: center; flex-shrink: 0; opacity: 0.9; }
.tc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tc-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tc-name { font-size: 0.85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-bar { height: 4px; border-radius: 2px; background: var(--surface4); overflow: hidden; }
.tc-bar-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #f59e0b 0%, #fb923c 100%);
  transition: width 0.4s ease;
}
.tc-values { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; gap: 2px; }
.tc-kwh { font-size: 0.95rem; font-weight: 800; color: var(--text); letter-spacing: -0.3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-kwh small { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; margin-left: 1px; }
.tc-share { font-size: 0.66rem; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* «Annet»: what the main meter saw beyond the named devices */
.tc-row.rest .tc-name, .tc-row.rest .tc-kwh { color: var(--text-muted); }
.tc-row.rest .tc-icon { color: var(--text-muted); }
.tc-row.rest .tc-bar-fill { background: repeating-linear-gradient(90deg, var(--surface5) 0 6px, transparent 6px 9px); }

/* Loading / empty */
.tc-skel { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 2px; }
.tc-skel-row { display: flex; flex-direction: column; gap: 6px; padding-left: 52px; }
.tc-skel-name { height: 12px; width: 40%; }
.tc-skel-bar { height: 4px; width: 100%; }
.tc-loading { font-size: 0.72rem; font-weight: 600; color: var(--text-dim); padding-left: 52px; }
.tc-empty { font-size: 0.8rem; color: var(--text-dim); padding: 8px 0; }

@media (max-width: 600px) {
  .tc-card { padding: 12px 12px; }
  .tc-row { gap: 8px; }
  .tc-icon { width: 24px; font-size: 1rem; }
  .tc-seg-btn { padding: 4px 9px; }
  .tc-skel-row, .tc-loading { padding-left: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .tc-bar-fill, .tc-seg-btn { transition: none; }
}

/* Donut: slices are circles with stroke-dasharray on a ring of circumference 100 (see DonutChart). */
.tc-body { display: flex; align-items: center; gap: 18px; min-width: 0; }
.tc-body .tc-list { flex: 1 1 auto; min-width: 0; }
.tc-donut {
  position: relative; flex: 0 0 160px; width: 160px; height: 160px; margin: 4px 0;
  display: grid; place-items: center;
}
.tc-donut svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tc-track { fill: none; stroke: var(--surface3); stroke-width: 5; }
.tc-slice {
  fill: none; stroke-width: 5; stroke: var(--surface5); cursor: pointer;
  transition: stroke-width 0.15s ease, opacity 0.2s ease;
}
.tc-slice.rest { stroke: var(--surface5); }
.tc-donut.has-focus .tc-slice:not(.is-focus) { opacity: 0.35; }
.tc-slice.is-focus, .tc-slice:hover { stroke-width: 6.5; opacity: 1; }
.tc-centre {
  position: absolute; inset: 0; margin: 0; padding: 0 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-align: center; pointer-events: none; min-width: 0;
}
.tc-centre-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
.tc-centre-value small { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; margin-left: 2px; }
.tc-centre-name { font-size: 0.66rem; font-weight: 700; color: var(--text-muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tc-dot.rest { background: var(--surface5); }
.tc-row { cursor: pointer; transition: background 0.15s ease; border-radius: 6px; }
.tc-row.is-focus { background: var(--surface3); }
.tc-row.is-focus .tc-name { color: var(--text); }
@media (max-width: 600px) {
  .tc-body { flex-direction: column; gap: 6px; }
  .tc-donut { flex-basis: auto; width: 150px; height: 150px; }
  .tc-body .tc-list { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .tc-slice, .tc-row { transition: none; }
}

/* ══ FEATURE: CUSTOMIZE ══ */
/* Per-user «Tilpass» mode: hide/restore tiles, toggle widgets, reset to default. cz- prefix. */
.cz-bar { display: flex; justify-content: flex-end; align-items: center; margin: 0 0 6px; }
.cz-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.01em;
  padding: 5px 11px; border-radius: 100px; cursor: pointer;
  color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.cz-btn:hover { color: var(--text); background: var(--surface3); border-color: var(--border-mid); }
.cz-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cz-btn.is-active { color: var(--accent); background: var(--accent-dim); border-color: rgba(59,130,246,0.35); }
.cz-btn.is-danger { color: var(--red); background: var(--red-dim); border-color: rgba(239,68,68,0.35); }
.cz-btn.is-danger:hover { background: rgba(239,68,68,0.22); }
.cz-reset { color: var(--text-muted); }

/* Tiles in customise mode: dashed outline + ✕ in the corner */
.group-tiles.is-customizing .tile-slot:not(.tile-empty-slot) > .group-tile {
  outline: 1px dashed var(--border-mid); outline-offset: 2px;
}
.group-tiles.is-customizing .group-tile-top { padding-right: 24px; } /* keep ⚠/count badges clear of the ✕ */
.group-tiles.is-customizing .tile-empty-slot { outline: 1px dashed var(--border); outline-offset: -1px; border-radius: var(--radius); }
.cz-hide {
  position: absolute; top: 4px; right: 4px; z-index: 4;
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 0.68rem; font-weight: 800; line-height: 1; cursor: pointer;
  color: var(--text); background: var(--surface4); border: 1px solid var(--border-mid);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.12s;
}
.cz-hide:hover { color: var(--red); background: var(--red-dim); border-color: rgba(239,68,68,0.45); transform: scale(1.08); }
.cz-hide:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The tray under the grid */
.cz-panel {
  margin-top: 12px; padding: 14px 16px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 14px;
  animation: panelIn 0.25s ease;
}
.cz-section { display: flex; flex-direction: column; gap: 8px; }
.cz-section-title { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); }
.cz-empty, .cz-hint { font-size: 0.74rem; color: var(--text-muted); }
.cz-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cz-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 0.76rem; font-weight: 700; padding: 6px 12px 6px 9px;
  border-radius: 100px; cursor: pointer;
  color: var(--text); background: var(--surface2); border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.cz-chip:hover { background: var(--accent-dim); border-color: rgba(59,130,246,0.35); transform: translateY(-1px); }
.cz-chip-plus { color: var(--accent); font-weight: 900; }
.cz-toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.cz-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-muted); cursor: pointer; user-select: none;
}
.cz-toggle.is-on { color: var(--text); }
.cz-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.cz-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: 10px;
}
.cz-confirm { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.76rem; font-weight: 700; color: var(--text); }
@media (max-width: 640px) {
  /* Empty drop slots are useless on a phone (no pointer drag) and left a blank band under the grid. */
  .tile-empty-slot:not(.drag-active) { display: none; }
  .cz-panel { padding: 12px 12px 10px; }
  .cz-footer { flex-direction: column; align-items: stretch; }
  .cz-confirm { justify-content: space-between; }
  .cz-hide { width: 26px; height: 26px; font-size: 0.78rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cz-panel { animation: none; }
}

/* ══ FEATURE: ADVISOR ══ */
/* «Strømråd» (AdvisorCard.razor, Forbruk panel): AI energy adviser — summary, prioritised tips, refresh. adv- prefix. */
.adv-card {
  margin-top: 12px; position: relative; overflow: hidden; min-width: 0;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.adv-card::before {
  /* faint aurora in the corner so the card reads as "the AI one" without shouting */
  content: ""; position: absolute; inset: -40% auto auto -20%; width: 60%; height: 120%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(167,139,250,0.10), transparent 70%);
}
.adv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; position: relative; }
.adv-head-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 140px; }
.adv-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted);
}
.adv-glyph { color: #a78bfa; font-size: 0.8rem; text-shadow: 0 0 10px rgba(167,139,250,0.55); }
.adv-hint { font-size: 0.66rem; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.adv-refresh {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  font: inherit; font-size: 0.7rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  color: var(--text-muted); background: var(--surface3); border: 1px solid var(--border);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.adv-refresh:hover:not(:disabled) { color: var(--text); background: var(--surface4); border-color: var(--border-mid); }
.adv-refresh:disabled { opacity: 0.5; cursor: not-allowed; }
.adv-refresh:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.adv-refresh-icon { font-size: 0.85rem; line-height: 1; display: inline-block; }
.adv-refresh-icon.spin { animation: advSpin 1s linear infinite; }
@keyframes advSpin { to { transform: rotate(360deg); } }

/* Summary + tips */
.adv-summary { margin: 0; font-size: 0.86rem; line-height: 1.45; color: var(--text); position: relative; }
.adv-tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; position: relative; }
.adv-tip {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; min-width: 0;
  border-bottom: 1px solid var(--border-soft);
}
.adv-tip:last-child { border-bottom: none; }
.adv-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 800; font-variant-numeric: tabular-nums;
  color: #0a0a0f; background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.14);
}
.adv-tip:nth-child(n+2) .adv-num { color: var(--text); background: var(--surface4); box-shadow: none; }
.adv-tip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.adv-tip-title { font-size: 0.86rem; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.adv-tip-detail { font-size: 0.78rem; line-height: 1.45; color: var(--text-muted); overflow-wrap: anywhere; }
.adv-tip-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
.adv-saving {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--green); background: var(--green-dim); border: 1px solid rgba(34,197,94,0.28);
}
.adv-effort {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  color: var(--text-muted); background: var(--surface3); border: 1px solid var(--border);
}
.adv-effort-lett { color: #a7f3d0; background: rgba(16,185,129,0.10); border-color: rgba(16,185,129,0.22); }
.adv-effort-middels { color: #fcd34d; background: var(--amber-dim); border-color: rgba(245,158,11,0.28); }
.adv-effort-stor { color: #fda4af; background: var(--red-dim); border-color: rgba(239,68,68,0.28); }

/* Footer */
.adv-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--border-soft); position: relative;
}
.adv-generated { font-size: 0.66rem; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.adv-foot-error { font-size: 0.66rem; font-weight: 700; color: var(--amber); }

/* Setup hint / loading / error / empty */
.adv-setup {
  display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); position: relative;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface3); border: 1px dashed var(--border-mid);
}
.adv-setup-icon { font-size: 0.95rem; }
.adv-skel { display: flex; flex-direction: column; gap: 10px; padding: 2px 0; position: relative; }
.adv-skel-summary { height: 11px; width: 92%; }
.adv-skel-summary.short { width: 64%; margin-bottom: 6px; }
.adv-skel-tip { display: flex; align-items: flex-start; gap: 12px; }
.adv-skel-num { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
.adv-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; padding-top: 3px; }
.adv-skel-title { height: 11px; width: 48%; }
.adv-skel-detail { height: 9px; width: 84%; opacity: 0.7; }
.adv-thinking { display: inline-flex; align-items: center; gap: 7px; font-size: 0.72rem; font-weight: 600; color: var(--text-dim); }
.adv-thinking-dot { width: 7px; height: 7px; border-radius: 50%; background: #a78bfa; animation: advPulse 1.2s ease-in-out infinite; }
@keyframes advPulse { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.1); } }
.adv-error {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; position: relative;
  font-size: 0.8rem; color: var(--text-muted); padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--amber-dim); border: 1px solid rgba(245,158,11,0.25);
}
.adv-error-text { color: var(--text); font-weight: 600; }
.adv-retry {
  font: inherit; font-size: 0.7rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  color: var(--text); background: var(--surface3); border: 1px solid var(--border-mid);
}
.adv-retry:hover { background: var(--surface4); }
.adv-empty { font-size: 0.8rem; color: var(--text-dim); padding: 6px 0; }

@media (max-width: 600px) {
  .adv-card { padding: 12px 12px; }
  .adv-tip { gap: 10px; }
  .adv-refresh { padding: 5px 9px; }
  .adv-foot { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .adv-refresh-icon.spin, .adv-thinking-dot { animation: none; }
  .adv-refresh { transition: none; }
}

/* «Strømråd» as its own tile (AdvisorTile.razor) + the month-so-far strip at the top of the card */
.grp-advisor { --group-color: #a78bfa; }
.group-tile.grp-advisor .adv-tile-tip { color: #c4b5fd; flex-shrink: 1; }
.group-tile.grp-advisor .adv-tile-busy .cue-dot { background: #a78bfa; animation: advPulse 1.2s ease-in-out infinite; }
.adv-month {
  display: flex; flex-direction: column; gap: 3px; position: relative; min-width: 0;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface3); border: 1px solid var(--border);
}
.adv-month-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.adv-month-kwh { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.adv-month-label { font-size: 0.74rem; font-weight: 600; color: var(--text-muted); }
.adv-month-cost { margin-left: auto; font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #c4b5fd; white-space: nowrap; }
.adv-month-sub { font-size: 0.66rem; font-weight: 600; color: var(--text-dim); overflow-wrap: anywhere; }
.adv-month-offline { color: var(--amber); }
.adv-panel .adv-card { margin-top: 0; }

/* ══ FEATURE: ROOMS ══ */
/* «Hus» (/hus): floor-plan editor with device assignment. hs- prefix. */
.hs-page { gap: 14px; }
.hs-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hs-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.hs-floors {
  display: flex; gap: 4px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 100px;
}
.hs-floor {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 0.74rem; font-weight: 700; padding: 5px 12px; border-radius: 100px;
  border: none; cursor: pointer; color: var(--text-muted); background: transparent;
  transition: color 0.15s, background 0.15s;
}
.hs-floor:hover { color: var(--text); background: var(--surface2); }
.hs-floor.is-active { color: var(--text); background: var(--surface3); }
.hs-floor:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hs-floor-count {
  font-size: 0.62rem; font-weight: 800; padding: 1px 6px; min-width: 16px; text-align: center;
  border-radius: 100px; background: var(--surface4); color: var(--text-muted);
}
.hs-floor.is-active .hs-floor-count { background: var(--accent-dim); color: var(--accent); }
.hs-actions { margin-left: auto; display: flex; gap: 6px; }
.hs-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.01em;
  padding: 6px 12px; border-radius: 100px; cursor: pointer; white-space: nowrap;
  color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.hs-btn:hover { color: var(--text); background: var(--surface3); border-color: var(--border-mid); }
.hs-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hs-btn.is-active { color: var(--accent); background: var(--accent-dim); border-color: rgba(59,130,246,0.35); }
.hs-btn.is-primary { color: #fff; background: var(--accent); border-color: transparent; }
.hs-btn.is-primary:hover { background: #2f6fe0; color: #fff; }
.hs-btn.is-danger { color: var(--red); background: var(--red-dim); border-color: rgba(239,68,68,0.35); }
.hs-btn.is-danger:hover { background: rgba(239,68,68,0.22); color: var(--red); }
.hs-close { padding: 4px 9px; }

/* Two columns: plan + side panel; the panel stacks below the plan on narrow screens */
.hs-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.hs-plan-wrap {
  min-width: 0; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.hs-svg {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 12;
  border-radius: var(--radius-sm); background: var(--bg);
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.hs-svg.is-editing { touch-action: none; cursor: crosshair; }
.hs-svg.is-dragging, .hs-svg.is-dragging .hs-room { cursor: grabbing; }
.hs-grid-line { fill: none; stroke: rgba(255,255,255,0.045); stroke-width: 0.02; }
.hs-grid-major { fill: none; stroke: rgba(255,255,255,0.085); stroke-width: 0.03; }
.hs-canvas { fill: url(#hs-grid-major); }

/* Rooms */
.hs-room { cursor: pointer; }
.hs-svg.is-editing .hs-room { cursor: move; }
.hs-room text { pointer-events: none; }
.hs-room-box { fill: var(--surface3); stroke: var(--border-mid); stroke-width: 0.06; transition: fill 0.2s, stroke 0.2s; }
.hs-room:hover .hs-room-box { fill: var(--surface4); stroke: rgba(255,255,255,0.2); }
.hs-room.is-lit .hs-room-box { fill: rgba(245,158,11,0.16); stroke: rgba(245,158,11,0.5); }
.hs-room.is-lit:hover .hs-room-box { fill: rgba(245,158,11,0.22); }
.hs-room.is-open .hs-room-box { stroke: var(--accent); }
.hs-room.is-empty { opacity: 0.6; }
.hs-room.is-selected { opacity: 1; }
.hs-room.is-selected .hs-room-box { stroke: var(--accent); stroke-width: 0.09; fill: var(--accent-dim); }
.hs-room.is-selected.is-lit .hs-room-box { fill: rgba(245,158,11,0.2); }
.hs-room-name { font-size: 0.5px; font-weight: 800; fill: var(--text); }
.hs-room-val { font-size: 0.4px; font-weight: 600; fill: var(--text-muted); }
.hs-room.is-lit .hs-room-val { fill: #fcd9a1; }
.hs-room-none { font-size: 0.36px; font-style: italic; fill: var(--text-dim); }
.hs-handle { fill: var(--accent); stroke: var(--bg); stroke-width: 0.06; cursor: nwse-resize; }
.hs-del { cursor: pointer; }
.hs-del circle { fill: var(--surface5); stroke: var(--border-mid); stroke-width: 0.04; transition: fill 0.15s; }
.hs-del:hover circle { fill: var(--red); }
.hs-del text { font-size: 0.36px; font-weight: 800; fill: var(--text); pointer-events: none; }
.hs-draft { fill: var(--accent-dim); stroke: var(--accent); stroke-width: 0.06; stroke-dasharray: 0.2 0.12; pointer-events: none; }
.hs-hint { margin: 10px 2px 0; font-size: 0.74rem; color: var(--text-muted); line-height: 1.5; }

/* Side panel */
.hs-side {
  min-width: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.hs-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hs-side-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted);
}
.hs-side-head .hs-side-title { font-size: 0.95rem; letter-spacing: -0.01em; text-transform: none; color: var(--text); }
.hs-count { font-size: 0.62rem; padding: 1px 7px; border-radius: 100px; background: var(--surface3); color: var(--text-muted); }
.hs-empty { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.hs-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
}
.hs-input {
  font: inherit; font-size: 0.95rem; font-weight: 700; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border-mid); border-radius: var(--radius-sm);
  padding: 9px 12px; width: 100%; min-width: 0; outline: none; box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hs-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.hs-input::placeholder { color: var(--text-dim); font-weight: 500; }
.hs-meta { font-size: 0.74rem; color: var(--text-muted); }
.hs-tools { display: flex; gap: 6px; align-items: center; }
.hs-search { flex: 1; font-size: 0.8rem; font-weight: 600; padding: 7px 10px; }
.hs-notice {
  font-size: 0.74rem; color: var(--text); padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--accent-dim); border: 1px solid rgba(59,130,246,0.3);
}
.hs-devlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow-y: auto; }
.hs-dev {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.8rem; color: var(--text-muted); transition: background 0.12s, color 0.12s;
}
.hs-dev:hover { background: var(--surface2); }
.hs-dev.is-on { color: var(--text); background: var(--surface2); }
.hs-dev input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.hs-dev-icon { width: 22px; text-align: center; flex-shrink: 0; }
.hs-dev-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hs-dev-name em { font-style: normal; font-weight: 500; color: var(--text-dim); margin-left: 5px; }
.hs-dev-group { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); flex-shrink: 0; }
.hs-danger {
  border-top: 1px solid var(--border); padding-top: 10px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.76rem; font-weight: 700;
}
.hs-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.hs-chip {
  font-size: 0.74rem; font-weight: 700; padding: 4px 10px; border-radius: 100px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
}
.hs-chip.is-lit { background: var(--amber-dim); border-color: rgba(245,158,11,0.3); color: var(--amber); }
.hs-chip.is-open { background: var(--accent-dim); border-color: rgba(59,130,246,0.3); color: var(--accent); }
.hs-rooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hs-room-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; text-align: left;
  font: inherit; color: var(--text); cursor: pointer; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border); transition: background 0.12s, border-color 0.12s;
}
.hs-room-row:hover { border-color: var(--border-mid); background: var(--surface3); }
.hs-room-row.is-lit { border-color: rgba(245,158,11,0.3); }
.hs-room-row-name { font-weight: 700; font-size: 0.84rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-room-row-val { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; }
.hs-cards { display: flex; flex-direction: column; gap: 8px; }
.hs-cards .device-card { cursor: default; }

@media (max-width: 900px) {
  .hs-layout { grid-template-columns: 1fr; }
  .hs-devlist { max-height: 40vh; }
}
@media (max-width: 640px) {
  .hs-head { gap: 8px; }
  .hs-floors { width: 100%; box-sizing: border-box; }
  .hs-floor { flex: 1; justify-content: center; padding: 6px 6px; }
  .hs-actions { margin-left: 0; width: 100%; }
  .hs-actions .hs-btn { flex: 1; justify-content: center; }
  .hs-plan-wrap { padding: 8px; }
  .hs-side { padding: 12px; }
  .hs-room-name { font-size: 0.56px; }
  .hs-room-val { font-size: 0.46px; }
}

/* ══ FEATURE: INTEGRATIONS ══ */
/* Admin tabs, direct-integration cards (/admin/integrations) and the schedule editor (/tidsplaner). */
.in-tabs { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.in-tab {
  font-size: 0.78rem; font-weight: 700; padding: 6px 12px; border-radius: 100px;
  color: var(--text-muted); border: 1px solid var(--border); text-decoration: none;
}
.in-tab:hover { color: var(--text); background: var(--surface2); }
.in-tab.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent-glow); }
.in-intro { font-size: 0.82rem; color: var(--text-muted); max-width: 720px; margin: 0; }
.in-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.in-name { font-size: 1rem; font-weight: 800; }
.in-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; max-width: 640px; }
.in-desc a { color: var(--accent); margin-left: 4px; }
.in-pill {
  font-size: 0.68rem; font-weight: 800; padding: 3px 10px; border-radius: 100px; white-space: nowrap;
  background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border);
}
.in-pill.is-ok { background: rgba(34,197,94,0.12); color: #22c55e; border-color: rgba(34,197,94,0.35); }
.in-pill.is-warn { background: rgba(245,158,11,0.12); color: #f59e0b; border-color: rgba(245,158,11,0.35); }
.in-pill.is-err { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.3); }
.in-ok { font-size: 0.78rem; color: var(--text-muted); }
.in-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.in-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; }
.in-field > span { font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }
.in-check { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-muted); padding-bottom: 10px; }
.in-actions { display: flex; gap: 8px; align-items: center; }

.sc-form .sc-narrow { flex: 0 0 120px; min-width: 120px; }
.sc-days { display: flex; gap: 4px; flex-wrap: wrap; }
.sc-day {
  font-size: 0.75rem; font-weight: 700; min-width: 36px; padding: 7px 8px; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); cursor: pointer;
}
.sc-day.is-on { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-glow); }
.sc-day.sc-preset { background: transparent; border-style: dashed; }
.sc-link { background: none; border: none; color: var(--accent); font-size: 0.75rem; font-weight: 700; cursor: pointer; padding: 4px 6px; }
.sc-off td { opacity: 0.5; }
.sc-err { color: var(--red); font-weight: 700; cursor: help; }
.sc-row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
@media (max-width: 700px) {
  .sc-table th:nth-child(5), .sc-table td:nth-child(5), .sc-table th:nth-child(6), .sc-table td:nth-child(6) { display: none; }
}

/* ══ FEATURE: ADMIN LOG ══ */
/* /admin/logg (lg-*) and the service/device sections on /admin/integrations. */
.in-section { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin: 6px 0 -4px; }
.in-help { font-size: 0.7rem; color: var(--text-dim); line-height: 1.35; }
.in-flash { font-weight: 600; }
.lg-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lg-levels { display: flex; gap: 4px; flex-wrap: wrap; }
.lg-count { opacity: 0.6; font-weight: 600; margin-left: 2px; }
.lg-search { flex: 1; min-width: 180px; }
.lg-clear { display: flex; justify-content: flex-end; margin-top: -6px; }
.lg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lg-row { border: 1px solid var(--border-soft); border-left: 3px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--surface2); }
.lg-row.lg-err { border-left-color: var(--red); }
.lg-row.lg-warn { border-left-color: #f59e0b; }
.lg-meta { display: flex; gap: 10px; align-items: baseline; font-size: 0.68rem; color: var(--text-dim); flex-wrap: wrap; }
.lg-level { font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; }
.lg-err .lg-level { color: var(--red); }
.lg-warn .lg-level { color: #f59e0b; }
.lg-cat { font-family: ui-monospace, monospace; }
.lg-msg { font-size: 0.82rem; color: var(--text); margin-top: 2px; word-break: break-word; }
.lg-ex summary { font-size: 0.7rem; color: var(--accent); cursor: pointer; margin-top: 4px; }
.lg-ex pre { font-size: 0.68rem; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; background: var(--surface); padding: 8px; border-radius: var(--radius-sm); }

/* ══ FEATURE: BIOMETRIC ══ */
/* Fingerprint / Face ID login: button on /login, one-time prompt after a password login, /konto. */
.bio-login { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.bio-login[hidden] { display: none; }
.bio-or { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; }
.bio-or::before, .bio-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.bio-btn { background: var(--surface2); color: var(--text); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 8px; }
.bio-prompt {
  position: fixed; left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 195; /* clear of the ✦ button */
  max-width: 520px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--accent-glow); border-radius: var(--radius-lg);
  padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.bio-icon { font-size: 1.6rem; line-height: 1; }
.bio-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.bio-title { font-weight: 800; font-size: 0.9rem; }
.bio-sub { font-size: 0.76rem; color: var(--text-muted); }
.bio-sub a { color: var(--accent); }
.bio-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

/* ══ FEATURE: CAMERAS ══ */
/* «Kamera» tile (latest picture), panel with live view, tonight's motion (00–06), time-span grid and viewer. cam-* */
.grp-cameras { overflow: hidden; }
.cam-tile-img { width: 100%; height: 100%; max-height: 120px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 6px; background: var(--surface2); min-height: 0; flex: 1; }
.cam-tile-sub { margin-top: 4px; font-size: 0.72rem; color: var(--text-muted); }
.cam-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cam-chip { font-size: 0.78rem; font-weight: 700; padding: 6px 12px; border-radius: 100px; border: 1px solid var(--border); background: var(--surface2); color: var(--text-muted); cursor: pointer; }
.cam-chip.is-on { color: var(--accent); background: var(--accent-dim); border-color: var(--accent-glow); }
.cam-card { display: flex; flex-direction: column; gap: 10px; }
.cam-view { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: #000; aspect-ratio: 16 / 9; max-height: 70vh; }
.cam-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-badge { position: absolute; left: 10px; top: 10px; font-size: 0.7rem; font-weight: 800; padding: 3px 8px; border-radius: 100px; background: rgba(0,0,0,0.6); color: #fff; }
.cam-badge-live { color: #ff5a5a; }
.cam-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cam-error { font-size: 0.75rem; color: #f59e0b; }
.cam-section { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.cam-section-title { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.cam-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.cam-strip .cam-thumb { flex: 0 0 160px; scroll-snap-align: start; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.cam-thumb { position: relative; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #000; cursor: pointer; aspect-ratio: 16 / 9; }
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-thumb span { position: absolute; left: 4px; bottom: 4px; font-size: 0.66rem; font-weight: 700; color: #fff; background: rgba(0,0,0,0.6); padding: 1px 6px; border-radius: 100px; }
.cam-thumb.is-motion { border-color: #f59e0b; box-shadow: 0 0 0 1px #f59e0b inset; }
.cam-range { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.cam-range label { display: flex; flex-direction: column; gap: 3px; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dim); }
.cam-range label.in-check { flex-direction: row; text-transform: none; font-weight: 600; padding-bottom: 10px; }
.cam-range .auth-input { min-width: 0; width: auto; }
.cam-viewer { position: fixed; inset: 0; z-index: 200; /* above the ✦ button (190), below the assistant drawer (210) */ background: rgba(0,0,0,0.92); display: flex; flex-direction: column; outline: none; }
.cam-viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.cam-viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); color: #fff; font-size: 0.82rem; }
.cam-viewer-bar span { flex: 1; text-align: center; }
.cam-nav, .cam-close { background: rgba(255,255,255,0.12); border: none; color: #fff; font-size: 1.4rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.cam-nav:disabled { opacity: 0.3; cursor: default; }
.cam-close { font-size: 1rem; }
.cam-section > .sc-link { align-self: flex-start; padding-left: 0; }
