/* ===== 后台样式（浅色） ===== */
:root {
    --brand: #2b6ef0;
    --ink: #1b1e23;
    --ink-2: #5b6270;
    --ink-3: #8a919c;
    --line: #e8eaee;
    --bg: #f5f6f8;
    --white: #fff;
    --ok: #0f9d58;
    --warn: #d97706;
    --danger: #e04a3a;
    --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }

.side {
    width: 208px;
    flex: 0 0 208px;
    background: var(--white);
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 18px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .2px;
}

.brand-dot {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 26px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 9px;
    color: #3d434e;
    font-size: 13.5px;
}

.nav a:hover { background: #f2f4f7; text-decoration: none; }
.nav a.on { background: #eaf1fe; color: var(--brand); font-weight: 600; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.page-title { margin: 0; font-size: 19px; font-weight: 700; }
.page-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-3); }

.who { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 10px; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-t { font-size: 14px; font-weight: 600; }
.card-tip { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }

/* ---------- 数据块 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }

.stat {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.stat-k { font-size: 12.5px; color: var(--ink-3); }
.stat-v { margin-top: 8px; font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.stat-x { margin-top: 6px; font-size: 12px; color: var(--ink-3); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--ink-3); font-weight: 600; white-space: nowrap; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td.nowrap, th.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--ink-3); }
.ellipsis { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--white);
    color: #33383f;
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: #f7f8fa; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.btn-primary:hover { background: #1f5edb; }
.btn-danger { color: var(--danger); border-color: #f3d6d2; }
.btn-danger:hover { background: #fdf3f2; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }

label.lb { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.req::after { content: " *"; color: var(--danger); }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #dfe3e8;
    border-radius: 9px;
    background: var(--white);
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 80px; line-height: 1.7; resize: vertical; }
.help { font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.help code { background: #f2f4f7; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.switch { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 13.5px; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- 徽标 ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    background: #f0f2f5;
    color: var(--ink-2);
    white-space: nowrap;
}

.tag-douyin { background: #ededf0; color: #161823; }
.tag-dianping { background: #fff0eb; color: #d9480f; }
.tag-meituan { background: #fff8e1; color: #a86a00; }
.tag-common { background: #eef3ff; color: #2b5fd9; }
.tag-ok { background: #e8f7ee; color: var(--ok); }
.tag-off { background: #f0f2f5; color: var(--ink-3); }
.tag-warn { background: #fff4e5; color: var(--warn); }

/* ---------- 提示条 ---------- */
.flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13.5px;
}

