/* ============================================================
   卡密管理系统 · Key Manager 2.0
   Dense admin-tool styling, dual theme (dark / light),
   monospace where keys matter, big readable whiteboard.
   ============================================================ */

* { box-sizing: border-box; }

:root,
html[data-theme="dark"] {
    --bg-0: #0d1013;
    --bg-1: #14181d;
    --bg-2: #1b2026;
    --bg-3: #232a32;
    --bg-4: #2c343d;
    --line: #2a3138;
    --line-2: #384049;
    --text: #e6e9ee;
    --text-dim: #8d959f;
    --text-faint: #646c76;
    --accent: #10d9a3;
    --accent-2: #3ba8ff;
    --accent-ink: #06251c;
    --warn: #ffb020;
    --danger: #ff6b6b;
    --ok: #35d07f;
    --up: #10d9a3;
    --down: #ff8a5c;
    --shadow: 0 12px 32px rgba(0,0,0,.45);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
    --radius: 10px;
    --radius-sm: 7px;
}

html[data-theme="light"] {
    --bg-0: #f4f6f8;
    --bg-1: #ffffff;
    --bg-2: #f7f9fb;
    --bg-3: #eef2f6;
    --bg-4: #e3e9ef;
    --line: #dfe5ec;
    --line-2: #cdd6e0;
    --text: #1c2530;
    --text-dim: #5f6b7a;
    --text-faint: #8a95a3;
    --accent: #00b183;
    --accent-2: #1a86e0;
    --accent-ink: #ffffff;
    --warn: #d98800;
    --danger: #e04a4a;
    --ok: #12a35f;
    --up: #00a06f;
    --down: #e06a3a;
    --shadow: 0 12px 32px rgba(30,45,70,.14);
    --shadow-sm: 0 2px 8px rgba(30,45,70,.08);
}

