/* ==================================================================
 * 研发部工作台 v2.0 · 主样式
 * 设计目标：
 *   1. 电脑端：宽屏信息密度高、操作便捷
 *   2. 手机端：单列卡片流、底部 Tab 一键切换
 *   3. 统一视觉语言：圆角、阴影、渐变、色彩语义化
 * ================================================================== */

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ========== 设计变量 ========== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-soft: #eff6ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;

    --text: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-disabled: #cbd5e1;

    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 20px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.2);

    --sidebar-w: 240px;
    --topbar-h: 60px;
    --bottom-nav-h: 64px;
}

/* ========== 布局 ========== */
/* 加载遮罩：默认隐藏，body.js-loading 时才显示
   关键修复：JS 加载失败时遮罩也不会卡住页面 */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
body.js-loading::before { opacity: 1; pointer-events: auto; }
body.js-ready::before { opacity: 0; pointer-events: none; }
/* 兜底：任何错误情况下确保遮罩不会挡住内容 */
body:not(.js-loading)::before { pointer-events: none !important; }

/* 桌面布局 */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.3s ease;
}
.sidebar-backdrop {
    position: fixed;
    top: var(--topbar-h);
    left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 89;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
.main-content {
    position: fixed;
    top: var(--topbar-h);
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg);
}

/* ========== 顶部栏 ========== */
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px; height: 36px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text);
}
.menu-toggle:hover { background: var(--bg-hover); }
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}
.logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -1px;
}
.logo-text { display: inline-block; }
.topbar-title {
    font-size: 12px;
    color: var(--text-tertiary);
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.sync-badge {
    font-size: 11px;
    padding: 4px 10px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 999px;
    font-weight: 500;
}
.sync-badge.saving { background: var(--warning-light); color: var(--warning); }
.sync-badge.ok { background: var(--success-light); color: var(--success); }
.sync-badge.error { background: var(--danger-light); color: var(--danger); }

.icon-btn {
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    position: relative;
    transition: all 0.2s;
}
.icon-btn:hover { background: var(--bg-hover); border-color: var(--primary); transform: translateY(-1px); }

/* 全局搜索 */
.global-search {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 12px;
    width: 240px;
    transition: all 0.2s;
}
.global-search:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    width: 320px;
}
.global-search input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}
.global-search kbd {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: ui-monospace, monospace;
}

.search-panel {
    position: fixed;
    top: calc(var(--topbar-h) + 8px);
    right: 12px;
    width: 480px;
    max-height: calc(100vh - var(--topbar-h) - 100px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s;
}
.search-panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.search-panel-header h3 { font-size: 14px; font-weight: 700; }
.search-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: 60vh;
}
.search-group {
    margin-bottom: 12px;
}
.search-group-title {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    font-weight: 600;
    padding: 4px 8px;
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}
.search-result-item:hover { background: var(--bg); }
.search-result-icon { font-size: 16px; flex-shrink: 0; }
.search-result-info { flex: 1; min-width: 0; }
.search-result-title { font-size: 13px; font-weight: 500; }
.search-result-meta { font-size: 11px; color: var(--text-tertiary); }

/* 导出页面 */
.export-page {
    max-width: 800px;
    margin: 0 auto;
}
.export-board {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}
.export-board-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.export-board-icon {
    width: 32px; height: 32px;
    background: var(--bg);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.export-board-title {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}
.export-board-count {
    color: var(--text-tertiary);
    font-size: 12px;
}
.export-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}
.export-module-btn {
    display: flex !important;
    justify-content: space-between;
    padding: 10px 14px;
}

.notif-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px white;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: var(--bg-hover);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s;
}
.user-badge:hover { background: var(--primary-soft); }
.user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 600; }

