/* TaskFlow Design System */
:root {
  --color-primary: #1a73e8;
  --color-primary-light: #e8f0fe;
  --color-bg: #f5f7fa;
  --color-bg-white: #ffffff;
  --color-text: #333333;
  --color-text-secondary: #666666;
  --color-success: #34a853;
  --color-warning: #fbbc04;
  --color-danger: #ea4335;
  --color-info: #4285f4;
  --color-border: #e0e0e0;
  --color-skeleton: #e0e0e0;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08);
  --radius-card: 8px;
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-family); background: var(--color-bg); color: var(--color-text); font-size: 14px; line-height: 1.6; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: #1e293b; color: #fff; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-logo { padding: 16px 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo span { color: var(--color-primary); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 14px; transition: all 0.2s; cursor: pointer; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: rgba(255,255,255,0.08); }
.sidebar-nav a .badge { margin-left: auto; background: var(--color-danger); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 10px; }
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar { height: var(--topbar-height); background: #fff; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left .menu-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; padding: 4px; }
.topbar-left select { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right select { padding: 6px 12px; border: 1px solid var(--color-border); border-radius: 6px; font-size: 13px; max-width: 300px; }
.toolbar-group { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; position: relative; padding: 4px 8px; border-radius: 6px; }
.btn-icon:hover { background: var(--color-bg); }
.btn-icon .badge { position: absolute; top: 0; right: 2px; background: var(--color-danger); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 10px; }
.user-menu { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.user-menu:hover { background: var(--color-bg); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }

/* Content */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

/* Cards */
.card { background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 20px; text-align: center; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 13px; color: var(--color-text-secondary); margin-top: 4px; }
.stat-card.stat-success .stat-value { color: var(--color-success); }
.stat-card.stat-warning .stat-value { color: var(--color-warning); }
.stat-card.stat-danger .stat-value { color: var(--color-danger); }
.stat-card.stat-info .stat-value { color: var(--color-info); }

/* Status color bars on cards */
.task-card { display: flex; align-items: stretch; background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); margin-bottom: 12px; overflow: hidden; }
.task-card-bar { width: 4px; flex-shrink: 0; }
.task-card-bar.bar-success { background: var(--color-success); }
.task-card-bar.bar-info { background: var(--color-info); }
.task-card-bar.bar-warning { background: var(--color-warning); }
.task-card-bar.bar-danger { background: var(--color-danger); }
.task-card-body { flex: 1; padding: 16px; }
.task-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.task-card-title { font-size: 15px; font-weight: 600; }
.task-card-title .status-tag { display: inline; font-size: 12px; padding: 1px 6px; border-radius: 4px; margin-right: 6px; font-weight: 500; }
.status-tag.tag-success { background: #e6f4ea; color: var(--color-success); }
.status-tag.tag-info { background: #e8f0fe; color: var(--color-info); }
.status-tag.tag-warning { background: #fef7e0; color: #b06000; }
.status-tag.tag-danger { background: #fce8e6; color: var(--color-danger); }
.task-card-meta { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 8px; display: flex; gap: 16px; flex-wrap: wrap; }
.task-card-progress { margin-bottom: 8px; }
.progress-bar { height: 6px; border-radius: 3px; background: #eee; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.progress-fill.fill-info { background: var(--color-info); }
.progress-fill.fill-success { background: var(--color-success); }
.progress-fill.fill-warning { background: var(--color-warning); }
.progress-fill.fill-danger { background: var(--color-danger); }
.task-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1557b0; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #2d9249; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d33426; }
.btn-outline { background: #fff; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn-outline:hover:not(:disabled) { background: var(--color-primary-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-group { display: flex; gap: 8px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--color-text-secondary); }
.form-group label .required { color: var(--color-danger); margin-left: 2px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 6px; font-size: 14px; font-family: inherit; transition: border-color 0.2s; }
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-error { color: var(--color-danger); font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.form-success { color: var(--color-success); font-size: 13px; margin-bottom: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--color-border); font-size: 13px; }
th { background: var(--color-bg); font-weight: 600; color: var(--color-text-secondary); position: sticky; top: 0; }
tr:hover { background: #fafbfc; }

/* Modal / Drawer */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-sm { background: #fff; border-radius: 12px; width: 400px; max-width: 95vw; max-height: 85vh; overflow-y: auto; padding: 24px; }
.modal-md { background: #fff; border-radius: 12px; width: 550px; max-width: 95vw; max-height: 85vh; overflow-y: auto; padding: 24px; }
.modal-lg { background: #fff; border-radius: 12px; width: 70%; max-width: 900px; max-height: 85vh; overflow-y: auto; padding: 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 90vw; background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,0.1); z-index: 100; padding: 24px; overflow-y: auto; }
.drawer-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); z-index: 99; }

/* Bottom sheet (mobile) */
@media (max-width: 768px) {
  .modal-sm { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; position: fixed; bottom: 0; left: 0; right: 0; top: auto; max-height: 50vh; }
  .modal-lg { width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  .drawer { width: 100%; max-width: 100%; }
}

/* Notifications panel */
.notif-panel { position: absolute; top: var(--topbar-height); right: 60px; width: 360px; max-height: 70vh; background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.12); z-index: 50; overflow-y: auto; }
.notif-panel-header { padding: 16px; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.notif-group { padding: 8px 16px; }
.notif-group-label { font-size: 12px; color: var(--color-text-secondary); font-weight: 600; padding: 8px 0; }
.notif-item { padding: 10px 0; border-bottom: 1px solid #f0f0f0; cursor: pointer; font-size: 13px; }
.notif-item:hover { color: var(--color-primary); }
.notif-item .time { font-size: 11px; color: var(--color-text-secondary); }
.notif-item.unread { font-weight: 600; }
.notif-panel-footer { padding: 12px 16px; text-align: center; border-top: 1px solid var(--color-border); }
.notif-panel-footer a { color: var(--color-primary); font-size: 13px; text-decoration: none; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a73e8 0%, #4285f4 60%, #8ab4f8 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 380px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 24px; }
.login-card h1 span { color: var(--color-primary); }
.login-card .subtitle { text-align: center; color: var(--color-text-secondary); margin-bottom: 32px; font-size: 14px; }

/* Skeleton */
.skeleton { background: var(--color-skeleton); border-radius: 4px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.8; } }
.skeleton-title { height: 18px; width: 60%; margin-bottom: 8px; }
.skeleton-text { height: 14px; width: 80%; margin-bottom: 6px; }
.skeleton-text.short { width: 50%; }

/* Empty states — 4 variants */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h4 { font-size: 16px; color: var(--color-text); margin-bottom: 8px; }
.empty-state p { color: var(--color-text-secondary); font-size: 14px; margin-bottom: 16px; }
.empty-state.empty-success { background: #f6fef6; border: 1px dashed var(--color-success); border-radius: 12px; }
.empty-state.empty-warning { background: #fffdf0; border: 1px dashed var(--color-warning); border-radius: 12px; }
.empty-state.empty-info { background: #f8faff; border: 1px dashed var(--color-info); border-radius: 12px; }
.empty-state.empty-danger { background: #fff5f5; border: 1px dashed var(--color-danger); border-radius: 12px; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 32px; color: var(--color-text-secondary); }
.spinner { width: 24px; height: 24px; border: 3px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tags & Labels */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-green { background: #e6f4ea; color: #1e7e34; }
.tag-blue { background: #e8f0fe; color: #1a5dc4; }
.tag-orange { background: #fef7e0; color: #b06000; }
.tag-red { background: #fce8e6; color: #c62828; }
.tag-gray { background: #f1f3f4; color: #5f6368; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 14px; z-index: 200; animation: slideUp 0.3s ease; max-width: 360px; }
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-info { background: var(--color-primary); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* WBS Tree */
.wbs-tree { padding-left: 0; }
.wbs-tree-item { margin-bottom: 4px; }
.wbs-tree-toggle { cursor: pointer; display: inline-block; width: 20px; font-size: 12px; }
.wbs-tree-children { padding-left: 24px; }
.wbs-node-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.wbs-node-row:hover { background: var(--color-bg); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; }
.tab { padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--color-text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -100%; top: 0; bottom: 0; z-index: 90; transition: left 0.3s ease; }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 89; display: none; }
  .sidebar.open + .sidebar-overlay { display: block; }
  .topbar-left .menu-toggle { display: block; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .content { padding: 16px; }
  .modal-sm, .modal-md { border-radius: 16px 16px 0 0; bottom: 0; top: auto; left: 0; right: 0; position: fixed; max-height: 60vh; }
  .modal-lg { width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  /* Mobile table-to-card */
  .table-card-mode table, .table-card-mode thead, .table-card-mode tbody, .table-card-mode th, .table-card-mode td, .table-card-mode tr { display: block; }
  .table-card-mode thead { display: none; }
  .table-card-mode td { padding: 6px 14px; text-align: right; position: relative; border-bottom: none; }
  .table-card-mode td::before { content: attr(data-label); float: left; font-weight: 600; color: var(--color-text-secondary); }
  .table-card-mode tr { margin-bottom: 12px; background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 4px 0; }
  .wbs-breadcrumb { font-size: 12px; padding: 8px 0; color: var(--color-text-secondary); }
  .wbs-breadcrumb a { color: var(--color-primary); cursor: pointer; }
  .notif-panel { width: 100%; max-width: 100%; right: 0; top: var(--topbar-height); border-radius: 0 0 12px 12px; }
}

/* Utility */
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-info { color: var(--color-info); }
.text-muted { color: var(--color-text-secondary); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* Help & config */
.help-box {
  background: var(--color-primary-light); border: 1px solid var(--color-primary);
  border-radius: var(--radius-card); padding: 12px 16px; margin-bottom: 20px; font-size: 13px;
}
.help-box ul { margin-bottom: 0; }
.field-hint { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 4px; }
.config-field { margin-bottom: 12px; }

/* Password eye toggle */
.input-eye-wrap { position: relative; display: flex; align-items: center; }
.input-eye-wrap .form-control { padding-right: 40px; }
.eye-toggle { position: absolute; right: 10px; cursor: pointer; font-size: 18px; user-select: none; }

/* ═══════════ WCAG 2.1 AA Accessibility ═══════════ */
*:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 2px; }
.btn:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }
a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip-link { position: absolute; top: -100px; left: 12px; background: var(--color-primary); color: #fff; padding: 8px 16px; border-radius: 0 0 6px 6px; z-index: 200; font-size: 14px; text-decoration: none; }
.skip-link:focus { top: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.form-control[readonly] { background: #f5f5f5; cursor: default; opacity: 0.8; }

/* ═══════════ Notification Badge Grading ═══════════ */
.btn-icon .badge.badge-critical { background: #d32f2f; animation: pulse-badge 1.5s ease-in-out infinite; }
.btn-icon .badge.badge-warning { background: #ed6c02; }
.btn-icon .badge.badge-info { background: var(--color-info); }
@keyframes pulse-badge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ═══════════ Right-side action bar (desktop) ═══════════ */
.action-bar { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 768px) {
  .action-bar { flex-wrap: wrap; justify-content: flex-end; }
}

/* ═══════════ Chart placeholders ═══════════ */
.chart-placeholder { width: 100%; height: 200px; background: #f0f4f8; border-radius: var(--radius-card); display: flex; align-items: center; justify-content: center; color: var(--color-text-secondary); font-size: 13px; }

/* ═══════════ Notification settings toggles ═══════════ */
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; }
.setting-desc { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 24px; transition: 0.3s; }
.toggle-slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 3px solid var(--color-primary); outline-offset: 2px; }

/* 批量操作模式 */
body.batch-mode .batch-cb { display: inline-block !important; }
body.batch-mode .task-card { cursor: pointer; }
body.batch-mode .task-card:hover { background: #f0f7ff; }
#batch-action-bar { display: flex; }

/* 全景看板双栏布局 */
.overview-charts-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.overview-charts-row > .card { margin-bottom: 0; }
@media (max-width: 768px) {
  .overview-charts-row { flex-direction: column; }
  .overview-charts-row > .card { min-width: unset !important; }
}

/* 侧边栏分隔线 */
.sidebar-sep { height: 1px; background: #e2e8f0; margin: 8px 0; }
.sidebar-action { display: block; padding: 8px 16px; font-size: 13px; color: var(--color-text-secondary); cursor: pointer; text-decoration: none; transition: background .15s; }
.sidebar-action:hover { background: #f0f7ff; color: var(--color-primary); }


/* 模态框内TAB切换 */
.modal-tabs { display: flex; gap: 0; }
.modal-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.modal-tab:hover { color: var(--color-primary); }
.modal-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

