/* =========================================================
   电商利润核算系统 - ERP 风格主题 (V2.4.6 UI 重构)
   ========================================================= */
:root {
    /* 主色：沉稳靛蓝（ERP 专业感） */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --primary-soft: #eef2ff;

    --success: #10b981;
    --success-soft: #ecfdf5;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --info: #8b5cf6;
    --info-soft: #f5f3ff;
    --teal: #14b8a6;
    --pink: #ec4899;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --bg: #f4f6fb;
    --sidebar-bg: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
    --sidebar-width: 248px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, 0.18);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 移动端溢出保护 */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell, .main, .content, .topbar, .sidebar {
    max-width: 100vw;
}

.metric-card, .card, .channel-card {
    min-width: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============ 整体布局 ============ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    padding: 22px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    display: flex;
    flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 6px; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px 22px;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 18px;
}
.brand-mark {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-light), var(--info));
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(99,102,241,0.5);
    flex-shrink: 0;
}
.brand small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}

.nav-section {
    padding: 0 22px 8px;
    font-size: 11px;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
}

.nav {
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: rgba(255,255,255,0.65);
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.18s ease;
    position: relative;
}
.nav a span { font-size: 18px; line-height: 1; }
.nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.nav a.active {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    box-shadow: 0 8px 20px -6px rgba(79,70,229,0.7);
}
.nav a.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 22px;
    background: #fff;
    border-radius: 0 4px 4px 0;
}

.side-user {
    margin: auto 14px 12px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.side-user .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--info));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.side-user .u-meta { min-width: 0; }
.side-user .u-name { font-size: 13px; font-weight: 600; color: #fff; }
.side-user .u-role { font-size: 11px; color: rgba(255,255,255,0.5); }

.sidebar-footer {
    padding: 14px 22px 0;
    color: rgba(255,255,255,0.35);
    font-size: 12px;
}

/* ============ 主内容区 ============ */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    height: 66px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}
.crumb {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}
.crumb::before {
    content: "";
    width: 4px;
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
}
.account {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
    color: var(--gray-600);
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.content {
    padding: 26px 32px 40px;
    max-width: 1360px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

/* ============ 页面标题 ============ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 16px;
}
.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.2px;
}
.page-header .subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}
.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 30px 0 16px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.section-title::before {
    content: "";
    width: 4px;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
}
.section-bar {
    display: inline-block;
    width: 4px;
    height: 17px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    margin-right: 9px;
    vertical-align: -2px;
}

/* ============ 日期筛选 ============ */
.date-filter { width: 100%; max-width: 880px; }
.date-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: #fff;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}
.date-sep { color: var(--gray-500); font-size: 14px; }
.quick-tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 9px;
}
.tab {
    padding: 6px 13px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--gray-600);
    font-weight: 500;
    transition: all 0.18s;
    white-space: nowrap;
}
.tab:hover { color: var(--gray-900); }
.tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ============ 月份选择器 ============ */
.month-picker-wrap {
    position: relative;
}
.tab-month {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--gray-300);
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.18s;
    white-space: nowrap;
    font-family: inherit;
}
.tab-month:hover { border-color: var(--primary-light); color: var(--primary); }
.tab-month.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}
.month-picker-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    box-shadow: 0 8px 24px -6px rgba(15,23,42,0.16), 0 3px 8px -3px rgba(15,23,42,0.08);
    padding: 12px 16px 14px;
    min-width: 300px;
}
.month-picker-panel.open { display: block; animation: mpFadeIn .15s ease; }
@keyframes mpFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.mp-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}
.mp-year {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
    min-width: 56px;
    text-align: center;
}
.mp-nav {
    width: 26px; height: 26px;
    border: none;
    background: transparent;
    border-radius: 5px;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}
.mp-nav:hover { background: var(--primary-soft); }
.mp-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.mp-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.12s;
    line-height: 1.6;
}
.mp-cell:hover:not(.disabled) {
    background: var(--primary);
    color: #fff;
}
.mp-cell.disabled {
    color: #cbd5e1;
    pointer-events: none;
}
.mp-cell.active {
    background: var(--primary);
    color: #fff !important;
    font-weight: 700;
}

/* ============ 指标卡片 ============ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(186px, 1fr));
    gap: 16px;
}
.metric-card {
    --mc: var(--primary);
    --mc-bg: var(--primary-soft);
    background: #fff;
    padding: 18px 18px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.metric-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--mc);
}
.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.metric-clickable {
    cursor: pointer;
}
.metric-clickable.active {
    border-color: var(--mc);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mc) 25%, transparent), var(--shadow);
    transform: translateY(-2px);
}
.metric-clickable.active::before {
    height: 4px;
}
.metric-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px 16px;
}
.metric-toggle-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.metric-toggle-item:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.metric-toggle-item input {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
}
/* 拖拽排序列表 */
.metric-sortable-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
}
.metric-sort-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s, transform .15s, opacity .15s;
    user-select: none;
}
.metric-sort-item:active { cursor: grabbing; }
.metric-sort-item.dragging {
    opacity: 0.5;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    border-color: var(--primary);
    z-index: 10;
}
.metric-sort-item.drag-over {
    border-color: var(--primary);
    border-style: dashed;
    background: var(--primary-soft);
    transform: translateY(2px);
}
.metric-drag-handle {
    font-size: 18px;
    color: var(--gray-400);
    cursor: grab;
    padding: 6px 12px;
    line-height: 1;
    letter-spacing: -1px;
    flex-shrink: 0;
    touch-action: none; /* 关键：触摸手柄时不触发页面滚动，专用于拖拽 */
    -webkit-user-select: none;
    user-select: none;
}
.metric-drag-handle:active { cursor: grabbing; }
.metric-sort-item:hover .metric-drag-handle { color: var(--gray-600); }
.metric-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.metric-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--mc-bg);
    color: var(--mc);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}
.metric-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
    line-height: 1.3;
}
.metric-value {
    font-size: 25px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.15;
    letter-spacing: -0.3px;
    overflow-wrap: anywhere;
}

