:root {
  color-scheme: light;
  --ink: #18252b;
  --muted: #637379;
  --line: #dce5e4;
  --canvas: #f4f7f5;
  --paper: #ffffff;
  --green: #167c63;
  --green-dark: #0d5849;
  --mint: #dff3eb;
  --cyan: #3a9eae;
  --amber: #d28a2e;
  --red: #bf5547;
  --radius: 8px;
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.shell { width: 100%; min-height: 100vh; margin: 0; background: var(--canvas); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px; min-height: 70px; padding: 0 28px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--green-dark); border-radius: 8px; }
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { display: block; font-weight: 800; font-size: 17px; line-height: 1.2; }
.brand-caption { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; letter-spacing: .06em; }
.topnav { align-self: stretch; display: flex; align-items: stretch; gap: 8px; overflow-x: auto; }
.topnav a { position: relative; display: flex; align-items: center; padding: 0 15px; color: #57666b; font-weight: 600; white-space: nowrap; }
.topnav a:hover, .topnav a.active { color: var(--green-dark); }
.topnav a.active::after { position: absolute; right: 14px; bottom: 0; left: 14px; height: 3px; content: ''; background: var(--green); border-radius: 3px 3px 0 0; }
.top-status { display: flex; align-items: center; gap: 8px; margin-left: auto; color: #48635b; font-size: 14px; white-space: nowrap; }
.pulse { width: 9px; height: 9px; background: #36a678; border-radius: 50%; box-shadow: 0 0 0 4px #dff3eb; }
.page { padding: 24px 28px 34px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 2px 0 20px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-weight: 700; font-size: 13px; letter-spacing: .04em; }
h1 { margin: 0; font-size: 27px; line-height: 1.25; }
.heading-note { margin: 7px 0 0; color: var(--muted); font-size: 15px; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.time-chip, .outline-button, .primary-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 6px; background: white; font-weight: 600; font-size: 14px; white-space: nowrap; }
.time-chip { color: #52636a; }
.outline-button, .icon-button { cursor: pointer; }
.outline-button:hover, .icon-button:hover { border-color: #93b8ab; background: #f7fbf8; }
.primary-button { color: white; background: var(--green); border-color: var(--green); cursor: pointer; }
.primary-button:hover { background: var(--green-dark); }
.outline-button svg, .primary-button svg, .icon-button svg, .time-chip svg { width: 17px; height: 17px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric { display: flex; align-items: center; gap: 14px; min-height: 91px; padding: 15px 17px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; color: var(--green); background: #e8f5ef; border-radius: 7px; }
.metric-icon svg { width: 21px; height: 21px; }
.metric-label { color: var(--muted); font-size: 14px; }
.metric-value { margin-top: 3px; font-size: 23px; font-weight: 800; line-height: 1.05; }
.metric-unit { margin-left: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.metric-trend { margin-top: 4px; color: var(--green); font-size: 12px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, .9fr); gap: 14px; }
.panel { min-width: 0; padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-title { margin: 0; font-size: 18px; font-weight: 800; }
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.text-link { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-weight: 700; font-size: 14px; white-space: nowrap; }
.text-link svg { width: 16px; height: 16px; }
.schematic { position: relative; min-height: 282px; overflow: hidden; padding: 18px; background: #f2f7f5; border: 1px solid #e0e9e5; border-radius: 6px; }
.schematic-grid { position: absolute; inset: 0; opacity: .4; background-image: linear-gradient(#dbe7e2 1px,transparent 1px),linear-gradient(90deg,#dbe7e2 1px,transparent 1px); background-size: 28px 28px; pointer-events: none; }
.schematic-content { position: relative; z-index: 1; }
.flow-line { position: absolute; z-index: 0; height: 2px; background: #8fb6a9; }
.flow-line::after { position: absolute; top: -4px; right: 0; width: 8px; height: 8px; content: ''; border-top: 2px solid #548b78; border-right: 2px solid #548b78; transform: rotate(45deg); }
.flow-line.flowing { background: linear-gradient(90deg, #83bca7 50%, #d28a2e 50%); background-size: 22px 2px; animation: flow 1s linear infinite; }
@keyframes flow { to { background-position: 22px 0; } }
.node { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 11px 12px; background: white; border: 1px solid #cddcd5; border-radius: 6px; box-shadow: 0 2px 4px rgba(31,68,55,.04); }
.node-icon { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; color: var(--green); background: var(--mint); border-radius: 6px; }
.node-icon svg { width: 19px; height: 19px; }
.node strong { display: block; font-size: 14px; }
.node small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.node-main { border-color: #8cbaaa; }
.flow-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 34px; }
.flow-row .node { flex: 1; }
.flow-arrow { flex: 0 0 33px; height: 2px; position: relative; background: #8fb6a9; }
.flow-arrow::after { position: absolute; top: -4px; right: 0; width: 8px; height: 8px; content: ''; border-top: 2px solid #548b78; border-right: 2px solid #548b78; transform: rotate(45deg); }
.flow-arrow.flowing { background: repeating-linear-gradient(90deg,#65a58c 0 7px,#c7ded5 7px 13px); animation: flow 1s linear infinite; }
.circuit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.circuit { padding: 13px; background: white; border: 1px solid #dce6e1; border-radius: 6px; }
.circuit-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.circuit-name { font-weight: 800; font-size: 15px; }
.circuit-desc { margin-top: 3px; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; color: #176b52; background: #e6f5ed; border-radius: 4px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.badge.warning { color: #986118; background: #fff2d9; }
.badge.offline { color: #8a5149; background: #fbe9e5; }
.badge .pulse { width: 6px; height: 6px; box-shadow: none; }
.readings { display: flex; gap: 18px; margin-top: 13px; }
.reading-label { color: var(--muted); font-size: 12px; }
.reading-value { margin-top: 2px; font-size: 17px; font-weight: 800; }
.reading-value small { color: var(--muted); font-size: 12px; }
.circuit-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #edf1ef; }
.mini-control { display: inline-flex; align-items: center; gap: 7px; color: #53656a; font-size: 13px; }
.toggle { position: relative; display: inline-flex; align-items: center; width: 44px; height: 26px; padding: 3px; border: 0; border-radius: 15px; background: #b8c4c0; cursor: pointer; transition: background .16s ease; }
.toggle::after { width: 20px; height: 20px; content: ''; background: white; border-radius: 50%; box-shadow: 0 1px 3px #0002; transition: transform .16s ease; }
.toggle[aria-checked='true'] { background: var(--green); }
.toggle[aria-checked='true']::after { transform: translateX(18px); }
.control-stack { display: grid; gap: 12px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #edf1ef; }
.control-row:last-child { border-bottom: 0; }
.control-title { font-weight: 700; font-size: 15px; }
.control-help { margin-top: 3px; color: var(--muted); font-size: 13px; }
.segmented { display: inline-flex; padding: 3px; background: #eef3f1; border-radius: 6px; }
.segmented button { min-height: 34px; padding: 0 11px; color: #586a6f; background: transparent; border: 0; border-radius: 4px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.segmented button.selected { color: var(--green-dark); background: white; box-shadow: 0 1px 3px #193c3017; }
.range-wrap { width: 100%; margin-top: 7px; }
input[type='range'] { width: 100%; accent-color: var(--green); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.wide-control { padding: 12px; background: #f5f8f6; border-radius: 6px; }
.wide-control-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 700; }
.wide-control-head output { color: var(--green); }
.trend-panel { margin-top: 14px; }
.trend-wrap { display: grid; grid-template-columns: minmax(0,1fr) 230px; gap: 22px; align-items: center; }
.chart { width: 100%; height: 128px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-gridline { stroke: #e8eeeb; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#chartFill); }
.chart-dot { fill: white; stroke: var(--green); stroke-width: 2; }
.chart-legend { display: grid; gap: 13px; }
.legend-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.legend-name { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.legend-swatch { width: 9px; height: 9px; background: var(--green); border-radius: 2px; }
.legend-swatch.cyan { background: var(--cyan); }
.legend-swatch.amber { background: var(--amber); }
.legend-value { font-weight: 800; font-size: 15px; }
.training-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.training-item { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.training-number { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; color: var(--green-dark); background: var(--mint); border-radius: 50%; font-size: 13px; font-weight: 800; }
.training-item strong { display: block; font-size: 14px; }
.training-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.section-gap { margin-top: 14px; }
.sim-message { min-height: 24px; margin-top: 12px; color: var(--green-dark); font-size: 13px; }
.energy-direction { display: inline-flex; align-items: center; gap: 8px; color: var(--green-dark); font-weight: 700; font-size: 14px; }
.energy-direction svg { width: 17px; height: 17px; }
.battery { position: relative; height: 32px; padding: 4px; border: 2px solid #7ca696; border-radius: 5px; }
.battery::after { position: absolute; top: 8px; right: -6px; width: 4px; height: 12px; content: ''; background: #7ca696; border-radius: 0 2px 2px 0; }
.battery-fill { width: 72%; height: 100%; background: #60ac82; border-radius: 2px; transition: width .2s ease; }
.sun-disc { display: grid; place-items: center; width: 47px; height: 47px; color: #a97618; background: #fff2d3; border-radius: 50%; }
.sun-disc svg { width: 26px; height: 26px; }
.pv-array { display: flex; align-items: center; gap: 5px; transform: skewY(-8deg); }
.pv-cell { width: 39px; height: 27px; background: #236a79; border: 2px solid #69a3a9; border-radius: 2px; box-shadow: inset 0 0 0 1px #ffffff20; }
.pv-cell:nth-child(2n) { background: #1f5d70; }
.charger-port { display: flex; align-items: center; gap: 10px; }
.charger-plug { display: grid; place-items: center; width: 38px; height: 38px; color: #fff; background: var(--green); border-radius: 7px; }
.charger-plug svg { width: 20px; height: 20px; }
.vehicle { width: 68px; height: 31px; border-radius: 17px 19px 8px 8px; background: #d4e1dc; border-bottom: 5px solid #8da39a; position: relative; }
.vehicle::before { position: absolute; top: 4px; left: 18px; width: 31px; height: 10px; content: ''; background: #94b4aa; border-radius: 8px 8px 2px 2px; }
.vehicle::after { position: absolute; right: 10px; bottom: -8px; width: 12px; height: 12px; content: ''; background: #40535a; border: 2px solid white; border-radius: 50%; box-shadow: -38px 0 #40535a,-38px 0 0 2px white; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; color: #748186; font-size: 12px; }

/* Landing page */
.landing { min-height: 100vh; background: #f3f7f5; }
.landing-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 32px 22px 26px; color: white; background: #124d43; }
.landing-hero h1 { max-width: 760px; font-size: 32px; }
.landing-hero p { margin: 9px 0 0; color: #c9e1d9; font-size: 16px; }
.hero-stat { min-width: 175px; padding-left: 24px; border-left: 1px solid #ffffff45; }
.hero-stat strong { display: block; font-size: 30px; }
.hero-stat span { color: #c9e1d9; font-size: 14px; }
.landing-main { padding: 23px 22px 28px; }
.landing-section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.landing-section-head h2 { margin: 0; font-size: 21px; }
.landing-section-head p { margin: 0; color: var(--muted); font-size: 14px; }
.app-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.app-card { display: flex; flex-direction: column; min-height: 180px; padding: 17px; background: white; border: 1px solid var(--line); border-radius: 7px; transition: transform .15s ease,border-color .15s ease; }
.app-card:hover { transform: translateY(-2px); border-color: #8bb7a7; }
.app-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.app-symbol { display: grid; place-items: center; width: 41px; height: 41px; color: white; background: var(--green); border-radius: 7px; }
.app-symbol svg { width: 22px; height: 22px; }
.app-card:nth-child(2) .app-symbol { background: #398fa0; }
.app-card:nth-child(3) .app-symbol { color: #87590d; background: #f4d889; }
.app-card:nth-child(4) .app-symbol { background: #537b6c; }
.app-card:nth-child(5) .app-symbol { background: #ad6844; }
.app-card h3 { margin: 13px 0 5px; font-size: 18px; }
.app-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.app-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 15px; color: var(--green); font-weight: 700; font-size: 14px; }
.app-card-foot svg { width: 17px; height: 17px; }
.landing-strip { display: flex; align-items: center; gap: 15px; margin-top: 16px; padding: 14px 16px; background: #e5f1ec; border-left: 4px solid var(--green); border-radius: 4px; }
.landing-strip svg { flex: 0 0 21px; color: var(--green); }
.landing-strip strong { font-size: 15px; }
.landing-strip span { margin-left: 8px; color: #546860; font-size: 14px; }
.guide-card { background: #e8f1ed; border-color: #cdded5; }
.guide-card .app-symbol { background: #d1e5da; color: var(--green-dark); }
.landing-hero { background-image: radial-gradient(circle at 95% -30%,#428b6c44 0 27%,transparent 27.15%),radial-gradient(circle at 95% -30%,transparent 0 40%,#80bd9a18 40.1% 40.4%,transparent 40.5%); }
.app-card { min-height: 221px; }
.app-card h3 { font-size: 21px; }
.app-card p { font-size: 16px; }
.app-card-foot { font-size: 16px; }
.landing-strip span { font-size: 15px; }
.icon { flex-shrink: 0; vertical-align: middle; }
@media(min-width:1000px) and (min-height:580px) {
  body.landing { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
  .landing > .topbar { flex: 0 0 67px; min-height: 67px; }
  .landing-hero { flex: 0 0 auto; padding: 25px 22px; }
  .landing-main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 18px 22px 12px; }
  .landing-section-head { flex: 0 0 auto; margin-bottom: 12px; }
  .app-grid { flex: 1; min-height: 0; grid-template-rows: repeat(2,minmax(0,1fr)); }
  .app-card { min-height: 0; padding: 20px; }
  .app-card h3 { font-size: 23px; }
  .app-card p { font-size: 17px; line-height: 1.65; }
  .landing-strip { flex: 0 0 auto; margin-top: 14px; }
  .landing .footer { flex: 0 0 auto; margin-top: 12px; }
}
@media(min-width:1000px) and (max-height:820px) {
  .landing > .topbar { flex-basis: 60px; min-height: 60px; }
  .landing-hero { padding: 19px 20px; }
  .landing-hero h1 { font-size: 28px; }
  .landing-hero p { font-size: 15px; }
  .landing-hero .eyebrow { font-size: 12px; }
  .landing-main { padding: 14px 18px 10px; }
  .landing-section-head { margin-bottom: 10px; }
  .landing-section-head h2 { font-size: 20px; }
  .app-grid { gap: 10px; }
  .app-card { padding: 15px 17px; }
  .app-card h3 { font-size: 20px; margin: 10px 0 6px; }
  .app-card p { font-size: 15px; }
  .app-card-foot { padding-top: 10px; font-size: 14px; }
  .app-symbol { width: 35px; height: 35px; }
  .landing-strip { margin-top: 10px; padding: 10px 14px; }
  .landing .footer { margin-top: 9px; }
}

@media (max-width: 1100px) {
  .topbar { gap: 12px; padding: 0 17px; }
  .brand { min-width: 230px; }
  .topnav a { padding: 0 10px; }
  .page { padding: 19px 17px 28px; }
  .content-grid { grid-template-columns: minmax(0,1.2fr) minmax(310px,.9fr); }
  .metric { padding: 12px; }
  .metric-icon { flex-basis: 36px; width: 36px; height: 36px; }
  .metric-value { font-size: 20px; }
  .trend-wrap { grid-template-columns: minmax(0,1fr) 185px; gap: 14px; }
}
@media (max-width: 820px) {
  .topbar { position: relative; flex-wrap: wrap; gap: 0; padding: 10px 14px 0; }
  .brand { min-width: 0; padding-bottom: 10px; }
  .top-status { margin-left: auto; padding-bottom: 10px; }
  .topnav { order: 3; width: calc(100% + 28px); height: 46px; margin: 0 -14px; padding: 0 6px; border-top: 1px solid var(--line); }
  .topnav a { padding: 0 11px; font-size: 14px; }
  .topnav a.active::after { right: 10px; left: 10px; }
  .page { padding: 17px 13px 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 14px; }
  .heading-actions { width: 100%; }
  h1 { font-size: 24px; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .metric { min-height: 80px; gap: 10px; }
  .content-grid { grid-template-columns: 1fr; }
  .schematic { min-height: 270px; }
  .trend-wrap { grid-template-columns: 1fr; }
  .chart-legend { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .legend-item { align-items: flex-start; flex-direction: column; gap: 4px; }
  .training-list { grid-template-columns: 1fr; }
  .landing-hero { align-items: flex-start; flex-direction: column; padding: 28px 18px 21px; }
  .landing-hero h1 { font-size: 27px; }
  .hero-stat { padding-left: 0; border-left: 0; }
  .hero-stat strong { display: inline; margin-right: 8px; font-size: 24px; }
  .landing-main { padding: 20px 14px 25px; }
  .landing-section-head { align-items: flex-start; flex-direction: column; }
  .app-grid { grid-template-columns: 1fr; }
  .app-card { min-height: 158px; }
  .landing-strip { align-items: flex-start; }
  .landing-strip span { display: block; margin: 4px 0 0; }
}
@media (max-width: 470px) {
  .brand-name { font-size: 15px; }
  .brand-caption { font-size: 11px; }
  .brand-mark { width: 34px; height: 34px; }
  .top-status { font-size: 12px; }
  .heading-actions { align-items: stretch; flex-wrap: wrap; }
  .time-chip, .outline-button, .primary-button { min-height: 40px; padding: 0 10px; font-size: 13px; }
  .panel { padding: 14px; }
  .panel-title { font-size: 17px; }
  .schematic { padding: 12px; }
  .flow-row { gap: 6px; }
  .flow-arrow { flex-basis: 18px; }
  .flow-row .node { padding: 8px 7px; }
  .node { gap: 7px; }
  .node-icon { flex-basis: 29px; width: 29px; height: 29px; }
  .node strong { font-size: 12px; }
  .node small { font-size: 10px; }
  .circuit-grid { grid-template-columns: 1fr; }
  .readings { gap: 25px; }
  .segmented button { padding: 0 8px; font-size: 12px; }
  .chart-legend { grid-template-columns: 1fr; }
  .legend-item { align-items: center; flex-direction: row; }
}
