:root {
  --bg: #0B0F1A;
  --surface: #141925;
  --surface-2: #1C2333;
  --border: #2A3345;
  --text: #E2E8F0;
  --text-muted: #64748B;
  --accent: #3B82F6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --purple: #8B5CF6;
  --pink: #EC4899;
  --cyan: #06B6D4;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell layout ─────────────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: white;
}
.sidebar-name { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-sub { font-size: 11px; color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-label {
  padding: 8px 12px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  transition: all 0.15s; margin-bottom: 2px; border: none;
  background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(239,68,68,0.15); color: var(--red);
}

/* ── Main area ────────────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.topbar h2 { font-size: 18px; font-weight: 700; }
.topbar-phase { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-btn {
  padding: 7px 14px; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.topbar-btn:hover { border-color: var(--accent); color: var(--accent); }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  animation: pulse-dot 2s infinite; margin-right: 6px; display: inline-block;
}
.live-indicator { font-size: 12px; color: var(--green); display: flex; align-items: center; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.content { padding: 28px; flex: 1; }

/* ── View tabs ────────────────────────────────────────────────────── */
.view-tabs {
  display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px;
  padding: 3px; width: fit-content; margin-bottom: 24px;
}
.view-tab {
  padding: 7px 16px; border: none; background: transparent;
  border-radius: 6px; font-family: inherit; font-size: 12px;
  font-weight: 600; color: var(--text-muted); cursor: pointer; transition: all 0.2s;
}
.view-tab:hover { color: var(--text); }
.view-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.view { display: none; }
.view.active { display: block; }

/* ── Stats row ────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
}
.stat-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 6px;
}
.stat-val { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Progress section ─────────────────────────────────────────────── */
.progress-section { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.progress-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
}
.progress-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

.ring-wrap { display: flex; align-items: center; gap: 24px; }
.ring { position: relative; width: 100px; height: 100px; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .bg { stroke: var(--surface-2); }
.ring .fill { stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.ring-text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-pct { font-size: 22px; font-weight: 800; }
.ring-label { font-size: 10px; color: var(--text-muted); }

.ring-details { flex: 1; }
.ring-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.ring-row:last-child { border-bottom: none; }
.ring-row .label { color: var(--text-muted); }
.ring-row .val { font-weight: 600; }

/* ── Phase bar ────────────────────────────────────────────────────── */
.phase-bar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; margin-bottom: 28px;
}
.phase-bar h4 { font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.phase-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(42,51,69,0.5);
}
.phase-item:last-child { border-bottom: none; }
.phase-num {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600;
  width: 24px; text-align: center; color: var(--text-muted);
}
.phase-name { flex: 1; font-size: 13px; font-weight: 500; }
.phase-prog { width: 120px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.phase-prog-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }
.phase-status {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 12px;
  width: 80px; text-align: center;
}

/* ── Activity feed ────────────────────────────────────────────────── */
.activity {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; margin-bottom: 28px;
}
.activity h4 { font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.activity-text { font-size: 13px; color: var(--text-muted); line-height: 1.5; flex: 1; }
.activity-text strong { color: var(--text); }
.activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ── Board view ───────────────────────────────────────────────────── */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.board-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; min-height: 200px;
}
.board-col-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.board-col-count {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; background: var(--surface-2); color: var(--text-muted);
}
.board-col-body { padding: 12px; }
.board-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: all 0.15s;
}
.board-card:last-child { margin-bottom: 0; }
.board-card:hover { border-color: rgba(59,130,246,0.4); transform: translateY(-1px); }
.board-card-id {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--text-muted); margin-bottom: 6px;
}
.board-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; line-height: 1.4; }
.board-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.board-card-tag {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; background: var(--accent-glow); color: var(--accent);
}
.board-card-tag.backend { background: var(--accent-glow); color: var(--accent); }
.board-card-tag.frontend { background: rgba(16,185,129,0.15); color: var(--green); }
.board-card-tag.database { background: rgba(139,92,246,0.15); color: var(--purple); }
.board-card-tag.security { background: rgba(245,158,11,0.15); color: var(--amber); }
.board-card-tag.infra { background: rgba(239,68,68,0.15); color: var(--red); }
.board-card-tag.ui { background: rgba(236,72,153,0.15); color: var(--pink); }
.board-card-blocker { font-size: 11px; color: var(--red); margin-top: 8px; }
.board-card.completed { opacity: 0.7; }
.board-card.void { opacity: 0.4; border-left: 3px solid var(--text-muted); text-decoration: line-through; }
.board-card.blocked { border-left: 3px solid var(--red); }
.board-card.in-progress { border-left: 3px solid var(--accent); }
.board-card.done { border-left: 3px solid var(--green); }

/* ── KPI view ─────────────────────────────────────────────────────── */
.kpi-phase {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px; overflow: hidden;
}
.kpi-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; cursor: pointer;
}
.kpi-header:hover { background: var(--surface-2); }
.kpi-title { flex: 1; font-size: 14px; font-weight: 600; }
.kpi-bar { width: 100px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.kpi-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }
.kpi-frac {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-muted); width: 50px; text-align: right;
}
.kpi-items { padding: 0 20px 16px; display: none; }
.kpi-items.open { display: block; }
.kpi-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid rgba(42,51,69,0.3); font-size: 13px;
}
.kpi-item:last-child { border-bottom: none; }
.kpi-check { font-size: 16px; cursor: pointer; }
.kpi-item-title { flex: 1; }
.kpi-item-title.unchecked { color: var(--text-muted); }
.kpi-sev {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}
.kpi-sev.critical { background: rgba(239,68,68,0.15); color: var(--red); }
.kpi-sev.important { background: rgba(245,158,11,0.15); color: var(--amber); }
.kpi-sev.nice_to_have { background: rgba(16,185,129,0.15); color: var(--green); }

/* ── Roadmap view ─────────────────────────────────────────────────── */
.roadmap-phase {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px; overflow: hidden;
}
.roadmap-phase-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; cursor: pointer;
}
.roadmap-phase-header:hover { background: var(--surface-2); }
.roadmap-phase-title { flex: 1; font-size: 14px; font-weight: 600; }
.roadmap-tasks { padding: 0 20px 16px; display: none; }
.roadmap-tasks.open { display: block; }
.roadmap-task {
  padding: 12px 0; border-bottom: 1px solid rgba(42,51,69,0.3);
}
.roadmap-task:last-child { border-bottom: none; }
.roadmap-task-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.roadmap-task-status {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
}
.roadmap-task-title { font-size: 13px; font-weight: 600; }
.roadmap-task-desc { font-size: 12px; color: var(--text-muted); margin-left: 28px; margin-bottom: 6px; }
.roadmap-task-notes { margin-left: 28px; }
.roadmap-task-note {
  font-size: 11px; color: var(--text-muted); padding: 4px 0;
  border-left: 2px solid var(--border); padding-left: 10px; margin-bottom: 4px;
}
.roadmap-task-note .note-author {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── PRD view ─────────────────────────────────────────────────────── */
.prd-search {
  margin-bottom: 20px; display: flex; gap: 8px;
}
.prd-search input {
  flex: 1; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: inherit; font-size: 13px;
  outline: none;
}
.prd-search input:focus { border-color: var(--accent); }
.prd-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px; overflow: hidden;
}
.prd-section-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; cursor: pointer;
}
.prd-section-header:hover { background: var(--surface-2); }
.prd-section-num {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--accent); font-weight: 600;
}
.prd-section-title { flex: 1; font-size: 14px; font-weight: 600; }
.prd-section-domain {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: var(--accent-glow); color: var(--accent);
}
.prd-section-body { padding: 0 20px 16px; display: none; }
.prd-section-body.open { display: block; }
.prd-content {
  font-size: 13px; color: #94A3B8; line-height: 1.8;
  white-space: pre-wrap;
}
.prd-amendment {
  margin-top: 12px; padding: 12px 16px;
  background: rgba(245,158,11,0.06); border-left: 3px solid var(--amber);
  border-radius: 0 8px 8px 0; font-size: 12px;
}
.prd-amendment-header {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--amber); margin-bottom: 4px;
}
.prd-amendment-content { color: #94A3B8; }

/* ── Change proposal banner ───────────────────────────────────────── */
.change-banner {
  background: rgba(245,158,11,0.06); border: 1px solid rgba(245,158,11,0.25);
  border-radius: 12px; padding: 20px 24px; margin-bottom: 28px;
}
.change-banner-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.change-banner-title { font-size: 14px; font-weight: 700; color: var(--amber); }
.change-banner-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.change-banner-desc { font-size: 13px; color: #94A3B8; margin-bottom: 12px; }
.change-banner-desc strong { color: var(--text); }
.change-banner-impact { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.change-banner-impact strong { color: var(--text); }
.change-banner-actions { display: flex; gap: 8px; margin-left: auto; }
.btn-approve {
  padding: 7px 14px; border: 1px solid var(--green); background: var(--green);
  border-radius: 6px; font-size: 12px; font-weight: 500; color: white;
  cursor: pointer; font-family: inherit;
}
.btn-reject {
  padding: 7px 14px; border: 1px solid rgba(239,68,68,0.3); background: transparent;
  border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--red);
  cursor: pointer; font-family: inherit;
}

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 20px; box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  max-width: 400px; transform: translateY(20px); opacity: 0;
  transition: all 0.3s ease; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast-icon { font-size: 18px; }

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .progress-section { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, 1fr); }
}

/* ── Task modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; max-width: 560px; width: 90%;
  max-height: 80vh; overflow-y: auto;
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-field { margin-bottom: 14px; }
.modal-field label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 4px;
}
.modal-field input, .modal-field textarea {
  width: 100%; padding: 8px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: inherit; font-size: 13px; outline: none;
}
.modal-field textarea { resize: vertical; min-height: 60px; }
.modal-field input:focus, .modal-field textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.modal-actions button {
  padding: 8px 18px; border-radius: 6px; font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.modal-cancel { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.modal-submit { background: var(--accent); border: 1px solid var(--accent); color: white; }

/* ── Codebase tree ──────────────────────────────────────────────── */
.codebase-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.codebase-repo code { color: var(--cyan); font-size: 14px; font-weight: 500; }
.tree-container { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 0; overflow-x: auto; }
.tree-node { display: flex; align-items: center; gap: 4px; padding: 3px 12px; font-size: 13px; min-height: 28px; }
.tree-node:hover { background: var(--surface-2); }
.tree-toggle { cursor: pointer; width: 16px; text-align: center; font-size: 9px; color: var(--text-muted); flex-shrink: 0; }
.tree-icon { font-size: 13px; width: 18px; text-align: center; flex-shrink: 0; }
.tree-name { font-weight: 500; color: var(--text); font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.tree-meta { font-size: 10px; color: var(--text-muted); margin-left: 4px; flex-shrink: 0; }
.tree-desc { flex: 1; font-size: 12px; color: var(--text-muted); margin-left: 12px; padding: 2px 6px; border-radius: 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tree-desc:hover { background: rgba(59,130,246,0.1); }
.tree-desc-edit { width: 100%; font-size: 12px; padding: 3px 8px; background: var(--surface-2); border: 1px solid var(--accent); border-radius: 4px; color: var(--text); outline: none; font-family: inherit; }
.tree-badge { font-size: 9px; color: var(--cyan); border: 1px solid var(--cyan); border-radius: 8px; padding: 1px 6px; flex-shrink: 0; opacity: 0.6; }
.scan-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.scan-item:last-child { border-bottom: none; }