/* 指标强调色 */
.metric-accent-blue   { --mc: #4f46e5; --mc-bg: #eef2ff; }
.metric-accent-orange { --mc: #f59e0b; --mc-bg: #fffbeb; }
.metric-accent-purple { --mc: #8b5cf6; --mc-bg: #f5f3ff; }
.metric-accent-teal   { --mc: #14b8a6; --mc-bg: #f0fdfa; }
.metric-accent-pink   { --mc: #ec4899; --mc-bg: #fdf2f8; }
.metric-accent-green  { --mc: #10b981; --mc-bg: #ecfdf5; }
.metric-accent-cyan   { --mc: #0ea5e9; --mc-bg: #e0f2fe; }
.metric-accent-amber  { --mc: #f97316; --mc-bg: #fff7ed; }
.metric-accent-indigo { --mc: #6366f1; --mc-bg: #eef2ff; }
.metric-accent-danger  { --mc: #ef4444; --mc-bg: #fef2f2; }
.metric-accent-success { --mc: #10b981; --mc-bg: #ecfdf5; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; font-weight: 600; }
.text-danger  { color: var(--danger) !important; font-weight: 600; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--gray-500) !important; }

.metric-success {
    background: linear-gradient(135deg, var(--success-soft), #fff) !important;
    border-left: 4px solid var(--success) !important;
}
.metric-success::before { background: var(--success); }
.metric-success .metric-value { color: var(--success) !important; }
.metric-danger {
    background: linear-gradient(135deg, var(--danger-soft), #fff) !important;
    border-left: 4px solid var(--danger) !important;
}
.metric-danger::before { background: var(--danger); }
.metric-danger .metric-value { color: var(--danger) !important; }

/* ============ 趋势图 ============ */
.trend-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}
.chart-container {
    height: 400px;
    position: relative;
    padding: 24px 20px 16px !important;
}
.trend-tabs {
    padding: 16px 22px !important;
    background: linear-gradient(135deg, #fafbff, #f8f9fc) !important;
    border-bottom: 1px solid var(--gray-200) !important;
}
.tab-buttons { display: flex; gap: 7px; flex-wrap: wrap; }
.trend-tab {
    padding: 8px 16px;
    border: 1.5px solid transparent;
    background: #fff;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.trend-tab:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--primary-soft);
    transform: translateY(-1px);
}
.trend-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px -3px rgba(79,70,229,0.5);
    transform: translateY(-1px);
}

/* ============ 渠道卡片 ============ */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.channel-card {
    --cc: var(--primary);
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.channel-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.channel-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #fff, var(--gray-50));
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 10px;
}
.channel-header::before {
    content: "";
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--cc);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cc) 18%, transparent);
}
.channel-header h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}
.channel-card.c0 { --cc: #f59e0b; }
.channel-card.c1 { --cc: #10b981; }
.channel-card.c2 { --cc: #8b5cf6; }
.channel-card.c3 { --cc: #0ea5e9; }
.channel-card.c4 { --cc: #ec4899; }

.channel-stats { padding: 8px 20px 14px; }
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px dashed var(--gray-200);
    font-size: 14px;
}
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-row span:first-child { color: var(--gray-500); }
.stat-row strong { font-weight: 700; font-size: 15px; color: var(--gray-800); }

/* ============ 推广费管理 - 双卡片布局 ============ */
.ad-spend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin-top: 0;
}
.ad-card { border-radius: var(--radius); overflow: hidden; }
.card-header-accent-blue {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-left: 4px solid var(--primary);
}
.card-header-accent-green {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-left: 4px solid var(--success);
}
.card-icon { font-size: 17px; }
.ad-form .form-field {
    margin-bottom: 14px;
}
.ad-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ad-form .form-control,
.ad-form .form-control-file {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--gray-300);
    background: #fff;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ad-form .form-control:focus,
.ad-form .form-control-file:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.ad-form .btn-block {
    width: 100%;
    padding: 11px;
    margin-top: 6px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 8px;
}
.text-sm { font-size: 13px; }

/* ============ 后台/快捷卡片 ============ */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.admin-card {
    --ac: var(--primary);
    background: #fff;
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    color: var(--gray-800);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.admin-card::after {
    content: "";
    position: absolute;
    right: -20px; top: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--ac) 10%, transparent);
}
.admin-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); color: var(--gray-900); }
.admin-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--ac) 12%, transparent);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    margin-bottom: 14px;
}
.admin-title { font-size: 16px; font-weight: 700; margin-bottom: 5px; position: relative; }
.admin-desc { font-size: 13px; color: var(--gray-500); position: relative; }
.admin-card.a0 { --ac: #4f46e5; }
.admin-card.a1 { --ac: #0ea5e9; }
.admin-card.a2 { --ac: #10b981; }
.admin-card.a3 { --ac: #f59e0b; }

.alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    color: #92400e;
    margin-bottom: 20px;
    font-weight: 500;
}
.alert-icon { font-size: 20px; }

/* ============ 上传区域 ============ */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

/* ============ 通用卡片 ============ */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--gray-800); margin: 0; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 22px; }
.mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 12px; }
.my-4 { margin: 22px 0; border: 0; border-top: 1px solid var(--gray-200); }

/* ============ 表单 ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    font-size: 14px;
    transition: all 0.18s;
    background: #fff;
    color: var(--gray-800);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-control-sm { padding: 7px 11px; font-size: 13px; width: auto; }
.form-control-file {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--gray-300);
    border-radius: 10px;
    background: var(--gray-50);
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.18s;
}
.form-control-file:hover { border-color: var(--primary-light); background: var(--primary-soft); }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; }
.form-check-label { font-size: 14px; color: var(--gray-700); }
.form-text { font-size: 12px; color: var(--gray-500); margin-top: 4px; display: block; }
.form-inline { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }
/* Bootstrap 风格栅格兼容（订单筛选用） */
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row.g-2 { gap: 8px; }
.col-auto { display: flex; flex-direction: column; gap: 4px; }
.align-items-end { align-items: flex-end; }
.form-label { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 0; }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    text-decoration: none;
    gap: 6px;
    font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
    box-shadow: 0 4px 12px -2px rgba(79,70,229,0.45);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-outline { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); color: var(--gray-900); border-color: var(--gray-400); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }
.btn.disabled, .btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; }
.btn-group .btn { border-radius: 9px; }

/* ============ 提示框 ============ */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: block;
    border: 1px solid transparent;
    line-height: 1.6;
}
.alert strong {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}
.alert div {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-bottom: 4px;
    padding-left: 0;
    box-sizing: border-box;
    word-break: break-word;
}
.alert::before { font-size: 16px; }
.alert-ok      { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.alert-ok::before { content: "✅"; }
.alert-error   { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert-error::before { content: "⛔"; }
.alert-warn    { background: var(--warning-soft); color: #92400e; border-color: #fcd34d; }
.alert-warn::before { content: "⚠️"; }
.alert-warning { background: var(--warning-soft); color: #92400e; border-color: #fcd34d; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-info::before { content: "ℹ️"; }
.alert-success { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }

/* ============ 表格 ============ */
.table-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.pager { display: flex; align-items: center; gap: 10px; color: var(--gray-500); font-size: 13px; }
.pager-bottom { justify-content: flex-end; margin-top: 14px; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 13px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    text-align: left;
    padding: 13px 16px;
    border-bottom: 2px solid var(--gray-200);
}
.table tbody td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}
.table tbody tr:nth-child(even) { background: #fcfdff; }
.table tbody tr:hover { background: var(--primary-soft); }
.table-sm th, .table-sm td { padding: 8px 12px; }
.table-borderless th, .table-borderless td { border-bottom: none; padding: 8px 0; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.py-4 { padding: 24px 0; }
.product-id-cell { font-weight: 700; color: var(--gray-700); background: var(--gray-50); vertical-align: top; }

/* ============ 徽章 / 状态 ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }
.badge-light   { background: var(--gray-100); color: var(--gray-500); }

/* ============ 登录页 ============ */
.login-page {
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,0.35), transparent),
        radial-gradient(1000px 500px at 110% 110%, rgba(139,92,246,0.30), transparent),
        linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-container { width: 100%; max-width: 410px; }
.login-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,0.55);
    overflow: hidden;
}
.login-banner {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    padding: 30px 32px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
}
.login-banner .brand-mark {
    background: rgba(255,255,255,0.2);
    box-shadow: none;
}
.login-banner h1 { font-size: 20px; font-weight: 700; margin: 0; }
.login-banner p { font-size: 13px; opacity: 0.85; margin: 2px 0 0; }
.login-inner { padding: 28px 32px 32px; }
.login-desc { color: var(--gray-500); font-size: 14px; margin-bottom: 20px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-control { padding: 12px 16px; font-size: 15px; }
.login-tip { text-align: center; font-size: 12px; color: var(--gray-400); margin-top: 18px; }

/* ============ 成本表单小输入框 ============ */
.cost-form { gap: 6px; flex-wrap: nowrap; }
.cost-input { width: 90px; min-width: 90px; }

/* ============ 移动端抽屉导航控件（全局，桌面隐藏） ============ */
.menu-toggle {
    display: none;
    width: 40px; height: 40px;
    flex: 0 0 auto;
    align-items: center; justify-content: center;
    border: 1px solid var(--gray-200);
    background: #fff;
    border-radius: 10px;
    color: var(--gray-700);
    font-size: 19px; line-height: 1;
    cursor: pointer;
    transition: all .18s;
    margin-right: 2px;
}
.menu-toggle:hover { background: var(--gray-50); color: var(--primary); }
.menu-toggle:active { transform: scale(.94); }
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
body.nav-open .sidebar-backdrop { display: block; }

/* ============ PC / 全局视觉打磨 ============ */
html { scroll-behavior: smooth; }
.card { transition: box-shadow .2s, transform .2s; }
.card:hover { box-shadow: var(--shadow); }
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 8px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 8px; }
.content::-webkit-scrollbar-track { background: transparent; }

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
    .app-shell { display: block; width: 100%; overflow-x: hidden; }
    /* 侧边栏改为左侧抽屉，默认隐藏，点击汉堡滑出 */
    .menu-toggle { display: inline-flex; }
    .sidebar {
        width: 264px;
        max-width: 82vw;
        height: 100vh;
        position: fixed;
        top: 0; left: 0;
        padding: 22px 0;
        overflow-y: auto;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    .brand { padding: 0 22px 22px; margin-bottom: 18px; }
    .brand small { display: block; }
    .nav-section { display: block; }
    .nav {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 4px;
        padding: 0 14px;
        overflow: visible;
    }
    .nav a { flex: 0 0 auto; padding: 12px 14px; white-space: nowrap; font-size: 15px; }
    .nav a span { font-size: 18px; }
    .nav a.active::before { display: block; }
    .side-user, .sidebar-footer { display: flex; }
    .main { margin-left: 0 !important; width: 100%; min-width: 0; overflow-x: hidden; }
    .topbar { width: 100%; min-height: 58px; height: auto; padding: 10px 14px; gap: 10px; }
    .crumb { font-size: 16px; min-width: 0; }
    .account { flex: 0 0 auto; gap: 10px; }
    .content { width: 100%; padding: 16px; overflow-x: hidden; }
    .page-header { margin-bottom: 16px; }
    .page-header h2 { font-size: 22px; }
    .date-filter, .date-form { width: 100%; min-width: 0; }
    .date-form { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 8px; align-items: center; }
    .date-form input[type="hidden"] { display: none; }
    .date-form .form-control-sm { width: 100%; min-width: 0; }
    .date-form .quick-tabs { grid-column: 1 / -1; width: 100%; min-width: 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .date-form > button { grid-column: 1 / -1; width: 100%; }
    .quick-tabs .tab { flex: 0 0 auto; white-space: nowrap; }
    .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 10px; }
    .metric-card { padding: 14px 12px; border-radius: 12px; }
    .metric-icon { width: 32px; height: 32px; font-size: 16px; }
    .metric-label { font-size: 12px; }
    .metric-value { font-size: clamp(18px, 5vw, 23px); }
    .channel-grid, .upload-grid, .admin-grid, .ad-spend-grid { grid-template-columns: 1fr !important; }
    .form-inline { flex-direction: column; gap: 12px; align-items: stretch; }
    .form-inline .form-group, .form-inline .form-group label { width: 100%; margin: 0; }
    .form-inline .form-control { width: 100%; }
    .form-inline .mt-4 { margin-top: 0 !important; }
    .table { font-size: 13px; }
    .table thead th, .table tbody td { padding: 10px 10px; }
    /* 移动端表格：冻结首列 + 平滑横向滚动，提升可读性 */
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .table-responsive .table thead th { position: sticky; top: 0; z-index: 2; }
    .table-responsive .table th:first-child,
    .table-responsive .table td:first-child {
        position: sticky; left: 0; z-index: 1;
        background: #fff;
        box-shadow: 1px 0 0 var(--gray-200);
    }
    .table-responsive .table thead th:first-child { z-index: 3; }
    .table-meta { align-items: stretch; }
    .pager, .pager-bottom { justify-content: space-between; width: 100%; }
    .cost-form { flex-direction: row; gap: 4px; flex-wrap: wrap; }
    .cost-input { width: 80px; min-width: auto; }
    .btn-group { width: 100%; }
    .btn-group .btn { flex: 1; }
    /* 触摸目标放大，操作更方便 */
    .btn, .nav a, .tab, .trend-tab, .mp-cell, .tab-month { min-height: 42px; }
    .table .btn { min-height: 36px; }
    .chart-container { height: 300px; padding: 12px !important; }
    .tab-buttons { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .trend-tab { white-space: nowrap; }
    /* 月份选择器在手机上居中显示 */
    .month-picker-panel.open {
        top: 50% !important; left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: min(340px, 92vw);
        min-width: auto;
        max-height: 82vh; overflow: auto;
        animation: mpFadeInMobile .15s ease;
    }
}
@keyframes mpFadeInMobile { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 480px) {
    .metrics-grid, .admin-grid { grid-template-columns: 1fr; }
    .metric-value { font-size: 20px; }
    .section-title { font-size: 15px; }
    .crumb { font-size: 15px; }
    .content { padding: 12px; }
}
@media (max-width: 380px) {
    .content { padding: 10px; }
    .metrics-grid { gap: 8px; }
    .metric-card { padding: 12px 10px; }
}

/* ===== 税务核算进度条 ===== */
.progress {
    display: flex;
    overflow: hidden;
    background-color: var(--gray-200, #e9ecef);
    border-radius: 10px;
}
.progress .bg-success { background-color: #28a745; }
.progress .bg-warning { background-color: #ffc107; }
.progress .bg-danger { background-color: #dc3545; }
.bg-success { background-color: #28a745; }
.bg-warning { background-color: #ffc107; }
.bg-danger { background-color: #dc3545; }
.h4 { font-size: 1.5rem; font-weight: 600; }

/* ===== 税务核算 下周期可售卖 提示框 ===== */
.sellable-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid transparent;
}
.sellable-box strong { font-size: 15px; font-weight: 700; }
.sellable-ok {
    background-color: #e8f5e9;
    border-color: #c8e6c9;
    color: #1b5e20;
}
.sellable-warning {
    background-color: #fff8e1;
    border-color: #ffe0b2;
    color: #e65100;
}
.sellable-danger {
    background-color: #fdecea;
    border-color: #f5c6cb;
    color: #c62828;
}
.sellable-monthly {
    background-color: #f3e5f5;
    border-color: #e1bee7;
    color: #4a148c;
}

/* 行内编辑金额 */
.tax-amount-cell {
    padding: 4px 8px !important;
    border-radius: 4px;
}
.tax-amount-cell .btn {
    vertical-align: middle;
}
.tax-edit-input {
    font-size: 13px !important;
}
