:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar navigation */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: fixed;
    height: 100vh;
}

.brand {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-icon {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.nav-item:hover .menu-icon {
    transform: scale(1.1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--text-main);
}

.nav-item.active {
    border-left: 3px solid var(--accent);
}

/* Mobile adaptive elements (Hidden on PC by default) */
.mobile-header {
    display: none;
}

/* Main Dashboard Area */
.main-content {
    margin-left: 260px;
    padding: 2.5rem;
    overflow-x: hidden; /* 防止子元素撑开主内容区，确保横向滚动被约束在表格容器内 */
}

.header {
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Cards & Layout */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
}

.card-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Tab panes */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.4s ease forwards;
}

/* Drag & Drop Upload Zone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 4rem 2rem;
    text-align: center;
    background-color: rgba(30, 41, 59, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropzone:hover {
    border-color: var(--accent);
    background-color: rgba(30, 41, 59, 0.8);
}

/* Dark themed Glassy Tables */
/* Dark themed Glassy Tables with fixed scrollbars & scroll behavior */
.table-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto !important; /* 强制启用横向滚动条 */
    overflow-y: auto;
    max-height: calc(100vh - 280px); /* 限制最大高度，使横向滚动条在屏幕可见区域底部 */
    max-width: 100%; /* 限制最大宽度，防止表格把容器撑大 */
    width: 100%;     /* 限制宽度为父容器的100% */
    margin-top: 1.5rem;
    position: relative;
    cursor: grab; /* 指明可以拖拽滚动 */
    transition: box-shadow 0.2s ease;
}

/* 显式自定义表格容器的滚动条，高亮蓝色，确保绝对可见 */
.table-container::-webkit-scrollbar {
    height: 10px; /* 横向滚动条高度 */
    width: 8px;   /* 纵向滚动条宽度 */
    display: block !important; /* 确保滚动条不被隐藏 */
}

.table-container::-webkit-scrollbar-track {
    background: #0f172a !important; /* 轨道背景使用深暗色 */
    border-radius: 6px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #3b82f6 !important; /* 滑块使用高亮蓝色 */
    border-radius: 6px;
    border: 2px solid #0f172a;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #60a5fa !important; /* 悬浮时滑块变亮 */
}

.table-container.active-dragging {
    cursor: grabbing;
    user-select: none; /* 拖拽时禁止选中文本 */
}

table {
    width: 100%;
    border-collapse: separate; /* position: sticky 要求 border-collapse: separate 配合 border-spacing: 0，避免边框在滚动时穿透或抖动 */
    border-spacing: 0;
    text-align: left;
}

/* 固定表头（Sticky Header） */
.table-container thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #1e293b !important; /* 使用背景色遮挡tbody */
    box-shadow: inset 0 -1px 0 var(--border), inset 0 1px 0 var(--border);
    border-bottom: none;
}

/* 针对提成汇总表（有双层表头），特别处理第二行 th 的 top 偏移 */
.summary-table-container thead tr:first-child th {
    top: 0;
    z-index: 11;
}

.summary-table-container thead tr:nth-child(2) th {
    top: 45px; /* 第一行表头的实际高度 */
    z-index: 11;
}

th {
    background-color: rgba(15, 23, 42, 0.4);
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* 冻结列（Locked / Sticky Columns）通用规则 */
.sticky-col {
    position: sticky !important;
    z-index: 8 !important;
    background-color: var(--bg-secondary) !important;
}

/* 冻结列在 hover 状态下同样改变背景色 */
tr:hover .sticky-col {
    background-color: #243049 !important; /* 微亮的悬停底色 */
}

/* 冻结列表头的 z-index 必须高于普通表头和普通冻结列 */
thead th.sticky-col {
    z-index: 12 !important;
}

/* ERP原稿表锁定列宽度及 left 偏移 */
.erp-table .sticky-col-l1 { left: 0px; min-width: 100px; max-width: 100px; width: 100px; }
.erp-table .sticky-col-l2 { left: 100px; min-width: 120px; max-width: 120px; width: 120px; }
.erp-table .sticky-col-l3 { left: 220px; min-width: 80px; max-width: 80px; width: 80px; }
.erp-table .sticky-col-l4 { 
    left: 300px; 
    min-width: 140px; 
    max-width: 140px; 
    width: 140px; 
    box-shadow: 4px 0 8px -3px rgba(0, 0, 0, 0.6), inset -1px 0 0 var(--border) !important;
}

/* 提成汇总表锁定列宽度及 left 偏移 */
.summary-table .sticky-col-l1 { left: 0px; min-width: 60px; max-width: 60px; width: 60px; }
.summary-table .sticky-col-l2 { left: 60px; min-width: 110px; max-width: 110px; width: 110px; }
.summary-table .sticky-col-l3 { left: 170px; min-width: 80px; max-width: 80px; width: 80px; }
.summary-table .sticky-col-l4 { 
    left: 250px; 
    min-width: 90px; 
    max-width: 90px; 
    width: 90px; 
    box-shadow: 4px 0 8px -3px rgba(0, 0, 0, 0.6), inset -1px 0 0 var(--border) !important;
}
/* 提成汇总表第一行合并单元格 thead 的 sticky 偏移 */
.summary-table .sticky-col-l-group {
    left: 0px;
    min-width: 340px;
    max-width: 340px;
    width: 340px;
    box-shadow: 4px 0 8px -3px rgba(0, 0, 0, 0.6), inset -1px 0 0 var(--border) !important;
}

/* 表格内交互友好提示栏 */
.scroll-tip {
    font-size: 0.8rem;
    color: var(--success);
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


/* Role Badges styling */
.role-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}
.role-manager {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.role-craftsman {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.role-guide {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Modern Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--accent);
    outline: none;
}

.btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--accent-hover);
}

