:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1c2028;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --text-muted: #9aa1ad;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

.boot-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; color: var(--text-muted); font-size: 14px;
}

a { color: var(--accent); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

button {
  cursor: pointer;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06210f;
  font-weight: 600;
}
button.primary:hover { background: var(--accent-dark); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

/* --- Login --- */
.login-screen {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 360px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .brand-accent { color: var(--accent); }
.login-card p.sub { color: var(--text-muted); margin-top: 0; margin-bottom: 20px; font-size: 13px; }
.error-banner {
  background: rgba(239, 68, 68, 0.12); border: 1px solid var(--danger); color: #fca5a5;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
}
.success-banner {
  background: var(--accent-soft); border: 1px solid var(--accent); color: #86efac;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
}

/* --- App shell --- */
.app-shell { display: flex; flex: 1; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--bg-elevated); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar .brand { font-weight: 700; font-size: 18px; padding: 8px 10px 20px; }
.sidebar .brand .accent { color: var(--accent); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-size: 14px; margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px; color: var(--text-muted); }
.avatar-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.main-content { flex: 1; padding: 24px 32px; max-width: 1200px; width: 100%; margin: 0 auto; }
.mobile-topbar { display: none; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; margin: 0; }

/* --- Cards / grids --- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
  .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
}

.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; }

.progress-bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-high { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-medium { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge-low { background: rgba(34,197,94,0.15); color: #86efac; }
.badge-cat { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.pill-overdue { color: var(--danger); font-weight: 600; }
.pill-soon { color: var(--warning); font-weight: 600; }

/* --- Todos --- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }

.todo-list { display: flex; flex-direction: column; gap: 10px; }
.todo-row {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
}
.todo-row:hover { border-color: var(--accent); }
.todo-row.done { opacity: 0.55; }
.todo-row.done .todo-title { text-decoration: line-through; }
.todo-check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border);
  flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center;
  background: transparent;
}
.todo-check.checked { background: var(--accent); border-color: var(--accent); color: #06210f; }
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-weight: 600; margin-bottom: 4px; }
.todo-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-muted); }
.assignee-tag { display: flex; align-items: center; gap: 6px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 560px; box-shadow: var(--shadow);
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } }

.checklist-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.checklist-item input[type=text] { flex: 1; }

.comment-thread { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.comment:last-child { border-bottom: none; }
.comment-header { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; margin-bottom: 3px; }

/* --- Activity feed --- */
.activity-feed { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.activity-item { font-size: 13px; display: flex; gap: 8px; }
.activity-item time { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

/* --- Milestones --- */
.milestone-card { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
.countdown { font-size: 26px; font-weight: 700; color: var(--accent); }
.countdown-label { font-size: 11px; color: var(--text-muted); }

/* --- Calendar --- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-cell {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 6px;
  min-height: 90px; font-size: 12px; display: flex; flex-direction: column; gap: 3px;
}
.calendar-cell .day-num { color: var(--text-muted); font-size: 11px; }
.calendar-cell.other-month { opacity: 0.35; }
.calendar-event { border-radius: 4px; padding: 1px 5px; font-size: 10px; color: #06210f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

/* --- Files --- */
.files-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
@media (max-width: 800px) { .files-layout { grid-template-columns: 1fr; } }
.folder-tree { display: flex; flex-direction: column; gap: 2px; }
.folder-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.folder-item:hover { background: var(--bg); }
.folder-item.active { background: var(--accent-soft); color: var(--accent); }
.file-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.file-table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.file-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.file-table tr:hover { background: var(--bg); }
.dropzone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center;
  color: var(--text-muted); margin-bottom: 12px; font-size: 13px;
}
.dropzone.dragover { border-color: var(--accent); color: var(--accent); }

/* --- Chat --- */
.chat-window { display: flex; flex-direction: column; height: 60vh; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 4px; }
.chat-bubble { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.chat-bubble.user { align-self: flex-end; background: var(--accent); color: #06210f; }
.chat-bubble.assistant { align-self: flex-start; background: var(--bg-elevated); border: 1px solid var(--border); }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row textarea { resize: none; height: 44px; }
.suggested-todo { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-top: 8px; background: var(--bg-elevated); }
.suggested-todo-actions { margin-top: 8px; display: flex; gap: 8px; }

/* --- Mobile --- */
@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0; z-index: 40; width: 100%; height: 100vh; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
  }
  .main-content { padding: 16px; }
}

.empty-state { color: var(--text-muted); font-size: 13px; padding: 20px; text-align: center; }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow); }
.toast.error { border-color: var(--danger); }
