:root {
  --bg: #0a0c11;
  --screen: #10131a;
  --card: #171a23;
  --text: #f3f5fa;
  --text2: #d9deea;
  --muted: #8e96a8;
  --line: rgba(174, 184, 208, .12);
  --green: #8190ff;
  --green2: #6f7df0;
  --green3: rgba(129, 144, 255, .12);
  --blue: #55c2ff;
  --cyan: #67d9dc;
  --orange: #f2b96b;
  --shadow: 0 14px 36px rgba(0, 0, 0, .22);
  --deep: 0 28px 70px rgba(0, 0, 0, .3);
  --r: 17px;
  --sidebar-width: 216px;
  color-scheme: dark;
}

html {
  background: #0a0c11;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.dashboard-body {
  display: block;
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgba(112, 125, 240, .16), transparent 34%),
    radial-gradient(circle at 14% 88%, rgba(85, 194, 255, .07), transparent 28%),
    linear-gradient(135deg, #090b10, #10131a 58%, #0a0c12);
}

#floatRefresh {
  position: fixed;
  z-index: 99999;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(164, 205, 191, .18);
  border-radius: 13px;
  color: #f3f5ff;
  background: linear-gradient(145deg, rgba(30, 34, 48, .96), rgba(19, 22, 32, .96));
  box-shadow: 0 14px 34px rgba(0, 0, 0, .3);
  user-select: none;
  touch-action: none;
  cursor: grab;
  backdrop-filter: blur(16px);
}

#floatRefresh:hover {
  border-color: rgba(129, 144, 255, .38);
  color: var(--green);
  transform: translateY(-1px);
}

#floatRefresh:active { cursor: grabbing; }
#floatRefresh svg { width: 21px; height: 21px; stroke: currentColor; }

.dashboard-body button,
.dashboard-body input,
.dashboard-body select {
  font: inherit;
}

.dashboard-body button:focus-visible,
.dashboard-body a:focus-visible,
.dashboard-body input:focus-visible,
.dashboard-body select:focus-visible {
  outline: 3px solid rgba(85, 194, 255, .38);
  outline-offset: 2px;
}

.stage {
  width: 100%;
  max-width: none;
  height: 100vh;
  display: block;
}

