:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e9edf5;
  --border: #e2e7f0;
  --border-strong: #cfd6e4;
  --text: #0f172a;
  --muted: #5b6675;
  --faint: #778192;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: rgba(79, 70, 229, .09);
  --accent: #0ea5a4;
  --ok: #129a63;
  --ok-soft: rgba(18, 154, 99, .12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, .12);
  --err: #e5484d;
  --err-soft: rgba(229, 72, 77, .12);
  --info: #2e7cf6;
  --info-soft: rgba(46, 124, 246, .12);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 28px -18px rgba(15, 23, 42, .35);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 16px;
}

html[data-theme="dark"] {
  --bg: #080b12;
  --surface: #0f1521;
  --surface-2: #161e2e;
  --surface-3: #1f293d;
  --border: #232d42;
  --border-strong: #33415c;
  --text: #e7ecf5;
  --muted: #a3afc2;
  --faint: #7e8ba0;
  --brand: #7c7cf8;
  --brand-strong: #9a9afb;
  --brand-soft: rgba(124, 124, 248, .14);
  --accent: #2dd4bf;
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .14);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 16px 32px -18px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
h1 { font-size: 26px; line-height: 1.25; }
h2 { font-size: 21px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.4; }
p { margin: 0; }
code, pre { font-family: var(--mono); }
button { font-family: inherit; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: 0 0 250px; background: var(--surface);
  border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5 0%, #0ea5a4 100%);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
}
.brand-name { font-weight: 650; font-size: 14px; letter-spacing: .01em; }
.brand-sub { font-size: 11px; color: var(--faint); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group { margin-top: 14px; padding: 0 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; font-weight: 500; cursor: pointer; border: 0; background: transparent;
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--faint); }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.main { flex: 1; min-width: 0; padding: 26px clamp(18px, 3vw, 40px) 56px; max-width: 1280px; margin: 0 auto; width: 100%; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }

/* ---------- card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 11.5px; color: var(--faint); margin-top: 6px; }

/* ---------- buttons ---------- */
.btn {
  height: 36px; padding: 0 14px; border-radius: 9px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  justify-content: center; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -10px var(--brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.loading::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; }
.field .hint { font-size: 11.5px; color: var(--faint); }
.field .error-text { font-size: 11.5px; color: var(--err); }
input, select, textarea {
  width: 100%; height: 38px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); padding: 0 11px; font-size: 13.5px; font-family: inherit;
}
textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  height: 40px; text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--border); padding: 0 12px; white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---------- badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--surface-3); color: var(--muted); }
.badge.plain::before { display: none; }

/* ---------- wallet ---------- */
.balance-card { border-left: 3px solid var(--brand); }
.balance-value { display: flex; align-items: baseline; gap: 6px; }
.balance-value strong { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-value span { font-size: 14px; color: var(--muted); }
.balance-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.balance-flash { animation: flash .9s ease; }
@keyframes flash { 0% { background: var(--brand-soft); } 100% { background: transparent; } }
.checkin-state { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.checkin-state.done { color: var(--ok); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 38px 16px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: 13px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sweep 1.2s infinite; }
@keyframes sweep { to { background-position: -200% 0; } }
.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.key-box {
  border: 1px dashed var(--brand); background: var(--brand-soft); border-radius: var(--radius-sm);
  padding: 12px; font-family: var(--mono); font-size: 13px; word-break: break-all;
}
.copy-line { display: flex; gap: 8px; align-items: center; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(8, 11, 18, .48); display: grid; grid-template-columns: minmax(0, 1fr);
  place-items: center; padding: 20px; z-index: 50;
}
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow: auto; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border);
}
.modal.wide { width: min(680px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  min-width: 240px; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--brand); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 11px 14px; font-size: 13px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 22px; text-align: center;
  color: var(--muted); cursor: pointer; font-size: 13px;
}
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone input { display: none; }
.preview { max-width: 100%; max-height: 200px; border-radius: 10px; border: 1px solid var(--border); margin-top: 12px; }
.result-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; margin-top: 14px; font-size: 13px; }
.result-text { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: .08em; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin: 18px 0 8px; }
.chart { width: 100%; height: 240px; display: block; }
.chart text { fill: var(--faint); font-size: 10.5px; font-family: var(--font); }

/* ---------- auth / guide ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-left {
  background: linear-gradient(150deg, #312e81 0%, #4f46e5 52%, #0f766e 100%);
  color: #fff; padding: 56px clamp(28px, 5vw, 72px); display: flex; flex-direction: column; justify-content: space-between;
}
.auth-left h1 { font-size: 32px; line-height: 1.25; max-width: 460px; }
.auth-left p { color: rgba(255, 255, 255, .78); margin-top: 14px; max-width: 440px; font-size: 14px; }
.auth-points { display: flex; flex-direction: column; gap: 10px; margin-top: 34px; font-size: 13px; color: rgba(255, 255, 255, .86); }
.auth-right { display: grid; place-items: center; padding: 32px 20px; min-width: 0; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { padding-left: 0; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--faint); text-align: center; }
.guide { max-width: 980px; margin: 0 auto; padding: 40px 20px 80px; }
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.guide-card { margin-bottom: 16px; }
.guide pre {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  overflow-x: auto; font-size: 12.5px; line-height: 1.6; margin: 10px 0 0;
}
.guide h2 { margin: 26px 0 10px; font-size: 19px; }
.guide h3 { margin: 16px 0 8px; }
.guide p, .guide li { color: var(--muted); font-size: 13.5px; }
.guide ul { padding-left: 20px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 899px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .main { padding-top: 18px; }
  .auth { grid-template-columns: 1fr; }
  .auth-left { display: none; }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2, .form-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .card-head { flex-wrap: wrap; align-items: flex-start; }
  .card-head > div:last-child:empty { display: none; }
  .guide table { min-width: 560px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ---------- landing ---------- */
.landing { max-width: 1120px; margin: 0 auto; padding: 24px clamp(18px, 4vw, 40px) 40px; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0 24px; flex-wrap: wrap; }
.landing-links { display: flex; align-items: center; gap: 16px; font-size: 13.5px; flex-wrap: wrap; }
.landing-links a:not(.btn) { color: var(--muted); }
.landing-links a:not(.btn):hover { color: var(--text); text-decoration: none; }
.hero { padding: clamp(20px, 5vw, 56px) 0 8px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--brand); text-transform: uppercase; margin-bottom: 14px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 44px); line-height: 1.2; letter-spacing: -.01em; max-width: 760px; }
.hero-lead { color: var(--muted); font-size: clamp(14px, 1.6vw, 16px); margin-top: 16px; max-width: 620px; }
.cta-row { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.landing-section { margin-top: clamp(32px, 5vw, 52px); }
.landing-section h2 { font-size: 20px; margin-bottom: 14px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-sm); }
.step-index { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.step h3 { margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 13px; }
.step code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.65; margin-top: 14px; }
.boundary-card h3 { margin-bottom: 10px; }
.plain-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 7px; }
.pricing-line { display: flex; align-items: center; gap: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; flex-wrap: wrap; }
.price-figure { display: flex; align-items: baseline; gap: 6px; }
.price-figure strong { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-figure span { color: var(--muted); font-size: 14px; }
.pricing-line p { color: var(--muted); font-size: 13.5px; max-width: 640px; }
.landing-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }
@media (max-width: 899px) {
  .steps { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
}
@media (max-width: 640px) {
  .landing-nav { align-items: flex-start; }
  .landing-links { width: 100%; }
  .hero h1 { font-size: 27px; }
  .cta-row .btn { width: 100%; }
  .landing-foot { flex-direction: column; }
}