.flash-ok { background: #e8f7ee; color: #0b7a44; }
.flash-err { background: #fdeceb; color: #b3341f; }

.note {
    padding: 12px 14px;
    border-radius: 10px;
    background: #f6f8fb;
    border: 1px solid var(--line);
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--ink-2);
}

.note b { color: var(--ink); }
.note ol, .note ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty-state .big { font-size: 15px; color: var(--ink-2); margin-bottom: 8px; }

/* ---------- 分布条 ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-name { flex: 0 0 76px; color: var(--ink-2); }
.bar-track { flex: 1; height: 8px; background: #f0f2f5; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-val { flex: 0 0 52px; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 趋势 ---------- */
.trend { display: flex; align-items: flex-end; gap: 8px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
/* 柱子要有固定的「底」，否则百分比高度会从顶部往下长 */
.trend-track { width: 100%; height: 88px; display: flex; align-items: flex-end; justify-content: center; }
.trend-bar { width: 100%; max-width: 42px; background: linear-gradient(180deg, #6f9bf5, #2b6ef0); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.trend-x { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.trend-v { font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, #eef3fe 0%, #f5f6f8 46%, #f7f8fa 100%);
}

.login-card {
    width: 100%;
    max-width: 372px;
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 24px;
    box-shadow: 0 2px 4px rgba(20,24,32,.04), 0 18px 40px rgba(20,24,32,.08);
}

.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.login-card .sub { margin: 0 0 22px; font-size: 12.5px; color: var(--ink-3); }
.login-card .field { margin-bottom: 14px; }
.login-err { margin-bottom: 14px; }

/* ---------- 二维码页 ---------- */
.qr-layout { display: grid; grid-template-columns: 240px 1fr; gap: 22px; align-items: start; }
.qr-box { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; text-align: center; }
.qr-box img { width: 100%; max-width: 212px; display: block; margin: 0 auto; }
.qr-url { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); word-break: break-all; line-height: 1.5; }
.link-copy { display: flex; gap: 8px; margin-top: 8px; }
.link-copy input { font-size: 12.5px; }

/* ---------- 模板编辑 ---------- */
.tpl-group { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.tpl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tpl-head .t { font-size: 13px; font-weight: 600; }
.tpl-body { padding: 6px 14px 12px; }
.tpl-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed #eef0f3; }
.tpl-row:last-child { border-bottom: 0; }
.tpl-row textarea { min-height: 40px; font-size: 13.5px; padding: 8px 10px; overflow-y: hidden; resize: none; }
.tpl-row .col-grow { flex: 1; min-width: 0; }
.tpl-row .col-act { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding-top: 4px; }
.tpl-add { padding: 10px 0 4px; }
.tpl-off textarea { color: var(--ink-3); background: #fafbfc; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 13px;
    border-radius: 9px;
    background: #fff;
    border: 1px solid var(--line);
    color: #3d434e;
    font-size: 13px;
}
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.tabs a:hover { text-decoration: none; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; font-size: 13px; }
.pager a, .pager span {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #3d434e;
}
.pager .cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .gap { border: 0; background: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .qr-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .side {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 12px 12px 10px;
    }
    .brand { padding: 0 4px 12px; }
    .nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .nav a { min-height: 38px; padding: 0 11px; font-size: 13px; }
    .nav .sep { display: none; }
    .main { padding: 16px 14px 48px; }
    .form-grid { grid-template-columns: 1fr; }
    .stat-v { font-size: 22px; }
    .ellipsis { max-width: 200px; }
}

/* ---------- 分页（框架默认输出的 pagination） ---------- */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    list-style: none;
    flex-wrap: wrap;
}

.pagination li { display: block; }

.pagination li a,
.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #3d434e;
    font-size: 13px;
}

.pagination li a:hover { background: #f7f8fa; text-decoration: none; }
.pagination li.active span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination li.disabled span { color: #c3c8d0; background: #fafbfc; }

/* ---------- 试生成结果 ---------- */
.preview-box {
    background: #fafbfc;
    border: 1px dashed #e2e6ec;
    border-radius: 10px;
    padding: 14px;
    min-height: 64px;
}

.pv-empty { font-size: 12.5px; color: var(--ink-3); }

.pv-item {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px dashed #eaedf1;
}

.pv-item:last-child { border-bottom: 0; }
.pv-item p { margin: 0; font-size: 13.5px; line-height: 1.75; color: #2a2f37; }

.pv-idx {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e8eefb;
    color: var(--brand);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

@media (max-width: 900px) {
    .dash-cols { grid-template-columns: 1fr !important; }
}

/* ---------- NFC 写卡 ---------- */

.nfc-pick { display: grid; gap: 10px; }

.nfc-opt {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--white);
    cursor: pointer;
}

.nfc-opt:hover { border-color: #ccd6e6; background: #fafbfc; }
.nfc-opt input { margin-top: 3px; flex: 0 0 auto; }

.nfc-opt-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nfc-opt-body b { font-size: 13.5px; font-weight: 500; }
.nfc-opt-body em { font-style: normal; font-size: 12.5px; color: var(--ink-3); }
.nfc-opt-body code { font-size: 12px; color: var(--ink-2); word-break: break-all; line-height: 1.5; }

.nfc-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.nfc-status { font-size: 13px; color: var(--ink-3); }
.nfc-status.nfc-ok { color: var(--ok); }
.nfc-status.nfc-err { color: var(--danger); }
.nfc-status.nfc-wait { color: var(--brand); }

.nfc-log {
    margin: 12px 0 0;
    padding: 10px 12px;
    background: #fafbfc;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    color: #454c58;
    max-height: 220px;
    overflow: auto;
}

.nfc-explain p { margin: 0 0 8px; font-size: 13px; line-height: 1.75; color: #3d434e; }
.nfc-explain p:last-child { margin-bottom: 0; }

.btn:disabled,
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover,
.btn[disabled]:hover { text-decoration: none; }

/* ---------- 桌贴预览 ---------- */

.card-preview-wrap {
    background: #f4f6f9;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 26px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 320px;
}

.card-preview {
    max-width: 100%;
    max-height: 640px;
    width: auto;
    height: auto;
    /* 印刷品的投影，让预览看起来像一张实物而不是网页图片 */
    box-shadow: 0 10px 30px rgba(20, 26, 38, .16), 0 1px 3px rgba(20, 26, 38, .1);
    background: #fff;
}

@media (max-width: 780px) {
    .card-preview { max-height: 440px; }
    .card-preview-wrap { padding: 16px 10px; }
}
