:root {
  --bg: #f3f5f8; --card: #ffffff; --ink: #14202e; --muted: #5d6b7b; --line: #dde3ea;
  --accent: #1f6feb; --ok: #1a9a55; --warn: #d98a00; --bad: #d63a2f; --t2: #1f6feb; --curve: #e5483d;
  --chip: #eaeef3; --shadow: 0 1px 2px rgba(20,32,46,.08), 0 6px 18px rgba(20,32,46,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1320; --card: #131f31; --ink: #e8eef6; --muted: #93a2b5; --line: #243247;
    --accent: #5aa0ff; --ok: #3ccf82; --warn: #f0b429; --bad: #ff6b5e; --t2: #5aa0ff; --curve: #ff7a6e;
    --chip: #1b2a40; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: calc(env(safe-area-inset-top) + 56px) 0 calc(env(safe-area-inset-bottom) + 76px); min-height: 100vh; }
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 5; height: calc(env(safe-area-inset-top) + 52px);
  padding: env(safe-area-inset-top) 16px 0; display: flex; align-items: center; justify-content: space-between;
  background: #0f1b2d; color: #fff; }
.top-title { font-weight: 650; font-size: 18px; letter-spacing: .2px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c9d5e4; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #8c98a8; }
.conn.ok .dot { background: #3ccf82; } .conn.warn .dot { background: #f0b429; } .conn.bad .dot { background: #ff6b5e; }
main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }
.view { display: none; } .view.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .k { color: var(--muted); } .row .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero .big { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.hero .small { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--chip); font-weight: 600; }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.seg button { padding: 14px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--chip); color: var(--muted);
  font: inherit; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.seg button svg { width: 33px; height: 33px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.seg button.on { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); border-color: var(--ok); }
.seg button:disabled { opacity: .5; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .lbl { fill: var(--ink); font-weight: 600; } .chart .t2lbl { fill: var(--t2); font-weight: 700; }
.chart .grid { stroke: var(--line); stroke-width: 1; } .chart .curve { stroke: var(--curve); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.chart .pt { fill: var(--card); stroke: var(--curve); stroke-width: 2; } .chart .t2line { stroke: var(--t2); stroke-width: 2; }
.chart .t2dot { fill: var(--t2); stroke: var(--card); stroke-width: 2; }
.form-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.form-row:first-of-type { border-top: 0; }
.form-row .name { font-weight: 600; } .form-row .now { color: var(--muted); font-size: 13px; }
input[type=number], input[type=text], input[type=password], input[type=url] {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.form-row input[type=number] { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.btn { font: inherit; font-weight: 650; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #fff; cursor: pointer; }
.btn.ghost { background: var(--chip); color: var(--ink); } .btn:disabled { opacity: .45; }
label.f { display: block; margin: 0 0 12px; } label.f span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.alarm-item { padding: 10px 0; border-top: 1px solid var(--line); } .alarm-item:first-of-type { border-top: 0; }
.alarm-item .when { font-weight: 650; font-variant-numeric: tabular-nums; } .alarm-item .why { color: var(--muted); font-size: 14px; }
.mono { font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-word; color: var(--muted); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; padding: 9px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.active { color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 88px); transform: translate(-50%, 20px); opacity: 0;
  background: #0f1b2d; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; pointer-events: none; transition: .2s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.bad { background: var(--bad); }
.stale { color: var(--warn); font-size: 13px; margin: 0 0 12px; }

/* --- wersja 2: oprawa wizualna --- */
.top { background: linear-gradient(135deg,#0b1a30,#12335c); height: calc(env(safe-area-inset-top) + 60px); }
body { padding-top: calc(env(safe-area-inset-top) + 68px); }
.brand { display:flex; align-items:center; gap:12px; } .logo { width:38px; height:38px; flex:none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.top-title { line-height:1.1; } .top-sub { font-size:11.5px; color:#9fb4cf; letter-spacing:.04em; margin-top:2px; }
.hero-card { border:0; color:#fff; background: linear-gradient(145deg,#1b5fd1,#12a39a); position:relative; overflow:hidden; padding:20px 18px 16px; }
.hero-card::after { content:""; position:absolute; right:-40px; top:-40px; width:170px; height:170px; border-radius:50%; background:rgba(255,255,255,.10); }
.hero-card.run { background: linear-gradient(145deg,#d9542c,#f0a02b); } .hero-card.cwu { background: linear-gradient(145deg,#6b3fd1,#2f7bff); }
.hero-card.alarm { background: linear-gradient(145deg,#a8231a,#e5483d); }
.hero-label { font-size:12px; text-transform:uppercase; letter-spacing:.12em; opacity:.85; font-weight:650; }
.hero-card .hero { margin:6px 0 12px; } .hero-card .big { font-size:56px; } .hero-card .small { color:rgba(255,255,255,.85); }
.state-chip { display:inline-flex; align-items:center; gap:8px; background:rgba(255,255,255,.18); border-radius:999px; padding:7px 14px; font-weight:650; backdrop-filter: blur(4px); }
.state-chip .pdot { width:9px; height:9px; border-radius:50%; background:#fff; opacity:.9; }
.state-chip.on .pdot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow:0 0 0 0 rgba(255,255,255,.6);} 50% { box-shadow:0 0 0 7px rgba(255,255,255,0);} }
.stats { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:0 0 14px; }
.stat { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:12px 14px; box-shadow:var(--shadow); }
.stat .sk { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12.5px; } .stat .sk svg { width:18px; height:18px; stroke:var(--accent); fill:none; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.stat .sv { font-size:22px; font-weight:700; margin-top:4px; font-variant-numeric:tabular-nums; } .stat .sv.small2 { font-size:16px; line-height:1.3; }
.stat .sv.ok { color:var(--ok); } .stat .sv.bad { color:var(--bad); }

/* --- motyw czarno-pomaranczowy (zawsze ciemny) --- */
:root, :root:not([data-theme="light"]) {
  --bg:#0a0a0a; --card:#161310; --ink:#f4ede6; --muted:#a89d92; --line:#2b251f; --accent:#ff8a1f;
  --ok:#3ccf82; --warn:#f0b429; --bad:#ff5a4d; --t2:#ffd9a3; --curve:#ff8a1f; --chip:#211c17;
  --shadow:0 1px 2px rgba(0,0,0,.6), 0 8px 22px rgba(0,0,0,.45);
}
.top { background: linear-gradient(135deg,#0a0a0a 40%,#3a1c05); border-bottom:1px solid #2b1a0a; }
.top-sub { color:#c9a47a; } .toast { background:#2b1a0a; border:1px solid #ff8a1f; }
.hero-card { background: linear-gradient(145deg,#1d1814,#7a3a0c 90%); border:1px solid #3a2410; }
.hero-card.run { background: linear-gradient(145deg,#8a3a00,#ff9a2e); border-color:#ff9a2e; }
.hero-card.cwu { background: linear-gradient(145deg,#2a2018,#d9791c); border-color:#d9791c; }
.hero-card.alarm { background: linear-gradient(145deg,#4a0f0a,#d9382c); border-color:#d9382c; }
.hero-card::after { background:rgba(255,160,60,.12); }
.btn { color:#1a0f05; } .tabs { background:#100d0a; }
.tabs button.active { color:#ff8a1f; }
.seg button.on { background:color-mix(in srgb,var(--ok) 14%,#161310); }
.stat .sk svg { stroke:#ff8a1f; }
.chart .pt { fill:#161310; } .chart .t2dot { stroke:#161310; }
.chart text { fill:#a89d92; } .chart .lbl { fill:#f4ede6; } .chart .t2lbl { fill:#ffd9a3; }

.hero-card { background: linear-gradient(145deg,#141210,#2a1a0c 90%); border:1px solid #ff8a1f55; }
.hero-card.run { background: linear-gradient(145deg,#8a3a00,#ff9a2e); border-color:#ff9a2e; }
.hero-card.cwu { background: linear-gradient(145deg,#2a2018,#d9791c); border-color:#d9791c; }
.hero-card.alarm { background: linear-gradient(145deg,#4a0f0a,#d9382c); border-color:#d9382c; }

:root, :root:not([data-theme="light"]) { --t2:#22d3ee; }
.chart .t2lbl { fill:#22d3ee; }

.mode-ico { display:none; align-items:center; } .mode-ico svg { width:28px; height:28px; stroke:#fff; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* --- harmonogram CWU --- */
.seg.two { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
.toggle { display:flex; align-items:center; gap:10px; margin:0 0 10px; font-weight:600; }
.toggle input { width:22px; height:22px; accent-color: var(--accent); }
.legend { display:flex; align-items:center; gap:6px; color:var(--muted); font-size:13px; margin:0 0 8px; }
.lg { width:14px; height:14px; border-radius:4px; background:var(--chip); border:1px solid var(--line); display:inline-block; }
.lg.on { background:var(--accent); border-color:var(--accent); margin-left:0; }
.sgrid { display:flex; flex-direction:column; gap:3px; touch-action:none; user-select:none; -webkit-user-select:none; }
.srow { display:grid; grid-template-columns: 30px repeat(24, 1fr); gap:2px; align-items:center; }
.shead .shr { font-size:10px; color:var(--muted); text-align:left; height:12px; line-height:12px; overflow:visible; white-space:nowrap; }
.sday { font: inherit; font-size:12px; font-weight:700; color:var(--muted); background:none; border:0; text-align:left; padding:0; height:26px; }
.cell { height:26px; border-radius:4px; background:var(--chip); border:1px solid var(--line); }
.cell.on { background:var(--accent); border-color:var(--accent); }
.cell.now { outline:2px solid var(--t2); outline-offset:1px; }
.presets { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0 4px; }
.presets .btn { padding:8px 12px; font-size:14px; }
.btn.ghost { color: var(--ink); }
