:root {
  --blue: #0a6ebd; --blue-d: #08558f; --blue-l: #e7f2fb;
  --ink: #102233; --muted: #5d6f80; --line: #e2e9ef; --bg: #f2f6f9; --card: #fff;
  --ok: #13804a; --ok-bg: #e6f6ec; --bad: #b42318; --bad-bg: #fdeceb; --warn: #b45f00; --warn-bg: #fff4e5;
  --off: #5d6f80; --off-bg: #eceff3;
  --radius: 16px; --shadow: 0 1px 2px rgba(16,34,51,.06), 0 4px 16px rgba(16,34,51,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* culori care nu erau încă variabile — aceleași valori ca în tema inițială */
  --on-blue: #fff; --field: #fff; --bar: #fff; --sheet: #fff; --star: #c2ccd6; --switch-off: #cfd8e1;
  --notice-off: #3d4c5a; --pm-bg: #efe9ff; --pm: #5a3fc0; --scrim: rgba(16,34,51,.45);
  --toast-bg: #102233; --toast-fg: #fff;
  color-scheme: light;
}
/* Tema întunecată: aceeași identitate (albastrul Pool Master), deschis la culoare ca să se citească pe fundal închis */
:root[data-theme="dark"] {
  --blue: #4ea4e8; --blue-d: #a9d4f6; --blue-l: #16324a;
  --ink: #e6edf3; --muted: #95a6b6; --line: #253341; --bg: #0c141b; --card: #141f29;
  --ok: #4fc784; --ok-bg: #11301f; --bad: #f4887e; --bad-bg: #3a1814; --warn: #f2a54a; --warn-bg: #36260f;
  --off: #9dabb8; --off-bg: #1c2631;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --on-blue: #04223a; --field: #0f1922; --bar: #111b24; --sheet: #16212c; --star: #4a5966; --switch-off: #34434f;
  --notice-off: #c3ced8; --pm-bg: #2a2150; --pm: #c4b5ff; --scrim: rgba(0,0,0,.6);
  --toast-bg: #e6edf3; --toast-fg: #0c141b;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- layout */
.app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(84px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 18px 0 10px; }
.topbar h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }
.topbar .back { border: 0; background: none; font-size: 22px; padding: 4px 8px 4px 0; cursor: pointer; color: var(--blue); }
.sub { color: var(--muted); font-size: 14px; margin: -4px 0 14px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bar); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-b); z-index: 10; }
.tabbar a { flex: 1; max-width: 200px; text-align: center; padding: 9px 0 10px; text-decoration: none; color: var(--muted); font-size: 12px; }
.tabbar a .ic { display: block; font-size: 22px; line-height: 1.1; }
.tabbar a.active { color: var(--blue); font-weight: 600; }

