/* ESPNet — „kotłownia nocą” / „porcelana” */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,700&family=Instrument+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #121a22;
  --wall: #16202a;
  --surface: #1a2530;
  --raised: #223040;
  --line: #2a3846;
  --line-soft: #223040;
  --text: #e6edf2;
  --muted: #8a9baa;
  --faint: #5d6e7d;
  --ember: #ff8a3d;
  --ember-hot: #ffc15e;
  --water: #5bb8e8;
  --ok: #5fd39a;
  --warn: #f2b544;
  --alarm: #ff5a5f;
  --steel-1: #2d3c4a;
  --steel-2: #3a4b5b;
  --pellet: #c58a4e;
  --ash: #8f969c;
  --focus: #9fd3ff;
  --shadow: 0 18px 50px rgba(3, 8, 14, .45);
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 9px;
  --display: 'Bricolage Grotesque', 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --body: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #eef2f5;
  --wall: #e4eaef;
  --surface: #ffffff;
  --raised: #f4f7f9;
  --line: #d4dde4;
  --line-soft: #e6ecf0;
  --text: #14202a;
  --muted: #566776;
  --faint: #8695a2;
  --ember: #e4661a;
  --ember-hot: #f29a1c;
  --water: #1d86c0;
  --ok: #1f9d63;
  --warn: #b7791f;
  --alarm: #d64045;
  --steel-1: #c9d3db;
  --steel-2: #dbe3e9;
  --pellet: #b07434;
  --ash: #9aa2a8;
  --focus: #1d6fd1;
  --shadow: 0 18px 40px rgba(20, 32, 42, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1;
  min-height: 100vh;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- układ ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  padding: calc(26px + env(safe-area-inset-top)) 16px 26px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--line-soft);
  background: var(--bg);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 10px 22px; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font: 600 15px/1.2 var(--display); display: block; }
.brand small { color: var(--muted); font-size: 12px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current='page'] { color: var(--text); background: var(--surface); }
.nav a[aria-current='page'] svg { color: var(--ember); }
.rail .spacer { flex: 1; }
.rail .who { padding: 10px 12px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rail .who a { color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.rail .who a:hover { color: var(--text); }

main { padding: calc(28px + env(safe-area-inset-top)) clamp(16px, 3.4vw, 44px) 120px; max-width: 1360px; width: 100%; min-width: 0; }
main:focus { outline: none; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font: 650 clamp(24px, 3vw, 32px)/1.1 var(--display); margin: 0; letter-spacing: -.02em; }
.page-head .grow { flex: 1; }
.lead { color: var(--muted); max-width: 66ch; margin: -8px 0 22px; }

.tabbar { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  main { padding: calc(18px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 110px calc(16px + env(safe-area-inset-left)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--line-soft);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 7px 0 5px; text-decoration: none; color: var(--muted);
    font-size: 11px; font-weight: 500; border-radius: 12px;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current='page'] { color: var(--text); }
  .tabbar a[aria-current='page'] svg { color: var(--ember); }
}

/* ---------- elementy ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--ember); border-color: var(--ember); color: #1b0d03; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--alarm); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface); }
.btn.sm { min-height: 32px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.status {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 13px 6px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-soft);
  font-weight: 600; font-size: 14px;
}
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.status[data-kind='work'] i, .status[data-kind='kindle'] i { background: var(--ember); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ember) 22%, transparent); }
.status[data-kind='idle'] i { background: var(--water); }
.status[data-kind='alarm'] i { background: var(--alarm); box-shadow: 0 0 0 4px color-mix(in srgb, var(--alarm) 25%, transparent); }
.status[data-kind='offline'] i { background: var(--faint); }
.status small { color: var(--muted); font-weight: 500; }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-soft); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--raised); color: var(--text); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip[aria-pressed='true'] { color: var(--text); background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.panel { background: var(--surface); border-radius: var(--r-lg); padding: 20px; border: 1px solid var(--line-soft); }
.panel h2, .section-title { font: 600 17px/1.25 var(--display); margin: 0 0 14px; letter-spacing: -.01em; }
.section-title { margin-top: 34px; }

input[type='text'], input[type='number'], input[type='password'], input[type='date'], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; align-content: start; }
label.field small { color: var(--muted); font-weight: 400; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--ember); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.bar { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar > b { display: block; height: 100%; border-radius: inherit; background: var(--ember); transition: width .6s ease; }
.bar.water > b { background: var(--water); }
.bar.ash > b { background: var(--ash); }
.bar.warn > b { background: var(--warn); }
.bar.alarm > b { background: var(--alarm); }

.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font: 600 17px/1.3 var(--display); margin-bottom: 6px; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  margin-bottom: 18px; font-size: 14px;
}
.banner.info { background: color-mix(in srgb, var(--water) 10%, var(--surface)); border-color: color-mix(in srgb, var(--water) 30%, transparent); }
.banner.alarm { background: color-mix(in srgb, var(--alarm) 13%, var(--surface)); border-color: color-mix(in srgb, var(--alarm) 40%, transparent); }
.banner b { display: block; }
.banner { flex-wrap: wrap; }
.banner > div:first-child { flex: 1 1 260px !important; }

/* ---------- przegląd ---------- */
.stage {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  gap: 0; border-radius: 28px; overflow: hidden;
  background: var(--wall); border: 1px solid var(--line-soft);
}
.stage .scene { position: relative; padding: 14px 10px 6px; min-height: 340px; }
.stage .scene svg { width: 100%; height: auto; display: block; }
.readouts { padding: 22px 24px; border-left: 1px solid var(--line-soft); display: flex; flex-direction: column; }
.ro {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); gap: 2px 12px;
}
.ro:last-child { border-bottom: 0; }
.ro .lbl { font-size: 14px; color: var(--muted); }
.ro .val { font: 600 26px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-align: right; }
.ro .val small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 1px; }
.ro .sub { grid-column: 1 / -1; font-size: 13px; color: var(--faint); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; }
.ro .sub > :last-child { margin-left: auto; text-align: right; }
.ro.hero .val { font-size: 46px; }
.ro.hero .lbl { color: var(--text); font-weight: 600; }
.ro button.target {
  border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; font-size: 13px; white-space: nowrap; text-align: left;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.ro button.target:hover { color: var(--text); }

.resources { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.ro .sub a { color: var(--muted); }
.res { padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-soft); }
.res .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.res h3 { margin: 0; font: 600 15px/1.3 var(--body); color: var(--muted); }
.res .big { font: 650 34px/1.05 var(--display); letter-spacing: -.03em; margin: 10px 0 12px; font-variant-numeric: tabular-nums; }
.res .big small { font-size: 17px; color: var(--muted); font-weight: 500; }
.res .meta { display: flex; flex-wrap: wrap; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 9px; gap: 10px; }
.res .act { margin-top: 12px; }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 14px; margin-top: 14px; }
.today { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 14px; }
.today div { padding: 2px 0; }
.today b { display: block; font: 600 22px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.today span { font-size: 13px; color: var(--muted); }

.ev-list { list-style: none; margin: 0; padding: 0; }
.ev-list li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.ev-list li:last-child { border-bottom: 0; }
.ev-list i { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--water); }
.ev-list li[data-level='warn'] i { background: var(--warn); }
.ev-list li[data-level='alarm'] i { background: var(--alarm); }
.ev-list b { font-weight: 600; display: block; }
.ev-list small { color: var(--muted); font-size: 13px; }
.ev-list time { color: var(--faint); font-size: 13px; white-space: nowrap; }

.custom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 14px; }
.custom-grid div { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); }
.custom-grid span { color: var(--muted); font-size: 13px; display: block; }
.custom-grid b { font: 600 22px/1.2 var(--display); }