.phone {
  width: 100%;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.phone::before,
.phone::after {
  display: none;
}

.screen {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0;
  background:
    radial-gradient(circle at 92% 2%, rgba(112, 125, 240, .1), transparent 24%),
    #0f1218;
}

.app {
  position: relative;
  inset: auto;
  grid-column: 2;
  grid-row: 1;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 24px 30px;
  scrollbar-width: none;
}

.app::-webkit-scrollbar { display: none; }

.page {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 0 0 16px;
}

.page.active {
  animation: dashboardPageIn .28s cubic-bezier(.2, .8, .2, 1);
}

@keyframes dashboardPageIn {
  from { opacity: .2; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.app-header {
  min-height: 68px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 10px 20px rgba(129, 144, 255, .18));
}

.brand-text b {
  color: var(--text);
  font-size: 17px;
  letter-spacing: -.02em;
}

.brand-text span {
  color: var(--muted);
  font-size: 12px;
}

.sys-ok {
  margin-left: auto;
  margin-right: 10px;
  color: #c8d8d3;
  font-size: 12px;
  letter-spacing: .01em;
}

.sys-ok.is-offline { color: #ff9a9a; }
.sys-ok.is-offline .ok-dot {
  background: #ff7474;
  box-shadow: 0 0 0 5px rgba(255, 116, 116, .1), 0 0 18px rgba(255, 116, 116, .28);
  animation: none;
}

.ok-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(129, 144, 255, .1), 0 0 18px rgba(129, 144, 255, .3);
}

.bell {
  border-color: var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  box-shadow: none;
}

.bell:hover {
  border-color: rgba(129, 144, 255, .32);
  background: rgba(129, 144, 255, .08);
}

.bell svg,
.icon-btn svg {
  stroke: #d5e3df;
}

.card,
.segment,
.hero {
  border-color: var(--line);
  background: linear-gradient(145deg, rgba(25, 28, 39, .98), rgba(19, 22, 31, .98));
  box-shadow: var(--shadow);
}

.card {
  color: var(--text);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

#dl_xs_svg { fill: var(--green) !important; }
[stroke="#16c96f"] { stroke: var(--green) !important; }

.battery-card:hover,
.preview:hover,
.toggle:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 144, 255, .28);
  box-shadow: 0 24px 58px rgba(0, 0, 0, .28);
}

.hero {
  min-height: 224px;
  padding: 23px 18px 16px;
  background:
    radial-gradient(circle at 50% 30%, rgba(129, 144, 255, .16), transparent 27%),
    linear-gradient(150deg, #1a1e2c 0%, #141721 64%, #151924 100%);
}

.hero::after {
  content: "实时能量流";
  position: absolute;
  left: 18px;
  top: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.hero-bg {
  height: 112px;
  opacity: .13;
  filter: saturate(.65) hue-rotate(105deg);
}

.hero-grid {
  grid-template-columns: 1fr 130px 1fr;
  gap: 12px;
  margin-top: 10px;
}

.flow-label,
.flow-num,
.hero-battery {
  color: var(--text);
}

.flow-line { border-top-color: rgba(129, 144, 255, .5); }
.flow-line::after { border-left-color: var(--green); }
.pill { color: var(--green); background: rgba(129, 144, 255, .1); }
.green-num { color: var(--green); }

.flow-label,
.main-ring span {
  color: var(--muted);
}

.flow-num {
  font-size: 23px;
}

.main-ring {
  width: 124px;
  height: 124px;
  background: conic-gradient(var(--green) 0 100%, rgba(129, 144, 255, .1) 100% 100%);
  box-shadow: 0 0 0 8px rgba(129, 144, 255, .05), 0 16px 36px rgba(129, 144, 255, .12);
}

.main-ring::before,
.soc-ring::before,
.donut::before {
  background: #1a1e29;
}

.flow-line.l { left: 16%; width: 24%; }
.flow-line.r { right: 16%; width: 24%; }

.battery-card {
  min-height: 174px;
  padding: 16px;
  cursor: pointer;
}

.battery-card::after,
.battery-card::before {
  opacity: .7;
}

.battery-card::after { border-color: rgba(129, 144, 255, .075); }
.battery-card::before { background: rgba(129, 144, 255, .075); }

.soc {
  color: var(--text);
}

.soc small,
.caption,
.metric label,
.cell label,
.kpi label,
.info,
.more {
  color: var(--muted);
}

.bar {
  background: rgba(156, 196, 183, .12);
}

.section,
.chart,
.site-card,
.preview,
.form {
  margin-top: 0;
}

.section {
  padding: 17px;
}

.section-title {
  color: var(--text);
  margin-bottom: 13px;
}

.metric {
  min-height: 92px;
  padding: 13px;
  border-color: var(--line);
  background: rgba(255, 255, 255, .025);
}

.metric b,
.cell b,
.row,
.site-meta b,
.chart-head,
.kpi b,
.legend,
.titlebar h2 {
  color: var(--text);
}

.titlebar {
  min-height: 68px;
  padding: 15px 0 11px;
  border-bottom: 1px solid var(--line);
}

.titlebar h2,
.analysis h2 {
  font-size: clamp(23px, 1.8vw, 30px);
  font-weight: 800;
  letter-spacing: -.035em;
}

.titlebar .icon-btn:first-child {
  display: none;
}

.segment {
  padding: 7px;
  border-radius: 16px;
}

.seg {
  min-height: 66px;
  color: var(--muted);
}

.seg.active {
  border-color: rgba(129, 144, 255, .4);
  color: var(--text);
  background: rgba(129, 144, 255, .08);
  box-shadow: inset 0 0 24px rgba(129, 144, 255, .04);
}

/* Bootstrap's grid row is available globally; the legacy device row needs compact sizing. */
.mppt-card .row {
  width: auto;
  margin: 0;
}

.mppt-card .row > * {
  width: auto;
  max-width: none;
  padding: 0;
}

.mppt-card {
  margin-top: 9px;
  padding: 14px;
  background: rgba(255, 255, 255, .025);
}

.info {
  background: linear-gradient(145deg, rgba(85, 194, 255, .08), rgba(129, 144, 255, .06));
}

.tabs,
.filters span,
.input,
.site-meta div {
  border-color: var(--line);
  background: rgba(255, 255, 255, .035);
}

.tab {
  color: var(--muted);
}

.tab.active {
  color: var(--green);
  background: rgba(129, 144, 255, .1);
  box-shadow: none;
}

.battery-detail {
  padding: 17px;
}

.grid {
  border-color: var(--line);
  background: rgba(255, 255, 255, .02);
}

.cell {
  border-color: var(--line);
}

.chart {
  padding: 17px;
}

.chart-wrap {
  height: 250px;
}

.chart-wrap.compact {
  height: 185px;
}

.chart-empty {
  color: var(--muted);
  background: rgba(10, 20, 18, .82);
}

.site-photo {
  height: 176px;
  filter: saturate(.82) brightness(.82);
}

.site-overlay {
  color: #12201c;
  background: rgba(237, 248, 244, .85);
}

.site-overlay span {
  color: #51645e;
}

.small-ring {
  background: conic-gradient(var(--green) var(--soc, 0%), rgba(156, 196, 183, .12) 0);
}

.toggle-grid {
  gap: 10px;
}

.toggle {
  min-height: 116px;
  padding: 17px 10px 13px;
  cursor: pointer;
}

.toggle svg {
  width: 31px;
  height: 31px;
  stroke: #9bb0a9;
}

.toggle b {
  color: var(--text);
  font-size: 14px;
}

.switch.off {
  background: #2a3935;
}

.toggle.off b {
  color: #91a49e;
}

.manual-takeover-note {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(129, 144, 255, .18);
  border-radius: 14px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(129, 144, 255, .09), rgba(85, 194, 255, .05));
}

.takeover-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--green);
  background: rgba(129, 144, 255, .1);
}