html, body {
    margin: 0; padding: 0; height: 100%;
    background: var(--bg-0);
    color: var(--text);
    font: 13px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* The [hidden] attribute must always win, even over an explicit
   display:flex on overlays (.modal-host / .whiteboard / .overlay). */
[hidden] { display: none !important; }

.mono, input, textarea, code { font-family: ui-monospace, "SF Mono", "Cascadia Mono",
    Consolas, "Liberation Mono", Menlo, monospace; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.grow { flex: 1; }
.dim { color: var(--text-dim); }

/* ============================ top bar ============================ */
.topbar {
    height: 60px;
    display: flex; align-items: center; gap: 20px;
    padding: 0 16px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--line);
    position: relative; z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.logo {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-ink);
    display: grid; place-items: center;
    font-weight: 800; font-size: 17px;
    box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text .title { font-weight: 650; font-size: 14px; letter-spacing: .2px; }
.brand-text .subtitle { font-size: 10.5px; color: var(--text-faint); max-width: 260px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kpis { display: flex; gap: 6px; flex: 1; justify-content: center; }
.kpi {
    display: flex; flex-direction: column; align-items: center;
    padding: 4px 15px; border-radius: var(--radius-sm);
    background: var(--bg-2); border: 1px solid var(--line);
    min-width: 74px; transition: border-color .15s;
}
.kpi:hover { border-color: var(--line-2); }
.kpi-num { font-size: 17px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-num.up { color: var(--up); }
.kpi-num.down { color: var(--down); }
.kpi-lbl { font-size: 10px; color: var(--text-faint); letter-spacing: .3px; }
.kpi.warn .kpi-num { color: var(--warn); }

.top-actions { display: flex; gap: 6px; }

.icon-btn {
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 7px 12px;
    cursor: pointer; transition: all .14s; font-size: 12.5px; font-weight: 500;
}
.icon-btn:hover { background: var(--bg-3); border-color: var(--line-2); }
.icon-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ============================ layout ============================ */
.layout { display: flex; height: calc(100% - 60px); }

.sidebar {
    width: 296px; flex-shrink: 0;
    background: var(--bg-1);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
}

.side-search { padding: 12px 12px 8px; }
.side-search input {
    width: 100%; padding: 9px 12px;
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.side-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,217,163,.12); }

.side-filters { display: flex; gap: 6px; padding: 0 12px 8px; }
.side-filters select {
    flex: 1; padding: 6px 8px; font-size: 12px;
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: 6px; outline: none; cursor: pointer;
}

.side-meta {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px 8px; font-size: 11.5px; color: var(--text-dim);
}

.game-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }

.game-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; margin-bottom: 3px;
    border-radius: var(--radius-sm);
    cursor: pointer; transition: background .12s;
    border: 1px solid transparent;
}
.game-item:hover { background: var(--bg-2); }
.game-item.selected { background: var(--bg-3); border-color: var(--accent); }
.game-item.empty .g-name { color: var(--text-faint); }

.g-main { flex: 1; min-width: 0; }
.g-name {
    font-weight: 550; font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.g-type { font-size: 11px; color: var(--text-faint);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-count {
    font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
    padding: 2px 9px; border-radius: 20px;
    background: var(--bg-3); color: var(--text);
    min-width: 40px; text-align: center;
}
.g-count.zero { background: transparent; color: var(--text-faint); border: 1px dashed var(--line-2); }
.g-count.low { background: rgba(255,176,32,.16); color: var(--warn); }
.g-count.hit { box-shadow: 0 0 0 2px var(--accent-2); }

.side-empty { padding: 30px 16px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ============================ main ============================ */
.main { flex: 1; overflow-y: auto; position: relative; }

.empty-state {
    height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px;
    color: var(--text-dim); text-align: center;
}
.empty-logo {
    width: 76px; height: 76px; border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-ink); display: grid; place-items: center;
    font-size: 36px; font-weight: 800; margin-bottom: 10px; opacity: .92;
}
.empty-state h2 { margin: 0; font-size: 19px; color: var(--text); font-weight: 600; }
.empty-state p { margin: 0; font-size: 13px; }
.empty-tips { display: flex; gap: 18px; margin-top: 22px; font-size: 11.5px; color: var(--text-faint); }
.empty-tips b { color: var(--accent); font-family: ui-monospace, monospace; }

.game-view, .traffic-view { padding: 22px 26px 60px; }

.game-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 24px; margin-bottom: 18px;
}
.game-title h1 { margin: 0 0 5px; font-size: 22px; font-weight: 680; letter-spacing: -.2px; }
.game-sub { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.tag {
    padding: 2px 10px; border-radius: 20px; font-size: 11.5px;
    background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text-dim);
}
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); }

.game-stats { display: flex; gap: 10px; }
.gs {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 18px; border-radius: var(--radius-sm);
    background: var(--bg-1); border: 1px solid var(--line); min-width: 82px;
}
.gs b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gs span { font-size: 10.5px; color: var(--text-faint); }

.action-bar { display: flex; gap: 9px; margin-bottom: 16px; flex-wrap: wrap; }

.btn {
    padding: 9px 16px; border-radius: var(--radius-sm);
    background: var(--bg-3); border: 1px solid var(--line-2);
    cursor: pointer; font-weight: 550; font-size: 13px;
    transition: all .13s; white-space: nowrap;
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(1px); }
.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-ink); border-color: transparent; font-weight: 650;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-2); color: var(--text); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.lg { padding: 11px 20px; font-size: 13.5px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.line-toolbar {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 0; margin-bottom: 5px;
    border-bottom: 1px solid var(--line);
}

.seg { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px; }
.seg button {
    padding: 5px 14px; border: none; background: transparent;
    border-radius: 5px; cursor: pointer; font-size: 12px; color: var(--text-dim);
    font-weight: 550; transition: all .13s;
}
.seg button b { font-variant-numeric: tabular-nums; opacity: .8; margin-left: 3px; }
.seg button.active { background: var(--bg-4); color: var(--text); }

.mini-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; color: var(--text-dim); cursor: pointer; user-select: none;
}
.mini-toggle input { accent-color: var(--accent); cursor: pointer; }

/* ============================ line list ============================ */
.line-list { margin-top: 8px; }

