:root {
    --bg: #eef3f7;
    --panel: rgba(255, 255, 255, .88);
    --panel-solid: #ffffff;
    --ink: #101722;
    --muted: #647386;
    --line: rgba(108, 125, 148, .18);
    --accent: #00a878;
    --accent-2: #246bfe;
    --cyan: #00a3ff;
    --warn: #f59e0b;
    --danger: #ef4444;
    --violet: #7c3aed;
    --sidebar: #07111f;
    --shadow: 0 24px 70px rgba(16, 23, 34, .13);
    --glow: 0 0 32px rgba(0, 168, 120, .28);
}

body[data-theme="dark"] {
    --bg: #0b111c;
    --panel: rgba(18, 27, 42, .88);
    --panel-solid: #121b2a;
    --ink: #eef5ff;
    --muted: #9aaabe;
    --line: rgba(154, 170, 190, .18);
    --accent: #27d8a1;
    --accent-2: #6aa2ff;
    --cyan: #38c7ff;
    --warn: #fbbf24;
    --danger: #fb7185;
    --violet: #a78bfa;
    --sidebar: #050914;
    --shadow: 0 24px 70px rgba(0, 0, 0, .34);
    --glow: 0 0 32px rgba(39, 216, 161, .24);
}

* { box-sizing: border-box; }
html.sidebar-collapsed-preset body {
    visibility: hidden;
}
html.sidebar-ready body {
    visibility: visible;
}

body {
    margin: 0;
    background:
        linear-gradient(135deg, rgba(0,168,120,.08), transparent 28rem),
        radial-gradient(circle at 18% 8%, rgba(0,163,255,.22), transparent 24rem),
        radial-gradient(circle at 88% 12%, rgba(124,58,237,.14), transparent 28rem),
        radial-gradient(circle at 72% 82%, rgba(245,158,11,.10), transparent 24rem),
        var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
}
body[data-theme="dark"] {
    background:
        linear-gradient(135deg, rgba(39,216,161,.10), transparent 26rem),
        radial-gradient(circle at 18% 8%, rgba(56,199,255,.18), transparent 23rem),
        radial-gradient(circle at 88% 12%, rgba(167,139,250,.12), transparent 26rem),
        radial-gradient(circle at 72% 82%, rgba(251,191,36,.08), transparent 23rem),
        var(--bg);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px 1fr;
    transition: grid-template-columns .18s ease;
    overflow-x: hidden;
    background: linear-gradient(90deg, var(--sidebar) 0 248px, transparent 248px);
}
body.sidebar-collapsed .app-shell,
html.sidebar-collapsed-preset .app-shell {
    grid-template-columns: 0 1fr;
    background: transparent;
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: start;
    padding: 22px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.07), transparent 28%),
        radial-gradient(circle at 18% 8%, rgba(0,168,120,.24), transparent 16rem),
        radial-gradient(circle at 100% 65%, rgba(36,107,254,.18), transparent 18rem),
        var(--sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 28px;
    box-shadow: inset -1px 0 0 rgba(255,255,255,.08), 18px 0 60px rgba(7,17,31,.08);
    transform: translateX(0);
    opacity: 1;
    transition: transform .18s ease, opacity .18s ease, padding .18s ease;
}
body.sidebar-collapsed .app-sidebar,
html.sidebar-collapsed-preset .app-sidebar {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    min-height: 48px;
}
.brand strong,
.nav-stack span,
.nav-section-title span,
.sidebar-foot small {
    transition: opacity .14s ease, width .14s ease;
}
.brand span,
.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    color: #fff;
    font-weight: 800;
    box-shadow: 0 16px 32px rgba(0, 168, 120, .28);
}
.brand strong {
    font-size: 1.08rem;
    letter-spacing: .01em;
}