.takeover-icon svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
}

.manual-takeover-note b,
.manual-takeover-note span {
  display: block;
}

.manual-takeover-note > div:nth-child(2) > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.takeover-badge {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(129, 144, 255, .1);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.frow {
  border-color: var(--line);
}

.input {
  color: var(--text);
}

.save {
  box-shadow: 0 14px 32px rgba(111, 125, 240, .2);
}

.filters {
  justify-content: flex-end;
  margin: 0;
}

.filters span {
  color: var(--muted);
}

.filters .on {
  color: var(--green);
  border-color: rgba(129, 144, 255, .28);
  background: rgba(129, 144, 255, .09);
}

.kpi {
  min-height: 108px;
  padding: 15px;
}

.donut {
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .025);
}

.toast {
  position: fixed;
  left: auto;
  right: 30px;
  bottom: 28px;
  width: min(430px, calc(100vw - 44px));
  padding: 15px 18px;
  border: 1px solid rgba(164, 205, 191, .16);
  border-radius: 16px;
  color: var(--text);
  background: rgba(17, 31, 28, .94);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}

.sheet-mask {
  position: fixed;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(4px);
}

.sheet {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 28px;
  width: min(520px, calc(100vw - 32px));
  border-color: var(--line);
  color: var(--text);
  background: #1b1f2b;
  transform: translate(-50%, 120%);
}

.sheet.show { transform: translate(-50%, 0); }
.sheet-options button,
.sheet-actions .cancel { color: var(--text); border-color: var(--line); background: rgba(255, 255, 255, .04); }
.sheet-options button.active { color: var(--green); background: rgba(129, 144, 255, .1); }

/* Primary quick-control page */
.quick-control {
  min-height: 100%;
}

.quick-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 23px 0 17px;
}

.quick-eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
}

.quick-heading h1 {
  margin: 5px 0 6px;
  color: var(--text);
  font-size: clamp(29px, 3vw, 40px);
  font-weight: 840;
  letter-spacing: -.055em;
}

.quick-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.quick-clock {
  min-width: 154px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: right;
  background: rgba(255, 255, 255, .025);
}

.quick-clock span,
.quick-clock b {
  display: block;
}

.quick-clock span {
  color: var(--muted);
  font-size: 11px;
}

.quick-clock b {
  margin-top: 3px;
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.quick-device-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.quick-device-card {
  padding: 16px;
  overflow: hidden;
}

.quick-device-card.inverter-card {
  grid-column: auto;
  display: flex;
  flex-direction: column;
}

.quick-device-card[data-state="on"] {
  border-color: rgba(129, 144, 255, .26);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .24), inset 0 1px rgba(129, 144, 255, .08);
}

