/* 运营后台公共样式（S6-6.4 / 6.5）
   零依赖：不引任何 CDN，字体用系统字体，图标用字符，离线也能正常显示。 */

:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --line: #e3e8ef;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --ok: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Microsoft YaHei", "PingFang SC", sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
    background: #111827;
    color: #f9fafb;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: #9ca3af; font-size: 13px; }
.topbar a.navlink {
    color: #d1d5db; text-decoration: none; font-size: 13px;
    padding: 6px 10px; border-radius: 6px;
}
.topbar a.navlink:hover { background: #1f2937; color: #fff; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
    padding: 9px 16px; cursor: pointer; border: 0; background: none;
    color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.pane { display: none; }
.pane.on { display: block; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow);
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.5px; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card.ok   .v { color: var(--ok); }
.card.warn .v { color: var(--warn); }
.card.bad  .v { color: var(--bad); }

.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.panel h3 .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
input, select, textarea {
    padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 14px; background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { min-width: 130px; }

button {
    padding: 8px 16px; border: 1px solid var(--line); background: #fff;
    border-radius: 6px; cursor: pointer; font-size: 14px; font-family: inherit;
    color: var(--text);
}
button:hover { background: #f9fafb; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { background: #fff; border-color: #fecaca; color: var(--bad); }
button.danger:hover { background: #fef2f2; }
button.sm { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfc; }
tbody tr:hover { background: #f9fafb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.tag {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 12px; background: #f3f4f6; color: var(--muted);
}
.tag.ok   { background: #dcfce7; color: #15803d; }
.tag.bad  { background: #fee2e2; color: #b91c1c; }
.tag.warn { background: #fef3c7; color: #b45309; }
.tag.info { background: #dbeafe; color: #1d4ed8; }

/* ---------- 其他 ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; }

.toast {
    position: fixed; right: 20px; bottom: 20px; z-index: 99;
    display: flex; flex-direction: column; gap: 8px;
}
.toast div {
    background: #111827; color: #fff; padding: 10px 16px; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .2); font-size: 13px; max-width: 380px;
}
.toast div.err { background: #b91c1c; }
.toast div.ok { background: #15803d; }
.toast div.warn { background: #b45309; }

/* 登录遮罩 */
.login-mask {
    position: fixed; inset: 0; background: var(--bg); display: flex;
    align-items: center; justify-content: center; z-index: 50;
}
.login-box {
    background: #fff; padding: 28px 32px; border-radius: 10px;
    box-shadow: 0 8px 28px rgba(16, 24, 40, .12); width: 340px;
}
.login-box h2 { margin: 0 0 4px; font-size: 18px; }
.login-box p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login-box .field { margin-bottom: 14px; }
.login-box button { width: 100%; }

/* 生成的卡密列表 */
.keys-out {
    margin-top: 14px; border: 1px solid var(--line); border-radius: 6px;
    background: #fafbfc; padding: 12px; max-height: 320px; overflow-y: auto;
    font-family: ui-monospace, Consolas, monospace; font-size: 13px;
}
.keys-out div { padding: 3px 0; border-bottom: 1px dashed #eef1f5; }
.keys-out div:last-child { border: 0; }

.bar-track { background: #eef2f7; border-radius: 6px; height: 8px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; }
.bar-fill.over { background: var(--bad); }

/* 通用弹窗（代理卡密明细用） */
.modal-mask {
    position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
    display: flex; align-items: flex-start; justify-content: center;
    z-index: 60; padding: 40px 20px; overflow-y: auto;
}
.modal-box {
    background: #fff; border-radius: 10px; width: 100%; max-width: 1000px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, .25); padding: 20px 22px 24px;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