/* ========== 侧边栏 ========== */
.sidebar-section {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 12px 8px;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: left;
    transition: all 0.2s;
    margin-bottom: 2px;
    font-family: inherit;
    font-weight: 500;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-icon { font-size: 18px; flex-shrink: 0; transition: transform 0.2s; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
    background: var(--bg-hover);
    color: var(--text-tertiary);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
}
.nav-item.active .nav-count {
    background: var(--primary);
    color: white;
}

.sidebar-footer-section {
    margin-top: auto;
    background: var(--bg);
}
.sidebar-perms {
    padding: 16px 12px 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.8;
}
.perms-title { font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.sidebar-version {
    padding: 8px 16px 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    opacity: 0.6;
}

/* ========== 移动端底部 Tab ========== */
.mobile-bottom-nav {
    display: none;
}

/* ========== 加载骨架 ========== */
.loading-skeleton {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    max-width: 800px;
}
.skeleton-card {
    height: 180px;
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-lg);
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========== 看板卡片 ========== */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
}
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}
.dashboard-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.dashboard-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
}
.dashboard-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: var(--stat-color, var(--primary));
    opacity: 0.05;
    border-radius: 50%;
    transform: translate(30%, -30%);
}
.stat-icon {
    font-size: 24px;
    margin-bottom: 8px;
}
.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.stat-extra {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.stat-card.stat-primary { --stat-color: var(--primary); }
.stat-card.stat-success { --stat-color: var(--success); }
.stat-card.stat-warning { --stat-color: var(--warning); }
.stat-card.stat-info { --stat-color: var(--info); }

.board-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.board-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.board-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.board-summary-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--board-color, var(--primary));
}
.board-summary-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.board-summary-icon {
    width: 40px; height: 40px;
    background: var(--board-color, var(--primary));
    color: white;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.board-summary-title {
    font-size: 16px;
    font-weight: 700;
}
.board-summary-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
}
.board-summary-modules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.board-module-mini {
    background: var(--bg);
    padding: 10px;
    border-radius: var(--radius);
    font-size: 12px;
}
.board-module-mini .name { font-weight: 600; }
.board-module-mini .count { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.recent-records {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.recent-records-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 13px;
    transition: background 0.2s;
    cursor: pointer;
}
.recent-item:hover { background: var(--bg-hover); }
.recent-item-icon { font-size: 16px; }
.recent-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item-meta { font-size: 11px; color: var(--text-tertiary); }

/* ========== 按钮 ========== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow); }
.btn-ghost { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--primary); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
}
.btn-text:hover { background: var(--primary-soft); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ========== 子工作台 ========== */
.board-container {
    max-width: 1400px;
    margin: 0 auto;
}
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}
.board-info { flex: 1; min-width: 0; }
.board-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.board-title-icon {
    width: 36px; height: 36px;
    background: var(--board-color);
    color: white;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.board-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}
.board-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.module-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.module-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.2s;
    margin-bottom: -1px;
}
.module-tab:hover { color: var(--text); }
.module-tab.active {
    color: var(--board-color);
    border-bottom-color: var(--board-color);
    font-weight: 600;
}
.module-tab .badge {
    background: var(--bg-hover);
    color: var(--text-tertiary);
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    margin-left: 6px;
    font-weight: 600;
}
.module-tab.active .badge {
    background: var(--board-color);
    color: white;
}

/* ========== 数据表格 ========== */
.data-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.data-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 12px;
}
.data-table-search {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 360px;
}
.data-table-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg);
    transition: all 0.2s;
}
.data-table-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-light);
}
.data-table-wrap {
    overflow-x: auto;
    max-width: 100%;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    background: var(--bg);
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.data-table tbody tr { transition: background 0.2s; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-progress { width: 140px; }
.data-table .col-actions { width: 100px; text-align: right; }
.data-table .col-priority { width: 80px; }
.data-table .col-status { width: 100px; }

.progress-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.progress-track {
    flex: 1;
    height: 6px;
    background: var(--border-light);
    border-radius: 999px;
    overflow: hidden;
    min-width: 60px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #6366f1);
    transition: width 0.4s;
    border-radius: 999px;
}
.progress-fill.done { background: var(--success); }
.progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: right;
}

.badge-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-pill.priority-urgent { background: #fee2e2; color: #b91c1c; }
.badge-pill.priority-high { background: #ffedd5; color: #c2410c; }
.badge-pill.priority-normal { background: var(--primary-light); color: var(--primary); }
.badge-pill.priority-low { background: var(--bg-hover); color: var(--text-secondary); }
.badge-pill.status-active { background: var(--primary-light); color: var(--primary); }
.badge-pill.status-done { background: var(--success-light); color: var(--success); }
.badge-pill.status-archived { background: var(--bg-hover); color: var(--text-tertiary); }

.row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}
.row-action-btn {
    width: 28px; height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-tertiary);
    transition: all 0.2s;
}
.row-action-btn:hover { background: var(--bg-hover); color: var(--primary); }
.row-action-btn.danger:hover { background: var(--danger-light); color: var(--danger); }

/* ========== 移动端：卡片视图 ========== */
.mobile-cards {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 16px;
}
.mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.mobile-card-title {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    min-width: 0;
}
.mobile-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.mobile-card-meta-item {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 999px;
}
.mobile-card-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.mobile-card-progress .progress-track { flex: 1; }
.mobile-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}
.mobile-card-actions .btn { flex: 1; justify-content: center; }

