:root {
    --shopee-primary: #ee4d2d;
    --shopee-primary-dark: #d73211;
    --shopee-primary-light: #ff6533;
    --bg-color: #f5f5f5;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --success-color: #2e7d32;
    --danger-color: #c62828;
    --text-muted: #6c757d;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--shopee-primary) 0%, var(--shopee-primary-dark) 100%) !important;
    box-shadow: 0 2px 8px rgba(238,77,45,0.3);
    padding: 0.6rem 1rem;
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}
.navbar .form-control,
.navbar .btn {
    font-size: 0.875rem;
}
/* ===== Filter Bar (下栏筛选区) ===== */
.filter-bar {
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 0.6rem 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.filter-bar .date-range-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-bar .date-picker-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.filter-bar .date-picker-wrap input[type="text"] {
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #333;
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    width: 220px;
    transition: all 0.2s;
}
.filter-bar .date-picker-wrap input[type="text"]:hover {
    border-color: #bbb;
    background: #eee;
}
.filter-bar .date-picker-wrap input[type="text"]::placeholder {
    color: #999;
}
.filter-bar .quick-date-btns {
    display: flex;
    gap: 0.3rem;
}
.filter-bar .quick-date-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #555;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.filter-bar .quick-date-btn:hover,
.filter-bar .quick-date-btn.active {
    background: var(--shopee-primary);
    border-color: var(--shopee-primary);
    color: #fff;
}
/* 通用 .btn-query 样式（导出按钮等也使用） */
.btn-query {
    background: var(--shopee-primary);
    border: 1px solid var(--shopee-primary-dark);
    color: #fff;
    font-weight: 600;
    padding: 0.35rem 1.2rem;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
    white-space: nowrap;
}
.btn-query:hover {
    background: var(--shopee-primary-dark);
    border-color: var(--shopee-primary-dark);
    color: #fff;
}
.btn-query:active {
    transform: scale(0.97);
}
/* Flatpickr 移动端适配 */
.flatpickr-calendar { z-index: 999999 !important; }

/* --- Flatpickr 移动端样式 --- */
@media (max-width: 768px) {
    .flatpickr-calendar {
        width: 100% !important;
        max-width: 340px;
        left: 50% !important;
        transform: translateX(-50%);
        box-shadow: 0 4px 20px rgba(0,0,0,0.2);
        border-radius: 12px;
        font-size: 14px;
    }
    .flatpickr-calendar .flatpickr-months {
        padding: 0.4rem 0;
    }
    .flatpickr-calendar .flatpickr-months .flatpickr-month {
        font-size: 14px;
        height: 36px;
    }
    .flatpickr-calendar .flatpickr-current-month .flatpickr-monthDropdown-months {
        font-size: 14px;
        font-weight: 600;
    }
    .flatpickr-calendar .flatpickr-current-month input.cur-year {
        font-size: 14px;
    }
    .flatpickr-calendar .flatpickr-weekdays {
        height: 28px;
    }
    .flatpickr-calendar .flatpickr-weekday {
        font-size: 11px;
        height: 28px;
        line-height: 28px;
    }
    .flatpickr-calendar .dayContainer {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        padding: 0 0.3rem;
    }
    .flatpickr-calendar .flatpickr-days {
        width: 100%;
    }
    .flatpickr-calendar .flatpickr-day {
        height: 36px;
        line-height: 36px;
        font-size: 13px;
        border-radius: 8px;
        max-width: 36px;
    }
    .flatpickr-calendar .flatpickr-day.selected,
    .flatpickr-calendar .flatpickr-day.startRange,
    .flatpickr-calendar .flatpickr-day.endRange,
    .flatpickr-calendar .flatpickr-day.inRange {
        border-radius: 8px;
    }
    .flatpickr-calendar .flatpickr-months .flatpickr-prev-month,
    .flatpickr-calendar .flatpickr-months .flatpickr-next-month {
        width: 32px;
        height: 32px;
        padding: 4px;
    }
    .flatpickr-calendar .flatpickr-months .flatpickr-prev-month svg,
    .flatpickr-calendar .flatpickr-months .flatpickr-next-month svg {
        width: 14px;
        height: 14px;
    }
    /* 遮罩层 */
    .flatpickr-calendar.arrowTop::before,
    .flatpickr-calendar.arrowTop::after,
    .flatpickr-calendar.arrowBottom::before,
    .flatpickr-calendar.arrowBottom::after {
        display: none;
    }
}

/* Main content */
.main-content {
    padding: 1.5rem 0 3rem;
}

/* KPI Cards */
.kpi-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1.25rem 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    position: relative;
    overflow: hidden;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}