.quick-device-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.device-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--green);
  background: rgba(129, 144, 255, .09);
}

.strip-icon { color: var(--blue); background: rgba(85, 194, 255, .09); }
.inverter-icon { color: var(--orange); background: rgba(255, 181, 71, .09); }

.device-icon svg {
  width: 27px;
  height: 27px;
  stroke: currentColor;
}

.quick-device-head > div > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.quick-device-head h2 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 19px;
  font-weight: 820;
}

.quick-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.quick-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #71827d;
}

.quick-state.on { color: var(--green); background: rgba(129, 144, 255, .09); }
.quick-state.on i { background: var(--green); box-shadow: 0 0 10px rgba(129, 144, 255, .5); }
.quick-state.off { color: #a2b2ad; }

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 12px;
}

.inverter-card .quick-actions {
  margin: 14px 0 12px;
}

.quick-action-btn {
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, .035);
  transition: .18s ease;
}

.quick-action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(129, 144, 255, .32);
  background: rgba(129, 144, 255, .08);
}

.quick-action-btn.off:hover {
  border-color: rgba(255, 112, 112, .32);
  background: rgba(255, 112, 112, .07);
}

.quick-action-btn span {
  font-size: 15px;
  font-weight: 850;
}

.quick-action-btn small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .11em;
}

.quick-action-btn.is-current.on {
  color: #0c0e15;
  border-color: var(--green);
  background: linear-gradient(135deg, #91a0ff, #6f7df0);
}

.quick-action-btn.is-current.on small { color: rgba(12, 14, 21, .62); }
.quick-action-btn.is-current.off { border-color: rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .09); }
.quick-action-btn:disabled { cursor: wait; opacity: .55; transform: none; }

.schedule-panel {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(7, 9, 14, .36);
}

.schedule-head,
.schedule-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.schedule-head span { color: var(--text); font-size: 13px; font-weight: 800; }
.schedule-head small { color: var(--muted); font-size: 10px; }

.schedule-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 8px 0 7px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
}

.schedule-mode-switch button {
  min-height: 29px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.schedule-mode-switch button.active {
  color: var(--text);
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .16);
}

.schedule-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.schedule-entry input {
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: #1a1e29;
}

.duration-editor {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto;
  gap: 6px;
}

.schedule-duration-value {
  width: 100%;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.duration-unit-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .025);
}

.duration-unit-switch button {
  min-width: 41px;
  padding: 0 7px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.duration-unit-switch button.active {
  color: #f5f6ff;
  background: rgba(129, 144, 255, .18);
}

.custom-time-editor {
  display: grid;
  gap: 6px;
}

.time-input-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 5px;
  align-items: center;
}

.time-input-row > b {
  color: var(--muted);
  font-size: 15px;
}

.time-part {
  display: grid;
  grid-template-columns: 24px 35px 24px;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1a1e29;
}

.time-part button {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.time-part button:hover {
  color: var(--text);
  background: rgba(129, 144, 255, .1);
}

.time-part input {
  width: 35px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  background: transparent;
}

.time-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.time-presets button {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.time-presets button:hover,
.time-presets button.active {
  border-color: rgba(129, 144, 255, .28);
  color: var(--green);
  background: rgba(129, 144, 255, .08);
}

.schedule-submit {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 11px;
  color: #0c0e15;
  background: linear-gradient(135deg, #91a0ff, #7381f3);
  font-size: 12px;
  font-weight: 850;
}

.schedule-status {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
}

.schedule-cancel {
  color: #ff9393;
  font-size: 11px;
  font-weight: 800;
}

.inverter-hint {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  margin-top: auto;
}

.inverter-hint i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
}

.inverter-hint b { color: var(--text); margin-right: 5px; }

/* Desktop page composition */
#home.active,
#device.active,
#monitor.active,
#control.active,
#stats.active {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

#home > .app-header { grid-column: 1 / -1; }
#home > .hero { grid-column: 1 / 8; }
#home > .battery-pair { grid-column: 8 / -1; margin-top: 0; }
#home > .section { grid-column: 1 / -1; }

#device > .titlebar,
#device > .segment,
#device > .info { grid-column: 1 / -1; }
#device > .section:nth-of-type(1),
#device > .section:nth-of-type(2) { grid-column: 1 / -1; }

#monitor > .titlebar { grid-column: 1 / -1; }
#monitor > .battery-detail { grid-column: 1 / 8; }
#monitor > .site-card { grid-column: 8 / -1; }
#monitor > .chart { grid-column: 1 / 9; }
#monitor > .preview { grid-column: 9 / -1; align-self: stretch; }

#control > .app-header,
#control > .titlebar { grid-column: 1 / -1; }
#control > .toggle-grid { grid-column: 1 / 8; grid-row: 3; }
#control > .manual-takeover-note { grid-column: 1 / 8; grid-row: 4; }
#control > .form { grid-column: 8 / -1; grid-row: 3 / 5; }

#stats > .app-header,
#stats > .kpis { grid-column: 1 / -1; }
#stats > h2 { grid-column: 1 / 4; margin: 10px 0 0; align-self: center; }
#stats > .filters { grid-column: 4 / -1; align-self: center; }
#stats > .chart { grid-column: 1 / 9; grid-row: 4 / 6; }
#stats > .section:not(.chart) { grid-column: 9 / -1; }

/* Sidebar navigation */
.nav {
  position: relative;
  inset: auto;
  z-index: 45;
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 16px 12px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(23, 26, 36, .97), rgba(15, 18, 26, .98));
  box-shadow: 14px 0 38px rgba(0, 0, 0, .12);
  backdrop-filter: blur(24px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 7px 17px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.nav-brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: var(--green);
  filter: drop-shadow(0 9px 18px rgba(129, 144, 255, .22));
}

.nav-brand-mark svg { width: 100%; height: 100%; }
.nav-brand strong,
.nav-brand small { display: block; }
.nav-brand strong { color: var(--text); font-size: 17px; letter-spacing: -.02em; }
.nav-brand small { margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 700; }

.nav-context {
  padding: 0 13px 8px;
  color: #687c75;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .15em;
}

.nav button {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #8fa19b;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
  transition: .18s ease;
}

.nav button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .035);
}

.nav button.active {
  color: #eafff7;
  border-color: rgba(129, 144, 255, .18);
  background: linear-gradient(135deg, rgba(129, 144, 255, .15), rgba(129, 144, 255, .055));
  box-shadow: inset 3px 0 var(--green), 0 12px 28px rgba(0, 0, 0, .12);
}

.nav svg,
.nav .main svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  box-shadow: none;
}

.nav-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 18px 9px 2px;
  border-top: 1px solid var(--line);
}

.nav-foot span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.nav-foot span i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(129, 144, 255, .58);
}

.nav-foot a {
  display: flex;
  justify-content: space-between;
  color: #b9c9c4;
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}

.nav-foot a:hover { color: var(--green); }

@media (max-width: 1180px) {
  :root { --sidebar-width: 92px; }

  .app { padding-inline: 24px; }
  .nav { padding-inline: 12px; }
  .nav-brand { justify-content: center; padding-inline: 0; }
  .nav-brand > span:last-child,
  .nav-context,
  .nav-foot { display: none; }
  .nav button { justify-content: center; padding: 0; font-size: 0; }
  .nav button svg { width: 23px; height: 23px; }

  #home > .hero { grid-column: 1 / -1; }
  #home > .battery-pair { grid-column: 1 / -1; }
  #device > .section:nth-of-type(1),
  #device > .section:nth-of-type(2) { grid-column: 1 / -1; }
  #monitor > .battery-detail,
  #monitor > .site-card,
  #monitor > .chart,
  #monitor > .preview { grid-column: 1 / -1; }
  #control > .toggle-grid,
  #control > .manual-takeover-note,
  #control > .form { grid-column: 1 / -1; grid-row: auto; }
  #stats > .chart,
  #stats > .section:not(.chart) { grid-column: 1 / -1; grid-row: auto; }
}

