:root {
  --bg-body: #f4f6f8;
  --primary: #3182ce;
  --text-main: #2d3748;
  --green: #48bb78;
  --red: #f56565;
  --purple: #805ad5;
  --muted: #718096;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg-body); color: var(--text-main); margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* NAVBAR */
.navbar {
  background: white;
  height: 60px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.nav-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { font-weight: 800; color: var(--primary); font-size: 1.1rem; white-space: nowrap; }

.project-selector { display: flex; gap: 6px; align-items: center; }
.project-selector select { margin: 0; width: 220px; }
.btn-icon-add { background: var(--primary); color: white; border: 0; border-radius: 6px; width: 34px; height: 34px; cursor: pointer; }

.progress-pill {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  color: #1a202c;
  background: #f7fafc;
  white-space: nowrap;
}

.nav-right { display: flex; align-items: center; gap: 8px; }

.view-btn {
  border: 1px solid var(--border);
  background: #f7fafc;
  color: #1a202c;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}
.view-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.user-profile { font-weight: 700; margin-left: 6px; }
.logout-btn { border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; color: #1a202c; }

/* WORKSPACE */
.workspace { max-width: 1200px; margin: 18px auto; padding: 0 14px; }
.view-section { display: none; }
.view-section.active { display: block; }

/* TOOLBAR / QUICK ADD */
.toolbar { margin-bottom: 12px; }
.quick-add-wrapper {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.quick-add-wrapper i { color: var(--primary); }

/* TREE */
.node-row {
  background: white;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.node-row:hover { box-shadow: 0 2px 7px rgba(0,0,0,0.05); }
.node-left { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.node-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 560px; }
.node-right { display: flex; align-items: center; gap: 10px; }

.children-container { margin-left: 28px; border-left: 2px solid var(--border); padding-left: 10px; }
.completed-group { margin-top: 10px; margin-left: 28px; border-top: 1px dashed #cbd5e0; padding-top: 6px; }
.completed-header { font-size: 0.82rem; color: #a0aec0; cursor: pointer; }

/* PROGRESS BAR */
.progress-container { display: flex; align-items: center; gap: 10px; }
.progress-bar-bg { width: 110px; height: 8px; background: #edf2f7; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; transition: width 0.35s; }
.fill-green { background: var(--green); }
.fill-red { background: var(--red); }
.fill-striped {
  background: repeating-linear-gradient(45deg, var(--red), var(--red) 10px, #feb2b2 10px, #feb2b2 20px);
}

/* BADGES */
.badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7fafc;
  color: #1a202c;
  white-space: nowrap;
}
.badge.blocked { border-color: #fed7d7; background: #fff5f5; color: #c53030; }
.badge.warn { border-color: #fbd38d; background: #fffaf0; color: #c05621; }

.time-pill{
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #c6f6d5;
  background: #f0fff4;
  color: #2f855a;
  white-space: nowrap;
}

/* PULSE */
.pulse-sidebar {
  position: fixed;
  right: 0;
  top: 60px;
  bottom: 0;
  width: 320px;
  background: white;
  border-left: 1px solid var(--border);
  padding: 16px;
  box-shadow: -5px 0 15px rgba(0,0,0,0.05);
  overflow-y: auto;
  z-index: 90;
}
.pulse-header { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: bold; }
.pulse-item { padding: 10px 0; border-bottom: 1px solid #f7fafc; font-size: 0.92rem; color: #4a5568; }
.close-pulse { cursor: pointer; font-size: 1.5rem; }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; padding: 2rem; border-radius: 12px; width: 420px; }
.large-modal { width: 900px; max-width: 95vw; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 16px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-body-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
@media (max-width: 768px) { .modal-body-grid { grid-template-columns: 1fr; } }

input, textarea, select { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.title-input { font-size: 1.4rem; border: none; font-weight: 800; margin-bottom: 0; }
.title-input:focus { outline: none; border-bottom: 2px solid var(--primary); border-radius: 0; }

.status-actions button { width: 100%; padding: 10px; margin-bottom: 6px; border-radius: 10px; text-align: left; opacity: 0.75; transition: 0.2s; border: 0; cursor: pointer; }
.status-actions button:hover { opacity: 1; }
.status-actions .active { opacity: 1; font-weight: 800; color: white; }
.start.active { background: var(--primary); }
.block.active { background: var(--red); }
.complete.active { background: var(--green); }

.warning-box { background: #fffaf0; color: #c05621; padding: 10px; border-radius: 8px; font-size: 0.9rem; border: 1px solid #fbd38d; }
.divider { border: 0; border-top: 1px solid #eee; margin: 15px 0; }

.btn-primary { background: var(--text-main); color: white; border: 0; padding: 10px; border-radius: 10px; cursor: pointer; }
.btn-secondary { background: #edf2f7; color: #1a202c; border: 1px solid var(--border); padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.btn-sm { padding: 6px 10px; border-radius: 9px; font-size: .85rem; }
.btn-danger-text { background: transparent; border: 0; color: #e53e3e; cursor: pointer; margin-top: 12px; }
.full-width { width: 100%; }

/* OVERVIEW */
.overview-header { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 14px; }
.overview-title { margin: 0; font-size: 1.25rem; }
.overview-subtitle { color: var(--muted); font-size: .92rem; }
.overview-actions { display: flex; gap: 8px; }

.overview-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 980px) { .overview-cards { grid-template-columns: 1fr; } }

.overview-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.overview-card-top { display: flex; justify-content: space-between; align-items: center; }
.overview-card-title { font-weight: 800; }
.overview-card-pct { font-weight: 900; color: var(--primary); }
.overview-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.overview-card-actions { margin-top: 10px; }

.mini-pill {
  font-size: .75rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7fafc;
}
.mini-ok { border-color: #c6f6d5; background: #f0fff4; color: #2f855a; }
.mini-warn { border-color: #fbd38d; background: #fffaf0; color: #c05621; }
.mini-neutral { color: #1a202c; }

/* overview table */
.overview-table-wrap { background: white; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.overview-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.overview-table th, .overview-table td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; }
.overview-table th { background: #f7fafc; font-weight: 800; }

/* TIMELINE */
.timeline-container { display: grid; grid-template-columns: 320px 1fr; gap: 10px; }
@media (max-width: 980px) { .timeline-container { grid-template-columns: 1fr; } }

.timeline-sidebar {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}
.timeline-row-label {
  height: 32px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-canvas-wrapper {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

#timeline-axis {
  border-bottom: 1px solid var(--border);
  background: #f7fafc;
  overflow-x: auto;
}
.axis-ticks { display: flex; }
.axis-tick {
  height: 34px;
  font-size: 0.72rem;
  color: #4a5568;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #edf2f7;
  padding: 0 6px;
  white-space: nowrap;
}

#timeline-canvas {
  position: relative;
  overflow: auto;
  height: calc(32px * 18);
}
#gantt-bars { position: relative; }
.gantt-row { height: 32px; border-bottom: 1px solid #f1f5f9; position: relative; }

.gantt-bar {
  position: absolute;
  top: 6px;
  height: 20px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.95;
}
.gantt-bar.task { background: var(--primary); }
.gantt-bar.event { background: var(--purple); }
.gantt-bar.blocked { background: var(--red); }

.timeline-hint { padding: 10px 12px; color: var(--muted); font-size: .92rem; }

/* ADMIN */
.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 980px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-card { background: white; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.admin-card-header { padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f7fafc; }
.admin-card-body { padding: 10px 12px; overflow: auto; max-height: 420px; }

.mini-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.mini-table th, .mini-table td { border-bottom: 1px solid #edf2f7; padding: 8px; text-align: left; }
.mini-table th { font-weight: 800; background: #f7fafc; }
