* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 16px;
}

/* 独立页面（非侧边栏）：外层不滚动，只有 table-wrapper 滚 */
body.standalone {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 16px;
}
body.standalone .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 16px;
    max-width: 100%;
}

.page-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.page-header h1 {
    font-size: 16px;
    font-weight: 600;
}

.page-header .subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.toolbar label {
    font-size: 13px;
    color: #666;
}

.toolbar select,
.toolbar input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.refresh-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.refresh-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 表格包装器：独立滚动区域 */
.table-wrapper {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: auto;
    position: relative;
}


/* 独立页面模式下的表格包装器 */
body.standalone .table-wrapper {
    flex: 1;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    white-space: nowrap;
}

/* 表头样式 */
thead th {
    position: sticky;
    top: 0;
    background: #667eea;
    color: white;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    z-index: 10;
}

/* 表头第一列（文字列） */
thead th:first-child {
    text-align: left;
    padding-left: 12px;
    left: 0;
    z-index: 11;
}

/* 数据行样式 */
tbody tr {
    transition: background 0.15s;
}

tbody tr:hover {
    background: #f5f7ff;
}

tbody td {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
}

/* 第一列（文字列）固定 */
tbody td:first-child {
    position: sticky;
    left: 0;
    background: white;
    text-align: left;
    padding-left: 12px;
    font-weight: 500;
    z-index: 5;
}

tbody tr:hover td:first-child {
    background: #f5f7ff;
}

/* 数字列样式 */
tbody td.num {
    font-family: "SF Mono", Monaco, monospace;
    font-variant-numeric: tabular-nums;
}

/* 品牌列 */
tbody td.brand-cell {
    font-weight: 500;
}

/* 合计行样式 */
tfoot td {
    position: sticky;
    bottom: 0;
    background: #f8f9fa;
    padding: 10px 8px;
    font-weight: 600;
    border-top: 2px solid #e0e0e0;
    text-align: center;
}

tfoot td:first-child {
    left: 0;
    z-index: 6;
    text-align: left;
    padding-left: 12px;
}

/* 加载状态 */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    color: #666;
    font-size: 14px;
}

.loading-progress {
    margin-top: 8px;
    color: #999;
    font-size: 12px;
}

/* 错误状态 */
.error-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-text {
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
}

.error-detail {
    font-size: 13px;
    color: #999;
    margin-bottom: 20px;
}

.retry-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.retry-btn:hover {
    background: #5a6fd6;
}

/* 提示条 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-hide {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* 分页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.pagination button:hover:not(:disabled) {
    background: #f5f5f5;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-info {
    font-size: 13px;
    color: #666;
}

/* 排序指示器 */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    background: #5a6fd6;
}

.sort-indicator {
    margin-left: 4px;
    opacity: 0.5;
}

.sort-indicator.active {
    opacity: 1;
}

/* 可点击行 */
.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: #e8ebff !important;
}

/* 选中行高亮 */
tbody tr.selected {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* 提示文字 */
.hint {
    font-size: 12px;
    color: #999;
}

/* ====== 统一Excel风格表格 ====== */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
}

/* 表头：深蓝背景 */
.excel-table thead th {
    position: sticky;
    top: 0;
    background: #667eea;
    color: white;
    padding: 6px 4px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #D0D0D0;
    z-index: 10;
}

/* 数据行：紧凑 */
.excel-table tbody tr {
    height: 22px;
}

.excel-table tbody td {
    text-align: center;
}

/* 斑马纹 */
.rate-table tbody tr:nth-child(even) {
    background: #F5F7FF;
}

.rate-table tbody tr:nth-child(odd) {
    background: #FFFFFF;
}

/* 品牌分组行（"全部分类"）浅蓝背景 */
.excel-table tbody tr.brand-total {
    background: #D6E9F8 !important;
    font-weight: 600;
}

/* 所有单元格边框 */
.ratrable tbody td {
    padding: 2px 4px;
    border: 1px solid #D0D0D0;
    text-align: center;
    vertical-align: middle;
}

/* 数字列右对齐 */
.excel-table tbody td.num {
    text-align: right;
    font-family: "SF Mono", Monaco, monospace;
    font-variant-numeric: tabular-nums;
}

/* 环比正负颜色 */
.excel-table tbody td.num.up {
    color: #22c55e;
}
.excel-table tbody td.num.down {
    color: #ef4444;
}

/* 品牌列 */
.excel-table tbody td.brand-cell {
    font-weight: 500;
}

/* 分类列 */
.excel-table tbody td.category-cell {
    text-align: left;
    padding-left: 6px;
}

/* 合计行 */
.excel-table tfoot td {
    position: sticky;
    bottom: 0;
    background: #E8E8E8;
    padding: 6px 4px;
    font-weight: 600;
    border: 1px solid #D0D0D0;
    text-align: center;
}

.excel-table tfoot td.num {
    text-align: right;
}

/* ====== 日报表页面样式 ====== */
.daily-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.daily-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
}

.daily-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.daily-table-wrapper {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.daily-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
}

.daily-table thead th {
    position: sticky;
    top: 0;
    background: #4472C4;
    color: white;
    padding: 6px 4px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #4472C4;
    z-index: 10;
}

.daily-table thead th.row-label-th {
    text-align: center;
    padding-left: 4px;
    left: 0;
    z-index: 11;
}

.daily-table thead th.total-th {
    background: #3a62a8;
}

.daily-table thead th.brand-th {
    background: #4472C4;
}

