:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --raised: #ffffff; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11,11,11,0.10); --wash: rgba(11,11,11,0.05);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --accent: #2a78d6; --ok: #1baf7a; --warn: #c98500; --err: #d03b3b; --star: #eda100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #222221; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10); --wash: rgba(255,255,255,0.06);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --accent: #3987e5; --ok: #199e70; --warn: #e0a019; --err: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --raised: #222221; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10); --wash: rgba(255,255,255,0.06);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --accent: #3987e5; --ok: #199e70; --warn: #e0a019; --err: #e66767;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 56px; outline: none; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.sub { color: var(--ink-2); margin: 4px 0 0; }
.muted { color: var(--muted); }

/* ---------- górny pasek ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
       background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); box-shadow: 0 1px 0 var(--ring); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.clock { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.date { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
nav a { color: var(--ink-2); text-decoration: none; padding: 8px 14px; border-radius: 999px; white-space: nowrap; }
nav a:hover { background: var(--wash); }
nav a[aria-current="page"] { background: var(--ink); color: var(--page); }
.health { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.health.ok .dot { background: var(--ok); }
.health.warn .dot { background: var(--warn); }
.health.err .dot { background: var(--err); }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 8px 12px; }
  nav { order: 3; width: 100%; margin-left: 0; }
  .health { margin-left: auto; }
  .date { display: none; }
}

/* ---------- karty ---------- */
.card { background: var(--surface); border-radius: 16px; box-shadow: 0 0 0 1px var(--ring); padding: 18px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
@media (max-width: 900px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }
section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

/* pogoda: karta główna */
.hero .place { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hero .city { font-size: 20px; font-weight: 600; }
.hero .street { color: var(--ink-2); font-size: 13px; }
.hero .big { display: flex; align-items: center; gap: 18px; margin: 14px 0 16px; flex-wrap: wrap; }
.hero .temp { font-size: 64px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero .temp small { font-size: 26px; font-weight: 400; color: var(--ink-2); margin-left: 2px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--wash); font-weight: 500; }
.pill i, .dotlv { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero .temp { font-size: 52px; } }
.tile { background: var(--wash); border-radius: 12px; padding: 10px 12px; }
.tile .label { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 12px; font-weight: 400; color: var(--ink-2); margin-left: 3px; }
.note { color: var(--muted); font-size: 12px; margin-top: 12px; }
.warn-line { color: var(--warn); font-size: 13px; margin-top: 10px; }
.chip { font-size: 12px; color: var(--ink-2); background: var(--wash); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }

/* wkrótce */
.soon { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.soon .card { display: flex; flex-direction: column; gap: 6px; min-height: 104px; opacity: .72; }
.soon .ico { font-size: 22px; }
.soon .t { font-weight: 600; }
.soon .s { color: var(--muted); font-size: 12px; margin-top: auto; }

/* ESP32 */
.devices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.device .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; }

/* ---------- przyciski, formularze ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.btn { text-decoration: none; display: inline-block; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--wash); box-shadow: 0 0 0 1px var(--ring); cursor: pointer; white-space: nowrap; }
.btn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--ink); color: var(--page); box-shadow: none; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 5px 9px; }
.btn.danger:hover { color: var(--err); }
.seg { display: inline-flex; background: var(--surface); border-radius: 10px; box-shadow: 0 0 0 1px var(--ring); padding: 2px; }
.seg button { color: var(--ink-2); background: none; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
input[type=text], input[type=number], select { background: var(--raised); border: 0; box-shadow: 0 0 0 1px var(--ring); border-radius: 10px; padding: 9px 11px; min-width: 0; }
input:focus-visible, select:focus-visible, .btn:focus-visible, .seg button:focus-visible, nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.progress { height: 4px; border-radius: 2px; background: var(--wash); overflow: hidden; min-width: 120px; flex: 1; max-width: 260px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- tabele ---------- */
.tablewrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--ink-2); font-weight: 500; }
th:first-child, td:first-child, td.l, th.l { text-align: left; }
td .addr { color: var(--muted); font-size: 12px; display: block; }
td:first-child { white-space: normal; min-width: 170px; }
tr.main td { background: color-mix(in srgb, var(--star) 9%, transparent); }
tr.off td { color: var(--muted); }
tr.off .btn { color: var(--ink-2); }
tr.avgrow td { font-weight: 600; background: var(--wash); }
td.err { color: var(--err); text-align: left; white-space: normal; min-width: 180px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; vertical-align: middle; }
.star { color: var(--star); }
tr.res-dane td { background: color-mix(in srgb, var(--ok) 9%, transparent); }
tr.res-błąd td { color: var(--err); }
tr.res-brak td { color: var(--muted); }

/* ---------- wykresy ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.legend b { color: var(--ink); font-weight: 600; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 14px; }
.chart { position: relative; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart .unit { color: var(--muted); font-size: 12px; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; outline: none; touch-action: pan-y; }
.chart svg:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 4px; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tip { position: absolute; pointer-events: none; background: var(--raised); box-shadow: 0 0 0 1px var(--ring), 0 6px 20px rgba(0,0,0,0.14);
       border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 150px; display: none; z-index: 2; }
.tip .t { color: var(--ink-2); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r strong { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 44px; }
.tip .r span:last-child { color: var(--ink-2); }

.empty { color: var(--muted); padding: 48px 0; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
         background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* energia */
.ecards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
a.ecard { color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 8px; }
a.ecard:hover { box-shadow: 0 0 0 1px var(--axis); }
.ehead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.epower { font-size: 34px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.epower small { font-size: 16px; font-weight: 400; color: var(--ink-2); margin-left: 4px; }
.epower.big { font-size: 56px; margin: 6px 0 14px; letter-spacing: -0.02em; }
.epower.big small { font-size: 22px; }
.epower.stale { color: var(--muted); }
.devices .ecard .tiles { margin-top: 4px; }
.room { display: flex; flex-direction: column; gap: 8px; }
.room .pill { align-self: flex-start; }
[hidden] { display: none !important; }

/* ---------- Start: swobodne okienka (wymiary w em — rosną razem z czcionką okienka) ---------- */
main.wide { max-width: none; }
.dashbar { display: flex; gap: 8px; align-items: center; min-height: 0; margin-bottom: 10px; }
.dashbar:empty { display: none; }
.dash { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.dash.free { display: block; }
.w { position: relative; background: var(--surface); border-radius: 1em; box-shadow: 0 0 0 1px var(--ring); padding: 1.1em 1.15em;
     overflow: hidden; display: flex; flex-direction: column; font-size: 16px; line-height: 1.35; }
.dash.free .w { position: absolute; }
.w .wbody { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.w.link { cursor: pointer; }
.w.link:hover { box-shadow: 0 0 0 1px var(--axis); }
.dash.edit .w { cursor: move; user-select: none; touch-action: none; outline: 2px dashed var(--axis); outline-offset: -2px; }
.dash.edit .w.moving { z-index: 3; box-shadow: 0 0 0 1px var(--accent), 0 12px 30px rgba(0,0,0,.18); }
.w .rz { display: none; position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; cursor: nwse-resize; touch-action: none;
         background: linear-gradient(135deg, transparent 50%, var(--axis) 50%, var(--axis) 58%, transparent 58%, transparent 70%, var(--axis) 70%, var(--axis) 78%, transparent 78%); }
.dash.edit .w .rz { display: block; }
.wh { display: flex; justify-content: space-between; align-items: flex-start; gap: .6em; }
.wt { font-size: 1.25em; font-weight: 600; line-height: 1.2; }
.ws { font-size: .8em; color: var(--ink-2); }
.wchip { font-size: .75em; color: var(--ink-2); background: var(--wash); border-radius: 999px; padding: .3em .75em; white-space: nowrap; }
.wbig { display: flex; align-items: center; gap: 1em; margin: .7em 0 .9em; min-height: 4.4em; }
.wtemp { font-size: 4em; font-weight: 600; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wtemp small { font-size: .4em; font-weight: 400; color: var(--ink-2); margin-left: .1em; }
.wpill { display: inline-flex; align-items: center; gap: .5em; padding: .4em .85em; border-radius: 999px; background: var(--wash); font-weight: 500; white-space: nowrap; }
.wpill i, .wtile i, .wdot { width: .65em; height: .65em; border-radius: 50%; display: inline-block; flex: none; }
.wtiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6em; }
.wtile { background: var(--wash); border-radius: .75em; padding: .6em .75em; min-width: 0; }
.wtile .l { font-size: .75em; color: var(--ink-2); display: flex; align-items: center; gap: .45em; white-space: nowrap; overflow: hidden; }
.wtile .v { font-size: 1.4em; font-weight: 600; margin-top: .1em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wtile .v small { font-size: .55em; font-weight: 400; color: var(--ink-2); margin-left: .25em; }
.wwarn { font-size: .8em; color: var(--warn); margin-top: .6em; }
.wnote { font-size: .75em; color: var(--muted); margin-top: auto; padding-top: .7em; }
.wpower { font-size: 2.6em; font-weight: 600; line-height: 1.1; margin-top: .25em; font-variant-numeric: tabular-nums; }
.wpower small { font-size: .45em; font-weight: 400; color: var(--ink-2); margin-left: .2em; }
.wpower.stale, .wroom.stale { color: var(--muted); }
.wroom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr) minmax(0, 1.25fr); gap: .5em; margin-top: auto; padding-top: .6em; }
.wbigval { font-size: 1.7em; font-weight: 600; line-height: 1.1; white-space: nowrap; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: .25em; }
.wbigval small { font-size: .5em; font-weight: 400; color: var(--ink-2); }
.wbigval .wdot { width: .4em; height: .4em; }
.wplan { display: flex; flex-wrap: wrap; gap: .5em 1.6em; margin-top: .6em; color: var(--muted); }
a.cardlink { color: inherit; text-decoration: none; display: block; }
a.cardlink > .card:hover { box-shadow: 0 0 0 1px var(--axis); }
/* wąskie okienko: zawartość się przestawia (próg w em = szerokość bazowa / 16 minus marginesy 2,3 em) */
.w { container-type: inline-size; }
@container (max-width: 35.1em) {          /* pogoda, średnia: 600 px bazowo, minus marginesy 2,3 em */
  .wtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wbig { flex-wrap: wrap; gap: .5em 1em; }
}
@container (max-width: 21.4em) {          /* energia: 380 px bazowo, minus marginesy */
  .w[data-t="energia"] .wh { flex-wrap: wrap; }
}
@container (max-width: 16.4em) {          /* pokój: 300 px bazowo, minus marginesy */
  .wroom { grid-template-columns: minmax(0, 1fr); gap: .35em; }
  .wroom > div { display: flex; align-items: baseline; justify-content: space-between; gap: .5em; }
}
@container (max-width: 72.6em) {          /* „w przygotowaniu”: 1200 px bazowo, minus marginesy */
  .wplan { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* karty z kafelkami: za wąsko na 4 w rzędzie (np. 3 karty energii obok siebie) → 2×2 */
.card { container-type: inline-size; }
@container (max-width: 470px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.tile .value { white-space: nowrap; }

/* przycisk powrotu */
.back { display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font-weight: 500; color: var(--ink);
        background: var(--surface); box-shadow: 0 0 0 1px var(--ring); border-radius: 999px; padding: 5px 16px 5px 5px; margin-bottom: 4px; }
.back svg { width: 30px; height: 30px; padding: 5px; border-radius: 50%; background: var(--ink); color: var(--page); transition: transform .15s; }
.back:hover { box-shadow: 0 0 0 1px var(--axis); }
.back:hover svg { transform: translateX(-2px); }
.back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- sterowanie: pompka CWU i brama ---------- */
.wseg { display: flex; gap: .45em; margin-top: auto; padding-top: .8em; }
.wseg button { flex: 1; min-width: 0; border: 0; border-radius: .7em; padding: .55em .5em; font-size: .9em; font-weight: 500; cursor: pointer;
               background: var(--wash); box-shadow: 0 0 0 1px var(--ring); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wseg button:hover:not(:disabled) { box-shadow: 0 0 0 1px var(--axis); }
.wseg button[aria-pressed="true"] { background: var(--ink); color: var(--page); box-shadow: none; }
.wseg button:disabled, .btnrow .btn:disabled { opacity: .45; cursor: default; }
.wbtns button { font-weight: 600; }
.wseg button.armed, .btn.armed { background: var(--warn); color: #fff; box-shadow: none; }
.wseg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dash.edit .w button { pointer-events: none; }
.wstate { font-size: 2.6em; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.wbig.stale .wtemp, .wstate.stale { color: var(--muted); }
.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-err { color: var(--err); }
.lamp { display: inline-flex; align-items: center; gap: .35em; }
.lamp i { width: .8em; height: .8em; border-radius: 50%; display: inline-block; flex: none; }
.wtile .v.lamp { height: 1.35em; }
.wtile.txt .v { font-size: 1.12em; line-height: 1.69; overflow: hidden; text-overflow: ellipsis; }   /* godziny okien: ta sama wysokość kafelka */
.kv .lamp i { width: 12px; height: 12px; }
.ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.step { display: inline-flex; align-items: center; gap: 8px; }
.step b { min-width: 72px; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; }
.btnrow .btn { flex: 1; min-width: 92px; padding: 12px 14px; font-weight: 600; }
input[type=time] { background: var(--raised); border: 0; box-shadow: 0 0 0 1px var(--ring); border-radius: 10px; padding: 7px 9px; font-variant-numeric: tabular-nums; }
input[type=time]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* harmonogram tygodniowy pompki */
.sweek { display: grid; gap: 3px; }
.srow { display: grid; grid-template-columns: 34px 1fr 64px; align-items: center; gap: 10px; border: 0; background: none; padding: 5px 6px; border-radius: 8px; cursor: pointer; text-align: left; }
.srow:hover { background: var(--wash); }
.srow.sel { background: var(--wash); box-shadow: 0 0 0 1px var(--axis); }
.srow:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sday { font-weight: 600; font-size: 13px; }
.srow.today .sday { color: var(--accent); }
.ssum { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.sbar { position: relative; height: 14px; border-radius: 4px; background: var(--wash); overflow: hidden;
  background-image: repeating-linear-gradient(to right, transparent 0 calc(25% - 1px), var(--grid) calc(25% - 1px) 25%); }
.sbar i { position: absolute; top: 0; bottom: 0; background: var(--s2); border-radius: 3px; min-width: 2px; }
.sbar .snow { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--ink); }
.saxis { display: grid; grid-template-columns: 34px 1fr 64px; gap: 10px; padding: 0 6px; }
.saxis div { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sched h3 { margin: 0; font-size: 15px; }
.sact { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.smsg { font-size: 12px; color: var(--warn); }
.scopy { margin-top: 6px; border-top: 1px solid var(--grid); padding-top: 4px; }
.sdays { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.sdays button { border: 0; border-radius: 8px; padding: 5px 9px; min-width: 38px; background: var(--wash); box-shadow: 0 0 0 1px var(--ring); cursor: pointer; font-size: 13px; }
.sdays button[aria-pressed="true"] { background: var(--ink); color: var(--page); box-shadow: none; }
.sdays button:disabled { opacity: .35; cursor: default; }

/* sygnalizator bramy: miganie 1 s / 1 s, „na przemian” w przeciwfazie */
.lamp i.blink { animation: lampblink 2s steps(1, end) infinite; }
.lamp i.blink.alt { animation-delay: -1s; }
@keyframes lampblink { 0% { opacity: 1; } 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .lamp i.blink { animation: none; } }
.ctl.active { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.ctl select { padding: 6px 9px; max-width: 100%; }
.ctl small { font-size: 11px; }
.alarm { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }

/* ---------- logowanie i konto ---------- */
input[type=password] { background: var(--raised); border: 0; box-shadow: 0 0 0 1px var(--ring); border-radius: 10px; padding: 9px 11px; min-width: 0; }
input[type=password]:focus-visible, input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.loginpage main { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); display: grid; gap: 12px; }
.login label, .acct label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.login label.check, .acct label.check { display: flex; align-items: center; gap: 8px; }
.login input, .acct input[type=password], .acct input[type=text] { font-size: 16px; }
.login .btn { padding: 12px 14px; font-weight: 600; }
.err { color: var(--err); font-size: 13px; margin: 0; min-height: 1em; }
.acct form { display: grid; gap: 10px; max-width: 360px; }
.acct .secret { font: 600 16px/1.4 ui-monospace, Consolas, monospace; letter-spacing: .5px; word-break: break-all; background: var(--wash); border-radius: 8px; padding: 8px 10px; }
.sess { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.sess:last-child { border-bottom: 0; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--wash); color: var(--ink-2); margin-left: 6px; }
.tag.bad { color: var(--err); }
.logout { margin-left: 4px; }
.pinin { font-size: 28px; letter-spacing: 10px; text-align: center; padding: 8px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad .btn { font-size: 24px; padding: 16px 0; font-weight: 600; touch-action: manipulation; }
.pinpad .btn.primary { font-size: 18px; }
.wall { display: flex; align-items: center; gap: 8px; }
/* wybór okienek na Starcie */
.w .wx { display: none; position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; z-index: 2;
         background: var(--ink); color: var(--page); font-size: 14px; line-height: 28px; padding: 0; cursor: pointer; }
.dash.edit .w .wx { display: block; pointer-events: auto; }
.dash.edit:not(.free) .w { cursor: default; touch-action: auto; }
.picker { margin-bottom: 12px; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; }
.picks label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
/* użytkownicy i uprawnienia */
.perms { display: grid; gap: 2px; }
.perms label.perm { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 14px; color: var(--ink); }
.perms label.perm:last-child { border-bottom: 0; }
.perms label.perm input { margin-top: 3px; }
.perms label.perm span { display: grid; gap: 1px; }
.perms label.perm small { font-size: 12px; }
.perms label.implied { opacity: .55; }
.perms label.admin b { color: var(--accent); }
.useracts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }
.tag.warn { color: var(--warn); }
.newpass { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 10%, transparent); }
.adduser form { max-width: 760px; }
.adduser form > label { max-width: 360px; }
@media (min-width: 800px) { .adduser .perms { grid-template-columns: 1fr 1fr; column-gap: 28px; } .adduser .perms label.perm:nth-last-child(2) { border-bottom: 0; } }

/* System (Raspberry) */
.kv b.bad { color: var(--err); }
.kv b.warn { color: var(--warn); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* dwie kolumny: Konto, Użytkownicy (po lewej menu, po prawej treść; na telefonie po kolei) */
.split { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 16px; align-items: start; }
.split .side { display: flex; flex-direction: column; gap: 2px; padding: 8px; position: sticky; top: 12px; }
.split .side a.item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-size: 14px; }
.split .side a.item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split .side a.item:hover { background: var(--wash); }
.split .side a.item[aria-current="page"] { background: var(--wash); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.split .side a.item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.split .side .foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding: 10px 4px 2px; border-top: 1px solid var(--grid); }
.split .main { display: grid; gap: 16px; min-width: 0; }
.split .mback { display: none; }
.subh { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.btn.danger.solid { background: var(--err); color: #fff; box-shadow: none; }
@media (max-width: 760px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split .side { position: static; }
  .split.sel .side { display: none; }
  .split:not(.sel) .mainwrap { display: none; }
  .split .mback { display: inline-flex; margin: 0 0 10px; color: var(--ink); font-weight: 500; text-decoration: none; }
}
/* okno potwierdzenia (np. usunięcie konta) */
dialog.confirm { border: 0; border-radius: 14px; padding: 20px 22px; max-width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink);
                 box-shadow: 0 0 0 1px var(--ring), 0 20px 50px rgba(0,0,0,.3); }
dialog.confirm h2 { margin: 0 0 8px; font-size: 18px; }
dialog.confirm p { margin: 0 0 16px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
dialog.confirm .btnrow { justify-content: flex-end; }
dialog.confirm::backdrop { background: rgba(0, 0, 0, .45); }

/* Start: widok „Lista” i ⚙ wygląd okienka */
.wlbig { font-size: 3.2em; font-weight: 600; line-height: 1; letter-spacing: -.02em; margin: .4em 0 .3em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wlbig small { font-size: .42em; font-weight: 400; color: var(--ink-2); margin-left: .12em; }
.wlbig.stale { color: var(--muted); }
.wlist { display: grid; font-size: 1.3em; }   /* wiersze listy ok. 3 px większe niż reszta okienka */
.wlist > div { display: flex; justify-content: space-between; align-items: baseline; gap: .8em; padding: .3em 0; border-bottom: 1px solid var(--grid); }
.wlist > div:last-child { border-bottom: 0; }
.wlist span { display: flex; align-items: center; gap: .45em; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wlist b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wlist b small { font-size: .8em; font-weight: 400; color: var(--ink-2); margin-left: .25em; }
.wlist i { width: .6em; height: .6em; border-radius: 50%; display: inline-block; flex: none; }
.wlist .lamp i { width: .75em; height: .75em; }
.w.lst .wseg { padding-top: .6em; }
.w .wg { display: none; position: absolute; top: 6px; right: 40px; width: 28px; height: 28px; border: 0; border-radius: 50%; z-index: 2; padding: 0; cursor: pointer;
         background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--axis); font-size: 16px; line-height: 28px; }
.dash.edit .w .wg { display: block; pointer-events: auto; }
.wmenu { position: fixed; z-index: 50; display: grid; gap: 2px; min-width: 200px; max-height: min(70vh, 460px); overflow: auto; padding: 10px 14px 12px;
         font-size: 14px; line-height: 1.3; background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: 0 0 0 1px var(--ring), 0 12px 32px rgba(0,0,0,.22); }
.wmenu .wmh { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 2px; }
.wmenu .wmh:not(:first-child) { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--grid); }
.wmenu label.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: default; }
.split .main > .card, .split .side { margin: 0; }

/* drobne napisy w okienkach czytelne także po zmniejszeniu okienka */
.wh { flex-wrap: wrap; }
.wchip { font-size: max(.75em, 11px); }
.ws { font-size: max(.8em, 11px); }
.wnote { font-size: max(.75em, 11px); }
.wwarn { font-size: max(.8em, 11px); }
.wtile .l { font-size: max(.75em, 10.5px); }
.w.lst .wt { font-size: calc(1.25em + 2px); }   /* nazwa okienka w liście o 2 px większa */
.wmenu input[type=text] { font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--ring); background: var(--page); color: var(--ink); width: 100%; box-sizing: border-box; }
.wmenu .wmnote { font-size: 12px; color: var(--muted); margin: 2px 0 2px; }
.wtiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: .7em; }   /* energia: napięcie i prąd */

/* prognoza: okienko na Starcie */
.wicon { font-size: 3.2em; line-height: 1; }
.wtemp .wmin { font-size: .55em; font-weight: 500; color: var(--ink-2); }
.wfc { font-size: 1.5em; font-weight: 600; line-height: 1.25; }
/* prognoza: karta w Pogodzie */
.fcwarn { color: var(--warn); font-size: 14px; margin: 8px 0 0; }
.fcdays { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.fcday { padding: 12px; border-radius: 12px; background: var(--wash); display: grid; gap: 2px; align-content: start; }
.fcday.on { box-shadow: inset 0 0 0 2px var(--accent); }
.fcd { font-weight: 600; }
.fcd span { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 13px; }
.fci { font-size: 30px; line-height: 1.25; }
.fct b { font-size: 22px; font-variant-numeric: tabular-nums; }
.fct span { color: var(--ink-2); font-size: 16px; }
.fco { font-size: 13.5px; font-weight: 500; margin-bottom: 2px; }
.fcm { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fcm.rain { color: var(--s1); font-weight: 600; }
.fchours { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.fch { flex: none; width: 64px; text-align: center; padding: 8px 2px; border-radius: 10px; display: grid; gap: 2px; justify-items: center; }
.fch:nth-child(odd) { background: var(--wash); }
.fch.nd { box-shadow: inset 2px 0 0 var(--accent); }
.fch b { font-size: 16px; font-variant-numeric: tabular-nums; }
.fch .fci { font-size: 22px; }

/* Ustawienia: zakładki w zakładce */
.subtabs { display: flex; gap: 2px; margin: 0 0 20px; border-bottom: 1px solid var(--grid); overflow-x: auto; scrollbar-width: none; }
.subtabs a { padding: 10px 16px; color: var(--ink-2); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.subtabs a:hover { background: var(--wash); color: var(--ink); }
.subtabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.subtabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* 2FA: kod QR (białe tło także w ciemnym trybie — inaczej aplikacje go nie odczytają) */
img.qr { display: block; width: 220px; height: 220px; max-width: 100%; background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px var(--ring); margin: 4px 0 12px; image-rendering: pixelated; }
/* Ustawienia → Liczniki */
.meterhow { display: inline-flex; align-items: center; gap: 8px; }
.meterhow.ok .dotlv { background: var(--ok); }
.meterhow.warn .dotlv { background: var(--warn); }
.meterhow.err .dotlv { background: var(--err); }
table.meters td { vertical-align: middle; }
