[hidden] { display: none !important; }
:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7684;
  --line: #e2e6ec;
  --brand: #1f3a5f;
  --brand-2: #2f6fb0;
  --ok: #2e9d62;
  --warn: #d98a1c;
  --bad: #c8463d;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161d; --card: #1a212b; --ink: #e8edf3; --muted: #93a0b0; --line: #2a3340; --brand: #0f2238; --brand-2: #5a9ad8; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #fff; }
.topbar h1 { font-size: 1.1rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 1.8rem; line-height: 1; padding: 0 6px; cursor: pointer; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #8a96a5; }
.conn.on { background: #4cd38a; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }
h2 { font-size: 1rem; margin: 22px 4px 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h2:first-child { margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }

.device { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; border-top: 1px solid var(--line); }
.device:first-of-type { border-top: 0; }
.device .ico { font-size: 1.6rem; width: 36px; text-align: center; }
.device .info { flex: 1; min-width: 0; }
.device .name { font-weight: 600; }
.device .meta { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 1.4rem; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa5b3; margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--line); }
.badge.locked { background: #fde7e5; color: var(--bad); }
.badge.pending { background: #fff1db; color: #a26206; }
@media (prefers-color-scheme: dark) { .badge.locked { background: #3d1f1d; } .badge.pending { background: #3a2c14; color: #f2b45a; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

.big-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big-toggle .label { font-weight: 700; font-size: 1.05rem; }

.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c3cad3; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--bad); }
.switch.green input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(22px); }

label.field { display: block; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
input.code { font-size: 1.6rem; letter-spacing: .2em; text-align: center; text-transform: uppercase; font-family: ui-monospace, monospace; }

.app { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.app:first-child { border-top: 0; }
.app .info { flex: 1; min-width: 0; }
.app .pkg { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.request { border-left: 4px solid var(--warn); }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tab { flex: 1; background: none; border: 0; padding: 8px 0 10px; font-size: .72rem; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: 1.2rem; }
.tab.active { color: var(--brand-2); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222b36; color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

.tabs-inline { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs-inline button { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.tabs-inline button.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }

video.scan { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 1; object-fit: cover; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.log-item { padding: 8px 0; border-top: 1px solid var(--line); }
.log-item:first-child { border-top: 0; }

/* ---------- Etapp 2 ---------- */
.today { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.today .big { font-size: 1.35rem; font-weight: 700; }
.today .left { font-size: .9rem; color: var(--muted); }
.bonus-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.bonus-btns .btn { padding: 7px 10px; font-size: .85rem; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.meter > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.meter.warn > i { background: var(--warn); }
.meter.over > i { background: var(--bad); }
table.week { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.week th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 2px; font-size: .78rem; }
table.week td { padding: 5px 2px; border-top: 1px solid var(--line); vertical-align: middle; }
table.week input[type=time], table.week input[type=number] { width: 100%; padding: 6px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: .85rem; }
table.week .day { font-weight: 700; width: 40px; }
.bars { display: flex; gap: 6px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bars .area { flex: 1; width: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; }
.bars .bar { width: 100%; max-width: 34px; background: var(--brand-2); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .bar.over { background: var(--bad); }
.bars .lim { position: absolute; left: 8%; right: 8%; border-top: 2px dashed var(--warn); }
.bars .lbl { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.bars .val { font-size: .68rem; color: var(--muted); }
.app-bar { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.app-bar .name { width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.app-bar .track { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.app-bar .track i { display: block; height: 100%; background: var(--brand-2); }
.app-bar .min { width: 64px; text-align: right; font-size: .82rem; color: var(--muted); }
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px; font-size: .85rem; cursor: pointer; background: var(--card); }
.chip.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }

.dayrow { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.dayrow:first-child { border-top: 0; padding-top: 0; }
.dayrow .dname { font-weight: 700; width: 36px; padding-top: 8px; }
.dayrow .dgrid { flex: 1; display: grid; grid-template-columns: 88px 1fr; gap: 6px 8px; align-items: center; }
.dayrow .dgrid > span { font-size: .8rem; color: var(--muted); }
.dayrow .pair { display: flex; align-items: center; gap: 6px; }
.dayrow .pair b { font-weight: 400; color: var(--muted); font-size: .85rem; }
.dayrow input { flex: 1; min-width: 0; padding: 7px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: .9rem; }
.bars .val { white-space: nowrap; height: 16px; }
.dayrow .dgrid { grid-template-columns: 74px minmax(0, 1fr); }
.dayrow .dgrid > *, .dayrow .pair { min-width: 0; }
.dayrow input { width: 0; flex: 1 1 0; font-size: .85rem; padding: 7px 4px; }
.dayrow input[type=time]::-webkit-calendar-picker-indicator { margin-left: 0; padding: 0; }