.kpi-card.cost::before { background: var(--shopee-primary); }
.kpi-card.direct-gmv::before { background: #2e7d32; }
.kpi-card.broad-gmv::before { background: #1565c0; }
.kpi-card.total-gmv::before { background: #e65100; }
.kpi-card.roi::before { background: #6a1b9a; }
.kpi-card.orders::before { background: #4527a0; }

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}
.kpi-icon.cost { background: linear-gradient(135deg, var(--shopee-primary), var(--shopee-primary-light)); }
.kpi-icon.direct-gmv { background: linear-gradient(135deg, #2e7d32, #43a047); }
.kpi-icon.broad-gmv { background: linear-gradient(135deg, #1565c0, #1e88e5); }
.kpi-icon.total-gmv { background: linear-gradient(135deg, #e65100, #f57c00); }
.kpi-icon.roi { background: linear-gradient(135deg, #6a1b9a, #8e24aa); }
.kpi-icon.orders { background: linear-gradient(135deg, #4527a0, #7b1fa2); }

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 500;
}
.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #212529;
    line-height: 1.2;
}
.kpi-trend {
    font-size: 0.75rem;
    margin-top: 0.2rem;
}
.kpi-trend.up { color: var(--success-color); }
.kpi-trend.down { color: var(--danger-color); }

/* Chart Cards */
.chart-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
    border: none;
    margin-bottom: 1.5rem;
}
.chart-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chart-card-title i {
    color: var(--shopee-primary);
}
.chart-container {
    position: relative;
    width: 100%;
    min-height: 300px;
}

/* Ranking Table */
.ranking-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
    border: none;
    margin-bottom: 1.5rem;
}
.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.ranking-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ranking-title i {
    color: var(--shopee-primary);
}
.sort-select {
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    color: #495057;
    min-width: 140px;
}
.sort-select:focus {
    border-color: var(--shopee-primary);
    box-shadow: 0 0 0 2px rgba(238,77,45,0.15);
}

.table-rank {
    font-size: 0.8rem;
    color: #212529;
    width: 100%;
    min-width: 900px;
}
.table-rank thead th {
    background: #fafafa;
    border-bottom: 2px solid var(--shopee-primary);
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    padding: 0.65rem 0.5rem;
    font-size: 0.78rem;
    position: sticky;
    top: 0;
    z-index: 1;
}
.table-rank tbody td {
    padding: 0.55rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.8rem;
}
.table-rank tbody tr:hover {
    background-color: #fff8f6;
}
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.75rem;
}
.rank-1 { background: linear-gradient(135deg, #ffd700, #ffb300); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #b0bec5, #90a4ae); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #d7a86e, #b8860b); color: #fff; }
.rank-other { background: #f5f5f5; color: #757575; }

.state-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
}
.state-normal { background: #e8f5e9; color: #2e7d32; }
.state-paused { background: #fff3e0; color: #e65100; }
.state-ended { background: #f5f5f5; color: #757575; }
.state-ongoing { background: #e3f2fd; color: #1565c0; }

.table-responsive {
    max-height: 520px;
    overflow-x: auto;
    overflow-y: auto;
}

.table-rank .num-positive { color: var(--success-color); font-weight: 600; }
.table-rank .num-negative { color: var(--danger-color); font-weight: 600; }

/* Pagination */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.pagination-wrapper .page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.pagination-wrapper .btn-page {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    transition: all 0.15s;
}
.pagination-wrapper .btn-page:hover:not(:disabled) {
    background: var(--shopee-primary);
    color: #fff;
    border-color: var(--shopee-primary);
}
.pagination-wrapper .btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Upload Logs */
.logs-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
    border: none;
    margin-bottom: 1.5rem;
}
.logs-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.logs-title i {
    color: var(--shopee-primary);
}
.logs-table {
    font-size: 0.82rem;
}
.logs-table thead th {
    background: #fafafa;
    font-weight: 600;
    color: #495057;
    font-size: 0.78rem;
    border-bottom: 2px solid var(--shopee-primary);
    padding: 0.6rem 0.75rem;
}
.logs-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}
.status-success {
    color: var(--success-color);
    font-weight: 600;
}
.status-failed {
    color: var(--danger-color);
    font-weight: 600;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.spinner-shopee {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(238,77,45,0.2);
    border-top-color: var(--shopee-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}
.empty-state p {
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in {
    animation: fadeInUp 0.4s ease-out forwards;
}
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }

/* Toast notification */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
}
.custom-toast {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease-out;
    max-width: 360px;
}
.custom-toast.error {
    border-left: 4px solid var(--danger-color);
}
.custom-toast.success {
    border-left: 4px solid var(--success-color);
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 991.98px) {
    .filter-bar .date-range-group { flex-wrap: wrap; }
    .filter-bar .date-picker-wrap input[type="text"] { width: 100%; }
}
@media (max-width: 768px) {
    /* 导航栏 */
    .navbar .navbar-brand { font-size: 0.9rem; }
    .navbar .container-fluid { padding: 0 0.5rem !important; }
    .filter-bar .date-range-group { flex-wrap: wrap; gap: 0.4rem; }
    .filter-bar .date-picker-wrap { flex: 1 1 100%; }
    .filter-bar .date-picker-wrap input[type="text"] { width: 100%; font-size: 0.8rem; }
    .filter-bar .quick-date-btns { flex-wrap: wrap; gap: 0.25rem; }
    .filter-bar .quick-date-btn { font-size: 0.7rem; padding: 0.2rem 0.45rem; }
    .btn-query { padding: 0.3rem 0.8rem; font-size: 0.8rem; }

    /* KPI 卡片 */
    .kpi-card { padding: 0.75rem; border-radius: 8px; }
    .kpi-icon { width: 34px; height: 34px; font-size: 0.95rem; border-radius: 8px; }
    .kpi-label { font-size: 0.7rem; }
    .kpi-value { font-size: 1.1rem; }
    .kpi-trend { font-size: 0.65rem; }

    /* 图表 */
    .chart-card { padding: 0.75rem; border-radius: 8px; }
    .chart-card-title { font-size: 0.85rem; margin-bottom: 0.5rem; }
    .chart-container { min-height: 220px; }

    /* 分析模块 */
    .insight-card { padding: 0.75rem; border-radius: 8px; }
    .insight-card-title { font-size: 0.85rem; margin-bottom: 0.5rem; }
    .insight-card > div[style*="font-size:0.75rem"] { font-size: 0.68rem !important; }
    .health-score-ring { width: 80px; height: 80px; }
    .health-score-inner { width: 60px; height: 60px; }
    .health-score-inner .score-num { font-size: 1.3rem; }
    .health-metric-label { font-size: 0.72rem; width: 50px; }
    .health-metric-value { font-size: 0.72rem; width: 40px; }
    .funnel-bar { height: 28px; font-size: 0.75rem; }
    .funnel-value { font-size: 0.78rem; width: 60px; }
    .funnel-rate { font-size: 0.68rem; }
    .quadrant-legend { font-size: 0.68rem; gap: 0.4rem; }

    /* 排名表格 */
    .ranking-card { padding: 0.75rem; border-radius: 8px; }
    .ranking-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .ranking-title { font-size: 0.9rem; }
    .sort-select { font-size: 0.78rem; }
    .table-rank { font-size: 0.72rem; }
    .table-rank th, .table-rank td { padding: 0.35rem 0.3rem; white-space: nowrap; }

    /* 上传记录 */
    .logs-card { padding: 0.75rem; border-radius: 8px; }
    .logs-title { font-size: 0.9rem; }
    .logs-table { font-size: 0.72rem; }

    /* 主内容 */
    .main-content { padding: 0.75rem 0 2rem; }
    .container-fluid { padding: 0 0.5rem !important; }
}


@media (max-width: 768px) {
    .nav-tabs-custom { margin-left: 0; margin-top: 0.5rem; }
    .nav-tab-btn { font-size: 0.75rem; padding: 0.2rem 0.6rem; }
    .prod-ranking-card { padding: 0.75rem; border-radius: 8px; }
    .prod-ranking-card .ranking-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

@media (max-width: 576px) {
    .kpi-card { padding: 0.6rem; }
    .kpi-icon { width: 30px; height: 30px; font-size: 0.85rem; }
    .kpi-value { font-size: 1rem; }
    .kpi-label { font-size: 0.65rem; }
    .chart-container { min-height: 200px; }
    .insight-card > div[style*="height:220px"] { height: 180px !important; }
}

/* Scrollbar styling */
.table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: #f5f5f5;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
/* ===== 分析模块样式 ===== */
.insight-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 1.25rem;
    border: none;
}
.insight-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.insight-card-title i { color: var(--shopee-primary); }

/* 健康度评分 */
.health-score-ring {
    width: 100px; height: 100px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 700;
    margin: 0 auto 0.75rem;
    position: relative;
}
.health-score-ring.grade-a { background: conic-gradient(#2e7d32 0deg, #43a047 calc(var(--score) * 3.6deg), #e8f5e9 calc(var(--score) * 3.6deg)); }
.health-score-ring.grade-b { background: conic-gradient(#1565c0 0deg, #1e88e5 calc(var(--score) * 3.6deg), #e3f2fd calc(var(--score) * 3.6deg)); }
.health-score-ring.grade-c { background: conic-gradient(#e65100 0deg, #f57c00 calc(var(--score) * 3.6deg), #fff3e0 calc(var(--score) * 3.6deg)); }
.health-score-ring.grade-d { background: conic-gradient(#c62828 0deg, #e53935 calc(var(--score) * 3.6deg), #ffebee calc(var(--score) * 3.6deg)); }
.health-score-inner {
    width: 76px; height: 76px;
    border-radius: 50%;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
}
.health-score-inner .score-num { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.health-score-inner .score-grade { font-size: 0.75rem; color: #888; margin-top: 2px; }

.health-metric {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f5f5f5;
}
.health-metric:last-child { border-bottom: none; }
.health-metric-label { font-size: 0.82rem; color: #666; width: 60px; flex-shrink: 0; }
.health-metric-bar { flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.health-metric-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.health-metric-bar-fill.good { background: linear-gradient(90deg, #2e7d32, #43a047); }
.health-metric-bar-fill.warn { background: linear-gradient(90deg, #e65100, #f57c00); }
.health-metric-bar-fill.bad { background: linear-gradient(90deg, #c62828, #e53935); }
.health-metric-value { font-size: 0.82rem; font-weight: 600; width: 50px; text-align: right; }

/* 转化漏斗 */
.funnel-step {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 0.75rem;
}
.funnel-bar-wrap { flex: 1; }
.funnel-bar {
    height: 36px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 0.85rem;
    transition: width 0.5s;
    min-width: 60px;
}
.funnel-rate {
    font-size: 0.78rem; color: #888; margin-top: 2px;
}
.funnel-value {
    font-size: 0.9rem; font-weight: 600; width: 80px; text-align: right;
}

/* 四象限 */
.quadrant-legend {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
    font-size: 0.78rem; margin-bottom: 0.75rem;
}
.quadrant-legend span {
    display: flex; align-items: center; gap: 4px;
}
.quadrant-legend .dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
/* ===== 广告详情弹窗 ===== */
.detail-modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 100000;
    justify-content: center; align-items: center;
}
.detail-modal-overlay.active { display: flex; }
.detail-modal {
    background: #fff; border-radius: 12px; width: 90%; max-width: 800px;
    max-height: 85vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: modalIn 0.25s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.detail-modal-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: #fff; z-index: 1; border-radius: 12px 12px 0 0;
}
.detail-modal-header h5 { margin: 0; font-size: 1rem; font-weight: 600; color: #333; }
.detail-modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer;
    color: #999; padding: 0 4px; line-height: 1;
}
.detail-modal-close:hover { color: #333; }
.detail-modal-body { padding: 1.25rem; }
.detail-kpi-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem; margin-bottom: 1rem;
}
.detail-kpi-item {
    background: #f8f9fa; border-radius: 8px; padding: 0.75rem; text-align: center;
}
.detail-kpi-item .label { font-size: 0.75rem; color: #888; margin-bottom: 0.25rem; }
.detail-kpi-item .value { font-size: 1.1rem; font-weight: 700; color: #333; }
.detail-kpi-item .value.positive { color: #2e7d32; }
.detail-kpi-item .value.negative { color: #c62828; }
.detail-chart-wrap { height: 220px; margin-bottom: 1rem; }
.ranking-table tbody tr { cursor: pointer; }
.ranking-table tbody tr:hover { background: #fff5f2 !important; }
/* ===== 预警横幅 ===== */
.alert-banner {
    border-radius: 8px; padding: 0.75rem 1rem;
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    font-size: 0.85rem; animation: bannerSlide 0.3s ease-out;
}
.alert-banner.warn { background: #fff3e0; border: 1px solid #ffe0b2; color: #e65100; }
.alert-banner.danger { background: #ffebee; border: 1px solid #ffcdd2; color: #c62828; }
.alert-banner.good { background: #e8f5e9; border: 1px solid #c8e6c9; color: #2e7d32; }
.alert-banner .alert-icon { font-size: 1.2rem; }
.alert-banner .alert-item { display: flex; align-items: center; gap: 0.3rem; }
.alert-banner .alert-item + .alert-item::before { content: '|'; margin-right: 0.5rem; color: rgba(0,0,0,0.2); }
@keyframes bannerSlide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Tab Navigation ===== */
.nav-tabs-custom {
    display: flex;
    gap: 0.25rem;
    margin-left: 1.5rem;
}
.nav-tab-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.75);
    padding: 0.3rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.nav-tab-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.nav-tab-btn.active {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    color: #fff;
    font-weight: 600;
}
.nav-tab-btn i { margin-right: 0.3rem; }

/* ===== Product Panel KPI Cards (Teal theme) ===== */
.kpi-card.prod-impressions::before { background: #00796b; }
.kpi-card.prod-uv::before { background: #00897b; }
.kpi-card.prod-clicks::before { background: #26a69a; }
.kpi-card.prod-cart::before { background: #4db6ac; }
.kpi-card.prod-sales::before { background: #00695c; }
.kpi-card.prod-orders::before { background: #004d40; }

.kpi-icon.prod-impressions { background: linear-gradient(135deg, #00796b, #00897b); }
.kpi-icon.prod-uv { background: linear-gradient(135deg, #00897b, #26a69a); }
.kpi-icon.prod-clicks { background: linear-gradient(135deg, #26a69a, #4db6ac); }
.kpi-icon.prod-cart { background: linear-gradient(135deg, #4db6ac, #80cbc4); }
.kpi-icon.prod-sales { background: linear-gradient(135deg, #00695c, #00796b); }
.kpi-icon.prod-orders { background: linear-gradient(135deg, #004d40, #00695c); }

/* Product ranking table teal theme */
.prod-ranking-card .table-rank thead th {
    border-bottom: 2px solid #00796b;
}
.prod-ranking-card .table-rank tbody tr:hover {
    background-color: #e0f2f1;
}
.prod-ranking-card .ranking-title i {
    color: #00796b;
}
.prod-ranking-card .sort-select:focus {
    border-color: #00796b;
    box-shadow: 0 0 0 2px rgba(0,121,107,0.15);
}

/* Product insight card teal accent */
.prod-insight-card .insight-card-title i { color: #00796b; }

/* Product chart card teal accent */
.prod-chart-card .chart-card-title i { color: #00796b; }

/* Tab panel visibility */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Mobile Optimization ===== */

/* --- 导航栏：压缩高度，胶囊Tab --- */
.navbar {
    padding: 0.35rem 0.5rem !important;
}
.navbar-brand {
    font-size: 0.95rem !important;
    padding: 0.2rem 0 !important;
}
.nav-tabs-custom {
    gap: 0.15rem;
    margin-left: 0.75rem;
}
.nav-tab-btn {
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.78rem;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
}
.nav-tab-btn.active {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.4);
}

/* --- 筛选栏：日期一行 + 横向滚动快捷标签 + 全宽查询按钮 --- */
.filter-bar {
    padding: 0.4rem 0.5rem;
}
.filter-date-row {
    margin-bottom: 0.35rem;
}
.filter-date-row .date-picker-wrap {
    width: 100%;
}
.filter-date-row .date-picker-wrap input[type="text"] {
    width: 100%;
    font-size: 0.82rem;
    padding: 0.3rem 0.6rem;
}
.quick-date-scroll {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.25rem 0;
    margin-bottom: 0.4rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.quick-date-scroll::-webkit-scrollbar { display: none; }
.quick-date-chip {
    flex-shrink: 0;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    color: #555;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.quick-date-chip:hover,
.quick-date-chip.active {
    background: var(--shopee-primary);
    border-color: var(--shopee-primary);
    color: #fff;
}
.btn-query-full {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* --- 手机端 (≤576px) --- */
@media (max-width: 576px) {
    .navbar .container-fluid {
        padding: 0.25rem 0.5rem !important;
    }
    .navbar-brand {
        font-size: 0.85rem !important;
    }
    .nav-tabs-custom {
        margin-left: auto;
        gap: 0.1rem;
    }
    .nav-tab-btn {
        padding: 0.15rem 0.55rem;
        font-size: 0.7rem;
        border-radius: 16px;
    }
    .nav-tab-btn i { font-size: 0.65rem; }

    .filter-bar { padding: 0.35rem 0.4rem; }
    .filter-date-row .date-picker-wrap input[type="text"] {
        font-size: 0.78rem;
        padding: 0.28rem 0.5rem;
    }
    .quick-date-chip {
        font-size: 0.68rem;
        padding: 0.18rem 0.6rem;
        border-radius: 16px;
    }
    .btn-query-full {
        padding: 0.35rem;
        font-size: 0.8rem;
    }

    /* KPI 卡片 */
    .main-content { padding: 0.5rem 0 2rem; }
    .container-fluid { padding: 0 0.4rem !important; }
    .row { --bs-gutter-x: 0.4rem; --bs-gutter-y: 0.4rem; }
    .kpi-card {
        padding: 0.5rem 0.6rem;
        border-radius: 8px;
    }
    .kpi-card:hover { transform: none; box-shadow: var(--card-shadow); }
    .kpi-icon {
        width: 30px; height: 30px;
        font-size: 0.8rem;
        border-radius: 8px;
    }
    .kpi-label { font-size: 0.62rem; }
    .kpi-value { font-size: 0.9rem; }
    .kpi-trend { font-size: 0.58rem; }
    .col-6.col-lg-3 { flex: 0 0 auto; width: 50%; }

    /* 图表/表格全宽 */
    .col-lg-6, .col-lg-8, .col-lg-7, .col-lg-5, .col-lg-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    .card { border-radius: 8px; }
    .card-header { padding: 0.4rem 0.6rem; }
    .card-header h6 { font-size: 0.78rem; }
    .card-body { padding: 0.4rem; }
    .card-body[style*="height:300px"],
    .card-body[style*="height: 280px"] {
        height: 220px !important;
    }
    .card-body.p-0 { height: 220px !important; }
    .table { font-size: 0.7rem; }
    .table th, .table td { padding: 0.25rem 0.35rem; white-space: nowrap; }
    .table thead th { font-size: 0.68rem; }

    /* 漏斗卡片 */
    #funnelCards .col-md-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    #funnelCards .card { font-size: 0.72rem; }
    #funnelCards .card .small { font-size: 0.62rem; }

    /* 排名/上传 */
    .ranking-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem;
    }
    .ranking-title { font-size: 0.8rem; }
    .sort-select { font-size: 0.72rem; width: 100%; }
    .table-rank th, .table-rank td { padding: 0.25rem; font-size: 0.68rem; }
    .logs-title { font-size: 0.8rem; }
    .logs-table { font-size: 0.68rem; }
    .logs-table th, .logs-table td { padding: 0.25rem; white-space: nowrap; }

    /* 滚动条 */
    .table-responsive::-webkit-scrollbar { height: 3px; }
    .card-body::-webkit-scrollbar { width: 3px; height: 3px; }
}

/* --- 平板适配 (577px - 992px) --- */
@media (min-width: 577px) and (max-width: 992px) {
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-8 { flex: 0 0 66.66%; max-width: 66.66%; }
    .col-lg-4 { flex: 0 0 33.33%; max-width: 33.33%; }
    .col-lg-7 { flex: 0 0 58.33%; max-width: 58.33%; }
    .col-lg-5 { flex: 0 0 41.66%; max-width: 41.66%; }
    .card-body[style*="height:300px"],
    .card-body[style*="height: 280px"] {
        height: 260px !important;
    }
}
