/* ============================================================
   鹿匠数字运营系统 - 生产计划与物料管理样式
   ============================================================ */

:root {
    --primary-color: #4361ee;
    --secondary-color: #667eea;
    --success-color: #1D9E75;
    --warning-color: #f39c12;
    --danger-color: #E24B4A;
    --gray-color: #B4B2A9;
    --bg-color: #f0f2f5;
    --card-bg: #fff;
    --border-color: #e8eaed;
    --text-primary: #1e2532;
    --text-secondary: #666;
    --text-muted: #8a93a2;
    /* 产线色：色相拉开，避免蓝/紫、绿/青接近 */
    --line-a: #4C6FFF;
    --line-b: #2EC27E;
    --line-c: #F5A524;
    --line-d: #FF5A5F;
    --line-e: #8B5CF6;
    --line-f: #06B6D4;
    --line-g: #EC4899;
    --line-h: #64748B;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ── 顶部导航 ────────────────────────────────────────────── */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 22px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ── Tab 导航 ────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab:hover {
    background: #f5f7ff;
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── 按钮 ────────────────────────────────────────────── */

.btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: #3451d1;
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #f5f5f5;
}

/* ── 输入框 ────────────────────────────────────────────── */

.input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ── 排产日历 ────────────────────────────────────────────── */

.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.calendar-toolbar h2 {
    font-size: 18px;
    font-weight: 500;
}

.calendar-grid {
    background: var(--card-bg);
    min-width: 708px;
}

.calendar-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    max-width: 100%;
}

.calendar-scroll .calendar-grid {
    border: none;
    border-radius: 0;
}

.calendar-header {
    display: grid;
    grid-template-columns: 64px repeat(7, minmax(92px, 1fr));
    background: #f8f9fb;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 5;
}

.calendar-header-cell:first-child {
    position: sticky;
    left: 0;
    z-index: 6;
    background: #f8f9fb;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    min-width: 64px;
    max-width: 64px;
}

.calendar-header-cell {
    padding: 6px 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
}

.calendar-row {
    display: grid;
    grid-template-columns: 64px minmax(644px, 1fr);
    border-bottom: 1px solid var(--border-color);
    align-items: stretch;
}

.calendar-row:last-child {
    border-bottom: none;
}

.calendar-line-label {
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 500;
    background: #fafbfc;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    align-self: stretch;
    position: sticky;
    left: 0;
    z-index: 4;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    min-width: 64px;
    max-width: 64px;
    flex-shrink: 0;
}