@media (max-width: 1100px) {
  .stage { grid-template-columns: 1fr; }
  .readouts { border-left: 0; border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: 1fr 1fr; column-gap: 26px; }
  .ro.hero { grid-column: 1 / -1; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .resources { grid-template-columns: 1fr; }
  .readouts { grid-template-columns: 1fr; padding: 14px 18px; }
  .stage { border-radius: 22px; }
  .stage .scene { min-height: 0; padding: 6px 0 0; }
  .today { grid-template-columns: repeat(2, 1fr); row-gap: 12px; }
  .ro.hero .val { font-size: 40px; }
}

/* ---------- scena kotła (SVG) ---------- */
.boiler text { font-family: var(--display); fill: var(--text); }
.boiler .t-sm { font-size: 13px; fill: var(--muted); font-family: var(--body); }
.boiler .t-md { font-size: 17px; font-weight: 600; }
.boiler .t-lg { font-size: 34px; font-weight: 650; letter-spacing: -1px; }
.boiler .steel { fill: var(--steel-1); }
.boiler .steel-2 { fill: var(--steel-2); }
.boiler .edge { fill: none; stroke: var(--line); stroke-width: 1.5; }
.boiler .pipe { fill: none; stroke: var(--steel-2); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.boiler .flow { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 3 13; opacity: 0; transition: opacity .6s; }
.boiler .flow.hot { stroke: var(--ember-hot); }
.boiler .flow.cold { stroke: var(--water); }
.boiler.pump-co .flow.co, .boiler.pump-cwu .flow.cwu, .boiler.pump-boiler .flow.buf { opacity: .95; animation: flow 1.1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -32; } }

.boiler .flame { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .8s ease, opacity .8s; }
.boiler .flame path { transform-box: fill-box; transform-origin: 50% 100%; }
.boiler.burning .flame path.f1 { animation: flick 1.3s ease-in-out infinite alternate; }
.boiler.burning .flame path.f2 { animation: flick 0.9s ease-in-out infinite alternate-reverse; }
.boiler.burning .flame path.f3 { animation: flick 1.7s ease-in-out infinite alternate; }
@keyframes flick {
  0% { transform: scale(1, 1) skewX(0deg); }
  50% { transform: scale(.94, 1.06) skewX(-2deg); }
  100% { transform: scale(1.04, .95) skewX(2deg); }
}
.boiler .glow { transition: opacity .8s; }
.boiler .fan-blades { transform-box: fill-box; transform-origin: center; }
.boiler.fan .fan-blades { animation: spin var(--fan-dur, 1.2s) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boiler .screw { transition: opacity .3s; }
.boiler.feeder .screw-move { animation: screw .6s linear infinite; }
@keyframes screw { to { transform: translateX(-14px); } }
.boiler .bpump { transform-box: fill-box; transform-origin: 50% 66%; }
.boiler.pump-boiler .bpump { animation: spin 1.1s linear infinite; }
.boiler.pump-boiler .bpump path { fill: var(--water); }
.boiler .cwupump { transform-box: fill-box; transform-origin: 50% 66%; }
.boiler.pump-cwu .cwupump { animation: spin 1.1s linear infinite; }
.boiler.pump-cwu .cwupump path { fill: var(--water); }
.boiler .smoke { opacity: 0; transition: opacity 1s; }
.boiler.burning .smoke { opacity: .5; }
.boiler.burning .smoke path { animation: rise 4s ease-in infinite; }
.boiler.burning .smoke path:nth-child(2) { animation-delay: 1.3s; }
.boiler.burning .smoke path:nth-child(3) { animation-delay: 2.6s; }
@keyframes rise {
  0% { transform: translateY(8px); opacity: 0; }
  30% { opacity: .9; }
  100% { transform: translateY(-34px); opacity: 0; }
}
.boiler .level { transition: y .9s ease, height .9s ease; }
.boiler .grate-bar { transition: transform 1s ease; }
.boiler.offline { filter: saturate(.25); opacity: .75; }
@media (max-width: 720px) {
  .boiler .t-sm { display: none; }
  .boiler .t-md { font-size: 24px; }
  .boiler .t-lg { font-size: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .boiler *, .boiler.burning .flame path, .boiler.fan .fan-blades, .boiler.feeder .screw-move,
  .boiler.pump-co .flow.co, .boiler.pump-cwu .flow.cwu, .boiler.burning .smoke path, .boiler.pump-boiler .bpump, .boiler.pump-cwu .cwupump { animation: none !important; }
  .bar > b, .boiler .level { transition: none; }
}

/* ---------- wykresy ---------- */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart canvas { display: block; width: 100%; }
.chart .tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 11px; font-size: 13px; box-shadow: var(--shadow); min-width: 150px;
  opacity: 0; transition: opacity .12s;
}
.chart .tip.on { opacity: 1; }
.chart .tip time { display: block; color: var(--muted); margin-bottom: 4px; font-size: 12px; }
.chart .tip div { display: flex; justify-content: space-between; gap: 14px; }
.chart .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.chart-panel { margin-bottom: 14px; }
.chart-panel header { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chart-panel h2 { margin: 0; }

/* ---------- statystyki ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-soft); }
.kpi span { color: var(--muted); font-size: 14px; }
.kpi b { display: block; font: 650 30px/1.15 var(--display); letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi b small { font-size: 16px; color: var(--muted); font-weight: 500; }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 10px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
table.data td.r, table.data th.r { text-align: right; white-space: nowrap; }
table.data tbody tr[title]:hover td { background: var(--raised); }
.table-wrap { overflow-x: auto; }

/* ---------- sterowanie ---------- */
.pgroup { margin-bottom: 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-soft); overflow: hidden; }
.pgroup > summary {
  list-style: none; cursor: pointer; padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center; font: 600 16px/1.3 var(--display);
}
.pgroup > summary::-webkit-details-marker { display: none; }
.pgroup > summary .gt span { color: var(--muted); font: 500 13px var(--body); margin-left: 8px; }
.pgroup > summary svg { width: 18px; height: 18px; color: var(--muted); transition: transform .2s; }
.pgroup[open] > summary svg { transform: rotate(180deg); }
.prow {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  padding: 12px 20px; border-top: 1px solid var(--line-soft);
}
.prow .pl b { font-weight: 500; display: block; }
.prow .pl small { color: var(--faint); font-size: 12.5px; }
.prow .pv { font: 600 19px/1 var(--display); font-variant-numeric: tabular-nums; text-align: right; }
.prow .pv small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.prow .pend { color: var(--warn); font-size: 12.5px; display: block; text-align: right; margin-top: 3px; font-family: var(--body); font-weight: 500; }
.prow .ok { color: var(--ok); }

/* ---------- arkusz (okno potwierdzeń) ---------- */
.sheet-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(4, 9, 14, .55);
  display: grid; place-items: center; padding: 18px;
  animation: fadein .18s ease;
}
.sheet {
  width: min(460px, 100%); background: var(--surface); border-radius: 24px;
  border: 1px solid var(--line); box-shadow: var(--shadow); padding: 22px;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
.sheet h3 { margin: 0 0 6px; font: 650 20px/1.25 var(--display); }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
@keyframes fadein { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(14px) scale(.98); opacity: 0; } }
@media (max-width: 600px) {
  .sheet-back { place-items: end center; padding: 0; }
  .sheet { border-radius: 24px 24px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; gap: 10px; align-items: center; }
.stepper button { height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--raised); font-size: 26px; cursor: pointer; }
.stepper output { text-align: center; font: 650 44px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stepper output small { font-size: 18px; color: var(--muted); font-weight: 500; }
.range-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }
input[type='range'] { width: 100%; accent-color: var(--ember); margin-top: 14px; }

/* ---------- zdarzenia ---------- */
.day-head { font: 600 14px/1 var(--body); color: var(--muted); margin: 22px 0 6px; }
.timeline { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 4px 20px; }

/* ---------- mapowanie ---------- */
.map-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.map-tools input { max-width: 260px; }
table.map td.f { font-weight: 600; white-space: nowrap; }
table.map td.v { font: 600 16px var(--display); text-align: right; white-space: nowrap; }
table.map tr.flash td { animation: flash 1.4s ease; }
@keyframes flash { from { background: color-mix(in srgb, var(--ember) 22%, transparent); } }
table.map svg { width: 120px; height: 26px; display: block; }
.role { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--ember); }

/* ---------- ustawienia ---------- */
.set-sec { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; padding: 14px 0; }
.set-sec:first-of-type { border-top: 0; padding-top: 6px; }
.set-sec > header h2 { font: 600 17px/1.3 var(--display); margin: 0 0 6px; }
.set-sec > header p { margin: 0; color: var(--muted); font-size: 14px; }
.set-sec .body { display: grid; gap: 14px; align-content: start; }
/* każda sekcja ustawień na kontrastowej karcie */
.set-sec > .body { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 22px; box-shadow: 0 1px 2px rgba(10, 20, 30, .04); }
.set-sec > .body input[type='text'], .set-sec > .body input[type='number'], .set-sec > .body input[type='password'], .set-sec > .body input[type='date'], .set-sec > .body select { background: var(--bg); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; align-items: baseline; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 9px; background: var(--line-soft); overflow: hidden; }
.progress b { display: block; height: 100%; background: var(--ember); width: 0; transition: width .3s; }
@media (max-width: 860px) { .set-sec { grid-template-columns: minmax(0, 1fr); gap: 12px; } .set-sec > .body { padding: 16px; } }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); }
@media (max-width: 960px) { .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 500; animation: pop .2s ease; }
.toast.err { border-color: color-mix(in srgb, var(--alarm) 50%, var(--line)); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }

/* ---------- logowanie ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(380px, 100%); display: grid; gap: 14px; }
.auth .brand { padding: 0 0 10px; }
.auth h1 { font: 650 28px/1.15 var(--display); margin: 0 0 4px; letter-spacing: -.02em; }
.auth .err { color: var(--alarm); font-size: 14px; }
.auth .btn { width: 100%; min-height: 46px; }

.skeleton { color: transparent !important; background: var(--line-soft); border-radius: 8px; }

/* ---------- urządzenia (administrator) ---------- */
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 14px; }
.dev-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 14px; align-content: start; }
.dev-card.current { border-color: color-mix(in srgb, var(--ember) 55%, var(--line)); }
.dev-id { font: 650 18px/1.2 var(--display); letter-spacing: -.01em; }
.dev-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.dev-stats span { display: block; color: var(--muted); font-size: 12.5px; }
.dev-stats b { font: 600 16px/1.3 var(--display); font-variant-numeric: tabular-nums; }
.viewing { display: grid; gap: 2px; margin: 10px 4px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface); text-decoration: none; border: 1px solid var(--line-soft); }
.viewing span { font-size: 12px; color: var(--muted); }
.viewing b { font: 600 14px var(--display); color: var(--ember); }
.dev-card .status { font-size: 13px; padding: 5px 11px 5px 9px; }
.ro[hidden] { display: none; }

