:root {
  --bg: #f3f5f9; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --primary: #2563eb; --primary-ink: #ffffff; --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2; --warn: #b45309; --warn-bg: #fef3c7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #141d30; --ink: #e8edf6; --muted: #93a1b8; --line: #24314a;
    --primary: #4c8dff; --primary-ink: #06122b; --ok: #4ade80; --ok-bg: #12351f; --bad: #f87171; --bad-bg: #3a1618; --warn: #fbbf24; --warn-bg: #3a2a0c;
    --shadow: none;
  }
}
* { 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; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* khung */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
header.top h1 { margin: 0; font-size: 19px; flex: 1; letter-spacing: .2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--line); color: var(--muted); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.iconbtn { border: 0; background: transparent; padding: 8px; border-radius: 10px; font-size: 20px; line-height: 1; color: var(--muted); }
.progress { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 30; background: linear-gradient(90deg, transparent, var(--primary), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: slide 1s linear infinite; opacity: 0; transition: opacity .2s; }
.progress.on { opacity: 1; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }
main { max-width: 640px; margin: 0 auto; padding: 14px 16px; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 2px 8px; color: var(--muted); font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.tabs button span { font-size: 22px; line-height: 1.1; }
nav.tabs button[aria-selected="true"] { color: var(--primary); font-weight: 700; }

/* the */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; border: 1px solid var(--line); }
.card h2 { margin: 0 0 4px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: none; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }
.big { font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.stack > * + * { margin-top: 10px; }

/* the khoa */
.lock { display: flex; align-items: center; gap: 14px; }
.lock .ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: var(--ok-bg); }
.lock.locked .ic { background: var(--bad-bg); }
.lock .st { font-size: 20px; font-weight: 800; }
.lock.locked .st { color: var(--bad); }
.lock:not(.locked) .st { color: var(--ok); }

/* nut */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--primary); color: var(--primary-ink); min-height: 46px; }
.btn.block { width: 100%; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.ok { color: #06210f; } .btn.bad { color: #2a0608; } }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--line); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btns > .btn { flex: 1; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--primary); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 600; }
.chips button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }

/* danh sach */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .t b { font-weight: 600; }
.list .t small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--bad); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .45; }
.gh { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.gh h3 { flex: 1; margin: 0; font-size: 16px; }
.gh .cnt { color: var(--muted); font-size: 13px; }
.icon16 { width: 28px; height: 28px; border-radius: 7px; background: var(--line); flex: none; object-fit: contain; }

/* form */
input[type=text], input[type=search], input[type=time], input[type=number], input[type=password], select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); min-height: 46px; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
label.f { display: block; font-size: 13.5px; color: var(--muted); font-weight: 600; margin: 12px 0 5px; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow: auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 60; max-width: 90vw; font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.toast.err { background: #b91c1c; }

/* man hinh phu */
.center { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px; text-align: center; gap: 12px; }
.logo { width: 84px; height: 84px; border-radius: 24px; }
.center h1 { margin: 6px 0 0; font-size: 24px; }
.pin { display: flex; gap: 12px; justify-content: center; margin: 8px 0; }
.pin i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin i.on { background: var(--primary); border-color: var(--primary); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; margin-top: 8px; }
.pad button { height: 64px; border-radius: 50%; border: 0; background: var(--card); border: 1px solid var(--line); font-size: 24px; font-weight: 600; }
.pad button:active { background: var(--line); }
.err { color: var(--bad); font-weight: 600; min-height: 1.4em; }
pre.txt { white-space: pre-wrap; word-break: break-word; font: 14px/1.5 ui-monospace, Consolas, monospace; background: var(--bg); border-radius: 12px; padding: 12px; margin: 10px 0 0; max-height: 55dvh; overflow: auto; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--muted); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.lnk { color: var(--primary); word-break: break-all; font-size: 14px; }