/* Filter controls bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Popup Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 12px;
    width: 480px;
    max-width: 90%;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Sub-Tab Styles */
.sub-tabs-container {
    display: flex;
    gap: 0.75rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    width: fit-content;
}

.sub-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sub-tab-btn:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

.sub-tab-btn.active {
    color: var(--text-main);
    background-color: var(--accent);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

/* 页面头部、筛选栏和提示的折叠缩拢动效 */
.tab-pane .header,
.tab-pane .filter-bar,
.tab-pane .scroll-tip {
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.2s ease, 
                margin 0.25s ease, 
                padding 0.25s ease,
                border-width 0.25s ease;
    max-height: 180px; /* 给予足够大的高 */
    opacity: 1;
    overflow: hidden;
}

/* 激活向上滚动（收拢头部）状态时的隐藏规则 */
body.header-collapsed .tab-pane.active .header {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body.header-collapsed .tab-pane.active .filter-bar {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-width: 0 !important;
}

body.header-collapsed .tab-pane.active .scroll-tip {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-width: 0 !important;
}

/* 折叠时，自动扩展表格容器的最大高度，容纳更多数据行 */
body.header-collapsed .table-container {
    max-height: calc(100vh - 120px) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* 全屏密码锁定遮罩样式 */
.lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, #1e293b, #0f172a);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999; /* 确保处于最顶级 */
    backdrop-filter: blur(10px);
}

.lock-card {
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid var(--border);
    padding: 3rem 2.5rem;
    border-radius: 16px;
    width: 420px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.5s ease;
}

.lock-icon {
    font-size: 3rem;
    margin-bottom: 1.25rem;
    animation: lockBounce 2s infinite ease-in-out;
}

.lock-input {
    text-align: center;
    font-size: 1.25rem !important;
    letter-spacing: 6px;
    background-color: rgba(15, 23, 42, 0.6) !important;
    border-color: #3b82f6 !important;
    font-weight: bold;
}

.lock-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.85rem;
    font-size: 1rem;
    background-color: var(--accent);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.lock-error {
    color: #f87171;
    font-size: 0.875rem;
    margin-top: 1.25rem;
    font-weight: 600;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem;
    border-radius: 6px;
    animation: lockShake 0.4s ease;
}

@keyframes lockShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

@keyframes lockBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 侧边栏底部主题切换面板 */
.sidebar-footer {
    margin-top: auto; /* 自动推至侧边栏Flex布局底部 */
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: rgba(15, 23, 42, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    background-color: rgba(59, 130, 246, 0.05);
}

.toggle-icon {
    font-size: 1.1rem;
    margin-right: 0.5rem;
}

.toggle-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-grow: 1;
}

.toggle-switch {
    width: 48px;
    height: 24px;
    background-color: var(--border);
    border-radius: 9999px;
    padding: 2px;
    position: relative;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover .toggle-switch {
    background-color: rgba(59, 130, 246, 0.3);
}

.toggle-knob {
    width: 20px;
    height: 20px;
    background-color: var(--text-main);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ==========================================
   浅色白金主题 (Light Mode / White Theme) 重置
   ========================================== */
body.light-theme {
    --bg-primary: #f1f5f9;       /* 柔和浅灰蓝色背景 */
    --bg-secondary: #ffffff;     /* 纯白卡片和侧边栏 */
    --accent: #2563eb;           /* 亮蓝色 */
    --accent-hover: #1d4ed8;
    --text-main: #0f172a;        /* 深灰黑色高对比度文字 */
    --text-muted: #475569;       /* 更深沉的辅助文字，确保浅色背景下极佳的可读性 */
    --border: #cbd5e1;           /* 浅灰白边框 */
}

/* 修正上传框在白色模式下的背景色 */
body.light-theme .dropzone {
    background-color: rgba(255, 255, 255, 0.8) !important;
    border-color: #cbd5e1 !important;
    color: var(--text-main) !important;
}
body.light-theme .dropzone:hover {
    background-color: #ffffff !important;
    border-color: var(--accent) !important;
}

/* 修正所有表头和固定/锁定表头单元格在白色模式下的背景和文字颜色 */
body.light-theme .table-container table thead th {
    background-color: #e2e8f0 !important; /* 精致淡灰表头背景，与 Excel 观感类似 */
    color: var(--text-main) !important;   /* 确保文字足够深 */
    box-shadow: inset 0 -1px 0 var(--border), inset 0 1px 0 var(--border) !important;
}

body.light-theme thead tr {
    background-color: rgba(226, 232, 240, 0.5) !important;
}

/* 提成汇总表第一层多级表头的锁定组 */
body.light-theme .summary-table .sticky-col-l-group {
    background-color: #cbd5e1 !important; /* 锁定组合并栏使用略深的深灰色，更显专业 */
    color: var(--text-main) !important;
}

/* 锁定列 (td) 修正 */
body.light-theme .sticky-col {
    background-color: #ffffff !important;
    color: var(--text-main) !important;
}

/* 锁定列的表头 (th) 修正 */
body.light-theme thead th.sticky-col {
    background-color: #cbd5e1 !important; /* 锁定列表头同样用稍深的灰色以作醒目区分 */
    color: var(--text-main) !important;
}

/* 浅色模式下鼠标悬停行背景色 */
body.light-theme tr:hover td {
    background-color: rgba(37, 99, 235, 0.05) !important;
}
body.light-theme tr:hover .sticky-col {
    background-color: #f1f5f9 !important;
}

/* 浅色模式提示条修正 */
body.light-theme .scroll-tip {
    background-color: rgba(37, 99, 235, 0.05) !important;
    border-color: rgba(37, 99, 235, 0.15) !important;
    color: #2563eb !important;
}

/* 亮色模式下锁屏卡片微调 */
body.light-theme .lock-card {
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15) !important;
}

/* 亮色模式下输入框微调 */
body.light-theme .lock-input {
    background-color: #ffffff !important;
    color: var(--text-main) !important;
    border-color: #cbd5e1 !important;
}
body.light-theme .lock-input:focus {
    border-color: var(--accent) !important;
}

/* 平滑主题过渡动效，避免瞬间变色刺眼 */
body, .sidebar, .main-content, .card, .table-container, table, th, td, .theme-toggle, .toggle-switch, .toggle-knob {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ==========================================
   仪表盘图表与红黑榜精美样式设计
   ========================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.chart-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px -15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.chart-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -20px rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.4);
}

.chart-header-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    border-left: 4px solid var(--accent);
    padding-left: 0.75rem;
    letter-spacing: 0.5px;
}

/* 红黑榜样式设计 */
.ranking-card {
    grid-column: span 2; /* 默认占据双列宽度以展现更丰富的对比 */
}

@media (max-width: 1024px) {
    .ranking-card {
        grid-column: span 1;
    }
}

.ranking-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .ranking-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.ranking-board {
    background-color: rgba(15, 23, 42, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

/* 亮色模式下排行榜背景微调 */
body.light-theme .ranking-board {
    background-color: rgba(226, 232, 240, 0.4);
}

.board-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border);
}

.red-board-list .board-title {
    color: #10b981; /* 绿色代表优秀荣誉 */
}

.black-board-list .board-title {
    color: #ef4444; /* 红色代表警示红线 */
}

.rank-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.85rem;
    background-color: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

/* 亮色模式下排行条目背景微调 */
body.light-theme .rank-item {
    background-color: #ffffff;
}

.rank-item:hover {
    transform: translateX(4px);
    border-color: var(--accent);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 50%;
    margin-right: 0.75rem;
    color: #ffffff;
    flex-shrink: 0;
}

/* 金银铜牌配色 */
.rank-1 {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

.rank-2 {
    background: linear-gradient(135deg, #cbd5e1, #64748b);
    box-shadow: 0 0 10px rgba(203, 213, 225, 0.4);
}

.rank-3 {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.rank-badge:not(.rank-1):not(.rank-2):not(.rank-3) {
    background-color: var(--border);
    color: var(--text-muted);
}

/* 警示黑榜徽章颜色 */
.rank-tail {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.rank-name {
    font-weight: 700;
    color: var(--text-main);
    width: 60px;
}

.rank-role {
    color: var(--text-muted);
    font-size: 0.8rem;
    width: 60px;
}

.rank-store {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-val {
    font-weight: 800;
    font-size: 0.95rem;
}

.font-success {
    color: #10b981;
}

.font-error {
    color: #ef4444;
}

.no-rank-data {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2rem 0;
}

/* ==========================================
   移动端 H5 响应式自适应布局媒体查询 (屏宽 < 768px)
   ========================================== */
@media (max-width: 768px) {
    /* 1. 移动端 Header 页头定义 */
    .mobile-header {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background-color: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        padding: 0 1rem;
        z-index: 999;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    }
    
    .menu-toggle-btn {
        background: none;
        border: none;
        color: var(--text-main);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.25rem 0.5rem;
        margin-right: 0.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-title {
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--text-main);
        letter-spacing: 0.5px;
    }

    /* 2. 侧边栏抽屉菜单自适应 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px; /* 初始隐藏在左侧 */
        width: 260px;
        height: 100vh;
        z-index: 10000;
        box-shadow: none;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 1.5rem 1.25rem;
    }
    
    .sidebar.active {
        transform: translateX(260px); /* 滑出呈现 */
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        z-index: 9999;
        animation: fadeIn 0.2s ease;
    }

    /* 3. 主内容区偏移消除与顶部 padding */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 72px 1rem 2rem 1rem !important; /* 72px 刚好避开 56px 的 Header，并留出间距 */
    }

    /* 4. 仪表盘卡片与图表自适应 */
    .card-grid {
        grid-template-columns: 1fr !important; /* 卡片单列排布 */
        gap: 1rem !important;
    }
    
    .charts-grid {
        grid-template-columns: 1fr !important; /* 图表单列排布 */
        gap: 1rem !important;
    }
    
    .chart-card {
        padding: 1rem !important;
        border-radius: 12px !important;
    }
    
    .ranking-card {
        grid-column: span 1 !important; /* 占单列 */
    }
    
    .ranking-container {
        grid-template-columns: 1fr !important; /* 红黑榜垂直堆叠 */
        gap: 1.5rem !important;
    }

    /* 5. 过滤查询栏垂直自适应堆叠 */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        padding: 1rem !important;
        border-radius: 12px !important;
    }
    
    .filter-bar label {
        margin-bottom: -0.25rem !important;
    }
    
    .filter-bar .form-control {
        width: 100% !important; /* 宽度全满 */
        max-width: 100% !important;
    }
    
    /* 过滤栏按钮并排 */
    .filter-bar button {
        width: 100% !important;
        margin-top: 0.25rem;
    }

    /* 6. 表格手机防遮挡（解开 Sticky 锁定） */
    .summary-table-container th, 
    .summary-table-container td,
    .table-container th,
    .table-container td {
        font-size: 11px !important; /* 微调字号 */
        padding: 0.5rem 0.4rem !important; /* 减小内边距 */
    }

    /* 核心：重置所有固定列 (position: sticky) 为普通定位 (position: static) */
    .sticky-col {
        position: static !important;
        box-shadow: none !important;
        background-color: transparent !important;
        border-right: 1px solid var(--border) !important;
    }
    
    /* 重置固定表头里的固定单元格 */
    thead th.sticky-col {
        position: static !important;
        background-color: var(--bg-secondary) !important;
        box-shadow: none !important;
    }
    
    /* 亮色模式下表格内容自适应 */
    body.light-theme thead th.sticky-col {
        background-color: #e2e8f0 !important;
    }
    
    /* 提成汇总表合并标题组重置 */
    .summary-table .sticky-col-l-group {
        position: static !important;
        background-color: var(--bg-secondary) !important;
        box-shadow: none !important;
    }
    
    body.light-theme .summary-table .sticky-col-l-group {
        background-color: #cbd5e1 !important;
    }

    /* 7. 算法配置页面折叠 */
    .config-group {
        grid-template-columns: 1fr !important; /* 输入框单列 */
        gap: 0.5rem !important;
    }
    
    .config-card {
        padding: 1.25rem 1rem !important;
    }
}
