:root {
  --bg: #0f1115;
  --surface: #1b1e26;
  --surface-2: #232733;
  --line: #2d3240;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #3b82f6;
  --accent-press: #2f6bde;
  --danger: #ef4444;
  --good: #34d399;
  --warn: #f59e0b;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.loading { color: var(--muted); text-align: center; padding: 40px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 20px 10px; position: sticky; top: 0; background: linear-gradient(var(--bg), rgba(15,17,21,0.86)); backdrop-filter: blur(6px); z-index: 5; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.02em; flex: 1; }
.topbar .sub { color: var(--muted); font-size: 12px; }
.iconbtn { background: var(--surface); border: 1px solid var(--line); color: var(--text); width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; }
.iconbtn:active { background: var(--surface-2); }
.back { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--accent); font-size: 15px; padding: 0; cursor: pointer; }

/* Content */
.content { padding: 8px 16px 40px; flex: 1; }
.section-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin: 18px 4px 8px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.lock-card { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; cursor: pointer; transition: transform .06s ease; }
.lock-card:active { transform: scale(0.99); }
.lock-ico { width: 46px; height: 46px; border-radius: 13px; background: radial-gradient(120% 120% at 30% 20%, #2b3550, #1a2030); display: grid; place-items: center; flex: none; }
.lock-ico svg { width: 24px; height: 24px; color: #cdd7ff; }
.lock-main { flex: 1; min-width: 0; }
.lock-name { font-weight: 600; font-size: 16px; }
.lock-meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); }
.chip.warn { color: var(--warn); border-color: #4a3a1a; }
.chip.readonly { color: var(--warn); }
.battery { font-variant-numeric: tabular-nums; }
.chev { color: var(--muted); flex: none; }

/* Code rows */
.code-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.code-row:last-child { border-bottom: 0; }
.code-main { flex: 1; min-width: 0; }
.code-name { font-weight: 600; }
.code-sched { color: var(--muted); font-size: 12px; margin-top: 3px; }
.dots { letter-spacing: 3px; color: var(--muted); font-size: 16px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.pill.perm { background: #22303f; color: #8bd3ff; }
.pill.sched { background: #2a2440; color: #c4b5fd; }
.pill.none { background: #3a2a2a; color: #f0a6a6; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 14px; padding: 6px; }
.linkbtn.danger { color: var(--danger); }

/* Buttons / forms */
.btn { display: block; width: 100%; border: 0; border-radius: 13px; padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.fab { position: sticky; bottom: 16px; margin: 18px 4px 0; }

.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); padding: 13px; font-size: 16px; }
.field input:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.error { color: var(--danger); font-size: 13px; margin: 10px 4px; min-height: 1em; }

/* Login */
.auth { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 22px; gap: 4px; }
.brand { text-align: center; margin-bottom: 20px; }
.brand .mark { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, #3b82f6, #6366f1); display: inline-grid; place-items: center; }
.brand .mark svg { width: 30px; height: 30px; color: #fff; }
.brand h2 { margin: 12px 0 2px; font-size: 20px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.captcha-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px; background: #fff; }

/* Modal sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: grid; align-items: end; z-index: 20; }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); width: 100%; max-width: 480px; margin: 0 auto; max-height: 88vh; overflow: auto; }
.sheet h3 { margin: 4px 0 8px; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #111826; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px; z-index: 40; box-shadow: 0 8px 30px rgba(0,0,0,.4); }

/* Remember-me checkbox */
.field label.check { display:flex; align-items:center; gap:8px; cursor:pointer; font-weight:400; }
.field label.check input { width:auto; margin:0; }
