:root {
    --primary: #3b6cff;
    --primary-dark: #2b56d6;
    --primary-soft: #eaf0ff;
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #1f2430;
    --text-2: #6b7280;
    --text-3: #9aa1ad;
    --border: #e6e9f0;
    --danger: #e5484d;
    --success: #12b76a;
    --warning: #f79009;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 6px 24px rgba(30, 41, 82, .08);
    --shadow-sm: 0 2px 8px rgba(30, 41, 82, .06);
    --mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 通用组件 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    background: var(--primary); color: #fff; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c93b40; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon { padding: 7px; width: 34px; height: 34px; }

.input, .select, .textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: #fff; color: var(--text);
    outline: none; transition: .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 96px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; font-weight: 600; color: var(--text-2); font-size: 13px; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }

.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); }
.tag {
    display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
    background: var(--primary-soft); color: var(--primary-dark); font-weight: 600;
}
.tag.gray { background: #eef0f4; color: var(--text-2); }
.tag.red { background: #fdecec; color: var(--danger); }
.tag.green { background: #e7f8f0; color: var(--success); }

/* ---------- 登录/注册 ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background: linear-gradient(135deg, #eef2ff 0%, #f7f9ff 40%, #eefaf6 100%);
}
.auth-card {
    width: 100%; max-width: 400px; background: #fff; border-radius: 20px;
    box-shadow: var(--shadow); padding: 34px 30px;
}
.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-card .brand .logo { width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.auth-card h1 { font-size: 21px; margin: 0; }
.auth-card .sub { color: var(--text-2); margin: 4px 0 24px; font-size: 13px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--text-2); font-size: 13px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px; flex: 0 0 232px; background: #fff; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; font-weight: 800; font-size: 16px; }
.sidebar .brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    color: var(--text-2); font-weight: 600; margin-bottom: 2px; transition: .12s;
}
.nav a:hover { background: #f4f6fb; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav a .ico { width: 18px; text-align: center; }
.sidebar .userbox { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 34px; }
.sidebar .userbox .name { font-weight: 700; font-size: 13px; }
.sidebar .userbox .name small { display: block; color: var(--text-3); font-weight: 500; font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px; padding: 16px 26px;
    background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 18px; flex: 1; }
.topbar .search { max-width: 280px; }
.content { padding: 24px 26px 60px; }

/* ---------- 账号卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.acc-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; position: relative; transition: box-shadow .15s, transform .15s; }
.acc-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.acc-head { display: flex; align-items: center; gap: 12px; }
.acc-head .issuer-logo { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex: 0 0 42px; font-size: 17px; }
.acc-head .meta { min-width: 0; }
.acc-head .meta .t { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-head .meta .s { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-code-row { display: flex; align-items: center; gap: 14px; }
.acc-code { font-family: var(--mono); font-size: 33px; font-weight: 700; letter-spacing: 3px; color: var(--text); }
.acc-code .sep { color: var(--text-3); }
.ring { position: relative; width: 44px; height: 44px; flex: 0 0 44px; }
.ring svg { transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--text-2); }
.acc-actions { display: flex; gap: 8px; margin-left: auto; }
.grow { flex: 1; }
.empty { text-align: center; padding: 70px 20px; color: var(--text-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { color: var(--text-2); font-size: 12px; font-weight: 700; background: #fafbfe; }
table.tbl tr:hover td { background: #fafbff; }

/* ---------- 模态框 ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(20, 26, 45, .45); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
    width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; background: #fff;
    border-radius: 18px; box-shadow: 0 24px 60px rgba(20,26,45,.28);
    transform: translateY(8px); transition: transform .18s;
}
.modal-mask.show .modal { transform: translateY(0); }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.modal .close { border: none; background: none; font-size: 22px; color: var(--text-3); cursor: pointer; line-height: 1; }

/* ---------- Toast ---------- */
.toast-box { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
    padding: 11px 18px; border-radius: 10px; background: #222; color: #fff; font-size: 14px;
    box-shadow: var(--shadow); animation: drop .2s ease; max-width: 90vw;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #2b3142; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- QR ---------- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; background: #f8faff; border-radius: 12px; }
.qr-box img, .qr-box canvas { border-radius: 8px; background: #fff; }
.qr-hint { color: var(--text-2); font-size: 12px; text-align: center; }

/* ---------- 其它 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 20px; }
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.section-title { font-weight: 700; font-size: 15px; margin: 26px 0 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--border); cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 13px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 16px; color: var(--text-2); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.hamburger { display: none; }

@media (max-width: 860px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .hamburger { display: inline-flex; }
    .acc-code { font-size: 28px; }
    .topbar .search { display: none; }
}
