:root {
  --bg: #0b0f14; --surface: #141a22; --surface-2: #1b232e; --line: #26303d; --ink: #e8edf3; --mute: #8d99a8;
  --accent: #1aa3ff; --accent-ink: #03141f; --ok: #2fbf71; --bad: #ff5a4f; --unk: #f0b429; --hold: #ff8a3d;
  --radius: 16px; --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --hero-clear: linear-gradient(135deg, #1f8f55, #156b40); --hero-clear-ink: #fff; --hero-clear-line: transparent;
  --hero-bad: linear-gradient(135deg, #d8453c, #a52a22); --hero-bad-ink: #fff; --hero-bad-line: transparent;
  --hero-unk: linear-gradient(135deg, #b98a10, #8a6406); --hero-unk-ink: #fff; --hero-unk-line: transparent;
  --scrim: rgba(0, 0, 0, .5); --toast-bg: var(--ink); --toast-ink: var(--bg); --toast-line: transparent; --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f5f7fa; --surface: #ffffff; --surface-2: #eef2f6; --line: #dde3ea; --ink: #121821; --mute: #5d6b7c; --accent: #0a84d6; --accent-ink: #fff; color-scheme: light;
    --ok: #138a4f; --bad: #d92d20; --unk: #b7791f; --hold: #c4580e;
    --hero-clear: #e7f6ee; --hero-clear-ink: #0f5c36; --hero-clear-line: #a9dcbf;
    --hero-bad: #fdecea; --hero-bad-ink: #a2231a; --hero-bad-line: #f3b7b1;
    --hero-unk: #fff4d6; --hero-unk-ink: #7a5200; --hero-unk-line: #f0d58a;
    --scrim: rgba(16, 24, 40, .32); --toast-bg: #ffffff; --toast-ink: #121821; --toast-line: #dde3ea; --shadow: 0 8px 24px rgba(16, 24, 40, .14); }
}
:root[data-theme="light"] { --bg: #f5f7fa; --surface: #ffffff; --surface-2: #eef2f6; --line: #dde3ea; --ink: #121821; --mute: #5d6b7c; --accent: #0a84d6; --accent-ink: #fff; color-scheme: light;
    --ok: #138a4f; --bad: #d92d20; --unk: #b7791f; --hold: #c4580e;
    --hero-clear: #e7f6ee; --hero-clear-ink: #0f5c36; --hero-clear-line: #a9dcbf;
    --hero-bad: #fdecea; --hero-bad-ink: #a2231a; --hero-bad-line: #f3b7b1;
    --hero-unk: #fff4d6; --hero-unk-ink: #7a5200; --hero-unk-line: #f0d58a;
    --scrim: rgba(16, 24, 40, .32); --toast-bg: #ffffff; --toast-ink: #121821; --toast-line: #dde3ea; --shadow: 0 8px 24px rgba(16, 24, 40, .14); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
#root { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h2 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 17px; margin: 0 0 4px; }
p { margin: 0 0 10px; }
.mute { color: var(--mute); }
.small { font-size: 13px; }

/* app bar + tab bar */
.appbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.appbar h1 { font-size: 19px; margin: 0; flex: 1; }
.appbar-right { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--mute); }
#view { flex: 1; padding: 8px 16px calc(96px + var(--safe-b)); outline: none; }
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(560px, 100%); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 6; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; color: var(--mute); text-decoration: none; font-size: 11.5px; }
.tabbar a .ti { font-size: 21px; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* controls */
button, .btn { font: inherit; min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.block, .btn.block { width: 100%; }
.icon-btn { min-height: 40px; min-width: 40px; padding: 0; font-size: 28px; background: transparent; border: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns > * { flex: 1; }
input[type=text], input[type=password], textarea, select { font: inherit; width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
textarea { min-height: 76px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mute); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.tight { padding: 12px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 60px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; border-radius: 0; color: inherit; }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; display: block; }
.item .s { display: block; font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; }
.item .chev { color: var(--mute); font-size: 22px; }
.badge { font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge.sim { color: #b88400; border-color: #b8840066; background: #f0b42914; }
:root[data-theme="light"] .badge.sim { color: #7a5200; border-color: #f0d58a; background: #fff4d6; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .badge.sim { color: #7a5200; border-color: #f0d58a; background: #fff4d6; } }
.badge.ok { color: var(--ok); border-color: #2fbf7155; }
.badge.live { color: var(--accent); border-color: #1aa3ff55; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mute); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #2fbf7133; }

/* status */
.status-hero { border-radius: var(--radius); padding: 18px; color: #fff; margin-bottom: 14px; position: relative; overflow: hidden; }
.status-hero.CLEAR { background: var(--hero-clear); color: var(--hero-clear-ink); border: 1px solid var(--hero-clear-line); }
.status-hero.NOT_CLEAR { background: var(--hero-bad); color: var(--hero-bad-ink); border: 1px solid var(--hero-bad-line); }
.status-hero.UNKNOWN { background: var(--hero-unk); color: var(--hero-unk-ink); border: 1px solid var(--hero-unk-line); }
.status-hero.IDLE { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.status-hero .k { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: .6px; }
.status-hero .v { font-size: 32px; font-weight: 800; letter-spacing: .5px; margin: 2px 0; }
.status-hero .r { opacity: .92; }
.status-hero .eta { position: absolute; right: 16px; top: 16px; text-align: right; }
.status-hero .eta b { font-size: 26px; display: block; font-variant-numeric: tabular-nums; }
.alexa { display: flex; gap: 10px; background: var(--surface-2); border-radius: 12px; padding: 12px; margin-top: 12px; color: var(--ink); }
.alexa .ring { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex: none; box-shadow: 0 0 10px var(--accent); }
.ask { margin-top: 12px; }

/* camera */
.cam { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 16/9; touch-action: none; }
.cam canvas, .cam video { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam video { opacity: 0; pointer-events: none; }
.cam .tag { position: absolute; left: 8px; top: 8px; font-size: 12px; background: rgba(0,0,0,.6); color: #fff; padding: 3px 8px; border-radius: 8px; }
.cam-actions { display: flex; gap: 8px; margin-top: 10px; }
.cam-actions > * { flex: 1; }

/* onboarding */
.onb { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; padding-top: calc(20px + var(--safe-t)); }
.onb .grow { flex: 1; }
.progress { display: flex; gap: 6px; margin-bottom: 22px; }
.progress span { height: 4px; flex: 1; border-radius: 4px; background: var(--line); }
.progress span.on { background: var(--accent); }
.hero-icon { width: 92px; height: 92px; border-radius: 24px; margin: 10px 0 18px; }
.value { display: flex; gap: 12px; align-items: flex-start; margin: 12px 0; }
.value .i { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; flex: none; }
.option { text-align: left; display: flex; gap: 12px; align-items: flex-start; padding: 16px; min-height: 76px; width: 100%; border-radius: var(--radius); background: var(--surface); }
.option .i { font-size: 24px; }
.option b { display: block; }
.option .mute { display: block; }
.option.recommended { border-color: var(--accent); }

/* toggles */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* zone mini preview */
.thumb { width: 72px; height: 41px; border-radius: 8px; background: #000; flex: none; object-fit: cover; }
.empty { text-align: center; padding: 28px 16px; }
.empty .big { font-size: 40px; }

/* sheet + toast */
.sheet { position: fixed; inset: 0; background: var(--scrim); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: min(560px, 100%); max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 14px; }
.toast { position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-ink); border: 1px solid var(--toast-line); box-shadow: var(--shadow); padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 14px; max-width: 90vw; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 10px; }
ul.plain { padding-left: 18px; margin: 6px 0 10px; }
ul.plain li { margin: 4px 0; }
.sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--mute); margin: 18px 4px 8px; }
.audit-line { font-size: 14px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); margin-top: 8px; }
.audit-line.warn, .audit-line.error { border-left: 3px solid var(--unk); }
.audit-line.ok { border-left: 3px solid var(--ok); }
@media (prefers-reduced-motion: no-preference) { .sheet-card { animation: up .18s ease-out; } @keyframes up { from { transform: translateY(30px); opacity: .6; } } }

.pcards{display:grid;gap:12px}.pcard{margin:0}.phead{display:flex;align-items:center;gap:10px;margin-bottom:4px}.phead .pname{flex:0 1 auto;min-width:0}.pbtn{margin-left:auto;flex:none;min-height:32px;width:auto;padding:6px 14px;font-size:13px;border-radius:999px;line-height:1.2}.phead .badge+.pbtn{margin-left:8px}.phead .badge{margin-left:auto}.plogo{width:32px;height:32px;border-radius:8px;object-fit:contain;background:#fff}.pcard p{margin:0 0 0 42px}
