/* ===== 基础重置与变量 ===== */
:root {
    --primary: #c23531;
    --primary-dark: #a02926;
    --primary-light: #f4d6d5;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --info: #3498db;
    --text: #333;
    --text-secondary: #666;
    --text-light: #999;
    --bg: #f5f6fa;
    --card-bg: #fff;
    --border: #e8e8e8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 6px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    height: 100%;
}

.hidden { display: none !important; }
.page { min-height: 100vh; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all .2s;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219150; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #2980b9; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ===== 登录页 ===== */
#login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
}
.login-card {
    width: 420px;
    padding: 40px;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 {
    color: var(--primary);
    font-size: 26px;
    margin: 0 0 8px;
}
.login-header p { color: var(--text-secondary); margin: 0; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; }
.login-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.login-form input:focus { outline: none; border-color: var(--primary); }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.login-hint { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--border); color: var(--text-light); font-size: 12px; text-align: center; }
.login-hint p { margin: 4px 0; }

/* ===== 顶部导航 ===== */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 16px; }
.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-weight: 500;
}
.nav-brand-text { color: var(--text); font-weight: 600; }
.nav-tabs { display: flex; gap: 4px; margin-left: 20px; }
.nav-tab {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 14px;
}
.nav-tab:hover { color: var(--primary); background: #fff5f5; }
.nav-tab.active { color: #fff; background: var(--primary); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.save-status { color: var(--success); font-size: 13px; margin-right: 10px; }

/* ===== 主视图 ===== */
.view { padding: 20px; max-width: 1400px; margin: 0 auto; }

/* ===== 列表页 ===== */
.list-header { margin-bottom: 20px; }
.list-header h2 { margin: 0 0 6px; font-size: 20px; }
.list-header p { margin: 0; color: var(--text-secondary); font-size: 13px; }

.table-responsive { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th, .data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.data-table th { background: #fafafa; font-weight: 600; color: var(--text-secondary); }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }

/* ===== 报表页 ===== */
.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.report-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    text-align: center;
}
.report-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.report-label { color: var(--text-secondary); margin-top: 6px; }
.report-chart-placeholder {
    background: #fff;
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

/* ===== 周报编辑页 ===== */
.weekly-report {
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* 头部 */
.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #c23531 0%, #a02926 100%);
    color: #fff;
    padding: 24px 32px;
    gap: 24px;
}
.report-header > div { flex: 1; }
.header-center { text-align: center; flex: 2; }
.header-right { text-align: right; }
.company-name { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.project-info { font-size: 13px; opacity: .9; }
.project-info input[type="date"] {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.project-info input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
.report-header h1 { margin: 0; font-size: 24px; font-weight: 600; }
.header-right { font-size: 13px; line-height: 1.8; }
.header-right [contenteditable], .header-right span { display: inline-block; }
.project-slogan { margin-top: 6px; opacity: .85; font-size: 12px; }
.overall-progress { font-size: 14px; font-weight: 600; }
[contenteditable]:hover { outline: 1px dashed rgba(255,255,255,.4); }
[contenteditable]:focus { outline: 2px solid rgba(255,255,255,.6); background: rgba(255,255,255,.1); }

/* 里程碑 */
.milestone-section { padding: 24px 32px; border-bottom: 1px solid var(--border); }
.section-title { font-weight: 700; color: var(--primary); margin-bottom: 16px; font-size: 15px; }
.milestone-timeline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    padding: 0 20px;
}
.milestone-timeline::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 40px;
    right: 40px;
    height: 4px;
    background: #e8e8e8;
    z-index: 0;
}
.milestone-line-progress {
    position: absolute;
    top: 18px;
    left: 40px;
    height: 4px;
    background: var(--primary);
    z-index: 0;
    transition: width .3s;
}
.milestone-node {
    position: relative;
    z-index: 1;
    text-align: center;
    flex: 1;
}
.milestone-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #ccc;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}
.milestone-node.completed .milestone-dot { border-color: var(--success); color: var(--success); }
.milestone-node.active .milestone-dot { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.milestone-node.pending .milestone-dot { border-color: #ccc; color: #999; }
.milestone-date { font-size: 11px; color: var(--text-light); }
.milestone-desc { font-size: 11px; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; max-width: 120px; margin-left: auto; margin-right: auto; }
.milestone-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: var(--radius);
    font-size: 13px;
}
.status-item { display: flex; align-items: center; gap: 8px; }
.progress-bar-mini {
    width: 120px;
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
    margin-left: 8px;
}
.progress-bar-mini > div { height: 100%; background: var(--primary); width: 0; transition: width .3s; }

/* 统计卡片 */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 24px 32px;
}
.stat-card {
    text-align: center;
    padding: 24px;
    border-radius: var(--radius);
    border-top: 4px solid;
    background: #fff;
    box-shadow: var(--shadow);
}
.stat-danger { border-top-color: var(--danger); }
.stat-warning { border-top-color: var(--warning); }
.stat-success { border-top-color: var(--success); }
.stat-value { font-size: 42px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { color: var(--text-secondary); margin-top: 10px; font-size: 13px; }

/* 表格模块 */
.table-section { padding: 24px 32px; border-top: 1px solid var(--border); }
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.section-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}
.section-header .section-title { margin: 0; }
.section-meta { flex: 1; color: var(--text-light); font-size: 12px; font-weight: normal; }

.progress-table .module-cell select,
.risk-table .level-cell select,
.support-table .category-cell select,
.data-table select,
.data-table input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}
.data-table input:focus, .data-table select:focus { outline: none; border-color: var(--primary); }
.data-table td [contenteditable] {
    min-height: 28px;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
}
.data-table td [contenteditable]:hover { border-color: #ddd; }
.data-table td [contenteditable]:focus { border-color: var(--primary); background: #fff; outline: none; }
.status-select { min-width: 80px; }
.progress-input { width: 70px; text-align: center; }
.row-actions { display: flex; gap: 4px; justify-content: center; }
.row-actions button {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.row-actions button:hover { color: var(--primary); border-color: var(--primary); }
.row-actions .btn-del:hover { color: var(--danger); border-color: var(--danger); }

.module-empty { text-align: center; padding: 30px; color: var(--text-light); font-size: 13px; }

/* 底部 */
.report-footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 32px;
    background: #fafafa;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== 组件 ===== */
.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 2000;
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2001;
}
.modal-content {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 400px;
    max-width: 90%;
    box-shadow: var(--shadow);
}
.modal-content h3 { margin: 0 0 12px; }
.modal-content p { margin: 0 0 20px; color: var(--text-secondary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ===== 打印/PDF ===== */
@media print {
    .top-nav, .section-header button, .row-actions, .toast, .modal { display: none !important; }
    .weekly-report { box-shadow: none; }
    body { background: #fff; }
    .view { padding: 0; max-width: 100%; }
    .data-table td [contenteditable], .data-table input, .data-table select { border: none; background: transparent; }
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .report-header { flex-direction: column; text-align: center; gap: 16px; }
    .header-left, .header-center, .header-right { text-align: center; }
    .stat-cards { grid-template-columns: 1fr; }
    .milestone-timeline { overflow-x: auto; }
    .top-nav { flex-wrap: wrap; height: auto; padding: 10px; gap: 10px; }
    .nav-tabs { margin-left: 0; }
}
