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

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1a1f2e;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --done-opacity: 0.45;
  --row-h: 38px;
  --label-w: 280px;
  --header-h: 56px;
  --header-sub-h: 24px;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.subtitle {
  margin-left: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  font-size: 12px;
  color: var(--text-muted);
}

.btn {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: #1d4ed8; }
.btn:active { opacity: .8; }
.btn.loading { opacity: .6; pointer-events: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
}
.btn-secondary:hover { background: var(--accent-light); }

/* ── Error banner ────────────────────────────────────────────────────── */
.error-banner {
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #991b1b;
  padding: 8px 20px;
  font-size: 13px;
  flex-shrink: 0;
}
.hidden { display: none !important; }

/* ── Controls ────────────────────────────────────────────────────────── */
#controls {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

#controls select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  cursor: pointer;
}

/* ── Gantt wrapper ───────────────────────────────────────────────────── */
#gantt-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left label column */
#gantt-labels {
  width: var(--label-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.label-header {
  height: calc(var(--header-h) + var(--header-sub-h));
  display: flex;
  align-items: flex-end;
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.label-rows {
  overflow-y: hidden;
  flex: 1;
}

.label-group-header {
  height: var(--row-h);
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.label-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.label-row {
  height: var(--row-h);
  padding: 0 12px 0 24px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  cursor: default;
  transition: background .1s;
}
.label-row:hover { background: var(--accent-light); }
.label-row.done { opacity: var(--done-opacity); }

.label-row-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.label-done-badge {
  margin-left: 6px;
  font-size: 11px;
  color: #16a34a;
  flex-shrink: 0;
}

/* ── Chart scroll area ───────────────────────────────────────────────── */
#gantt-chart-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
  background: var(--surface);
}

canvas {
  display: block;
}

#gantt-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

#today-line {
  position: absolute;
  top: calc(var(--header-h) + var(--header-sub-h));
  width: 2px;
  background: #ef4444;
  pointer-events: none;
  z-index: 5;
}

/* ── Tooltip ─────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  background: var(--text);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.6;
  pointer-events: none;
  z-index: 100;
  max-width: 260px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

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

/* ── Empty state ─────────────────────────────────────────────────────── */
#empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
}

#empty-state .empty-icon { font-size: 40px; }
#empty-state p { font-size: 14px; }