/* ========== 空状态 ========== */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-tertiary);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.empty-title {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.empty-desc {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ========== 模态框 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    display: none;
    backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    width: 32px; height: 32px;
    font-size: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.2s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

/* 身份验证模态框 */
.auth-modal { max-width: 440px; }
.auth-hint {
    background: var(--primary-soft);
    color: var(--primary-hover);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 16px;
    border-left: 3px solid var(--primary);
}
.auth-field { margin-bottom: 14px; }
.auth-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: all 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.auth-error {
    color: var(--danger);
    font-size: 12px;
    margin: 8px 0;
    min-height: 18px;
}
.auth-actions {
    margin-top: 16px;
}
.auth-admin {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-light);
}
.auth-admin summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px 0;
    font-weight: 500;
}
.auth-admin summary:hover { color: var(--primary); }

/* 编辑器模态框 */
.editor-modal { max-width: 720px; }
.editor-form {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, 1fr);
}
.editor-form .full-width { grid-column: 1 / -1; }
.editor-form .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.editor-form .form-group input,
.editor-form .form-group select,
.editor-form .form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: white;
    transition: all 0.2s;
}
.editor-form .form-group input:focus,
.editor-form .form-group select:focus,
.editor-form .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.editor-form textarea { resize: vertical; min-height: 60px; }
.editor-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border-light);
    grid-column: 1 / -1;
}

/* ========== 通知面板 ========== */
.notif-panel {
    position: fixed;
    top: calc(var(--topbar-h) + 8px);
    right: 12px;
    width: 360px;
    max-height: calc(100vh - var(--topbar-h) - 100px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    flex-direction: column;
}
.notif-panel.open { display: flex; animation: fadeIn 0.2s; }
.notif-panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-panel-header h3 { font-size: 14px; font-weight: 700; }
.notif-panel-header > div { display: flex; gap: 4px; align-items: center; }
.notif-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: 60vh;
}
.notif-panel-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    background: var(--bg);
}

.notif-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 4px;
    transition: background 0.2s;
    cursor: pointer;
    border-left: 3px solid var(--info);
    position: relative;
}
.notif-item:hover { background: var(--bg); }
.notif-item.record { border-left-color: var(--primary); }
.notif-item.file { border-left-color: var(--success); }
.notif-item.checkin { border-left-color: var(--warning); }
.notif-item.system { border-left-color: var(--info); }
.notif-item.unread { background: var(--primary-soft); }
.notif-text {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.4;
    padding-right: 24px;
}
.notif-meta {
    font-size: 11px;
    color: var(--text-tertiary);
}
.notif-close-item {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px; height: 20px;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
}
.notif-close-item:hover { background: var(--bg-hover); color: var(--danger); }

/* ========== Toast 提示 ========== */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--text);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ========== 共享资料库 ========== */
.shared-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 16px 0;
}
.shared-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}
.shared-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.shared-icon {
    width: 48px; height: 48px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}
.shared-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}
.shared-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 8px;
}
.shared-actions {
    margin-top: 12px;
    display: flex;
    gap: 6px;
}
.shared-actions .btn { flex: 1; justify-content: center; }

/* ========== 成员管理 ========== */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.member-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    text-align: center;
    transition: all 0.2s;
}
.member-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.member-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin: 0 auto 12px;
}
.member-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}
.member-role {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}
.member-position {
    font-size: 13px;
    color: var(--text-secondary);
}
.member-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
}

/* ========== BOM 配方编辑器 ========== */
.bom-editor { }
.bom-header { margin-bottom: 12px; }
.bom-row {
    display: grid;
    grid-template-columns: 1.5fr 0.7fr 0.8fr 0.8fr 1.2fr 36px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.bom-row .form-input { padding: 8px 10px; font-size: 13px; }
@media (max-width: 768px) {
    .bom-row { grid-template-columns: 1fr 1fr; }
}

/* ========== 任务卡片 ========== */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: all 0.2s;
}
.task-card:hover { box-shadow: var(--shadow-md); }
.task-card.overdue { border-left: 4px solid var(--danger); }
.task-title { font-weight: 600; font-size: 14px; }
.task-title.done { text-decoration: line-through; opacity: 0.6; }
.task-meta {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 6px; font-size: 12px;
}
.overdue-text { color: var(--danger); font-weight: 600; }
.my-tasks { max-width: 900px; margin: 0 auto; }

/* ========== 评论 ========== */
.comment-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.comment-item:last-child { border-bottom: none; }
.comment-head {
    display: flex; justify-content: space-between; margin-bottom: 4px;
}
.comment-body { font-size: 13px; color: var(--text-secondary); white-space: pre-wrap; word-break: break-word; }
.comment-mentions {
    margin-top: 6px; font-size: 12px; color: var(--primary);
    background: var(--primary-light); padding: 4px 8px; border-radius: 4px; display: inline-block;
}