.nav-stack {
    display: grid;
    gap: 6px;
}
.nav-section {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.1);
}
.nav-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 2px 13px 5px;
    border: 0;
    background: transparent;
    color: rgba(255,255,255,.74);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
}
.nav-section-title i {
    width: 20px;
    text-align: center;
    flex: 0 0 20px;
    color: var(--accent);
}
.nav-section-title span {
    flex: 1;
    text-align: left;
}
.nav-section-chevron {
    margin-left: auto;
    transform: rotate(0deg);
    transition: transform .16s ease;
    color: rgba(255,255,255,.58) !important;
}
.nav-section-links {
    display: grid;
    gap: 6px;
    overflow: hidden;
    max-height: 300px;
    opacity: 1;
    padding-bottom: 2px;
    transition: max-height .18s ease, opacity .18s ease, padding-bottom .18s ease;
}
.nav-section.is-collapsed .nav-section-links {
    max-height: 0;
    opacity: 0;
    padding-bottom: 0;
    pointer-events: none;
}
.nav-section.is-collapsed .nav-section-chevron {
    transform: rotate(-90deg);
}
.nav-stack a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.68);
    text-decoration: none;
    padding: 12px 13px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.nav-stack i {
    width: 20px;
    text-align: center;
    flex: 0 0 20px;
}
.nav-stack a.active,
.nav-stack a:hover {
    color: #fff;
    background: rgba(255,255,255,.11);
    border-color: rgba(255,255,255,.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.nav-stack a:hover {
    transform: translateX(2px);
}
.nav-stack a[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.sidebar-foot {
    margin-top: auto;
    color: rgba(255,255,255,.58);
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
}

.app-main { min-width: 0; }
.topbar {
    height: 62px;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255,255,255,.55);
    background: rgba(255,255,255,.66);
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 5;
}
body[data-theme="dark"] .topbar {
    border-bottom-color: rgba(154,170,190,.14);
    background: rgba(11,17,28,.78);
}
.topbar-title {
    flex: 1;
    display: grid;
}
.topbar-title span {
    font-weight: 800;
    font-size: 1.02rem;
}
.topbar-title small { color: var(--muted); }

.icon-button {
    display: grid;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 12px;
    background: rgba(255,255,255,.78);
    place-items: center;
    padding: 10px;
    box-shadow: 0 12px 28px rgba(16,23,34,.08);
}
body[data-theme="dark"] .icon-button {
    border-color: rgba(154,170,190,.18);
    background: rgba(18,27,42,.82);
    box-shadow: 0 12px 28px rgba(0,0,0,.22);
}
.icon-button i { color: var(--ink); }
[data-sidebar-toggle] { display: none; }
.collapse-button { display: grid; }
body.sidebar-collapsed .collapse-button i,
html.sidebar-collapsed-preset .collapse-button i { transform: rotate(180deg); }

.content-wrap {
    padding: 20px 28px 28px;
    max-width: 1440px;
    margin: 0 auto;
}
.flash-stack {
    position: fixed;
    top: 74px;
    right: 18px;
    z-index: 1080;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 36px));
    pointer-events: none;
}
.flash-stack .alert {
    margin: 0;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
    border: 1px solid rgba(255,255,255,.72);
    overflow-wrap: anywhere;
    pointer-events: auto;
}
.page-head {
    margin-bottom: 24px;
    padding: 20px;
    border: 1px solid rgba(255,255,255,.62);
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.82), rgba(255,255,255,.58)),
        linear-gradient(135deg, rgba(0,168,120,.08), rgba(36,107,254,.08));
    box-shadow: var(--shadow);
}
body[data-theme="dark"] .page-head {
    border-color: rgba(154,170,190,.16);
    background:
        linear-gradient(135deg, rgba(18,27,42,.86), rgba(18,27,42,.70)),
        linear-gradient(135deg, rgba(39,216,161,.10), rgba(106,162,255,.10));
}
.section-title,
.device-row,
.device-actions,
.topbar-live,
.live-tools,
.live-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.eyebrow {
    margin: 0 0 4px;
    color: var(--accent-2);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 {
    font-size: clamp(2rem, 4vw, 3.1rem);
    font-weight: 850;
    line-height: 1;
}
h2 {
    font-size: 1.1rem;
    font-weight: 800;
}

.btn {
    border-radius: 12px;
    font-weight: 750;
    letter-spacing: 0;
}
.btn-primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    box-shadow: 0 14px 30px rgba(0, 168, 120, .24);
}
.btn-primary:hover {
    border-color: transparent;
    filter: brightness(.96);
}
.btn-dark {
    border-color: transparent;
    background: linear-gradient(135deg, #162033, #243b63);
    box-shadow: 0 12px 26px rgba(22, 32, 51, .16);
}
body[data-theme="dark"] .control-card .btn-dark,
body[data-theme="dark"] .device-actions .btn-dark {
    --bs-btn-focus-shadow-rgb: 0, 0, 0;
    border-color: transparent;
    background: linear-gradient(180deg, #253d68, #17243c);
    box-shadow: none;
    color: #f8fbff;
}
body[data-theme="dark"] .control-card .btn-dark:hover,
body[data-theme="dark"] .device-actions .btn-dark:hover,
body[data-theme="dark"] .control-card .btn-dark:focus,
body[data-theme="dark"] .device-actions .btn-dark:focus,
body[data-theme="dark"] .control-card .btn-dark:focus-visible,
body[data-theme="dark"] .device-actions .btn-dark:focus-visible,
body[data-theme="dark"] .control-card .btn-dark:active,
body[data-theme="dark"] .device-actions .btn-dark:active {
    border-color: transparent;
    background: linear-gradient(180deg, #2b4778, #1b2c49);
    box-shadow: none;
    outline: none;
}
body[data-theme="dark"] .control-card .btn-dark::before,
body[data-theme="dark"] .device-actions .btn-dark::before {
    display: none;
}
.btn-outline-dark,
.btn-outline-secondary {
    border-color: rgba(100,115,134,.26);
    background: rgba(255,255,255,.62);
    color: var(--ink);
}
body[data-theme="dark"] .btn-outline-dark,
body[data-theme="dark"] .btn-outline-secondary {
    border-color: rgba(154,170,190,.24);
    background: rgba(18,27,42,.76);
    color: var(--ink);
}
.btn-outline-dark:hover,
.btn-outline-secondary:hover {
    background: #101722;
    border-color: #101722;
}
body[data-theme="dark"] .btn-outline-dark:hover,
body[data-theme="dark"] .btn-outline-secondary:hover {
    background: rgba(238,245,255,.12);
    border-color: rgba(238,245,255,.22);
}
.form-control,
.form-select {
    border-radius: 12px;
    border-color: rgba(100,115,134,.22);
    background-color: rgba(255,255,255,.78);
}
body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select {
    border-color: rgba(154,170,190,.22);
    background-color: rgba(18,27,42,.86);
    color: var(--ink);
}
body[data-theme="dark"] .form-control::placeholder {
    color: rgba(154,170,190,.68);
}
body[data-theme="dark"] .table {
    --bs-table-color: var(--ink);
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(154,170,190,.12);
    --bs-table-striped-color: var(--ink);
    --bs-table-hover-color: var(--ink);
}
.form-control:focus,
.form-select:focus {
    border-color: rgba(0,163,255,.62);
    box-shadow: 0 0 0 .22rem rgba(0,163,255,.14);
}

.topbar-live,
.live-tools {
    justify-content: flex-end;
    flex-wrap: wrap;
}
.topbar-live {
    gap: 10px;
}
.topbar-live form {
    margin: 0;
}
.topbar > form {
    margin: 0;
}
.theme-toggle {
    width: 38px;
    height: 38px;
}
.live-pill {
    justify-content: flex-start;
    gap: 8px;
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid rgba(0,168,120,.18);
    border-radius: 999px;
    background: rgba(255,255,255,.78);
    color: var(--muted);
}
body[data-theme="dark"] .live-pill {
    border-color: rgba(39,216,161,.22);
    background: rgba(18,27,42,.78);
}
.live-pill i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(0,168,120,.12), 0 0 18px rgba(0,168,120,.6);
}
.live-pill b {
    color: var(--ink);
    font-size: .86rem;
}
.live-pill small {
    font-size: .78rem;
}
.live-pill[data-state="error"] i {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(180,35,24,.12);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}
.dashboard-section {
    min-width: 0;
}
.dashboard-section.width-full { grid-column: span 12; }
.dashboard-section.width-three-quarter,
.dashboard-section.width-wide { grid-column: span 9; }
.dashboard-section.width-half { grid-column: span 6; }
.dashboard-section.width-quarter { grid-column: span 3; }
.dashboard-section.width-third { grid-column: span 4; }
.dashboard-section .metric-grid,
.dashboard-section .safety-band {
    margin-bottom: 0;
}
.metric,
.device-list,
.sensor-tile,
.login-card,
.settings-panel,
.safety-band {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
body[data-theme="dark"] .metric,
body[data-theme="dark"] .device-list,
body[data-theme="dark"] .sensor-tile,
body[data-theme="dark"] .login-card,
body[data-theme="dark"] .settings-panel,
body[data-theme="dark"] .safety-band {
    border-color: rgba(154,170,190,.16);
}
.control-box {
    padding: 16px;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.88), rgba(255,255,255,.70)),
        linear-gradient(135deg, rgba(36,107,254,.10), rgba(0,168,120,.08));
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
body[data-theme="dark"] .control-box {
    border-color: rgba(154,170,190,.16);
    background:
        linear-gradient(135deg, rgba(18,27,42,.92), rgba(18,27,42,.78)),
        linear-gradient(135deg, rgba(106,162,255,.12), rgba(39,216,161,.08));
}
.control-box-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: dense;
    grid-auto-rows: 8px;
    gap: 10px;
    align-items: start;
    contain: layout;
}
.control-box-grid > * {
    grid-column: span 3;
    min-width: 0;
}
.dashboard-section.width-three-quarter .control-box-grid > *,
.dashboard-section.width-wide .control-box-grid > * {
    grid-column: span 4;
}
.dashboard-section.width-half .control-box-grid > * {
    grid-column: span 6;
}
.dashboard-section.width-quarter .control-box-grid > *,
.dashboard-section.width-third .control-box-grid > *,
.control-box-grid > .empty-state {
    grid-column: 1 / -1;
}
.control-box-grid > :only-child {
    grid-column: 1 / -1;
}
.dashboard-section.width-full .control-box-grid > :last-child:nth-child(4n + 1):not(.app-security-card),
.dashboard-section.width-three-quarter .control-box-grid > :last-child:nth-child(3n + 1):not(.app-security-card),
.dashboard-section.width-wide .control-box-grid > :last-child:nth-child(3n + 1):not(.app-security-card),
.dashboard-section.width-half .control-box-grid > :last-child:nth-child(2n + 1):not(.app-security-card) {
    grid-column: 1 / -1;
}
.dashboard-section.width-full .control-box-grid > :nth-last-child(2):nth-child(4n + 1):not(.app-security-card),
.dashboard-section.width-full .control-box-grid > :nth-last-child(2):nth-child(4n + 1):not(.app-security-card) + :not(.app-security-card),
.dashboard-section.width-three-quarter .control-box-grid > :nth-last-child(2):nth-child(3n + 1):not(.app-security-card),
.dashboard-section.width-three-quarter .control-box-grid > :nth-last-child(2):nth-child(3n + 1):not(.app-security-card) + :not(.app-security-card),
.dashboard-section.width-wide .control-box-grid > :nth-last-child(2):nth-child(3n + 1):not(.app-security-card),
.dashboard-section.width-wide .control-box-grid > :nth-last-child(2):nth-child(3n + 1):not(.app-security-card) + :not(.app-security-card) {
    grid-column: span 6;
}
.dashboard-section.width-full .control-box-grid > .app-security-card {
    grid-column: span 3;
}
.dashboard-section.width-three-quarter .control-box-grid > .app-security-card,
.dashboard-section.width-wide .control-box-grid > .app-security-card {
    grid-column: span 4;
}
.dashboard-section.width-half .control-box-grid > .app-security-card {
    grid-column: span 6;
}
.dashboard-section.width-full .control-box-grid > .widget-span-1 {
    grid-column: span 3 !important;
}
.dashboard-section.width-full .control-box-grid > .widget-span-2 {
    grid-column: span 6 !important;
}
.dashboard-section.width-full .control-box-grid > .widget-span-3 {
    grid-column: span 9 !important;
}
.dashboard-section.width-full .control-box-grid > .widget-span-4,
.dashboard-section.width-full .control-box-grid > .widget-span-4:only-child {
    grid-column: 1 / -1 !important;
}
.dashboard-section.width-three-quarter .control-box-grid > .widget-span-1,
.dashboard-section.width-wide .control-box-grid > .widget-span-1 {
    grid-column: span 4 !important;
}
.dashboard-section.width-three-quarter .control-box-grid > .widget-span-2,
.dashboard-section.width-wide .control-box-grid > .widget-span-2 {
    grid-column: span 8 !important;
}
.dashboard-section.width-three-quarter .control-box-grid > .widget-span-3,
.dashboard-section.width-three-quarter .control-box-grid > .widget-span-4,
.dashboard-section.width-wide .control-box-grid > .widget-span-3,
.dashboard-section.width-wide .control-box-grid > .widget-span-4 {
    grid-column: 1 / -1 !important;
}
.dashboard-section.width-half .control-box-grid > .widget-span-1 {
    grid-column: span 6 !important;
}
.dashboard-section.width-half .control-box-grid > .widget-span-2,
.dashboard-section.width-half .control-box-grid > .widget-span-3,
.dashboard-section.width-half .control-box-grid > .widget-span-4,
.dashboard-section.width-quarter .control-box-grid > .widget-span-1,
.dashboard-section.width-quarter .control-box-grid > .widget-span-2,
.dashboard-section.width-quarter .control-box-grid > .widget-span-3,
.dashboard-section.width-quarter .control-box-grid > .widget-span-4,
.dashboard-section.width-third .control-box-grid > .widget-span-1,
.dashboard-section.width-third .control-box-grid > .widget-span-2,
.dashboard-section.width-third .control-box-grid > .widget-span-3,
.dashboard-section.width-third .control-box-grid > .widget-span-4 {
    grid-column: 1 / -1 !important;
}
.control-box-grid .thermostat-card {
    border: 0;
    border-radius: 16px;
    height: auto;
}
.control-box-grid .control-card,
.control-box-grid .sensor-tile {
    height: auto;
}
.control-card {
    position: relative;
    container-type: inline-size;
    display: grid;
    gap: 12px;
    padding: 13px 10px;
    border: 1px solid rgba(255,255,255,.70);
    border-radius: 14px;
    background: rgba(255,255,255,.68);
}
body[data-theme="dark"] .control-card {
    border-color: rgba(154,170,190,.15);
    background: rgba(15,23,37,.72);
}
.control-card.is-jammed,
.device-row.is-jammed {
    border-color: rgba(239,68,68,.42);
    background:
        linear-gradient(135deg, rgba(255,255,255,.78), rgba(255,255,255,.64)),
        linear-gradient(135deg, rgba(239,68,68,.18), rgba(245,158,11,.08));
}
body[data-theme="dark"] .control-card.is-jammed,
body[data-theme="dark"] .device-row.is-jammed {
    border-color: rgba(251,113,133,.42);
    background:
        linear-gradient(135deg, rgba(18,27,42,.86), rgba(18,27,42,.72)),
        linear-gradient(135deg, rgba(251,113,133,.22), rgba(251,191,36,.08));
}
.control-card.is-jammed {
    box-shadow: 0 16px 36px rgba(239,68,68,.14);
}
.app-security-card {
    gap: 9px;
    padding-block: 11px;
    border-color: rgba(36,107,254,.20);
    background:
        linear-gradient(135deg, rgba(255,255,255,.80), rgba(255,255,255,.68)),
        linear-gradient(135deg, rgba(36,107,254,.12), rgba(0,168,120,.08));
}
body[data-theme="dark"] .app-security-card {
    border-color: rgba(106,162,255,.24);
    background:
        linear-gradient(135deg, rgba(18,27,42,.86), rgba(18,27,42,.74)),
        linear-gradient(135deg, rgba(106,162,255,.14), rgba(39,216,161,.08));
}
.app-security-card.security-arm.is-active {
    border-color: rgba(239,68,68,.34);
    background:
        linear-gradient(135deg, rgba(255,255,255,.80), rgba(255,255,255,.66)),
        linear-gradient(135deg, rgba(239,68,68,.18), rgba(245,158,11,.08));
}
.app-security-card.security-disarm.is-active {
    border-color: rgba(16,185,129,.34);
}
.app-security-card .control-state-icon {
    color: #246bfe;
    background: rgba(36,107,254,.10);
}
.app-security-card.security-arm.is-active .control-state-icon {
    color: #ef4444;
    background: rgba(239,68,68,.12);
}
.security-mode-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--muted);
    background: rgba(15,23,42,.06);
    font-size: .72rem;
    font-weight: 850;
    line-height: 1;
    white-space: nowrap;
}
.device-row.is-jammed {
    box-shadow: inset 4px 0 0 rgba(239,68,68,.62);
}
.control-card > div {
    display: grid;
    gap: 5px;
    min-width: 0;
}
.control-icon-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    min-width: 0;
}
.control-icon-line.title-lock {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    row-gap: 8px;
    column-gap: 8px;
}
.control-icon-line.title-lock > .door-state-badge {
    justify-self: center;
    margin-inline: 0;
}
.control-icon-line.title-lock > .control-status-wrap {
    justify-self: end;
    margin-left: auto;
}
.control-icon-line.title-switch {
    display: flex;
    row-gap: 8px;
}
.control-icon-stack {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
}
.control-card .control-state-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--accent-2);
    background: rgba(36,107,254,.10);
}
.control-card strong,
.control-card small {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.control-card small {
    color: var(--muted);
}
.metric {
    min-height: 82px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-areas:
        "icon label"
        "icon value";
    column-gap: 13px;
    row-gap: 3px;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.metric.metric-alerts {
    overflow: visible;
    z-index: 2;
}
.metric.metric-alerts.is-open {
    z-index: 20;
}
.metric::after {
    display: none;
}
.metric > i,
.metric-icon-button {
    grid-area: icon;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    align-self: center;
    border-radius: 13px;
    color: var(--accent);
    background: linear-gradient(135deg, rgba(0,168,120,.16), rgba(0,163,255,.13));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
body[data-theme="dark"] .metric > i,
body[data-theme="dark"] .metric-icon-button {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.metric-icon-button {
    border: 0;
    padding: 0;
    cursor: pointer;
}
.metric-icon-button i {
    pointer-events: none;
}
.metric-icon-button:focus-visible {
    outline: 2px solid rgba(49, 130, 206, .38);
    outline-offset: 4px;
}
.metric span,
.section-title span,
.device-row small,
.sensor-tile span,
.sensor-tile small {
    color: var(--muted);
}
.metric span {
    grid-area: label;
    align-self: end;
    font-size: .82rem;
    font-weight: 750;
}
.metric strong {
    grid-area: value;
    align-self: start;
    font-size: 1.72rem;
    line-height: 1;
    font-weight: 850;
}
.metric.is-warn strong { color: var(--warn); }
.metric.is-danger strong { color: var(--danger); }
.metric.is-warn > i { color: var(--warn); background: rgba(245,158,11,.14); }
.metric.is-danger > i { color: var(--danger); background: rgba(239,68,68,.13); }
.metric.is-warn .metric-icon-button { color: var(--warn); background: rgba(245,158,11,.14); }
.metric.is-danger .metric-icon-button { color: var(--danger); background: rgba(239,68,68,.13); }
.alert-summary-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 50;
    width: min(360px, calc(100vw - 36px));
    padding: 12px;
    border: 1px solid rgba(239,68,68,.20);
    border-radius: 14px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 22px 54px rgba(15,23,42,.20);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
}
body[data-theme="dark"] .alert-summary-popover {
    border-color: rgba(251,113,133,.24);
    background: rgba(18,27,42,.98);
    box-shadow: 0 22px 54px rgba(0,0,0,.40);
}
.metric-alerts.is-open .alert-summary-popover {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.alert-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 2px 9px;
    border-bottom: 1px solid rgba(100,115,134,.14);
}
body[data-theme="dark"] .alert-summary-head {
    border-bottom-color: rgba(154,170,190,.14);
}
.alert-summary-head span {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.alert-summary-head strong {
    color: var(--danger);
    font-size: .82rem;
    line-height: 1;
}
.alert-summary-list {
    display: grid;
    gap: 7px;
    padding-top: 9px;
}
.alert-summary-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(239,68,68,.07);
}
body[data-theme="dark"] .alert-summary-item {
    background: rgba(251,113,133,.10);
}
.alert-summary-item > i,
.alert-summary-empty > i {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--danger);
    background: rgba(239,68,68,.12);
}
.alert-summary-item strong,
.alert-summary-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alert-summary-item strong {
    font-size: .86rem;
    line-height: 1.15;
}
.alert-summary-item small,
.alert-summary-more,
.alert-summary-empty span {
    color: var(--muted);
    font-size: .74rem;
    font-weight: 700;
}
.alert-summary-more {
    padding: 3px 8px 0;
}
.alert-summary-empty {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-top: 11px;
}
.control-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(7, 17, 31, .46);
    backdrop-filter: blur(10px);
}
.control-confirm-backdrop.is-open {
    display: flex;
}
.control-confirm-card {
    width: min(360px, 100%);
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 18px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 24px 70px rgba(7,17,31,.28);
    color: var(--ink);
}
body[data-theme="dark"] .control-confirm-card {
    border-color: rgba(154,170,190,.18);
    background: rgba(18,27,42,.98);
}
.control-confirm-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: var(--accent-2);
    background: rgba(36,107,254,.12);
}
.control-confirm-card strong {
    display: block;
    font-size: 1.05rem;
}
.control-confirm-card p {
    margin: 4px 0 0;
    color: var(--muted);
    line-height: 1.35;
}
.control-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 2px;
}
.control-confirm-actions .btn {
    min-height: 44px;
}

