/* ======= Reset & Base ======= */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--gray-50); color: var(--gray-900); min-height: 100vh; }
.hidden { display: none !important; }

/* ======= Login ======= */
#login-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
#login-box { background: #fff; border-radius: 16px; padding: 36px; width: 400px; max-width: 92vw; box-shadow: var(--shadow-lg); }
#login-box h2 { margin-bottom: 8px; text-align: center; color: var(--primary); font-size: 20px; }
#login-box .subtitle { font-size: 13px; color: var(--gray-500); text-align: center; margin-bottom: 24px; }
#login-box input { width: 100%; padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; transition: border-color 0.2s; }
#login-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
#login-error { color: var(--danger); font-size: 13px; text-align: center; margin-bottom: 8px; }
.auth-toggle { text-align: center; margin-top: 14px; font-size: 13px; color: var(--gray-500); }
.auth-toggle a { color: var(--primary); cursor: pointer; font-weight: 600; text-decoration: none; }
.auth-toggle a:hover { text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* ======= Buttons ======= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px dashed var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ======= App Layout ======= */
#app { display: flex; min-height: 100vh; }

#sidebar { width: 240px; background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform 0.3s ease; }
#sidebar .brand { padding: 20px 20px 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
#sidebar .brand span { font-size: 18px; font-weight: 700; display: block; }
#sidebar .brand small { font-size: 11px; opacity: 0.7; display: block; margin-top: 2px; }
#sidebar nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-item { padding: 10px 20px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 10px; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: rgba(255,255,255,0.12); border-left-color: #fff; font-weight: 600; }
.nav-home { padding: 10px 20px; font-size: 13px; display: flex; align-items: center; gap: 10px; border-left: 3px solid transparent; transition: all 0.15s; text-decoration: none; color: #fff; }
.nav-home:hover { background: rgba(255,255,255,0.08); }
.nav-home .nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-item .nav-badge { margin-left: auto; background: rgba(255,255,255,0.15); padding: 1px 8px; border-radius: 10px; font-size: 11px; }
#sidebar .user-info { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 12px; }
#sidebar .user-info .email { display: block; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sidebar .user-info a { color: rgba(255,255,255,0.6); cursor: pointer; text-decoration: underline; font-size: 11px; }
#sidebar .user-info a:hover { color: #fff; }

#main { flex: 1; margin-left: 240px; padding: 24px; min-height: 100vh; }
#hamburger { display: none; position: fixed; top: 10px; left: 10px; z-index: 101; background: var(--primary); color: #fff; border: none; border-radius: 8px; width: 40px; height: 40px; font-size: 20px; cursor: pointer; align-items: center; justify-content: center; }
#sidebar-overlay { display: none; }

/* ======= Panels ======= */
.panel { display: none; }
.panel.active { display: block; }
.panel h1 { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.panel .subtitle { color: var(--gray-500); font-size: 13px; margin-bottom: 20px; }

/* ======= Stats Bar ======= */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.stat-card .stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat-card .stat-change { font-size: 12px; margin-top: 2px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ======= Cards ======= */
.card { background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-header { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }

/* ======= Top Bar ======= */
.top-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.top-bar > h1 { margin-bottom: 0; }
.search-input { flex: 1; min-width: 180px; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; }
.search-input:focus { outline: none; border-color: var(--primary); }
.filter-select { padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; background: #fff; }

/* ======= Project Grid ======= */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.project-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow 0.2s, transform 0.2s; position: relative; }
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.project-card .project-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.project-card .project-desc { font-size: 13px; color: var(--gray-500); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-card .project-meta { display: flex; gap: 12px; font-size: 12px; color: var(--gray-500); flex-wrap: wrap; }
.project-card .project-meta span { display: flex; align-items: center; gap: 4px; }
.project-card .project-status { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.status-active { background: #d1fae5; color: #065f46; }
.status-on_hold { background: #fef3c7; color: #92400e; }
.status-completed { background: #dbeafe; color: #1e40af; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.priority-high { border-left: 3px solid var(--danger); }
.priority-medium { border-left: 3px solid var(--warning); }
.priority-low { border-left: 3px solid var(--success); }
.priority-critical { border-left: 3px solid #7c3aed; }
.project-card .card-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.project-card:hover .card-actions { opacity: 1; }
.card-actions .btn { padding: 4px 8px; font-size: 11px; border-radius: 6px; }

/* ======= Tasks ======= */
.task-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.task-column { background: var(--gray-100); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.task-column h3 { font-size: 13px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 2px solid var(--gray-200); }
.task-card { background: #fff; border-radius: 8px; padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); cursor: pointer; transition: box-shadow 0.15s; }
.task-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.task-card .task-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.task-card .task-meta { display: flex; gap: 8px; font-size: 11px; color: var(--gray-500); align-items: center; }
.task-card .task-priority { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pri-critical { background: #7c3aed; }
.pri-high { background: var(--danger); }
.pri-medium { background: var(--warning); }
.pri-low { background: var(--success); }
.task-assignee { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; font-weight: 600; margin-left: auto; }

/* ======= Modal ======= */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; z-index: 200; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 580px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; margin-top: 12px; }
.modal input:not([type="checkbox"]):not([type="radio"]), .modal select, .modal textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; }
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.modal textarea { min-height: 80px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ======= Comments ======= */
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.comment-item:last-child { border-bottom: none; }
.comment-item .comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-item .comment-author { font-size: 13px; font-weight: 600; }
.comment-item .comment-time { font-size: 11px; color: var(--gray-500); }
.comment-item .comment-text { font-size: 13px; color: var(--gray-700); }
.add-comment { display: flex; gap: 8px; margin-top: 12px; }
.add-comment textarea { flex: 1; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 13px; resize: none; min-height: 40px; }

/* ======= Timeline/Milestones ======= */
.timeline { position: relative; padding: 8px 0; }
.timeline::before { content: ''; position: absolute; left: 12px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; padding: 8px 0 16px 36px; }
.timeline-item::before { content: ''; position: absolute; left: 6px; top: 12px; width: 14px; height: 14px; border-radius: 50%; background: var(--gray-300); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--gray-300); }
.timeline-item.completed::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.in_progress::before { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.timeline-item.delayed::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.timeline-item .tl-title { font-weight: 600; font-size: 14px; }
.timeline-item .tl-date { font-size: 12px; color: var(--gray-500); }
.timeline-item .tl-desc { font-size: 13px; color: var(--gray-700); margin-top: 2px; }

/* ======= Gantt (simplified) ======= */
.gantt-wrap { overflow-x: auto; }
.gantt-chart { min-width: 600px; }
.gantt-row { display: flex; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--gray-100); }
.gantt-row .gantt-label { width: 200px; font-size: 12px; font-weight: 500; flex-shrink: 0; padding-right: 12px; }
.gantt-row .gantt-bar-wrap { flex: 1; height: 24px; background: var(--gray-100); border-radius: 4px; position: relative; }
.gantt-row .gantt-bar { height: 24px; border-radius: 4px; position: absolute; top: 0; min-width: 4px; }
.gantt-bar.todo { background: var(--gray-300); }
.gantt-bar.in_progress { background: var(--primary); }
.gantt-bar.review { background: var(--warning); }
.gantt-bar.done { background: var(--success); }
.gantt-header { display: flex; font-size: 11px; color: var(--gray-500); margin-bottom: 4px; }
.gantt-header .gantt-label-h { width: 200px; flex-shrink: 0; padding-right: 12px; }

/* ======= Risks ======= */
.risk-item { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--gray-100); gap: 10px; }
.risk-item:last-child { border-bottom: none; }
.risk-severity { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.sev-critical { background: #f3e8ff; color: #6b21a8; }
.sev-high { background: #fee2e2; color: #991b1b; }
.sev-medium { background: #fef3c7; color: #92400e; }
.sev-low { background: #d1fae5; color: #065f46; }

/* ======= Budget ======= */
.budget-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.budget-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }

/* ======= Notifications ======= */
.notif-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--gray-100); align-items: flex-start; }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-icon { font-size: 18px; }
.notif-item .notif-content { flex: 1; }
.notif-item .notif-title { font-size: 13px; font-weight: 600; }
.notif-item .notif-msg { font-size: 12px; color: var(--gray-500); }
.notif-item .notif-time { font-size: 11px; color: var(--gray-300); }

/* ======= Tabs ======= */
.tab-bar { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--gray-200); overflow-x: auto; }
.tab { padding: 8px 20px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: all 0.15s; }
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ======= Status Badge ======= */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-todo { background: var(--gray-200); color: var(--gray-700); }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-review { background: #fef3c7; color: #92400e; }
.badge-done { background: #d1fae5; color: #065f46; }

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

/* ======= Responsive ======= */
@media (max-width: 768px) {
  #hamburger { display: flex; }
  #app { padding-top: 0; }
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #sidebar.open + #sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
  #main { margin-left: 0; padding: 12px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .project-grid { grid-template-columns: 1fr; }
  .task-board { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: 20px; }
  .top-bar { gap: 6px; }
  .top-bar > h1 { font-size: 18px; }
  .search-input { min-width: 120px; font-size: 13px; }
  .modal { padding: 16px; width: 95vw; }
  .panel h1 { font-size: 18px; }
  .nav-item { padding: 8px 16px; font-size: 13px; }
  .project-card .card-actions { opacity: 1; }
}
