/* PVPlex Cloud - Compact Desktop-First Dashboard */

:root {
    --bg-primary: #f8f9fb;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f3f4f6;
    --bg-input: #f3f4f6;
    --bg-subtle: #f0f1f3;
    --border: #e5e7eb;
    --border-light: #f0f1f3;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #737b87;
    --brand: #f59e0b;
    --brand-hover: #d97706;
    --accent-yellow: #f59e0b;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --accent-orange: #f97316;
    --accent-purple: #8b5cf6;
    --pv-color: #f59e0b;
    --battery-color: #10b981;
    --grid-import-color: #ef4444;
    --grid-export-color: #3b82f6;
    --load-color: #f97316;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-card-hover: #262a3a;
    --bg-input: #262a3a;
    --bg-subtle: #1a1d27;
    --border: #2d3148;
    --border-light: #252839;
    --text-primary: #e8eaf0;
    --text-secondary: #9ba1b0;
    --text-muted: #6b7280;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #0f1117;
        --bg-secondary: #1a1d27;
        --bg-card: #1e2130;
        --bg-card-hover: #262a3a;
        --bg-input: #262a3a;
        --bg-subtle: #1a1d27;
        --border: #2d3148;
        --border-light: #252839;
        --text-primary: #e8eaf0;
        --text-secondary: #9ba1b0;
        --text-muted: #6b7280;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
        --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
        --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
    }
}

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

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Card ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
    max-width: 100%;
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.card-title .icon { font-size: 13px; }

/* ── Header ── */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    max-width: 1400px;
    margin: 0 auto;
}
.header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.logo { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.logo-cloud { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.status-indicator { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-red); transition: all 0.3s; }
.status-dot.online { background: var(--accent-green); box-shadow: 0 0 5px rgba(16, 185, 129, 0.4); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.clock { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.device-dropdown {
    background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    padding: 5px 10px; font-size: 12px; cursor: pointer;
}

/* User Menu */
.user-menu { position: relative; display: flex; align-items: center; gap: 6px; }
.user-name { font-size: 12px; color: var(--text-secondary); }
.user-avatar {
    display: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 11px;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nav-icon { font-size: 14px; margin-right: 2px; }
.btn-icon {
    background: none; border: none; color: var(--text-secondary);
    font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-xs);
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-input); color: var(--text-primary); }

.dropdown-menu {
    display: none; position: absolute; top: 100%; right: 0; margin-top: 6px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); min-width: 180px;
    box-shadow: var(--shadow-md); z-index: 200; overflow: hidden;
}
.dropdown-menu.show { display: block; }
.dropdown-menu a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; color: var(--text-primary); text-decoration: none;
    font-size: 13px; transition: background 0.1s;
}
.dropdown-menu a:hover { background: var(--bg-input); }
.dropdown-menu .menu-divider { height: 1px; background: var(--border-light); margin: 3px 0; }

/* ── Navigation Tabs ── */
.main-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 41px; z-index: 99;
}
.nav-content {
    display: flex; gap: 0;
    padding: 0 24px;
    max-width: 1400px;
    margin: 0 auto;
}
.nav-tab {
    padding: 8px 20px; font-size: 13px; font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    border: none; background: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.nav-tab:hover { color: var(--text-primary); }
.nav-tab.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Main Layout ── */
.main { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }

/* ── Dashboard Grid ── */
.dashboard-grid { display: grid; gap: 16px; }

/* ── KPI Strip ── */
.kpi-strip {
    display: none;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.kpi-card:hover { box-shadow: var(--shadow); }
.kpi-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 2px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card.pv::before { background: var(--pv-color); }
.kpi-card.battery::before { background: var(--battery-color); }
.kpi-card.grid::before { background: var(--grid-import-color); }
.kpi-card.grid.exporting::before { background: var(--grid-export-color); }
.kpi-card.load::before { background: var(--load-color); }
.kpi-card.autarky::before { background: var(--accent-green); }

.kpi-card-icon { font-size: 16px; margin-bottom: 4px; opacity: 0.6; }
.kpi-card-value {
    font-size: 22px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2; color: var(--text-primary);
    letter-spacing: -0.5px;
}
.kpi-card-value .kpi-unit, .kpi-unit {
    font-size: 12px; font-weight: 400;
    color: var(--text-muted); letter-spacing: 0;
}
.kpi-card-label {
    font-size: 10px; color: var(--text-muted);
    margin-top: 3px; text-transform: uppercase;
    letter-spacing: 0.6px; font-weight: 500;
}

/* Battery SOC Mini Circle */
.soc-circle-sm {
    width: 44px; height: 44px;
    margin: 0 auto 4px; position: relative;
}
.soc-circle-sm svg { transform: rotate(-90deg); }
.soc-text-sm {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px; font-weight: 800; color: var(--battery-color);
    letter-spacing: -0.5px;
}
.soc-text-sm .kpi-unit { font-size: 9px; }

/* Hero sun animation (on PV kpi-card) */
.hero-sun.active { animation: sunPulse 3s ease-in-out infinite; }
@keyframes sunPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ── Energy Flow (Horizontal Grid) ── */
.energy-flow-container { padding: 16px 12px; }
/* ── Mobile: SolarWeb style - icons + bus bar underneath ── */
.ef-row-wrap { padding: 4px 0; }
.ef-bus-layout { position: relative; }

/* Top row: 4 nodes evenly spaced */
.ef-bus-nodes {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 0 4px;
}
.ef-bnode {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.ef-bcircle {
    width: 50px; height: 50px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2.5px solid;
    transition: all 0.3s;
    background: var(--bg-card);
    position: relative;
    z-index: 2;
}
.ef-bicon { font-size: 16px; line-height: 1; }
.ef-bvalue {
    font-size: 11px; font-weight: 700; color: var(--text-primary);
    white-space: nowrap; text-align: center;
}
.ef-blabel {
    font-size: 7px; font-weight: 600; letter-spacing: 0.6px;
    color: var(--text-muted); text-transform: uppercase; text-align: center;
}

/* Grid icon SVG in mobile circle */
.ef-bicon-svg { color: #ef4444; display: block; }
.ef-circle-grid.exporting .ef-bicon-svg { color: #3b82f6; }

/* SVG pipes area underneath the nodes */
.ef-pipes-svg {
    width: 100%;
    height: auto;
    display: block;
    margin-top: 4px;
}

/* Shared circle color classes (used by both mobile and desktop) */
.ef-circle-pv { border-color: #fbbf24; background: #fffbeb; }
.ef-circle-pv2 { border-color: #a78bfa; background: #f5f3ff; }
.ef-circle-home { border-color: #fb923c; background: #fff7ed; }
.ef-circle-bat { border-color: #34d399; background: #ecfdf5; }
.ef-circle-bat.discharging { border-color: #f59e0b; background: #fffbeb; }
.ef-circle-bat.charging { border-color: #10b981; background: #ecfdf5; }
.ef-circle-bat.standby { border-color: #d1d5db; background: #f9fafb; }
.ef-circle-grid { border-color: #f87171; background: #fef2f2; }
.ef-circle-grid.exporting { border-color: #3b82f6; background: #eff6ff; }
.ef-circle-grid.importing { border-color: #ef4444; background: #fef2f2; }

/* Dark theme adjustments */
[data-theme="dark"] .ef-circle-pv { background: rgba(251,191,36,0.1); }
[data-theme="dark"] .ef-circle-pv2 { background: rgba(167,139,250,0.1); }
[data-theme="dark"] .ef-circle-home { background: rgba(251,146,60,0.1); }
[data-theme="dark"] .ef-circle-bat { background: rgba(52,211,153,0.1); }
[data-theme="dark"] .ef-circle-bat.discharging { background: rgba(245,158,11,0.1); }
[data-theme="dark"] .ef-circle-bat.standby { background: rgba(209,213,219,0.05); }
[data-theme="dark"] .ef-circle-grid { background: rgba(248,113,113,0.1); }
[data-theme="dark"] .ef-circle-grid.exporting { background: rgba(59,130,246,0.1); }

/* ── Ertrag heute ── */
.yield-today-layout {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 0;
}
.yield-today-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.yield-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.yield-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}
.yield-stat-value {
    font-size: 14px;
    font-weight: 700;
}

/* Desktop-only legacy classes (used by desktop SVG) */
.ef-grid { display: none; }
.ef-node { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ef-circle { width: 64px; height: 64px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2.5px solid; transition: all 0.3s; }
.ef-icon { font-size: 18px; line-height: 1; }
.ef-value { font-size: 11px; font-weight: 700; line-height: 1; margin-top: 2px; }
.ef-circle-pv .ef-value { color: #f59e0b; }
.ef-circle-pv2 .ef-value { color: #7c3aed; }
.ef-circle-pv2 .ef-icon { font-size: 14px; }
.ef-circle-home .ef-value { color: #ea580c; }
.ef-circle-bat .ef-value { color: #059669; }
.ef-circle-bat.discharging .ef-value { color: #b45309; }
.ef-circle-bat.standby .ef-value { color: #6b7280; }
.ef-circle-grid .ef-value { color: #ef4444; }
.ef-circle-grid.exporting .ef-value { color: #3b82f6; }
.ef-label { font-size: 9px; font-weight: 600; letter-spacing: 0.8px; color: var(--text-secondary); text-align: center; text-transform: uppercase; }
.ef-sublabel { font-size: 8px; font-weight: 600; letter-spacing: 0.5px; color: var(--text-muted); text-transform: uppercase; }

/* ── Forecast Days Summary ── */
.forecast-days {
    display: flex; gap: 8px; margin-top: 12px;
}
.forecast-day-card {
    flex: 1; text-align: center; padding: 8px 4px;
    background: var(--bg-subtle); border-radius: var(--radius-xs);
}
.forecast-day-name { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.3px; }
.forecast-day-kwh { font-size: 16px; font-weight: 700; color: var(--pv-color); margin: 4px 0 2px; }
.forecast-day-unit { font-size: 10px; color: var(--text-muted); }

/* ── Day Energy ── */
.day-energy-card { padding: 16px 20px; }
.day-energy-list { display: flex; flex-direction: column; gap: 10px; }
.day-energy-row { display: flex; align-items: center; gap: 10px; }
.day-energy-icon { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; opacity: 0.7; }
.day-energy-info { flex: 1; min-width: 0; }
.day-energy-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 3px; }
.day-energy-bar-wrap { height: 7px; background: var(--bg-subtle); border-radius: 4px; overflow: hidden; }
.day-energy-bar {
    height: 100%; border-radius: 4px;
    transition: width 0.8s ease; min-width: 2px;
}
.day-energy-bar.pv { background: var(--pv-color); }
.day-energy-bar.export { background: var(--grid-export-color); }
.day-energy-bar.import { background: var(--grid-import-color); }
.day-energy-bar.load { background: var(--load-color); }
.day-energy-bar.bat-charge { background: var(--battery-color); }
.day-energy-bar.bat-discharge { background: #6ee7b7; }
.day-energy-value {
    font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
    width: 75px; text-align: right; flex-shrink: 0; color: var(--text-primary);
}

/* ── Rates Row ── */
.rates-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-card {
    background: var(--bg-subtle); border: none;
    border-radius: var(--radius-sm); padding: 10px; text-align: center;
}
.rate-value {
    font-size: 20px; font-weight: 700; color: var(--accent-green);
    font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
}
.rate-value .kpi-unit { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.rate-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Charts ── */
.chart-tabs { display: flex; gap: 4px; }
.chart-tab {
    padding: 5px 14px; border-radius: 16px;
    background: var(--bg-subtle); border: 1px solid transparent;
    color: var(--text-secondary); cursor: pointer; font-size: 12px;
    transition: all 0.2s; font-weight: 500;
}
.chart-tab:hover { color: var(--text-primary); background: var(--bg-input); }
.chart-tab.active { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }
.chart-wrapper {
    width: 100%; height: 320px;
    background: var(--bg-card); border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

/* ── Chart Toggles ── */
.chart-header-row {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 12px;
    flex-wrap: wrap; gap: 8px;
}
.chart-toggles { display: flex; gap: 3px; flex-wrap: wrap; }
.chart-toggle {
    padding: 3px 8px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--bg-subtle);
    color: var(--text-muted); font-size: 10px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.chart-toggle.active {
    background: var(--toggle-color, var(--text-primary));
    color: #fff; border-color: var(--toggle-color, var(--text-primary));
}
.chart-toggle:hover:not(.active) { border-color: var(--text-secondary); }

/* ── Daily Comparison Table ── */
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th {
    text-align: left; font-size: 10px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}
.compare-table td {
    padding: 7px 10px; font-size: 12px;
    border-bottom: 1px solid var(--border-light); color: var(--text-primary);
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--bg-subtle); }
.trend-good { color: var(--accent-green); font-size: 10px; font-weight: 600; margin-left: 3px; }
.trend-bad { color: var(--accent-red); font-size: 10px; font-weight: 600; margin-left: 3px; }

/* ── Accordion ── */
.accordion { display: flex; flex-direction: column; gap: 4px; }
.accordion-item {
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); overflow: hidden;
    transition: border-color 0.15s;
}
.accordion-item:hover { border-color: var(--border); }
.accordion-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; cursor: pointer; user-select: none;
    transition: background 0.1s;
}
.accordion-header:hover { background: var(--bg-subtle); }
.accordion-header-left { display: flex; align-items: center; gap: 8px; }
.accordion-title {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.accordion-chevron {
    font-size: 9px; color: var(--text-muted);
    transition: transform 0.25s ease; display: inline-block;
}
.accordion-item.open .accordion-chevron { transform: rotate(180deg); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.accordion-item.open .accordion-body { max-height: 500px; }
.accordion-content {
    padding: 0 14px 10px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 3px 0; font-size: 12px;
}
.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* ── Connection Banner ── */
.connection-banner {
    display: none; padding: 6px 20px;
    background: var(--accent-red);
    color: #fff; text-align: center; font-size: 12px; font-weight: 500;
}
.connection-banner.show { display: block; }
.connection-banner.stale { background: var(--accent-orange); }

/* ── Loading ── */
.loading-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 60vh; gap: 16px; color: var(--text-secondary);
}
.loading-spinner {
    width: 32px; height: 32px; border: 2px solid var(--border);
    border-top-color: var(--accent-yellow); border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.no-device-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 60vh; gap: 10px; color: var(--text-secondary); text-align: center; padding: 24px;
}
.no-device-icon { font-size: 48px; opacity: 0.25; }

/* ── Time Slots ── */
.time-slot {
    background: var(--bg-subtle); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden;
}
.time-slot-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
}
.time-slot-title {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    display: flex; align-items: center; gap: 6px;
}
.time-slot-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-primary);
    font-size: 10px; font-weight: 700;
}
.time-slot-body { padding: 0 14px 12px; }

/* ── Toast Notifications ── */
.toast-container {
    position: fixed; bottom: 20px; right: 12px; left: 12px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 2000; max-width: 360px; margin-left: auto;
}
.toast {
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: var(--shadow-md); font-size: 13px;
    color: var(--text-primary); display: flex; align-items: center; gap: 8px;
    animation: toastIn 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}
.toast.removing { opacity: 0; transform: translateX(100%); }
.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error { border-left: 3px solid var(--accent-red); }
.toast-warning { border-left: 3px solid var(--accent-orange); }
.toast-info { border-left: 3px solid var(--accent-blue); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ===========================
   DESKTOP LAYOUT (>= 1024px)
   =========================== */

@media (min-width: 1024px) {
    .header-content { padding: 10px 32px; }
    .nav-content { padding: 0 32px; }
    .main-nav { top: 41px; }
    .main { padding: 20px 32px; max-width: 1400px; }

    .dashboard-grid {
        grid-template-columns: 3fr 2fr;
        grid-template-areas:
            "flow     energy"
            "yield    energy"
            "chart    chart"
            "forecast forecast"
            "sankey   sankey"
            "compare  details"
            "devcomp  health";
        gap: 20px;
    }
    .grid-forecast { grid-area: forecast; }
    .grid-yield-today { grid-area: yield; }

    .grid-flow      { grid-area: flow; }
    .grid-dayenergy { grid-area: energy; }
    .grid-chart     { grid-area: chart; }
    .grid-sankey    { grid-area: sankey; }
    .grid-compare   { grid-area: compare; }
    .grid-details   { grid-area: details; }
    .grid-devcompare { grid-area: devcomp; }
    .grid-health    { grid-area: health; }

    .chart-wrapper { height: 380px; }

    .flow-svg { width: 100%; height: auto; min-height: 200px; max-height: 340px; }
    .ef-grid { display: none; }
    .ef-row-wrap { display: none; } /* Desktop uses SVG, not row */

    /* Accordion: 3 columns on desktop */
    .accordion {
        display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
    }
    #mppt-accordions { display: contents; }
}

/* ===========================
   WIDE DESKTOP (>= 1400px)
   =========================== */

@media (min-width: 1400px) {
    .header-content { padding: 10px 40px; }
    .nav-content { padding: 0 40px; }
    .main { padding: 24px 40px; }

    .dashboard-grid { gap: 18px; }
    .chart-wrapper { height: 420px; }
}

/* ===========================
   EXTRA-WIDE (>= 1700px)
   =========================== */

@media (min-width: 1700px) {
    .main { padding: 28px 56px; max-width: 1400px; }
    .chart-wrapper { height: 460px; }
}

/* ===========================
   TABLET LAYOUT (768-1023px)
   =========================== */

@media (min-width: 768px) and (max-width: 1023px) {
    .main { padding: 16px 20px; }

    .kpi-strip { grid-template-columns: repeat(5, 1fr); }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "flow    energy"
            "yield   energy"
            "chart   chart"
            "sankey  sankey"
            "compare details"
            "devcomp health";
    }
    .grid-yield-today { grid-area: yield; }

    .grid-flow      { grid-area: flow; }
    .grid-dayenergy { grid-area: energy; }
    .grid-chart     { grid-area: chart; }
    .grid-sankey    { grid-area: sankey; }
    .grid-compare   { grid-area: compare; }
    .grid-details   { grid-area: details; }
    .grid-devcompare { grid-area: devcomp; }
    .grid-health    { grid-area: health; }

    .chart-wrapper { height: 340px; }
    .report-chart { height: min(380px, 40vh); }
}

/* ===========================
   MOBILE LAYOUT (< 768px)
   =========================== */

@media (max-width: 767px) {
    .header-content { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
    .header-left { gap: 8px; }
    .header-right { gap: 8px; }
    .device-selector { display: none !important; }
    .nav-content { padding: 0 12px; }
    .main-nav { top: 37px; }
    .nav-tab { padding: 10px 16px; font-size: 13px; -webkit-tap-highlight-color: transparent; }
    .main { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }

    .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }

    .kpi-strip { display: none; }

    .chart-wrapper { height: 280px; }
    .user-name { display: none; }
    .user-avatar { display: none; }
    .clock { display: none; }
    .status-indicator { display: none; }
    .theme-toggle { display: none; }
    .ef-bcircle { width: 44px; height: 44px; }
    .ef-bicon { font-size: 14px; }
    .ef-bvalue { font-size: 10px; }
    .ef-blabel { font-size: 7px; }
    .chart-header-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .logo { flex-shrink: 0; }
    .logo svg { width: 140px; height: auto; }
    .accordion-content { grid-template-columns: 1fr; }
    .chart-tab { padding: 8px 14px; font-size: 12px; }
    .chart-toggle { padding: 4px 10px; font-size: 11px; }
    .card { padding: 14px 16px; }
    .btn-icon { min-width: 48px; min-height: 48px; font-size: 22px; }
    .accordion-header { min-height: 44px; }
}

@media (max-width: 480px) {
    .kpi-strip { display: none; }
    .rates-row { grid-template-columns: 1fr; }
    .day-energy-value { font-size: 13px; }
    .card-title { font-size: 10px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Auth Pages ── */
.auth-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: var(--bg-primary);
}
.auth-container { width: 100%; max-width: 380px; padding: 20px; }
.auth-card {
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 32px 28px;
    box-shadow: var(--shadow-md);
}
.auth-logo { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 4px; color: var(--text-primary); }
.auth-logo-cloud { font-size: 16px; font-weight: 400; color: var(--text-muted); }
.auth-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 28px; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.form-group input, .form-group select {
    padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-xs); color: var(--text-primary); font-size: 14px;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--brand); }
.form-group input::placeholder { color: var(--text-muted); }
.auth-error { color: var(--accent-red); font-size: 12px; min-height: 18px; }
.auth-success { color: var(--accent-green); font-size: 12px; min-height: 18px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-secondary); }
.auth-footer a { color: var(--brand); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn {
    padding: 8px 16px; border-radius: var(--radius-xs);
    border: 1px solid var(--border); cursor: pointer;
    font-size: 13px; font-weight: 500; transition: all 0.15s;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--brand); border: none; color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-lg { padding: 10px 20px; font-size: 14px; width: 100%; margin-top: 6px; border-radius: var(--radius-sm); }
.btn-sm { padding: 5px 12px; font-size: 11px; }
.btn-success { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }
.btn-danger { background: var(--accent-red); border-color: var(--accent-red); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--text-secondary); }

/* ── Modal ── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-card {
    background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
    width: 100%; max-width: 480px; box-shadow: var(--shadow-md); max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { font-size: 22px; }
.modal-body { padding: 20px; }

/* ── Admin Page ── */
.admin-container { max-width: 1400px; margin: 0 auto; padding: 24px 32px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.admin-header h1 { font-size: 20px; font-weight: 600; }
.admin-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
    padding: 16px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.admin-section { margin-bottom: 24px; }
.admin-section h2 {
    font-size: 15px; font-weight: 600; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: space-between;
}

/* Tables */
.data-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); overflow: hidden;
}
.data-table th, .data-table td {
    padding: 8px 14px; text-align: left; font-size: 12px;
    border-bottom: 1px solid var(--border-light);
}
.data-table th {
    background: var(--bg-subtle); color: var(--text-muted);
    font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px;
}
.data-table td { color: var(--text-primary); }
.data-table tr:hover td { background: var(--bg-subtle); }
.data-table tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 8px;
    font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.badge-online { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.badge-offline { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.badge-provisioned { background: rgba(245, 158, 11, 0.1); color: var(--accent-yellow); }
.badge-active { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.badge-inactive { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.badge-admin { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }
.badge-customer { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }

.token-text {
    font-family: 'SF Mono', 'Courier New', monospace; font-size: 11px;
    background: var(--bg-subtle); padding: 2px 5px; border-radius: 3px; cursor: pointer;
}
.token-text:hover { background: var(--bg-input); }

/* MQTT Credentials */
.mqtt-cred { margin-bottom: 12px; }
.mqtt-cred label { display: block; font-size: 10px; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.mqtt-value {
    padding: 8px 12px; background: var(--bg-input); border-radius: var(--radius-xs);
    font-family: 'SF Mono', 'Courier New', monospace; font-size: 13px; word-break: break-all;
    border: 1px solid var(--border-light);
}
.mqtt-value.copyable { cursor: pointer; transition: all 0.15s; }
.mqtt-value.copyable:hover { background: var(--bg-card-hover); border-color: var(--border); }
.mqtt-value.copied { background: rgba(16, 185, 129, 0.06); border-color: var(--accent-green); }
.mqtt-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 12px; }

/* ── Settings Page ── */
.settings-container { max-width: 680px; margin: 0 auto; padding: 24px 20px; }
.settings-header { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.settings-header h1 { font-size: 20px; font-weight: 600; }
.settings-back {
    color: var(--text-muted); text-decoration: none; font-size: 18px;
    padding: 3px 6px; border-radius: var(--radius-xs); transition: all 0.15s;
}
.settings-back:hover { color: var(--text-primary); background: var(--bg-input); }

.settings-tabs {
    display: flex; gap: 0; margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.settings-tab {
    padding: 8px 18px; font-size: 13px; font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.15s;
    background: none; border-top: none; border-left: none; border-right: none;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }

.settings-panel { display: none; }
.settings-panel.active { display: block; }

.settings-section {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.settings-section-title {
    font-size: 14px; font-weight: 600; margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
}
.settings-section-desc {
    font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.6;
}

.setup-step {
    margin-bottom: 16px; padding: 16px;
    background: var(--bg-subtle); border-radius: var(--radius-sm);
    border-left: 3px solid var(--text-primary);
}
.setup-step-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-primary);
    font-size: 11px; font-weight: 700; margin-right: 8px;
}
.setup-step-title {
    font-size: 13px; font-weight: 600; margin-bottom: 10px;
    display: flex; align-items: center;
}

.code-block {
    background: #1e293b; border: none;
    border-radius: var(--radius-xs); padding: 14px;
    font-family: 'SF Mono', 'Courier New', monospace; font-size: 12px;
    line-height: 1.6; overflow-x: auto; position: relative; color: #e2e8f0;
}
.code-block .copy-btn {
    position: absolute; top: 6px; right: 6px;
    padding: 3px 8px; font-size: 10px;
    background: rgba(255,255,255,0.1); border: none;
    border-radius: 3px; color: rgba(255,255,255,0.6); cursor: pointer;
    transition: all 0.15s;
}
.code-block .copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.code-block .copy-btn.copied { background: rgba(16, 185, 129, 0.3); color: var(--accent-green); }

.entity-list { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.entity-item {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; background: var(--bg-input);
    border-radius: var(--radius-xs); font-size: 12px;
    font-family: 'SF Mono', 'Courier New', monospace;
}
.entity-dot { width: 5px; height: 5px; border-radius: 50%; }

/* ── Reports ── */
.reports-container { max-width: 100%; padding: 0; }
.report-type-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.report-type-tab {
    padding: 6px 14px; border-radius: 16px;
    background: var(--bg-subtle); border: 1px solid transparent;
    color: var(--text-secondary); cursor: pointer;
    font-size: 12px; font-weight: 500; transition: all 0.15s;
}
.report-type-tab:hover { color: var(--text-primary); background: var(--bg-input); }
.report-type-tab.active { background: var(--text-primary); color: #fff; }
.date-picker-row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.date-quick-btn {
    padding: 5px 12px; border-radius: 14px;
    background: var(--bg-subtle); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer;
    font-size: 11px; transition: all 0.15s;
}
.date-quick-btn:hover { background: var(--bg-input); }
.date-quick-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.date-input {
    padding: 5px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-xs); background: var(--bg-input);
    color: var(--text-primary); font-size: 12px;
}
.summary-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.summary-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 12px; text-align: center;
}
.summary-card-value {
    font-size: 22px; font-weight: 700; color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.summary-card-unit { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.summary-card-label {
    font-size: 10px; color: var(--text-muted); margin-top: 3px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.report-chart-container {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 20px;
}
.report-chart { width: 100%; height: 380px; }
.export-row { display: flex; gap: 8px; margin-top: 12px; }
@media (max-width: 767px) {
    .report-chart { height: 260px; }
    .summary-cards { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
    .summary-card-value { font-size: 18px; }
}

/* ── Controls Tab ── */
.controls-container { max-width: 720px; margin: 0 auto; padding: 0; }
.control-group {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.control-group-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.control-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--border-light);
}
.control-row:last-child { border-bottom: none; }
.control-label { font-size: 13px; color: var(--text-secondary); }
.control-input {
    width: 72px; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--bg-input); color: var(--text-primary);
    font-size: 13px; text-align: center;
}
.control-select {
    padding: 5px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-xs); background: var(--bg-input);
    color: var(--text-primary); font-size: 13px;
}
.control-toggle {
    position: relative; width: 40px; height: 22px;
    background: var(--bg-subtle); border-radius: 11px;
    border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.control-toggle.active { background: var(--accent-green); border-color: var(--accent-green); }
.control-toggle::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: white; transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.control-toggle.active::after { transform: translateX(18px); }
.control-status {
    padding: 10px; margin-top: 10px; border-radius: var(--radius-xs);
    font-size: 12px; display: none;
}
.control-status.success { display: block; background: rgba(16,185,129,0.1); color: var(--accent-green); }
.control-status.error { display: block; background: rgba(239,68,68,0.1); color: var(--accent-red); }

/* ── Onboarding Wizard ── */
.onboarding-container { max-width: 560px; margin: 32px auto; padding: 0 20px; }

.wizard-progress { height: 3px; background: var(--bg-subtle); border-radius: 2px; overflow: hidden; margin-bottom: 20px; }
.wizard-progress-bar { height: 100%; background: var(--brand); border-radius: 2px; transition: width 0.4s ease; }

.wizard-steps-indicator { display: flex; justify-content: space-between; margin-bottom: 28px; }
.step-dot { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; }
.step-dot-circle {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--bg-subtle); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--text-muted); transition: all 0.2s;
}
.step-dot.active .step-dot-circle { background: var(--brand); border-color: var(--brand); color: #fff; }
.step-dot.done .step-dot-circle { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }
.step-dot-label { font-size: 9px; color: var(--text-muted); text-align: center; }
.step-dot.active .step-dot-label { color: var(--text-primary); font-weight: 600; }

.wizard-step { display: none; animation: fadeIn 0.3s ease; }
.wizard-step.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.wizard-step h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.wizard-desc { color: var(--text-secondary); font-size: 13px; line-height: 1.6; margin-bottom: 20px; }
.wizard-icon { font-size: 40px; text-align: center; margin-bottom: 12px; }

.wizard-form { display: flex; flex-direction: column; gap: 14px; }
.wizard-form .form-group input, .wizard-form .form-group select { width: 100%; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.wizard-toggle-row { display: flex; align-items: center; gap: 10px; }

.wizard-nav {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border);
}
.wizard-step-label { font-size: 11px; color: var(--text-muted); }

.wizard-status { margin-top: 10px; font-size: 12px; min-height: 18px; }
.wizard-status.error { color: var(--accent-red); }
.wizard-status.success { color: var(--accent-green); }

.mppt-config-card {
    background: var(--bg-subtle); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px;
}
.mppt-config-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; }

.wizard-summary { display: flex; flex-direction: column; gap: 16px; }
.summary-section { background: var(--bg-subtle); border-radius: var(--radius-sm); padding: 14px 16px; }
.summary-title {
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px;
}
.summary-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; font-size: 13px;
}
.summary-row span { color: var(--text-secondary); }
.summary-row strong { color: var(--text-primary); }

@media (max-width: 767px) {
    .onboarding-container { padding: 0 12px; margin: 16px auto; }
    .wizard-steps-indicator { display: none; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .chart-header-row { flex-direction: column; align-items: flex-start; }
}

/* ── Controls: responsive input classes ── */
.control-time-input { width: 110px; }
.control-number-input { width: 100px; }
@media (max-width: 767px) {
    .control-time-input { width: 100%; max-width: 140px; }
    .control-number-input { width: 100%; max-width: 100px; }
    .control-row { flex-wrap: wrap; gap: 6px; }
}

/* ── Admin: mobile responsive ── */
@media (max-width: 767px) {
    .admin-container { padding: 12px; }
    .admin-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .admin-header h1 { font-size: 18px; }
    .admin-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 600px; }
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Weather Strip ── */
.weather-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-card, #fff);
    border-radius: var(--radius, 10px);
    margin: 0 0 12px 0;
    font-size: 13px;
    box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,0.06));
    border: 1px solid var(--border, #e5e7eb);
}
.weather-current {
    display: flex;
    align-items: center;
    gap: 8px;
}
.weather-temp {
    font-size: 18px;
    font-weight: 600;
}
.weather-desc {
    color: var(--text-secondary, #6b7280);
    margin-left: 4px;
}
.weather-details {
    display: flex;
    gap: 12px;
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
}
@media (max-width: 600px) {
    .weather-strip {
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
        padding: 10px 12px;
    }
    .weather-current { justify-content: space-between; }
    .weather-details { font-size: 11px; }
    .weather-forecast { gap: 4px; overflow-x: auto; flex-wrap: nowrap; }
    .weather-day { min-width: 52px; padding: 4px 2px; }
    .weather-day-icon { font-size: 16px; }
    .weather-day-name { font-size: 9px; }
    .weather-day-temp { font-size: 11px; }
    .weather-day-clouds { font-size: 9px; }
}

/* ── Theme Toggle ── */
.theme-toggle {
    font-size: 18px;
    line-height: 1;
}

/* ── Tariff Strip ── */
.tariff-strip {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; background: var(--bg-card);
    border-radius: var(--radius); margin: 0 0 12px 0;
    font-size: 13px; box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.tariff-label { color: var(--text-secondary); margin-right: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.tariff-price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tariff-current { display: flex; align-items: center; gap: 4px; }
.tariff-range { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); }
.tariff-min { color: var(--accent-green); }
.tariff-max { color: var(--accent-red); }
@media (max-width: 600px) {
    .tariff-strip { flex-direction: column; gap: 4px; align-items: flex-start; }
}

/* ── Weather Forecast ── */
.weather-forecast { display: flex; gap: 8px; margin-top: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.weather-day {
    flex: 1; text-align: center; padding: 6px 4px;
    background: var(--bg-subtle); border-radius: var(--radius-xs);
    font-size: 11px; color: var(--text-secondary);
}
.weather-day-name { font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px; }
.weather-day-icon { font-size: 20px; margin: 2px 0; }
.weather-day-temp { font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 2px 0; }
.weather-day-clouds { font-size: 10px; color: var(--text-muted); }

/* ── Device Comparison ── */
.devcompare-content { margin-top: 8px; }
.devcompare-device { margin-bottom: 12px; }
.devcompare-device-name {
    font-size: 12px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 4px; display: flex; align-items: center; gap: 6px;
}
.devcompare-device-name .badge { font-size: 9px; padding: 1px 6px; }
.devcompare-bars { display: flex; flex-direction: column; gap: 4px; }
.devcompare-bar-row {
    display: flex; align-items: center; gap: 8px; font-size: 11px;
}
.devcompare-bar-label { width: 70px; color: var(--text-secondary); flex-shrink: 0; }
.devcompare-bar-wrap {
    flex: 1; height: 12px; background: var(--bg-subtle);
    border-radius: 6px; overflow: hidden; position: relative;
}
.devcompare-bar {
    height: 100%; border-radius: 6px; transition: width 0.8s ease; min-width: 2px;
}
.devcompare-bar.pv { background: var(--pv-color); }
.devcompare-bar.load { background: var(--load-color); }
.devcompare-bar.export { background: var(--grid-export-color); }
.devcompare-bar.import { background: var(--grid-import-color); }
.devcompare-bar-value {
    width: 60px; text-align: right; font-weight: 600;
    font-variant-numeric: tabular-nums; color: var(--text-primary);
    flex-shrink: 0;
}
.devcompare-stats {
    display: flex; gap: 12px; margin-top: 4px; font-size: 11px; color: var(--text-muted);
}
.devcompare-stat-value { font-weight: 600; color: var(--text-primary); }

/* ── Health Score ── */
.health-score-display {
    display: flex; align-items: flex-start; gap: 20px;
}
.health-score-circle {
    position: relative; width: 100px; height: 100px; flex-shrink: 0;
}
.health-score-circle svg { width: 100%; height: 100%; }
.health-score-value {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px; font-weight: 800; color: var(--text-primary);
    letter-spacing: -1px;
}
.health-grade {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-align: center; margin-top: -4px;
}
.health-components { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.health-component {
    display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.health-component-name { width: 110px; color: var(--text-secondary); flex-shrink: 0; }
.health-component-bar-wrap {
    flex: 1; height: 8px; background: var(--bg-subtle);
    border-radius: 4px; overflow: hidden;
}
.health-component-bar {
    height: 100%; border-radius: 4px; transition: width 0.8s ease;
}
.health-component-score {
    width: 40px; text-align: right; font-weight: 600;
    font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-primary);
}
.health-recommendations {
    margin-top: 12px; display: flex; flex-direction: column; gap: 4px;
}
.health-rec {
    font-size: 11px; color: var(--text-secondary);
    padding: 4px 8px; background: var(--bg-subtle);
    border-radius: var(--radius-xs); border-left: 2px solid var(--accent-orange);
}
.health-rec.good { border-left-color: var(--accent-green); }

@media (max-width: 767px) {
    .health-score-display { flex-direction: column; align-items: center; }
    .health-components { width: 100%; }
}

/* ── Inverter Error Banner ── */
.inverter-error-banner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    z-index: 100;
    position: relative;
}
.inverter-error-banner.error-warning {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 2px solid #f59e0b;
}
.inverter-error-banner.error-error {
    background: #fee2e2;
    color: #991b1b;
    border-bottom: 2px solid #ef4444;
}
.inverter-error-banner.error-critical {
    background: #fecaca;
    color: #7f1d1d;
    border-bottom: 2px solid #dc2626;
    animation: error-pulse 2s ease-in-out infinite;
}
@keyframes error-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}
.error-banner-icon { font-size: 18px; flex-shrink: 0; }
.error-banner-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 4px 8px;
    border-radius: 4px;
}
.error-banner-dismiss:hover { opacity: 1; background: rgba(0,0,0,0.1); }

[data-theme="dark"] .inverter-error-banner.error-warning {
    background: #78350f;
    color: #fef3c7;
    border-bottom-color: #f59e0b;
}
[data-theme="dark"] .inverter-error-banner.error-error {
    background: #7f1d1d;
    color: #fecaca;
    border-bottom-color: #ef4444;
}
[data-theme="dark"] .inverter-error-banner.error-critical {
    background: #991b1b;
    color: #fecaca;
    border-bottom-color: #dc2626;
}


/* ── Tooltip System ── */
[data-tooltip] {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--text-muted);
}
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--tooltip-bg, rgba(17,24,39,0.95));
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    width: max-content;
    max-width: min(260px, 90vw);
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    letter-spacing: 0;
    text-transform: none;
}
[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--tooltip-bg, rgba(17,24,39,0.95));
    z-index: 1001;
    pointer-events: none;
}
[data-theme="dark"] [data-tooltip]:hover::after {
    background: rgba(40, 44, 62, 0.97);
}
[data-theme="dark"] [data-tooltip]:hover::before {
    border-top-color: rgba(40, 44, 62, 0.97);
}