/* przyciski powiększenia na wykresie */
.zoomctl { display: flex; gap: 4px; }
.zoomctl .zbtn { min-width: 34px; height: 32px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); font: 600 17px/1 var(--body); color: var(--text); cursor: pointer; }
.zoomctl .zbtn.reset { font-size: 13px; }
.zoomctl .zbtn:hover { background: var(--raised); }
.zoomctl .zbtn[disabled] { opacity: .35; cursor: default; }

/* tabele statystyk na telefonie: każdy wiersz jako karta z podpisanymi wartościami */
@media (max-width: 720px) {
  table.resp thead { display: none; }
  table.resp, table.resp tbody { display: block; }
  table.resp tr[hidden] { display: none; }
  table.resp tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); }
  table.resp td { border: 0; padding: 0; text-align: left !important; white-space: normal; }
  table.resp td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; }
  table.resp td:first-child { grid-column: 1 / -1; font: 600 16px/1.3 var(--display); }
  table.resp td:first-child::before { display: none; }
  .panel { padding: 16px; }
}

/* iOS: pola daty i wybory nie mogą rozpychać strony */
input[type='date'] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left; }
input[type='date']::-webkit-date-and-time-value { text-align: left; }
input, select, textarea { min-width: 0; max-width: 100%; }
label.field { min-width: 0; }
.form-grid > * { min-width: 0; }
/* iOS przybliża stronę przy polach z tekstem < 16 px — na telefonie dajemy 16 px */
@media (max-width: 960px) {
  input[type='text'], input[type='number'], input[type='password'], input[type='date'], select, textarea { font-size: 16px; }
}
/* przyciski powiększenia pod wykresem — nie zasłaniają wartości */
.zoomctl { position: static; display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.chart .tip { z-index: 5; }

/* ---------- asystent AI ---------- */
.ai-score { display: flex; gap: 18px; align-items: center; }
.ai-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.ai-card { background: var(--surface); border: 1px solid color-mix(in srgb, var(--ember) 35%, var(--line)); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 10px; align-content: start; }
.ai-card p { margin: 0; }
.ai-title { font: 600 16px/1.3 var(--display); }
.ai-change .num { font-size: 26px; margin-top: 2px; }
.ai-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.ai-metric { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 4px; }
.ai-metric > span { color: var(--muted); font-size: 13px; }
.ai-metric b { font: 650 24px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.ai-metric b small { font-size: 13px; color: var(--muted); font-weight: 500; }
.ai-metric > small { color: var(--faint); font-size: 12px; line-height: 1.35; }
textarea { width: 100%; min-height: 64px; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); resize: vertical; }
@media (max-width: 600px) { .ai-score { flex-direction: column; align-items: flex-start; } .ai-metrics { grid-template-columns: 1fr 1fr; } }

.curve-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.curve-grid svg { width: 100%; height: auto; margin-top: 6px; }
@media (max-width: 860px) { .curve-grid { grid-template-columns: 1fr; } }

.ai-run { border-bottom: 1px solid var(--line-soft); padding: 10px 2px; }
.ai-run:last-child { border-bottom: 0; }
.ai-run summary { cursor: pointer; display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; list-style: none; }
.ai-run summary::-webkit-details-marker { display: none; }
.ai-run summary::before { content: '›'; color: var(--muted); transition: transform .15s; display: inline-block; }
.ai-run[open] summary::before { transform: rotate(90deg); }
.ai-run p { margin: 10px 0 0; }
.ai-run .ev-list { margin-top: 8px; }

.btn.danger-text { color: var(--alarm); }

.ai-text { display: grid; gap: 10px; }
.ai-text p { margin: 0; line-height: 1.6; max-width: 72ch; }
.ai-text.lg p { font-size: 16px; }
.ai-text.lg { margin-top: 8px; }
.ai-text.sm p { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.ai-text.muted p { color: var(--muted); }
.ai-note { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--raised); }
.ai-note > b { font-size: 13px; color: var(--muted); font-weight: 600; }
.ai-note .ai-text p { font-size: 14px; }

/* ================= Statystyki rozszerzone ================= */
.xs-tabs { display: flex; gap: 4px; margin: 4px 0 18px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.xs-tabs::-webkit-scrollbar { display: none; }
.xs-tabs button { flex: none; border: 0; background: transparent; color: var(--muted); font: 600 14.5px/1 var(--body); padding: 12px 14px 13px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.xs-tabs button:hover { color: var(--text); }
.xs-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--ember); }
.xs-pane { display: grid; gap: 14px; }
.xs-grid { display: grid; gap: 14px; }
.xs-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .xs-grid.two { grid-template-columns: minmax(0, 1fr); } }
.xs-card { display: grid; gap: 14px; align-content: start; }
.xs-head h2 { margin: 0; font: 650 17px/1.25 var(--display); }
.xs-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.xs-foot { margin: 0; font-size: 13px; }
.big-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.big-stat { display: grid; gap: 3px; padding: 14px 16px; border-radius: var(--r-md); background: var(--raised); border: 1px solid var(--line-soft); }
.big-stat > span { color: var(--muted); font-size: 12.5px; }
.big-stat b { font: 680 26px/1.1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.big-stat b small { font: 500 13px var(--body); color: var(--muted); }
.big-stat > small { color: var(--faint); font-size: 12px; }
.big-stat.accent { background: linear-gradient(135deg, color-mix(in srgb, var(--ember) 20%, var(--raised)), var(--raised)); border-color: color-mix(in srgb, var(--ember) 40%, var(--line)); }
.kpis .big-stat { background: var(--surface); }
.heatmap, .linechart { width: 100%; height: auto; display: block; }
.hm-wrap { overflow-x: auto; }
.heatmap .hm-l, .linechart .ax { fill: var(--faint); font: 500 11px var(--body); }
.linechart .gl { stroke: var(--line-soft); }
.lg { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.lg span { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.stackbar { display: flex; height: 34px; border-radius: 10px; overflow: hidden; gap: 2px; }
.stackbar > div { display: grid; place-items: center; min-width: 2px; }
.stackbar span { font: 650 12px var(--body); color: #1b0d03; }
.stack-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.stack-legend span { display: inline-flex; align-items: center; gap: 6px; }
.stack-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
table.cmp { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.cmp th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13.5px; padding: 8px 0; }
table.cmp td { text-align: right; padding: 8px 0 8px 12px; font-weight: 600; white-space: nowrap; }
table.cmp tr + tr > * { border-top: 1px solid var(--line-soft); }
.delta { font: 650 12px var(--body); padding: 3px 8px; border-radius: 99px; background: var(--raised); color: var(--muted); }
.delta.good { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.delta.bad { color: var(--alarm); background: color-mix(in srgb, var(--alarm) 14%, transparent); }
.hero-forecast { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: center; padding: 26px 28px; border-radius: var(--r-lg);
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--ember) 26%, var(--surface)) 0%, var(--surface) 60%); border: 1px solid color-mix(in srgb, var(--ember) 30%, var(--line)); }
.hero-forecast p { margin: 6px 0 0; color: var(--muted); }
.hero-side { display: grid; gap: 10px; }
.eyebrow { font: 650 11.5px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--ember); }
.hero-num { font: 720 54px/1.05 var(--display); letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.hero-num small { font-size: 22px; color: var(--muted); font-weight: 600; }
@media (max-width: 760px) { .hero-forecast { grid-template-columns: 1fr; padding: 20px; } .hero-num { font-size: 42px; } }
.month-bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.mb { display: grid; gap: 4px; justify-items: center; text-align: center; }
.mb-bar { height: 120px; width: 100%; max-width: 44px; display: flex; align-items: flex-end; background: var(--raised); border-radius: 10px; overflow: hidden; }
.mb-bar i { display: block; width: 100%; background: linear-gradient(180deg, var(--ember), color-mix(in srgb, var(--ember) 55%, var(--surface))); border-radius: 10px 10px 0 0; }
.mb b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.mb span { font-size: 12.5px; color: var(--muted); }
.mb small { font-size: 11.5px; color: var(--faint); }
.refills { list-style: none; margin: 0; padding: 0; display: grid; }
.refills li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.refills li i { width: 10px; height: 10px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ember) 20%, transparent); }
.refills li small { display: block; color: var(--muted); font-size: 12.5px; }
.refills time { color: var(--faint); font-size: 12.5px; }
.twin { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; }
.twin-col { display: grid; gap: 6px; padding: 16px; border-radius: var(--r-md); background: var(--raised); }
.twin-col > b { font: 650 16px var(--display); }
.twin-vs { display: grid; justify-items: center; gap: 2px; }
.twin-vs b { font: 720 28px var(--display); color: var(--ember); }
.twin-vs small { color: var(--muted); font-size: 12px; }
@media (max-width: 760px) { .twin { grid-template-columns: 1fr; } }
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.record { display: grid; gap: 4px; padding: 16px 18px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-soft); position: relative; overflow: hidden; }
.record::after { content: ''; position: absolute; right: -24px; top: -24px; width: 80px; height: 80px; border-radius: 50%; background: color-mix(in srgb, var(--ember) 10%, transparent); }
.record span { color: var(--muted); font-size: 13px; }
.record b { font: 700 28px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.record b small { font-size: 14px; color: var(--muted); font-weight: 500; }
.record time { color: var(--faint); font-size: 12.5px; }
.xs-pane[hidden] { display: none; }
.hm-wrap .heatmap { max-width: 760px; }
.record > * { position: relative; z-index: 1; }
.record::after { right: -34px; top: -34px; width: 70px; height: 70px; background: color-mix(in srgb, var(--ember) 7%, transparent); z-index: 0; }

/* dymek wykresów SVG */
.svg-tip { position: fixed; z-index: 90; pointer-events: none; padding: 9px 12px; border-radius: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.28); backdrop-filter: blur(8px); font-size: 13px; line-height: 1.45; max-width: 260px; }
.svg-tip b { display: block; font-weight: 650; margin-bottom: 2px; }
.svg-tip div { color: var(--muted); font-variant-numeric: tabular-nums; }
.tipcol { fill: transparent; }
.tipcol.tip-on { fill: color-mix(in srgb, var(--text) 7%, transparent); }
.hm-cell.tip-on { stroke: var(--text); stroke-width: 2; }
.sc-pt.tip-on { stroke: var(--text); stroke-width: 2; }
.linechart, .scatter, .barchart { touch-action: pan-y; }
.hm-wrap { overflow: visible; }

