:root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --status-not-started: #898781;
  --status-in-progress: #2a78d6;
  --status-complete: #0ca30c;

  --accent: #2a78d6;
  --danger: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);

    --status-not-started: #898781;
    --status-in-progress: #3987e5;
    --status-complete: #0ca30c;

    --accent: #3987e5;
    --danger: #e66767;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

.muted {
  color: var(--text-secondary);
}

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 6px 12px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.btn-icon:hover {
  background: var(--gridline);
  color: var(--text-primary);
}

/* ---- login ---- */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-view[hidden],
.app-view[hidden] {
  display: none;
}

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 6px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-card input {
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

/* ---- app shell ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

.topbar h1 {
  font-size: 16px;
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.main {
  padding: 20px 24px 60px;
  max-width: 1400px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.range-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.range-filter label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-filter input[type="date"] {
  width: 140px;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.swatch-not_started { background: var(--status-not-started); }
.swatch-in_progress { background: var(--status-in-progress); }
.swatch-complete { background: var(--status-complete); }

/* ---- table / chart ---- */

.chart-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

.gantt-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

.gantt-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gridline);
  position: sticky;
  top: 0;
  background: var(--surface-1);
}

.gantt-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
  vertical-align: middle;
}

.gantt-table tr:last-child td {
  border-bottom: none;
}

.col-timeline { width: 480px; }
.col-actions { width: 70px; }

.row-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-name input[type="text"] {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.row-name input[type="text"]:hover,
.row-name input[type="text"]:focus {
  border-color: var(--border);
  background: var(--page);
  outline: none;
}

.indent {
  display: inline-block;
  flex-shrink: 0;
}

.row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  flex-shrink: 0;
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  border-radius: 3px;
  line-height: 1;
}
.toggle-btn:hover {
  background: var(--gridline);
  color: var(--text-primary);
}

.late-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
}

.cell-input {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.cell-input:hover,
.cell-input:focus {
  border-color: var(--border);
  background: var(--page);
  outline: none;
}

select.cell-input {
  width: auto;
}

.cell-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions-cell {
  display: flex;
  gap: 2px;
  white-space: nowrap;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- timeline axis ---- */

.timeline-axis {
  position: relative;
  height: 32px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.axis-tick {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 11px;
}

/* Today gets its own lane above the date ticks so the badge never overlaps tick text. */
.axis-today-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  line-height: 15px;
}

.axis-today-marker::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 5px;
  background: var(--accent);
  transform: translateX(-50%);
}

/* ---- gantt bar ---- */

.bar-cell {
  padding: 6px 12px;
}

.bar-track {
  position: relative;
  height: 16px;
  border-radius: 4px;
  background: var(--gridline);
  overflow: hidden;
}

.bar-gridline {
  position: absolute;
  top: 0;
  height: 100%;
  width: 1px;
  background: var(--baseline);
  opacity: 0.5;
}

.bar-gridline-today {
  width: 2px;
  background: var(--accent);
  opacity: 0.7;
}

.bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 4px;
}

.bar-fill.status-not_started { background: var(--status-not-started); opacity: 0.55; }
.bar-fill.status-in_progress { background: var(--status-in-progress); }
.bar-fill.status-complete { background: var(--status-complete); }

.bar-outline {
  position: absolute;
  top: 0;
  height: 100%;
  box-sizing: border-box;
  border-radius: 4px;
  border: 1.5px solid var(--baseline);
  pointer-events: none;
}

/* ---- tooltip ---- */

.tooltip {
  position: fixed;
  z-index: 50;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  pointer-events: none;
  max-width: 240px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tooltip strong {
  display: block;
  margin-bottom: 2px;
}
