:root {
  --bg: #07090d;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #eef2f7;
  --text-2: #9aa6b5;
  --text-3: #5f6b7a;

  --ok: #4fe0a8;      /* disarmed / closed */
  --armed: #ffb547;   /* armed */
  --alarm: #ff4f61;   /* alarm / tamper */
  --info: #7cb4ff;    /* bypassed / neutral accents */

  --accent: var(--ok);
  --radius: 22px;
  --radius-sm: 14px;
  --gap: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
}

body[data-status="armed"],
body[data-status="partial"] { --accent: var(--armed); }
body[data-status="alarm"] { --accent: var(--alarm); }
body[data-status="loading"],
body[data-status="offline"] { --accent: var(--text-3); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 1em; height: 1em; display: block; flex: none; }
[hidden] { display: none !important; }

/* Ambient light that follows system state */
.aura {
  position: fixed;
  inset: -30vmax auto auto -20vmax;
  width: 90vmax;
  height: 90vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
  opacity: 0.55;
  pointer-events: none;
  transition: background 0.8s ease;
  z-index: 0;
}
body[data-status="alarm"] .aura { animation: aura-pulse 1.4s ease-in-out infinite; }
@keyframes aura-pulse { 50% { opacity: 0.95; } }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px 10px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 30px; color: var(--accent); transition: color 0.5s; }
.brand-title { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 22px; }
.clock { text-align: right; }
.clock-time { font-size: 30px; font-weight: 300; letter-spacing: -0.02em; line-height: 1; }
.clock-date { font-size: 12px; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.08em; }

.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.conn.is-live .conn-dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.conn.is-down .conn-dot { background: var(--alarm); }

.lock-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--armed) 14%, transparent);
  color: var(--armed);
  font-size: 13px; font-weight: 600;
}
.lock-pill svg { font-size: 16px; }

.banner {
  position: relative; z-index: 1;
  margin: 0 28px 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--alarm) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--alarm) 30%, transparent);
  color: #ffc2c8;
  font-size: 14px;
}

/* ------------------------------------------------------------ layout */
.layout {
  position: relative; z-index: 1;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: var(--gap);
  padding: 8px 28px 24px;
}
.col { min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.col-main { overflow-y: auto; scrollbar-width: none; padding-bottom: 8px; }
.col-main::-webkit-scrollbar { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-2); }
.count { font-size: 13px; color: var(--text-3); }

/* ------------------------------------------------------------ hero */
.hero { padding: 26px; display: flex; flex-direction: column; gap: 26px; }
.hero-status { display: flex; align-items: center; gap: 28px; }

.orb { position: relative; width: 132px; height: 132px; flex: none; display: grid; place-items: center; }
.orb-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent);
  transition: border-color 0.6s;
}
.orb-ring.r2 { inset: 16px; border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
body[data-status="armed"] .orb-ring.r1,
body[data-status="partial"] .orb-ring.r1 { animation: breathe 3.2s ease-in-out infinite; }
body[data-status="alarm"] .orb-ring { animation: ripple 1.2s ease-out infinite; }
body[data-status="alarm"] .orb-ring.r2 { animation-delay: 0.4s; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: 0.5; } }
@keyframes ripple { from { transform: scale(0.8); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }

.orb-core {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 40px;
  color: var(--accent);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 30%, transparent), color-mix(in srgb, var(--accent) 8%, transparent) 70%);
  box-shadow: 0 0 60px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: color 0.6s, background 0.6s, box-shadow 0.6s;
}

.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-3); }
.hero-text h1 { margin: 6px 0 6px; font-size: 44px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; color: var(--accent); transition: color 0.6s; }
.hero-text p { margin: 0; font-size: 16px; color: var(--text-2); }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 17px; font-weight: 600;
  transition: transform 0.12s, background 0.2s;
}
.quick-btn svg { font-size: 22px; color: var(--armed); }
.quick-off svg { color: var(--ok); }
.quick-btn:active { transform: scale(0.97); background: var(--surface-3); }

/* ------------------------------------------------------------ scenarios */
.scenarios { display: flex; flex-wrap: wrap; gap: 10px; }
.scenario {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 0 16px; height: 52px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 15px; font-weight: 550;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.scenario svg { font-size: 18px; color: var(--text-2); }
.scenario:active { transform: scale(0.96); background: var(--surface-3); }
.scenario.is-active { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.scenario.is-active svg { color: var(--accent); }

/* ------------------------------------------------------------ areas */
.areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.area {
  --c: var(--ok);
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.4s, background 0.4s;
}
.area[data-s="armed"] { --c: var(--armed); }
.area[data-s="alarm"] { --c: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 50%, transparent); background: color-mix(in srgb, var(--alarm) 8%, transparent); }
.area-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.area-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-state {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--c);
  white-space: nowrap;
}
.area-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }

.seg {
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px; gap: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}
.seg button {
  height: 44px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: background 0.2s, color 0.2s, transform 0.12s;
}
.seg button svg { font-size: 16px; }
.seg button:active { transform: scale(0.95); }
.seg button.is-on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.08); }
.seg button.is-on[data-mode="disarm"] { color: var(--ok); }
.seg button.is-on:not([data-mode="disarm"]) { color: var(--armed); }
.seg button.is-pending { opacity: 0.5; }

.area-memory {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; color: #ffc2c8;
}
.area-memory button { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; }

/* ------------------------------------------------------------ zones */
.zones-card { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 20px 20px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 550; color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
}
.chip b { font-weight: 600; color: var(--text-3); margin-left: 3px; }
.chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.is-on b { color: rgba(0,0,0,0.5); }

