:root {
  --bg: #0b1220; --card: #141d2f; --line: #22304a; --text: #e8eef8; --muted: #8a9bb8;
  --green: #22c55e; --red: #ef4444; --amber: #f59e0b; --blue: #60a5fa;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); min-height: 1.4em; }

.screen { min-height: 100vh; }
.login-box { max-width: 340px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 15vh) 20px 20px; text-align: center; }
.logo { font-size: 56px; }
.login-box h1 { margin: 8px 0 4px; }
.login-box form { display: grid; gap: 12px; margin-top: 20px; }
input, button { font: inherit; border-radius: 12px; border: 1px solid var(--line); padding: 14px; }
input { background: var(--card); color: var(--text); }
button { background: var(--blue); color: #06101f; font-weight: 600; border: 0; cursor: pointer; }

header { position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; background: rgba(11,18,32,.92); backdrop-filter: blur(8px); }
header h1 { font-size: 20px; margin: 0; }
main { padding: 4px 16px calc(env(safe-area-inset-bottom) + 90px); max-width: 640px; margin: 0 auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 12px 0; }
.label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.big { font-size: 30px; font-weight: 700; }

.hero { display: flex; align-items: center; gap: 16px; padding: 18px; }
.hero-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: var(--line); flex: none; }
.hero-title { font-size: 22px; font-weight: 700; }
.hero.on { border-color: rgba(34,197,94,.5); background: linear-gradient(135deg, rgba(34,197,94,.18), var(--card) 60%); }
.hero.on .hero-icon { background: rgba(34,197,94,.25); }
.hero.off { border-color: rgba(239,68,68,.55); background: linear-gradient(135deg, rgba(239,68,68,.22), var(--card) 60%); }
.hero.off .hero-icon { background: rgba(239,68,68,.3); }
.banner { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.5); color: #fcd34d; border-radius: 12px; padding: 10px 14px; font-size: 14px; }

.bar { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.bar div { height: 100%; width: 0; background: var(--green); border-radius: 6px; transition: width .6s; }
.bar div.mid { background: var(--amber); } .bar div.low { background: var(--red); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin: 0; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.val { font-size: 22px; font-weight: 650; }

.stats { display: grid; gap: 8px; margin-top: 8px; font-size: 15px; }
.stats b { font-weight: 650; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .dur { font-weight: 650; white-space: nowrap; }
.list .now { color: var(--red); }

.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-top: 12px; }
.seg button { flex: 1; background: transparent; color: var(--muted); padding: 8px; border-radius: 9px; }
.seg button.on { background: var(--line); color: var(--text); }
.seg.ctl { margin: 10px 0 8px; }
.seg.ctl button { color: var(--text); font-weight: 600; }
.seg.ctl button.on { background: var(--blue); color: #06101f; }
.seg.ctl button:disabled { opacity: .5; }
#prio-msg.ok { color: var(--green); } #prio-msg.err { color: var(--red); }

.chips { flex-wrap: wrap; gap: 4px; }
.chips button { flex: 1 0 28%; padding: 8px 4px; font-size: 14px; }
.chips button small { display: block; font-weight: 400; opacity: .7; font-size: 11px; }
#charge-msg.ok { color: var(--green); } #charge-msg.err { color: var(--red); }
button.link { background: none; color: var(--blue); padding: 0; font-weight: 500; font-size: 14px; }

.day { margin-top: 10px; }
.day .t { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.day .t span:last-child { text-align: right; color: var(--text); }
.tl { position: relative; height: 18px; border-radius: 6px; background: rgba(34,197,94,.25); overflow: hidden; margin-top: 4px; }
.tl.na { background: var(--line); }
.tl .off { position: absolute; top: 0; bottom: 0; background: rgba(239,68,68,.75); }
.tl .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; }
.ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 1px; }
.badge.em { background: rgba(239,68,68,.25); color: #fca5a5; }
.badge.sc { background: rgba(96,165,250,.2); color: #93c5fd; }
.warn { color: #fca5a5; }

.pick { display: grid; gap: 4px; margin-top: 12px; }
.pick input { padding: 10px 12px; }
.pick input:disabled { opacity: .5; }
.opts { list-style: none; margin: 0 0 6px; padding: 0; max-height: 180px; overflow-y: auto; }
.opts li { padding: 9px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.opts li:hover { background: var(--line); }
select { font: inherit; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }

.kv { list-style: none; margin: 8px 0 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.kv li:first-child { border-top: 0; }
.kv li span:last-child { text-align: right; font-weight: 600; }
.kv li.w span:last-child { color: var(--blue); }
.raw summary { cursor: pointer; }
.raw table { width: 100%; border-collapse: collapse; font: 13px ui-monospace, Menlo, monospace; margin-top: 8px; }
.raw td, .raw th { padding: 3px 6px; border-top: 1px solid var(--line); text-align: right; }
.raw th { color: var(--muted); font-weight: 500; }
.raw .blk { color: var(--muted); margin-top: 12px; font-size: 13px; }
.raw-wrap { overflow-x: auto; }

canvas { width: 100%; display: block; margin-top: 8px; }
.legend { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.sw.off { background: rgba(239,68,68,.35); }

nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: rgba(20,29,47,.96);
  border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
nav button { flex: 1; max-width: 200px; background: transparent; color: var(--muted); font-weight: 500;
  font-size: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav button span { font-size: 20px; }
nav button.on { color: var(--text); }
