/* GasGuard owner app — mobile first; on wide screens the tab bar becomes a sidebar.
   Theme "instrument panel": a dark device body, readings on an LCD strip in a monospace face, levels shown as
   LEDs. Colour is reserved for meaning: LCD green = interactive, green/yellow/orange/red = gas level. */
:root {
  --bg: #101316;
  --surface: #1A1E23;
  --surface-soft: #22272D;
  --ink: #E6E8E3;
  --muted: #98A19A;
  --line: #2A3037;
  --line-strong: #3A4149;
  --brand: #C7D3B4;
  --brand-dark: #A9B996;
  --brand-soft: #23302A;
  --lcd: #C7D3B4; --lcd-ink: #1E2A17; --lcd-muted: #4A5A3C; --bezel: #2A2F35;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --safe: #59D26B; --safe-ink: #7BE08A; --safe-bg: #16301F; --safe-line: #24502F;
  --watch: #E8B23A; --watch-ink: #F2C55C; --watch-bg: #33290F; --watch-line: #5A4718;
  --warning: #F07B2D; --warning-ink: #F7A066; --warning-bg: #3A2210; --warning-line: #6A3A18;
  --danger: #F0483E; --danger-ink: #FF8A80; --danger-bg: #3A1414; --danger-line: #6E2222;
  --unknown: #8A94A6; --unknown-ink: #A9B0B7; --unknown-bg: #22272D; --unknown-line: #333A42;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---- Buttons, fields, cards ---- */
.btn, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover, .button:hover { background: var(--surface-soft); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--lcd-ink); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger-ink); }
a.btn-danger[href^="tel:"] { background: #C2412D; border-color: #C2412D; color: #fff; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.button.is-active, .fp-edit-toggle.is-active { border-color: var(--brand); color: var(--brand); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { font-size: 16px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.field input, .field select { min-height: 46px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.form-error { margin: 0; min-height: 20px; color: var(--danger-ink); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); box-shadow: 0 0 6px currentColor; }
.pill.is-online i { box-shadow: 0 0 6px var(--safe); }
.pill.is-online i { background: var(--safe); }
.pill.is-offline i { background: var(--danger); }
.pill.is-demo i { background: var(--brand); }
.tag { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.is-ok { background: var(--safe-bg); color: var(--safe-ink); }
.tag.is-no { background: var(--danger-bg); color: var(--danger-ink); }
.tag.is-info { background: var(--brand-soft); color: var(--brand-dark); }
.tag.is-off { background: var(--unknown-bg); color: var(--unknown-ink); }
.sg-segment, .segment { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--line); }
.sg-segment button, .segment button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.sg-segment button.is-active, .segment button.is-active { background: var(--lcd); color: var(--lcd-ink); }

/* ---- Landing / sign in ---- */
.landing { min-height: 100vh; padding: 20px 18px 40px; max-width: 1080px; margin: 0 auto; }
.landing-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--lcd); border: 2px solid var(--bezel); }
.brand-mark svg { width: 19px; height: 19px; fill: none; stroke: var(--lcd-ink); stroke-width: 2.4; stroke-linejoin: round; }
.landing-body { display: grid; gap: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-weight: 600; font-size: 14px; }
.landing h1 { font-size: clamp(34px, 7vw, 54px); font-weight: 700; letter-spacing: -.01em; }
.landing-points { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 14px; }
.landing-points li { display: grid; gap: 2px; padding-left: 18px; border-left: 3px solid var(--line-strong); }
.landing-points strong { font-size: 16px; }
.landing-points span { color: var(--muted); font-size: 14px; }
.landing-device { display: grid; gap: 10px; max-width: 440px; margin-top: 28px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.landing-leds { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.landing-leds span { flex: 1 1 auto; }
.landing-leds i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.landing-leds i.is-safe { background: var(--safe); box-shadow: 0 0 8px var(--safe); }
.login { display: grid; gap: 14px; align-self: start; padding: 24px; }
.login h2 { font-size: 22px; }
@media (min-width: 860px) {
  .landing { padding: 28px 40px 60px; }
  .landing-body { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 56px; align-items: start; padding-top: 32px; }
}

/* ---- App shell ---- */
.app { min-height: 100vh; }
.app-main { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 21px; font-weight: 700; }
.view { display: grid; gap: 14px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 6px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar-brand { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 500; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--lcd); font-weight: 600; }
@media (min-width: 900px) {
  .tabbar { top: 0; right: auto; width: 228px; display: flex; flex-direction: column; gap: 4px; padding: 22px 14px; border-top: 0; border-right: 1px solid var(--line); }
  .tabbar-brand { display: flex; padding: 0 8px 18px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 44px; padding: 0 12px; font-size: 15px; }
  .tab.is-active { background: var(--brand-soft); }
  .app-main { margin-left: 228px; margin-right: 0; max-width: none; padding: 26px 32px 48px; }
  .app-main > * { max-width: 980px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
}
.demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); font-size: 14px; }

/* ---- Status hero ---- */
.hero { --lv: var(--unknown); --lv-ink: var(--unknown-ink); --lv-bg: var(--unknown-bg); --lv-line: var(--unknown-line); display: grid; gap: 14px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--lv); }
.hero.is-safe { --lv: var(--safe); --lv-ink: var(--safe-ink); --lv-bg: var(--safe-bg); --lv-line: var(--safe-line); }
.hero.is-watch { --lv: var(--watch); --lv-ink: var(--watch-ink); --lv-bg: var(--watch-bg); --lv-line: var(--watch-line); }
.hero.is-warning { --lv: var(--warning); --lv-ink: var(--warning-ink); --lv-bg: var(--warning-bg); --lv-line: var(--warning-line); }
.hero.is-danger { --lv: var(--danger); --lv-ink: var(--danger-ink); --lv-bg: var(--danger-bg); --lv-line: var(--danger-line); }
.why.is-watch { --lv-ink: var(--watch-ink); --lv-bg: var(--watch-bg); --lv-line: var(--watch-line); }
.why.is-warning { --lv-ink: var(--warning-ink); --lv-bg: var(--warning-bg); --lv-line: var(--warning-line); }
.why.is-danger { --lv-ink: var(--danger-ink); --lv-bg: var(--danger-bg); --lv-line: var(--danger-line); }
.why { border-color: var(--lv-line); display: grid; gap: 8px; }
.why-tag { background: var(--lv-bg); color: var(--lv-ink); }
.why-text { margin: 0; font-size: 15px; line-height: 1.65; }
.incident-facts { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.incident-facts div { padding: 8px 10px; border-radius: 10px; background: var(--lv-bg); }
.incident-facts dt { font-size: 12px; color: var(--muted); }
.incident-facts dd { margin: 2px 0 0; font-weight: 600; color: var(--lv-ink); }
.incident-facts small { display: block; font-weight: 400; color: var(--muted); }
.incident-todo { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.report-card .actions .btn { min-height: 40px; }
.ask { display: grid; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover, .chip.is-on { border-color: var(--brand); background: var(--brand-soft); }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: inherit; font: inherit; }
.ask-answer { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.ask-q { margin: 0; font-weight: 600; }
.ask-rule { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
@media (max-width: 520px) { .incident-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hero-top { display: flex; align-items: center; gap: 14px; }
.hero-badge { display: grid; place-items: center; flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; background: var(--lv); color: #0E1114; box-shadow: 0 0 0 5px var(--lv-bg), 0 0 18px var(--lv); }
.hero-badge svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hero.is-warning .hero-badge, .hero.is-danger .hero-badge { animation: beat 1.1s ease-in-out infinite; }
.hero-kicker { margin: 0; font-size: 13px; font-weight: 600; color: var(--lv-ink); }
.hero h2 { font-size: 31px; font-weight: 700; color: var(--lv-ink); }
.hero-head { margin: 0; font-size: 17px; font-weight: 600; }
/* Readings sit on an LCD strip framed by a bezel, like the screen of a hand-held gas detector. */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 4px; border-radius: 10px; background: var(--lcd); border: 3px solid var(--bezel); color: var(--lcd-ink); }
.stat { padding: 8px 10px; border-left: 1px dashed rgba(30, 42, 23, .25); }
.stat:first-child { border-left: 0; }
.stat span { display: block; font-family: var(--mono); font-size: 11px; color: var(--lcd-muted); }
.stat strong { display: block; font-family: var(--mono); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat small { display: block; font-family: var(--mono); font-size: 11px; color: var(--lcd-muted); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 10px; font-size: 14.5px; }
.steps li::before { content: counter(s); display: grid; place-items: center; flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; background: var(--lv); color: #0E1114; font-family: var(--mono); font-size: 12px; font-weight: 700; }
.hero-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@keyframes beat { 50% { box-shadow: 0 0 0 9px var(--lv-bg), 0 0 30px var(--lv); } }

/* ---- Lists ---- */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.checks li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.checks li > span { display: grid; place-items: center; flex: 0 0 auto; width: 21px; height: 21px; border-radius: 50%; font-size: 12px; font-weight: 700; }
.checks .is-ok > span { background: var(--safe-bg); color: var(--safe-ink); }
.checks .is-no > span { background: var(--danger-bg); color: var(--danger-ink); }
.list { padding: 4px 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-main strong { display: block; font-size: 14px; font-weight: 600; }
.row-main small { display: block; font-size: 12px; color: var(--muted); }
.row-main small.is-bad { color: var(--danger-ink); }
.row-side { text-align: right; flex: 0 0 auto; }
.row-side strong { display: block; font-family: var(--mono); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.row-side small { display: block; font-size: 12px; color: var(--muted); }
.dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.badge { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 13px; font-weight: 700; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.plan-card { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.plan-thumb { position: relative; flex: 0 0 auto; width: 120px; aspect-ratio: 1000 / 700; border-radius: 8px; overflow: hidden; border: 3px solid var(--bezel); background: #FBFAF7; }
.plan-thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.actions .btn { min-height: 52px; border-radius: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 6px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; }
.legend b { color: var(--ink); font-weight: 600; }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); }
.chart { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.empty { padding: 18px 0; text-align: center; color: var(--muted); font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 999px; background: var(--lcd); color: var(--lcd-ink); font-size: 14px; max-width: calc(100vw - 32px); }

/* ---- Full-screen alarm ---- */
.alarm { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; gap: 18px; padding: 28px 22px calc(26px + env(safe-area-inset-bottom)); background: #B3261E; color: #fff; overflow-y: auto; animation: flash 1.2s steps(2, jump-none) infinite; }
.alarm.is-warning { background: #C25700; }
.alarm-inner { width: min(460px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; min-height: 100%; }
.alarm-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; }
.alarm-meta span:first-child { padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, .18); }
.alarm-icon { align-self: center; display: grid; place-items: center; width: 92px; height: 92px; margin: 10px 0 14px; border-radius: 50%; background: #fff; color: #B3261E; box-shadow: 0 0 0 14px rgba(255, 255, 255, .16), 0 0 0 28px rgba(255, 255, 255, .08); }
.alarm.is-warning .alarm-icon { color: #C25700; }
.alarm-icon svg { width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.alarm h2 { text-align: center; font-size: 34px; }
.alarm-head { margin: 0; text-align: center; font-size: 20px; font-weight: 600; }
.alarm-sub { margin: 0; text-align: center; font-size: 14px; opacity: .92; }
.alarm-why { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, .22); font-size: 14px; line-height: 1.55; }
.alarm .steps { padding: 16px 18px; border-radius: 18px; background: rgba(255, 255, 255, .12); }
.alarm .steps li { font-size: 16px; }
.alarm .steps li::before { background: #fff; color: #B3261E; width: 26px; height: 26px; }
.alarm-buttons { margin-top: auto; display: grid; gap: 10px; }
.alarm-buttons a, .alarm-buttons button { min-height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 16px; font-size: 17px; font-weight: 700; cursor: pointer; }
.alarm-call { background: #fff; color: #B3261E; }
.alarm-ack { background: transparent; color: #fff; border: 2px solid rgba(255, 255, 255, .75); }
.alarm-test { align-self: center; padding: 4px 12px; border-radius: 999px; background: #fff; color: #B3261E; font-size: 13px; font-weight: 700; }
@keyframes flash { 50% { filter: brightness(1.12); } }

/* ---- Floor plan (js/floor-plan.js) ---- */
.fp-toolbar, .fp-editbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.fp-toolbar { justify-content: space-between; }
.fp-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fp-field select { min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
.fp-view button { min-height: 32px; padding: 0 12px; font-size: 13px; }
.fp-editbar { padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-soft); }
.fp-editbar-label { font-size: 13px; color: var(--muted); }
.fp-editbar-spacer { flex: 1 1 auto; }
.fp-tool { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 13px; cursor: pointer; }
.fp-tool svg { width: 16px; height: 16px; }
.fp-tool[data-fp-tool="stove"] svg { color: #F05A1A; }
.fp-tool[data-fp-tool="tank"] svg { color: #2F6FD0; }
.fp-tool.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.fp-tool-dot { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--safe); color: #fff; font-size: 10px; font-style: normal; font-weight: 700; }
.fp-link { border: 0; background: none; color: var(--brand); font-size: 13px; cursor: pointer; padding: 4px 2px; }
.fp-link.is-danger { color: var(--danger-ink); }
.fp-hint { margin: 0 0 10px; font-size: 13px; color: var(--brand-dark); }
.fp-stage { position: relative; aspect-ratio: 1000 / 700; overflow: hidden; border: 4px solid var(--bezel); border-radius: 12px; background: #FBFAF7; touch-action: manipulation; user-select: none; }
.fp-stage.is-editing { outline: 2px dashed #8FAEFF; outline-offset: 3px; }
.fp-stage.is-placing { cursor: crosshair; }
.fp-stage.is-3d { background: radial-gradient(ellipse at 50% 42%, #2C333B, #14171B 78%); }
.fp-stage.is-3d .fp-iso-note { fill: #6F7A86; }

/* Zoom and pan (js/floor-plan.js): the plan grows, pins and labels keep their size. */
.fp-zoom { position: absolute; inset: 0; transform-origin: 0 0; }
.fp-zoom .fp-pin, .fp-zoom .fp-room, .fp-zoom .fp-door-tag { scale: var(--inv, 1); }
.fp-stage { touch-action: pan-y; }
.fp-stage.is-zoomed { touch-action: none; cursor: grab; }
.fp-stage.is-editing, .fp-stage.is-editing .fp-pin { touch-action: none; } /* a finger on a pin drags it instead of scrolling the page */
.fp-zoom-ctl { position: absolute; right: 8px; bottom: 8px; z-index: 3; display: grid; gap: 6px; }
.fp-zoom-ctl button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(20, 23, 27, .78); color: #fff; font-size: 18px; font-weight: 600; line-height: 1; cursor: pointer; }
.fp-zoom-ctl button:active { transform: scale(.92); }
.fp-zoom-hint { display: none; margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* 3D labels are HTML chips anchored to the top of each sensor's dashed stem. */
.fp-iso-chip { position: absolute; transform: translate(-50%, -100%); transform-origin: 50% 100%; scale: var(--inv, 1); display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; border: 2px solid var(--pin); background: #fff; color: #1F2937; font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); font-variant-numeric: tabular-nums; pointer-events: none; }
.fp-iso-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--pin); box-shadow: 0 0 6px var(--pin); }
.fp-iso-chip b { font-weight: 700; }
.fp-iso-chip.is-danger { animation: blink .8s steps(2, jump-none) infinite; }
.fp-stage.is-3d .fp-room { background: rgba(20, 23, 27, .72); color: #E6E8E3; }

/* Sensors breathe on the plan (delay synced to the clock so refreshes don't restart it). */
.fp-pin-sensor .fp-pin-dot { animation: sensor-breathe 2.4s ease-in-out var(--t, 0s) infinite; }
@keyframes sensor-breathe { 50% { box-shadow: 0 3px 8px rgba(20, 32, 51, .3), 0 0 0 7px color-mix(in srgb, var(--pin) 28%, transparent); } }

@media (max-width: 600px) {
  #view-plan > .card:first-child { padding: 12px 10px; }
  .fp-toolbar { gap: 8px; }
  .fp-toolbar .fp-field { flex: 1 1 100%; }
  .fp-toolbar .fp-field > span { display: none; }
  .fp-toolbar .fp-field select { flex: 1 1 auto; width: 100%; }
  .fp-toolbar .fp-view { flex: 1 1 auto; }
  .fp-edit-toggle { min-height: 36px; padding: 0 12px; font-size: 13px; }
  .fp-stage { border-width: 3px; border-radius: 10px; }
  .fp-zoom-hint { display: block; }
  .fp-iso-chip { font-size: 11px; padding: 3px 8px 3px 6px; }
}
.fp-svg-host, .fp-svg-host svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fp-svg-note { font-size: 13px; fill: #8A93A3; font-family: inherit; }
.fp-idw { mix-blend-mode: multiply; }
.fp-pulse { transform-box: fill-box; transform-origin: center; animation: fp-ring 2.2s ease-out infinite; }
.fp-pulse.is-danger { animation-duration: 1.1s; }
.fp-overlay { position: absolute; inset: 0; pointer-events: none; }
.fp-iso-label { font-size: 17px; font-weight: 700; fill: #4F5868; paint-order: stroke; stroke: #fff; stroke-width: 5px; stroke-linejoin: round; font-family: inherit; }
.fp-iso-note { font-size: 15px; fill: #8A93A3; font-family: inherit; }
.fp-iso text { font-family: inherit; }
.fp-led-blink { animation: fp-blink .8s steps(2, jump-none) infinite; }
.fp-room { position: absolute; transform: translate(-50%, -50%); padding: 2px 8px; border-radius: 4px; background: rgba(255, 255, 255, .72); color: #4F5868; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.fp-door-tag { position: absolute; transform: translate(-50%, -50%); padding: 2px 8px; border-radius: 999px; background: #fff; border: 1px solid #D5DBE5; color: #4F5868; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.fp-door-tag.is-main { border-color: #2563C9; background: #2563C9; color: #fff; }
.fp-pin { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; padding: 0; border: 0; background: none; pointer-events: auto; cursor: default; }
.fp-stage.is-editing .fp-pin { cursor: grab; }
.fp-pin-stove, .fp-pin-tank { width: 34px; height: 34px; border-radius: 9px; border: 2px solid #fff; box-shadow: 0 3px 8px rgba(20, 32, 51, .28); }
.fp-pin-stove { background: #2B3340; color: #FF7A2F; }
.fp-pin-tank { background: #2F6FD0; color: #fff; }
.fp-pin-stove svg, .fp-pin-tank svg { width: 20px; height: 20px; }
.fp-pin-dot { position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; background: var(--pin); color: #fff; font-size: 13px; font-weight: 700; box-shadow: 0 3px 8px rgba(20, 32, 51, .3); }
.fp-pin-sensor.is-danger .fp-pin-dot::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 3px solid var(--pin); animation: fp-ping 1s ease-out infinite; }
.fp-pin-chip { position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%); padding: 3px 9px; border-radius: 999px; border: 1px solid #E1E5EC; background: rgba(255, 255, 255, .95); color: #1F2937; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: 0 2px 6px rgba(20, 32, 51, .12); font-variant-numeric: tabular-nums; }
.fp-pin.chip-left .fp-pin-chip { left: auto; right: calc(100% + 6px); }
.fp-pin.is-selected .fp-pin-dot, .fp-pin.is-selected.fp-pin-stove, .fp-pin.is-selected.fp-pin-tank { outline: 3px solid var(--brand); outline-offset: 2px; }
.fp-inspector { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); font-size: 13.5px; }
.fp-muted { color: var(--muted); font-size: 13px; }
@keyframes fp-ring { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
@keyframes fp-ping { from { transform: scale(.7); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
@keyframes fp-blink { 50% { opacity: .25; } }
@media (max-width: 600px) {
  .fp-room { font-size: 10px; padding: 1px 5px; }
  .fp-door-tag { font-size: 10px; padding: 1px 6px; }
  .fp-pin-stove, .fp-pin-tank { width: 26px; height: 26px; border-radius: 7px; }
  .fp-pin-stove svg, .fp-pin-tank svg { width: 15px; height: 15px; }
  .fp-pin-dot { width: 24px; height: 24px; border-width: 2px; font-size: 11px; }
  .fp-pin-chip { font-size: 10.5px; padding: 2px 6px; }
  .hero h2 { font-size: 28px; }
}
/* ---- Motion: alive but calm. The device "breathes"; changes are announced, not decorated. ---- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes sonar { from { transform: scale(1); opacity: .65; } to { transform: scale(1.75); opacity: 0; } }
@keyframes shift { 0% { background: var(--lv-bg); box-shadow: 0 0 0 0 var(--lv); } 35% { box-shadow: 0 0 0 8px var(--lv-line); } 100% { background: var(--surface); box-shadow: 0 0 0 0 transparent; } }
@keyframes sweep { from { left: -60px; } to { left: 100%; } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.6); } 24% { transform: scale(1); } }
@keyframes pop { from { transform: scale(0); } }
@keyframes tab-pop { 40% { transform: scale(1.25) translateY(-2px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } }

/* Opening a tab: its blocks rise in one after another. */
.view.is-entering > *, .view.is-entering .home-grid > .view > * { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.view.is-entering > *:nth-child(2), .view.is-entering .home-grid > .view > *:nth-child(2) { animation-delay: .07s; }
.view.is-entering > *:nth-child(3), .view.is-entering .home-grid > .view > *:nth-child(3) { animation-delay: .14s; }
.view.is-entering > *:nth-child(4), .view.is-entering .home-grid > .view > *:nth-child(4) { animation-delay: .21s; }
.view.is-entering > *:nth-child(n+5), .view.is-entering .home-grid > .view > *:nth-child(n+5) { animation-delay: .28s; }
.view.is-entering .home-grid > .view:nth-child(2) > * { animation-delay: .12s; }
.view.is-entering .checks li > span { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.view.is-entering .checks li:nth-child(2) > span { animation-delay: .1s; }
.view.is-entering .checks li:nth-child(3) > span { animation-delay: .2s; }
.view.is-entering .checks li:nth-child(4) > span { animation-delay: .3s; }

/* Status LED sends out sonar rings: slow when safe, faster as the level rises. */
.hero-badge { position: relative; }
.hero-top > div { position: relative; } /* the status words paint above the LED rings */
.hero-badge::before, .hero-badge::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--lv); opacity: 0; pointer-events: none; animation: sonar 3s ease-out infinite; }
.hero-badge::after { animation-delay: 1.5s; }
.hero.is-watch .hero-badge::before, .hero.is-watch .hero-badge::after { animation-duration: 2s; }
.hero.is-watch .hero-badge::after { animation-delay: 1s; }
.hero.is-warning .hero-badge::before, .hero.is-warning .hero-badge::after { animation-duration: 1.2s; }
.hero.is-warning .hero-badge::after { animation-delay: .6s; }
.hero.is-danger .hero-badge::before, .hero.is-danger .hero-badge::after { animation-duration: .8s; }
.hero.is-danger .hero-badge::after { animation-delay: .4s; }
.hero.is-unknown .hero-badge::before, .hero.is-unknown .hero-badge::after { animation: none; }
.hero, .hero h2, .hero-kicker { transition: border-color .5s, color .5s; }
.hero.is-shift { animation: shift 1.4s ease-out; }

/* LCD: faint scanlines, and a live trace with a sweeping beam. */
.stats, .scope { position: relative; overflow: hidden; }
.stats::after, .scope::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(30, 42, 23, .07) 0 1px, transparent 1px 3px); }
.scope { height: 66px; border-radius: 10px; background: var(--lcd); border: 3px solid var(--bezel); }
.scope svg { position: absolute; left: 8px; top: 6px; width: calc(100% - 16px); height: calc(100% - 22px); overflow: visible; }
.scope-line { fill: none; stroke: var(--lcd-ink); stroke-width: 1.8; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.scope-limit { stroke: var(--lcd-muted); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.scope-dot { stroke: var(--lcd-ink); stroke-width: 7; stroke-linecap: round; vector-effect: non-scaling-stroke; animation: blink 1s steps(2, jump-none) infinite; }
.scope-sweep { position: absolute; top: 0; bottom: 0; left: 0; width: 60px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .38)); animation: sweep 3.6s linear infinite; pointer-events: none; }
.scope-label { position: absolute; left: 8px; bottom: 2px; font-family: var(--mono); font-size: 10px; color: var(--lcd-muted); }

/* Small signs of life. */
.pill.is-online i, .landing-leds i.is-safe { animation: heartbeat 2.2s ease-in-out infinite; }
.landing-leds i:last-child { animation: blink 1.7s steps(2, jump-none) infinite; }
.btn, .button, .tab, .fp-tool, .segment button, .sg-segment button { transition: background-color .18s, border-color .18s, color .18s, transform .12s; }
.btn:active, .button:active, .fp-tool:active, .segment button:active { transform: scale(.96); }
.card { transition: border-color .2s, transform .2s; }
a.card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.plan-thumb svg { transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.plan-card:hover .plan-thumb svg { transform: scale(1.08); }
.tab.is-active svg { animation: tab-pop .38s cubic-bezier(.3, 1.6, .5, 1); }
.toast:not([hidden]) { animation: toast-in .3s cubic-bezier(.2, .8, .2, 1); }
.trial-bar button.is-on { animation: blink 1s steps(2, jump-none) infinite; }
.boot { display: flex; align-items: center; justify-content: center; gap: 10px; }
.boot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--safe); box-shadow: 0 0 10px var(--safe); animation: blink .8s steps(2, jump-none) infinite; }
.landing-copy > *, .landing-side > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) both; }
.landing-copy > *:nth-child(2) { animation-delay: .08s; }
.landing-copy > *:nth-child(3) { animation-delay: .16s; }
.landing-copy > *:nth-child(4) { animation-delay: .26s; }
.landing-side > * { animation-delay: .2s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Shared additions: site switcher, forms, tables, wizard, invitations ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.site-switch select { max-width: 70vw; min-height: 32px; padding: 0 28px 0 8px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); font-size: 13px; color: var(--muted); }
.landing-side { display: grid; gap: 16px; align-content: start; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.field textarea, .field-input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.field textarea { min-height: 84px; resize: vertical; }
.invite-form, .invite-result { display: grid; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface-soft); }
.alarm-acks { margin: 0; text-align: center; font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 12px; background: rgba(0, 0, 0, .18); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 9px 10px; text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td small { display: block; color: var(--muted); font-size: 12px; }
.table select { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); padding: 0 6px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi span { display: block; font-size: 13px; color: var(--muted); }
.kpi strong { display: block; font-family: var(--mono); font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--lcd); }
.kpi small { color: var(--muted); font-size: 12px; }
.secret-box { display: grid; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--warning-line); background: var(--warning-bg); }
.secret-box code { display: block; padding: 10px; border-radius: 8px; background: var(--surface); font-size: 13px; word-break: break-all; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.stepper li { display: grid; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.stepper li::before { content: ""; height: 5px; border-radius: 3px; background: var(--line-strong); }
.stepper li.is-done, .stepper li.is-current { color: var(--ink); }
.stepper li.is-done::before, .stepper li.is-current::before { background: var(--brand); }
.wizard-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.qr-video { width: 100%; max-height: 300px; border-radius: 12px; background: #000; object-fit: cover; }
.tabbar { grid-template-columns: repeat(var(--tabs, 4), minmax(64px, 1fr)); overflow-x: auto; }

/* ---- Printable report ---- */
.report { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  body > *:not(.report) { display: none !important; }
  .report { display: block !important; color: #000; font-size: 11pt; }
  .report-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .report-head h1 { font-size: 18pt; margin: 0; }
  .report-head p { margin: 4px 0 0; }
  .report-brand { font-weight: 700; font-size: 14pt; }
  .report h2 { font-size: 13pt; margin: 14px 0 6px; }
  .report-meta, .report-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .report-meta th, .report-meta td, .report-table th, .report-table td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
  .report-meta th, .report-table th { background: #eee; width: 18%; }
  .report .legend { font-size: 9pt; }
  .report .chart { max-height: 70mm; }
  .report-note { margin-top: 14px; font-size: 9pt; color: #333; }
}

/* On phones the sign-in form comes first; the product copy follows below it. */
@media (max-width: 859px) {
  .landing-side { order: -1; }
  .landing-head { padding-bottom: 18px; }
}

/* Trial mode (?trial): a bar on top of every screen, and its card on the landing page. */
.trial-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 110; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; min-height: 44px; padding: 6px 14px; background: #1F2937; color: #fff; font-size: 13.5px; }
/* Above the alarm so the demo leak can be stopped while the alarm shows. */
body.is-trial .alarm { padding-top: 72px; }
.trial-bar-actions { display: flex; gap: 8px; align-items: center; }
.trial-bar button, .trial-bar a { min-height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff; font: inherit; font-weight: 600; display: inline-flex; align-items: center; cursor: pointer; }
.trial-bar button { background: #D32F2F; border-color: #D32F2F; }
body.is-trial { padding-top: 92px; }
body.is-trial .landing { display: none; }
@media (min-width: 900px) { body.is-trial { padding-top: 44px; } body.is-trial .tabbar { top: 44px; } }
.trial-pick { display: grid; gap: 12px; padding: 24px; }
.trial-pick h2 { font-size: 20px; }

/* Signed-in account at the bottom of the desktop sidebar (on phones it lives in the "my home" tab). */
.tabbar-account { display: none; }
@media (min-width: 900px) {
  .tabbar-account { display: grid; gap: 4px; margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
  .tabbar-account strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar-account small { color: var(--muted); margin-bottom: 6px; }
}
