/* ===== 视频二维码营销系统 后台样式 ===== */
:root {
    --primary: #2f6bff;
    --primary-dark: #2456d6;
    --success: #16a34a;
    --danger: #e5484d;
    --warn: #d97706;
    --info: #0891b2;
    --sidebar-bg: #171e2e;
    --sidebar-hover: #212b42;
    --sidebar-active: #2f6bff;
    --body-bg: #f2f4f8;
    --card-bg: #fff;
    --border: #e5e8ef;
    --text: #1e2433;
    --text-sub: #6b7385;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(23, 30, 46, .06), 0 4px 14px rgba(23, 30, 46, .05);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--body-bg);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
code { background: #eef1f7; padding: 1px 6px; border-radius: 4px; font-size: 12px; color: #475069; }

/* ---------- 布局 ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; flex-shrink: 0; background: var(--sidebar-bg);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.brand-logo {
    width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, #2f6bff, #7c3aed);
    color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }
.brand-sub { color: #7b849c; font-size: 11px; margin-top: 1px; }
.menu { flex: 1; padding: 8px 10px; }
.menu-item {
    display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 2px;
    color: #a5adc4; border-radius: 8px; font-size: 14px; transition: all .15s;
}
.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.menu-item:hover { background: var(--sidebar-hover); color: #fff; }
.menu-item.active { background: var(--sidebar-active); color: #fff; font-weight: 500; box-shadow: 0 4px 12px rgba(47, 107, 255, .35); }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.06); }
.side-link { color: #7b849c; font-size: 12px; }
.side-link:hover { color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 60px; background: var(--card-bg); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text-sub); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: #e8edfb; color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.content { padding: 22px 24px; flex: 1; }
.footer { padding: 18px 24px; color: #9aa2b5; font-size: 12px; text-align: center; }

/* ---------- 登录页 ---------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(140deg, #16203c 0%, #1c2a52 45%, #24356e 100%);
    padding: 20px;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: #fff; border-radius: 14px; padding: 36px 34px 30px;
    box-shadow: 0 18px 50px rgba(10, 18, 46, .45);
}
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-logo {
    width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 13px;
    background: linear-gradient(135deg, #2f6bff, #7c3aed); color: #fff;
    font-size: 24px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.auth-head h1 { font-size: 19px; margin-bottom: 4px; }
.auth-head p { color: var(--text-sub); font-size: 13px; }

/* ---------- 组件 ---------- */
.card {
    background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.link { font-size: 13px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px;
}
.stat-label { color: var(--text-sub); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.stat-sub { color: var(--text-sub); font-size: 12px; margin-top: 6px; }
.stat-actions { display: flex; gap: 10px; margin-top: 12px; }

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

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 8px; padding: 9px 18px;
    font-size: 14px; cursor: pointer; transition: all .15s; line-height: 1;
    background: transparent; text-decoration: none; user-select: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { border-color: #ccd3e0; color: var(--text); background: #fff; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { color: var(--text-sub); }
.btn-ghost:hover { color: var(--danger); }
.btn-danger-outline { border-color: #f3c1c3; color: var(--danger); background: #fff; }
.btn-danger-outline:hover { background: #fdf1f1; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; padding: 11px; }

/* 表单 */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #3c4457; }
.form-group label em { color: var(--danger); font-style: normal; }
.input {
    width: 100%; border: 1px solid #d4dae5; border-radius: 8px; padding: 9px 12px;
    font-size: 14px; color: var(--text); background: #fff; outline: none; transition: border .15s, box-shadow .15s;
    font-family: inherit;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }
textarea.input { resize: vertical; }
.input-file { padding: 7px; font-size: 13px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 980px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 12px; color: var(--text-sub); font-weight: 500;
    padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid #f0f2f7; vertical-align: middle; }
.table tbody tr:hover { background: #f8f9fc; }
.table tbody tr:last-child td { border-bottom: none; }
.table-plain td { border-bottom: 1px solid #f0f2f7; padding: 10px 6px; color: var(--text-sub); }
.table-plain td:first-child { color: #3c4457; }
.td-title .t { font-weight: 500; margin-bottom: 2px; }
.td-title .sub { font-size: 12px; color: var(--text-sub); }
.td-time { font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.td-ua { font-size: 12px; color: #9aa2b5; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-actions { white-space: nowrap; display: flex; gap: 6px; }
.thumb { width: 72px; height: 42px; object-fit: cover; border-radius: 6px; background: #eef1f7; }
.thumb-empty {
    width: 72px; height: 42px; border-radius: 6px; background: #eef1f7; color: #9aa2b5;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
}

/* 徽章 */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; line-height: 1.4;
}
.badge-ok { background: #e6f6ec; color: #15803d; }
.badge-info { background: #e0f2f7; color: #0e7490; }
.badge-warn { background: #fdf1e0; color: #b45309; }
.badge-err { background: #fdecec; color: #c53030; }

/* 排名 */
.rank {
    display: inline-flex; width: 22px; height: 22px; border-radius: 6px; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; background: #eef1f7; color: var(--text-sub);
}
.rank-1 { background: #fff3d6; color: #b45309; }
.rank-2 { background: #f0f2f7; color: #4b5563; }
.rank-3 { background: #fdeadd; color: #b4530a; }

/* 提示 */
.alert { border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; line-height: 1.7; }
.alert-error { background: #fdecec; color: #b91c1c; }
.alert-success { background: #e6f6ec; color: #15803d; }
.alert-tip { background: #f2f6ff; color: #3b5bdb; }

/* 扫码模式单选卡片 */
.mode-options { display: flex; flex-direction: column; gap: 12px; }
.mode-option { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border: 1.5px solid #e3e8f2; border-radius: 12px; cursor: pointer; background: #fff; transition: border-color .18s, background .18s, box-shadow .18s; }
.mode-option:hover { border-color: #b9c8ef; box-shadow: 0 2px 8px rgba(59, 91, 219, .06); }
.mode-option:has(input:checked),
.mode-option.is-checked { border-color: var(--primary); background: #f5f8ff; box-shadow: 0 2px 10px rgba(59, 91, 219, .10); }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #eef1f8; color: #79819a; transition: background .18s, color .18s; }
.mode-option:has(input:checked) .mode-icon,
.mode-option.is-checked .mode-icon { background: var(--primary); color: #fff; }
.mode-icon svg { width: 20px; height: 20px; }
.mode-text { flex: 1; min-width: 0; }
.mode-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.mode-title b { font-size: 14px; color: var(--text); }
.mode-badge { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: #eef1f8; color: #79819a; transition: background .18s, color .18s; }
.mode-option:has(input:checked) .mode-badge,
.mode-option.is-checked .mode-badge { background: #dfe8ff; color: var(--primary); }
.mode-text > span { display: block; font-size: 12px; color: #79819a; line-height: 1.7; }
.mode-check { flex: none; width: 20px; height: 20px; margin-top: 10px; color: var(--primary); opacity: 0; transform: scale(.4); transition: opacity .18s, transform .18s; }
.mode-option:has(input:checked) .mode-check,
.mode-option.is-checked .mode-check { opacity: 1; transform: scale(1); }

/* iOS 风格开关 */
.switch-row { display: flex; align-items: center; gap: 16px; padding: 4px 0; cursor: pointer; }
.switch-row .switch-text { flex: 1; }
.switch-row .switch-text b { display: block; font-size: 13.5px; color: var(--text); margin-bottom: 4px; }
.switch-row .switch-text span { font-size: 12px; color: #79819a; line-height: 1.7; }
.switch-input { display: none; }
.switch { flex: none; position: relative; width: 46px; height: 26px; border-radius: 26px; background: #d4d9e6; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .2s; }
/* 开启态：兄弟选择器（兼容旧内核）+ is-checked 兜底 */
.switch-input:checked + .switch,
.switch-row.is-checked .switch { background: #22c55e; }
.switch-input:checked + .switch::after,
.switch-row.is-checked .switch::after { left: 23px; }

.tip-warn { font-size: 12px; color: var(--warn); }
.empty { text-align: center; color: #9aa2b5; padding: 40px 10px; font-size: 13px; }

/* 工具栏 */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 14px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 10px; align-items: center; }
.search { display: flex; gap: 8px; }
.search .input { width: 240px; }
.logo-upload-form { display: flex; gap: 10px; align-items: center; }
.logo-upload-form .input-file { width: 260px; }

/* Logo 网格 */
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.logo-item { text-align: center; padding: 14px 10px; border: 1px solid var(--border); border-radius: 10px; }
.logo-img {
    width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 10px; background: #f6f8fb;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    background-image: linear-gradient(45deg, #eef1f7 25%, transparent 25%, transparent 75%, #eef1f7 75%),
                      linear-gradient(45deg, #eef1f7 25%, transparent 25%, transparent 75%, #eef1f7 75%);
    background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.logo-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.logo-sub { font-size: 11px; color: #9aa2b5; margin-bottom: 10px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: #fff; padding: 4px; border-radius: 10px; box-shadow: var(--shadow); width: fit-content; }
.tab { border: none; background: transparent; padding: 9px 22px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--text-sub); }
.tab.active { background: var(--primary); color: #fff; font-weight: 500; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 上传 */
.file-drop {
    border: 2px dashed #ccd3e0; border-radius: 10px; padding: 34px 20px; text-align: center;
    cursor: pointer; transition: border .15s, background .15s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: #f6f9ff; }
.file-icon { font-size: 34px; margin-bottom: 8px; }
.file-text { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.file-sub { font-size: 12px; color: var(--text-sub); }
.file-selected {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: #f6f9ff; border: 1px solid #d7e3ff; color: var(--primary);
    padding: 10px 14px; border-radius: 8px; margin-top: 10px; font-size: 13px;
}
.upload-progress { margin-top: 14px; }
.progress-bar { height: 8px; background: #e8ecf4; border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2f6bff, #7c3aed); border-radius: 6px; transition: width .2s; }
.progress-text { font-size: 12px; color: var(--text-sub); margin-top: 7px; }

/* 弹窗 */
.modal {
    display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 200;
    align-items: center; justify-content: center; padding: 20px;
}
.modal.show { display: flex; }
.modal-box {
    background: #fff; border-radius: 14px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto;
    box-shadow: 0 24px 60px rgba(10, 18, 46, .3);
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: #9aa2b5; padding: 4px 8px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.qr-preview-wrap {
    display: flex; align-items: center; justify-content: center;
    background: #f8f9fc; border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px;
}
#qrCanvas { max-width: 100%; height: auto; }
.qr-url {
    text-align: center; font-size: 12px; color: var(--text-sub); margin-bottom: 14px;
    word-break: break-all;
}

/* 趋势图 */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 10px 4px 0; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.trend-bar { width: 12px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s; }
.trend-bar.scan { background: #2f6bff; }
.trend-bar.follow { background: #22c55e; }
.trend-label { font-size: 10px; color: #9aa2b5; margin-top: 6px; }
.trend-legend { padding: 10px 4px 0; font-size: 12px; color: var(--text-sub); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin: 0 5px 0 12px; vertical-align: -1px; }
.dot-scan { background: #2f6bff; }
.dot-follow { background: #22c55e; }

/* 筛选栏 */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar .input { width: auto; min-width: 130px; }
.filter-bar input[type=date] { width: 140px; }
.filter-sep { color: var(--text-sub); font-size: 13px; }

/* 分页 */
.pagination { display: flex; gap: 6px; padding: 16px 0 4px; justify-content: center; flex-wrap: wrap; }
.page {
    min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #d4dae5; border-radius: 7px; padding: 0 10px; color: var(--text); font-size: 13px; background: #fff;
}
.page:hover { border-color: var(--primary); color: var(--primary); }
.page.current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 刷新小按钮 */
.btn-refresh {
    border: none; background: #f0f4ff; color: var(--primary); width: 22px; height: 22px; border-radius: 6px;
    cursor: pointer; font-size: 13px; margin-left: 5px; line-height: 1; vertical-align: middle;
}
.btn-refresh:hover { background: #dbe6ff; }
.btn-refresh.loading { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 图片预览 */
.img-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--border); }

/* Toast */
#toast-box { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #1e2433; color: #fff; border-radius: 9px; padding: 12px 18px; font-size: 13px;
    box-shadow: 0 8px 24px rgba(10, 18, 46, .25); animation: fadeIn .2s; max-width: 340px;
}
.toast.success { background: #0f7b3d; }
.toast.error { background: #b91c1c; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
