/* =============================================================
   Smart Home Admin Panel — admin.css
   Mirrors the Next.js template design in pure CSS
   ============================================================= */

/* ---------- CSS Custom Properties (Design Tokens) ---------- */
:root {
    --brand:       oklch(0.61 0.24 300);          /* purple default */
    --brand-2:     color-mix(in oklab, var(--brand) 85%, white 15%);
    --bg:          oklch(1 0 0);
    --bg-muted:    oklch(0.97 0 0);
    --card:        oklch(1 0 0);
    --foreground:  oklch(0.145 0 0);
    --muted-fg:    oklch(0.556 0 0);
    --border:      oklch(0.922 0 0);
    --input-bg:    oklch(0.97 0 0);
    --radius:      0.625rem;
    --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:   0 4px 16px rgba(0,0,0,.10);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Dark Mode */
.dark {
    --bg:          oklch(0.145 0 0);
    --bg-muted:    oklch(0.2 0 0);
    --card:        oklch(0.2 0 0);
    --foreground:  oklch(0.985 0 0);
    --muted-fg:    oklch(0.708 0 0);
    --border:      oklch(0.28 0 0);
    --input-bg:    oklch(0.18 0 0);
    --brand-2:     color-mix(in oklab, var(--brand) 80%, black 20%);
}

/* Brand Presets */
[data-brand="purple"] { --brand: oklch(0.61 0.24 300); }
[data-brand="blue"]   { --brand: oklch(0.65 0.17 240); }
[data-brand="teal"]   { --brand: oklch(0.7 0.12 180);  }
[data-brand="orange"] { --brand: oklch(0.73 0.19 60);  }
[data-brand="pink"]   { --brand: oklch(0.71 0.28 360); }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: var(--bg-muted);
    color: var(--foreground);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ---------- App Shell ---------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg-muted);
    padding: 0.75rem;
    gap: 0;
    position: relative;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 210px;
    min-width: 210px;
    background: linear-gradient(to bottom, var(--brand), var(--brand-2));
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 1.5rem);
    position: sticky;
    top: 0.75rem;
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease;
    flex-shrink: 0;
}
.sidebar.collapsed {
    width: 72px;
    min-width: 72px;
}
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-tip-text { display: none; }

/* Brand Row */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1.25rem 1rem 1rem;
    color: #fff;
    flex-shrink: 0;
}
.sidebar-logo {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px;
    color: #fff; flex-shrink: 0;
}
.sidebar-title { font-weight: 600; font-size: 14px; color: #fff; white-space: nowrap; flex: 1; }
.sidebar-toggle {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    display: grid; place-items: center;
    color: #fff; transition: background 0.2s; flex-shrink: 0;
}
.sidebar-toggle svg { width: 16px; height: 16px; }
.sidebar-toggle:hover { background: rgba(255,255,255,0.3); }

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0.75rem; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6875rem 0.75rem;
    border-radius: 12px; color: rgba(255,255,255,0.9);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.12); }
.nav-item.active { background: #fff; color: var(--brand); }
.nav-item.active .nav-icon { color: var(--brand); }

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; color: #fff; }
.nav-item.active .nav-icon { color: var(--brand); }
.nav-label { font-size: 13.5px; }
.nav-badge {
    margin-left: auto; background: #ef4444; color: #fff;
    border-radius: 999px; font-size: 10px;
    min-width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px; font-weight: 600;
}

/* Sidebar Tip */
.sidebar-tip {
    padding: 0.75rem;
    flex-shrink: 0;
}
.sidebar-tip-text {
    display: block;
    background: rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 0.75rem;
    font-size: 11.5px;
    color: rgba(255,255,255,0.9);
    line-height: 1.6;
}

/* ---------- Main Area ---------- */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.75rem 0.75rem 0;
    overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 1.25rem;
}
.topbar-inner {
    height: 62px; padding: 0 1.25rem;
    display: flex; align-items: center; gap: 0.75rem;
}
.topbar-menu-btn {
    display: none; width: 36px; height: 36px; border-radius: 50%;
    align-items: center; justify-content: center;
    background: var(--bg-muted); color: var(--foreground);
    flex-shrink: 0;
}
.topbar-menu-btn svg { width: 20px; height: 20px; }

