:root {
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --primary-light: #e8f0fe;
    --success: #0d904f;
    --success-light: #e6f4ea;
    --warning: #f29900;
    --warning-light: #fef7e0;
    --danger: #d93025;
    --danger-light: #fce8e6;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --border: #e0e0e0;
    --text: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Layout ─── */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1a3a5c 0%, #0d2137 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.sidebar-brand p { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 4px; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px; cursor: pointer; transition: all var(--transition);
    font-size: 14px; color: rgba(255,255,255,0.7); border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: #4da3ff; font-weight: 600; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
}
.sidebar-footer .user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sidebar-footer .user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: #4da3ff;
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}
.sidebar-footer .user-detail { line-height: 1.3; }
.sidebar-footer .user-name { font-weight: 600; }
.sidebar-footer .user-role { font-size: 11px; color: rgba(255,255,255,0.5); }
.sidebar-footer .logout-btn {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7); padding: 6px 12px; border-radius: 4px;
    cursor: pointer; font-size: 12px; width: 100%; transition: all var(--transition);
}
.sidebar-footer .logout-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

.main-content { margin-left: 240px; flex: 1; min-height: 100vh; }

/* ─── Top Bar ─── */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 20px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.mobile-menu-btn {
    display: none; background: none; border: none; font-size: 24px;
    cursor: pointer; color: var(--text); padding: 4px;
}

/* ─── Content Area ─── */
.content-area { padding: 24px; }

/* ─── Cards ─── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ─── Stats Grid ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
    padding: 20px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500;
    cursor: pointer; border: 1px solid transparent; transition: all var(--transition);
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0b7a43; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b3261e; }
.btn-outline { background: var(--card-bg); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Search & Filter Bar ─── */
.filter-bar {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin-bottom: 20px; padding: 16px; background: var(--card-bg);
    border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
}
.filter-bar input, .filter-bar select {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; outline: none; transition: border var(--transition);
    background: var(--card-bg);
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar select { min-width: 120px; }

/* ─── Table ─── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left; padding: 12px 14px; background: var(--bg);
    font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border);
    cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover { color: var(--primary); }
th .sort-icon { margin-left: 4px; font-size: 11px; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--primary-light); }

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f1f3f4; color: var(--text-secondary); }

.project-name-link { color: var(--primary); cursor: pointer; font-weight: 500; text-decoration: none; }
.project-name-link:hover { text-decoration: underline; }

/* ─── Modal ─── */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: flex-start;
    padding: 40px 20px; overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--card-bg); border-radius: 12px; width: 100%; max-width: 900px;
    box-shadow: var(--shadow-lg); margin: auto;
}
.modal.sm { max-width: 500px; }
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: var(--text-secondary); padding: 4px 8px; border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ─── Forms ─── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.span-2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; outline: none; font-family: inherit; transition: border var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ─── Timeline ─── */
.timeline { position: relative; padding-left: 30px; }
.timeline::before {
    content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item {
    position: relative; margin-bottom: 20px; padding: 12px 16px;
    background: var(--bg); border-radius: var(--radius); border: 1px solid var(--border);
}
.timeline-item::before {
    content: ''; position: absolute; left: -25px; top: 16px;
    width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
    border: 2px solid var(--card-bg);
}
.timeline-item .tl-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.timeline-item .tl-user { font-weight: 600; font-size: 14px; }
.timeline-item .tl-time { font-size: 12px; color: var(--text-muted); }
.timeline-item .tl-action { font-size: 12px; color: var(--primary); margin-bottom: 4px; }
.timeline-item .tl-content { font-size: 14px; color: var(--text); }

/* ─── Stages ─── */
.stages-list { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-badge {
    padding: 6px 12px; border-radius: 4px; font-size: 12px;
    background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
}
.stage-badge.completed { background: var(--success-light); border-color: var(--success); color: var(--success); }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
    padding: 10px 20px; border: none; background: none; cursor: pointer;
    font-size: 14px; font-weight: 500; color: var(--text-secondary);
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Ranking ─── */
.rank-bar-container { margin-top: 8px; }
.rank-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.rank-position { width: 30px; font-weight: 700; font-size: 14px; text-align: center; }
.rank-position.top { color: #f29900; }
.rank-info { flex: 1; }
.rank-name { font-weight: 500; }
.rank-count { font-size: 12px; color: var(--text-muted); }
.rank-bar {
    height: 8px; background: var(--primary-light); border-radius: 4px;
    min-width: 4px; transition: width 0.5s ease;
}
.rank-bar-inner { height: 100%; background: var(--primary); border-radius: 4px; }

/* ─── Pagination ─── */
.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 20px; }
.pagination button {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px;
    background: var(--card-bg); cursor: pointer; font-size: 13px;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-info { font-size: 13px; color: var(--text-secondary); margin: 0 8px; }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ─── Toast ─── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 14px;
    box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; min-width: 250px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; }
    .filter-bar input { min-width: 100%; }
}

/* ─── Page sections ─── */
.page-section { display: none; }
.page-section.active { display: block; }

/* ─── Charts placeholder ─── */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 768px) { .chart-row { grid-template-columns: 1fr; } }
.chart-box { padding: 16px; }
.chart-box canvas { max-height: 300px; }

/* Double column modal form */
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ─── Multi-Checkbox (User Select) ─── */
.multi-checkbox {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    max-height: 260px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.multi-checkbox-search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}
.multi-checkbox-search .search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.multi-checkbox-search .search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.multi-checkbox-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
}
.checkbox-item:hover {
    background: var(--primary-light);
}
.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}
.checkbox-item .dept-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: auto;
    flex-shrink: 0;
}
.multi-checkbox-selected {
    padding: 6px 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    background: #fafafa;
}
.multi-checkbox-selected span {
    color: var(--primary);
    font-weight: 600;
}

/* ─── Stage Cards (进度卡片) ─── */
.stage-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    background: var(--card-bg);
    overflow: hidden;
}
.stage-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-wrap: wrap;
}
.stage-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.stage-card-title .stage-num {
    color: var(--primary);
    margin-right: 4px;
}
.stage-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ─── Quill Rich Text Editor Styles ─── */
.quill-wrapper {
    border: none !important;
}
.quill-wrapper .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 4px 8px;
    background: #fafbfc;
    border-radius: 0;
}
.quill-wrapper .ql-toolbar.ql-snow .ql-formats {
    margin-right: 8px;
}
.quill-wrapper .ql-container.ql-snow {
    border: none;
    font-size: 14px;
    font-family: inherit;
    min-height: 100px;
}
.quill-wrapper .ql-editor {
    min-height: 100px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px 14px;
    line-height: 1.7;
}
.quill-wrapper .ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
    left: 14px;
    right: 14px;
}

/* ─── File Attachments Area ─── */
.stage-files {
    padding: 8px 14px;
    border-top: 1px dashed var(--border);
    background: #fcfcfc;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-height: 32px;
}
.stage-files .no-files {
    font-size: 12px;
    color: var(--text-muted);
}
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    background: var(--primary-light);
    border: 1px solid #d2e3fc;
    max-width: 280px;
}
.file-chip .file-icon {
    font-size: 14px;
}
.file-chip .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}
.file-chip .file-name:hover {
    text-decoration: underline;
}
.file-chip .file-size {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
}
.file-chip .file-delete {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}
.file-chip .file-delete:hover {
    color: var(--danger);
}
.stage-upload {
    padding: 6px 14px;
    border-top: 1px dashed var(--border);
    background: #fcfcfc;
}
.stage-upload .upload-btn {
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
}
.upload-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--primary);
    margin-left: 8px;
}