.daily-table tbody td {
    padding: 2px 4px;
    border: 1px solid #D0D0D0;
    text-align: center;
}

.daily-table tbody tr:hover {
    background: #eef3fb;
}

.daily-table tbody td.row-label {
    position: sticky;
    left: 0;
    background: white;
    text-align: center;
    padding-left: 4px;
    font-weight: 500;
    z-index: 5;
}

.daily-table tbody tr:hover td.row-label {
    background: #eef3fb;
}

.daily-table tbody td.num {
    font-family: "SF Mono", Monaco, monospace;
    font-variant-numeric: tabular-nums;
}

.daily-table tbody td.total-col {
    background: #f2f5fc;
    font-weight: 500;
}

.daily-table tbody td.brand-col {
    color: #333;
}

/* 盈亏平衡分析 */
.daily-balance-wrapper {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 12px 0 4px 0;
    margin-top: 12px;
    overflow-x: auto;
    flex: 0 0 auto;
}

.balance-title {
    font-size: 14px;
    color: #333;
    margin: 0 0 6px 16px;
    padding: 0;
    font-weight: 600;
}

.daily-table td.danger {
    color: #dc3545 !important;
    font-weight: 600;
}

.daily-table td.profit-up {
    color: #28a745 !important;
}

.daily-table td.profit-down {
    color: #dc3545 !important;
}

/* 图表区域 */
.chart-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-top: 12px;
    padding: 20px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chart-section .chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
}

.chart-section .chart-container canvas,
.chart-section .chart-container > div {
    width: 100% !important;
    height: 100% !important;
}

.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

/* ====== 日报表左右布局 ====== */
.daily-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.daily-left {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 24px;
}

.daily-right {
    flex: 0 0 65%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.daily-right .chart-section {
    margin-top: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    max-height: calc(100vh - 220px);
}

.daily-right .chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
    padding-right: 12px;
}

/* 响应式：小屏幕时堆叠 */
@media (max-width: 1200px) {
    .daily-layout {
        flex-direction: column;
    }
    .daily-left {
        flex: none;
        max-height: 50vh;
    }
    .daily-right {
        flex: none;
        min-height: 400px;
    }
}

/* 移动端优化 */
@media (max-width: 768px) {
    .daily-layout {
        flex-direction: column;
        gap: 12px;
    }
    .daily-left {
        flex: none;
        max-height: none;
    }
    .daily-right {
        flex: none;
        min-height: 300px;
    }
    .daily-table-wrapper {
        max-height: none;
    }
    .daily-right .chart-section {
        max-height: none;
        min-height: 300px;
    }
    .daily-right .chart-container {
        padding-right: 5px;
    }
    .daily-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 8px;
    }
    .daily-toolbar label {
        display: none;
    }
    .daily-toolbar input {
        flex: 1;
        min-width: 120px;
        padding: 6px 8px;
        font-size: 13px;
    }
    .daily-toolbar button {
        padding: 6px 10px;
        font-size: 12px;
        flex: 0 0 auto;
    }
    .daily-table {
        font-size: 11px;
    }
    .daily-table th,
    .daily-table td {
        padding: 4px 3px;
    }
    .page-header {
        padding: 8px 12px;
        margin-bottom: 8px;
    }
    .page-header h1 {
        font-size: 14px;
    }
    .page-header .subtitle {
        font-size: 11px;
    }
    .refresh-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    .content-area {
        padding: 8px;
    }
    /* 手机版：导出全部按钮移到上一行，隐藏行数统计 */
    .toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }
    .toolbar .search-box {
        flex: 1;
        min-width: 100px;
        position: relative;
    }
    .toolbar .search-box .search-icon {
        display: none;
    }
    .toolbar .search-box input {
        width: 100%;
        padding-left: 10px;
    }
    .toolbar .export-btn {
        margin-left: 0 !important;
        padding: 6px 10px;
        font-size: 12px;
    }
    .toolbar .row-count {
        display: none;
    }
    /* 手机版：隐藏副标题的额外部分 */
    .subtitle-extra {
        display: none;
    }
}

/* ====== 日志分析面板 ====== */
.analysis-panel {
    background: #f8f9fc;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    margin-top: 12px;
}
.analysis-panel h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}
.analysis-panel h3 small {
    font-weight: normal;
    color: #999;
    font-size: 13px;
    margin-left: 8px;
}
.analysis-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.analysis-card {
    flex: 1;
    min-width: 140px;
    background: #fff;
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    text-align: center;
}
.analysis-card .card-num {
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
    line-height: 1.2;
}
.analysis-card .card-label {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.analysis-grid .analysis-col h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #555;
}
.analysis-grid .analysis-col table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.analysis-grid .analysis-col table th,
.analysis-grid .analysis-col table td {
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}
.analysis-grid .analysis-col table th {
    background: #f0f2f8;
    color: #666;
    font-weight: 600;
}
.analysis-grid .analysis-col .percent-bar {
    display: inline-block;
    height: 6px;
    border-radius: 3px;
    background: #667eea;
    vertical-align: middle;
    margin-left: 6px;
}
/* 右侧面板样式 */
#日志分析面板 {
    margin-top: 0 !important;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}
#日志分析面板 .analysis-grid {
    grid-template-columns: 1fr;
}
#日志分析面板 .analysis-grid .analysis-col table th,
#日志分析面板 .analysis-grid .analysis-col table td {
    padding: 5px 6px;
}
