/* ===== 全局变量 ===== */
:root {
    --primary: #4f6df5;
    --primary-dark: #3b56c9;
    --primary-light: #eef2ff;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-page: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
    --sidebar-width: 230px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

#app {
    display: flex;
    min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.logo-title {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

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

.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

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

.nav-group-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 12px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

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

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
}

.breadcrumb-current {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-icon {
    position: relative;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.btn-icon:hover {
    background: var(--bg-page);
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.page-content {
    padding: 24px;
    flex: 1;
}

/* ===== 通用组件 ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.card-link:hover {
    text-decoration: underline;
}

/* ===== 驾驶舱 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.stat-card.blue::before { background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-value .unit {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-trend {
    font-size: 12px;
    font-weight: 600;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-grid .card {
    margin-bottom: 0;
}

/* 今日要事 */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.alert-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.alert-dot.red { background: var(--danger); }
.alert-dot.orange { background: var(--warning); }
.alert-dot.green { background: var(--success); }

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.alert-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.alert-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 项目健康度 */
.project-health-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.project-health-item:last-child { border-bottom: none; }

.health-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-status.green { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,0.15); }
.health-status.yellow { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.health-status.red { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }

.ph-info { flex: 1; }
.ph-name { font-size: 13px; font-weight: 600; }
-ph-customer { font-size: 12px; color: var(--text-secondary); }
.ph-customer { font-size: 12px; color: var(--text-secondary); }

.ph-progress {
    width: 100px;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.ph-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.ph-amount {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 人效排行 */
.efficiency-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.eff-rank {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.eff-rank.top1 { background: #fef3c7; color: #d97706; }
.eff-rank.top2 { background: #e0e7ff; color: #4f6df5; }
.eff-rank.top3 { background: #fce7f3; color: #db2777; }
.eff-rank.normal { background: var(--bg-page); color: var(--text-muted); }

.eff-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.eff-info { flex: 1; }
.eff-name { font-size: 13px; font-weight: 600; }
.eff-dept { font-size: 11px; color: var(--text-muted); }

.eff-score {
    font-size: 15px;
    font-weight: 800;
}

.eff-score.high { color: var(--success); }
.eff-score.mid { color: var(--warning); }
.eff-score.low { color: var(--danger); }

/* ===== 表格 ===== */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

.input, .select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    transition: border 0.15s;
    background: #fff;
}

.input:focus, .select:focus {
    border-color: var(--primary);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

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

.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

.data-table tr:hover td {
    background: #fafbfc;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-green { background: #dcfce7; color: #16a34a; }
.tag-orange { background: #fef3c7; color: #d97706; }
.tag-red { background: #fee2e2; color: #dc2626; }
.tag-gray { background: #f1f5f9; color: var(--text-secondary); }
.tag-purple { background: #f3e8ff; color: #9333ea; }

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-right: 6px;
    vertical-align: middle;
}

.progress-bar {
    width: 100px;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
}

/* ===== 大客户矩阵 ===== */
.client-tree {
    padding: 4px 0;
}

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

.client-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.client-group-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
}

.client-group-stat {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

.client-children {
    padding-left: 24px;
    margin-top: 8px;
}

.client-child {
    margin-bottom: 8px;
}

.client-child-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: #fafbfc;
}

.client-child-name {
    font-size: 13px;
    font-weight: 600;
}

.client-projects {
    padding-left: 24px;
    margin-top: 4px;
}

.client-project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== 日报卡片 ===== */
.report-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
}

.report-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.report-card-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.report-card-body strong {
    color: var(--text-primary);
}

.report-tags {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* ===== 简报 ===== */
.briefing-card {
    background: linear-gradient(135deg, #4f6df5, #7c3aed);
    border-radius: var(--radius);
    padding: 28px;
    color: #fff;
    margin-bottom: 20px;
}

.briefing-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.briefing-date {
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 20px;
}

.briefing-section {
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.briefing-section-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.briefing-section ul {
    list-style: none;
    font-size: 13px;
    opacity: 0.95;
}

.briefing-section li {
    padding: 4px 0;
}

/* ===== 页面切换 ===== */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

/* ===== 登录页 ===== */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #1e293b, #334155);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-overlay.hidden { display: none; }

.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-icon {
    margin: 0 auto 12px;
}

.login-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.login-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border 0.15s;
}

.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,109,245,0.1);
}

.login-btn {
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.login-btn:hover { background: var(--primary-dark); }

.btn-logout {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
}

.btn-logout:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* ===== 加载状态 ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 600px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-title {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover { background: var(--bg-page); color: var(--text-primary); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 16px;
}

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

.form-label .required {
    color: var(--danger);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border 0.15s;
    background: #fff;
    font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,109,245,0.08);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 20px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.form-section-title:first-child {
    margin-top: 0;
}

/* 应收节点动态列表 */
.payment-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.payment-row .form-input {
    padding: 7px 10px;
    font-size: 13px;
}

.btn-remove {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--danger);
    cursor: pointer;
    padding: 7px 10px;
    font-size: 13px;
}

.btn-remove:hover { background: #fee2e2; }

.btn-add-row {
    background: var(--primary-light);
    border: 1px dashed var(--primary);
    color: var(--primary);
    border-radius: var(--radius-sm);
    padding: 8px;
    width: 100%;
    cursor: pointer;
    font-size: 13px;
    margin-top: 4px;
}

.btn-add-row:hover { background: #e0e7ff; }

/* 项目成员选择 */
.member-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

/* 日报项目关联项 */
.report-project-item {
    background: var(--bg-page);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
}

.report-project-item .form-row {
    margin-bottom: 8px;
}

.report-project-item .form-textarea {
    min-height: 50px;
}

/* 员工日报页面 */
.employee-portal {
    max-width: 800px;
    margin: 0 auto;
}

.portal-header {
    text-align: center;
    margin-bottom: 24px;
}

.portal-greeting {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.portal-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.portal-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 12px;
}

.portal-status.submitted {
    background: #dcfce7;
    color: #16a34a;
}

.portal-status.pending {
    background: #fef3c7;
    color: #d97706;
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px; }
}
