/* =====================================================================
   资源兑换中心 · 后台样式
   ===================================================================== */
:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #14161a;
    --ink-2: #4a4f57;
    --ink-3: #868d98;
    --line: #e8eaee;
    --accent: #2b59ff;
    --accent-soft: #eef2ff;
    --ok: #0f9960;
    --ok-soft: #e9f8f0;
    --warn: #b7791f;
    --warn-soft: #fdf6e7;
    --err: #d93b3b;
    --err-soft: #fdecec;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--line);
}
.brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 600;
    font-size: 16px;
}
.brand strong { display: block; font-size: 14px; letter-spacing: .2px; }
.brand small { color: var(--ink-3); font-size: 12px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--ink-2);
    font-size: 13.5px;
    margin-bottom: 2px;
}
.nav-item:hover { background: #f3f4f7; text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-icon { width: 16px; text-align: center; opacity: .85; }

.sidebar-foot { padding: 14px 16px 18px; border-top: 1px solid var(--line); }
.whoami { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar-dot {
    width: 30px; height: 30px; border-radius: 50%;
    background: #eef0f4; color: var(--ink-2);
    display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.whoami strong { display: block; font-size: 13px; }
.whoami small { color: var(--ink-3); font-size: 11.5px; }
.logout { font-size: 12.5px; color: var(--ink-3); }
.logout:hover { color: var(--err); }

/* ---------------- 主区域 ---------------- */
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.topbar {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.topbar-meta { color: var(--ink-3); font-size: 12.5px; }

.flash {
    padding: 11px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: #0b6b45; border-color: #cdeedd; }
.flash-err { background: var(--err-soft); color: #9c2626; border-color: #f7d4d4; }

/* ---------------- 卡片 ---------------- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-head .sub { color: var(--ink-3); font-size: 12.5px; }

.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)); }
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: 18px 16px 40px; }
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.stat .label { color: var(--ink-3); font-size: 12.5px; margin-bottom: 6px; }
.stat .value { font-size: 24px; font-weight: 600; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.stat.accent .value { color: var(--accent); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left; color: var(--ink-3); font-weight: 500; font-size: 12.5px;
    padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
    background: #fafbfc;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid #f1f2f5; vertical-align: middle; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-3); }
.right { text-align: right; }
.center { text-align: center; }

/* ---------------- 徽标 ---------------- */
.tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11.5px; line-height: 1.7; white-space: nowrap;
    background: #f0f2f5; color: var(--ink-2);
}
.tag-blue { background: var(--accent-soft); color: #2347cc; }
.tag-green { background: var(--ok-soft); color: #0b6b45; }
.tag-amber { background: var(--warn-soft); color: #8a5a12; }
.tag-red { background: var(--err-soft); color: #9c2626; }
.tag-gray { background: #f1f2f5; color: #6b7280; }

/* ---------------- 表单 ---------------- */
.form-row { margin-bottom: 16px; }
.form-row > label {
    display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500;
}
.form-row .help { color: var(--ink-3); font-size: 12px; margin-top: 5px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid #dfe2e8; border-radius: 9px;
    font-size: 13.5px; color: var(--ink); background: #fff;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: #9db2ff; box-shadow: 0 0 0 3px rgba(43, 89, 255, .1);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } }

.switch { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); }
.switch input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border-radius: 9px; border: 1px solid transparent;
    font-size: 13.5px; cursor: pointer; font-family: inherit;
    background: var(--accent); color: #fff; transition: filter .15s;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: #dfe2e8; }
.btn-ghost:hover { background: #f7f8fa; color: var(--ink); }
.btn-danger { background: #fff; color: var(--err); border-color: #f0cdcd; }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="text"], .toolbar select { width: auto; min-width: 150px; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; font-size: 13px; }
.pager a, .pager span {
    padding: 5px 11px; border-radius: 7px; border: 1px solid var(--line);
    color: var(--ink-2); background: #fff;
}
.pager a:hover { background: #f5f6f8; text-decoration: none; }
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------- 空状态 ---------------- */
.empty { padding: 42px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* ---------------- 登录页 ---------------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: linear-gradient(180deg, #f7f8fb 0%, #eef1f7 100%);
}
.auth-card {
    width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
    border: 1px solid var(--line); padding: 30px 28px 26px;
    box-shadow: 0 12px 40px rgba(20, 22, 26, .06);
}
.auth-card h1 { font-size: 19px; margin: 0 0 4px; font-weight: 600; }
.auth-card .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.auth-error {
    background: var(--err-soft); color: #9c2626; border: 1px solid #f7d4d4;
    padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 16px;
}
.auth-card .btn { width: 100%; padding: 10px; margin-top: 6px; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ---------------- 其他 ---------------- */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.split { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.bar {
    height: 6px; border-radius: 999px; background: #eef0f4; overflow: hidden;
}
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.hr { height: 1px; background: var(--line); margin: 16px 0; }
.code-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; min-height: 160px; }
.inline-form { display: inline; }
