:root {
  --bg: #f3f5fa; --surface: #fff; --surface2: #eef1f8; --text: #172033; --muted: #66728c; --border: #e2e7f0;
  --primary: #3566f0; --primary-h: #2a56d4; --on-primary: #fff; --primary-soft: #e8eefe;
  --ok: #15803d; --ok-bg: #e4f6ea; --warn: #b45309; --warn-bg: #fff3dc; --bad: #c62828; --bad-bg: #fde8e8;
  --code-bg: #fff3b0; --code-ink: #5b4300;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 20px rgba(20, 30, 60, .06);
  --radius: 16px; --radius-sm: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #0c1120; --surface: #151c2e; --surface2: #1c2540; --text: #e7ebf6; --muted: #97a3bf; --border: #26304c;
    --primary: #6d93ff; --primary-h: #8aa9ff; --on-primary: #0b1020; --primary-soft: #1b2850;
    --ok: #5ee08c; --ok-bg: #12301f; --warn: #fbbf4a; --warn-bg: #382a0c; --bad: #ff8585; --bad-bg: #3a1818;
    --code-bg: #5a4a0a; --code-ink: #ffe98a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #0c1120; --surface: #151c2e; --surface2: #1c2540; --text: #e7ebf6; --muted: #97a3bf; --border: #26304c;
  --primary: #6d93ff; --primary-h: #8aa9ff; --on-primary: #0b1020; --primary-soft: #1b2850;
  --ok: #5ee08c; --ok-bg: #12301f; --warn: #fbbf4a; --warn-bg: #382a0c; --bad: #ff8585; --bad-bg: #3a1818;
  --code-bg: #5a4a0a; --code-ink: #ffe98a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35); color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.55;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 1.05rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hidden { display: none !important; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-right: auto; }
.brand svg { width: 26px; height: 26px; }
.page { max-width: 960px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 16px; }
.page.narrow { max-width: 640px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1 1 200px; min-width: 0; }

/* controls */
button, .btn {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
button:hover:not(:disabled), .btn:hover { background: var(--border); }
button:active:not(:disabled) { transform: scale(.98); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:disabled { opacity: .6; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover:not(:disabled) { background: var(--primary-h); }
button.danger { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
button.sm { min-height: 32px; padding: 0 12px; font-size: .85rem; }
button.ghost { background: transparent; border-color: transparent; }
button.icon { width: 40px; padding: 0; font-size: 1.1rem; }
button.big { min-height: 60px; font-size: 1.2rem; width: 100%; border-radius: 14px; }
input, select {
  font: inherit; min-height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); max-width: 100%;
}
input:focus, select:focus { border-color: var(--primary); }
label.field { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
label.field input, label.field select { width: 100%; }
form.stack { display: grid; gap: 12px; }
.form-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.error { color: var(--bad); background: var(--bad-bg); border-radius: var(--radius-sm); padding: 8px 12px; font-size: .92rem; }
.error:empty { display: none; }
.notice { border-radius: var(--radius-sm); padding: 10px 14px; background: var(--warn-bg); color: var(--warn); font-size: .92rem; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .82rem; font-weight: 600; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.pulse::before { animation: pulse 1.1s ease-in-out infinite; }
.badge.plain::before { display: none; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .4; } }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }

/* card hero */
.hero { display: grid; gap: 14px; }
.hero-name { font-size: 1.35rem; font-weight: 700; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0; list-style: none; padding: 0; }
.steps li { text-align: center; font-size: .78rem; color: var(--muted); position: relative; padding-top: 22px; }
.steps li::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 4px; border-radius: 4px; background: var(--border); }
.steps li.done { color: var(--text); } .steps li.done::before { background: var(--ok); }
.steps li.now { color: var(--primary); font-weight: 600; } .steps li.now::before { background: var(--primary); animation: pulse 1.1s ease-in-out infinite; }
.steps li.err { color: var(--bad); font-weight: 600; } .steps li.err::before { background: var(--bad); }
.banner-ok { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 600; }
.banner-bad { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius-sm); padding: 10px 14px; }

/* sms */
.sms { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.sms + .sms { margin-top: 10px; }
.sms.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { 0% { background: var(--primary-soft); transform: translateY(-6px); box-shadow: 0 0 0 3px var(--primary); } 100% { background: var(--surface); transform: none; box-shadow: none; } }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.sms-main { flex: 1; min-width: 0; }
.sms-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sms-head b { overflow-wrap: anywhere; }
.sms-body { margin-top: 4px; overflow-wrap: anywhere; white-space: pre-wrap; }
.unread::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); display: inline-block; margin-left: 6px; }
.code { background: var(--code-bg); color: var(--code-ink); font: 700 1.25em ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; padding: 0 8px; border-radius: 8px; }
.copy-row { margin-top: 8px; }
.empty { text-align: center; padding: 32px 12px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; opacity: .6; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 960px; margin: 0 auto; padding: 0 12px; }
.tab { background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; min-height: 44px; color: var(--muted); white-space: nowrap; }
.tab[aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(:disabled) { background: transparent; color: var(--text); }

/* dialog + toast */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 12, 24, .55); }
dialog h3 { margin-bottom: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toasts { position: fixed; left: 0; right: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; pointer-events: none; z-index: 20; }
.toast { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 99px; font-size: .9rem; box-shadow: var(--shadow); animation: toast .25s ease-out; }
@keyframes toast { from { opacity: 0; transform: translateY(8px); } }

/* login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); }
.login-card .brand { justify-content: center; margin: 0 0 6px; font-size: 1.3rem; }
@media (max-width: 520px) { .card { padding: 14px; border-radius: 14px; } .topbar-in .uname { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.tc { text-align: center; margin: 0 0 16px; }
.tall { min-height: 46px; }
.row.center { justify-content: center; }
.top-gap { margin-top: 14px; }

/* multi-card */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { min-height: 34px; padding: 0 14px; border-radius: 99px; font-size: .88rem; background: var(--surface2); }
.chip[aria-selected=true] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.number { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.number .mono { font-size: 1.05rem; font-weight: 600; letter-spacing: .5px; }
.tag { font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.chiplist { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 99px; background: var(--surface2); font-size: .82rem; }
.pill button { min-height: 22px; width: 22px; padding: 0; border-radius: 50%; background: transparent; border: 0; font-size: 1rem; line-height: 1; }
.checklist { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; margin: 8px 0; }
.checklist label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.checklist input { min-height: auto; width: 18px; height: 18px; }
.md h1 { font-size: 1.4rem; margin: 6px 0 12px; } .md h2 { font-size: 1.15rem; margin: 22px 0 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.md h3 { font-size: 1rem; margin: 16px 0 6px; } .md p { margin: 8px 0; } .md ul, .md ol { padding-left: 22px; margin: 8px 0; }
.md code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface2); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.codeblock { position: relative; margin: 10px 0; }
.codeblock pre { margin: 0; padding: 12px; background: var(--surface2); border-radius: var(--radius-sm); overflow-x: auto; font: .85rem/1.5 ui-monospace, Menlo, Consolas, monospace; }
.codeblock button { position: absolute; top: 6px; right: 6px; }
.md table { margin: 10px 0; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* collapsible card list (account with several cards) */
.groupbar { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px 16px; font-weight: 600; text-align: left; }
.chev { opacity: .6; font-weight: 400; }

.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }
