:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #2563eb;
  --primary-light: #eff6ff;
  
  --success: #16a34a;
  --success-light: #f0fdf4;
  --success-border: #bbf7d0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.logo-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.badge-kc {
  font-size: 0.65rem;
  background: #0f172a;
  color: #fff;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.view-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tab-icon {
  font-size: 0.9rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success);
  border-radius: 50%;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Metrics Bar */
.metrics-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.7rem 1.8rem;
}

.metrics-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.metric-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.progress-bar {
  width: 140px;
  height: 7px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #0f172a;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.metric-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-counters {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.counter-sep {
  color: #cbd5e1;
}

.counter-badge strong {
  color: var(--text-main);
  font-weight: 600;
}

.counter-badge.counter-done strong {
  color: #16a34a;
}

.counter-badge.counter-prog strong {
  color: #2563eb;
}

.counter-badge.counter-ready strong {
  color: #6366f1;
}

.counter-badge.counter-back strong {
  color: #64748b;
}

/* Filter Bar */
.filters-bar {
  padding: 0.75rem 1.8rem 0.25rem 1.8rem;
}

.filters-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stream-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 500;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.chip.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1rem 1.8rem 2.5rem 1.8rem;
  display: flex;
  flex-direction: column;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.panel-header {
  margin-bottom: 1.5rem;
  text-align: left;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

.panel-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* 1. KANBAN BOARD (6 COLUMNS) */
.kanban-board {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 1.5rem;
  flex: 1;
}

.kanban-col {
  background: #f8fafc;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  min-width: 290px;
  max-width: 320px;
  flex: 0 0 305px;
  box-shadow: var(--shadow-sm);
}

.kanban-col.col-ready { border-top: 3px solid #6366f1; }
.kanban-col.col-in_progress { border-top: 3px solid #2563eb; }
.kanban-col.col-done { border-top: 3px solid #10b981; }
.kanban-col.col-planned { border-top: 3px solid #64748b; }
.kanban-col.col-idea { border-top: 3px solid #f59e0b; }
.kanban-col.col-blocked { border-top: 3px solid #ef4444; }

.col-header {
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.col-title-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.col-icon {
  font-size: 0.9rem;
}

.col-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.col-count {
  font-size: 0.72rem;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 7px;
  border-radius: 9999px;
  font-weight: 600;
}

.col-cards {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 180px;
}

.col-cards.drag-over {
  background-color: #e2e8f0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Kanban Card */
.task-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.85rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.task-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-id-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.task-id {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
}

.badge-priority {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.badge-priority.priority-high {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.badge-priority.priority-critical {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fda4af;
}

.badge-stream {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  color: var(--text-muted);
}

.card-title {
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-main);
}

/* Card Dependencies */
.card-deps {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 0.68rem;
}

.deps-label {
  color: var(--text-muted);
  font-weight: 500;
}

.deps-pills {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.dep-pill {
  font-family: monospace;
  font-size: 0.66rem;
  font-weight: 600;
  color: #2563eb;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.dep-pill:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.card-checklist-bar {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.checklist-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-progress {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background: #0f172a;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* 2. ROADMAP VIEW */
.roadmap-container {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.roadmap-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.phase-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.phase-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.phase-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.phase-status-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  color: var(--text-muted);
}

.phase-status-badge.status-done {
  background: var(--success-light);
  color: var(--success);
}

.phase-status-badge.status-in_progress {
  background: var(--primary-light);
  color: var(--primary);
}

.phase-status-badge.status-ready {
  background: #eef2ff;
  color: #4338ca;
}

.phase-status-badge.status-planned {
  background: #f8fafc;
  color: #475569;
}

.phase-goal {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.phase-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.phase-bar {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.phase-fill {
  height: 100%;
  background: #0f172a;
  border-radius: 9999px;
}

.phase-percent {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  min-width: 35px;
  text-align: right;
}

.phase-tasks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.phase-task-pill {
  font-size: 0.73rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.12s ease;
}

.phase-task-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pill-icon {
  font-size: 0.75rem;
}

.phase-task-pill.pill-status-done {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.phase-task-pill.pill-status-in_progress {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.phase-task-pill.pill-status-ready {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.phase-task-pill.pill-status-planned {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

.phase-task-pill.pill-status-idea {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

.phase-task-pill.pill-status-blocked {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

/* 3. HISTORY VIEW (Concise, Clean, Without Dates) */
.history-container {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.history-grid {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.history-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-title-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.history-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.history-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.history-tag {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.history-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-left: 0.2rem;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.45;
}

.history-bullet {
  color: var(--success);
  font-weight: bold;
  line-height: 1.3;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-task-id {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-task-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
}

.modal-task-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title-row h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.checklist-stat {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: #f8fafc;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-main);
  cursor: pointer;
}

.check-item.done span {
  text-decoration: line-through;
  color: var(--text-light);
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.meta-item.span-full {
  grid-column: 1 / -1;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.meta-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.meta-val {
  font-size: 0.78rem;
  font-weight: 500;
}

.status-select {
  font-size: 0.78rem;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
}

.modal-footer {
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-primary {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
  }
  .view-tabs {
    width: 100%;
    justify-content: space-between;
  }
  .tab-btn {
    flex: 1;
    justify-content: center;
  }
  .metrics-bar, .filters-bar, .main-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