@media (min-width: 768px) and (max-width: 920px) {
  .quick-device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-device-card.inverter-card { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  body.dashboard-body { overflow: hidden; }

  .screen { display: block; }
  .app {
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top, 0) max(11px, env(safe-area-inset-right, 0)) calc(91px + env(safe-area-inset-bottom, 0)) max(11px, env(safe-area-inset-left, 0));
  }

  .page { padding-bottom: 9px; }

  #home.active,
  #device.active,
  #monitor.active,
  #control.active,
  #stats.active {
    display: block;
  }

  #home > *,
  #device > *,
  #monitor > *,
  #control > *,
  #stats > * { margin-top: 10px; }

  .app-header { min-height: 61px; padding: 9px 0; }
  .brand-mark { width: 33px; height: 33px; }
  .brand-text b { font-size: 15px; }
  .brand-text span { font-size: 10px; }
  .sys-ok { margin-right: 0; font-size: 10px; }
  .bell { display: none; }

  .nav {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom, 0));
    width: auto;
    height: 70px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    padding: 5px 4px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(22, 25, 35, .95);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, .32);
  }

  .nav-brand,
  .nav-context,
  .nav-foot { display: none; }

  .nav button,
  .nav .main {
    min-height: 56px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    padding: 3px 1px;
    border-radius: 12px;
    font-size: 9px;
    text-align: center;
  }

  .nav button.active { box-shadow: inset 0 -2px var(--green); }
  .nav button svg,
  .nav .main svg { width: 20px; height: 20px; margin: 0 auto 3px; }

  .quick-heading { align-items: flex-start; padding: 18px 0 13px; }
  .quick-heading h1 { font-size: 31px; }
  .quick-heading p { max-width: 270px; line-height: 1.6; }
  .quick-clock { display: none; }
  .quick-device-grid { grid-template-columns: 1fr; gap: 10px; }
  .quick-device-card { padding: 14px; }
  .quick-device-card.inverter-card { grid-column: auto; display: block; }
  .inverter-card .quick-actions { margin: 13px 0 11px; }
  .quick-device-head { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 9px; }
  .device-icon { width: 40px; height: 40px; border-radius: 12px; }
  .quick-device-head h2 { font-size: 18px; }
  .quick-state { padding: 6px 8px; font-size: 9px; }
  .quick-action-btn { min-height: 54px; padding: 9px 11px; }
  .schedule-entry { grid-template-columns: 1fr; }
  .schedule-submit { width: 100%; }

  .hero { min-height: 218px; padding-inline: 11px; }
  .hero-grid { grid-template-columns: 1fr 116px 1fr; gap: 3px; }
  .main-ring { width: 112px; height: 112px; }
  .main-ring b { font-size: 26px; }
  .flow-line.l { left: 22%; width: 16%; }
  .flow-line.r { right: 22%; width: 16%; }

  .battery-pair { grid-template-columns: 1fr 1fr; gap: 10px; }
  .battery-card { min-height: 162px; padding: 14px; }
  .metric-grid { grid-template-columns: 1fr; }
  .titlebar { min-height: 68px; margin-top: 0 !important; }
  .titlebar .icon-btn:first-child { display: grid; }
  .titlebar h2 { font-size: 25px; }
  .toggle-grid { grid-template-columns: repeat(2, 1fr); }
  .toggle { min-height: 108px; }
  .manual-takeover-note { grid-template-columns: 38px 1fr; }
  .takeover-badge { display: none; }
  .frow { grid-template-columns: 1fr; gap: 7px; }
  .input { width: 100%; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .cell:nth-child(3n) { border-right: 1px solid var(--line); }
  .cell:nth-child(2n) { border-right: 0; }
  .cell:nth-last-child(-n+3) { border-bottom: 1px solid var(--line); }
  .cell:nth-last-child(-n+2) { border-bottom: 0; }
  .detail-top { grid-template-columns: 110px 1fr; }
  .soc-ring { width: 105px; height: 105px; }
  .soc-ring div { font-size: 29px; }
  .site-photo { height: 180px; }
  .filters { justify-content: flex-start; }
  #stats > h2 { margin-top: 22px; }
  .kpis { grid-template-columns: 1fr; }
  .chart-wrap { height: 220px; }
  .donut-row { grid-template-columns: 100px 1fr; }
  .donut { width: 96px; height: 96px; }

  .toast { right: 14px; bottom: 96px; width: calc(100vw - 28px); }
  .sheet { bottom: 8px; }
}

@media (max-width: 390px) {
  .app { padding-inline: 10px; }
  .nav { left: 4px; right: 4px; }
  .nav button { font-size: 8px; }
  .quick-heading h1 { font-size: 32px; }
  .quick-device-card { padding: 15px; }
  .battery-pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
