:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --grid: #e8e7e3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --temp: #eb6834;
  --prec: #2a78d6;
  --band: #f6d3c3;
  --weekend: #f7f3ea;
  --warn: #d03b3b;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a;
  --c1-wash: rgb(42 120 214 / .13); --c2-wash: rgb(235 104 52 / .14);
  --c4: #8a63d2; --c5: #c2457a; --c3-wash: rgb(27 175 122 / .16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #2f2f2c;
    --grid: #2b2b29;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8e8d86;
    --accent: #3987e5;
    --temp: #d95926;
    --prec: #3987e5;
    --band: #6e4130;
    --weekend: #22211d;
    --warn: #e66767;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70;
    --c1-wash: rgb(57 135 229 / .2); --c2-wash: rgb(217 89 38 / .2);
    --c4: #9d7fe3; --c5: #e0679a; --c3-wash: rgb(25 158 112 / .22);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #242422;
  --border: #2f2f2c;
  --grid: #2b2b29;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #8e8d86;
  --accent: #3987e5;
  --temp: #d95926;
  --prec: #3987e5;
  --band: #6e4130;
  --weekend: #22211d;
  --warn: #e66767;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70;
    --c1-wash: rgb(57 135 229 / .2); --c2-wash: rgb(217 89 38 / .2);
    --c4: #9d7fe3; --c5: #e0679a; --c3-wash: rgb(25 158 112 / .22);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }

.top { display: grid; gap: 10px; padding: 12px 16px 16px; max-width: 1400px; margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* first navigation level: sections */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.modules { display: flex; gap: 2px 20px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.modules button, .module-name {
  border: 0; background: none; font: inherit; font-size: 21px; font-weight: 650; color: var(--text-3);
  padding: 4px 0; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.module-name { color: var(--text); cursor: default; }
.modules button:hover { color: var(--text-2); }
.modules button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.modules button:focus-visible, .account:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.account {
  flex: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px 5px 30px;
  background-image: radial-gradient(circle at 15px 50%, var(--text-3) 0 3.5px, transparent 4px);
  max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tabs[hidden] { display: none; }
.tabs { display: flex; gap: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tabs button {
  border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 550;
  padding: 6px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

.locations {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 16px; padding: 0 16px 16px; max-width: 1400px; margin: 0 auto;
}
.loc { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-width: 0; }
.loc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.loc-head h2 { margin: 0; font-size: 20px; }
.muted { color: var(--text-3); font-size: 13px; }
.small { font-size: 13px; color: var(--text-2); }
.error { color: var(--warn); font-size: 13px; margin: 6px 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }

/* Now */
.now-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.panel { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.panel h3 { margin: 0 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 650; }
.hero { display: flex; align-items: center; gap: 10px; margin: 8px 0 10px; }
.hero .t { font-size: 40px; font-weight: 600; line-height: 1; }
.hero img, .hero .sym { width: 56px; height: 56px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; white-space: nowrap; }
.kv dd .age { color: var(--text-3); font-size: 12px; margin-left: 4px; white-space: nowrap; }
.wind-arrow { display: inline-block; width: 14px; text-align: center; color: var(--text-2); }

.sym { display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: var(--text-3); text-align: center; word-break: break-word; }
img.sym-img { display: block; }

/* 24h */
.chart-wrap { position: relative; }
.chart-title { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 4px 0 0; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--temp); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--temp); opacity: .1; }
.chart .bar { fill: var(--prec); }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .dot { fill: var(--temp); stroke: var(--surface); stroke-width: 2; }
.chart .line.cold { stroke: var(--c1); }
.chart .area.cold { fill: var(--c1); }
.chart .dot.cold { fill: var(--c1); }
.chart .hit { fill: transparent; }

.strip { display: flex; overflow-x: auto; gap: 2px; margin-top: 12px; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.hour { flex: 0 0 52px; text-align: center; padding: 6px 2px; border-radius: 8px; font-size: 13px; }
.hour > div { height: 20px; line-height: 20px; white-space: nowrap; }
.hour > .ic { height: 40px; }
.hour:nth-child(even) { background: var(--surface-2); }
.hour .h { color: var(--text-2); font-weight: 600; }
.hour img, .hour .sym { width: 36px; height: 36px; margin: 2px auto; }
.hour .tt { font-weight: 650; font-size: 15px; }
.hour.lbls {
  flex-basis: 64px; position: sticky; left: 0; z-index: 1; text-align: left; padding-left: 4px;
  background: var(--surface); color: var(--text-2); font-size: 12px; box-shadow: 4px 0 6px -4px rgb(0 0 0 / .25);
}
.hour.lbls .tt { font-size: 12px; font-weight: 400; }
.hour .p { color: var(--prec); }
.hour .p.zero { color: var(--text-3); }

/* 3 day */
.days3 { display: grid; gap: 12px; }
.day3 { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.day3-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.day3-head img, .day3-head .sym { width: 48px; height: 48px; }
.day3-name { font-weight: 650; font-size: 16px; }
.day3-temp { font-size: 20px; font-weight: 600; margin-left: auto; }
.day3-temp .lo { color: var(--text-2); font-weight: 500; }
.day3-facts > span { white-space: nowrap; }
.day3-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-2); margin: 8px 0; }
.tod { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tod > div { background: var(--surface); border-radius: 8px; padding: 6px 4px; text-align: center; font-size: 12px; }
.tod img, .tod .sym { width: 32px; height: 32px; margin: 2px auto; }
.tod .lbl { color: var(--text-2); font-weight: 600; }
.tod .tt { font-size: 14px; font-weight: 600; }
.tod .tt .lo { color: var(--text-2); font-weight: 400; }
.tod .line { white-space: nowrap; }

.g { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.g-drop { stroke: var(--prec); }
/* risk labels sit next to the day name, so they never change the box height */
.day3-title { min-width: 0; }
.day3-name { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.risks { display: inline-flex; gap: 4px; }
.risk {
  display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px 0 3px;
  font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap;
  background: var(--c1-wash); border: 1px solid var(--c1); border-radius: 11px; cursor: help;
}
.risk img, .risk .sym { width: 18px; height: 18px; }

/* 14 day */
.trend { width: 100%; border-collapse: collapse; font-size: 13px; }
.trend th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 0 4px 6px; vertical-align: bottom; white-space: nowrap; }
.trend th.num { text-align: right; }
.trend th small { display: block; font-weight: 400; color: var(--text-3); }
.trend td { padding: 4px 4px; border-top: 1px solid var(--grid); vertical-align: middle; white-space: nowrap; }
.trend tr.we td { background: var(--weekend); }
.trend .d { font-weight: 600; }
.trend .d span { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; }
.trend img, .trend .sym { width: 32px; height: 32px; }
.trend .range { width: 45%; min-width: 120px; }
.trend .num { text-align: right; }
.rb { position: relative; height: 22px; }
.rb .band { position: absolute; top: 8px; height: 6px; background: var(--band); border-radius: 3px; }
.rb .core { position: absolute; top: 6px; height: 10px; background: var(--temp); border-radius: 5px; }
.trend .tlo { text-align: right; color: var(--text-2); width: 1%; }
.trend .thi { font-weight: 600; width: 1%; }
.trend th.tcol { text-align: center; }
.rb.uncertain .core { display: none; }
.trend-legend { font-size: 12px; color: var(--text-3); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.trend-legend i { display: inline-block; width: 18px; height: 8px; border-radius: 4px; margin-right: 4px; vertical-align: middle; }

.foot {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  max-width: 1400px; margin: 0 auto; padding: 8px 16px 24px; font-size: 13px; color: var(--text-2);
}
.foot .credit { margin-left: auto; }
.foot .credit[hidden] { display: none; }
.foot button {
  font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 4px 12px; cursor: pointer;
}

/* login page and account dialog */
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login { width: min(100% - 32px, 360px); }
.login form, .acc { display: grid; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login label, .acc label, .adm-new label, .adm-pw { display: grid; gap: 4px; font-size: 14px; color: var(--text-2); }
.login input, .acc input, .adm-form input[type="text"], .adm-form input[type="password"], .adm-form input:not([type]) {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
.login .error, .login .small { margin: 0; }
.login button { height: 36px; font-size: 15px; }
.acc-dlg { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 16px; width: min(100% - 32px, 400px); }
.acc-dlg::backdrop { background: rgb(0 0 0 / .35); }
.acc h2 { margin: 0; font-size: 18px; }
.acc h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.acc p { margin: 0; }
.acc-head { display: flex; justify-content: space-between; align-items: center; }
.acc-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-msg:empty { display: none; }
.acc-msg.ok, .adm-ok { color: var(--c3); font-weight: 600; }

/* Admin > Users */
.users h2 { margin: 0 0 4px; font-size: 18px; }
.users p { margin: 0; }
.adm-form { display: grid; gap: 12px; margin-top: 10px; }
.adm-new { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.adm-roles { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.adm-roles legend { font-size: 13px; color: var(--text-2); padding: 0; margin-bottom: 6px; }
.adm-role { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.adm-role input { margin: 0; transform: translateY(2px); }
.adm-pw { max-width: 340px; }
.adm-user .adm-roles { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.adm-user .adm-roles legend { width: 100%; }
.adm-user .adm-role .muted { display: none; }  /* descriptions: in the add form and as tooltips */
.adm-you { font-size: 14px; font-weight: 400; }
.adm-user .rl-foot { margin-top: 0; }
.rl-mode-ro { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.rl-mode-ro.on { background: var(--c3-wash); color: var(--c3); }

.tooltip {
  position: fixed; pointer-events: none; z-index: 10;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 4px 12px rgb(0 0 0 / .15);
}
.tooltip b { display: block; margin-bottom: 2px; }

@media (max-width: 560px) {
  .modules { gap: 2px 14px; }
  .modules button, .module-name { font-size: 18px; }
  .account { padding-left: 26px; background-position: -2px 0; max-width: 30vw; }
  .risk { padding: 0 3px; }
  .risk .rl { display: none; }
  .tabs { gap: 0; padding: 3px; }
  .tabs button { padding: 6px 6px; font-size: 14px; }
  .loc { padding: 12px; }
  .tod { grid-template-columns: repeat(2, 1fr); }
  .trend .hide-sm { display: none; }
  .trend th { white-space: normal; }
  .trend td { padding: 4px 2px; }
  .trend .range { min-width: 64px; width: 30%; }
  .trend td.num { padding-left: 8px; }
  .trend .tlo, .trend .thi { font-size: 13px; }
  .trend img, .trend .sym { width: 26px; height: 26px; }
}

/* History */
.history { display: grid; gap: 16px; padding: 0 16px 16px; max-width: 1100px; margin: 0 auto; }
.history[hidden], .locations[hidden] { display: none; }
.history h2 { margin: 0 0 10px; font-size: 18px; }
.hloc { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; justify-self: start; flex-wrap: wrap; }
.hloc button { border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 550; padding: 6px 14px; border-radius: 7px; cursor: pointer; }
.hloc button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.hnav { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.hnav button, .hnav select {
  font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 4px 10px; cursor: pointer;
}
.hnav button:disabled { opacity: .4; cursor: default; }
.hlegend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--text-2); margin: 6px 0 4px; }
.hlegend i { display: inline-block; vertical-align: middle; margin-right: 5px; }
.hlegend .k-line { width: 16px; height: 2px; background: var(--c); }
.hlegend .k-ref { width: 16px; height: 0; border-top: 1.5px dashed var(--c); }
.hlegend .k-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.hlegend .k-band { width: 16px; height: 9px; border-radius: 3px; background: var(--c); opacity: .25; }
.hlegend .k-bar { width: 9px; height: 11px; border-radius: 2px 2px 0 0; background: var(--c); }
.chart .sline { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .sdot { stroke: var(--surface); stroke-width: 2; }
.chart .hband { stroke: none; }
.chart .ref { stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .reflabel { fill: var(--text); font-weight: 600; }
.chart .vline { stroke: var(--border); stroke-width: 1; }
.chart .vlabel { fill: var(--text-3); }
.hscroll { overflow-x: auto; margin-top: 10px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.htable { width: 100%; border-collapse: collapse; font-size: 13px; }
.htable th { text-align: left; font-weight: 600; color: var(--text-2); padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.htable td { padding: 4px 6px; border-top: 1px solid var(--grid); white-space: nowrap; }
.htable .num { text-align: right; }
.htable .few { color: var(--text-3); }
.err { color: var(--text-3); font-size: 11px; margin-left: 5px; }
.hdetails { margin-top: 10px; }
.hdetails summary { cursor: pointer; color: var(--text-2); font-size: 13px; }

/* Sun & moon */
:root {
  --sky-night: #27304a; --sky-astro: #3d4a72; --sky-naut: #5f74a8; --sky-civil: #a3b6dd; --sky-day: #f4d77e;
  --moon-dark: #4a4b52; --moon-lit: #f1e6b8;
}
.astro-wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px 16px; }
.astro-wrap[hidden] { display: none; }
.astro-wrap .panel.astro { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.astro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 4px 24px; }
.astro-hero { min-height: 56px; }
.astro-hero .g { width: 34px; height: 34px; stroke: #e0a400; stroke-width: 1.3; margin: 0 4px 0 2px; }
.astro-times { font-size: 26px; font-weight: 600; }
.moon-name { font-size: 18px; font-weight: 600; }
.moon .moon-dark { fill: var(--moon-dark); }
.moon .moon-lit { fill: var(--moon-lit); }
.daybar { position: relative; height: 14px; margin-top: 14px; border-radius: 7px; overflow: hidden; background: var(--sky-night); }
.daybar .seg { position: absolute; top: 0; bottom: 0; }
.seg-night { background: var(--sky-night); }
.seg-astro { background: var(--sky-astro); }
.seg-naut { background: var(--sky-naut); }
.seg-civil { background: var(--sky-civil); }
.seg-day { background: var(--sky-day); }
.daybar-now { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--warn); box-shadow: 0 0 0 1px var(--surface-2); }
.daybar-axis { position: relative; height: 16px; font-size: 11px; color: var(--text-3); }
.daybar-axis span { position: absolute; transform: translateX(-50%); }
.daybar-axis span:first-child { transform: none; }
.daybar-axis span:last-child { transform: translateX(-100%); }
.daybar-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.daybar-legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* Ecoflow */
.ecoflow { display: grid; gap: 16px; padding: 0 16px 16px; max-width: 1100px; margin: 0 auto; }
.ecoflow[hidden] { display: none; }
.ef-plugs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.ef-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; position: relative; top: -2px; }
.ef-dot.on { background: var(--c3); }
.ef-dot.off { background: var(--text-3); }
.ef-pill { font-size: 13px; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.ef-pill.charging { background: var(--c2-wash); color: var(--c2); }
.ef-pill.discharging { background: var(--c1-wash); color: var(--c1); }
.ef-pill.plug-on { background: rgb(27 175 122 / .18); color: var(--text); box-shadow: inset 0 0 0 1px var(--c3); }

.ef-battery { display: flex; align-items: center; gap: 16px; margin: 4px 0 16px; }
.ef-soc { line-height: 1; white-space: nowrap; }
.ef-soc-v { font-size: 48px; font-weight: 650; }
.ef-soc-u { font-size: 20px; font-weight: 600; color: var(--text-2); margin-left: 2px; }
.ef-soc-main { flex: 1; min-width: 0; }
.ef-bar { position: relative; height: 22px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.ef-bar.thin { height: 8px; border-radius: 4px; margin: 2px 0 12px; }
.ef-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c3); border-radius: 5px 0 0 5px; }
.ef-bar.low .ef-fill { background: var(--warn); }
.ef-fill.out { background: var(--c1); }
.ef-mark { position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--text-2); }
.ef-soc-sub { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 14px; color: var(--text-2); margin-top: 6px; }

.ef-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 8px; align-items: start; }
.ef-col h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 650; }
.ef-col h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 4px; }
.ef-arrow { align-self: center; color: var(--text-3); font-size: 22px; padding-top: 18px; }
.ef-port { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 8px; padding: 8px 10px; margin-bottom: 6px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid transparent; }
.ef-port-label { color: var(--text-2); font-size: 14px; }
.ef-port-w { font-weight: 650; font-size: 17px; text-align: right; }
.ef-port-sub { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); }
.ef-port:not(.active) .ef-port-w { color: var(--text-3); font-weight: 500; }
.ef-port.in.active { border-left-color: var(--c2); background: var(--c2-wash); }
.ef-port.out.active { border-left-color: var(--c1); background: var(--c1-wash); }
.ef-port.batt .ef-port-w { font-size: 22px; }
.ef-port.batt.active { border-left-color: var(--c3); }
.ef-note { font-size: 12px; color: var(--text-3); margin: 2px 2px 0; }

.ef-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 12px; margin-top: 14px; }
.ef-stack { display: grid; gap: 12px; align-content: start; }
.ef-stack > .panel:only-child { height: 100%; }
.ef-ctl-list { display: grid; gap: 2px; }
.ef-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 5px 0; min-height: 36px; }
.ef-ctl + .ef-ctl, .ef-msg + .ef-ctl { border-top: 1px solid var(--border); }
.ef-ctl-label { font-size: 14px; color: var(--text); min-width: 0; }
.ef-hint { display: block; font-size: 12px; color: var(--text-3); }
.ef-ro { font-size: 13px; color: var(--text-2); padding-right: 4px; }
.ef-msg { font-size: 12px; margin: -2px 0 4px; }
.ef-field { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.ef-field input, .ef-field select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 6px; height: 30px;
}
.ef-field input { width: 76px; text-align: right; }
.ef-unit { font-size: 13px; color: var(--text-2); min-width: 14px; }
.ef-set {
  font: inherit; font-size: 13px; font-weight: 600; height: 30px; padding: 0 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--c1); background: var(--c1); color: #fff;
}
.ef-set:disabled { background: none; border-color: var(--border); color: var(--text-3); cursor: default; }
.ef-switch {
  flex: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-2); background: none; border: 0; padding: 2px 0;
}
.ef-switch .ef-knob { position: relative; width: 40px; height: 22px; border-radius: 11px; background: var(--border); transition: background .15s; }
.ef-switch .ef-knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: left .15s;
}
.ef-switch.on .ef-knob { background: var(--c3); }
.ef-switch.on .ef-knob::after { left: 21px; }
.ef-switch.on { color: var(--text); }
.ef-switch:disabled { cursor: progress; opacity: .6; }
.ef-switch:focus-visible, .ef-set:focus-visible { outline: 2px solid var(--c1); outline-offset: 2px; border-radius: 11px; }
.ef-switch-t { min-width: 22px; text-align: left; }
.ef-plug .ef-ctl-list { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 4px; }

.ef-plug-hero { display: flex; align-items: baseline; gap: 10px; margin: 0 0 6px; }
.ef-plug-w { font-size: 36px; font-weight: 650; line-height: 1.1; }
.ef-sn { margin-top: 8px; }

@media (max-width: 640px) {
  .ef-flow { grid-template-columns: 1fr; gap: 4px; }
  .ef-arrow { transform: rotate(90deg); justify-self: center; padding: 0; font-size: 18px; }
  .ef-soc-v { font-size: 40px; }
}

/* Ecoflow history */
.efh-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.efh-bar .hnav { margin: 0; }
.efh-when { font-size: 14px; color: var(--text-2); min-width: 0; }
.efh-chart + .efh-chart { margin-top: 18px; }
.efh-chart h3 { margin: 0 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 650; }
.efh-chart h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.efh-loading { opacity: .5; transition: opacity .2s; }

/* Rules */
.rl-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; }
.rl-top h2 { margin: 0 0 4px; font-size: 20px; }
.rl-top p { margin: 0; max-width: 62ch; }
.rl-top-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rl-auto { font-size: 13px; font-weight: 600; color: var(--text-2); margin-right: 4px; }
.rl-auto.paused { color: var(--warn); }
.rl-btn {
  font: inherit; font-size: 13px; font-weight: 600; height: 30px; padding: 0 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.rl-btn.danger { color: var(--warn); }
.rl-btn:disabled { opacity: .5; cursor: default; }
.rl-btn:focus-visible, .rl-x:focus-visible, .rl-add:focus-visible, .rl-days button:focus-visible { outline: 2px solid var(--c1); outline-offset: 2px; }
.rl-btns { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.rl-btns.end { display: flex; justify-content: flex-end; margin-top: 12px; }
.rl-list { display: grid; gap: 16px; }
.rl-list:empty, #rl-editor:empty, #rl-top:empty { display: none; }
#rules > div { display: grid; gap: 16px; }

.rl-card { border-left: 4px solid var(--border); }
.rl-card.on { border-left-color: var(--c3); }
.rl-card.simulate { border-left-color: var(--c4); }
.rl-card.off .rl-sum { opacity: .7; }
.rl-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.rl-head h2 { margin: 0; font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
.rl-modes button { padding: 4px 12px; font-size: 13px; }
.rl-modes button:disabled { opacity: .5; cursor: progress; }
.rl-state { margin: 6px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.rl-state::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--text-3); vertical-align: 1px; }
.rl-state.met::before { background: var(--c3); }
.rl-state.due::before { background: var(--c2); }
.rl-state.unknown::before { background: none; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.rl-sum { display: grid; gap: 6px; font-size: 14px; }
.rl-sum ul { margin: 2px 0 0; padding-left: 20px; }
.rl-sum li { margin: 2px 0; }
.rl-kw { font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: .05em; color: var(--text-2); margin-right: 4px; }
.rl-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.rl-now { font-size: 12px; white-space: nowrap; color: var(--text-3); margin-left: 4px; }
.rl-now b { font-weight: 700; }
.rl-now.ok b { color: var(--c3); }
.rl-now.no b { color: var(--warn); }
.rl-now.bad { color: var(--warn); white-space: normal; }

.rl-editor { border: 2px solid var(--c1); }
.rl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.rl-name { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); flex: 1 1 280px; }
.rl-name input { flex: 1; min-width: 0; }
.rl-editor input, .rl-editor select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 6px; height: 30px; max-width: 100%;
}
.rl-editor input[type="number"] { width: 76px; text-align: right; }
.rl-editor h3 select { font-size: 13px; height: 26px; text-transform: none; }
.rl-editor > .ef-hint { margin: 6px 0 12px; }
.rl-block { margin-top: 12px; }
.rl-block h3 { display: flex; align-items: center; gap: 6px; }
.rl-block > .ef-hint { margin: 0 0 6px; }
.rl-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.rl-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.rl-grp { display: inline-flex; align-items: center; gap: 6px; }
.rl-row-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; min-height: 30px; }
.rl-txt { font-size: 13px; color: var(--text-2); }
.rl-x { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 18px; line-height: 1; cursor: pointer; }
.rl-add { font: inherit; font-size: 13px; font-weight: 600; color: var(--c1); background: none; border: 1px dashed var(--border); border-radius: 7px; padding: 5px 12px; cursor: pointer; margin-top: 4px; }
.rl-days { display: inline-flex; gap: 2px; }
.rl-days button { font: inherit; font-size: 12px; font-weight: 600; width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); cursor: pointer; }
.rl-days button[aria-pressed="true"] { background: var(--c1); border-color: var(--c1); color: #fff; }
.rl-timing label { display: block; font-size: 14px; margin: 6px 0; }
/* condition groups: "and"/"or" between rows and between groups */
.rl-conn { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c1); }
.rl-row[data-conn] { position: relative; padding-top: 12px; }
.rl-row[data-conn]::before {
  content: attr(data-conn); position: absolute; top: -8px; left: 8px; padding: 0 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--c1); background: var(--surface-2); line-height: 16px;
}
.rl-group { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px 10px; }
.rl-group .rl-row[data-conn]::before { background: var(--surface); }
.rl-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rl-group-head h4 { margin: 0; font-size: 13px; font-weight: 650; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.rl-group-head select { font-size: 13px; height: 26px; }
.rl-gconn { text-align: center; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--c1); margin: 6px 0; }
.rl-adds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rl-adds .rl-add { margin-top: 0; }
.rl-sgroups { margin-top: 4px; }
.rl-sgroup { border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; }
.rl-sgroup ul { padding-left: 18px; }
.rl-sgroups .rl-gconn { margin: 2px 0; text-align: left; padding-left: 12px; }
.rl-gh { font-size: 12px; font-weight: 650; color: var(--text-2); }

.rl-log { max-height: 380px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.rl-log td { padding: 5px 8px 5px 0; border-top: 1px solid var(--border); vertical-align: top; }
.rl-log tr:first-child td { border-top: 0; }
.rl-log-t { white-space: nowrap; color: var(--text-3); }
.rl-log td:last-child { width: 100%; white-space: normal; overflow-wrap: anywhere; }
.rl-log-n { font-weight: 600; white-space: nowrap; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }
.rl-lv { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.lv-action .rl-lv { background: var(--c3-wash); color: var(--c3); }
.lv-simulate .rl-lv { background: rgb(138 99 210 / .16); color: var(--c4); }
.lv-error .rl-lv { background: rgb(208 59 59 / .14); color: var(--warn); }
.lv-skip td:last-child, .lv-info td:last-child { color: var(--text-2); }

@media (max-width: 640px) {
  .rl-log-n { max-width: 28vw; }
  .rl-row { flex-wrap: wrap; }
  .rl-row-end { width: 100%; justify-content: space-between; }
}

/* Cameras */
.cam-station .cam-modes { margin-top: 10px; }
.cam-modes button:disabled { opacity: .5; cursor: progress; }
.cam-grid { align-items: start; }
.cam-card { display: grid; gap: 10px; }
.cam-card .loc-head { margin-bottom: 0; }
.cam-media {
  position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #111;
  display: grid; place-items: center;
}
.cam-media img, .cam-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-empty { color: #bbb; font-size: 14px; padding: 0 16px; text-align: center; }
.cam-live-t {
  position: absolute; z-index: 1; left: 8px; top: 8px; font-size: 12px; font-weight: 650; color: #fff;
  background: rgb(208 59 59 / .85); padding: 2px 8px; border-radius: 6px;
}
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cam-card .ef-pill.cam-low { background: rgb(208 59 59 / .15); color: var(--warn); }
.cam-ctls { border-top: 1px solid var(--border); padding-top: 4px; }
.cam-multi { flex-wrap: wrap; }
.cam-checks { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; }
.cam-checks label { display: inline-flex; align-items: center; gap: 5px; }
.cam-checks input { margin: 0; width: auto; height: auto; }
.cam-card .rl-btns { flex-wrap: nowrap; flex: none; }
.cam-more { margin-top: 0; }
.cam-more .ef-ctl-list { margin-top: 6px; }
.cam-more .ef-sn { margin-top: 8px; }
@media (max-width: 420px) {
  .cam-modes button { padding: 6px 10px; }
}
