:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: rgba(255,255,255,0.08);
  --text: #e8e8f0;
  --muted: #6b6b80;
  --accent: #6c63ff;
  --accent2: #9b8aff;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: -0.3px;
}
.sidebar-logo span { color: var(--text); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.12); color: var(--accent2); }
.nav-icon { font-size: 16px; }

.main { flex: 1; overflow-y: auto; padding: 36px 40px; max-width: 1100px; }

/* ── Header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.page-subtitle { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7c73ff; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ── Priority Queue ── */
.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 16px;
}

.priority-list { display: flex; flex-direction: column; gap: 12px; }

.priority-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; gap: 16px; align-items: flex-start;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.priority-card:hover { border-color: rgba(108,99,255,0.3); box-shadow: 0 0 0 1px rgba(108,99,255,0.1); }

.rank-badge {
  min-width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.rank-1 { background: rgba(251,191,36,0.15); color: #fbbf24; }
.rank-2 { background: rgba(156,163,175,0.12); color: #9ca3af; }
.rank-3 { background: rgba(180,120,60,0.12); color: #b47c3c; }
.rank-other { background: var(--bg3); color: var(--muted); }

.priority-content { flex: 1; min-width: 0; }
.priority-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.priority-reasoning { font-size: 13px; color: var(--muted); line-height: 1.5; }

.priority-meta {
  display: flex; gap: 12px; align-items: center;
  margin-top: 10px; flex-wrap: wrap;
}
.meta-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted);
  background: var(--bg3); border-radius: 4px;
  padding: 3px 8px;
}

.score-bar-wrap { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.score-bar {
  flex: 1; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden;
}
.score-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.6s ease; }
.score-num { font-size: 12px; font-weight: 600; color: var(--accent2); min-width: 26px; text-align: right; }

/* ── Empty / Loading states ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 18px;
  font-size: 14px; z-index: 999;
  transition: opacity 0.3s;
  max-width: 320px;
}
.toast.success { border-color: rgba(34,197,94,0.3); color: var(--success); }
.toast.error { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.toast.fade-out { opacity: 0; }

/* ── All Tasks table ── */
.tasks-table { width: 100%; border-collapse: collapse; }
.tasks-table th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.tasks-table td {
  padding: 12px 12px; border-bottom: 1px solid var(--border);
  font-size: 14px; vertical-align: middle;
}
.tasks-table tr:last-child td { border-bottom: none; }
.tasks-table tr:hover td { background: rgba(255,255,255,0.02); }

.status-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 500;
}
.status-todo { background: rgba(107,107,128,0.15); color: var(--muted); }
.status-in_progress { background: rgba(108,99,255,0.12); color: var(--accent2); }
.status-done { background: rgba(34,197,94,0.1); color: var(--success); }

/* ── Add task form ── */
.add-task-form {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  display: none;
}
.add-task-form.open { display: block; }

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 20px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; font-family: inherit;
  padding: 10px 12px; outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg3); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; }
.tab-btn {
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; background: transparent;
  color: var(--muted); transition: all 0.15s;
}
.tab-btn.active { background: var(--bg3); color: var(--text); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Deadline urgency ── */
.urgent { color: var(--danger); }
.soon { color: var(--warn); }