.safety-band {
    padding: 16px;
    margin-bottom: 16px;
}
.safety-band.clear {
    border-color: rgba(0,168,120,.24);
    background:
        linear-gradient(135deg, rgba(255,255,255,.88), rgba(255,255,255,.70)),
        linear-gradient(135deg, rgba(0,168,120,.10), rgba(0,163,255,.08));
}
body[data-theme="dark"] .safety-band.clear {
    border-color: rgba(39,216,161,.22);
    background:
        linear-gradient(135deg, rgba(18,27,42,.90), rgba(18,27,42,.72)),
        linear-gradient(135deg, rgba(39,216,161,.10), rgba(56,199,255,.08));
}
.safety-band.danger {
    border-color: rgba(239,68,68,.45);
    background:
        linear-gradient(135deg, rgba(255,255,255,.88), rgba(255,255,255,.70)),
        linear-gradient(135deg, rgba(239,68,68,.16), rgba(245,158,11,.10));
    box-shadow: 0 22px 64px rgba(239,68,68,.18);
}
body[data-theme="dark"] .safety-band.danger {
    border-color: rgba(251,113,133,.42);
    background:
        linear-gradient(135deg, rgba(18,27,42,.90), rgba(18,27,42,.72)),
        linear-gradient(135deg, rgba(251,113,133,.16), rgba(251,191,36,.08));
}
.safety-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.safety-head h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}
.dashboard-section.width-quarter .safety-head,
.dashboard-section.width-third .safety-head {
    display: grid;
    gap: 7px;
}
.dashboard-section.width-quarter .safety-head h2,
.dashboard-section.width-third .safety-head h2 {
    font-size: .98rem;
}
.dashboard-section.width-quarter .safety-head .eyebrow,
.dashboard-section.width-third .safety-head .eyebrow {
    display: none;
}
.safety-head h2 i { color: var(--accent); }
.safety-band.danger .safety-head h2 i { color: var(--danger); }
.safety-head > span {
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(0,168,120,.12);
    color: var(--accent);
    font-weight: 800;
    font-size: .78rem;
    white-space: nowrap;
}
.safety-band.danger .safety-head > span {
    background: rgba(239,68,68,.12);
    color: var(--danger);
}
.safety-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.safety-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid rgba(255,255,255,.70);
    border-radius: 14px;
    background: rgba(255,255,255,.66);
}
body[data-theme="dark"] .safety-card {
    border-color: rgba(154,170,190,.15);
    background: rgba(15,23,37,.72);
}
.safety-card-compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 10px;
}
.safety-card-compact strong {
    align-self: center;
    min-width: 0;
    font-size: .88rem;
    overflow-wrap: anywhere;
    white-space: normal;
}
.safety-icons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.safety-status {
    display: inline-grid;
    justify-items: center;
    gap: 3px;
    min-width: 30px;
}
.safety-status small {
    color: var(--muted);
    font-size: .56rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: .04em;
}
.safety-icons i {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(0,168,120,.12);
    color: var(--accent);
    font-size: .82rem;
}
.safety-icons .safety-state-on {
    background: rgba(239,68,68,.13);
    color: var(--danger);
    box-shadow: 0 10px 22px rgba(239,68,68,.13);
}
.safety-icons .safety-state-missing {
    background: rgba(100,115,134,.10);
    color: rgba(100,115,134,.48);
}
.safety-card > i {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(0,168,120,.12);
    color: var(--accent);
    flex: 0 0 42px;
}
.safety-card.active {
    border-color: rgba(239,68,68,.45);
    background: rgba(255,248,247,.78);
}
body[data-theme="dark"] .safety-card.active {
    background: rgba(251,113,133,.12);
}
.safety-card.active > i {
    background: rgba(239,68,68,.12);
    color: var(--danger);
}
.safety-card div {
    min-width: 0;
    display: grid;
}
.safety-card strong,
.safety-card small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.safety-card-compact strong {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}
.safety-card small { color: var(--muted); }

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
    gap: 26px;
}
.section-title {
    margin-bottom: 12px;
    padding-inline: 4px;
}
.device-list {
    overflow: hidden;
    padding: 16px;
}
.thermostat-card {
    position: relative;
    isolation: isolate;
    container-type: inline-size;
    padding: 0;
    border-bottom: 0;
    overflow: visible;
    background: transparent;
    color: #f8fbff;
}
.battery-pill {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 24px;
    background: transparent;
    border: 2px solid currentColor;
    border-radius: 5px;
    filter: drop-shadow(0 7px 12px rgba(16,23,34,.16));
    vertical-align: middle;
    line-height: 1;
}
.battery-pill::after {
    content: "";
    position: absolute;
    right: -5px;
    top: 7px;
    width: 4px;
    height: 8px;
    border-radius: 0 3px 3px 0;
    background: currentColor;
}
.battery-pill b {
    display: block;
    position: static;
    z-index: 1;
    color: currentColor;
    font-size: 9.5px;
    font-weight: 950;
    line-height: 1;
    letter-spacing: 0;
    text-shadow: none;
    transform: translateY(0.5px);
}
.battery-pill.battery-good { color: #10b981; }
.battery-pill.battery-warn { color: #f59e0b; }
.battery-pill.battery-low { color: #ef4444; }
.device-row {
    position: relative;
}
.device-row.has-battery {
    padding-right: 17px;
}
.control-card.has-battery {
    padding-top: 13px;
}
.thermostat-card.has-battery {
    padding-bottom: 0;
}
.thermostat-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}
.thermostat-glow {
    display: none;
}
.thermostat-summary,
.thermostat-actions,
.thermostat-actions form,
.thermostat-meta,
.linked-sensors {
    display: flex;
    align-items: center;
    gap: 10px;
}
.thermostat-summary {
    justify-content: space-between;
    position: relative;
    z-index: 1;
    gap: 18px;
}
.thermostat-summary > div:first-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.thermostat-summary strong {
    display: flex;
    align-items: center;
    gap: 9px;
}
.thermostat-summary strong i {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #7dd3fc;
    background: rgba(255,255,255,.12);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.thermostat-summary small,
.thermostat-meta,
.linked-sensors {
    color: rgba(232,240,252,.72);
}
.thermostat-temp {
    text-align: right;
    min-width: 120px;
}
.thermostat-temp-main {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    white-space: nowrap;
}
.thermostat-current-temp {
    display: block;
    color: #ffffff;
    font-size: 2.7rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0;
    text-shadow: 0 12px 30px rgba(0,0,0,.25);
}
.thermostat-temp-main .battery-pill {
    flex: 0 0 auto;
}
.thermostat-temp small {
    display: block;
    margin-top: 4px;
    color: rgba(232,240,252,.78);
    font-weight: 700;
}
.thermostat-meta {
    flex-wrap: wrap;
    margin-top: 16px;
    font-size: .88rem;
    position: relative;
    z-index: 1;
}
.thermostat-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    border-radius: 999px;
    color: rgba(248,251,255,.88);
    background: rgba(255,255,255,.10);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
}
.thermostat-chip i {
    color: #67e8f9;
}
.thermostat-chip.chip-action {
    background: rgba(16,185,129,.18);
}
.thermostat-chip.chip-action i {
    color: #86efac;
}
.thermostat-chip.action-heating,
.thermostat-chip.action-heat {
    color: #fff7ed;
    background: rgba(239,68,68,.24);
    box-shadow: inset 0 0 0 1px rgba(252,165,165,.28), 0 10px 26px rgba(239,68,68,.16);
}
.thermostat-chip.action-heating i,
.thermostat-chip.action-heat i {
    color: #fb7185;
}
.thermostat-chip.action-cooling,
.thermostat-chip.action-cool {
    color: #eff6ff;
    background: rgba(59,130,246,.22);
}
.thermostat-chip.action-cooling i,
.thermostat-chip.action-cool i {
    color: #93c5fd;
}
.thermostat-actions {
    flex-wrap: wrap;
    margin-top: 16px;
    position: relative;
    z-index: 1;
}
.thermostat-actions form {
    flex-wrap: wrap;
    padding: 11px;
    border-radius: 16px;
    background: rgba(255,255,255,.11);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.thermostat-actions .thermostat-control-form {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(190px, auto) auto;
    align-items: center;
    justify-content: start;
    gap: 12px;
}
.thermostat-control-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr);
    gap: 10px;
    align-items: center;
    justify-items: center;
}
.thermostat-dial {
    --dial-track: rgba(255,255,255,.14);
    --dial-fill: #10b981;
    --dial-angle: 90deg;
    --arc-top: 14px;
    --arc-height: 116px;
    --arc-thickness-inner: 54%;
    --arc-thickness-outer: 82%;
    position: relative;
    width: min(100%, 270px);
    min-height: 184px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: 1fr 38px;
    align-items: center;
    justify-self: center;
    padding: 8px 12px 0;
    border-radius: 18px;
    background: rgba(17,24,39,.94);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 14px 34px rgba(0,0,0,.18);
    touch-action: none;
    user-select: none;
    overflow: hidden;
}
.thermostat-dial-arc {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 8px;
    width: calc(100% - 24px);
    height: 132px;
    overflow: visible;
    pointer-events: none;
    filter: drop-shadow(0 9px 16px rgba(0,0,0,.18));
}
.thermostat-dial-track,
.thermostat-dial-fill {
    fill: none;
    stroke-linecap: round;
    stroke-width: 16;
}
.thermostat-dial-track {
    stroke: var(--dial-track);
}
.thermostat-dial-fill {
    stroke: var(--dial-fill);
    filter: drop-shadow(0 0 9px rgba(16,185,129,.32));
}
.thermostat-dial-knob {
    fill: rgba(255,255,255,.72);
    stroke: rgba(255,255,255,.82);
    stroke-width: 1.3;
    filter:
        drop-shadow(0 0 3px rgba(17,24,39,.95))
        drop-shadow(0 0 7px rgba(16,185,129,.34))
        drop-shadow(0 5px 8px rgba(0,0,0,.34));
}
.thermostat-dial-status,
.thermostat-dial-readouts {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    position: relative;
    z-index: 1;
}
.thermostat-dial-status {
    padding-top: 0;
    color: rgba(248,251,255,.88);
    font-size: .72rem;
    font-weight: 850;
}
.thermostat-dial-status i {
    color: #67e8f9;
}
.thermostat-dial-status.action-heating i,
.thermostat-dial-status.action-heat i {
    color: #fb7185;
}
.thermostat-dial-status.action-cooling i,
.thermostat-dial-status.action-cool i {
    color: #93c5fd;
}
.thermostat-dial-readouts {
    flex-wrap: wrap;
    max-width: 100%;
    justify-self: center;
    color: rgba(232,240,252,.72);
    font-size: .66rem;
    padding-top: 1px;
}
.thermostat-dial-readouts span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}
.thermostat-dial-readouts .battery-pill {
    width: 34px;
    height: 18px;
}
.thermostat-dial-readouts .battery-pill::after {
    top: 4px;
    height: 6px;
}
.thermostat-dial-readouts .battery-pill b {
    font-size: 7.5px;
}
.thermostat-dial-button,
.thermostat-mode-button {
    border: 0;
    color: #f8fbff;
    background: rgba(255,255,255,.12);
}
.thermostat-dial-button {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
    position: absolute;
    z-index: 2;
    top: 138px;
}
.thermostat-dial-button[data-temp-step="-1"] {
    left: 7.5%;
}
.thermostat-dial-button[data-temp-step="1"] {
    right: 7.5%;
}
.thermostat-dial-button:hover,
.thermostat-mode-button:hover {
    background: rgba(255,255,255,.20);
}
.thermostat-dial-center {
    grid-column: 1 / -1;
    grid-row: 1 / 3;
    display: grid;
    justify-items: center;
    gap: 3px;
    text-align: center;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    justify-self: center;
    position: relative;
    z-index: 1;
    align-self: end;
    padding: 44px 24px 14px;
}
.thermostat-dial-label {
    color: rgba(232,240,252,.66);
    font-size: .7rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.thermostat-dial-center strong {
    color: #fff;
    font-size: 1.48rem;
    line-height: 1;
    font-weight: 850;
}
.thermostat-dial-center small {
    color: rgba(232,240,252,.72);
    font-size: .78rem;
    font-weight: 750;
}
.thermostat-mode-buttons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    max-width: 100%;
    flex-wrap: wrap;
    margin-top: 1px;
}
.thermostat-mode-button {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.thermostat-mode-button.active {
    color: #101722;
    background: #f8fbff;
}
.thermostat-mode-button.mode-heat.active {
    color: #fff7ed;
    background: #ef4444;
}
.thermostat-mode-button.mode-cool.active {
    color: #eff6ff;
    background: #2563eb;
}
.thermostat-mode-button.mode-off.active {
    color: #e5e7eb;
    background: #475569;
}
.thermostat-apply-button {
    width: min(176px, 100%);
    max-width: 100%;
    min-height: 30px;
    padding: 4px 10px;
    justify-self: center;
    justify-content: center;
    margin-top: 10px;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 999px;
    color: #0f172a;
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(225,245,239,.94));
    font-size: .74rem;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(16,185,129,.18), inset 0 1px 0 rgba(255,255,255,.9);
}
.thermostat-apply-button:hover,
.thermostat-apply-button:focus {
    color: #052e2b;
    background: linear-gradient(180deg, #ffffff, rgba(187,247,208,.96));
    border-color: rgba(187,247,208,.95);
}
@container (max-width: 430px) {
    .thermostat-control-form {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .thermostat-dial {
        width: min(280px, 100%);
    }
    .thermostat-apply-button {
        width: min(176px, 100%);
        max-width: 100%;
    }
}
@container (min-width: 260px) {
    .thermostat-dial-button[data-temp-step="-1"] {
        left: 28px;
    }
    .thermostat-dial-button[data-temp-step="1"] {
        right: 28px;
    }
}
.thermostat-actions input[type="number"] {
    width: 96px;
}
.thermostat-actions select {
    width: 148px;
}
.thermostat-actions .form-control,
.thermostat-actions .form-select {
    border-color: rgba(255,255,255,.16);
    background-color: rgba(255,255,255,.94);
    font-weight: 700;
}
.thermostat-actions .btn-dark {
    background: #10b981;
    border-color: #10b981;
    font-weight: 800;
}
.thermostat-actions .btn-outline-dark {
    color: #f8fbff;
    border-color: rgba(255,255,255,.36);
    background: rgba(255,255,255,.08);
}
.linked-sensors {
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.14);
    font-size: .86rem;
    position: relative;
    z-index: 1;
}
.linked-sensors span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    border-radius: 14px;
    background: rgba(255,255,255,.10);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.linked-sensors span i {
    color: #67e8f9;
}
.linked-sensors small {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.linked-sensors b {
    color: #ffffff;
}
.device-row {
    padding: 17px;
    border-bottom: 1px solid rgba(108,125,148,.16);
    transition: background .16s ease;
}
.device-row:hover { background: rgba(36,107,254,.035); }
.device-row:last-child { border-bottom: 0; }
.device-row > div:first-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.device-row strong {
    display: block;
}
.control-title-line {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    width: 100%;
}
.control-title-line.title-lock {
    display: flex;
    flex-wrap: wrap;
    row-gap: 8px;
}
.control-title-line.title-lock > .door-state-badge {
    margin-inline: auto;
}
.control-title-line.title-switch {
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
}
.control-status-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.control-status-wrap.status-lock {
    margin-left: auto;
}
.control-status-wrap.status-switch {
    margin-left: auto;
}
@container (max-width: 205px) {
    .control-icon-line.title-lock {
        grid-template-columns: 38px minmax(0, 1fr);
    }
    .control-icon-line.title-lock > .control-icon-stack {
        grid-column: 1;
        grid-row: 1;
    }
    .control-icon-line.title-lock > .door-state-badge {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
        margin-inline: 0;
    }
    .control-icon-line.title-lock > .control-status-wrap.status-lock {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
        justify-self: start;
        margin-left: 0;
    }
}
.control-name-wrap {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex: 1 1 180px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.control-title-line.title-lock .control-name-wrap {
    flex: 1 1 160px;
}
.control-title-line.title-lock > .door-state-badge,
.control-title-line.title-switch > .door-state-badge,
.control-icon-line.title-lock > .door-state-badge,
.control-icon-line.title-switch > .door-state-badge {
    flex: 0 1 auto;
}
.door-state-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 10px;
    font-size: .78rem;
    font-weight: 850;
    line-height: 1;
    flex: 0 0 auto;
}
.door-state-badge i {
    width: 18px;
    text-align: center;
}
.door-state-badge .battery-pill {
    width: 34px;
    height: 18px;
    margin-left: 1px;
}
.door-state-badge .battery-pill::after {
    right: -4px;
    top: 5px;
    width: 3px;
    height: 7px;
}
.door-state-badge .battery-pill b {
    font-size: 7.5px;
}
.door-state-badge.door-open {
    color: #b91c1c;
    background: rgba(239,68,68,.12);
}
.door-state-badge.door-jammed {
    color: #b91c1c;
    background: rgba(239,68,68,.16);
    box-shadow: 0 10px 22px rgba(239,68,68,.12);
}
.door-state-badge.door-closed {
    color: #0369a1;
    background: rgba(14,165,233,.12);
}
.door-state-badge.parent-switch.door-closed {
    color: #0369a1;
    background: rgba(14,165,233,.12);
}
.door-state-badge.parent-switch.door-open {
    color: #b91c1c;
    background: rgba(239,68,68,.12);
}
.device-row strong .battery-pill {
    flex: 0 0 auto;
}
.device-row strong .control-state-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--accent-2);
    background: rgba(36,107,254,.10);
}
.control-state-icon.control-state-locked,
.control-state-icon.control-state-off,
.control-state-icon.control-state-closed {
    color: #059669;
    background: rgba(16,185,129,.12);
}
.control-state-icon.control-state-unlocked,
.control-state-icon.control-state-on,
.control-state-icon.control-state-open {
    color: #dc2626;
    background: rgba(239,68,68,.12);
}
.control-card .control-state-icon.control-state-unlocked,
.control-card .control-state-icon.control-state-on,
.control-card .control-state-icon.control-state-open {
    box-shadow: 0 12px 28px rgba(239,68,68,.14);
}
.control-state-icon[data-last-updated] {
    cursor: pointer;
}
.control-state-icon[data-last-updated]:focus-visible {
    outline: 2px solid rgba(49, 130, 206, .38);
    outline-offset: 4px;
    border-radius: 999px;
}
.last-updated-popup {
    position: absolute;
    z-index: 9999;
    min-width: 178px;
    max-width: min(260px, calc(100vw - 20px));
    padding: 9px 11px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 10px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 16px 38px rgba(15, 23, 42, .18);
    color: var(--ink);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .14s ease, transform .14s ease;
    pointer-events: none;
}
body[data-theme="dark"] .last-updated-popup {
    border-color: rgba(154,170,190,.18);
    background: rgba(18,27,42,.98);
    box-shadow: 0 16px 38px rgba(0,0,0,.38);
}
.last-updated-popup.show {
    opacity: 1;
    transform: translateY(0);
}
.last-updated-popup span {
    display: block;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.last-updated-popup strong {
    display: block;
    margin-top: 2px;
    font-size: .82rem;
    line-height: 1.25;
}
.device-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.state-pill {
    min-width: 84px;
    text-align: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(100,115,134,.10);
    color: #34403c;
    font-weight: 700;
    font-size: .82rem;
}
body[data-theme="dark"] .state-pill {
    color: var(--ink);
    background: rgba(154,170,190,.12);
}
.state-on,
.state-unlocked,
.state-open { background: rgba(245,158,11,.14); color: #a16207; }
.state-locked,
.state-off,
.state-closed { background: rgba(0,168,120,.12); color: #047857; }
.state-heat,
.state-cool,
.state-heat_cool,
.state-auto { background: rgba(36,107,254,.12); color: #1d4ed8; }

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.sensor-tile {
    padding: 16px;
    display: grid;
    gap: 10px;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.sensor-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 46px rgba(16,23,34,.12);
}
body[data-theme="dark"] .sensor-tile:hover {
    box-shadow: 0 18px 46px rgba(0,0,0,.24);
}
.sensor-tile strong {
    min-height: 44px;
}
.sensor-tile em {
    color: var(--muted);
    font-style: normal;
    font-size: .86rem;
}
.sensor-tile div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.sensor-tile.attention {
    border-color: rgba(245,158,11,.45);
}
.sensor-tile.type-smoke,
.sensor-tile.type-co,
.sensor-tile.type-power {
    border-color: rgba(0,168,120,.24);
}
.sensor-tile.type-smoke.attention,
.sensor-tile.type-co.attention,
.sensor-tile.type-power.attention {
    border-color: rgba(239,68,68,.52);
    background: rgba(255,248,247,.84);
}
body[data-theme="dark"] .sensor-tile.type-smoke.attention,
body[data-theme="dark"] .sensor-tile.type-co.attention,
body[data-theme="dark"] .sensor-tile.type-power.attention {
    background: rgba(251,113,133,.12);
}
.sensor-tile.type-temperature {
    position: relative;
    overflow: hidden;
    gap: 7px;
    padding: 13px 14px;
    border-color: rgba(36,107,254,.20);
    background:
        linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,255,255,.78)),
        radial-gradient(circle at 18% 20%, rgba(36,107,254,.15), transparent 38%),
        radial-gradient(circle at 88% 0%, rgba(0,168,120,.13), transparent 34%);
}
body[data-theme="dark"] .sensor-tile.type-temperature {
    border-color: rgba(106,162,255,.22);
    background:
        linear-gradient(135deg, rgba(18,27,42,.94), rgba(18,27,42,.80)),
        radial-gradient(circle at 18% 20%, rgba(106,162,255,.18), transparent 38%),
        radial-gradient(circle at 88% 0%, rgba(39,216,161,.11), transparent 34%);
}
.sensor-tile.type-temperature strong {
    min-height: 0;
    margin-top: -1px;
    line-height: 1.08;
}
.temperature-card-head,
.temperature-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.temperature-card-head span {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.temperature-card-head .battery-pill {
    flex: 0 0 auto;
    transform: scale(.86);
    transform-origin: right center;
}
.temperature-reading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-top: -2px;
}
.temperature-reading b {
    color: var(--text);
    font-size: clamp(2rem, 4.6vw, 2.75rem);
    font-weight: 950;
    line-height: .9;
}
.temperature-reading sup {
    top: -.65em;
    color: var(--muted);
    font-size: .36em;
    font-weight: 900;
    margin-left: 2px;
}
.temperature-reading span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(0,168,120,.11);
    color: #047857;
    font-size: .86rem;
    font-weight: 900;
}
body[data-theme="dark"] .temperature-reading span {
    background: rgba(39,216,161,.13);
    color: #7ddfbd;
}
.temperature-card-foot small {
    color: var(--muted);
    font-weight: 700;
}
.empty-state {
    margin: 0;
    padding: 18px;
    color: var(--muted);
}

.settings-panel {
    padding: 20px;
    padding-bottom: 118px;
    backdrop-filter: none;
}
.section-layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin: 16px 0 6px;
    overflow: hidden;
    border: 1px solid rgba(35, 42, 58, .08);
    border-radius: 14px;
    background: rgba(255,255,255,.62);
    box-shadow: 0 18px 48px rgba(29, 40, 63, .08);
}
body[data-theme="dark"] .section-layout-grid {
    border-color: rgba(154,170,190,.14);
    background: rgba(18,27,42,.72);
    box-shadow: 0 18px 48px rgba(0,0,0,.22);
}
.section-layout-head,
.layout-card {
    display: grid;
    grid-template-columns: 54px minmax(180px, 1fr) minmax(180px, .9fr) 96px minmax(145px, .55fr);
    align-items: center;
    gap: 10px;
}
.section-layout-head {
    padding: 11px 14px 9px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .06em;
    text-transform: uppercase;
    background: rgba(248,250,252,.72);
    border-bottom: 1px solid rgba(35, 42, 58, .08);
}
body[data-theme="dark"] .section-layout-head {
    background: rgba(15,23,37,.82);
    border-bottom-color: rgba(154,170,190,.12);
}
.layout-card {
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid rgba(35, 42, 58, .07);
    border-radius: 0;
    background: transparent;
}
body[data-theme="dark"] .layout-card {
    border-bottom-color: rgba(154,170,190,.10);
}
.layout-card:last-child {
    border-bottom: 0;
}
.layout-card:hover {
    background: rgba(255,255,255,.54);
}
body[data-theme="dark"] .layout-card:hover {
    background: rgba(106,162,255,.08);
}
.layout-card > div {
    min-width: 0;
    display: grid;
}
.layout-card label:not(.switch) {
    min-width: 0;
}
.layout-card label:not(.switch) .form-control,
.layout-card label:not(.switch) .form-select {
    width: 100%;
}
.layout-card .switch {
    justify-self: start;
}
.layout-card small {
    color: var(--muted);
}
.layout-name-empty {
    min-height: 31px;
    align-content: center;
}
.layout-card label:not(.switch) span {
    display: none;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.settings-divider {
    margin: 22px 0;
    border-color: rgba(108,125,148,.22);
}
.settings-intro,
.entity-filter-row,
.sticky-save {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
body[data-theme="dark"] .sticky-save {
    border-top-color: rgba(154,170,190,.18);
    background:
        linear-gradient(135deg, rgba(18,27,42,.94), rgba(18,27,42,.82)),
        linear-gradient(135deg, rgba(106,162,255,.12), rgba(39,216,161,.10));
    box-shadow: 0 -14px 42px rgba(0,0,0,.26), 0 18px 44px rgba(0,0,0,.20);
}
.settings-intro p {
    margin: 6px 0 0;
    color: var(--muted);
}
.settings-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.vpn-setup-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid rgba(217,119,6,.26);
    border-radius: 8px;
    background: rgba(255,251,235,.92);
    color: #92400e;
    box-shadow: 0 14px 34px rgba(146,64,14,.08);
}
body[data-theme="dark"] .vpn-setup-alert {
    border-color: rgba(251,191,36,.24);
    background: rgba(69,45,12,.55);
    color: #fde68a;
}
.vpn-setup-alert i {
    margin-top: 3px;
    font-size: 18px;
}
.vpn-setup-alert div {
    display: grid;
    gap: 3px;
}
.vpn-setup-alert span {
    font-size: 13px;
    color: currentColor;
    opacity: .88;
}
.page-heading p.text-muted,
.page-heading .text-muted.mb-0,
.vpn-card .settings-intro p,
.vpn-progress-panel .settings-intro p {
    color: #405063 !important;
}
body[data-theme="dark"] .page-heading p.text-muted,
body[data-theme="dark"] .page-heading .text-muted.mb-0,
body[data-theme="dark"] .vpn-card .settings-intro p,
body[data-theme="dark"] .vpn-progress-panel .settings-intro p {
    color: #c8d3e1 !important;
}
.vpn-setup-hero .eyebrow,
.vpn-card .settings-intro h2,
.vpn-progress-panel .settings-intro h2 {
    color: var(--ink);
}
body[data-theme="dark"] .vpn-setup-hero .eyebrow,
body[data-theme="dark"] .vpn-card .settings-intro h2,
body[data-theme="dark"] .vpn-progress-panel .settings-intro h2 {
    color: #f3f7fb;
}
.vpn-setup-hero {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid rgba(18,32,49,.09);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(25,118,210,.12), rgba(22,163,74,.08)),
        rgba(255,255,255,.82);
    box-shadow: 0 18px 44px rgba(29,44,62,.08);
}
body[data-theme="dark"] .vpn-setup-hero {
    border-color: rgba(154,170,190,.16);
    background:
        linear-gradient(135deg, rgba(37,99,235,.18), rgba(20,184,166,.1)),
        rgba(18,27,42,.76);
}
.vpn-hero-main {
    display: flex;
    gap: 14px;
    min-width: 0;
}
.vpn-hero-icon {
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(25,118,210,.14);
    color: var(--primary);
    font-size: 22px;
}
body[data-theme="dark"] .vpn-hero-icon {
    background: rgba(96,165,250,.16);
}
.vpn-hero-main h2 {
    margin: 0 0 6px;
    font-size: 24px;
    letter-spacing: 0;
}
.vpn-hero-main p:last-child {
    max-width: 720px;
    margin: 0;
    color: #405063;
}
body[data-theme="dark"] .vpn-hero-main p:last-child {
    color: #c8d3e1;
}
.vpn-hero-status {
    display: grid;
    align-content: center;
    justify-items: end;
    min-width: 188px;
    padding: 12px 14px;
    border: 1px solid rgba(126,139,155,.18);
    border-radius: 8px;
    background: rgba(255,255,255,.68);
}
body[data-theme="dark"] .vpn-hero-status {
    background: rgba(15,23,42,.52);
}
.vpn-hero-status span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.vpn-hero-status strong {
    margin-top: 4px;
    font-size: 16px;
    overflow-wrap: anywhere;
}
.vpn-hero-status.is-ready strong,
.vpn-pill.is-ready {
    color: #15803d;
}
body[data-theme="dark"] .vpn-hero-status.is-ready strong,
body[data-theme="dark"] .vpn-pill.is-ready {
    color: #86efac;
}
.vpn-hero-status.is-pending strong,
.vpn-pill.is-pending {
    color: #b45309;
}
body[data-theme="dark"] .vpn-hero-status.is-pending strong,
body[data-theme="dark"] .vpn-pill.is-pending {
    color: #fcd34d;
}
.vpn-setup-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    gap: 18px;
    align-items: start;
}
.settings-panel.vpn-card,
.settings-panel.vpn-progress-panel {
    border-radius: 8px;
    padding: 20px;
    border: 1px solid rgba(18,32,49,.09);
    box-shadow: 0 14px 34px rgba(29,44,62,.07);
}
body[data-theme="dark"] .settings-panel.vpn-card,
body[data-theme="dark"] .settings-panel.vpn-progress-panel {
    border-color: rgba(154,170,190,.14);
}
.vpn-card form {
    display: grid;
    gap: 14px;
}
.vpn-app-url-card {
    margin-bottom: 18px;
}
.vpn-app-url-form {
    display: grid;
    gap: 14px;
}
.vpn-card label {
    display: grid;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.vpn-card input {
    width: 100%;
}
.vpn-url-suggestions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}
.vpn-url-suggestions code {
    padding: 4px 7px;
    border: 1px solid rgba(126,139,155,.22);
    border-radius: 6px;
    background: rgba(248,250,252,.78);
    color: var(--ink);
}
body[data-theme="dark"] .vpn-url-suggestions code {
    background: rgba(15,23,42,.55);
    color: #f3f7fb;
}
.vpn-inline-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(217,119,6,.24);
    border-radius: 8px;
    background: rgba(255,251,235,.82);
    color: #92400e;
    font-size: 13px;
}
body[data-theme="dark"] .vpn-inline-warning {
    border-color: rgba(251,191,36,.24);
    background: rgba(69,45,12,.45);
    color: #fde68a;
}
.vpn-setup-submit {
    min-width: 220px;
    justify-content: center;
}
.vpn-state-list {
    display: grid;
    gap: 10px;
    margin: 0;
}
.vpn-state-list div {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-bottom: 1px solid rgba(126,139,155,.18);
    border-radius: 8px;
    background: rgba(248,250,252,.78);
}
body[data-theme="dark"] .vpn-state-list div {
    background: rgba(15,23,42,.38);
}
.vpn-state-list div:last-child { border-bottom: 0; }
.vpn-state-list dt {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0;
}
.vpn-state-list dt i {
    width: 16px;
    color: var(--primary);
}
.vpn-state-list dd {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.vpn-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 26px;
    padding: 4px 10px;
    border: 1px solid rgba(126,139,155,.2);
    border-radius: 999px;
    background: rgba(255,255,255,.7);
}
body[data-theme="dark"] .vpn-pill {
    background: rgba(15,23,42,.5);
}
.vpn-progress-panel {
    margin-top: 18px;
}
.vpn-progress-log {
    display: grid;
    gap: 8px;
    max-height: 420px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: auto;
}
.vpn-log-row {
    display: grid;
    grid-template-columns: 86px 70px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid rgba(126,139,155,.18);
    border-left-width: 4px;
    border-radius: 8px;
    background: rgba(255,255,255,.58);
}
body[data-theme="dark"] .vpn-log-row {
    background: rgba(15,23,42,.55);
}
.vpn-log-row span {
    color: var(--muted);
    font-size: 12px;
}
.vpn-log-row strong {
    font-size: 12px;
    text-transform: uppercase;
}
.vpn-log-row p {
    margin: 0;
    overflow-wrap: anywhere;
}
.vpn-log-info {
    border-left-color: #3b82f6;
}
.vpn-log-ok {
    border-left-color: #16a34a;
}
.vpn-log-error {
    border-left-color: #dc2626;
}
.ha-token-hero {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid rgba(18,32,49,.09);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(20,184,166,.13), rgba(59,130,246,.09)),
        rgba(255,255,255,.82);
    box-shadow: 0 18px 44px rgba(29,44,62,.08);
}
body[data-theme="dark"] .ha-token-hero {
    border-color: rgba(154,170,190,.16);
    background:
        linear-gradient(135deg, rgba(20,184,166,.17), rgba(59,130,246,.12)),
        rgba(18,27,42,.76);
}
.ha-token-hero > div {
    display: flex;
    gap: 14px;
    min-width: 0;
}
.ha-token-icon {
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(20,184,166,.14);
    color: #0f766e;
    font-size: 21px;
}
body[data-theme="dark"] .ha-token-icon {
    background: rgba(45,212,191,.16);
    color: #5eead4;
}
.ha-token-hero h2 {
    margin: 0 0 6px;
    font-size: 24px;
    letter-spacing: 0;
}
.ha-token-hero p:last-child {
    max-width: 760px;
    margin: 0;
    color: #405063;
}
body[data-theme="dark"] .ha-token-hero p:last-child {
    color: #c8d3e1;
}
.ha-token-hero > strong {
    display: grid;
    align-content: center;
    justify-items: end;
    min-width: 170px;
    padding: 12px 14px;
    border: 1px solid rgba(126,139,155,.18);
    border-radius: 8px;
    background: rgba(255,255,255,.68);
    color: #b45309;
    font-size: 16px;
}
body[data-theme="dark"] .ha-token-hero > strong {
    background: rgba(15,23,42,.52);
}
.ha-token-hero > strong.is-ready { color: #15803d; }
.ha-token-hero > strong.is-expired { color: #dc2626; }
body[data-theme="dark"] .ha-token-hero > strong.is-ready { color: #86efac; }
body[data-theme="dark"] .ha-token-hero > strong.is-expired { color: #fca5a5; }
.ha-token-grid {
    display: grid;
    grid-template-columns: minmax(300px, .9fr) minmax(0, 1.1fr);
    gap: 18px;
    align-items: start;
}
.settings-panel.ha-token-card {
    border-radius: 8px;
    padding: 20px;
    border: 1px solid rgba(18,32,49,.09);
    box-shadow: 0 14px 34px rgba(29,44,62,.07);
}
body[data-theme="dark"] .settings-panel.ha-token-card {
    border-color: rgba(154,170,190,.14);
}
.ha-token-card .settings-intro p {
    color: #405063;
}
body[data-theme="dark"] .ha-token-card .settings-intro p {
    color: #c8d3e1;
}
.ha-token-status-list {
    display: grid;
    gap: 10px;
    margin: 0;
}
.ha-token-status-list div {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-bottom: 1px solid rgba(126,139,155,.18);
    border-radius: 8px;
    background: rgba(248,250,252,.78);
}
body[data-theme="dark"] .ha-token-status-list div {
    background: rgba(15,23,42,.38);
}
.ha-token-status-list div:last-child { border-bottom: 0; }
.ha-token-status-list dt {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0;
}
.ha-token-status-list dd {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.ha-token-form {
    display: grid;
    gap: 14px;
}
.ha-token-form label {
    display: grid;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.ha-token-form textarea {
    width: 100%;
    resize: vertical;
    min-height: 170px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
}
.ha-token-form small {
    color: var(--muted);
}
.danger-text {
    color: #dc2626;
}
body[data-theme="dark"] .danger-text {
    color: #fca5a5;
}
.entity-filter-row {
    margin: 18px 0;
    justify-content: flex-start;
}
.search-box {
    position: relative;
    width: min(520px, 100%);
}
.search-box i {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    color: var(--muted);
}
.search-box input { padding-left: 40px; }
.entity-shown-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid rgba(18,32,49,.1);
    border-radius: 12px;
    background: rgba(255,255,255,.72);
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(29,44,62,.06);
}
body[data-theme="dark"] .entity-shown-filter {
    border-color: rgba(154,170,190,.18);
    background: rgba(18,27,42,.76);
}
.entity-shown-filter input {
    width: 16px;
    height: 16px;
    margin: 0;
}
.entity-table-wrap {
    max-height: 62vh;
    overflow: auto;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 14px;
    background: rgba(255,255,255,.58);
}
body[data-theme="dark"] .entity-table-wrap {
    border-color: rgba(154,170,190,.16);
    background: rgba(18,27,42,.62);
}
.entity-table {
    margin: 0;
    min-width: 1180px;
}
.entity-table tbody tr {
    transition: background .14s ease;
}
.entity-table tbody tr:hover {
    background: rgba(36,107,254,.045);
}
body[data-theme="dark"] .entity-table tbody tr:hover {
    background: rgba(106,162,255,.08);
}
.entity-table td,
.entity-table th {
    padding: 14px 12px;
}
.entity-table thead th {
    position: sticky;
    top: 0;
    background: rgba(248,250,252,.92);
    z-index: 2;
    border-bottom: 1px solid var(--line);
    color: #455468;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
body[data-theme="dark"] .entity-table thead th {
    background: rgba(15,23,37,.96);
    color: rgba(238,245,255,.78);
}
.entity-name {
    display: grid;
    min-width: 0;
}
.entity-name small {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(100,115,134,.10);
    color: #34403c;
    font-weight: 800;
    font-size: .78rem;
}
body[data-theme="dark"] .type-badge {
    color: var(--ink);
    background: rgba(154,170,190,.13);
}
.type-smoke,
.type-co,
.type-power {
    background: rgba(239,68,68,.12);
    color: var(--danger);
}
.class-hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}
.order-input {
    width: 92px;
}
.switch input { display: none; }
.switch span {
    display: inline-block;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #c8d3df;
    position: relative;
    cursor: pointer;
    transition: background .16s ease;
}
.switch span::after {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transition: transform .16s ease;
}
.switch input:checked + span {
    background: linear-gradient(135deg, var(--accent), var(--cyan));
}
.switch input:checked + span::after {
    transform: translateX(20px);
}
.sticky-save {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
    padding: 12px max(18px, calc((100vw - 1440px) / 2 + 28px));
    margin-top: 0;
    border: 0;
    border-top: 1px solid rgba(255,255,255,.78);
    border-radius: 0;
    background:
        linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,255,255,.82)),
        linear-gradient(135deg, rgba(36,107,254,.12), rgba(0,168,120,.10));
    box-shadow: 0 -14px 42px rgba(16,23,34,.12), 0 18px 44px rgba(16,23,34,.10);
    backdrop-filter: blur(20px);
}
.sticky-save::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100% + 20px);
    z-index: -1;
    background: linear-gradient(180deg, rgba(238,243,247,0), rgba(238,243,247,.94) 38%, rgba(238,243,247,1));
}
body[data-theme="dark"] .sticky-save::before {
    background: linear-gradient(180deg, rgba(11,17,28,0), rgba(11,17,28,.94) 38%, rgba(11,17,28,1));
}
.sticky-save span {
    color: var(--muted);
    font-weight: 700;
}
.sticky-save span strong {
    color: var(--ink);
    font-size: 1.15rem;
}
.sticky-save .btn {
    min-height: 48px;
    padding-inline: 22px;
    border-radius: 14px;
    font-weight: 850;
    box-shadow: 0 12px 28px rgba(36,107,254,.24);
}
.sticky-save .btn i {
    margin-right: 7px;
}

.empty-dashboard {
    margin-top: 24px;
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px dashed rgba(108,125,148,.28);
    border-radius: 18px;
    background: rgba(255,255,255,.72);
}
body[data-theme="dark"] .empty-dashboard {
    background: rgba(18,27,42,.72);
}
.empty-dashboard > i {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(180,35,24,.1);
    color: var(--danger);
    flex: 0 0 46px;
}
.empty-dashboard p {
    margin: 4px 0 12px;
    color: var(--muted);
}

.logbook-page {
    display: grid;
    gap: 18px;
}
.logbook-hero,
.logbook-filters,
.logbook-panel,
.log-entry {
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
body[data-theme="dark"] .logbook-hero,
body[data-theme="dark"] .logbook-filters,
body[data-theme="dark"] .logbook-panel,
body[data-theme="dark"] .log-entry {
    border-color: rgba(154,170,190,.16);
}
.logbook-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, .95fr);
    gap: 20px;
    align-items: center;
    padding: 22px;
}
.logbook-hero p:last-child {
    margin: 8px 0 0;
    color: var(--muted);
}
.logbook-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.logbook-stats article {
    padding: 14px;
    border: 1px solid rgba(108,125,148,.16);
    border-radius: 14px;
    background: rgba(255,255,255,.58);
}
.logbook-stats span,
.logbook-filters label span {
    display: block;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.logbook-stats strong {
    display: block;
    margin-top: 8px;
    font-size: 1.8rem;
    line-height: 1;
}
.logbook-stats .warn strong { color: var(--warn); }
.logbook-stats .danger strong { color: var(--danger); }
.logbook-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.25fr) repeat(4, minmax(130px, .7fr)) auto;
    gap: 12px;
    align-items: end;
    padding: 16px;
}
.logbook-filters label {
    display: grid;
    gap: 6px;
    min-width: 0;
}
.logbook-filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.logbook-panel {
    padding: 18px;
}
.logbook-list {
    display: grid;
    gap: 10px;
}
.log-entry {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    box-shadow: none;
}
.log-entry-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: var(--accent-2);
    background: rgba(36,107,254,.10);
}
.log-entry-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.log-entry-head strong,
.log-entry-body p,
.log-entry-body small {
    overflow-wrap: anywhere;
}
.log-entry-head span {
    flex: 0 0 auto;
    padding: 6px 9px;
    border-radius: 999px;
    color: var(--accent-2);
    background: rgba(36,107,254,.10);
    font-size: .76rem;
    font-weight: 850;
}
.log-entry-body p {
    margin: 7px 0 6px;
}
.log-entry-body small {
    color: var(--muted);
}
.log-type-warning .log-entry-icon,
.log-type-warning .log-entry-head span {
    color: var(--warn);
    background: rgba(245,158,11,.14);
}
.log-type-error .log-entry-icon,
.log-type-fatal .log-entry-icon,
.log-type-error .log-entry-head span,
.log-type-fatal .log-entry-head span {
    color: var(--danger);
    background: rgba(239,68,68,.13);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 18% 12%, rgba(0,163,255,.22), transparent 24rem),
        radial-gradient(circle at 82% 20%, rgba(0,168,120,.18), transparent 24rem),
        var(--bg);
}
.login-panel { width: min(440px, 100%); }
.login-card { padding: 34px; }
.login-card h1 { margin-top: 18px; }
.stack { display: grid; gap: 16px; }
.stack label span:not(.form-check-label) {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
}

@media (max-width: 980px) {
    .vpn-setup-hero,
    .ha-token-hero {
        display: grid;
    }
    .vpn-hero-status,
    .ha-token-hero > strong {
        justify-items: start;
        min-width: 0;
    }
    .vpn-setup-grid,
    .ha-token-grid {
        grid-template-columns: 1fr;
    }
    .app-shell {
        grid-template-columns: 1fr;
        background: transparent;
    }
    body.sidebar-collapsed .app-shell,
    html.sidebar-collapsed-preset .app-shell {
        grid-template-columns: 1fr;
        background: transparent;
    }
    .app-sidebar {
        position: fixed;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform .2s ease;
        width: 248px;
        opacity: 1;
        pointer-events: auto;
    }
    body.sidebar-collapsed .app-sidebar,
    html.sidebar-collapsed-preset .app-sidebar {
        opacity: 1;
        pointer-events: auto;
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    [data-sidebar-toggle] { display: grid; }
    .collapse-button { display: none; }
    body.sidebar-collapsed .brand strong,
    body.sidebar-collapsed .nav-stack span,
    body.sidebar-collapsed .nav-section-title span,
    body.sidebar-collapsed .sidebar-foot small,
    html.sidebar-collapsed-preset .brand strong,
    html.sidebar-collapsed-preset .nav-stack span,
    html.sidebar-collapsed-preset .nav-section-title span,
    html.sidebar-collapsed-preset .sidebar-foot small {
        opacity: 1;
        width: auto;
    }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-grid { grid-template-columns: 1fr; }
    .dashboard-section.width-three-quarter,
    .dashboard-section.width-wide,
    .dashboard-section.width-half,
    .dashboard-section.width-quarter,
    .dashboard-section.width-third { grid-column: span 12; }
    .control-box-grid,
    .dashboard-section.width-full .control-box-grid,
    .dashboard-section.width-three-quarter .control-box-grid,
    .dashboard-section.width-wide .control-box-grid,
    .dashboard-section.width-half .control-box-grid,
    .dashboard-section.width-quarter .control-box-grid,
    .dashboard-section.width-third .control-box-grid {
        grid-template-columns: 1fr;
    }
    .control-box-grid > *,
    .dashboard-section.width-full .control-box-grid > *,
    .dashboard-section.width-three-quarter .control-box-grid > *,
    .dashboard-section.width-wide .control-box-grid > *,
    .dashboard-section.width-half .control-box-grid > *,
    .dashboard-section.width-quarter .control-box-grid > *,
    .dashboard-section.width-third .control-box-grid > * {
        grid-column: auto !important;
        grid-row: auto !important;
    }
    .control-box-grid,
    .dashboard-section.width-full .control-box-grid,
    .dashboard-section.width-three-quarter .control-box-grid,
    .dashboard-section.width-wide .control-box-grid,
    .dashboard-section.width-half .control-box-grid,
    .dashboard-section.width-quarter .control-box-grid,
    .dashboard-section.width-third .control-box-grid {
        grid-auto-rows: auto;
    }
    .section-layout-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .vpn-hero-main,
    .ha-token-hero > div {
        display: grid;
    }
    .vpn-hero-main h2,
    .ha-token-hero h2 {
        font-size: 21px;
    }
    .vpn-setup-submit {
        width: 100%;
        min-width: 0;
    }
    .vpn-log-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .content-wrap { padding: 18px; }
    .topbar {
        height: auto;
        min-height: 62px;
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .topbar-title {
        min-width: 0;
    }
    .topbar-title small {
        display: none;
    }
    .topbar-live {
        order: 5;
        width: 100%;
        justify-content: space-between;
        padding-top: 10px;
        border-top: 1px solid rgba(108,125,148,.16);
    }
    .topbar-live .live-pill {
        flex: 1 1 auto;
        min-width: 0;
    }
    .topbar-live form {
        flex: 0 0 auto;
    }
    .topbar-live .btn {
        white-space: nowrap;
    }
    .flash-stack {
        top: 78px;
        right: 12px;
        width: min(390px, calc(100vw - 24px));
    }
    .page-head,
    .settings-intro,
    .sticky-save,
    .device-row,
    .device-actions,
    .thermostat-summary,
    .thermostat-actions,
    .thermostat-actions form {
        align-items: stretch;
        flex-direction: column;
    }
    .settings-panel {
        padding-bottom: 142px;
    }
    .sticky-save {
        padding: 12px;
    }
    .thermostat-temp { text-align: left; }
    .thermostat-control-form,
    .thermostat-actions .thermostat-control-form {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .thermostat-dial {
        width: min(270px, 100%);
        min-height: 190px;
        padding: 8px 12px 0;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        grid-template-rows: 1fr 38px;
    }
    .thermostat-dial-status {
        padding-top: 0;
        font-size: .76rem;
    }
    .thermostat-dial-center {
        gap: 5px;
        padding: 46px 24px 14px;
    }
    .thermostat-dial-center strong {
        font-size: 1.65rem;
    }
    .thermostat-dial-center small {
        font-size: .72rem;
    }
    .thermostat-dial-label {
        font-size: .64rem;
    }
    .thermostat-dial-button {
        width: 28px;
        height: 28px;
    }
    .thermostat-mode-button {
        width: 28px;
        height: 28px;
        border-radius: 9px;
    }
    .thermostat-dial-readouts {
        max-width: 92%;
        gap: 6px;
        padding-top: 0;
        font-size: .66rem;
    }
    .thermostat-dial-readouts .battery-pill {
        width: 32px;
        height: 17px;
    }
    .thermostat-actions input[type="number"],
    .thermostat-actions select,
    .thermostat-actions .btn { width: 100%; }
    .metric-grid,
    .sensor-grid { grid-template-columns: 1fr; }
    .control-box-grid > *,
    .dashboard-section.width-full .control-box-grid > *,
    .dashboard-section.width-three-quarter .control-box-grid > *,
    .dashboard-section.width-wide .control-box-grid > *,
    .dashboard-section.width-half .control-box-grid > *,
    .dashboard-section.width-quarter .control-box-grid > *,
    .dashboard-section.width-third .control-box-grid > * {
        grid-column: 1 / -1;
        grid-row: auto !important;
    }
    .device-actions .btn { width: 100%; }
    .section-layout-grid {
        gap: 8px;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }
    .layout-card {
        grid-template-columns: 1fr;
        align-items: stretch;
        border: 1px solid rgba(35, 42, 58, .08);
        border-radius: 12px;
        background: rgba(255,255,255,.62);
    }
    .section-layout-head {
        display: none;
    }
    .layout-card label:not(.switch) span {
        display: block;
    }
    .logbook-hero,
    .logbook-filters {
        grid-template-columns: 1fr;
    }
    .logbook-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .log-entry-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