/* Search */
.topbar-search { flex: 1; max-width: 480px; }
.search-label { position: relative; display: block; }
.search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--muted-fg); pointer-events: none;
}
.search-input {
    width: 100%; height: 38px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--input-bg);
    color: var(--foreground); font-size: 13px;
    padding: 0 1rem 0 2.25rem; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent);
}

/* Topbar Actions */
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.action-dropdown { position: relative; }
.action-btn {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--foreground);
    transition: background 0.15s;
}
.action-btn:hover { background: var(--bg-muted); }
.action-btn svg { width: 20px; height: 20px; }
.action-btn.user-avatar-btn { width: 40px; height: 40px; border-radius: 50%; padding: 0; }

.notif-btn { position: relative; }
.notif-badge {
    position: absolute; top: 4px; right: 4px;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    width: 16px; height: 16px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-weight: 700; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    min-width: 200px; background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-md); z-index: 100;
    overflow: hidden; padding: 4px 0;
    animation: dropIn 0.15s ease;
}
.dropdown-menu-right { left: auto; right: 0; transform: none; }
@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px) translateX(-50%); }
    to   { opacity: 1; transform: translateY(0) translateX(-50%); }
}
.dropdown-menu-right { animation: dropInRight 0.15s ease; }
@keyframes dropInRight {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dropdown-header {
    padding: 8px 14px; font-weight: 600; font-size: 12.5px;
    color: var(--foreground); display: flex; align-items: center;
}
.dropdown-item {
    padding: 8px 14px; font-size: 13px; color: var(--foreground);
    cursor: pointer; transition: background 0.12s;
    display: flex; align-items: center; justify-content: space-between;
    background: none; width: 100%; text-align: left; border: none; font-family: inherit;
}
.dropdown-item:hover { background: var(--bg-muted); }
.dropdown-muted { color: var(--muted-fg); }
.dropdown-danger { color: #ef4444; }
.dropdown-divider { height: 1px; background: var(--border); margin: 3px 0; }

/* Theme & Brand Controls */
.theme-toggle-btn {
    padding: 3px 10px; border-radius: 8px;
    background: var(--bg-muted); color: var(--foreground);
    font-size: 12px; transition: background 0.15s;
}
.color-swatches { display: flex; gap: 6px; align-items: center; }
.swatch {
    width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s; cursor: pointer;
}
.swatch:hover { transform: scale(1.2); border-color: var(--border); }
.swatch-purple { background: oklch(0.61 0.24 300); }
.swatch-blue   { background: oklch(0.65 0.17 240); }
.swatch-teal   { background: oklch(0.7  0.12 180); }
.swatch-orange { background: oklch(0.73 0.19 60);  }
.swatch-pink   { background: oklch(0.71 0.28 360); }

/* ---------- Page Content ---------- */
.page-content { flex: 1; overflow-y: auto; padding-bottom: 1rem; }

/* ---------- Alert ---------- */
.alert {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.75rem 1rem; border-radius: 12px; font-size: 13px; margin-bottom: 1rem;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.dark .alert-success { background: #14532d; color: #4ade80; border-color: #16a34a; }
.dark .alert-error   { background: #450a0a; color: #f87171; border-color: #dc2626; }

/* ---------- Card ---------- */
.card {
    background: var(--card); border-radius: 1rem;
    padding: 1.25rem; box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--foreground); }
.card-meta  { font-size: 11px; color: var(--muted-fg); }

/* ---------- Welcome Banner ---------- */
.welcome-banner {
    position: relative; overflow: hidden;
    border-radius: 1.5rem;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    padding: 1.75rem 2rem; color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1.5rem; margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.welcome-text { flex: 1; min-width: 240px; }
.welcome-title { font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-bottom: 0.5rem; }
.welcome-desc  { font-size: 13.5px; color: rgba(255,255,255,0.85); margin-bottom: 1rem; line-height: 1.6; }
.welcome-temp {
    display: inline-flex; align-items: center; gap: 0.75rem;
    background: rgba(255,255,255,0.15); border-radius: 14px;
    padding: 0.625rem 1rem; font-size: 13px; backdrop-filter: blur(4px);
}
.temp-value { font-size: 1.5rem; font-weight: 700; }
.temp-label { font-weight: 600; font-size: 13px; }
.temp-sub   { font-size: 11.5px; color: rgba(255,255,255,0.75); }
.welcome-img-wrap { position: relative; flex: 0 0 35%; min-width: 200px; }
.welcome-img  {
    width: 100%; border-radius: 14px; object-fit: cover;
    height: 200px; opacity: 0.9;
}
.welcome-illustration { /* SVG fallback */
    width: 100%; padding: 0.5rem;
}
.welcome-blur-circle {
    position: absolute; top: -60px; right: -60px; width: 220px; height: 220px;
    border-radius: 50%; background: rgba(255,255,255,0.12); filter: blur(40px);
    pointer-events: none;
}

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--card); border-radius: 1rem;
    padding: 1.25rem; display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-brand  { background: color-mix(in oklab, var(--brand) 15%, transparent); color: var(--brand); }
.stat-icon-teal   { background: #ccfbf1; color: #0d9488; }
.stat-icon-pink   { background: #fce7f3; color: #db2777; }
.stat-icon-orange { background: #ffedd5; color: #ea580c; }
.dark .stat-icon-teal   { background: #042f2e; color: #2dd4bf; }
.dark .stat-icon-pink   { background: #4a044e; color: #f472b6; }
.dark .stat-icon-orange { background: #431407; color: #fb923c; }
.stat-info { min-width: 0; }
.stat-title  { font-size: 12px; color: var(--muted-fg); margin-bottom: 3px; }
.stat-value  { font-size: 1.5rem; font-weight: 700; color: var(--foreground); line-height: 1; margin-bottom: 4px; }
.stat-change { font-size: 11.5px; color: var(--muted-fg); }

/* ---------- Dashboard Grid ---------- */
.dashboard-grid {
    display: grid; grid-template-columns: 1fr minmax(240px, 320px);
    gap: 1rem; margin-bottom: 1rem;
}
.col-main { display: flex; flex-direction: column; gap: 1rem; }
.col-side { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Rooms ---------- */
.rooms-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem;
}
.room-card {
    background: var(--bg-muted); border-radius: 14px; padding: 1rem;
    display: flex; flex-direction: column; gap: 4px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}
.room-card:hover { border-color: var(--brand); }
.room-icon { width: 32px; height: 32px; margin-bottom: 6px; color: var(--brand); }
.room-icon svg { width: 100%; height: 100%; }
.room-name    { font-size: 13px; font-weight: 600; color: var(--foreground); }
.room-devices { font-size: 11px; color: var(--muted-fg); }
.room-badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 10.5px; font-weight: 600; margin-top: 4px;
}
.badge-active { background: #dcfce7; color: #15803d; }
.badge-idle   { background: var(--bg-muted); color: var(--muted-fg); border: 1px solid var(--border); }
.dark .badge-active { background: #14532d; color: #4ade80; }
.dark .badge-idle   { background: var(--bg); }

/* ---------- Devices + Scenes ---------- */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.devices-list { display: flex; flex-direction: column; gap: 0.625rem; }
.device-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0; border-bottom: 1px solid var(--border);
}
.device-row:last-child { border-bottom: none; }
.device-icon-wrap {
    width: 36px; height: 36px; border-radius: 10px;
    background: color-mix(in oklab, var(--brand) 12%, transparent);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    color: var(--brand);
}
.device-icon-wrap svg { width: 18px; height: 18px; }
.device-meta { flex: 1; min-width: 0; }
.device-name  { font-size: 13px; font-weight: 500; }
.device-power { font-size: 11px; color: var(--muted-fg); }
.device-status { font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.status-on  { background: #dcfce7; color: #15803d; }
.status-off { background: var(--bg-muted); color: var(--muted-fg); border: 1px solid var(--border); }
.dark .status-on  { background: #14532d; color: #4ade80; }

/* Scenes */
.scenes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem; }
.scene-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 0.75rem 0.5rem; border-radius: 12px; background: var(--bg-muted);
    border: 1px solid var(--border); transition: border-color 0.2s, background 0.2s;
    font-family: inherit; cursor: pointer;
}
.scene-btn:hover { border-color: var(--brand); background: color-mix(in oklab, var(--brand) 6%, var(--bg-muted)); }
.scene-emoji { font-size: 1.25rem; }
.scene-name  { font-size: 11px; color: var(--muted-fg); }

/* ---------- Energy Widget ---------- */
.energy-card { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.energy-left { display: flex; flex-direction: column; align-items: center; }
.energy-times { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.time-pill {
    padding: 4px 12px; border-radius: 999px; background: var(--bg-muted);
    border: 1px solid var(--border); font-size: 12px; font-weight: 500;
}
.energy-to { font-size: 12px; color: var(--muted-fg); }

/* Gauge */
.gauge-wrap { position: relative; }
.gauge-svg  { width: 180px; height: 180px; }
.gauge-track { stroke: var(--bg-muted); }
.gauge-fill  { stroke: var(--brand); transition: stroke-dashoffset 0.4s ease; }
.gauge-text  { fill: var(--foreground); font-size: 2rem; font-weight: 700; font-family: 'Inter', sans-serif; }

/* Range */
.range-wrap  { width: 100%; margin-top: 0.75rem; text-align: center; }
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted-fg); margin-bottom: 4px; }
.energy-range {
    width: 100%; height: 8px; border-radius: 999px;
    -webkit-appearance: none; appearance: none; cursor: pointer; outline: none;
    background: linear-gradient(to right, var(--brand) 65%, var(--bg-muted) 65%);
}
.energy-range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2.5px solid var(--brand);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent);
}
.range-value { font-size: 12px; color: var(--muted-fg); margin-top: 4px; }

/* Bar Chart */
.energy-right  { display: flex; flex-direction: column; }
.energy-chart-title { font-size: 12.5px; font-weight: 600; color: var(--muted-fg); margin-bottom: 0.5rem; }
.bar-chart {
    display: flex; align-items: flex-end; gap: 6px; height: 120px;
    padding-bottom: 0.25rem;
}
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar {
    width: 100%; background: var(--muted-fg); border-radius: 6px 6px 0 0;
    opacity: 0.4; transition: opacity 0.2s;
}
.bar-accent { background: var(--brand) !important; opacity: 1 !important; }
.bar-label  { font-size: 10px; color: var(--muted-fg); }
.energy-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.5rem; margin-top: 0.75rem; }
.energy-btn {
    padding: 0.5rem; border-radius: 10px; background: var(--bg-muted);
    border: 1px solid var(--border); font-size: 12.5px;
    color: var(--foreground); font-family: inherit; transition: background 0.15s;
}
.energy-btn:hover { background: color-mix(in oklab, var(--brand) 10%, var(--bg-muted)); }
.energy-btn-accent { background: var(--brand); color: #fff; border-color: transparent; }
.energy-btn-accent:hover { background: var(--brand-2); }

/* ---------- AC Card ---------- */
.ac-temp-display {
    display: flex; align-items: center; justify-content: center; gap: 1.5rem;
    padding: 1.25rem 0;
}
.ac-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-muted); border: 1px solid var(--border);
    font-size: 1.25rem; color: var(--foreground); transition: background 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.ac-btn:hover { background: color-mix(in oklab, var(--brand) 10%, var(--bg-muted)); }
.ac-temp { font-size: 2rem; font-weight: 700; color: var(--brand); }
.ac-modes { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.ac-mode {
    padding: 6px 4px; border-radius: 10px; background: var(--bg-muted);
    border: 1px solid var(--border); font-size: 11.5px; color: var(--foreground);
    transition: all 0.15s; font-family: inherit;
}
.ac-mode:hover { border-color: var(--brand); }
.ac-mode-active { background: var(--brand); color: #fff; border-color: transparent; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.active { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }

/* ---------- Users ---------- */
.users-list { display: flex; flex-direction: column; gap: 0.625rem; }
.user-row { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar-sm {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--muted-fg); }
.user-status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status-online  { background: #dcfce7; color: #15803d; }
.status-offline { background: var(--bg-muted); color: var(--muted-fg); border: 1px solid var(--border); }
.dark .status-online { background: #14532d; color: #4ade80; }

/* ---------- Bottom Grid ---------- */
.bottom-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem;
}
.col-span-2 { grid-column: span 2; }

/* Consumption Chart */
.consumption-chart {
    display: flex; align-items: flex-end; justify-content: space-between;
    height: 160px; gap: 8px; padding-top: 0.5rem;
}
.consumption-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; }
.consumption-bar-wrap {
    flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center;
}
.consumption-bar {
    width: 70%; background: linear-gradient(to top, var(--brand), color-mix(in oklab, var(--brand) 60%, white));
    border-radius: 8px 8px 0 0; position: relative; transition: height 0.5s ease;
    min-height: 8px; cursor: pointer;
}
.consumption-bar:hover .consumption-tooltip { opacity: 1; transform: translateY(-4px); }
.consumption-tooltip {
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%) translateY(0);
    background: var(--foreground); color: var(--bg); font-size: 11px;
    padding: 3px 8px; border-radius: 6px; white-space: nowrap;
    opacity: 0; transition: opacity 0.15s, transform 0.15s; pointer-events: none;
    margin-bottom: 4px;
}
.consumption-label { font-size: 11px; color: var(--muted-fg); margin-top: 6px; }
.chart-tabs { display: flex; gap: 4px; }
.chart-tab {
    padding: 4px 12px; border-radius: 8px; font-size: 12px;
    background: transparent; color: var(--muted-fg); transition: all 0.15s;
    border: 1px solid transparent; font-family: inherit;
}
.chart-tab:hover { background: var(--bg-muted); }
.chart-tab.active { background: var(--brand); color: #fff; }

/* Shortcuts */
.shortcuts-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.625rem; }
.shortcut-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 0.875rem 0.5rem; border-radius: 14px; background: var(--bg-muted);
    border: 1px solid var(--border); transition: all 0.2s; font-family: inherit;
    cursor: pointer;
}
.shortcut-btn:hover { border-color: var(--brand); background: color-mix(in oklab, var(--brand) 6%, var(--bg-muted)); transform: scale(1.03); }
.shortcut-icon { font-size: 1.5rem; }
.shortcut-label { font-size: 11.5px; color: var(--foreground); font-weight: 500; text-align: center; }

/* ---------- Footer ---------- */
.admin-footer {
    padding: 1rem 0.5rem; text-align: center;
    font-size: 12px; color: var(--muted-fg);
    border-top: 1px solid var(--border); margin-top: 0.5rem;
}
.admin-footer a { color: var(--brand); font-weight: 500; }
.admin-footer a:hover { text-decoration: underline; }

/* -------- Login Page -------- */
.login-card {
    width: 100%; max-width: 400px;
    background: var(--card); border-radius: 1.5rem;
    padding: 2rem; box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.login-logo { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.login-logo-icon {
    width: 44px; height: 44px; border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.login-logo-title { font-weight: 700; font-size: 15px; color: var(--foreground); }
.login-logo-sub   { font-size: 11px; color: var(--muted-fg); }
.login-heading { font-size: 1.5rem; font-weight: 700; color: var(--foreground); margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--muted-fg); margin-bottom: 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group  { display: flex; flex-direction: column; gap: 6px; }
.form-label  { font-size: 13px; font-weight: 500; color: var(--foreground); }
.form-input-wrap { position: relative; }
.form-input-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--muted-fg); pointer-events: none;
}
.form-input {
    width: 100%; height: 42px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--input-bg);
    color: var(--foreground); font-size: 14px;
    padding: 0 1rem 0 2.5rem; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 18%, transparent);
}
.form-input.input-error { border-color: #ef4444; }
.form-error { font-size: 12px; color: #dc2626; margin-top: 2px; }
.pw-toggle {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    color: var(--muted-fg); padding: 4px; border-radius: 6px;
    transition: color 0.15s;
}
.pw-toggle svg { width: 16px; height: 16px; display: block; }
.pw-toggle:hover { color: var(--brand); }
.btn-submit {
    height: 44px; border-radius: 10px;
    background: var(--brand); color: #fff;
    font-size: 14px; font-weight: 600;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    border: none; cursor: pointer; width: 100%;
    transition: opacity 0.2s, transform 0.15s;
}
.btn-submit:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.login-hint {
    margin-top: 1rem; padding: 0.625rem; border-radius: 10px;
    background: var(--bg-muted); text-align: center;
    font-size: 12px; color: var(--muted-fg); border: 1px solid var(--border);
}
.login-hint strong { color: var(--foreground); }

/* -------- Mobile Sidebar Overlay -------- */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 49; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* -------- Responsive -------- */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .col-side { flex-direction: row; flex-wrap: wrap; }
    .col-side .card { flex: 1; min-width: 240px; }
    .bottom-grid { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: span 1; }
    .energy-card { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .app-wrapper { padding: 0; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
        z-index: 50; border-radius: 0 1.5rem 1.5rem 0;
        transform: translateX(-100%); transition: transform 0.3s ease, width 0.3s;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-area { padding: 0.5rem; }
    .topbar-menu-btn { display: flex; }
    .topbar-search { display: none; }
    .rooms-grid { grid-template-columns: repeat(2,1fr); }
    .two-col-grid { grid-template-columns: 1fr; }
    .welcome-banner { padding: 1.25rem; }
    .welcome-title  { font-size: 1.25rem; }
    .welcome-img-wrap { display: none; }
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .ac-modes { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .scenes-grid { grid-template-columns: repeat(2,1fr); }
    .shortcuts-grid { grid-template-columns: repeat(2,1fr); }
}

/* ---------- Tables ---------- */
.admin-table-wrap { overflow-x: auto; margin-top: 1rem; border-radius: var(--radius); border: 1px solid var(--border); }
.admin-table { width: 100%; border-collapse: collapse; text-align: left; background: var(--card); }
.admin-table th { padding: 1rem; font-weight: 600; font-size: 13px; color: var(--muted-fg); border-bottom: 1px solid var(--border); background: var(--bg-muted); }
.admin-table td { padding: 1rem; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover { background: var(--bg-muted); }

/* ---------- Custom Components ---------- */
.status-pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.status-pill.success { background: #dcfce7; color: #15803d; }
.status-pill.warning { background: #fef9c3; color: #854d0e; }
.status-pill.danger  { background: #fee2e2; color: #dc2626; }
.status-pill.muted   { background: var(--bg-muted); color: var(--muted-fg); border: 1px solid var(--border); }
.dark .status-pill.success { background: #14532d; color: #4ade80; }
.dark .status-pill.warning { background: #422006; color: #facc15; }
.dark .status-pill.danger  { background: #450a0a; color: #f87171; }

.icon-box { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-box-brand { background: color-mix(in oklab, var(--brand) 12%, transparent); color: var(--brand); }