.line {
    display: flex; align-items: center; gap: 11px;
    padding: 7px 11px; border-radius: 6px;
    border: 1px solid transparent;
    transition: background .1s;
}
.line:hover { background: var(--bg-1); }
.line.selected { background: var(--bg-2); border-color: var(--line-2); }

/* ---- drag-to-select (rubber band) ---- */
.rubber-box {
    position: fixed; z-index: 2000; pointer-events: none;
    border: 1px solid var(--accent);
    background: rgba(16,217,163,.14);
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(16,217,163,.25) inset;
}
body.rubber-active { user-select: none; -webkit-user-select: none; }
body.rubber-active .line .body { cursor: crosshair; }
body.rubber-active .line { user-select: none; }

.rubber-hint {
    display: flex; align-items: center; gap: 7px;
    margin: 6px 0 2px; font-size: 11.5px; color: var(--accent);
}
.rubber-hint .rb-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 8px var(--accent);
}

.line .chk { display: flex; align-items: center; }
.line .chk input { accent-color: var(--accent); cursor: pointer; }
.line .ln {
    width: 44px; flex-shrink: 0; text-align: right;
    color: var(--text-faint); font-size: 11px;
    font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
.line .body {
    flex: 1; min-width: 0;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 12.5px; line-height: 1.5;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: pointer;
}
.line .body:hover { white-space: normal; word-break: break-all; }
.line .k-acc { color: var(--accent-2); }
.line .k-pw { color: var(--warn); }
.line .k-code { color: var(--accent); font-weight: 700; }
.line .k-url { color: var(--text-faint); text-decoration: underline;
    text-decoration-color: var(--line-2); }
.line .kind-badge {
    font-size: 9.5px; padding: 1px 7px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: .4px; font-weight: 700;
    background: var(--bg-3); color: var(--text-dim); flex-shrink: 0;
}
.line .cat-badge {
    font-size: 9.5px; padding: 1px 7px; border-radius: 4px;
    font-weight: 700; flex-shrink: 0;
}
.kind-steam { background: rgba(59,168,255,.15); color: var(--accent-2); }
.kind-uplay { background: rgba(16,217,163,.15); color: var(--accent); }
.kind-microsoft { background: rgba(255,176,32,.15); color: var(--warn); }
.kind-ea { background: rgba(255,107,107,.15); color: var(--danger); }
.kind-member { background: rgba(150,120,255,.16); color: #a98cff; }
.kind-custom { background: var(--bg-3); color: var(--text-faint); }
.cat-coded { border: 1px solid var(--accent); color: var(--accent); }
.cat-plain { border: 1px solid var(--line-2); color: var(--text-faint); }
.cat-custom { border: 1px dashed var(--line-2); color: var(--text-faint); }

.line .acts { display: flex; gap: 4px; opacity: 0; transition: opacity .13s; }
.line:hover .acts { opacity: 1; }
.line .acts button {
    padding: 4px 10px; font-size: 11px; border-radius: 5px;
    background: var(--bg-3); border: 1px solid var(--line-2); cursor: pointer;
}
.line .acts button:hover { background: var(--bg-4); }
.line .acts button.del:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.placeholder { padding: 50px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* ============================ traffic ============================ */
.page-title { margin: 0 0 20px; font-size: 21px; font-weight: 680; }

.traffic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 14px; }

.panel {
    background: var(--bg-1); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
}
.panel h3 { margin: 0 0 14px; font-size: 13px; font-weight: 620; color: var(--text-dim); letter-spacing: .3px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }

.chart { height: 150px; display: flex; align-items: flex-end; gap: 4px; padding-top: 8px; }
.chart .bar {
    flex: 1; min-width: 8px; border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    position: relative; transition: filter .15s; min-height: 3px;
}
.chart .bar:hover { filter: brightness(1.2); }
.chart .bar .lbl {
    position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%);
    font-size: 9px; color: var(--text-faint); white-space: nowrap;
}
.chart .bar[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; bottom: 100%; left: 50%;
    transform: translateX(-50%); margin-bottom: 6px;
    background: var(--bg-4); color: var(--text); padding: 4px 8px;
    border-radius: 5px; font-size: 11px; white-space: nowrap; z-index: 5;
    box-shadow: var(--shadow-sm);
}

.by-action { display: flex; flex-direction: column; gap: 9px; }
.by-action .row { display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px; background: var(--bg-2); border-radius: 6px; }
.by-action .a { font-size: 12.5px; font-weight: 550; }
.by-action .v { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.mini-list { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
.mini-list .mi {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 9px; border-radius: 5px; cursor: pointer; font-size: 12px;
}
.mini-list .mi:hover { background: var(--bg-2); }
.mini-list .mi .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .mi .c { font-variant-numeric: tabular-nums; color: var(--warn); font-weight: 650; }
.mini-list .mi .c.zero { color: var(--danger); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 10.5px;
    background: var(--bg-3); color: var(--text-dim); font-weight: 700; }
.warn-badge { background: rgba(255,176,32,.18); color: var(--warn); }

.top-games { display: flex; flex-direction: column; gap: 4px; }
.tg-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
    padding: 7px 11px; border-radius: 6px; cursor: pointer; }
.tg-row:hover { background: var(--bg-2); }
.tg-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-row .nm .ty { color: var(--text-faint); font-size: 11.5px; }
.tg-bar { height: 5px; border-radius: 3px; background: var(--bg-3); overflow: hidden; width: 90px; }
.tg-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tg-row .c { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 46px; text-align: right; }

.log-filter { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
    padding: 4px 12px; border-radius: 20px; font-size: 11.5px;
    background: var(--bg-2); border: 1px solid var(--line);
    cursor: pointer; color: var(--text-dim); transition: all .13s;
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }

.table-wrap { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.log-table th {
    text-align: left; padding: 9px 11px; color: var(--text-faint);
    font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 1px solid var(--line);
}
.log-table td { padding: 8px 11px; border-bottom: 1px solid var(--line); }
.log-table tr:hover td { background: var(--bg-2); }
.act { padding: 2px 9px; border-radius: 4px; font-size: 11px; font-weight: 650; }
.act-extract { background: rgba(255,176,32,.16); color: var(--warn); }
.act-generate { background: rgba(16,217,163,.16); color: var(--accent); }
.act-import { background: rgba(59,168,255,.16); color: var(--accent-2); }
.act-edit { background: rgba(150,120,255,.16); color: #a98cff; }
.act-delete { background: rgba(255,107,107,.16); color: var(--danger); }
.act-return { background: rgba(53,208,127,.16); color: var(--ok); }

/* ============================ whiteboard ============================ */
.whiteboard {
    position: fixed; inset: 0; z-index: 100;
    background: var(--bg-0);
    display: flex; flex-direction: column;
    animation: wb-in .16s ease-out;
}
@keyframes wb-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

.wb-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px; border-bottom: 1px solid var(--line);
    background: var(--bg-1);
}
.wb-title { display: flex; align-items: center; gap: 9px; font-weight: 620; font-size: 14px; }
.wb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 10px var(--accent); }
.wb-info { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.wb-toggle { padding: 5px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; }

.wb-text {
    flex: 1; width: 100%; resize: none; border: none; outline: none;
    padding: 26px 34px;
    background: var(--bg-0); color: var(--text);
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
    font-size: 15px; line-height: 1.85;
    white-space: pre; overflow: auto;
    selection-background-color: var(--accent);
}
.wb-text::selection { background: var(--accent); color: var(--accent-ink); }

.wb-foot {
    padding: 9px 18px; border-top: 1px solid var(--line);
    background: var(--bg-1); font-size: 11.5px; color: var(--text-faint);
    display: flex; align-items: center; gap: 8px;
}

/* ====================== dual whiteboard (cards + serials) ====================== */
.dual-wb {
    position: fixed; inset: 0; z-index: 110;
    background: var(--bg-0);
    display: flex; flex-direction: column;
    animation: wb-in .16s ease-out;
}

.dwb-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; border-bottom: 1px solid var(--line);
    background: var(--bg-1);
}
.dwb-bar .wb-info { margin-right: auto; }

.dwb-body {
    flex: 1; display: grid; grid-template-columns: 1fr 1fr;
    gap: 1px; background: var(--line); min-height: 0;
}

.dwb-col {
    display: flex; flex-direction: column; min-width: 0; min-height: 0;
    background: var(--bg-0);
}

.dwb-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 9px 16px;
    background: var(--bg-1); border-bottom: 1px solid var(--line);
}
.dwb-head-l { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.dwb-head-l .dim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dwb-head-r { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn.tiny { padding: 3px 9px; font-size: 11px; border-radius: 6px; }
.btn.tiny:hover { border-color: var(--accent); color: var(--accent); }
.dwb-tag {
    font-size: 11.5px; font-weight: 620; letter-spacing: .2px;
    padding: 3px 9px; border-radius: 999px;
}
.dwb-tag.cards { background: rgba(16,217,163,.14); color: var(--accent); }
.dwb-tag.codes { background: rgba(59,168,255,.14); color: var(--accent-2); }

.dwb-text {
    flex: 1; min-height: 0;
    padding: 18px 20px;
    font-size: 13.5px; line-height: 1.8;
}
.dwb-text.code-only {
    font-size: 16px; line-height: 2.1; letter-spacing: .6px;
}

@media (max-width: 900px) {
    .dwb-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* batch whiteboard picker */
.batch-tools { display: flex; gap: 8px; align-items: center; margin: 6px 0 12px; }
.batch-filter { flex: 1; }
.batch-list {
    max-height: 320px; overflow: auto; margin-top: 12px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2);
}
.batch-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px;
}
.batch-row:last-child { border-bottom: none; }
.batch-row:hover { background: var(--bg-3); }
.batch-row .bn { flex: 1; }
.batch-row .bc {
    font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600;
}

/* ============================ traffic flow ============================ */
.flow-cards {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px;
}
.flow-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px 18px;
}
.flow-card .fc-ico {
    width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; background: var(--bg-3);
}
.flow-card.in .fc-ico { background: rgba(79,157,255,.16); color: #4f9dff; }
.flow-card.out .fc-ico { background: rgba(255,107,107,.16); color: #ff6b6b; }
.flow-card.net .fc-ico { background: rgba(53,208,127,.16); color: #35d07f; }
.flow-card.today .fc-ico { background: rgba(255,196,84,.16); color: #ffc454; }
.flow-card .fc-num {
    font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.flow-card .fc-num.pos { color: #35d07f; }
.flow-card .fc-num.neg { color: #ff6b6b; }
.flow-card .fc-lbl { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

.dim-hint { font-size: 11.5px; color: var(--text-faint); font-weight: 400; margin-left: 8px; }

.flow-chart {
    display: flex; align-items: flex-end; gap: 6px; height: 190px;
    padding: 16px 4px 0; overflow-x: auto;
}
.fc-col {
    display: flex; flex-direction: column; align-items: center;
    flex: 1 0 26px; min-width: 26px; height: 100%;
}
.fc-bars {
    display: flex; align-items: flex-end; gap: 3px; flex: 1; width: 100%;
    justify-content: center;
}
.fc-bar {
    width: 8px; border-radius: 3px 3px 0 0; transition: opacity .15s;
    position: relative;
}
.fc-bar.in { background: #4f9dff; }
.fc-bar.out { background: #ff6b6b; }
.fc-bar:hover { opacity: .72; }
.fc-day {
    font-size: 10px; color: var(--text-faint); margin-top: 6px;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}

.accent-btn { color: var(--accent); border-color: var(--accent); }

.ver-tag {
    font-size: 10px; padding: 3px 7px; border-radius: 5px; align-self: center;
    background: var(--bg-2); border: 1px solid var(--line);
    color: var(--text-faint); font-family: ui-monospace, Consolas, monospace;
    cursor: help;
}

/* ============================ history / undo ============================ */
.undo-panel { background: linear-gradient(135deg, var(--bg-1), var(--bg-2)); }
.undo-head { display: flex; align-items: center; gap: 18px; }
.undo-ico {
    width: 52px; height: 52px; border-radius: 13px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; background: rgba(16,217,163,.15); color: var(--accent);
}
.undo-text { flex: 1; }
.undo-text h3 { margin: 0 0 4px; font-size: 15px; }
.undo-text p { margin: 0; font-size: 12px; color: var(--text-faint); }
.undo-meta {
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
    font-size: 11.5px; color: var(--text-faint);
}

.snap-list { display: flex; flex-direction: column; }
.snap-row {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 16px;
    padding: 13px 6px; border-bottom: 1px solid var(--line);
    align-items: center;
}
.snap-row:last-child { border-bottom: none; }
.snap-row.undone { opacity: .5; }
.snap-main { display: flex; align-items: center; gap: 9px; }
.snap-label { font-size: 13.5px; font-weight: 550; }
.snap-tag {
    font-size: 10px; padding: 2px 7px; border-radius: 5px;
    background: var(--bg-3); color: var(--text-faint);
}
.snap-sub { grid-column: 1; font-size: 11px; color: var(--text-faint); }
.snap-files { grid-column: 1; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.fchip {
    font-size: 10.5px; padding: 2px 8px; border-radius: 5px;
    background: var(--bg-2); border: 1px solid var(--line);
    color: var(--text-dim); font-family: ui-monospace, Consolas, monospace;
}
.fchip.dim { color: var(--text-faint); }
.snap-acts { grid-column: 2; grid-row: 1 / 4; display: flex; gap: 8px; align-items: center; }

.toast-act {
    margin-left: 12px; padding: 4px 12px; border-radius: 6px;
    background: var(--accent); color: var(--accent-ink);
    border: none; font-size: 12px; font-weight: 600; cursor: pointer;
}
.toast-act:hover { filter: brightness(1.1); }

/* ============================ find overlay ============================ */
.overlay {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
    display: flex; justify-content: center; padding-top: 8vh;
    animation: wb-in .13s ease-out;
}
.find-box {
    width: min(760px, 92vw); max-height: 76vh;
    background: var(--bg-1); border: 1px solid var(--line-2);
    border-radius: 14px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; overflow: hidden;
}
.find-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
    border-bottom: 1px solid var(--line); }
.find-icon { font-size: 18px; color: var(--text-faint); }
.find-input-row input { flex: 1; border: none; background: transparent; outline: none; font-size: 15px; }
.find-hint { padding: 10px 16px; font-size: 11.5px; color: var(--text-faint); border-bottom: 1px solid var(--line); }
.find-results { flex: 1; overflow-y: auto; padding: 8px; }

.fr-section { padding: 8px 8px 4px; font-size: 11px; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: .5px; font-weight: 650; }
.fr-game, .fr-key {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: 7px; cursor: pointer;
}
.fr-game:hover, .fr-key:hover { background: var(--bg-2); }
.fr-game .n { flex: 1; }
.fr-game .c { font-size: 11.5px; color: var(--text-dim); }
.fr-key { align-items: flex-start; }
.fr-key .kc { flex: 1; min-width: 0; }
.fr-key .kline { font-family: ui-monospace, monospace; font-size: 12px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-key .kmeta { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.fr-key .kmeta .where { color: var(--accent-2); }
.fr-key .kacts { display: flex; gap: 5px; }
.fr-key .kacts button { padding: 4px 10px; font-size: 11px; border-radius: 5px;
    background: var(--bg-3); border: 1px solid var(--line-2); cursor: pointer; }
.fr-key mark, .fr-game mark { background: rgba(255,176,32,.3); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ============================ modal ============================ */
.modal-host { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.modal {
    position: relative; width: min(560px, 94vw); max-height: 90vh;
    background: var(--bg-1); border: 1px solid var(--line-2);
    border-radius: 14px; box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    animation: wb-in .15s ease-out;
}
.modal.wide { width: min(900px, 95vw); }
.modal > header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    font-weight: 640; font-size: 14.5px;
}
.modal .close { background: transparent; border: none; font-size: 22px;
    color: var(--text-faint); cursor: pointer; line-height: 1; padding: 0 4px; }
.modal .close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body label { display: block; margin-bottom: 15px; }
.modal-body label > span { display: block; margin-bottom: 6px; font-size: 12px;
    color: var(--text-dim); font-weight: 550; }
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body textarea,
.modal-body select {
    width: 100%; padding: 9px 12px;
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm); outline: none; transition: border-color .15s;
}
.modal-body input:focus, .modal-body textarea:focus, .modal-body select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,217,163,.12); }
.modal-body textarea { resize: vertical; font-size: 12.5px; line-height: 1.6; min-height: 90px; }
.modal-body .row { display: flex; align-items: center; gap: 9px; }
.modal-body .row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.modal-body .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-body .hint { font-size: 11.5px; color: var(--text-faint); margin-top: -8px; margin-bottom: 14px; }

.kind-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.kind-picker.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .kind-picker.four { grid-template-columns: repeat(2, 1fr); } }
.kind-opt {
    padding: 11px 10px; border-radius: var(--radius-sm); text-align: center;
    background: var(--bg-2); border: 1px solid var(--line); cursor: pointer;
    transition: all .13s; font-size: 12px;
}
.kind-opt:hover { border-color: var(--line-2); }
.kind-opt.active { border-color: var(--accent); background: rgba(16,217,163,.1); }
.kind-opt .ko-t { font-weight: 620; }
.kind-opt .ko-d { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }

/* account-pool distribution preview */
.dist-preview {
    margin: 2px 0 14px; padding: 10px 11px; border-radius: var(--radius-sm);
    background: var(--bg-2); border: 1px dashed var(--line-2);
}
.dist-preview .dp-title { font-size: 11px; color: var(--text-faint); margin-bottom: 7px; }
.dist-preview .dp-row { display: flex; flex-wrap: wrap; gap: 6px; }
.dist-preview .dp-cell {
    font-size: 11px; font-family: var(--mono, ui-monospace, monospace);
    padding: 3px 8px; border-radius: 5px; background: var(--bg-1);
    border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap;
}
.dist-preview .dp-cell b { color: var(--accent); font-weight: 700; margin-right: 5px; }
.dist-preview .dp-cell:nth-child(odd) { border-color: rgba(16, 217, 163, .45); }
.dist-preview .dp-cell:nth-child(even) { border-color: rgba(99, 102, 241, .45); }
.dist-preview .dp-more {
    font-size: 11px; color: var(--text-faint); align-self: center; padding-left: 2px;
}

.modal > footer {
    display: flex; justify-content: flex-end; gap: 9px;
    padding: 14px 20px; border-top: 1px solid var(--line);
}

.result-box {
    margin-top: 14px; padding: 13px 15px; border-radius: var(--radius-sm);
    background: var(--bg-0); border: 1px solid var(--line);
    font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.65;
    white-space: pre-wrap; word-break: break-all;
    max-height: 240px; overflow-y: auto;
}
.result-box .ok-tag { color: var(--ok); font-weight: 700; }

/* ============================ toast ============================ */
.toast-host { position: fixed; bottom: 22px; right: 22px; z-index: 200;
    display: flex; flex-direction: column; gap: 9px; }
.toast {
    padding: 12px 18px; border-radius: var(--radius-sm);
    background: var(--bg-3); border: 1px solid var(--line-2);
    box-shadow: var(--shadow); font-size: 12.5px; font-weight: 550;
    animation: toast-in .2s ease-out; transition: opacity .25s;
    border-left: 3px solid var(--accent-2); max-width: 340px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ============================ responsive ============================ */
@media (max-width: 900px) {
    .kpis { display: none; }
    .sidebar { width: 220px; }
    .game-stats { display: none; }
}

/* ============================ auth / roles ============================ */

/* ---- login gate ---- */
.login-gate {
    position: fixed; inset: 0; z-index: 500;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background:
        radial-gradient(1100px 560px at 50% -12%, rgba(16,217,163,.13), transparent 62%),
        var(--bg-0);
}
.login-card {
    width: 100%; max-width: 348px; padding: 34px 30px 26px;
    background: var(--bg-1); border: 1px solid var(--line-2);
    border-radius: 16px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-logo {
    width: 60px; height: 60px; border-radius: 17px; margin-bottom: 14px;
    display: grid; place-items: center; font-size: 28px; font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-ink); box-shadow: 0 8px 22px rgba(16,217,163,.28);
}
.login-card h2 { margin: 0; font-size: 19px; font-weight: 680; letter-spacing: -.2px; }
.login-sub { margin: 6px 0 22px; font-size: 12px; color: var(--text-faint); }
.login-card form { width: 100%; display: flex; flex-direction: column; gap: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-card label > span { font-size: 11.5px; color: var(--text-dim); }
.login-card input {
    width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
    background: var(--bg-0); border: 1px solid var(--line-2); color: var(--text);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16,217,163,.14);
}
.login-btn { width: 100%; margin-top: 4px; justify-content: center; }
.login-error {
    padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px;
    background: rgba(255,107,107,.10); border: 1px solid rgba(255,107,107,.4);
    color: var(--danger); text-align: left;
}
.login-foot { margin-top: 18px; font-size: 10.5px; color: var(--text-faint); letter-spacing: .02em; }

/* ---- user chip in the top bar ---- */
.user-chip {
    display: flex; align-items: center; gap: 7px; align-self: center;
    padding: 3px 4px 3px 3px; border-radius: 999px;
    background: var(--bg-2); border: 1px solid var(--line);
}
.uc-avatar {
    width: 25px; height: 25px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-size: 11px; font-weight: 700;
    background: var(--accent); color: var(--accent-ink);
}
.uc-meta { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.uc-name { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.uc-role { font-size: 9.5px; letter-spacing: .05em; }
.uc-role.admin { color: var(--accent-2); }
.uc-role.staff { color: var(--warn); }
.uc-logout {
    border: 1px solid var(--line-2); background: transparent; color: var(--text-dim);
    font-size: 10.5px; padding: 3px 9px; border-radius: 999px; cursor: pointer;
    transition: color .15s, border-color .15s;
}
.uc-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ---- staff quota chip ---- */
.quota-chip {
    display: flex; align-items: center; gap: 5px; align-self: center;
    padding: 4px 11px; border-radius: 999px; font-size: 11px;
    background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text-dim);
    white-space: nowrap; cursor: default;
}
.quota-chip .qc-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}
.quota-chip b { color: var(--accent); font-variant-numeric: tabular-nums; }
.quota-chip .qc-slash { opacity: .45; }
.quota-chip .qc-used { opacity: .7; margin-left: 5px; }
.quota-chip.low { border-color: var(--warn); }
.quota-chip.low .qc-dot { background: var(--warn); }
.quota-chip.low b { color: var(--warn); }
.quota-chip.empty { border-color: var(--danger); }
.quota-chip.empty .qc-dot { background: var(--danger); }
.quota-chip.empty b { color: var(--danger); }

/* ---- staff simplified panel (replaces the raw key list) ---- */
.staff-panel {
    display: none; flex-direction: column; align-items: center; text-align: center;
    gap: 10px; padding: 52px 24px; margin: 8px 0;
    border: 1px dashed var(--line-2); border-radius: var(--radius);
    background: var(--bg-1);
}
body.role-staff .staff-panel { display: flex; }
.sp-icon { font-size: 30px; opacity: .85; }
.staff-panel h3 { margin: 0; font-size: 16px; font-weight: 650; }
.staff-panel p { margin: 0; font-size: 12.5px; color: var(--text-dim); max-width: 470px; }
.staff-panel p b { color: var(--accent); }
.staff-panel .sp-dim { color: var(--text-faint); font-size: 12px; }

/* ---- role based visibility ---- */
body.role-staff [data-admin-only] { display: none !important; }
body.role-staff .line-toolbar,
body.role-staff #line-list,
body.role-staff #rubber-hint { display: none !important; }

.empty-tips.staff-only,
.staff-only-line { display: none !important; }
body.role-staff .empty-tips.staff-only { display: flex !important; }
body.role-staff .staff-only-line { display: block !important; }