/* tylko przezroczyste kolumny łapią kursor — dymek nad słupkami i liniami */
.barchart rect:not(.tipcol), .barchart path, .barchart line, .barchart polyline, .barchart circle, .barchart text,
.linechart path, .linechart circle, .linechart text, .linechart line { pointer-events: none; }
.barchart rect.tipcol.tip-on { fill: color-mix(in srgb, var(--text) 8%, transparent); }

.mb .mb-t { color: var(--water); font-size: 11.5px; }

.ev-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; margin-top: 8px; }
.ev-legend span { font-weight: 700; display: inline-flex; gap: 5px; align-items: baseline; }
.ev-legend em { font-style: normal; font-weight: 500; color: var(--muted); }
.chart .tip .tip-ev { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.chart .tip .tip-ev { display: grid; gap: 3px; }
.chart .tip .tip-ev > div { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.chart .tip .tip-ev span { display: inline-flex; align-items: center; gap: 6px; }
.chart .tip .tip-ev i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Premium */
.premium-cta { display: grid; gap: 6px; padding: 18px 20px; border-radius: var(--r-md);
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--ember) 24%, var(--raised)) 0%, var(--raised) 65%); border: 1px solid color-mix(in srgb, var(--ember) 35%, var(--line)); }
.premium-price { font: 700 28px/1.1 var(--display); }
.premium-on { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r-md); background: color-mix(in srgb, var(--ember) 12%, var(--raised)); }
.premium-on b { color: var(--ember); font: 650 17px var(--display); }
.premium-feats { display: grid; gap: 12px; }
.premium-feats b { font-weight: 650; }
.premium-feats p { margin: 3px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* zakładka Premium */
.tab-lock { margin-left: 6px; color: var(--ember); font-size: 11px; }
.locked { position: relative; min-height: 420px; }
.locked-preview { filter: blur(6px) saturate(.8); opacity: .55; pointer-events: none; display: grid; gap: 14px; }
.locked-card { position: absolute; inset: 40px 0 auto; margin: 0 auto; max-width: 460px; text-align: center; display: grid; gap: 10px; justify-items: center;
  padding: 28px 26px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid color-mix(in srgb, var(--ember) 40%, var(--line)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.locked-card h2 { margin: 0; font: 680 22px var(--display); }
.locked-card p { margin: 0; line-height: 1.55; }
.locked-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: #1b0d03; background: var(--ember); }
.pr-hero { padding: 34px 32px; border-radius: var(--r-lg); margin-bottom: 18px; display: grid; gap: 12px;
  background: radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--ember) 30%, var(--surface)) 0%, var(--surface) 62%); border: 1px solid color-mix(in srgb, var(--ember) 35%, var(--line)); }
.pr-hero h1 { margin: 0; font: 740 clamp(28px, 4.2vw, 42px)/1.12 var(--display); letter-spacing: -.02em; max-width: 22ch; }
.pr-hero > p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--muted); max-width: 62ch; }
.pr-price { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.pr-price b { font: 720 26px var(--display); color: var(--ember); }
.pr-price.big b { font-size: 34px; }
.pr-price span { color: var(--muted); }
.pf { display: grid; grid-template-columns: 54px 1fr; gap: 16px; padding: 24px; margin-bottom: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-soft); }
.pf-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--ember) 16%, var(--raised)); color: var(--ember); }
.pf h2 { margin: 2px 0 6px; font: 680 20px var(--display); }
.pf-lead { margin: 0 0 10px; color: var(--muted); line-height: 1.55; }
.pf-list { margin: 0; padding-left: 18px; display: grid; gap: 7px; line-height: 1.5; }
.pf-list li::marker { color: var(--ember); }
.pf-note { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--raised); font-size: 14px; }
.pr-benefits, .pr-buy, .pr-faq { padding: 24px; margin-bottom: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-soft); display: grid; gap: 12px; }
.pr-benefits h2, .pr-buy h2, .pr-faq h2 { margin: 0; font: 680 20px var(--display); }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pr-b { padding: 16px; border-radius: var(--r-md); background: var(--raised); }
.pr-b p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.pr-buy { border-color: color-mix(in srgb, var(--ember) 40%, var(--line)); }
@media (max-width: 600px) { .pf { grid-template-columns: 1fr; } .pr-hero { padding: 24px 20px; } }
.seg[hidden] { display: none; }

/* ukryty element jest zawsze niewidoczny — niezależnie od display ustawionego w klasie */
[hidden] { display: none !important; }

/* ulubione w Sterowaniu */
.fav-star { border: 0; background: transparent; cursor: pointer; font-size: 20px; line-height: 1; padding: 6px; margin: -6px 2px -6px -6px; color: var(--faint); border-radius: 8px; font-style: normal; }
.fav-star:hover { color: var(--ember); background: var(--raised); }
.fav-star.on { color: var(--ember); }
.fav-group { border-color: color-mix(in srgb, var(--ember) 35%, var(--line)) !important; }
.prow { align-items: center; }

/* zablokowane nastawy (bez Premium) */
.locked-row .pl b { color: var(--muted); }
.lock-ic { width: 32px; text-align: center; font-size: 15px; opacity: .75; }
.pv.blurred { filter: blur(6px); user-select: none; pointer-events: none; opacity: .7; }

.cron-url { display: block; padding: 10px 12px; border-radius: 10px; background: var(--raised); word-break: break-all; font-size: 13px; }

/* wykres na pełny ekran */
html.fs-open, html.fs-open body { overflow: hidden; }
.fs-chart { position: fixed; inset: 0; z-index: 200; background: var(--bg); }
.fs-inner { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.fs-chart.rot .fs-inner { inset: auto; top: 0; left: 0; width: 100vh; width: 100dvh; height: 100vw; transform: rotate(90deg) translateY(-100%); transform-origin: top left;
  padding: max(10px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)); }
.fs-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fs-head b { font: 650 16px var(--display); }
.fs-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.fs-chips::-webkit-scrollbar { display: none; }
.fs-chips .chip { flex: none; }
.fs-host { flex: 1; min-height: 0; }

.zbtn.fsbtn { margin-left: 8px; font-size: 17px; }

.fs-zoom { margin: 0; }
.fs-hint { color: var(--muted); font-size: 13px; }
.fs-hint::before { content: '⤾ '; color: var(--ember); }
@media (max-height: 520px) {
  .fs-head { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .fs-head::-webkit-scrollbar { display: none; }
  .fs-head > b { display: none; }
  .fs-head .seg button { padding: 6px 9px; font-size: 13px; }
  .fs-head .zbtn { min-width: 30px; height: 30px; }
  .fs-close span { display: none; }
  .fs-inner { gap: 6px; }
}

.ai-run summary .grow { flex: 1; }
.ai-run summary .btn { margin-left: auto; }

/* licznik kosztów na żywo */
.cost-cell small { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }
.cost-cell small.up { color: var(--warn); }
.cost-cell small.down { color: var(--ok); }
.cost-live { font-variant-numeric: tabular-nums; }

/* nawigacja po wykresach */
.chart canvas.nav { cursor: grab; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.chart canvas.nav.grabbing { cursor: grabbing; }
.chart canvas.nav:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.fs-chart .chart, .fs-chart .chart canvas { touch-action: none; }
.chart-loading { position: absolute; top: 6px; right: 10px; font-size: 12px; color: var(--muted); pointer-events: none; animation: navpulse 1.1s ease-in-out infinite; }
@keyframes navpulse { 50% { opacity: .35; } }
.nav-sticky { position: sticky; top: 0; z-index: 30; margin: 0 -6px 10px; padding: 8px 6px 10px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft); }
.nav-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-height: 34px; }
.nav-bar .grow { flex: 1; }
.nav-info { font: 600 14px var(--body); color: var(--text); font-variant-numeric: tabular-nums; }
.nav-hint { font-size: 13px; margin: 0 0 12px; line-height: 1.45; }
.nav-hint summary { cursor: pointer; width: fit-content; }
.nav-hint ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
@media (max-width: 699px) { .nav-sticky { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; border-bottom: 0; background: none; padding-top: 0; } }
.minimap { position: relative; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-soft); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.minimap canvas { display: block; width: 100%; }

/* raporty */
.rp-season { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 22px 24px; border-radius: var(--r-lg);
  background: radial-gradient(120% 160% at 100% 0%, color-mix(in srgb, #b69cff 26%, var(--surface)) 0%, var(--surface) 60%); border: 1px solid color-mix(in srgb, #b69cff 35%, var(--line)); }
.rp-season h2 { margin: 6px 0 4px; font: 700 22px var(--display); }
.rp-season p { margin: 0; }
.rp-months { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.rp-months::-webkit-scrollbar { display: none; }
.rp-months .chip { flex: none; text-transform: capitalize; }
.rp-month { display: grid; gap: 16px; }
.rp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.rp-head h2 { margin: 6px 0 0; font: 720 28px var(--display); }
.rp-score { display: grid; justify-items: center; padding: 10px 16px; border-radius: var(--r-md); background: var(--raised); }
.rp-score b { font: 720 26px var(--display); color: var(--ok); }
.rp-score small { color: var(--muted); font-size: 12px; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.rp-box { display: grid; gap: 8px; padding: 16px; border-radius: var(--r-md); background: var(--raised); align-content: start; }
.rp-cmp { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; font-size: 14px; }
.rp-cmp > span:first-child { color: var(--muted); }
.rp-rec { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.rp-rec span { color: var(--muted); font-size: 14px; }
.rp-rec small { grid-column: 1 / -1; color: var(--faint); font-size: 12.5px; }
/* podsumowanie sezonu (slajdy) */
.wr { position: fixed; inset: 0; z-index: 210; color: #fff; overflow: hidden;
  background: radial-gradient(140% 120% at 10% 0%, #ff8a3d 0%, #b23a6b 45%, #2b1a55 100%); }
.wr-bar { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; right: 56px; display: flex; gap: 5px; z-index: 2; }
.wr-bar i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.3); }
.wr-bar i.on { background: #fff; }
.wr-close { position: absolute; top: max(4px, env(safe-area-inset-top)); right: 10px; z-index: 3; background: none; border: 0; color: #fff; font-size: 22px; padding: 8px; cursor: pointer; }
.wr-nav { position: absolute; top: 0; bottom: 0; width: 40%; background: none; border: 0; z-index: 1; cursor: pointer; }
.wr-nav.l { left: 0; } .wr-nav.r { right: 0; width: 60%; }
.wr-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 70px 28px 40px; pointer-events: none; }
.wr-card { max-width: 620px; width: 100%; display: grid; gap: 14px; animation: wrIn .5s cubic-bezier(.2,.8,.2,1); }
.wr-card .eyebrow { color: rgba(255,255,255,.85); font-size: 13px; }
.wr-big { font: 800 clamp(44px, 9vw, 84px)/1 var(--display); letter-spacing: -.03em; }
.wr-num { font: 800 clamp(64px, 15vw, 132px)/1 var(--display); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.wr-num small { font-size: .32em; font-weight: 600; letter-spacing: 0; opacity: .85; }
.wr-num.good { color: #b8ffd0; } .wr-num.bad { color: #ffd0c4; }
.wr-card p { margin: 0; font-size: clamp(17px, 2.6vw, 22px); line-height: 1.4; opacity: .95; }
.wr-months { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; height: 240px; align-items: end; }
.wr-months > div { display: grid; grid-template-rows: 1fr auto auto; height: 100%; justify-items: center; gap: 4px; }
.wr-months i { align-self: end; width: 70%; border-radius: 10px 10px 4px 4px; background: rgba(255,255,255,.85); animation: wrBar .9s cubic-bezier(.2,.8,.2,1) both; transform-origin: bottom; }
.wr-months b { font-size: 13px; } .wr-months span { font-size: 12px; opacity: .8; text-transform: capitalize; }
@keyframes wrIn { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes wrBar { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Rozmowa z Asystentem */
.chat { display: grid; gap: 12px; margin-bottom: 18px; }
.chat-list { display: grid; gap: 14px; max-height: 520px; overflow-y: auto; }
.chat-list:empty { display: none; }
.chat-item { display: grid; gap: 6px; }
.chat-q { justify-self: end; max-width: 85%; background: color-mix(in srgb, var(--ember) 16%, transparent); border: 1px solid color-mix(in srgb, var(--ember) 30%, transparent); border-radius: 14px 14px 4px 14px; padding: 8px 12px; }
.chat-q p { margin: 0; }
.chat-q small { color: var(--faint); font-size: 11px; }
.chat-a { justify-self: start; max-width: 92%; background: var(--raised); border: 1px solid var(--line-soft); border-radius: 14px 14px 14px 4px; padding: 10px 14px; }
.chat-a .ai-text p { margin: 0 0 8px; } .chat-a .ai-text p:last-child { margin: 0; }
.chat-sug { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-sug .chip { cursor: pointer; border: 1px solid var(--line-soft); background: transparent; color: var(--muted); font: inherit; font-size: 13px; }
.chat-sug .chip:hover { color: var(--text); border-color: var(--ember); }
.chat-form { display: grid; gap: 6px; }
.chat-form textarea { width: 100%; resize: vertical; }
.dots::after { content: '…'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 1.2em; } }

/* Widżet na telefon */
.wg-help { border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 8px 12px; }
.wg-help summary { cursor: pointer; font-weight: 600; }
.wg-help ol { margin: 8px 0; padding-left: 20px; color: var(--muted); }
.wg-code { max-height: 220px; overflow: auto; font-size: 11.5px; background: var(--wall); border-radius: var(--r-sm); padding: 10px; white-space: pre; margin: 8px 0 0; }

/* Tryb ścienny — kotłownia na ścianę */
body.wall-mode .rail, body.wall-mode .tabbar { display: none !important; }
body.wall-mode .shell { display: block; }
body.wall-mode main { max-width: none; padding: 0; }
.wall { position: fixed; inset: 0; background: #0b1117; color: #e6edf2; display: grid; grid-template-rows: auto 1fr auto; gap: 1.5vh; padding: calc(2vh + env(safe-area-inset-top)) 2.5vw calc(2vh + env(safe-area-inset-bottom)); overflow: hidden; z-index: 50; cursor: default; user-select: none; }
.wl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.wl-name { font: 700 clamp(20px, 3vw, 40px)/1.1 var(--display); margin-bottom: 8px; }
.wl-time { text-align: right; }
.wl-clock { font: 700 clamp(40px, 7vw, 110px)/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.wl-date { color: #8a9baa; font-size: clamp(13px, 1.5vw, 20px); }
.wl-date::first-letter { text-transform: uppercase; }
.wl-body { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 2.5vw; align-items: center; min-height: 0; }
.wl-scene { min-height: 0; height: 100%; display: flex; align-items: center; }
.wl-scene .scene { width: 100%; }
.wl-scene svg { width: 100%; height: auto; max-height: 68vh; }
.wl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: min(1.4vw, 1.8vh); align-content: center; min-height: 0; }
.wl-tile { background: #121a22; border: 1px solid #1f2b37; border-radius: 18px; padding: 1.3vh 1.4vw; display: grid; gap: 2px; min-width: 0; }
.wl-tile span { color: #8a9baa; font-size: clamp(12px, 1.3vw, 18px); }
.wl-tile b { font: 700 clamp(26px, min(4.6vw, 6.6vh), 76px)/1.05 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wl-tile b small { font-size: .45em; color: #8a9baa; font-weight: 600; margin-left: 2px; }
.wl-tile > small { color: #5d6e7d; font-size: clamp(11px, 1.15vw, 16px); min-height: 1.2em; }
.wl-tile.heat b { color: #ffc15e; }
.wl-tile.cwu b { color: #5bb8e8; }
.wl-tile.room b { color: #5fd39a; }
.wl-tile.pwr.lit { border-color: rgba(255, 138, 61, .55); box-shadow: 0 0 40px rgba(255, 138, 61, .15) inset; }
.wl-tile.pwr.lit b { color: #ff8a3d; }
.wl-tile.pel.low { border-color: rgba(242, 181, 68, .6); }
.wl-tile.pel.low b { color: #f2b544; }
.wl-alert { background: rgba(242, 181, 68, .12); border: 1px solid rgba(242, 181, 68, .45); color: #f2b544; border-radius: 12px; padding: 1vh 1.4vw; font-size: clamp(14px, 1.6vw, 22px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-exit { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -150%); display: flex; gap: 8px; transition: transform .25s; z-index: 51; }
.wl-exit.on { transform: translate(-50%, 0); }
@media (orientation: portrait), (max-width: 760px) {
  .wl-body { grid-template-columns: 1fr; align-content: start; }
  .wl-scene svg { max-height: 34vh; }
  .wl-tile b { font-size: clamp(26px, 8vw, 60px); }
  .wall { overflow-y: auto; }
}

/* Prognoza: pewność */
.fc-conf { margin-top: 8px; display: inline-block; }
.fc-conf[data-c='dobra'] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.fc-conf[data-c='srednia'] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.fc-conf[data-c='wstepna'], .fc-conf[data-c='brak'] { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 45%, transparent); }

/* Ustawienia: nic nie może rozpychać kart na wąskim ekranie */
.set-sec > *, .set-sec .body, .set-sec .body > *, .set-pane { min-width: 0; }
.set-sec input, .set-sec select, .set-sec textarea { max-width: 100%; min-width: 0; }
.set-sec dd, .set-sec small, .set-sec p { overflow-wrap: anywhere; }
.wg-help { min-width: 0; }
.wg-help ol { overflow-wrap: anywhere; }
.wg-code { max-width: 100%; }

/* Ogrzewanie (CO) i analiza krzywej */
.ready-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.ready-list li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; column-gap: 8px; align-items: baseline; font-size: 14px; }
.ready-list li i { font-style: normal; font-weight: 700; color: var(--alarm); }
.ready-list li[data-ok='true'] i { color: var(--ok); }
.ready-list li small { grid-column: 2 / 4; }
.ready-det summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.ok-chip { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.warn-chip { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.curve-score { font: 700 26px var(--display); }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; column-gap: 10px; align-items: center; font-size: 14px; }
.hbar-track { height: 10px; background: var(--line-soft); border-radius: 6px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--ember-hot), var(--ember)); border-radius: 6px; }
.hbar small { grid-column: 2 / 4; font-size: 12px; }
.wl-alert.info { background: rgba(159, 178, 194, .1); border-color: rgba(159, 178, 194, .35); color: #c9d4dd; }

.res-when { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }

/* Zdarzenia, magazyn, czyszczenia i raport serwisowy. */
.event-link{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:700;text-align:left;cursor:pointer;text-decoration:none;display:block}
.ev-list small{display:block}
.event-link:hover,.event-link:focus-visible{color:var(--ember)}
.service-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.service-entry{padding:12px;border:1px solid var(--line-soft);border-radius:12px;min-width:0;overflow-wrap:anywhere}
.service-entry summary{cursor:pointer;display:flex;flex-direction:column;gap:4px}
.service-entry small{display:block;color:var(--muted);margin-top:4px}
.service-entry p{font-size:14px;line-height:1.5}
.cycle-list{display:grid;gap:8px;max-height:650px;overflow:auto}
.service-clean{margin:12px 0;padding-bottom:12px;border-bottom:1px solid var(--line-soft)}
.service-clean p{font-size:14px}
.service-history{list-style:none;padding:0;margin:12px 0 0;max-height:330px;overflow:auto}
.service-history li{padding:10px 0;border-top:1px solid var(--line-soft);font-size:14px;overflow-wrap:anywhere}
.service-history small{display:block;color:var(--muted);margin-top:4px}
.service-actions{flex-wrap:wrap;gap:8px}
.service-form{display:grid;gap:12px}
.service-export{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-bottom:12px}
.service-export input,.service-export select,.service-form input{box-sizing:border-box;width:100%;min-width:0;max-width:100%}
@media(max-width:600px){.service-grid,.service-export{grid-template-columns:1fr}.service-entry p{margin:4px 0}.sheet .xs-grid.two{grid-template-columns:1fr}}

.service-sheet{width:min(740px,100%);max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);overflow:auto;overscroll-behavior:contain;box-sizing:border-box}