.calendar-line-label.line-a { border-left: 4px solid #4C6FFF; }
.calendar-line-label.line-b { border-left: 4px solid #2EC27E; }
.calendar-line-label.line-c { border-left: 4px solid #F5A524; }
.calendar-line-label.line-d { border-left: 4px solid #FF5A5F; }
.calendar-line-label.line-e { border-left: 4px solid #8B5CF6; }
.calendar-line-label.line-f { border-left: 4px solid #06B6D4; }
.calendar-line-label.line-g { border-left: 4px solid #EC4899; }
.calendar-line-label.line-h { border-left: 4px solid #64748B; }

/* 周历轨道：与甘特图同构竖排色条 */
.calendar-track {
    display: grid;
    grid-template-columns: repeat(7, minmax(92px, 1fr));
    grid-template-rows: repeat(var(--calendar-track-rows, 1), minmax(54px, auto));
    row-gap: 4px;
    padding: 5px 3px;
    background-color: #fff;
    background-image: repeating-linear-gradient(
        to right,
        transparent,
        transparent calc((100% / 7) - 1px),
        var(--border-color) calc((100% / 7) - 1px),
        var(--border-color) calc(100% / 7)
    );
}

.calendar-track-gap {
    min-height: 54px;
    margin: 3px 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0faf4;
}

.calendar-cell {
    padding: 6px;
    min-height: 80px;
    border-right: 1px solid var(--border-color);
    transition: background 0.2s;
}

.calendar-cell.busy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 80px;
    cursor: default;
}

.calendar-cell.busy:hover {
    background: transparent;
}

.calendar-cell:hover {
    background: #f5f7ff;
}

.calendar-cell.empty {
    background: #fafbfc;
    cursor: default;
}

.calendar-cell.empty:hover {
    background: #fafbfc;
}

.calendar-cell.read-only,
.gantt-cell.read-only {
    cursor: default;
    user-select: none;
}

/* 方案D：每日格 — 顶栏工单 + 下行当日（产线色左条，与图例一致） */
.day-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    font-size: 11px;
    cursor: default;
    flex-shrink: 0;
    background: #fff;
    border-left-width: 3px;
    border-left-style: solid;
}

.day-card.line-a { border-left-color: #4C6FFF; }
.day-card.line-b { border-left-color: #2EC27E; }
.day-card.line-c { border-left-color: #F5A524; }
.day-card.line-d { border-left-color: #FF5A5F; }
.day-card.line-e { border-left-color: #8B5CF6; }
.day-card.line-f { border-left-color: #06B6D4; }
.day-card.line-g { border-left-color: #EC4899; }
.day-card.line-h { border-left-color: #64748B; }

.day-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.day-card.insert {
    box-shadow: inset 0 0 0 2px #f5a623;
}

.day-card.completed {
    opacity: 0.65;
}

.day-card-order-strip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: #f8f9fb;
    color: var(--text-primary);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.3;
    min-width: 0;
    border-bottom: 1px solid var(--border-color);
}

.day-card.line-a .day-card-no { color: #4C6FFF; }
.day-card.line-b .day-card-no { color: #2EC27E; }
.day-card.line-c .day-card-no { color: #F5A524; }
.day-card.line-d .day-card-no { color: #FF5A5F; }
.day-card.line-e .day-card-no { color: #8B5CF6; }
.day-card.line-f .day-card-no { color: #06B6D4; }
.day-card.line-g .day-card-no { color: #EC4899; }
.day-card.line-h .day-card-no { color: #64748B; }

.day-card-no {
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.day-card-product {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-weight: 500;
}

.day-card-body {
    padding: 5px 6px 6px;
}

.day-card-daily {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.day-card-order-sub {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 2px;
}

.day-card-progress {
    height: 4px;
    margin-top: 4px;
    background: #e8eaed;
    border-radius: 2px;
    overflow: hidden;
}

.day-card-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.2s;
}

.day-card.line-a .day-card-progress-fill { background: #4C6FFF; }
.day-card.line-b .day-card-progress-fill { background: #2EC27E; }
.day-card.line-c .day-card-progress-fill { background: #F5A524; }
.day-card.line-d .day-card-progress-fill { background: #FF5A5F; }
.day-card.line-e .day-card-progress-fill { background: #8B5CF6; }
.day-card.line-f .day-card-progress-fill { background: #06B6D4; }
.day-card.line-g .day-card-progress-fill { background: #EC4899; }
.day-card.line-h .day-card-progress-fill { background: #64748B; }

.schedule-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 0;
    font-size: 11px;
    cursor: default;
    transition: all 0.2s;
    flex-shrink: 0;
}

.schedule-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.schedule-card.insert {
    border-left: 3px solid var(--warning-color);
}

.schedule-card.delayed {
    border-left: 3px solid var(--danger-color);
}

.schedule-card.completed {
    border-left: 3px solid var(--success-color);
}

.schedule-card .product-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.schedule-card .qty {
    color: var(--text-secondary);
}

.schedule-card .progress-bar {
    height: 4px;
    background: #e8eaed;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.schedule-card .progress-fill {
    height: 100%;
    background: var(--success-color);
    transition: width 0.3s;
}

/* ── 物料齐套 ────────────────────────────────────────────── */

.kitcheck-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.kitcheck-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 15px;
    overflow: hidden;
}

.kitcheck-header {
    padding: 12px 16px;
    background: #f8f9fb;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kitcheck-header h3 {
    font-size: 14px;
    font-weight: 500;
}

.kitcheck-rate {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

.kitcheck-rate.full {
    background: #E1F5EE;
    color: #085041;
}

.kitcheck-rate.partial {
    background: #FAEEDA;
    color: #633806;
}

.kitcheck-rate.shortage {
    background: #FCEBEB;
    color: #791F1F;
}

.kitcheck-table {
    width: 100%;
    border-collapse: collapse;
}

.kitcheck-table th,
.kitcheck-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.kitcheck-table th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
}

.kitcheck-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.full {
    background: #E1F5EE;
    color: #085041;
}

.status-badge.partial {
    background: #FAEEDA;
    color: #633806;
}

.status-badge.shortage {
    background: #FCEBEB;
    color: #791F1F;
}

/* ── 每日报工 ────────────────────────────────────────────── */

.reporting-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.reporting-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 15px;
    padding: 16px;
}

.reporting-card h3 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}

.reporting-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.reporting-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

/* ── 进度看板 ────────────────────────────────────────────── */

.progress-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.progress-table {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.progress-row {
    display: grid;
    grid-template-columns: 120px 80px 80px 100px 1fr 80px 80px;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.progress-row.header {
    background: #f8f9fb;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-bar {
    height: 8px;
    background: #e8eaed;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--success-color);
    transition: width 0.3s;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.normal {
    background: var(--success-color);
}

.status-indicator.warning {
    background: var(--warning-color);
}

.status-indicator.danger {
    background: var(--danger-color);
}

/* ── 弹窗 ────────────────────────────────────────────── */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    z-index: 100;
    overflow-y: auto;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 500;
}

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

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── 表单 ────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group .input {
    width: 100%;
}

/* ── 齐套状态预览 ────────────────────────────────────────────── */

.kit-status-preview {
    background: #f8f9fb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.kit-status-preview h4 {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.kit-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
}

.kit-status-item:last-child {
    border-bottom: none;
}

/* ── 响应式 ────────────────────────────────────────────── */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .dashboard-page {
        max-width: 100%;
    }

    .dash-section {
        padding: 12px 10px;
        overflow: visible;
    }

    .dash-header {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
    }

    .dash-header h1 {
        font-size: 16px;
    }

    .dash-header-right {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .dash-header-right .btn {
        flex: 1 1 auto;
        min-width: calc(50% - 4px);
        padding: 8px 10px;
        font-size: 12px;
    }

    .dash-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .week-nav-bar {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .week-nav-title {
        width: 100%;
        text-align: center;
        order: -1;
        font-size: 12px;
        padding: 4px 0;
    }

    .dash-select {
        width: 100%;
    }

    .kpi-grid-compact {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .calendar-legend {
        gap: 6px 10px;
        font-size: 10px;
    }

    .calendar-grid {
        min-width: 660px;
    }

    .calendar-header {
        grid-template-columns: 56px repeat(7, minmax(86px, 1fr));
    }

    .calendar-header-cell:first-child,
    .calendar-line-label {
        min-width: 56px;
        max-width: 56px;
    }

    .calendar-row {
        grid-template-columns: 56px minmax(602px, 1fr);
    }

    .calendar-track {
        grid-template-columns: repeat(7, minmax(86px, 1fr));
    }

    .scroll-hint {
        display: block;
    }

    .line-cap-stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 12px;
    }

    .stat-val {
        font-size: 18px;
    }

    .line-cap-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 12px;
    }

    .overdue-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .overdue-item .btn {
        width: 100%;
    }

    .stock-chart-container {
        height: 240px;
    }

    .progress-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .kpi-grid-compact {
        grid-template-columns: 1fr;
    }

    .dash-header-right .btn {
        min-width: 100%;
    }
}

/* ── 生产看板统一布局 ────────────────────────────────────────────── */

.dashboard-page {
    max-width: 1480px;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #4361ee 0%, #667eea 100%);
    border-radius: 12px;
    color: #fff;
    margin-bottom: 16px;
}

.dash-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.dash-toolbar-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.dash-toolbar-sep {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 4px;
}

.dash-month-select {
    min-width: 140px;
}

.dash-view-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.dash-view-tab {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.15s;
}

.dash-view-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.dash-view-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* ── 甘特图（按月） ────────────────────────────────────────────── */

.gantt-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    max-width: 100%;
}

/* 宽表格横向滚动（产线产能、逾期工单等） */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
    margin-top: 4px;
}

.table-scroll::-webkit-scrollbar,
.calendar-scroll::-webkit-scrollbar,
.gantt-scroll::-webkit-scrollbar {
    height: 6px;
}

.table-scroll::-webkit-scrollbar-thumb,
.calendar-scroll::-webkit-scrollbar-thumb,
.gantt-scroll::-webkit-scrollbar-thumb {
    background: #c5cad3;
    border-radius: 3px;
}

.scroll-hint {
    display: none;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

.gantt-grid {
    min-width: max-content;
    --gantt-days: 31;
}

.gantt-header,
.gantt-row {
    display: grid;
    grid-template-columns: 100px 1fr;
}

.gantt-header {
    background: #f8f9fb;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
    grid-template-columns: 100px repeat(var(--gantt-days), minmax(36px, 1fr));
}

.gantt-row {
    border-bottom: 1px solid var(--border-color);
    align-items: stretch;
}

.gantt-row:last-child {
    border-bottom: none;
}

.gantt-track {
    display: grid;
    grid-template-columns: repeat(var(--gantt-days), minmax(36px, 1fr));
    grid-template-rows: repeat(var(--gantt-lanes, 1), minmax(54px, auto));
    row-gap: 4px;
    padding: 4px 0;
    position: relative;
    background: #fff;
}

.gantt-header-cell {
    padding: 6px 2px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
}

.gantt-header-cell.gantt-line-col {
    font-size: 12px;
    position: sticky;
    left: 0;
    z-index: 7;
    background: #f8f9fb;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    min-width: 100px;
    max-width: 100px;
}

.gantt-line-label {
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 500;
    background: #fafbfc;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    align-self: stretch;
    position: sticky;
    left: 0;
    z-index: 4;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    min-width: 100px;
    max-width: 100px;
    flex-shrink: 0;
}

.gantt-line-label.line-a { border-left: 4px solid #4C6FFF; }
.gantt-line-label.line-b { border-left: 4px solid #2EC27E; }
.gantt-line-label.line-c { border-left: 4px solid #F5A524; }
.gantt-line-label.line-d { border-left: 4px solid #FF5A5F; }
.gantt-line-label.line-e { border-left: 4px solid #8B5CF6; }
.gantt-line-label.line-f { border-left: 4px solid #06B6D4; }
.gantt-line-label.line-g { border-left: 4px solid #EC4899; }
.gantt-line-label.line-h { border-left: 4px solid #64748B; }

.gantt-cell {
    min-height: 54px;
    border-right: 1px solid var(--border-color);
    background: #fafbfc;
}

.gantt-cell.empty {
    cursor: default;
}

.gantt-cell.empty:hover {
    background: #fafbfc;
}

.gantt-header-cell.col-today,
.calendar-header-cell.col-today {
    background: #fff3cd;
    color: var(--text-primary);
    font-weight: 700;
}

.gantt-bar {
    margin: 3px 2px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 5px 3px;
    min-height: 48px;
    height: calc(100% - 6px);
    overflow: hidden;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    align-self: center;
    position: relative;
    z-index: 1;
}

.gantt-bar-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
}

.gantt-bar-no {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-bar-product {
    font-size: 9px;
    opacity: 0.92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 11px;
}

.gantt-bar-qty {
    font-size: 9px;
    opacity: 0.85;
}

.gantt-bar-pct {
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.gantt-bar-progress {
    height: 5px;
    margin-top: 6px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.gantt-bar-progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 3px;
    transition: width 0.3s;
}

.gantt-bar.line-a { background: linear-gradient(180deg, #7B93FF 0%, #4C6FFF 100%); }
.gantt-bar.line-b { background: linear-gradient(180deg, #5ED9A0 0%, #2EC27E 100%); }
.gantt-bar.line-c { background: linear-gradient(180deg, #FFC15A 0%, #F5A524 100%); }
.gantt-bar.line-d { background: linear-gradient(180deg, #FF8A8E 0%, #FF5A5F 100%); }
.gantt-bar.line-e { background: linear-gradient(180deg, #B794F4 0%, #8B5CF6 100%); }
.gantt-bar.line-f { background: linear-gradient(180deg, #67E8F9 0%, #06B6D4 100%); }
.gantt-bar.line-g { background: linear-gradient(180deg, #F9A8D4 0%, #EC4899 100%); }
.gantt-bar.line-h { background: linear-gradient(180deg, #94A3B8 0%, #64748B 100%); }

.gantt-bar.completed {
    opacity: 0.5;
    background: #94a3b8 !important;
}

.gantt-bar.completed .gantt-bar-progress-fill {
    background: #fff;
}

.gantt-bar.insert {
    box-shadow: inset 0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,0.15);
}

.legend-dot.progress-demo {
    background: linear-gradient(90deg, #fff 45%, rgba(0,0,0,0.25) 45%);
    border-radius: 2px;
    width: 20px;
    height: 8px;
}

.dash-header-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.dash-sync-badge {
    font-size: 11px;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

.dash-updated {
    font-size: 12px;
    opacity: 0.9;
}

/* 头部蓝底上与背景区分开 */
.dash-header .btn-primary {
    background: #fff;
    color: #3451d1;
    border-color: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.16);
    font-weight: 600;
}

.dash-header .btn-primary:hover {
    background: #eef2ff;
    border-color: #eef2ff;
    color: #2a44b8;
}

.dash-select {
    min-width: 120px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-success {
    background: var(--success-color);
    color: #fff;
    border-color: var(--success-color);
}

.btn-warning {
    background: #f5a623;
    color: #fff;
    border-color: #f5a623;
}

.btn-dark {
    background: #333;
    color: #fff;
    border-color: #333;
}

.dash-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.section-title-toggle {
    width: 100%;
    margin-bottom: 0;
    padding: 0 0 8px;
    border: none;
    border-bottom: 2px solid var(--primary-color);
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.section-title-toggle:hover {
    color: var(--primary-color);
}

.section-title-toggle .section-title-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.section-title-toggle:hover .section-title-meta {
    color: var(--primary-color);
}

.section-title-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: 14px;
}

.section-title-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(90deg);
}

.overdue-section:not(:has(#overdueContainer:not([hidden]))) {
    margin-bottom: 16px;
}

.overdue-section:has(#overdueContainer:not([hidden])) .section-title-toggle {
    margin-bottom: 12px;
}

/* 周历切换 — 顶部工具栏内 */
.week-nav-bar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 3px;
    background: #f4f6fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.week-nav-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    color: #374151;
    background: #fff;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.week-nav-btn:hover {
    background: #eef2ff;
    color: #1e40af;
}

.week-nav-btn:active {
    transform: translateY(1px);
}

.week-nav-btn.week-nav-today {
    color: #fff;
    background: var(--primary-color, #2563eb);
    border-color: var(--primary-color, #2563eb);
}

.week-nav-btn.week-nav-today:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

#btnNextWeek {
    margin-left: 14px;
}

.week-nav-title {
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
}

.calendar-toolbar-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
}

.kpi-grid-compact {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    border-left: 4px solid #ccc;
}

.kpi-card.kpi-blue { border-left-color: #4361ee; }
.kpi-card.kpi-green { border-left-color: #1D9E75; }
.kpi-card.kpi-yellow { border-left-color: #f5a623; }
.kpi-card.kpi-red { border-left-color: #E24B4A; }
.kpi-card.kpi-purple { border-left-color: #7B61FF; }

.kpi-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stock-chart-container {
    position: relative;
    height: 320px;
    margin-top: 12px;
}

.empty-hint {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 13px;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 11px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.legend-dot.line-a { background: #4C6FFF; }
.legend-dot.line-b { background: #2EC27E; }
.legend-dot.line-c { background: #F5A524; }
.legend-dot.line-d { background: #FF5A5F; }
.legend-dot.line-e { background: #8B5CF6; }
.legend-dot.line-f { background: #06B6D4; }
.legend-dot.line-g { background: #EC4899; }
.legend-dot.line-h { background: #64748B; }
.legend-dot.empty-gap { background: #e8f5e9; border: 1px dashed #1D9E75; }
.legend-dot.completed { background: #ddd; opacity: 0.6; }

.calendar-line-label.line-a { border-left: 4px solid #4C6FFF; }
.calendar-line-label.line-b { border-left: 4px solid #2EC27E; }
.calendar-line-label.line-c { border-left: 4px solid #F5A524; }
.calendar-line-label.line-d { border-left: 4px solid #FF5A5F; }
.calendar-line-label.line-e { border-left: 4px solid #8B5CF6; }
.calendar-line-label.line-f { border-left: 4px solid #06B6D4; }
.calendar-line-label.line-g { border-left: 4px solid #EC4899; }
.calendar-line-label.line-h { border-left: 4px solid #64748B; }

.calendar-line-label {
    flex-direction: column;
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 6px 8px !important;
}

.line-name { font-weight: 600; font-size: 11px; line-height: 1.3; }
.line-meta-inline { font-weight: 400; font-size: 9px; color: var(--text-muted); }
.line-meta { font-size: 10px; color: var(--text-muted); }

.calendar-cell.empty-gap {
    background: #f0faf4;
}

.gap-label {
    font-size: 9px;
    color: #1D9E75;
}

.schedule-card.line-a { border-left: 3px solid #4C6FFF; }
.schedule-card.line-b { border-left: 3px solid #2EC27E; }
.schedule-card.line-c { border-left: 3px solid #F5A524; }
.schedule-card.line-d { border-left: 3px solid #FF5A5F; }
.schedule-card.line-e { border-left: 3px solid #8B5CF6; }
.schedule-card.line-f { border-left: 3px solid #06B6D4; }
.schedule-card.line-g { border-left: 3px solid #EC4899; }
.schedule-card.line-h { border-left: 3px solid #64748B; }

.schedule-card .order-no {
    font-size: 10px;
    color: var(--text-muted);
}

.line-capacity-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: visible;
}

.line-cap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fb;
    border-bottom: 1px solid var(--border-color);
}

.line-cap-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.line-occupancy-badge {
    background: #fff3e0;
    color: #e65100;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.line-cap-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.stat-val {
    font-size: 20px;
    font-weight: 700;
}

.text-red { color: #E24B4A; }
.text-green { color: #1D9E75; }

.line-order-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 12px;
}

.line-order-table th,
.line-order-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.line-order-table th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-pct {
    font-size: 11px;
    color: var(--text-muted);
}

.progress-bar.progress-green .progress-bar-fill { background: #1D9E75; }
.progress-bar.progress-yellow .progress-bar-fill { background: #f5a623; }
.progress-bar.progress-red .progress-bar-fill { background: #E24B4A; }

.status-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

.status-tag.overdue {
    background: #fcebeb;
    color: #791f1f;
    border-color: #f5c6c6;
}

.overdue-panel {
    background: #fffbf0;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 14px;
    overflow: visible;
    max-width: 100%;
}

.overdue-warning {
    font-size: 13px;
    margin-bottom: 10px;
    color: #633806;
}

.overdue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #ffe082;
    font-size: 13px;
}

.overdue-table {
    width: 100%;
    min-width: 880px;
    border-collapse: collapse;
    margin-top: 14px;
    font-size: 12px;
}

.overdue-table th,
.overdue-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.overdue-table th {
    background: #f8f9fb;
}

.unclosed-analysis-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 13px;
}

.unclosed-analysis-table th,
.unclosed-analysis-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}

.unclosed-analysis-table th {
    background: #f8f9fb;
    font-weight: 600;
    color: var(--text-muted);
}

.unclosed-analysis-table .col-expand {
    width: 36px;
    padding-right: 0;
}

.unclosed-month-row {
    cursor: pointer;
    background: #fff;
}

.unclosed-month-row:hover {
    background: #f5f7fa;
}

.unclosed-month-row.is-open {
    background: #eef3f9;
}

.month-toggle-icon {
    display: inline-block;
    font-size: 14px;
    color: var(--text-muted);
    width: 20px;
    text-align: center;
}

.unclosed-order-row td {
    background: #fafbfc;
    padding-top: 6px;
    padding-bottom: 6px;
}

.unclosed-order-detail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 4px 0 4px 8px;
    border-left: 3px solid #c5d4e8;
    font-size: 12px;
}

.unclosed-order-detail .order-no {
    font-weight: 600;
    color: var(--text-primary);
}

.unclosed-order-detail .order-product {
    color: var(--text-primary);
}

.unclosed-order-detail .order-meta {
    color: var(--text-muted);
}

.status-tag.pick-full {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}

.status-tag.pick-over {
    background: #fce4ec;
    color: #c2185b;
    border-color: #f48fb1;
}

.status-tag.pick-partial {
    background: #fff8e1;
    color: #f57f17;
    border-color: #ffe082;
}

.status-tag.pick-none {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffcc80;
}

.status-tag.pick-unknown {
    background: #eceff1;
    color: #546e7a;
    border-color: #cfd8dc;
}

.collapsible summary {
    cursor: pointer;
    font-weight: 600;
    padding: 8px 0;
}

.sub-tabs {
    display: flex;
    gap: 0;
    margin: 12px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.sub-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: #fafbfc;
    cursor: pointer;
}

.sub-tab.active {
    background: var(--primary-color);
    color: #fff;
}

.sub-tab-content {
    display: none;
}

.sub-tab-content.active {
    display: block;
}

.modal-wide {
    max-width: 720px;
}

.ai-content {
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.ai-pre {
    font-family: inherit;
    white-space: pre-wrap;
    margin: 0;
}

