/* --- Variables --- */
:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-hover: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #e07c4a;
  --accent-hover: #eb9468;
  --accent-muted: rgba(224, 124, 74, 0.25);
  --grid-line: #2a2a2a;
  --today: #e07c4a;
  --danger: #c94a4a;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --cell-width: 32px;
  --row-height: 44px;
  --sidebar-width: 360px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* --- Header --- */
.header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.25rem 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

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

.btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-icon {
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-danger:hover {
  background: rgba(201, 74, 74, 0.15);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.zoom-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-width: 3rem;
  text-align: center;
}

/* --- Main Gantt --- */
.main {
  flex: 1;
  overflow: auto;
  padding: 1rem;
}

.gantt-wrap {
  display: flex;
  min-width: min-content;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.gantt-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.col-task { flex: 1; }
.col-dates { flex: 0 0 100px; text-align: right; }

.task-list {
  flex: 1;
  overflow-y: auto;
}

.task-row-sidebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1rem;
  height: var(--row-height);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  background: var(--surface);
  transition: background 0.15s;
}

.task-row-sidebar:hover {
  background: var(--surface-hover);
}

.task-row-sidebar .name {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  white-space: normal;
  word-wrap: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-row-sidebar .dates {
  flex: 0 0 100px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.task-row-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0.7;
}

.task-row-sidebar:hover .task-row-actions {
  opacity: 1;
}

.markers-section {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.markers-section-header {
  padding: 0.5rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg);
}

.marker-list {
  max-height: 160px;
  overflow-y: auto;
}

.marker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.marker-row:hover {
  background: var(--surface-hover);
}

.marker-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.marker-delete-btn {
  padding: 0.15rem 0.4rem;
  font-size: 1rem;
  line-height: 1;
}

.markers-empty {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --- Chart area --- */
.gantt-chart-area {
  flex: 1;
  overflow: auto;
  min-width: 400px;
}

.timeline-header {
  height: 2.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}

.timeline-body {
  position: relative;
  min-height: 200px;
}

.dependency-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.timeline-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.task-bars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.marker-labels {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 26px;
  z-index: 4;
  pointer-events: none;
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.marker-label {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--today);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.markers-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.marker-line {
  position: absolute;
  top: 0;
  width: 2px;
  background: var(--today);
  opacity: 0.9;
  margin-left: -1px;
}

/* Timeline header cells */
.header-cell {
  flex-shrink: 0;
  width: var(--cell-width);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  border-right: 1px solid var(--grid-line);
}

.header-cell.month {
  font-weight: 600;
  color: var(--text);
}

.header-cell.today {
  background: var(--accent-muted);
  color: var(--today);
}

/* Grid lines */
.grid-row {
  display: flex;
  height: var(--row-height);
  border-bottom: 1px solid var(--border);
}

.grid-cell {
  flex-shrink: 0;
  width: var(--cell-width);
  border-right: 1px solid var(--grid-line);
}

.grid-cell.today {
  background: var(--accent-muted);
}

/* Task bar */
.task-bar-wrap {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--row-height);
  display: flex;
  align-items: center;
  padding: 0 2px;
  z-index: 2;
}

.task-bar {
  height: 24px;
  border-radius: 6px;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 4px;
}

.task-bar:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(224, 124, 74, 0.4);
}

.task-bar.has-blockers {
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.task-bar-draggable {
  cursor: grab;
}

.task-bar-draggable:active,
.task-bar.dragging {
  cursor: grabbing;
}

.task-bar-draggable::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
}

.task-bar {
  position: relative;
}

/* Dependency line */
.dep-line {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.8;
}

.dep-arrow {
  fill: var(--text-muted);
  opacity: 0.8;
}

/* --- Modal --- */
.modal {
  border: none;
  padding: 0;
  max-width: 90vw;
  width: 420px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  padding: 1.5rem;
}

.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-desc {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.task-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
}

.field span {
  color: var(--text-muted);
  font-weight: 500;
}

.field input,
.field select {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}

.field small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.row {
  display: flex;
  gap: 1rem;
}

.row .field {
  flex: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Empty state */
.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.empty-state p {
  margin: 0 0 1rem;
}