.zones {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-content: start;
  gap: 8px;
  padding-bottom: 20px;
  scrollbar-width: none;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.zones::-webkit-scrollbar { display: none; }
.zone {
  --c: var(--text-3);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  min-height: 62px;
  transition: background 0.25s, border-color 0.25s, transform 0.12s;
}
.zone:active { transform: scale(0.98); }
.zone-icon {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 19px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
}
.zone-text { min-width: 0; }
.zone-name { font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-sub { font-size: 12px; color: var(--c); margin-top: 2px; white-space: nowrap; }
.zone[data-s="open"] { --c: var(--armed); border-color: color-mix(in srgb, var(--armed) 35%, transparent); }
.zone[data-s="alert"] { --c: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 45%, transparent); background: color-mix(in srgb, var(--alarm) 8%, transparent); }
.zone[data-s="bypassed"] { --c: var(--info); opacity: 0.75; }
.zone[data-s="bypassed"] .zone-name { text-decoration: line-through; text-decoration-color: var(--text-3); }
.zone[data-s="closed"] .zone-sub { color: var(--text-3); }
.zones-empty { grid-column: 1 / -1; padding: 30px 0; text-align: center; color: var(--text-3); font-size: 14px; }

/* ------------------------------------------------------------ system strip */
.system { display: flex; gap: 0; padding: 4px; }
.sys-item { padding: 14px 18px; min-width: 0; }
.sys-item + .sys-item { border-left: 1px solid var(--line); }
.sys-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); margin-bottom: 6px; }
.sys-value { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.sys-value small { font-size: 13px; color: var(--text-3); margin-left: 2px; }
.sys-value.is-ok { color: var(--ok); }
.sys-value.is-bad { color: var(--alarm); }
.sys-grow { flex: 1; text-align: right; }
.sys-small { font-size: 15px; color: var(--text-2); margin-top: 6px; }

/* ------------------------------------------------------------ outputs */
.outputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.output {
  --c: var(--text-3);
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 18px;
  min-height: 108px; padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  transition: background 0.25s, border-color 0.25s, transform 0.12s;
}
.output:active { transform: scale(0.97); }
.output-icon { font-size: 24px; color: var(--c); transition: color 0.25s; }
.output-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.output-state { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.output.is-on { --c: #ffd27a; background: color-mix(in srgb, #ffd27a 10%, transparent); border-color: color-mix(in srgb, #ffd27a 30%, transparent); }
.output.is-on .output-state { color: #ffd27a; }
.switch { position: absolute; top: 16px; right: 16px; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.output.is-on .switch { background: #e8b44f; }
.output.is-on .switch::after { transform: translateX(16px); }
.is-pending { animation: pending 1s ease-in-out infinite; }
@keyframes pending { 50% { opacity: 0.55; } }

/* ------------------------------------------------------------ overlays */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: rgba(3, 5, 8, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(420px, calc(100vw - 40px));
  padding: 28px;
  border-radius: 28px;
  background: #11151c;
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: rise 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rise { from { transform: translateY(16px) scale(0.98); opacity: 0; } }

.keypad { text-align: center; }
.kp-title { font-size: 20px; font-weight: 650; }
.kp-sub { font-size: 14px; color: var(--text-2); margin-top: 4px; min-height: 18px; }
.kp-dots { display: flex; justify-content: center; gap: 14px; height: 14px; margin: 24px 0 8px; }
.kp-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--text); animation: pop 0.15s ease; }
.kp-dots.is-empty::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--text-3); }
@keyframes pop { from { transform: scale(0.4); } }
.kp-msg { min-height: 20px; font-size: 13px; color: var(--alarm); margin-bottom: 8px; }
.keypad.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.kp-grid { display: grid; grid-template-columns: repeat(3, 84px); justify-content: center; gap: 14px 22px; }
.kp-grid button {
  width: 84px; height: 84px; border-radius: 50%;
  font-size: 32px; font-weight: 400;
  background: var(--surface-2);
  display: grid; place-items: center;
  transition: background 0.1s, transform 0.1s;
}
.kp-grid button:active { background: var(--surface-3); transform: scale(0.94); }
.kp-grid .kp-text { background: none; font-size: 16px; color: var(--text-2); }
.kp-grid .kp-text svg { font-size: 28px; }
.kp-ok {
  margin-top: 22px; width: 100%; height: 56px; border-radius: 16px;
  background: var(--text); color: var(--bg); font-size: 17px; font-weight: 650;
  transition: opacity 0.2s;
}
.kp-ok:disabled { opacity: 0.25; }
.kp-ok.is-busy { opacity: 0.6; }

.sheet-title { font-size: 20px; font-weight: 650; margin-bottom: 8px; }
.sheet-body { font-size: 15px; color: var(--text-2); line-height: 1.45; }
.sheet-body ul { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.sheet-body li { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); display: flex; align-items: center; gap: 10px; }
.sheet-body li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--armed); }
.sheet-actions { display: grid; gap: 10px; margin-top: 22px; }
.sheet-actions button { height: 54px; border-radius: 16px; font-size: 16px; font-weight: 600; background: var(--surface-2); }
.sheet-actions button.primary { background: var(--text); color: var(--bg); }
.sheet-actions button.warn { background: color-mix(in srgb, var(--armed) 18%, transparent); color: var(--armed); }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%);
  padding: 14px 22px; border-radius: 16px;
  background: #1a2029; border: 1px solid var(--line-2);
  font-size: 15px; font-weight: 550;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: rise 0.25s ease;
}
.toast.is-error { color: #ffc2c8; border-color: color-mix(in srgb, var(--alarm) 40%, transparent); }
.toast.is-ok { color: var(--ok); }

/* ------------------------------------------------------------ top buttons */
.top-btn {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.top-btn svg { font-size: 16px; }
.top-btn:active { background: var(--surface-3); }

/* ------------------------------------------------------------ sign in */
.login {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(80vmax 80vmax at 20% 0%, rgba(79, 224, 168, 0.12), transparent 60%), var(--bg);
}
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-mark { font-size: 44px; color: var(--ok); margin-bottom: 6px; }
.login h1 { margin: 0; font-size: 34px; font-weight: 650; letter-spacing: -0.02em; }
.login p { margin: -8px 0 10px; color: var(--text-3); }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.login input {
  height: 52px; padding: 0 16px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text);
  font: inherit; font-size: 17px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.login input:focus { border-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.login-msg { min-height: 20px; font-size: 14px; color: var(--alarm); }

/* ------------------------------------------------------------ activity */
.activity { width: min(560px, calc(100vw - 40px)); max-height: min(720px, calc(100vh - 80px)); display: flex; flex-direction: column; }
.activity-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.activity-list { overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.act-day { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); margin: 16px 0 6px; }
.act-row { display: grid; grid-template-columns: 52px 10px 1fr; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.act-time { font-size: 13px; color: var(--text-3); }
.act-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); transform: translateY(-1px); }
.act-row[data-level="ok"] .act-dot { background: var(--ok); }
.act-row[data-level="armed"] .act-dot { background: var(--armed); }
.act-row[data-level="alarm"] .act-dot { background: var(--alarm); }
.act-text { font-size: 15px; }
.act-user { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.act-empty { padding: 30px 0; text-align: center; color: var(--text-3); }

/* ------------------------------------------------------------ portrait / small */
@media (max-width: 1000px) {
  body { overflow: auto; }
  .layout { flex: none; grid-template-columns: 1fr; padding: 8px 20px 24px; }
  .col-main { overflow: visible; }
  .zones { overflow: visible; mask-image: none; }
  .topbar { padding: 16px 20px 8px; }
  .banner { margin: 0 20px 8px; }
}
@media (max-width: 600px) {
  .hero-status { gap: 18px; }
  .orb { width: 96px; height: 96px; }
  .orb-core { width: 62px; height: 62px; font-size: 30px; }
  .hero-text h1 { font-size: 32px; }
  .quick-btn { flex-direction: column; gap: 4px; font-size: 14px; }
  .conn span:last-child, .clock-date, .top-btn span { display: none; }
  .clock-time { font-size: 20px; white-space: nowrap; }
  .top-btn { padding: 0 10px; }
  .topbar-right { gap: 10px; }
  .system { flex-wrap: wrap; }
}

/* ------------------------------------------------------------ settings */
.settings {
  width: min(980px, calc(100vw - 40px));
  height: min(780px, calc(100vh - 60px));
  padding: 0;
  display: grid; grid-template-columns: 240px 1fr;
  overflow: hidden;
}
.set-nav { padding: 24px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.set-nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.set-nav-head .sheet-title { margin: 0; }
.set-tabs { display: flex; flex-direction: column; gap: 2px; }
.set-tabs button {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 12px; border-radius: 12px;
  font-size: 15px; font-weight: 550; color: var(--text-2); text-align: left;
}
.set-tabs button svg { font-size: 19px; }
.set-tabs button.is-on { background: var(--surface-2); color: var(--text); }
.set-tabs button:active { background: var(--surface-3); }

.set-body { overflow-y: auto; padding: 26px 30px 40px; -webkit-user-select: text; user-select: text; }
.set-body h2 { margin: 0 0 14px; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.set-body h3 { margin: 26px 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-2); }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.set-head h2 { margin: 0; }
.set-empty { padding: 26px; text-align: center; color: var(--text-3); }
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.set-card.form { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hint { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-3); }
.hint b { color: var(--text-2); font-weight: 600; }
.set-body > .hint { margin: -4px 0 14px; }

.list .item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.list .item + .item { border-top: 1px solid var(--line); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; line-height: 1.35; }
.item-icon { font-size: 22px; color: var(--text-2); }
.profile { display: flex; align-items: center; gap: 16px; padding: 16px 18px; }
.profile > div:nth-child(2) { flex: 1; min-width: 0; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 20px; font-weight: 650;
  background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok);
}
.avatar.small { width: 38px; height: 38px; font-size: 16px; }
em.tag-on, em.role { font-style: normal; font-size: 11px; font-weight: 650; padding: 3px 8px; border-radius: 999px; letter-spacing: 0.02em; }
em.tag-on { background: var(--surface-3); color: var(--text-2); }
em.role-owner { background: color-mix(in srgb, var(--armed) 16%, transparent); color: var(--armed); }
em.role-family { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
em.role-guest { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; }
.field > span { display: flex; align-items: center; gap: 8px; }
.field input, .field select, .name-input {
  height: 46px; padding: 0 14px; border-radius: 12px; min-width: 0; width: 100%;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text);
  font: inherit; font-size: 16px; outline: none;
  -webkit-user-select: text; user-select: text;
  color-scheme: dark;
}
.field input:focus, .field select:focus, .name-input:focus { border-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.field input:disabled { opacity: 0.5; }
.name-input::placeholder, .field input::placeholder { color: var(--text-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.check input { width: 18px; height: 18px; accent-color: var(--alarm); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-actions .danger { margin-right: auto; }

.btn {
  height: 42px; padding: 0 18px; border-radius: 12px; white-space: nowrap;
  font-size: 15px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line);
}
.btn:active { background: var(--surface-3); }
.btn:disabled { opacity: 0.4; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--alarm) 14%, transparent); color: #ff9aa5; border-color: color-mix(in srgb, var(--alarm) 30%, transparent); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.toggle { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; pointer-events: none; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(18px); }
.toggle input:focus-visible + span { outline: 2px solid var(--info); outline-offset: 2px; }

.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.role-opt { position: relative; }
.role-opt input { position: absolute; opacity: 0; }
.role-opt span {
  display: flex; flex-direction: column; gap: 4px; height: 100%;
  padding: 12px 14px; border-radius: 14px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-2);
}
.role-opt b { font-size: 15px; color: var(--text); }
.role-opt small { font-size: 12px; color: var(--text-3); line-height: 1.35; }
.role-opt input:checked + span { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.role-opt input:disabled + span { opacity: 0.4; cursor: not-allowed; }
.guest-only { display: flex; flex-direction: column; gap: 14px; padding: 14px; border-radius: 14px; background: color-mix(in srgb, var(--info) 6%, transparent); border: 1px solid color-mix(in srgb, var(--info) 20%, transparent); }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days .chip { min-width: 52px; height: 36px; }

.names .item { padding: 10px 14px; gap: 10px; }
.names .name-input { height: 40px; flex: 1; font-size: 15px; }
.mini { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }

.push-card { display: flex; align-items: center; gap: 16px; padding: 18px; flex-wrap: wrap; }
.push-card p { flex: 1; min-width: 220px; margin: 0; font-size: 15px; line-height: 1.45; color: var(--text-2); }
.push-card .item-icon { font-size: 28px; }
.push-card[data-state="on"] .item-icon { color: var(--ok); }
.push-card[data-state="denied"] .item-icon, .push-card[data-state="install"] .item-icon { color: var(--armed); }
.sch-time { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; min-width: 72px; }

.set-body, .set-nav { min-width: 0; }
@media (max-width: 760px) {
  #settings { place-items: stretch; }
  .settings {
    width: 100vw; height: 100dvh; border-radius: 0; border: 0;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  }
  .set-nav { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 14px 10px; }
  .set-tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .set-tabs::-webkit-scrollbar { display: none; }
  .set-tabs button { flex: none; height: 38px; font-size: 14px; }
  .set-body { padding: 20px 18px 40px; }
  .grid2, .grid3, .roles { grid-template-columns: 1fr; }
}
.field > span { min-height: 22px; }
.set-body > .field + .hint, .set-body > .set-card + .hint { margin: 10px 0 0; }

/* ------------------------------------------------------------ Face ID & two-step */
.login-step { display: flex; flex-direction: column; gap: 14px; }
.login-alt {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 52px; border-radius: 16px; width: 100%;
  font-size: 16px; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2);
}
.login-alt svg { font-size: 22px; color: var(--ok); }
.login-alt:active { background: var(--surface-3); }
.kp-face { margin-top: 10px; }
.qr { width: 200px; height: 200px; border-radius: 14px; background: #fff; padding: 8px; }
.twofa-setup { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.twofa-setup > div { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 12px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; letter-spacing: 0.08em; word-break: break-all; color: var(--text); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); -webkit-user-select: all; user-select: all; }
.status-on { color: var(--ok); }
.status-off { color: var(--text-3); }
.lang-pick { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.lang-pick button { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--text-3); }
.lang-pick button.is-on { color: var(--text); background: var(--surface-2); }
.lang-seg { grid-template-columns: repeat(3, auto); flex: none; }
.lang-seg button { padding: 0 14px; height: 36px; flex-direction: row; }
@media (max-width: 760px) { .lang-seg { width: 100%; grid-template-columns: repeat(3, 1fr); } .lang-seg button { padding: 0 6px; } }
.list .item:has(.lang-seg) { flex-wrap: wrap; }
.seg button { min-width: 0; padding: 0 2px; }
.seg button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html:lang(ka) .seg button { font-size: 12.5px; }
html:lang(ka) .section-head h2, html:lang(ka) .eyebrow, html:lang(ka) .sys-label, html:lang(ka) .set-body h3, html:lang(ka) .act-day, html:lang(ka) .mini { letter-spacing: 0.04em; }
.seg.lang-seg button.is-on { color: var(--text); }
.set-nav-head { gap: 10px; }
html:lang(ka) .set-nav-head .sheet-title { font-size: 17px; }

/* ------------------------------------------------------------ cameras */
.cameras { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.camera {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 16 / 9; border-radius: var(--radius);
  background: #000; border: 1px solid var(--line);
  transition: transform 0.12s;
}
.camera:active { transform: scale(0.98); }
.camera img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.4s; }
.camera.is-live img { opacity: 1; }
.camera-label {
  position: absolute; left: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 13px; font-weight: 600;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.camera.is-live .live-dot { background: var(--alarm); box-shadow: 0 0 8px var(--alarm); }
.camera-msg { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; color: var(--text-3); }

.cam-view { background: rgba(0, 0, 0, 0.92); }
.cam-view-inner { width: min(1400px, 100vw); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cam-view-head { display: flex; align-items: center; justify-content: space-between; font-size: 18px; font-weight: 650; padding: 0 4px; }
.cam-view img { width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 14px; background: #000; }
.cam-view-msg { text-align: center; color: var(--text-3); font-size: 14px; }

/* ------------------------------------------------------------ SOS, alarm handling, activity extras */
.sos-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--alarm);
  background: color-mix(in srgb, var(--alarm) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--alarm) 35%, transparent);
  touch-action: none; -webkit-touch-callout: none;
}
.sos-ring { position: absolute; inset: -1px; width: calc(100% + 2px); height: calc(100% + 2px); transform: rotate(-90deg); pointer-events: none; }
.sos-ring circle { fill: none; stroke: var(--alarm); stroke-width: 3; stroke-dasharray: 101; stroke-dashoffset: 101; }
.sos-btn.is-holding .sos-ring circle { transition: stroke-dashoffset 1.5s linear; stroke-dashoffset: 0; }
.sos-btn.is-sent { background: var(--alarm); color: #fff; }

.ack-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px 12px 18px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--alarm) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--alarm) 35%, transparent);
  font-size: 15px; font-weight: 600;
}

.act-tabs { justify-content: flex-start; margin: -4px 0 6px; }
.act-photos { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.act-photo { width: 112px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.act-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zone-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.zone-count { font-size: 13px; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.zone-count b { color: var(--armed); font-weight: 650; }
@media (max-width: 600px) { .sos-btn { width: 38px; height: 38px; } }
.tok-form { flex-wrap: wrap; }
.tok-form .name-input { flex: 1 1 200px; }
.tok-new { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: color-mix(in srgb, var(--ok) 6%, transparent); }
.tok-new + .item, .tok-new + form { border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ installer brand */
img.brand-logo { width: auto; object-fit: contain; border-radius: 8px; }
img.brand-mark { height: 34px; max-width: 120px; }
img.login-mark { height: 56px; max-width: 200px; align-self: flex-start; }
.login-mark { color: var(--brand, var(--ok)); }
.login { background: radial-gradient(80vmax 80vmax at 20% 0%, color-mix(in srgb, var(--brand, #4fe0a8) 14%, transparent), transparent 60%), var(--bg); }

/* Installer's phone under the sign-in form */
.login-help { margin: 14px 0 0; font-size: 13px; color: var(--text-3); text-align: center; }
.login-help:empty { display: none; }
.login-help a { color: var(--text-2); text-decoration: none; }
