/* ============================================================
   admin-v4.css — 五合茗酌 · 统一设计系统
   灵感：Linear / Vercel / Stripe Dashboard
   ============================================================ */

:root {
    /* Base */
    --bg-root: #f8f9fb;
    --bg-surface: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e8edf3;

    /* Sidebar */
    --sidebar-bg: #0c1222;
    --sidebar-hover: rgba(255,255,255,0.04);
    --sidebar-active: rgba(201,145,56,0.12);
    --sidebar-text: #8896a6;
    --sidebar-text-active: #f0c060;
    --sidebar-border: rgba(255,255,255,0.05);

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Accent */
    --accent: #c99138;
    --accent-hover: #b8832e;
    --accent-light: #fdf6e8;
    --accent-border: #f0d89c;

    /* Status Colors */
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #6366f1;
    --info-light: #eef2ff;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Radii */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 8px;
    --radius-xl: 8px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);

    /* Transitions */
    --fast: 0.15s ease;
    --normal: 0.2s ease;

    /* Layout */
    --sidebar-w: 232px;
    --header-h: 60px;
    /* --content-max: 1340px; */ /* 已废弃：不要给 .page-content 设 max-width，否则宽屏右半屏留白。 */
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14.5px; -webkit-font-smoothing: antialiased; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    color: var(--text-primary);
    background: var(--bg-root);
    line-height: 1.5;
    letter-spacing: 0;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: block;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-w); height: 100vh;
    overflow-y: auto; z-index: 200;
    border-right: 1px solid var(--sidebar-border);
}
.sidebar-brand {
    padding: 22px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand .logo {
    font-size: 18px; font-weight: 800; color: #f0c060;
    letter-spacing: 0.3px;
}
.sidebar-brand .sub {
    font-size: 10.5px; color: #556; margin-top: 2px;
    letter-spacing: 0.3px;
}
.sidebar-nav {
    flex: 1; padding: 8px 10px;
    display: flex; flex-direction: column; gap: 1px;
    overflow-y: auto;
}
.nav-section {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.5px; color: #4a5568;
    padding: 16px 10px 5px; margin-top: 2px;
}
.nav-section:first-child { padding-top: 4px; margin-top: 0; }
.nav-section-label { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 9.5px; }
.nav-section-label.blue { background: rgba(99,102,241,0.15); color: #818cf8; }
.nav-section-label.gold { background: rgba(201,145,56,0.15); color: #f0c060; }
.nav-section-label.gray { background: rgba(255,255,255,0.05); color: #666; }
.nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
    color: var(--sidebar-text); transition: all var(--fast);
    white-space: nowrap; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #cbd5e1; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); font-weight: 700; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 13px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--sidebar-border); font-size: 10.5px; color: #4a5568; }

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    display: flex; flex-direction: column;
    min-height: 100vh; min-width: 0;
    background: var(--bg-root);
}

/* ============================================================
   HEADER
   ============================================================ */
.page-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-h);
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
}
.page-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-header h1 { font-size: 17px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.page-header .page-desc { font-size: 12px; color: var(--text-muted); margin-left: 8px; white-space: nowrap; }

.page-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: nowrap; }

/* ============================================================
   BUTTONS — Unified System
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 5px; padding: 7px 14px; border-radius: var(--radius-sm);
    font-size: 12.5px; font-weight: 600; line-height: 1;
    border: 1px solid transparent; cursor: pointer;
    transition: all var(--fast); white-space: nowrap;
    text-decoration: none; color: inherit;
    letter-spacing: 0;
    position: relative; overflow: hidden;
}
.btn::after {
    content: ''; position: absolute; inset: 0;
    background: transparent; transition: background var(--fast);
    border-radius: inherit; pointer-events: none;
}
.btn:active { transform: scale(0.97); }

/* Primary */
.btn-primary {
    background: var(--accent); color: #fff; border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(201,145,56,0.25);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 2px 8px rgba(201,145,56,0.3); }

/* Secondary — default for most actions */
.btn-secondary {
    background: var(--bg-surface); color: var(--text-primary);
    border-color: var(--border); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: #d1d5db; box-shadow: var(--shadow-sm); }

/* Ghost — subtle actions */
.btn-ghost {
    background: transparent; color: var(--text-secondary); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Danger */
.btn-danger {
    background: var(--bg-surface); color: var(--danger); border-color: #fecaca;
}
.btn-danger:hover { background: var(--danger-light); border-color: #f87171; color: #dc2626; }

/* Teal — data/sync actions */
.btn-teal {
    background: #0f766e; color: #fff; border-color: #0f766e;
    box-shadow: 0 1px 2px rgba(15,118,110,0.2);
}
.btn-teal:hover { background: #0d9488; border-color: #0d9488; box-shadow: 0 2px 8px rgba(15,118,110,0.3); }

/* Accent outline */
.btn-outline {
    background: transparent; color: var(--accent); border-color: var(--accent-border);
}
.btn-outline:hover { background: var(--accent-light); }

/* Sizes */
.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 5px; }
.btn-xs { padding: 3px 8px; font-size: 10.5px; border-radius: 4px; }
.btn-icon { padding: 7px; min-width: 32px; }

/* Disabled */
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ============================================================
   BUTTON GROUPS
   ============================================================ */
.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn + .btn { border-left: none; margin-left: -1px; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 24px 28px 40px; flex: 1; width: 100%; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 24px;
    box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 16px; }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }

/* ============================================================
   KPI CARDS — Data Dashboard Style
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 20px;

/* 4卡片固定一排 */
.kpi-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
}
.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    transition: all var(--normal);
    position: relative; overflow: hidden;
}
.kpi-card::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 3px; height: 40%; border-radius: 0 0 3px 0;
    transition: height var(--normal);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-card:hover::before { height: 100%; }

.kpi-card.kpi-blue::before { background: var(--info); }
.kpi-card.kpi-cyan::before { background: #0891b2; }
.kpi-card.kpi-teal::before { background: #0f766e; }
.kpi-card.kpi-green::before { background: var(--success); }
.kpi-card.kpi-accent::before { background: var(--accent); }
.kpi-card.kpi-purple::before { background: #7c3aed; }

.kpi-value {
    font-size: 30px; font-weight: 800; color: var(--text-primary);
    line-height: 1.1; letter-spacing: 0;
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 4px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: #f8fafc; color: var(--text-muted);
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; padding: 11px 14px;
    text-align: left; border-bottom: 1px solid var(--border);
    white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
thead th:first-child { padding-left: 18px; border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child { padding-right: 18px; border-radius: 0 var(--radius-lg) 0 0; }
tbody td {
    padding: 11px 14px; border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary); vertical-align: middle;
}
tbody td:first-child { padding-left: 18px; }
tbody td:last-child { padding-right: 18px; }
tbody tr { transition: background var(--fast); }
tbody tr:hover td { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }

.channel-name { color: var(--text-primary); font-weight: 600; font-size: 13.5px; }
.channel-name:hover { color: var(--accent); }
.channel-name .channel-icon { color: var(--accent); font-weight: 800; margin-right: 3px; }

.slug-code {
    display: inline-block; padding: 2px 7px;
    background: var(--bg-hover); border-radius: 4px;
    font-size: 11px; color: var(--text-muted);
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

/* ============================================================
   TABLE ACTION BUTTONS
   ============================================================ */
.col-actions {
    display: flex; gap: 3px; flex-wrap: wrap; min-width: 260px;
}
.col-actions .btn { font-size: 11px; padding: 5px 9px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 9px; border-radius: 20px;
    font-size: 11px; font-weight: 600; line-height: 1.4;
}
.badge-green { background: var(--success-light); color: #059669; }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }
.badge-red { background: var(--danger-light); color: #dc2626; }

/* ============================================================
   TABLE CELL CLASSES
   ============================================================ */
.col-index { color: var(--text-muted); font-size: 11.5px; text-align: center; width: 36px; }
.col-avatar { text-align: center; padding: 3px 6px; width: 50px; }
.col-contact { font-size: 12.5px; line-height: 1.5; }
.col-contact .contact-phone { color: var(--text-muted); font-size: 11.5px; }

.avatar-img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto; }
.avatar-fallback {
    display: inline-block; width: 34px; height: 34px; border-radius: 50%;
    background: #f1f5f9; color: var(--text-muted);
    font-size: 13px; line-height: 34px; text-align: center;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; flex-wrap: wrap;
    padding: 12px 16px; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-label {
    font-size: 11.5px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.6px;
    margin-right: 2px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-card { max-width: 740px; }
.form-section { margin-bottom: 28px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    margin-bottom: 14px; padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
    display: flex; align-items: center; gap: 8px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
    font-size: 12px; font-weight: 700; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.3px;
}
.form-group .hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

input[type="text"], input[type="number"], input[type="password"],
input[type="url"], input[type="search"], input[type="date"],
textarea, select {
    padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px;
    color: var(--text-primary); background: var(--bg-surface);
    transition: all var(--fast); outline: none;
    font-family: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,145,56,0.1);
}
textarea { resize: vertical; min-height: 80px; }
select {
    cursor: pointer; appearance: none; padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2394a3b8'%3E%3Cpath d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-list { margin-bottom: 16px; }
.flash {
    padding: 10px 16px; border-radius: var(--radius);
    font-size: 13px; font-weight: 500; margin-bottom: 6px;
    border: 1px solid transparent;
}
.flash.success { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.flash.error { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.flash.info { background: var(--info-light); color: #3730a3; border-color: #c7d2fe; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
}
.modal-box {
    background: var(--bg-surface); border-radius: var(--radius-lg);
    padding: 26px; min-width: 360px; max-width: 90vw;
    box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; }

/* ============================================================
   CHART / ANALYTICS
   ============================================================ */
.chart-container { width: 100%; }
.chart-head {
    display: flex; align-items: baseline; gap: 10px;
    margin-bottom: 16px;
}
.chart-head h2 { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.chart-head span { font-size: 12px; color: var(--text-muted); }

.channel-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 18px; margin-bottom: 16px;
    background: var(--info-light); border: 1px solid #c7d2fe;
    border-radius: var(--radius); font-size: 13px; color: var(--text-secondary);
}
.channel-banner strong { color: var(--text-primary); }

.channel-selector {
    padding: 7px 28px 7px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 12.5px;
    background: var(--bg-surface); color: var(--text-primary);
    cursor: pointer; min-width: 160px; width: auto;
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-track {
    width: 38px; height: 20px; border-radius: 10px;
    background: #d1d5db; position: relative;
    transition: background var(--fast); cursor: pointer;
}
.toggle-track.on { background: var(--accent); }
.toggle-track .knob {
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; background: #fff;
    border-radius: 50%; transition: left var(--fast);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.toggle-track.on .knob { left: 20px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
body.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #f0f4f8 0%, #dce3ea 40%, #eef1f5 100%);
}

.login-wrapper {
    width: min(420px, calc(100vw - 40px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

/* ---- 品牌区 ---- */
.login-brand {
    text-align: center;
}

.login-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(201, 145, 56, 0.18);
}

.login-brand h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: 1px;
}

.login-brand p {
    margin: 6px 0 0;
    font-size: 12.5px;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

/* ---- 卡片 ---- */
.login-card {
    width: 100%;
    padding: 32px 30px;
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 14px;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.03),
        0 8px 32px rgba(0, 0, 0, 0.06);
}

.login-card .flash-list {
    margin-bottom: 20px;
}

.login-card .flash {
    border-radius: 8px;
    font-size: 13px;
}

/* ---- 输入字段 ---- */
.login-field {
    margin-bottom: 18px;
}

.login-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 7px;
    font-size: 12.5px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.login-field-icon {
    font-size: 14px;
    line-height: 1;
}

.login-field input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #0f172a;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.login-field input::placeholder {
    color: #c0c8d4;
}

.login-field input:focus {
    border-color: #c99138;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(201, 145, 56, 0.1);
}

/* 覆盖浏览器自动填充的默认黄底 */
.login-field input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #f8fafc inset;
    -webkit-text-fill-color: #0f172a;
}

.login-field input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px #fff inset;
}

/* ---- 登录按钮 ---- */
.login-btn {
    width: 100%;
    height: 46px;
    margin-top: 6px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #d49a3e 0%, #b87b24 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(201, 145, 56, 0.3);
}

.login-btn:hover {
    background: linear-gradient(135deg, #dea84a 0%, #c2852a 100%);
    box-shadow: 0 6px 20px rgba(201, 145, 56, 0.4);
    transform: translateY(-1px);
}

.login-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(201, 145, 56, 0.25);
}

/* ---- 页脚 ---- */
.login-footer {
    font-size: 11.5px;
    color: #b0b9c6;
}

/* ============================================================
   DARK THEME — Analytics Dashboard
   ============================================================ */
.dark-analytics {
    --bg-root: #060b14;
    --bg-surface: #0d1424;
    --bg-hover: #131c30;
    --bg-active: #162032;
    --text-primary: #e8ecf2;
    --text-secondary: #8899b4;
    --text-muted: #4a5a78;
    --border: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.03);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.25);
    --shadow: 0 4px 16px rgba(0,0,0,0.3);
    color: var(--text-primary);
    background: var(--bg-root);
}
.dark-analytics .page-header {
    background: rgba(13,20,36,0.85);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom-color: var(--border);
}
.dark-analytics .page-header h1 { color: var(--text-primary); }
.dark-analytics .kpi-card { background: var(--bg-surface); border-color: var(--border); }
.dark-analytics .kpi-value { color: var(--text-primary); }
.dark-analytics .kpi-label { color: var(--text-secondary); }
.dark-analytics .kpi-sub { color: var(--text-muted); }
.dark-analytics .card { background: var(--bg-surface); border-color: var(--border); }
.dark-analytics .card h2 { color: var(--text-primary); }
.dark-analytics thead th { background: #0a1020; color: var(--text-muted); border-bottom-color: var(--border); }
.dark-analytics tbody td { color: var(--text-secondary); border-bottom-color: var(--border-light); }
.dark-analytics tbody tr:hover td { background: rgba(255,255,255,0.01); }
.dark-analytics .channel-selector { background: var(--bg-surface); border-color: var(--border); color: var(--text-primary); }
.dark-analytics .btn-secondary { background: var(--bg-surface); border-color: var(--border); color: var(--text-primary); }
.dark-analytics .btn-secondary:hover { background: var(--bg-hover); }
.dark-analytics .btn-ghost { color: var(--text-secondary); }
.dark-analytics .btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.dark-analytics .channel-banner { background: rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.12); }
.dark-analytics .table-wrap { background: var(--bg-surface); border-color: var(--border); }
.dark-analytics .filter-bar { background: var(--bg-surface); border-color: var(--border); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar { left: -260px; width: 260px; transition: left 0.25s; }
    .sidebar.open { left: 0; }
    .main-area { margin-left: 0; }
    .page-header { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; }
    .page-content { padding: 16px; }
    .page-header-actions { width: 100%; flex-wrap: wrap; }
    .form-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .mobile-menu-btn { display: inline-flex; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================================
   UTILITY
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ============================================================
   v5 UI Refinement — 渠道列表 + 数据看板
   ============================================================ */
.page-content {
    width: 100%;
}

.mobile-menu-btn {
    display: none;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.page-header-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.page-header-actions .btn {
    min-height: 34px;
}

.page-header-actions .btn-secondary {
    background: rgba(255,255,255,0.92);
    border-color: var(--border);
}

.page-header-actions .btn-secondary:hover,
.page-header-actions .btn-secondary:focus {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 8px 18px rgba(201,145,56,0.18);
}

.filter-manage {
    margin-left: auto;
}

.channel-table th,
.channel-table td {
    vertical-align: middle;
}

.channel-table tbody tr {
    position: relative;
}

.channel-table tbody tr:hover td {
    background: #fbfaf7;
}

.ch-date {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12px;
}

.col-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 340px;
}

.col-actions form {
    display: inline-flex !important;
}

.col-actions .btn {
    border-radius: 6px;
    min-height: 28px;
}

.col-actions .btn-secondary {
    color: var(--text-secondary);
}

.col-actions .btn-primary {
    box-shadow: 0 6px 14px rgba(201,145,56,0.16);
}

.col-actions .btn-danger {
    color: #b91c1c;
    background: #fff;
    border-color: #fee2e2;
}

.col-actions .btn-danger:hover {
    color: #fff;
    background: #dc2626;
    border-color: #dc2626;
}

.btn-delete {
    color: #b91c1c;
    background: #fff;
    border-color: #fee2e2;
}

.badge-blue { background: var(--info-light); color: #4f46e5; }
.badge-amber { background: var(--warning-light); color: #b45309; }

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.table-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.table-head h2,
.card > h2 {
    font-size: 16px;
    line-height: 1.3;
    font-weight: 800;
    color: var(--text-primary);
}

.hint {
    color: var(--text-muted);
    font-size: 12px;
}

.empty,
.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 28px 16px;
}

.empty-icon {
    font-size: 22px;
    color: var(--accent);
    margin-bottom: 8px;
}

.truncate {
    display: inline-block;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.toolbar-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.single-date {
    min-width: 150px;
}

.mt-20 { margin-top: 20px; }
.chart-md { height: 320px; }
.chart-lg { height: 360px; }
.chart-xl { height: 400px; }

.quick-copy-modal {
    max-width: 420px;
}

.modal-desc {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 13px;
}

.modal-field {
    display: block;
    margin-bottom: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.modal-field input {
    margin-top: 6px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.info-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-root);
    min-width: 0;
}

.info-item label {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
}

.log-pre {
    max-width: 620px;
    white-space: pre-wrap;
    color: var(--text-secondary);
    font-size: 11px;
}

.funnel-insights {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.insight-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.insight-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.insight-dot.blue { background: #3b82f6; }
.insight-dot.teal { background: #14b8a6; }
.insight-dot.accent { background: var(--accent); }
.insight-dot.green { background: #10b981; }

/* 全屏暗色数据看板 */
.dark-analytics {
    background:
        linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
        #070b13;
    background-size: 36px 36px;
}

.dark-analytics.page-content {
    max-width: none;
    padding: 26px 32px 44px;
}

.dark-analytics .analytics-board {
    width: 100%;
}

.dark-analytics .page-header-actions .btn-secondary {
    background: rgba(17,24,39,0.72);
    color: #dbe4f0;
    border-color: rgba(148,163,184,0.18);
}

.dark-analytics .page-header-actions .btn-secondary:hover,
.dark-analytics .page-header-actions .btn-secondary:focus {
    color: #09111f;
    background: #f2c56b;
    border-color: #f2c56b;
}

.analytics-shell {
    background: #070b13;
}

.analytics-shell .page-header {
    background: rgba(7,11,19,0.9);
    border-bottom-color: rgba(148,163,184,0.14);
}

.analytics-shell .page-header h1 {
    color: #eef4ff;
}

.analytics-shell .page-header .page-desc {
    color: #708098;
}

.analytics-shell .page-header-actions .btn-secondary {
    background: rgba(15,23,42,0.88);
    color: #dbe4f0;
    border-color: rgba(148,163,184,0.18);
}

.analytics-shell .page-header-actions .btn-secondary:hover,
.analytics-shell .page-header-actions .btn-secondary:focus {
    color: #09111f;
    background: #f2c56b;
    border-color: #f2c56b;
}

.analytics-shell .channel-selector,
.analytics-shell input[type="date"] {
    background: rgba(15,23,42,0.88);
    color: #e6edf7;
    border-color: rgba(148,163,184,0.2);
}

.analytics-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.analytics-toolbar .channel-selector {
    min-height: 34px;
    width: auto;
    max-width: 220px;
}

.analytics-toolbar #dateRangePicker {
    min-width: 220px;
    max-width: 240px;
    cursor: pointer;
}

.dark-analytics .channel-selector,
.dark-analytics input[type="date"] {
    background: rgba(15,23,42,0.86);
    color: #e6edf7;
    border-color: rgba(148,163,184,0.18);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.dark-analytics .channel-selector:focus,
.dark-analytics input[type="date"]:focus {
    border-color: rgba(242,197,107,0.72);
    box-shadow: 0 0 0 3px rgba(242,197,107,0.12);
}

.dark-analytics .kpi-grid {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 16px;
}

.dark-analytics .kpi-card {
    min-height: 128px;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02)),
        rgba(15,23,42,0.82);
    border-color: rgba(148,163,184,0.14);
    box-shadow: 0 18px 46px rgba(0,0,0,0.22);
}

.dark-analytics .kpi-card::before {
    width: 100%;
    height: 3px;
    opacity: 0.9;
}

.dark-analytics .kpi-card:hover {
    transform: translateY(-3px);
    border-color: rgba(242,197,107,0.3);
    box-shadow: 0 22px 60px rgba(0,0,0,0.34);
}

.dark-analytics .kpi-value {
    font-size: 34px;
    color: #f7fbff;
}

.dark-analytics .kpi-label {
    color: #c6d1e3;
    font-size: 13px;
}

.dark-analytics .kpi-sub {
    color: #73829a;
    margin-top: 8px;
}

.dark-analytics .channel-banner {
    background: rgba(15,23,42,0.82);
    color: #c7d3e6;
    border-color: rgba(96,165,250,0.18);
}

.banner-action {
    margin-left: auto;
}

.insight-panel {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
}

.dark-analytics .insight-panel {
    background:
        linear-gradient(135deg, rgba(59,130,246,0.1), transparent 35%),
        rgba(10,16,29,0.92);
    border-color: rgba(148,163,184,0.14);
    box-shadow: 0 18px 46px rgba(0,0,0,0.22);
}

.insight-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 800;
}

.insight-panel-icon {
    color: var(--accent);
}

.insight-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.insight-card {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-root);
}

.dark-analytics .insight-card {
    background: rgba(15,23,42,0.72);
    border-color: rgba(148,163,184,0.12);
}

.insight-card.good .insight-card-icon { color: #10b981; }
.insight-card.warn .insight-card-icon { color: #f59e0b; }

.insight-card-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    font-size: 12px;
    font-weight: 900;
}

.insight-card-title {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.insight-card-value {
    margin-top: 4px;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 900;
}

.insight-card-desc {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.analytics-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 20px;
}

.chart-card,
.table-card {
    padding: 22px;
}

.dark-analytics .chart-card,
.dark-analytics .table-card {
    background: rgba(12,18,31,0.9);
    border-color: rgba(148,163,184,0.13);
    box-shadow: 0 18px 46px rgba(0,0,0,0.22);
}

.chart-card-primary {
    background:
        linear-gradient(135deg, rgba(201,145,56,0.12), transparent 42%),
        var(--bg-surface);
}

.dark-analytics .chart-head h2,
.dark-analytics .table-head h2,
.dark-analytics .card > h2 {
    color: #eef4ff;
}

.dark-analytics .chart-head span,
.dark-analytics .hint {
    color: #73829a;
}

.dark-analytics .table-wrap {
    border-color: rgba(148,163,184,0.12);
}

.dark-analytics code,
.dark-analytics .slug-code {
    background: rgba(255,255,255,0.06);
    color: #b8c6dc;
}

.dark-analytics .badge-blue { background: rgba(96,165,250,0.13); color: #93c5fd; }
.dark-analytics .badge-amber { background: rgba(245,158,11,0.13); color: #fbbf24; }
.dark-analytics .badge-green { background: rgba(16,185,129,0.13); color: #6ee7b7; }

@media (max-width: 1280px) {
    .dark-analytics .kpi-grid {
        grid-template-columns: repeat(3, minmax(170px, 1fr));
    }
    .insight-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1080px) {
    .analytics-main-grid,
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .col-actions {
        flex-wrap: wrap;
        min-width: 260px;
    }
}

@media (max-width: 900px) {
    .mobile-menu-btn {
        display: inline-flex;
    }
    .page-header-left {
        align-items: center;
        width: 100%;
    }
    .page-header .page-desc {
        display: none;
    }
    .analytics-toolbar {
        justify-content: flex-start;
        width: 100%;
    }
    .dark-analytics .kpi-grid,
    .insight-cards,
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* ════════════ v1.2: 平台总览 dashboard ════════════ */

@media(max-width:900px){.kpi-grid,.kpi-grid-4{grid-template-columns:repeat(2,1fr)}}
.kpi-card{background:#fff;border-radius:12px;padding:20px;box-shadow:0 1px 3px rgba(0,0,0,0.08);text-align:center}
.kpi-card.accent-blue{border-left:4px solid #3b82f6}
.kpi-card.accent-green{border-left:4px solid #22c55e}
.kpi-card.accent-orange{border-left:4px solid #f97316}
.kpi-card.accent-purple{border-left:4px solid #a855f7}
.kpi-card.accent-teal{border-left:4px solid #14b8a6}
.kpi-card.accent-red{border-left:4px solid #ef4444}
.kpi-value{font-size:28px;font-weight:700;color:#1e293b;line-height:1.2}
.kpi-label{font-size:13px;color:#64748b;margin-top:4px}
.kpi-sub{font-size:12px;color:#94a3b8;margin-top:2px}
.dashboard-grid{display:grid;grid-template-columns:2fr 1fr;gap:20px}
@media(max-width:900px){.dashboard-grid{grid-template-columns:1fr}}
.chart-card .card-header{font-weight:600;margin-bottom:12px}
.chart-wrap{height:260px;position:relative}
.mini-bar{display:flex;align-items:center;gap:8px;font-size:12px}
.mini-bar-fill{height:6px;background:#3b82f6;border-radius:3px;min-width:2px}
.table.compact th,.table.compact td{padding:8px 10px;font-size:13px}
.nowrap{white-space:nowrap;color:#94a3b8;font-size:12px}
.empty{text-align:center;color:#94a3b8;padding:32px 0}

/* ════════════ v1.2: 扫码列表 scan-channels ════════════ */
.scan-filters{display:flex;gap:12px;align-items:center;margin-bottom:20px;flex-wrap:wrap}
.scan-filters select,.scan-filters input{padding:8px 12px;border:1px solid #e2e8f0;border-radius:8px;font-size:13px}
.scan-filters input{min-width:200px}
.scan-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}
.scan-card{background:#fff;border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,0.08);overflow:hidden;transition:box-shadow .15s}
.scan-card:hover{box-shadow:0 4px 12px rgba(0,0,0,0.12)}
.scan-card-header{padding:16px 16px 0;display:flex;justify-content:space-between;align-items:flex-start}
.scan-card-title{font-weight:600;font-size:15px;color:#1e293b}
.scan-card-label{font-size:12px;color:#fff;background:#3b82f6;padding:2px 8px;border-radius:10px;white-space:nowrap}
.scan-card-label.direct-302{background:#22c55e}
.scan-card-label.direct-page{background:#f59e0b}
.scan-card-body{padding:12px 16px;font-size:13px;color:#64748b}
.scan-card-body .stat-row{display:flex;justify-content:space-between;padding:4px 0}
.scan-card-body .stat-row span:first-child{color:#94a3b8}
.scan-card-actions{padding:12px 16px;display:flex;gap:8px;border-top:1px solid #f1f5f9}
.scan-card-actions .btn-sm{padding:6px 12px;font-size:12px;border-radius:6px}

/* ════════════ v1.2: 扫码渠道表单/详情 ════════════ */
.scan-qr-preview{text-align:center;padding:20px}
.scan-qr-preview img{border:1px solid #e2e8f0;border-radius:12px;max-width:220px}
.scan-mode-hint{font-size:12px;color:#94a3b8;margin-top:8px}
.direct-page-preview{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:24px;text-align:center;max-width:300px;margin:0 auto}
.direct-page-preview .qr-img{border:1px solid #e2e8f0;border-radius:8px;padding:12px;margin-bottom:12px}
.direct-page-preview .qr-img img{max-width:180px}
.direct-page-preview .qr-hint{font-size:14px;color:#64748b}
.batch-import-area{border:2px dashed #e2e8f0;border-radius:12px;padding:24px;text-align:center;margin-bottom:20px}
.batch-import-area textarea{width:100%;min-height:120px;border:1px solid #e2e8f0;border-radius:8px;padding:12px;font-size:13px;font-family:monospace;margin-top:12px}
.batch-preview-table{max-height:300px;overflow:auto;margin:12px 0}
.batch-preview-table table{width:100%;font-size:13px}
.batch-preview-table th{background:#f8fafc;position:sticky;top:0}

/* ════════════ v1.2b: 扫码列表优化 ════════════ */
.scan-category-bar{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
.cat-tag{display:inline-block;padding:6px 14px;border-radius:20px;font-size:13px;text-decoration:none;color:#64748b;background:#f1f5f9;transition:all .15s}
.cat-tag:hover{background:#e2e8f0;color:#334155}
.cat-tag.active{background:#3b82f6;color:#fff}
.cat-tag.cat-add{background:transparent;border:1px dashed #cbd5e1;color:#94a3b8;padding:6px 10px;font-size:14px}
.cat-tag.cat-add:hover{border-color:#3b82f6;color:#3b82f6}

.scan-filters{display:flex;gap:8px;align-items:center;margin-bottom:16px;flex-wrap:wrap}
.scan-filters select{padding:7px 10px;border:1px solid #e2e8f0;border-radius:8px;font-size:13px;background:#fff}
.scan-filters input{padding:7px 10px;border:1px solid #e2e8f0;border-radius:8px;font-size:13px;min-width:180px}

.mode-badge{display:inline-block;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:500;white-space:nowrap}
.mode-badge.direct-302{background:#dcfce7;color:#166534}
.mode-badge.direct-page{background:#fef3c7;color:#92400e}
.mode-badge.landing{background:#e0e7ff;color:#3730a3}

.btn-sm{padding:5px 10px;font-size:12px;border-radius:6px;border:1px solid #e2e8f0;background:#fff;color:#475569;cursor:pointer;text-decoration:none;display:inline-block;white-space:nowrap}
.btn-sm:hover{background:#f8fafc}
.btn-danger{color:#ef4444!important;border-color:#fecaca!important}
.btn-danger:hover{background:#fef2f2!important}

/* ════════════ v1.2c: 分页 ════════════ */
.pagination-bar{display:flex;justify-content:space-between;align-items:center;padding:12px 0;border-top:1px solid #f1f5f9;margin-top:12px;flex-wrap:wrap;gap:8px}
.page-info{font-size:13px;color:#94a3b8}
.page-controls{display:flex;align-items:center;gap:4px;flex-wrap:wrap}
.page-btn{display:inline-block;padding:5px 11px;border-radius:6px;font-size:13px;text-decoration:none;color:#475569;border:1px solid #e2e8f0;background:#fff;transition:all .1s}
.page-btn:hover{background:#f1f5f9;border-color:#cbd5e1}
.page-btn.active{background:#3b82f6;color:#fff;border-color:#3b82f6;cursor:default}
.per-page-select{padding:5px 8px;border:1px solid #e2e8f0;border-radius:6px;font-size:12px;color:#64748b;background:#fff;margin-left:8px;cursor:pointer}
