:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --raise: #f5f5f2;
  --raise-2: #ececE8;
  --line: #e4e3de;
  --text: #1c1c1e;
  --dim: #6e6e73;
  --faint: #a1a1a6;
  --ink: #1c1c1e;
  --ok: #1e7a4c;
  --ok-soft: #e3f3ea;
  --warn: #93600c;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe6e3;
  --info: #2f55b8;
  --info-soft: #e6ecfa;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214; --panel: #1b1b1e; --raise: #242428; --raise-2: #2e2e33; --line: #2f2f34;
    --text: #ececef; --dim: #a0a0a8; --faint: #6c6c74; --ink: #ececef;
    --ok: #5fcf95; --ok-soft: #173326; --warn: #f0b75a; --warn-soft: #352a13; --bad: #ff8a80; --bad-soft: #3a1d1b;
    --info: #8fb0ff; --info-soft: #1d2740;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.boot { padding: 80px; text-align: center; color: var(--dim); }
[hidden] { display: none !important; }

/* 按钮 / 表单 */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--raise); }
.btn.sm { height: 28px; padding: 0 11px; font-size: 13px; }
.input, select.input, textarea.input { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); outline: none; min-width: 0; }
textarea.input { height: auto; padding: 8px 12px; }
.input:focus { border-color: var(--ink); }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--dim); }
label.field .input { color: var(--text); }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 0 24px; height: 56px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tab { height: 32px; padding: 0 12px; border-radius: 999px; border: 0; background: none; cursor: pointer; color: var(--dim); white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--raise); }
.tab.on { color: var(--text); background: var(--panel); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.top .spacer { flex: 1; }
.cos { display: flex; gap: 6px; }
main { max-width: 1440px; margin: 0 auto; padding: 22px 24px 80px; }

/* 公司标签：和卡台客户卡面同色 */
.co { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--raise-2); color: var(--text); }
.co.gold { background: #f3e2bf; color: #6e4c0c; }
.co.ink { background: #1f1f21; color: #fff; }
.co.green { background: #d6efe2; color: #1d6b45; }
.co.blue { background: #dfe3ea; color: #3c4656; }
.co.rose { background: #f6dce2; color: #8a2f46; }
@media (prefers-color-scheme: dark) { .co.ink { background: #000; box-shadow: 0 0 0 1px #3a3a40; } }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; background: var(--raise); color: var(--dim); white-space: nowrap; }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.frozen { background: var(--info-soft); color: var(--info); }
.badge.cancelled, .badge.suspended, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.expired, .badge.inactive, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.agent { background: #efe6fb; color: #6b3fa0; }
@media (prefers-color-scheme: dark) { .badge.agent { background: #2c2140; color: #c8a8f5; } }

/* 面板 / 表格 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { position: relative; flex: 1 1 360px; display: flex; }
.search .input { width: 100%; height: 42px; padding: 0 16px; border-radius: 12px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; color: var(--dim); white-space: nowrap; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip b { font-weight: 600; margin-left: 4px; }
.chip-label { font-size: 12px; color: var(--faint); margin: 0 2px 0 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--faint); position: sticky; top: 0; background: var(--panel); }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--raise); }
tbody tr.sel { background: color-mix(in srgb, var(--info-soft) 70%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.cb, th.cb { width: 36px; padding-right: 0; }
.nick { max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.sub { font-size: 12px; color: var(--dim); }
.empty { padding: 48px; text-align: center; color: var(--dim); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; color: var(--dim); font-size: 13px; }
.meter { height: 4px; border-radius: 99px; background: var(--raise-2); overflow: hidden; margin-top: 5px; width: 120px; }
.meter i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.meter i.hot { background: var(--bad); }
.over { color: var(--bad); font-weight: 600; }

/* 批量条 */
.batch { position: sticky; bottom: 18px; z-index: 15; margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px 10px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); width: fit-content; max-width: 100%; }
.batch .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.batch .btn.danger { color: #ff9b92; }

/* 卡号查找结果 */
.found { margin-bottom: 14px; padding: 14px 16px; }
.found h3 { margin: 0 0 8px; font-size: 14px; }

/* 抽屉 */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .28); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(620px, 100%); background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; box-shadow: var(--shadow); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 10px; padding: 18px 22px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; word-break: break-all; }
.drawer-body { padding: 18px 22px 40px; display: grid; gap: 14px; }
.section { padding: 16px; }
.section h3 { margin: 0 0 10px; font-size: 13px; color: var(--dim); font-weight: 600; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--raise); }
.stat .l { font-size: 12px; color: var(--dim); }
.stat .v { font-size: 18px; margin-top: 2px; letter-spacing: -.02em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.note { font-size: 12.5px; color: var(--dim); line-height: 1.6; }
.note.warn { color: var(--warn); }

/* 卡面 */
.cardface { position: relative; border-radius: 18px; padding: 20px 22px; min-height: 168px; color: #fff; background: linear-gradient(135deg, #2b2b30, #0f0f12); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.cardface.gold { background: linear-gradient(135deg, #d9bd84, #a8814a); color: #2a1d06; }
.cardface .pan { font-size: 21px; letter-spacing: .08em; }
.cardface .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; font-size: 13px; }
.cardface .lbl { font-size: 10.5px; opacity: .7; text-transform: uppercase; letter-spacing: .08em; }
.cardface .copy { cursor: pointer; border-bottom: 1px dashed currentColor; }
.cardface .t { font-size: 12px; opacity: .8; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .35); }
.modal-box { width: min(460px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.modal-box h3 { margin: 0; font-size: 17px; }
.modal-box .foot { display: flex; justify-content: flex-end; gap: 8px; }

/* 概览 */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.co-card { padding: 18px; display: grid; gap: 14px; }
.co-card .head { display: flex; align-items: center; gap: 8px; }
.co-card .head h3 { margin: 0; font-size: 16px; }
.capbar { height: 8px; border-radius: 99px; background: var(--raise-2); overflow: hidden; display: flex; }
.capbar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--dim); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; background: var(--c); }
.list-rows { display: grid; gap: 6px; font-size: 13.5px; }
.list-rows div { display: flex; justify-content: space-between; gap: 12px; }

/* 登录 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; }
.qr svg { width: 180px; height: 180px; }
.err { color: var(--bad); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 720px) {
  .top { padding: 0 14px; gap: 10px; }
  .cos { display: none; }
  main { padding: 16px 14px 80px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .drawer-body, .drawer-head { padding-left: 16px; padding-right: 16px; }
  .hide-sm { display: none; }
}
