:root {
  --app-bg: #f3f7fd;
  --app-panel: #fff;
  --app-text: #0f2544;
  --app-muted: #5a6f8f;
  --app-line: #e0e9f6;
  --app-blue: #1f6fff;
  --app-navy: #0a2a6c;
  --app-green: #12a150;
  --app-red: #d9363e;
  --app-amber: #e08a00;
}

body { background: var(--app-bg); color: var(--app-text); }
[hidden] { display: none !important; }
.sidebar { background: var(--app-navy); color: white; display:flex; flex-direction:column; gap:24px; min-height:100vh; padding:22px 14px; position:fixed; width:244px; }
.brand { align-items:center; color:white; display:flex; gap:12px; }
.brand b,.brand small { display:block; }
.brand small { color:#b9c9e6; font-size:11px; }
.brand-mark { display:block; flex:none; height:40px; object-fit:contain; width:40px; }
.nav-group { display:grid; gap:5px; }
.nav-label { color:#9db3d6; font-size:10px; font-weight:700; letter-spacing:.12em; margin:4px 10px; text-transform:uppercase; }
.nav-link { border-radius:8px; color:#dce7f8; display:block; padding:10px; }
.nav-link:hover,.nav-link.active { background:#ffffff20; color:white; }
.sidebar-user { border-top:1px solid #ffffff30; color:white; font-size:13px; margin-top:auto; padding:14px 5px 0; }
.sidebar-user small { color:#b9c9e6; display:block; }
.main { margin-left:244px; min-height:100vh; }
.topbar { align-items:center; background:#fff; border-bottom:1px solid var(--app-line); display:flex; gap:16px; justify-content:space-between; padding:16px 28px; position:sticky; top:0; z-index:2; }
.topbar h1 { font-size:20px; margin:0 auto 0 0; }
.content { margin:0 auto; max-width:1200px; padding:26px; }
.menu-button { background:transparent; border:0; display:none; font-size:20px; }
.page-heading { align-items:center; display:flex; flex-wrap:wrap; gap:16px; justify-content:space-between; margin-bottom:22px; }
.page-heading h2 { margin:0 0 4px; }
.page-heading p,.muted { color:var(--app-muted); margin:0; }
.grid { display:grid; gap:16px; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); margin:16px 0; }
.chart-grid { display:grid; gap:14px; grid-template-columns:repeat(2,minmax(0,1fr)); margin:16px 0; }
.panel.chart-panel { border-radius:14px; margin:0; min-width:0; padding:20px; }
.chart-heading { align-items:flex-start; display:flex; justify-content:space-between; margin-bottom:16px; }
.chart-heading h3 { font-size:16px; letter-spacing:-.01em; margin:0 0 4px; }
.chart-heading p { font-size:12px; }
.history-chart-controls { align-items:flex-end; border-bottom:1px solid var(--app-line); display:flex; flex-wrap:wrap; gap:14px 18px; margin:-2px 0 14px; padding:0 0 14px; }
.history-control { display:grid; gap:6px; }
.history-control-label { color:var(--app-muted); font-size:11px; font-weight:700; }
.period-switch { background:#f1f5fb; border:1px solid var(--app-line); border-radius:9px; display:flex; gap:3px; padding:3px; }
.period-switch button { background:transparent; border:0; border-radius:6px; color:var(--app-muted); cursor:pointer; font:inherit; font-size:12px; font-weight:600; min-height:34px; min-width:66px; padding:6px 12px; }
.period-switch button.active { background:#fff; box-shadow:0 1px 4px #102a5a20; color:var(--app-blue); }
.history-control input,.history-control select { min-height:40px; }
.history-control input[type="month"] { min-width:160px; }
.history-control input[type="number"] { min-width:110px; width:110px; }
.chart-loading { align-items:center; color:var(--app-muted); display:flex; gap:10px; justify-content:center; min-height:260px; }
.chart-loading::before { animation:chart-spin .8s linear infinite; border:2px solid #dce7f5; border-right-color:var(--app-blue); border-radius:50%; content:""; height:18px; width:18px; }
@keyframes chart-spin { to { transform:rotate(360deg); } }
.chart-unit-row { color:var(--app-muted); display:flex; font-size:11px; justify-content:space-between; margin:4px 0 -4px; }
.chart-svg { display:block; height:auto; overflow:visible; width:100%; }
.chart-grid-line { stroke:#e3eaf3; stroke-width:1; }
.chart-axis-label { fill:#64748b; font-size:11px; }
.chart-line { fill:none; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; }
.chart-legend { display:flex; flex-wrap:wrap; gap:8px 14px; margin:4px 0 2px; }
.chart-legend span { align-items:center; color:var(--app-muted); display:inline-flex; font-size:11px; gap:5px; }
.chart-legend i { background:var(--series-color); border-radius:2px; display:inline-block; height:8px; width:8px; }
.card,.panel { background:var(--app-panel); border:1px solid var(--app-line); border-radius:12px; box-shadow:0 5px 20px #102a5a08; padding:18px; }
.card { min-width:0; transition:border-color .15s ease,box-shadow .15s ease; }
.card:hover { border-color:#cadcf4; box-shadow:0 8px 24px #102a5a0d; }
.plant-card { display:flex; flex-direction:column; gap:12px; }
.plant-card-heading { align-items:flex-start; justify-content:space-between; }
.plant-card-heading b { font-size:15px; }
.plant-card > .muted { min-height:20px; }
.plant-card-metrics { border-block:1px solid var(--app-line); display:flex; flex-wrap:wrap; gap:12px 24px; padding:10px 0; }
.plant-card-metrics span { color:var(--app-muted); display:grid; font-size:11px; gap:2px; }
.plant-card-metrics b { color:var(--app-text); font-size:13px; }
.plant-card .btn { align-self:flex-start; margin-top:auto; }
.card-label { color:var(--app-muted); font-size:12px; font-weight:600; }
.card-value { font-size:clamp(21px,2vw,25px); font-weight:800; margin-top:5px; overflow-wrap:anywhere; }
.panel { margin:16px 0; overflow-x:auto; }
.panel h3 { margin:0 0 14px; }
.plant-overview { grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); }
.plant-overview .card { padding:15px; }
.plant-flow-panel { overflow-x:auto; }
.back-link { color:var(--app-blue); display:inline-block; font-size:12px; font-weight:700; margin-bottom:8px; }
.back-link:hover { text-decoration:underline; }
.config-grid { display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); }
.config-card { background:#f7f9fd; border:1px solid var(--app-line); border-radius:9px; min-width:0; padding:14px; }
.config-card h4 { margin:0 0 10px; }
.config-card dl { display:grid; gap:8px; margin:0; }
.config-card dl > div { border-top:1px solid var(--app-line); display:grid; gap:3px; padding-top:7px; }
.config-card dt { color:var(--app-muted); font-size:11px; }
.config-card dd { margin:0; overflow-wrap:anywhere; }
.flow-grid { display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); }
.flow-item { background:#f2f6fc; border-radius:9px; padding:13px; }
.flow-item b,.flow-item small { display:block; }
.flow-item small { color:var(--app-muted); }
.table-wrap { overflow-x:auto; }
table { border-collapse:collapse; min-width:620px; width:100%; }
th,td { border-bottom:1px solid var(--app-line); padding:11px 9px; text-align:left; vertical-align:top; }
th { color:var(--app-muted); font-size:11px; text-transform:uppercase; }
.btn { background:var(--app-blue); border:1px solid var(--app-blue); border-radius:8px; color:#fff; cursor:pointer; display:inline-block; font:inherit; font-size:13px; font-weight:700; padding:9px 13px; }
.btn:hover { filter:brightness(.94); }
.btn.secondary { background:#edf4ff; border-color:#d6e6ff; color:var(--app-blue); }
.btn.ghost { background:transparent; border-color:var(--app-line); color:var(--app-text); }
.btn.danger { background:var(--app-red); border-color:var(--app-red); }
.btn.sm { font-size:12px; padding:6px 9px; }
.actions { display:flex; flex-wrap:wrap; gap:8px; }
.field { display:grid; gap:6px; margin-bottom:14px; }
.field label { color:#314967; font-size:12px; font-weight:700; }
input,select { background:#fff; border:1px solid #c9d9ef; border-radius:7px; color:var(--app-text); font:inherit; min-height:39px; padding:8px 10px; width:100%; }
input:focus,select:focus { border-color:var(--app-blue); outline:2px solid #1f6fff25; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible { outline:3px solid #1f6fff55; outline-offset:2px; }
.form-grid { display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); }
.flash { border-radius:8px; margin:12px 0; padding:11px 13px; }
.flash.error { background:#fff0f0; border:1px solid #f3c6c6; color:#9d1720; }
.flash.ok { background:#e9fbf0; border:1px solid #bce7cd; color:#126b38; }
.badge { border-radius:99px; display:inline-block; font-size:11px; font-weight:700; padding:4px 8px; }
.badge.on { background:#e7f8ee; color:#138145; }
.badge.off { background:#fff0f0; color:#b32a32; }
.badge.warn { background:#fff5df; color:#996000; }
.badge.info { background:#eaf2ff; color:#1b5dc6; }
.empty { background:#fff; border:1px dashed #c9d9ef; border-radius:10px; color:var(--app-muted); padding:22px; text-align:center; }
.auth-screen { align-items:center; background:radial-gradient(ellipse at 50% 0,#e6efff 0,transparent 55%),#f5f8fd; display:flex; flex-direction:column; justify-content:center; min-height:100vh; padding:32px 18px; }
.auth-brand { align-items:center; color:var(--app-text); display:flex; gap:11px; justify-content:center; margin-bottom:22px; }
.auth-brand .brand-mark { height:42px; width:42px; }
.auth-brand b,.auth-brand small { display:block; }
.auth-brand b { font-size:14px; letter-spacing:.08em; }
.auth-brand small { color:var(--app-muted); font-size:9px; letter-spacing:.1em; }
.auth-card { background:#fff; border:1px solid var(--app-line); border-radius:16px; box-shadow:0 16px 45px #102a5a12; margin:0 auto; max-width:420px; padding:30px; width:min(100%,420px); }
.auth-card h1 { font-size:24px; letter-spacing:-.03em; margin:0 0 5px; }
.auth-subtitle { color:var(--app-muted); font-size:13px; margin:0 0 23px; }
.auth-card .field { margin-bottom:16px; }
.auth-card .field label { color:#314967; }
.auth-card input { min-height:45px; }
.auth-error { font-size:12px; }
.auth-submit { align-items:center; display:flex; justify-content:center; min-height:44px; position:relative; }
.auth-submit:disabled { cursor:wait; opacity:.8; }
.auth-loading { animation:chart-spin .8s linear infinite; border:2px solid #ffffff70; border-radius:50%; border-top-color:#fff; display:none; height:15px; position:absolute; right:14px; width:15px; }
.auth-submitting .auth-loading { display:block; }
.auth-switch { color:var(--app-muted); margin-top:18px; }
.auth-switch a { color:var(--app-blue); font-weight:700; }
.notice { margin:0 26px; }
.dashboard-page { --dash-blue:#1768e8; --dash-navy:#09265f; --dash-orange:#ff941f; color:var(--app-text); }
.dashboard-heading { align-items:flex-end; display:flex; gap:16px; justify-content:space-between; margin:4px 0 22px; }
.dashboard-heading h2 { font-size:clamp(23px,3vw,30px); letter-spacing:-.04em; margin:2px 0 3px; }
.dashboard-heading > div > p:last-child { color:var(--app-muted); margin:0; }
.eyebrow { color:#7184a1; font-size:10px; font-weight:800; letter-spacing:.14em; margin:0 0 5px; }
.dashboard-refresh { align-items:center; display:inline-flex; gap:7px; }
.dashboard-hero { align-items:center; background:radial-gradient(ellipse at 92% 10%,#e0ebff 0,transparent 42%),linear-gradient(120deg,#fff,#f8faff); border:1px solid #dfe9f8; border-radius:20px; box-shadow:0 14px 36px #183d7410; display:grid; gap:24px; grid-template-columns:minmax(0,1.3fr) minmax(190px,.7fr); min-height:240px; overflow:hidden; padding:28px 34px; position:relative; }
.dashboard-hero::after { background:linear-gradient(135deg,#dceaff,#fff); border:1px solid #dce8f8; border-radius:50%; content:""; height:280px; opacity:.45; position:absolute; right:-130px; top:-195px; width:280px; }
.dashboard-hero-copy,.dashboard-gauge-wrap { position:relative; z-index:1; }
.dashboard-plant-label { align-items:center; color:#617696; display:flex; font-size:10px; font-weight:800; gap:7px; letter-spacing:.13em; }
.dashboard-sun { color:var(--dash-orange); font-size:17px; }
.dashboard-hero h3 { font-size:18px; letter-spacing:-.02em; margin:12px 0 0; }
.dashboard-address { color:var(--app-muted); font-size:12px; margin:2px 0 0; }
.dashboard-generation { color:var(--dash-navy); font-size:clamp(38px,5vw,52px); font-weight:800; letter-spacing:-.06em; line-height:1.12; margin-top:14px; }
.dashboard-generation span { color:#7184a1; font-size:17px; font-weight:600; letter-spacing:0; margin-left:7px; }
.dashboard-live-note { align-items:center; color:var(--app-muted); display:flex; flex-wrap:wrap; font-size:11px; gap:7px; margin:7px 0 0; }
.live-dot { background:#18b66a; border-radius:50%; box-shadow:0 0 0 3px #18b66a22; height:7px; width:7px; }
.dashboard-primary-action { align-items:center; background:linear-gradient(105deg,#0b2a68,#174caa); border:0; border-radius:9px; display:inline-flex; gap:18px; margin-top:17px; padding:10px 15px; }
.dashboard-gauge-wrap { align-items:center; display:flex; flex-direction:column; justify-content:center; }
.dashboard-gauge { height:145px; overflow:visible; width:145px; }
.dashboard-gauge circle { fill:none; stroke-width:9; }
.dashboard-gauge .gauge-track { stroke:#e7edf7; }
.dashboard-gauge .gauge-progress { stroke:#2f82f6; stroke-dashoffset:283; stroke-linecap:round; transform:rotate(-90deg); transform-origin:60px 60px; transition:stroke-dashoffset .5s ease; }
.dashboard-gauge .gauge-value { fill:var(--dash-navy); font-size:22px; font-weight:800; text-anchor:middle; }
.dashboard-gauge .gauge-caption { fill:#8493aa; font-size:6px; font-weight:800; letter-spacing:.13em; text-anchor:middle; }
.gauge-capacity { color:var(--app-muted); font-size:11px; margin-top:6px; }
.dashboard-metrics { display:grid; gap:14px; grid-template-columns:repeat(3,minmax(0,1fr)); margin:16px 0 20px; }
.dashboard-metric { align-items:center; background:#fff; border:1px solid var(--app-line); border-radius:14px; box-shadow:0 5px 20px #102a5a08; display:flex; gap:12px; min-width:0; padding:16px; }
.dashboard-metric-icon { align-items:center; border-radius:12px; display:grid; flex:none; font-size:20px; height:42px; justify-items:center; width:42px; }
.solar-icon { background:#fff3df; color:#f29a19; }
.load-icon { background:#e9f1ff; color:#326ddd; }
.battery-icon { background:#e6f8ef; color:#1aa464; }
.dashboard-metric div { display:grid; gap:2px; min-width:0; }
.dashboard-metric div > span { color:var(--app-muted); font-size:11px; }
.dashboard-metric b { color:var(--dash-navy); font-size:21px; line-height:1.2; }
.dashboard-metric b small { color:#788ba7; font-size:11px; font-weight:600; }
.dashboard-columns { align-items:stretch; display:grid; gap:16px; grid-template-columns:minmax(0,1.65fr) minmax(240px,.75fr); }
.dashboard-page .panel { border-radius:15px; margin:0; padding:20px; }
.dashboard-section-heading { align-items:center; display:flex; gap:12px; justify-content:space-between; margin-bottom:13px; }
.dashboard-section-heading h3 { font-size:16px; letter-spacing:-.02em; margin:0; }
.dashboard-section-heading .eyebrow { margin-bottom:2px; }
.dashboard-chart-panel { min-width:0; }
.dashboard-chart-panel .chart-loading { min-height:230px; }
.dashboard-device-tag { background:#edf4ff; border-radius:20px; color:#3867af; font-size:10px; font-weight:700; max-width:42%; overflow:hidden; padding:6px 10px; text-overflow:ellipsis; white-space:nowrap; }
.dashboard-device-select select { background:#f7f9fd; border:1px solid var(--app-line); border-radius:8px; font-size:11px; min-height:34px; max-width:150px; padding:6px 9px; }
.dashboard-health { display:flex; flex-direction:column; }
.health-check { align-items:center; background:#e7f8ee; border-radius:50%; color:#14a15a; display:grid; font-size:15px; font-weight:800; height:30px; justify-items:center; width:30px; }
.health-status { align-items:center; background:#f6faf8; border:1px solid #e6f1e9; border-radius:10px; display:flex; flex-wrap:wrap; gap:8px; padding:11px; }
.health-status > span:last-child { color:#416451; font-size:11px; }
.health-detail { align-items:center; border-bottom:1px solid #edf1f7; color:var(--app-muted); display:flex; font-size:11px; justify-content:space-between; padding:12px 2px; }
.health-detail b { color:var(--app-text); font-size:13px; }
.health-link,.text-action { background:transparent; border:0; color:#2368d2; cursor:pointer; font:inherit; font-size:11px; font-weight:700; padding:11px 2px 0; text-align:left; }
.health-link { margin-top:auto; }
.health-link span,.text-action span { margin-left:4px; }
.dashboard-devices,.dashboard-other-plants { margin-top:24px; }
.dashboard-device-grid { display:grid; gap:10px; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); }
.dashboard-device-card { align-items:center; background:#fff; border:1px solid var(--app-line); border-radius:12px; color:inherit; display:flex; gap:10px; min-width:0; padding:12px; text-align:left; transition:border-color .15s,transform .15s; width:100%; }
.dashboard-device-card:hover { border-color:#b9d1f4; transform:translateY(-1px); }
.device-art { align-items:center; background:linear-gradient(145deg,#eff5ff,#dceaff); border-radius:10px; color:#2868cf; display:grid; flex:none; font-size:20px; height:42px; justify-items:center; width:42px; }
.dashboard-device-info { display:grid; flex:1; gap:2px; min-width:0; }
.dashboard-device-info b,.dashboard-device-info small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dashboard-device-info b { font-size:11px; }
.dashboard-device-info small { color:var(--app-muted); font-size:9px; }
.dashboard-device-card .badge { flex:none; font-size:9px; }
.device-arrow { color:#8295af; font-size:16px; }
.dashboard-no-devices { margin-top:0; }
.dashboard-other-plants .grid { margin-bottom:0; }
.dashboard-empty { background:#fff; border:1px solid var(--app-line); border-radius:16px; margin-top:26px; padding:44px 20px; text-align:center; }
.dashboard-empty-icon { align-items:center; background:#fff3df; border-radius:50%; color:#f29a19; display:inline-grid; font-size:28px; height:58px; justify-items:center; width:58px; }
.dashboard-empty h3 { margin:13px 0 5px; }
.dashboard-empty p { color:var(--app-muted); margin:0 auto 17px; max-width:440px; }
.visually-hidden { clip:rect(0,0,0,0); clip-path:inset(50%); height:1px; overflow:hidden; position:absolute; white-space:nowrap; width:1px; }
.mobile-open .sidebar { transform:translateX(0); }
@media(max-width:800px) {
  .chart-grid { grid-template-columns:minmax(0,1fr); }
  .history-chart-controls { align-items:stretch; gap:12px; }
  .dashboard-columns { grid-template-columns:minmax(0,1fr); }
  .dashboard-health { min-height:235px; }
  .sidebar { box-shadow:10px 0 30px #102a5a22; transform:translateX(-105%); transition:transform .2s ease; z-index:4; }
  .main { margin-left:0; }
  .menu-button { display:block; }
  .topbar { padding:13px 16px; }
  .content { padding:18px 14px; }
}
@media(max-width:480px) {
  .panel.chart-panel { padding:15px; }
  .history-chart-controls { display:grid; grid-template-columns:1fr; }
  .plant-overview { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .dashboard-heading { align-items:flex-start; }
  .dashboard-heading h2 { font-size:24px; }
  .dashboard-refresh { padding:8px 10px; }
  .dashboard-refresh span { display:none; }
  .dashboard-hero { gap:8px; grid-template-columns:minmax(0,1fr) 116px; padding:21px 16px; }
  .dashboard-gauge { height:112px; width:112px; }
  .dashboard-generation { font-size:38px; }
  .dashboard-generation span { font-size:14px; }
  .dashboard-primary-action { font-size:11px; gap:8px; padding:9px 10px; }
  .gauge-capacity { font-size:9px; text-align:center; }
  .dashboard-metrics { gap:8px; }
  .dashboard-metric { align-items:flex-start; flex-direction:column; gap:7px; padding:11px; }
  .dashboard-metric-icon { height:34px; width:34px; }
  .dashboard-metric b { font-size:17px; }
  .dashboard-page .panel { padding:15px; }
}
@media(max-width:360px) {
  .dashboard-hero { grid-template-columns:minmax(0,1fr) 94px; padding-inline:12px; }
  .dashboard-gauge { height:94px; width:94px; }
  .dashboard-generation { font-size:33px; }
  .dashboard-metric { padding:9px; }
  .dashboard-metric b { font-size:15px; }
}
@media(max-width:480px) {
  .auth-screen { padding:22px 14px; }
  .auth-card { padding:24px 20px; }
}
@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation-duration:.01ms !important; scroll-behavior:auto !important; transition-duration:.01ms !important; }
  .power-flow-beam:not(.idle) { animation-duration:3.5s !important; animation-iteration-count:infinite !important; }
}
