/* 现代 CSS 变量重置 */
:root {
    /* 品牌色 */
    --primary: #4f46e5;      /* 靛蓝 */
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    /* 状态色 */
    --success: #10b981;      /* 翠绿 */
    --success-hover: #059669;
    --warning: #f59e0b;      /* 琥珀 */
    --warning-hover: #d97706;
    --danger: #ef4444;       /* 宝石红 */
    --danger-hover: #dc2626;
    --info: #3b82f6;         /* 亮蓝 */
    --info-hover: #2563eb;
    /* 灰度/背景 */
    --bg-body: #ffffff;
    --bg-surface: #ffffff;
    --bg-sidebar: #eef2ff;   /* Indigo 50 */
    /* 文本 */
    --text-main: #0f172a;
    --text-muted: #64748b;   /* Slate 500 */
    --text-light: #312e81;   /* Indigo 900 */
    --text-sidebar: #4338ca; /* Indigo 700 */
    /* 结构 */
    --border-color: #e0e7ff; /* Indigo 100 */
    --table-stripe: #f8fafc;
    --th-icon-color: #cbd5e1;
    --progress-bg: #e2e8f0;
    --primary-accent: #818cf8;
    /* 半径 */
    --radius-xs: 3px;
    --radius-sm: 5px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 9999px;
    --radius: 8px;            /* 统计卡片专用 */
    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    /* 层级 */
    --z-topbar: 5;
    --z-sidebar: 10;
    --z-modal: 1000;
    --z-notification: 9999;
    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    /* 徽章语义色 */
    --badge-success-bg: #dcfce7;
    --badge-success-text: #166534;
    --badge-warning-bg: #fef3c7;
    --badge-warning-text: #92400e;
    --badge-danger-bg: #fee2e2;
    --badge-danger-text: #991b1b;
    --badge-info-bg: #e0f2fe;
    --badge-info-text: #075985;
    --badge-primary-bg: #e0e7ff;
    --badge-primary-text: #3730a3;
    --badge-secondary-bg: #f1f5f9;
    --badge-secondary-text: #475569;
    /* 统计卡片图标色 */
    --stat-icon-1-bg: #e0e7ff;
    --stat-icon-2-bg: #dcfce7;
    --stat-icon-3-bg: #fef3c7;
    --stat-icon-4-bg: #fee2e2;
    /* 进度条渐变色 */
    --progress-danger: linear-gradient(180deg, #ff1744, #b71c1c);
    --progress-warning: linear-gradient(180deg, #ff9100, #e65100);
    --progress-info: linear-gradient(180deg, #00e5ff, #0091ea);
    --progress-primary: linear-gradient(180deg, #651fff, #5600e8);
    --progress-success: linear-gradient(180deg, #00e676, #00c853);
    --unneeded-row-bg: rgba(59, 130, 246, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow: hidden; /* 防止body滚动，让内容区滚动 */
}

/* ----- 全新 App 布局 ----- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: var(--z-sidebar);
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-header i {
    color: var(--primary);
    font-size: 1.5rem;
    margin-right: 12px;
}

.sidebar-menu {
    flex: 1;
    padding: 24px 16px;
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 12px;
    text-align: center;
}

.nav-link:hover {
    background-color: rgba(79, 70, 229, 0.08);
    color: var(--primary);
}

.nav-link.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* 主内容区 */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background-color: var(--bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    box-shadow: var(--shadow-sm);
    z-index: var(--z-topbar);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    color: var(--text-muted);
}
.topbar-right > a { color: var(--text-muted); transition: color 0.2s; font-size: 1.2rem; padding: 6px; display: flex; align-items: center; text-decoration: none; }
.topbar-right > a:hover { color: var(--text-main); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-main);
    position: relative;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    overflow: hidden;
}

/* 用户名片 Popover */
.user-popover {
    opacity: 0; visibility: hidden;
    pointer-events: none;
    position: absolute;
    top: 100%; right: 0;
    margin-top: 10px;
    width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 18px;
    z-index: 100;
    text-align: center;
    transition: opacity 0.15s, visibility 0.15s;
}
.user-profile:hover .user-popover,
.user-popover:hover { opacity: 1; visibility: visible; pointer-events: auto; }
/* 透明桥接：填补触发区和弹窗之间的空隙 */
.user-popover::after {
    content: '';
    position: absolute;
    top: -20px; left: 0; right: 0;
    height: 20px;
    background: transparent;
}
.user-popover::before {
    content: '';
    position: absolute;
    top: -6px; right: 14px;
    width: 12px; height: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-right: none; border-bottom: none;
    transform: rotate(45deg);
}
.up-avatar { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 10px; overflow: hidden; }
.up-avatar img { width: 100%; height: 100%; object-fit: cover; }
.up-avatar-letter {
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-accent));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.3rem; font-weight: 700;
}
.up-name { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.up-role { display: inline-block; padding: 4px 14px; border-radius: 20px; font-size: 0.76rem; font-weight: 600; margin: 4px 0 10px; background: #ede9fe; color: #6d28d9; }
.up-email { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
.up-link { display: inline-block; padding: 4px 14px; border-radius: 20px; background: rgba(79,70,229,0.08); color: var(--primary); font-size: 0.76rem; font-weight: 600; text-decoration: none; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.up-link:hover { background: rgba(79,70,229,0.14); color: #3730a3; box-shadow: 0 2px 8px rgba(79,70,229,0.15); transform: translateY(-1px); }

.content-area {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* ----- 页面与排版 ----- */
.page {
    display: none;
    animation: fadeUp 0.4s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ----- UI 组件 ----- */
/* ===== 按钮系统 ===== */
/* 基础按钮 */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active { transform: scale(0.97); }

/* 焦点环 — 键盘无障碍 */
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* 禁用态 */
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.btn:disabled:active,
.btn.disabled:active {
    transform: none;
}

/* ——— 实心颜色变体 ——— */
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); }

.btn-success { background-color: var(--success); color: white; }
.btn-success:hover { background-color: var(--success-hover); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); }

.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: var(--danger-hover); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25); }

.btn-warning { background-color: var(--warning); color: white; }
.btn-warning:hover { background-color: var(--warning-hover); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25); }

.btn-info { background-color: var(--info); color: white; }
.btn-info:hover { background-color: var(--info-hover); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25); }

.btn-secondary { background-color: white; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: #f1f5f9; }

/* ——— 描边颜色变体 ——— */
.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-outline-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.btn-outline-secondary:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-outline-success {
    background: transparent;
    color: var(--success);
    border: 1px solid var(--success);
}
.btn-outline-success:hover {
    background: var(--success);
    color: white;
}

/* ——— 尺寸变体 ——— */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

/* ——— 图标按钮 ——— */
.btn-icon {
    padding: 6px 10px;
    font-size: 0.85rem;
    transition: var(--transition);
}

/* 危险图标按钮悬停增强：红色发光 + 更强抬升 */
.btn-danger.btn-icon:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

/* 表单提交区按钮微调 */
.config-submit .btn {
    padding: 10px 28px;
    font-size: 0.95rem;
}

/* 卡片面板 */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 生产总览统计卡片 */
/* ===== 统计卡片 (Design D: 数据密集型) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-surface);
    padding: 18px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* 卡片头部：圆点 + 标签 */
.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stat-dot.c1 { background: var(--primary); }
.stat-dot.c2 { background: var(--warning); }
.stat-dot.c3 { background: #0284c7; }
.stat-dot.c4 { background: var(--success); }
.stat-dot.c5 { background: var(--danger); }
.stat-dot.c6 { background: #8b5cf6; }

.stat-card-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* 主数值 */
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

/* 标题 */
.stat-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: -4px;
}

/* 细分进度条区域 */
.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
}

.stat-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
}

.stat-bar-lbl {
    color: var(--text-muted);
    min-width: 36px;
}

.stat-bar-val {
    color: var(--text-main);
    font-weight: 600;
    min-width: 24px;
    text-align: right;
}

.stat-bar-bg {
    flex: 1;
    height: 6px;
    background: var(--bg-body);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.stat-bar-fill.c1 { background: var(--primary); }
.stat-bar-fill.c2 { background: var(--warning); }
.stat-bar-fill.c3 { background: #0284c7; }
.stat-bar-fill.c4 { background: var(--success); }
.stat-bar-fill.c5 { background: var(--danger); }
.stat-bar-fill.c6 { background: #8b5cf6; }

/* 表格优化 */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

thead {
    background-color: var(--table-stripe);
    border-bottom: 1px solid var(--border-color);
}

th {
    padding: 16px 24px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
}

th:hover { color: var(--primary); }
th i { font-size: 0.75rem; margin-left: 6px; color: var(--th-icon-color); }

td {
    padding: 16px 24px;
    font-size: 0.95rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tbody tr { transition: var(--transition); }
tbody tr:hover { background-color: var(--table-stripe); }

/* 状态徽章 (Badge) */
.badge {
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge::before { content: ""; display: block; width: 6px; height: 6px; border-radius: 50%; }

.badge-success { background: var(--badge-success-bg); color: var(--badge-success-text); }
.badge-success::before { background: var(--badge-success-text); }

.badge-warning { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.badge-warning::before { background: var(--badge-warning-text); }

.badge-danger { background: var(--badge-danger-bg); color: var(--badge-danger-text); }
.badge-danger::before { background: var(--badge-danger-text); }

.badge-info { background: var(--badge-info-bg); color: var(--badge-info-text); }
.badge-info::before { background: var(--badge-info-text); }

.badge-primary { background: var(--badge-primary-bg); color: var(--badge-primary-text); }
.badge-primary::before { background: var(--badge-primary-text); }

.badge-secondary { background: var(--badge-secondary-bg); color: var(--badge-secondary-text); }
.badge-secondary::before { background: var(--badge-secondary-text); }

/* ===== 生产配置 — 时间轴 ===== */
/* ===== 时间轴 + 时钟 容器 ===== */
.timeline-container {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin: 16px 0 24px;
}

/* ===== 左侧时钟 ===== */
.timeline-clock-area {
    flex: 0 0 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.live-clock {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
}

/* 时针/分针：平滑过渡；秒针：无过渡 */
.live-clock #clockHourHand,
.live-clock #clockMinuteHand {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.live-clock #clockSecondHand {
    transition: none;
}

.live-clock-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

/* ===== 右侧时间轴 ===== */
.timeline-bar-area {
    flex: 1;
    min-width: 0;
}

/* 右列：上时间轴 + 下工作日 */
.timeline-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.timeline-bar {
    position: relative;
    height: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 30px;
}

.timeline-segment {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 6px;
    margin-right: 4px;
    transition: left 0.35s ease, width 0.35s ease;
}
.timeline-segment:last-child {
    margin-right: 0;
}

.timeline-work-morning {
    background: #6366f1;
}

.timeline-lunch {
    background: #f59e0b;
}

.timeline-work-afternoon {
    background: #6366f1;
}

/* ===== 标记 ===== */
.timeline-markers {
    position: relative;
    height: 0;
}

.timeline-marker {
    position: absolute;
    transform: translateX(-50%);
    text-align: center;
    cursor: grab;
    top: -30px;
    transition: transform 0.2s ease;
}

.timeline-marker:hover {
    transform: translateX(-50%) scale(1.12);
    z-index: 5;
}

.timeline-marker:active {
    cursor: grabbing;
}

.timeline-marker .marker-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin: 0 auto 3px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.10);
}

.timeline-marker .marker-time {
    display: inline-block;
    font-weight: 700;
    font-size: 0.85rem;
    color: #475569;
    white-space: nowrap;
}

/* ===== 工作日历 ===== */
.weekday-section {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.weekday-section-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.weekday-toggles {
    display: flex;
    gap: 4px;
}

.workday-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.workday-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.workday-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* ===== 每周工作时长（只读） ===== */
.weekly-hours-display {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border: 1px solid #c7d2fe;
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: center;
}

.weekly-hours-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.weekly-hours-value {
    font-size: 2rem;
    font-weight: 800;
    color: #4338ca;
}

.weekly-hours-value span {
    display: inline;
}

.weekly-hours-unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: #6366f1;
    margin-left: 4px;
}

.weekly-hours-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== 时间轴拖动 ===== */
.timeline-bar-area.dragging {
    cursor: ew-resize;
    user-select: none;
}

.timeline-marker.dragging {
    transform: translateX(-50%) scale(1.2) !important;
    z-index: 10;
}

.timeline-marker.dragging .marker-time {
    color: var(--primary);
    font-weight: 800;
}

/* 模态框优化 (玻璃拟态) */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content { transform: scale(1); }

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

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

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.close-modal:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

.modal-body { padding: 24px; }

/* 表单控件 */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--bg-surface);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s ease, background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    background: var(--table-stripe);
    position: relative;
}

.file-upload:hover { 
    border-color: var(--primary); 
    background: var(--primary-light); 
    transform: translateY(-3px); 
    box-shadow: 0 5px 20px rgba(79, 70, 229, 0.4);
}
.file-upload.dragover { 
    border-color: var(--primary) !important; 
    background: var(--primary-light) !important; 
    transform: translateY(-3px) scale(1.02) !important; 
    box-shadow: 0 5px 25px rgba(79, 70, 229, 0.6) !important;
    border-style: solid !important;
    border-width: 3px !important;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 5px 25px rgba(79, 70, 229, 0.6); }
    50% { box-shadow: 0 5px 30px rgba(79, 70, 229, 0.8); }
    100% { box-shadow: 0 5px 25px rgba(79, 70, 229, 0.6); }
}
.file-upload i { font-size: 2.5rem; color: var(--primary); margin-bottom: 12px; }

/* 生产队列 */
.queue-item {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}
.queue-item:last-child { border-bottom: none; }

.queue-info { width: 30%; }
.queue-info h4 { font-size: 1rem; margin-bottom: 4px; }
.queue-info p { font-size: 0.8rem; color: var(--text-muted); }

.queue-progress-wrap { flex: 1; padding: 0 24px; display: flex; align-items: center; gap: 16px; }
.progress-bar {
    flex: 1;
    height: 8px;
    background-color: var(--progress-bg);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.progress-value {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-accent));
    border-radius: var(--radius-pill);
    transition: width 0.5s ease;
}
.progress-text { font-size: 0.85rem; font-weight: 600; color: var(--primary); width: 40px;}

/* 图表容器限制 */
.chart-wrapper {
    position: relative;
    height: 350px;
    width: 100%;
    padding: 16px;
}

/* 动画 */
@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* 进度条状态渐变色 */
.progress-bar-danger  { background: var(--progress-danger); }
.progress-bar-warning { background: var(--progress-warning); }
.progress-bar-info    { background: var(--progress-info); }
.progress-bar-primary { background: var(--progress-primary); }
.progress-bar-success { background: var(--progress-success); }

.progress-bar.completed { animation: completedPulse 2s ease-in-out infinite; }

@keyframes completedPulse {
    0%, 100% { box-shadow: inset 0 0 0 1px rgba(0,230,118,0.3), 0 0 12px rgba(0,230,118,0.4); }
    50%      { box-shadow: inset 0 0 0 1px rgba(0,230,118,0.6), 0 0 24px rgba(0,230,118,0.67); }
}

/* ===== Number Input Stepper — 隐藏原生箭头 + 融合式右侧按钮 ===== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* 融合式容器: [输入框][−][+] 整体圆角 */
.stepper-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}
.stepper-wrapper:focus-within {
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* 输入框 — 左侧圆角，右侧无圆角衔接按钮 */
.stepper-wrapper > input.form-control,
.stepper-wrapper > input[type="number"] {
    height: 38px;
    padding: 6px 10px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    flex: 1;
    min-width: 60px;
    background: var(--bg-surface);
    transition: border-color 0.2s ease;
}
.stepper-wrapper:focus-within > input {
    border-color: var(--primary);
    outline: none;
}

/* 右侧 − / + 按钮 */
.stepper-btn {
    width: 32px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
    user-select: none;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.stepper-btn:hover {
    z-index: 1;
}
.stepper-btn.dec {
    border-left: none;
    border-right: 0.5px solid var(--border-color);
}
.stepper-btn.dec:hover {
    background: #fee2e2;
    color: var(--danger);
}
.stepper-btn.inc {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}
.stepper-btn.inc:hover {
    background: #dcfce7;
    color: var(--success);
}
.stepper-btn:active {
    transform: scale(0.93);
}

/* ===== 反馈页紧凑步进器 ===== */
.btn-qty {
    width: 28px;
    height: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    user-select: none;
    color: var(--text-muted);
    padding: 0;
    flex-shrink: 0;
}
.btn-qty:hover {
    z-index: 1;
}
.btn-qty.minus {
    border-left: none;
    border-right: 0.5px solid var(--border-color);
    border-radius: 0;
}
.btn-qty.minus:hover {
    background: #fee2e2;
    color: var(--danger);
}
.btn-qty.plus {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}
.btn-qty.plus:hover {
    background: #dcfce7;
    color: var(--success);
}
.btn-qty:active {
    transform: scale(0.93);
}

/* ===== 自定义 Select 下拉框 ===== */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 38px;
    padding: 0 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.custom-select-trigger:hover {
    border-color: var(--primary);
}

.custom-select-trigger:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select-trigger .trigger-text {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.custom-select-trigger .trigger-text.placeholder {
    color: var(--text-muted);
}

.custom-select-trigger .trigger-arrow {
    margin-left: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select-wrapper.open .trigger-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-modal) + 1);
    max-height: 240px;
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.custom-select-wrapper.open .custom-select-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.custom-select-option {
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.15s ease;
}

.custom-select-option:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.custom-select-option:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.custom-select-option:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.custom-select-option.selected {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.custom-select-option.empty {
    color: var(--text-muted);
    font-style: normal;
}

.custom-select-option.empty:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* 隐藏原生 select */
.custom-select-wrapper .native-select-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* ===== 通用工具类 ===== */
/* 表单错误提示 */
.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* 表格行 — 图片+文字布局 */
.cell-with-image {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 表格缩略图 */
.thumb-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* 无图片时的占位框 */
.img-placeholder {
    width: 40px;
    height: 40px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* 按钮组容器 */
.action-group {
    display: flex;
    gap: 8px;
}

/* 空状态 */
.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

/* 响应式 */
@media (max-width: 1024px) {
    .sidebar { width: 80px; }
    .sidebar-header span, .sidebar-menu span, .sidebar-footer { display: none; }
    .nav-link { justify-content: center; padding: 16px 0; }
    .nav-link i { margin-right: 0; font-size: 1.3rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    .queue-item { flex-direction: column; align-items: flex-start; gap: 12px; }
    .queue-info { width: 100%; }
    .queue-progress-wrap { width: 100%; padding: 0; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header > div:last-child { width: 100%; }
}

@media (max-width: 480px) {
    .content-area { padding: 16px; }
    .page-title { font-size: 1.25rem; }
    .page-header > div:last-child { flex-wrap: wrap; }
    .btn { padding: 8px 14px; font-size: 0.85rem; }
    .btn-sm { padding: 5px 10px; font-size: 0.75rem; }
    .modal-content { max-width: 95vw; margin: 10px; }
    .card-header { padding: 12px 16px; }
    td, th { padding: 10px 12px; font-size: 0.85rem; }
}

/* ===== 铃铛下拉面板 ===== */
.bell-wrapper { position: relative; display: flex; align-items: center; }
.bell-icon { font-size: 1.2rem; cursor: pointer; color: var(--text-muted); transition: color 0.2s, transform 0.3s; padding: 6px; }
.bell-icon:hover { color: var(--text-main); }
.bell-icon.has-alert { color: var(--warning); animation: bellShake 0.6s ease-in-out; }
.bell-badge {
    position: absolute; top: -2px; right: -4px;
    min-width: 18px; height: 18px;
    background: var(--danger); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    padding: 0 5px; line-height: 1; pointer-events: none;
}

.bell-dropdown {
    position: absolute; top: 100%; right: -10px; margin-top: 10px;
    width: 400px; max-width: calc(100vw - 24px); max-height: 480px;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    z-index: var(--z-notification); display: none; flex-direction: column;
    overflow: hidden;
}
.bell-dropdown.open { display: flex; animation: bellSlideIn 0.25s ease-out; }

.bell-dropdown-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border-color);
    font-weight: 700; font-size: 0.95rem; color: var(--text-main);
}
.bell-view-all { display: inline-block; padding: 4px 14px; border-radius: 20px; background: rgba(79,70,229,0.08); color: var(--primary); font-size: 0.76rem; font-weight: 600; text-decoration: none; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.bell-view-all:hover { background: rgba(79,70,229,0.14); color: #3730a3; box-shadow: 0 2px 8px rgba(79,70,229,0.15); transform: translateY(-1px); text-decoration: none; }
.bell-view-all i { transition: transform 0.2s; }
.bell-view-all:hover i { transform: translateX(2px); }

.bell-dropdown-body { padding: 4px 0; overflow-y: auto; max-height: 380px; }
.bell-loading { text-align: center; padding: 28px; color: var(--text-muted); font-size: 0.88rem; }
.bell-empty { text-align: center; padding: 28px; color: var(--text-muted); }
.bell-empty i { font-size: 2rem; opacity: 0.3; margin-bottom: 8px; display: block; }

.bell-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 18px; border-bottom: 1px solid #f1f5f9; cursor: default; transition: background 0.12s; }
.bell-item:hover { background: #f8fafc; }
.bell-item:last-child { border-bottom: none; }
.bell-item-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.bell-item-dot.info { background: #3b82f6; }
.bell-item-dot.warning { background: #f59e0b; }
.bell-item-dot.error { background: #ef4444; }
.bell-item-dot.critical { background: #7c3aed; }
.bell-item-content { flex: 1; min-width: 0; }
.bell-item-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.bell-item-time { font-size: 0.75rem; color: var(--text-muted); }
.bell-item-source { font-size: 0.7rem; background: #f1f5f9; color: #64748b; padding: 1px 6px; border-radius: 3px; }
.bell-item-severity { font-size: 0.7rem; font-weight: 600; padding: 1px 6px; border-radius: 3px; }
.bell-item-severity.info { background: #dbeafe; color: #1d4ed8; }
.bell-item-severity.warning { background: #fef3c7; color: #b45309; }
.bell-item-severity.error { background: #fee2e2; color: #b91c1c; }
.bell-item-severity.critical { background: #ede9fe; color: #6d28d9; }
.bell-item-msg { font-size: 0.82rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@keyframes bellSlideIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes bellShake {
    0%,100% { transform: rotate(0); }
    20% { transform: rotate(-12deg); }
    40% { transform: rotate(10deg); }
    60% { transform: rotate(-6deg); }
    80% { transform: rotate(4deg); }
}

/* ===== 会话超时倒计时模态框 ===== */
#timeout-modal-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    animation: timeoutFadeIn 0.25s ease-out;
}
.timeout-modal {
    background: #fff; border-radius: 16px; padding: 36px 44px;
    text-align: center; max-width: 400px; width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    animation: timeoutScaleIn 0.3s ease-out;
}
.timeout-modal-icon {
    font-size: 2.8rem; color: var(--warning, #f59e0b); margin-bottom: 12px;
}
.timeout-modal h3 { font-size: 1.15rem; margin-bottom: 8px; color: var(--text-main); }
.timeout-modal p  { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.timeout-modal #timeout-countdown {
    color: var(--danger, #ef4444); font-size: 1.1rem; font-weight: 700;
}
.timeout-modal .btn { min-width: 120px; }
@keyframes timeoutFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes timeoutScaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* ===== 药丸式图表图例（chart-legend.js） ===== */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.card-header .chart-legend {
    margin-left: auto;
    margin-top: 2px;
}
.chart-legend--bottom {
    justify-content: center;
    margin-top: 10px;
}
.legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 13px;
    border: none;
    border-radius: 999px;
    background: color-mix(in srgb, var(--c) 10%, transparent);
    color: var(--c);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}
.legend-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.10);
}
.legend-pill.dimmed {
    opacity: 0.38;
}

/* 环形图左右布局：左圆盘 + 右侧竖排图例 */
.doughnut-layout {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 16px;
}
.doughnut-layout .chart-wrapper,
.doughnut-layout .chart-wrap {
    flex: 1;
    min-width: 0;
}
.chart-legend--side {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    margin: 0;
}