/* ========== 周报月报 ========== */
.report-content table { font-size: 13px; }
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}
.report-table th, .report-table td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
}
.report-table th {
    background: #f8fafc;
    font-weight: 600;
}
.report-table tr:nth-child(even) { background: #fafbfc; }
.mini-progress {
    display: inline-block;
    width: 80px; height: 6px;
    background: #f1f5f9;
    border-radius: 999px;
    vertical-align: middle;
    margin-right: 6px;
}
.mini-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #6366f1);
    border-radius: 999px;
}

/* ========== 侧边栏管理链接 ========== */
.sidebar-admin-links {
    padding: 8px 16px;
    border-top: 1px solid var(--border-light);
    display: flex; flex-direction: column;
    gap: 6px;
}
.sidebar-admin-links a {
    font-size: 11px;
    color: var(--text-tertiary);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
}
.sidebar-admin-links a:hover { background: var(--bg-hover); color: var(--primary); }

/* ========== 甘特图 ========== */
.gantt-page { max-width: 100%; overflow-x: auto; }
.gantt-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; min-width: 800px; }
.gantt-header, .gantt-row {
    display: grid;
    border-bottom: 1px solid var(--border-light);
}
.gantt-header {
    background: var(--bg);
    font-weight: 600;
    font-size: 12px;
}
.gantt-cell-head, .gantt-row-label {
    padding: 12px 14px;
    border-right: 1px solid var(--border-light);
}
.gantt-cell-head { color: var(--text-secondary); }
.gantt-timeline { display: flex; padding: 12px 14px; gap: 0; overflow: hidden; }
.gantt-month {
    flex: 1;
    text-align: center;
    border-right: 1px dashed var(--border-light);
    color: var(--text-secondary);
}
.gantt-month:last-child { border-right: none; }
.gantt-row-label { background: var(--bg-card); }
.gantt-row-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.gantt-row-meta { font-size: 11px; color: var(--text-tertiary); display: flex; flex-direction: column; gap: 2px; }
.gantt-bar-area {
    position: relative;
    padding: 12px 0;
    background: linear-gradient(to right, transparent, transparent 4.16%, var(--border-light) 4.16%, var(--border-light) 4.2%, transparent 4.2%);
    background-size: calc(100% / 12) 100%;
}
.gantt-bar {
    position: absolute;
    height: 28px;
    background: var(--primary);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.gantt-bar.overdue { border: 2px solid var(--danger); }
.gantt-bar.done { background: var(--success); }
.gantt-bar-progress {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: rgba(255,255,255,0.3);
}
.gantt-bar-label {
    position: relative;
    display: block;
    text-align: center;
    color: white;
    font-size: 11px;
    font-weight: 600;
    line-height: 28px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.gantt-today-line {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--danger);
    z-index: 5;
}
.gantt-today-line::after {
    content: '今';
    position: absolute;
    top: -2px;
    left: -6px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ========== 调试面板 ========== */
#devPanel {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.85);
    color: white;
    border-radius: var(--radius);
    font-size: 11px;
    z-index: 9999;
    font-family: ui-monospace, monospace;
}
.dev-header {
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 700;
}
.dev-body { padding: 8px 12px; }
.dev-body > div { padding: 2px 0; }

/* ========== 响应式：手机端 ========== */
@media (max-width: 1024px) {
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .topbar-title { display: none; }
    .global-search { display: none; }
    .search-panel { width: auto; left: 8px; right: 8px; }

    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { z-index: 999; }

    .main-content {
        left: 0;
        bottom: var(--bottom-nav-h);
        padding: 16px;
        padding-bottom: 80px;
    }

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: var(--bottom-nav-h);
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        z-index: 90;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
        overflow-x: auto;
    }
    .mobile-nav-item {
        flex: 1;
        min-width: 60px;
        background: none;
        border: none;
        padding: 8px 4px;
        cursor: pointer;
        color: var(--text-tertiary);
        font-family: inherit;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 11px;
        transition: color 0.2s;
    }
    .mobile-nav-item .icon { font-size: 18px; }
    .mobile-nav-item.active { color: var(--primary); }
    .mobile-nav-item.active .icon { transform: scale(1.1); }

    .user-name { display: none; }
    .user-badge { padding: 4px; }

    .data-table-wrap { display: none; }
    .mobile-cards { display: flex; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .stat-icon { font-size: 20px; }

    .dashboard-title { font-size: 18px; }
    .board-title { font-size: 18px; }

    .modal { max-width: 100%; max-height: 95vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; }
    .modal-overlay { align-items: flex-end; padding: 0; }

    .notif-panel { right: 8px; left: 8px; width: auto; }

    .editor-form { grid-template-columns: 1fr; }
    .editor-form .full-width { grid-column: 1; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar { padding: 0 12px; }
    .logo-text { display: none; }
    .sync-badge { display: none; }
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-tertiary); }
.text-sm { font-size: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }