/* ===== CSS Variables ===== */
:root {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --bg-sidebar-hover: #334155;
  --bg-sidebar-active: #3b82f6;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --primary: #3b82f6;
  --primary-light: #dbeafe;
  --primary-dark: #2563eb;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --teal: #14b8a6;
  --teal-light: #ccfbf1;
  --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.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --transition: all 0.2s ease;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  overflow: hidden;
}
a { cursor: pointer; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.3s ease;
  z-index: 100;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 18px;
  font-weight: 700;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-sidebar);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: white; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.stat-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-mini-label { font-size: 12px; color: var(--text-light); }
.stat-mini-value { font-size: 24px; font-weight: 700; color: white; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
  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 24px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.menu-toggle { display: none; color: var(--text-secondary); }
.page-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 320px;
  color: var(--text-light);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search-box input { border: none; background: none; outline: none; flex: 1; font-size: 13px; color: var(--text-primary); }
.date-display {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* ===== View Container ===== */
.view-container { flex: 1; overflow-y: auto; padding: 24px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Stat Cards ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-info { flex: 1; }
.stat-card-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-card-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-card-trend { font-size: 12px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.stat-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.card-chart { min-height: 320px; }
.chart-wrap { height: 240px; position: relative; }

/* ===== Dashboard Grid ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dashboard-grid.two-col { grid-template-columns: 1fr 1fr; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-purple { background: var(--purple-light); color: #6d28d9; }
.badge-teal { background: var(--teal-light); color: #115e59; }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-icon { padding: 6px; border-radius: var(--radius-xs); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
.data-table tr:hover td { background: var(--border-light); }
.data-table .actions { display: flex; gap: 6px; }

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100px;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ===== Deadline List ===== */
.deadline-list { display: flex; flex-direction: column; gap: 10px; }
.deadline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  transition: var(--transition);
}
.deadline-item:hover { box-shadow: var(--shadow-sm); }
.deadline-item.urgent { border-left-color: var(--danger); }
.deadline-item.warning { border-left-color: var(--warning); }
.deadline-item.done { border-left-color: var(--success); opacity: 0.6; }
.deadline-info { flex: 1; }
.deadline-title { font-weight: 600; font-size: 13px; }
.deadline-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.deadline-date { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.deadline-date.urgent { color: var(--danger); }

/* ===== Activity List ===== */
.activity-list { display: flex; flex-direction: column; gap: 12px; }
.activity-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 6px;
}
.activity-content { flex: 1; }
.activity-text { font-size: 13px; }
.activity-time { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ===== View Toolbar ===== */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.view-tabs { display: flex; gap: 4px; background: var(--bg-card); padding: 4px; border-radius: var(--radius-sm); }
.tab {
  padding: 6px 16px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}
.tab.active { background: var(--primary); color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Filter Chips ===== */
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Kanban ===== */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column {
  min-width: 280px;
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
}
.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}
.kanban-column-count {
  background: var(--border-light);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}
.kanban-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kanban-card-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.kanban-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.kanban-card-progress { margin-top: 8px; }

/* ===== Task List ===== */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.task-item:hover { box-shadow: var(--shadow); }
.task-item.done { opacity: 0.55; }
.task-item.done .task-title { text-decoration: line-through; }
.task-checkbox {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.task-checkbox.checked { background: var(--success); border-color: var(--success); }
.task-checkbox.checked svg { display: block; }
.task-checkbox svg { display: none; }
.task-content { flex: 1; }
.task-title { font-weight: 600; font-size: 14px; }
.task-meta { display: flex; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--text-secondary); }
.task-priority {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
}
.priority-high { background: var(--danger); }
.priority-medium { background: var(--warning); }
.priority-low { background: var(--success); }
.task-actions { display: flex; gap: 6px; }

/* ===== Knowledge Grid ===== */
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.knowledge-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  border-top: 3px solid var(--primary);
}
.knowledge-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.knowledge-card-category { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.knowledge-card-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.knowledge-card-summary { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.knowledge-card-footer { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-light); }
.knowledge-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.knowledge-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--border-light);
  color: var(--text-secondary);
}

/* ===== Ideas ===== */
.idea-input-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.idea-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  resize: vertical;
  outline: none;
  transition: var(--transition);
}
.idea-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.idea-input-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}
.idea-tags-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}
.idea-tags-input:focus { border-color: var(--primary); }
.ideas-timeline { display: flex; flex-direction: column; gap: 12px; }
.idea-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 16px;
  transition: var(--transition);
  border-left: 3px solid var(--purple);
}
.idea-card:hover { box-shadow: var(--shadow); }
.idea-date-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 50px;
}
.idea-day { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.idea-month { font-size: 12px; color: var(--text-secondary); }
.idea-body { flex: 1; }
.idea-content { font-size: 14px; line-height: 1.7; margin-bottom: 8px; }
.idea-footer { display: flex; align-items: center; justify-content: space-between; }
.idea-tag {
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--purple-light);
  color: #6d28d9;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { font-size: 24px; color: var(--text-secondary); line-height: 1; }
.modal-body { padding: 20px; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
  background: white;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 16px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text-primary);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state svg { margin: 0 auto 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .search-box { width: 200px; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; }
  .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
  .menu-toggle { display: block; }
  .search-box { width: 160px; }
  .date-display { display: none; }
  .view-container { padding: 16px; }
  .form-row { flex-direction: column; }
}