/* ---------- cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.card h2 { font-size: 18px; margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 14px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.loc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.loc-head h2 { flex: 1; margin: 0; }
.link-btn { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 6px 0; font-weight: 600; }

/* ---------- status banner */
.status { display: flex; align-items: center; gap: 12px; border-radius: 14px; padding: 14px; font-weight: 600; font-size: 17px; }
.status .big { font-size: 26px; line-height: 1; }
.status small { display: block; font-weight: 400; font-size: 14px; opacity: .9; margin-top: 2px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.problem { background: var(--bad-bg); color: var(--bad); }
.status.offline { background: var(--off-bg); color: var(--off); }
.status.empty { background: var(--blue-l); color: var(--blue-d); }
.problem-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.problem-item:first-child { border-top: 0; }
.problem-item .txt { flex: 1; font-size: 15px; }
.problem-item .txt small { color: var(--muted); display: block; }

/* ---------- metrics */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.metric { background: var(--bg); border-radius: 14px; padding: 12px; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.metric .value small { font-size: 16px; font-weight: 600; }
.metric .note { color: var(--muted); font-size: 12px; }

/* ---------- equipment rows */
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .icon { width: 40px; height: 40px; border-radius: 12px; background: var(--blue-l); display: grid; place-items: center; font-size: 20px; flex: none; }
.row .main { flex: 1; min-width: 0; }
.row .main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .main small { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row .main .warn { color: var(--bad); font-weight: 600; }
.star { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 4px; color: var(--star); }
.star.on { color: #f2b01e; }

/* LED */
.led { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.led.green { background: #22b35a; animation: pulse 1.6s ease-in-out infinite; }
.led.gray { background: #b8c0c8; } .led.orange { background: #f08c00; } .led.red { background: #d93a3a; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(34,179,90,.5); } 50% { box-shadow: 0 0 0 5px rgba(34,179,90,0); } }

/* toggle */
.toggle { position: relative; width: 52px; height: 32px; flex: none; border: 0; border-radius: 16px; background: var(--switch-off); cursor: pointer; transition: background .2s; padding: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle.on { background: var(--blue); }
.toggle.on::after { transform: translateX(20px); }
.toggle:disabled { opacity: .45; cursor: default; }
.toggle.busy { opacity: .6; }

/* ---------- offline notice */
.notice { border-radius: 14px; padding: 12px 14px; font-size: 14px; margin: 10px 0; }
.notice.offline { background: var(--off-bg); color: var(--notice-off); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice b { display: block; margin-bottom: 2px; }

/* ---------- forms */
.auth { max-width: 420px; margin: 0 auto; padding: 32px 16px 40px; }
.brand { text-align: center; margin: 12px 0 22px; }
.brand .logo { width: 64px; height: 64px; border-radius: 18px; display: inline-block; }
.brand h1 { margin: 10px 0 2px; font-size: 26px; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--muted); }
label.field { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
label.field input, label.field select, label.field textarea, .input {
  display: block; width: 100%; margin-top: 6px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); font-size: 16px; color: var(--ink);
}
label.field textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-l); border-color: var(--blue); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); margin: 14px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 600; font-size: 16px; cursor: pointer; background: var(--blue); color: var(--on-blue); text-align: center; text-decoration: none; }
.btn:disabled { opacity: .6; }
.btn.secondary { background: var(--blue-l); color: var(--blue-d); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.small { display: inline-block; width: auto; padding: 9px 14px; font-size: 14px; }
.btn + .btn { margin-top: 10px; }
.btn-row { display: flex; gap: 10px; } .btn-row .btn { margin: 0; }
.center { text-align: center; } .muted { color: var(--muted); } .mt { margin-top: 16px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#googleBtn { display: flex; justify-content: center; min-height: 44px; }
.err { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.ok-msg { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.langs { display: flex; justify-content: center; gap: 6px; margin-top: 22px; }
.langs button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.langs button.on { background: var(--blue); color: var(--on-blue); border-color: var(--blue); }

/* ---------- lists */
.list-item { display: flex; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; }
.list-item:first-child { border-top: 0; }
.list-item .when { color: var(--muted); width: 92px; flex: none; font-size: 13px; }
.list-item .who { font-size: 12px; color: var(--muted); }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--blue-l); color: var(--blue-d); font-weight: 600; }
.pill.pm { background: var(--pm-bg); color: var(--pm); } .pill.prot { background: var(--bad-bg); color: var(--bad); }

/* ---------- modal & toast */
.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--sheet); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); max-height: 92vh; overflow: auto; }
.sheet h2 { margin: 0 0 6px; font-size: 20px; }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-fg); padding: 11px 16px; border-radius: 12px; font-size: 14px; z-index: 40; max-width: 90%; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--blue-l); border-top-color: var(--blue); border-radius: 50%; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- programe + temperatură */
.mt-s { margin-top: 8px; }
.block { display: block; margin-top: 12px; text-decoration: none; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 10px; }
.badge.forced { background: var(--warn-bg); color: var(--warn); }
.warn-text { color: var(--warn); font-weight: 600; }
.ok-text { color: var(--ok); }
.small-text { font-size: 13px; margin: -4px 0 8px; }
.heat { background: var(--bg); border-radius: 14px; padding: 12px; margin-top: 10px; }
.heat .label { color: var(--muted); font-size: 13px; }
.heat .note { color: var(--muted); font-size: 13px; margin-top: 8px; }
.heat .note.warn-text { color: var(--warn); }
.heat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.heat .auto { text-align: right; } .heat .auto .toggle { margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.stepper b { font-size: 24px; min-width: 88px; text-align: center; letter-spacing: -.02em; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--blue-l); color: var(--blue-d); font-size: 22px; font-weight: 700; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 7px 12px; min-width: 44px; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--blue); color: var(--on-blue); border-color: var(--blue); }
.chips.small .chip { font-size: 12px; padding: 4px 10px; color: var(--blue); }
.as-link { border: 0; background: none; text-align: left; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.row.sched .main small { margin-top: 2px; }
.row.sched.disabled .main { opacity: .55; }
.notice { background: var(--blue-l); color: var(--blue-d); }

/* ---------- mod de sezon */
.season-row { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.notice.season { margin-top: 12px; }
.notice.season.vacation { background: var(--blue-l); color: var(--blue-d); }
.notice.season.winter { background: var(--off-bg); color: var(--notice-off); }
.notice.season.reopening { background: var(--ok-bg); color: var(--ok); }
.option { display: block; width: 100%; text-align: left; border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; padding: 12px 14px; margin: 8px 0; cursor: pointer; font: inherit; }
.option b { display: block; font-size: 16px; }
.option small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.option.on { border-color: var(--blue); background: var(--blue-l); }
