:root {
  --bg: #0b1d2a;
  --bg2: #102a3b;
  --card: #13324599;
  --card-solid: #143246;
  --line: #ffffff1a;
  --text: #eaf6fb;
  --muted: #8fb3c4;
  --accent: #2ec5e6;
  --accent2: #36e0b0;
  --heat: #ff8a3d;
  --danger: #ff5a6a;
  --warn: #ffc24b;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -200px, #1c5a78 0%, var(--bg) 60%) fixed, var(--bg);
  min-height: 100vh;
  padding-bottom: calc(76px + var(--safe-b));
}
h1 { font-size: 22px; margin: 0; letter-spacing: .2px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; flex-wrap: wrap; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(16px + var(--safe-t)) 20px 8px;
  max-width: 560px; margin: 0 auto;
}
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; margin-top: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.ok { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.dot.bad { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.signal { display: flex; gap: 3px; align-items: flex-end; height: 18px; }
.signal i { width: 4px; background: var(--line); border-radius: 2px; }
.signal i.on { background: var(--accent); }

main { max-width: 560px; margin: 0 auto; padding: 8px 14px; }
.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

/* temperatura */
.temp-card { padding-top: 22px; }
.temp-ring { position: relative; width: min(62vw, 240px); aspect-ratio: 1; margin: 0 auto; }
.temp-ring svg { width: 100%; height: 100%; transform: rotate(135deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 12; stroke-linecap: round; }
.ring-bg { stroke: #ffffff14; stroke-dasharray: 405 540; }
.ring-fg { stroke: var(--accent); stroke-dasharray: 0 540; transition: stroke-dasharray .6s ease, stroke .4s; }
.temp-ring.heating .ring-fg { stroke: var(--heat); }
.temp-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.temp-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.temp-current { font-size: 64px; font-weight: 300; line-height: 1; margin: 4px 0; font-variant-numeric: tabular-nums; }
.temp-current small, .target-val small { font-size: .4em; color: var(--muted); margin-left: 2px; }
.temp-op { font-size: 14px; color: var(--muted); }
.temp-ring.heating .temp-op { color: var(--heat); }
.target-row { display: flex; align-items: center; justify-content: center; gap: 28px; margin-top: 4px; }
.target { text-align: center; min-width: 110px; }
.target-val { font-size: 34px; font-weight: 500; font-variant-numeric: tabular-nums; }
.target-val.pending { color: var(--accent); }
.temp-sub { font-size: 12px; color: var(--warn); min-height: 16px; }
.round {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card-solid); font-size: 30px; line-height: 1; cursor: pointer;
}
.round:active { transform: scale(.94); background: #1d4660; }
.round:disabled { opacity: .35; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.chip { font-size: 13px; padding: 5px 11px; border-radius: 99px; background: #ffffff10; color: var(--muted); }
.chip.on { background: #2ec5e622; color: var(--accent); }
.chip.heat { background: #ff8a3d22; color: var(--heat); }

/* pompy / segmenty */
.pump { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.pump + .pump { border-top: 1px solid var(--line); }
.pump-name { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: #00000033; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  border: 0; background: transparent; padding: 8px 13px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 14px;
}
.seg button.on { background: var(--accent); color: #032230; font-weight: 600; }
.seg.small button { padding: 5px 10px; font-size: 13px; }
.seg-wrap { display: flex; flex-wrap: wrap; }
.seg-wrap button { flex: 1 1 auto; }
.spin { display: inline-block; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* listy i przełączniki */
.list .item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; gap: 12px; }
.list .item + .item { border-top: 1px solid var(--line); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #ffffff22; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent2); }
.switch input:checked + span::before { transform: translateX(20px); }

.btn {
  border: 1px solid var(--line); background: var(--card-solid); padding: 10px 16px; border-radius: 12px; cursor: pointer; font-size: 15px;
}
.btn.primary { background: var(--accent); color: #032230; border-color: transparent; font-weight: 600; }
.btn.ok { background: var(--accent2); color: #032230; border-color: transparent; font-weight: 600; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.97); }

.banner { display: block; padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; text-decoration: none; font-size: 15px; }
.banner.danger { background: #ff5a6a22; color: #ffb3bb; border: 1px solid #ff5a6a55; }
.banner.warn { background: #ffc24b1c; color: var(--warn); border: 1px solid #ffc24b44; }

/* serwis */
.task { padding: 14px 0; }
.task + .task { border-top: 1px solid var(--line); }
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.task-name { font-weight: 600; }
.task-desc { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.bar { height: 6px; border-radius: 99px; background: #ffffff14; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent2); border-radius: 99px; }
.bar.soon i { background: var(--warn); }
.bar.due i { background: var(--danger); }
.task-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); gap: 8px; flex-wrap: wrap; }
.task-foot input { width: 58px; background: #00000033; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 6px; font: inherit; text-align: center; }
.task.disabled { opacity: .45; }
.days { font-weight: 600; }
.days.due { color: var(--danger); }
.days.soon { color: var(--warn); }

/* historia */
.chart { height: 200px; margin-top: 6px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 6px 14px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.lg { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: -8px; vertical-align: middle; }
.lg.cur { background: var(--accent); } .lg.tgt { background: var(--muted); } .lg.heat { background: #ff8a3d55; height: 10px; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-size: 12px; display: block; }

/* nawigacja */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center;
  background: #0b1d2ae6; border-top: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 6px 6px calc(6px + var(--safe-b));
}
.tabs a {
  flex: 1; max-width: 140px; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px;
  padding: 4px 0; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs a span { font-size: 22px; filter: grayscale(1) opacity(.7); }
.tabs a.on { color: var(--text); }
.tabs a.on span { filter: none; }
.badge { position: absolute; top: 0; left: 55%; background: var(--danger); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; line-height: 17px; padding: 0 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0;
  background: #000c; padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .25s; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* logowanie */
.login { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-logo { font-size: 48px; }
.login input { font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #00000033; color: var(--text); }
.error-text { color: var(--danger); min-height: 20px; margin: 0; font-size: 14px; }
