/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --ac: #E8612C;            /* Yooji's accent — warm orange */
  --ac-ink: #B8430F;
  --ink: #0A0A0A;
  --ink-2: #2A2A2D;
  --ink-3: #5C5C61;
  --ink-4: #8A8A90;
  --line: #E6E6E8;
  --line-2: #F0F0F2;
  --bg: #FAFAFA;
  --paper: #FFFFFF;
  --label-w: 264px;
  --row-h: 56px;
  --font: "Helvetica Neue", Helvetica, Arial, "Inter", sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,0.025) 1px, transparent 0);
  background-size: 4px 4px;
  pointer-events: none;
  z-index: 0;
}
#root { position: relative; z-index: 1; }

.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 32px 40px 48px;
}

/* ---------- Logo ---------- */
.logo {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ac);
}
.logo-ap { color: var(--ink-3); }

/* ---------- Header ---------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.page-head-left { display: flex; align-items: center; gap: 20px; }
.page-head-divider { width: 1px; height: 28px; background: var(--line); }
.page-head-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.page-head-title p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: 0.01em;
}
.page-head-right { display: flex; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.ctrl-group { display: flex; align-items: center; gap: 10px; }
.ctrl-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg);
}
.seg-btn {
  font: inherit;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  padding: 7px 13px;
  cursor: pointer;
  border-right: 1px solid var(--line);
  transition: background 120ms ease, color 120ms ease;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on {
  background: var(--ac);
  color: white;
  font-weight: 600;
}
.ctrl-select {
  font: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.ctrl-select:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ac) 14%, transparent);
}
.ctrl-spacer { flex: 1; }
.ctrl-gran {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}
.kpi {
  padding: 16px 20px;
  border-right: 1px solid var(--line);
}
.kpi:last-child { border-right: none; }
.kpi-label {
  font-size: 10.5px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--mono);
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--mono);
}

/* ---------- Chart ---------- */
.chart {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

/* shared lane geometry */
.lane-spacer {
  width: var(--label-w);
  flex: 0 0 var(--label-w);
  border-right: 1px solid var(--line);
}
.lane-track {
  flex: 1;
  position: relative;
}

/* ---------- Time header ---------- */
.time-header {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
  height: 46px;
}
.time-header .lane-track { overflow: hidden; }
.col-head {
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 7px 8px;
  border-left: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.col-head.is-major { border-left-color: var(--line); }
.col-sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  height: 12px;
  white-space: nowrap;
}
.col-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.col-head.is-major .col-label { color: var(--ink); }

/* ---------- Rows ---------- */
.rows { position: relative; }

.grid-lines {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  z-index: 0;
}
.grid-lines .lane-spacer { border-right: 1px solid var(--line); }
.grid-col {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line-2);
}
.grid-col.is-major { border-left-color: var(--line); }

.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1.5px dashed var(--ac);
  z-index: 4;
}
.today-flag {
  position: absolute;
  top: 2px;
  left: 3px;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: white;
  background: var(--ac);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.rows-empty {
  position: relative;
  z-index: 1;
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}

/* ---------- Group header (Hauptprojekt) ---------- */
.group {
  display: flex;
  min-height: 34px;
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line-2);
}
.group:first-child { border-top: none; }
.group-label {
  width: var(--label-w);
  flex: 0 0 var(--label-w);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
  border-left: 3px solid var(--tint);
}
.group-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.group-name {
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-owner {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  margin-left: auto;
  white-space: nowrap;
}
.group-track {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
}
.group-count {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* ---------- Project row (Teilprojekt) ---------- */
.lane {
  display: flex;
  height: var(--row-h);
  border-bottom: 1px solid var(--line-2);
  position: relative;
  z-index: 1;
}
.lane-label {
  width: var(--label-w);
  flex: 0 0 var(--label-w);
  border-right: 1px solid var(--line);
  padding: 0 16px 0 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: rgba(255,255,255,0.55);
  overflow: hidden;
}
.lane-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lane-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lane-owner {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* status badges */
.st-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--ink-3);
  flex: 0 0 auto;
}
.st-badge.st-geplant       { color: #5C5C61; border-color: #D6D6DA; background: #F6F6F8; }
.st-badge.st-aktiv         { color: #1B6B3A; border-color: #B7E0C4; background: #EEF8F1; }
.st-badge.st-pausiert      { color: var(--ac-ink); border-color: color-mix(in oklch, var(--ac) 40%, white); background: color-mix(in oklch, var(--ac) 8%, white); }
.st-badge.st-abgeschlossen { color: #8A8A90; border-color: #E6E6E8; background: #FAFAFA; }

/* the bar */
.bar {
  position: absolute;
  top: 9px;
  bottom: 9px;
  border-radius: 6px;
  background: color-mix(in oklch, var(--tint) 12%, white);
  border: 1px solid color-mix(in oklch, var(--tint) 45%, white);
  overflow: hidden;
  z-index: 2;
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  transition: transform 520ms cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity 260ms ease,
              box-shadow 180ms ease,
              border-color 180ms ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 10px;
}
.bar.is-in { transform: scaleX(1); opacity: 1; }
.bar:hover {
  border-color: var(--tint);
  box-shadow: 0 4px 18px -6px color-mix(in oklch, var(--tint) 40%, transparent);
}
.bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    color-mix(in oklch, var(--tint) 20%, white) 0%,
    color-mix(in oklch, var(--tint) 9%, white) 100%);
  z-index: 0;
}
.bar-label {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  color: color-mix(in oklch, var(--tint) 82%, black);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* status-specific bar treatments */
.bar.st-geplant {
  background: repeating-linear-gradient(135deg,
    color-mix(in oklch, var(--tint) 8%, white) 0, color-mix(in oklch, var(--tint) 8%, white) 6px,
    color-mix(in oklch, var(--tint) 14%, white) 6px, color-mix(in oklch, var(--tint) 14%, white) 12px);
  border-style: dashed;
}
.bar.st-geplant::before { display: none; }
.bar.st-pausiert { opacity: 0.92; }
.bar.st-pausiert.is-in { opacity: 0.92; }
.bar.st-abgeschlossen {
  filter: grayscale(0.55);
  opacity: 0.78;
}
.bar.st-abgeschlossen.is-in { opacity: 0.78; }
.bar.st-abgeschlossen .bar-label { text-decoration: line-through; }

/* clipped edges indicate the bar continues outside the window */
.bar.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 3px; border-left-style: solid; }
.bar.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-width: 3px; border-right-style: solid; }

/* ---------- Hidden note ---------- */
.hidden-note {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  margin: 0 0 20px;
  text-align: right;
}

/* ---------- Footer ---------- */
.page-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.foot-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.foot-right { display: flex; gap: 8px; align-items: center; }
.foot-sep { color: var(--ink-4); }
.foot-link {
  color: var(--ink-3);
  border-bottom: 1px dotted var(--ink-4);
  text-decoration: none;
  cursor: pointer;
}
.foot-link:hover { color: var(--ac); border-bottom-color: var(--ac); }

/* ---------- Empty state ---------- */
.empty-state {
  border: 1px dashed var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  margin-bottom: 24px;
}
.empty-state h2 { margin: 0 0 6px; font-size: 16px; letter-spacing: -0.01em; color: var(--ink); }
.empty-state p { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.empty-state a { color: var(--ac); border-bottom: 1px solid var(--ac); text-decoration: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: bdIn 180ms ease forwards;
}
@keyframes bdIn { to { opacity: 1; } }

.modal {
  background: var(--paper);
  border-radius: 10px;
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  overflow: auto;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px -20px rgba(0,0,0,0.25), 0 8px 24px -8px rgba(0,0,0,0.15);
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  animation: mdIn 240ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes mdIn { to { transform: translateY(0) scale(1); opacity: 1; } }

.modal-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}
.modal-head::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--tint, var(--ac));
}
.modal-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin: 0; }
.modal-sub {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 8px;
}
.modal-close {
  border: 1px solid var(--line);
  background: var(--paper);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14px;
  flex: 0 0 auto;
  transition: all 120ms ease;
}
.modal-close:hover { border-color: var(--ac); color: var(--ac); }

.modal-body { padding: 18px 24px 22px; }
.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}
.modal-stat { background: var(--paper); padding: 12px 14px; }
.modal-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.modal-stat-value {
  font-size: 14px;
  font-weight: 600;
  margin-top: 5px;
  letter-spacing: -0.01em;
}
.modal-stat-value.is-accent { color: var(--tint, var(--ac)); }

.modal-note {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
  background: var(--bg);
  border-left: 2px solid var(--tint, var(--ac));
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 4px;
}
.modal-section-title {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin: 18px 0 10px;
}
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff, #fafafa);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--soft, #eee);
  color: var(--tint, var(--ac));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in oklch, var(--tint, #888) 35%, white);
}
.team-text { flex: 1; min-width: 0; }
.team-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.team-role { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------- API key gate ---------- */
.api-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.api-gate-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  width: min(420px, 100%);
  box-shadow: 0 24px 80px -20px rgba(0,0,0,0.18), 0 8px 24px -8px rgba(0,0,0,0.10);
}
.api-gate-brand { margin-bottom: 18px; }
.api-gate-card h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.api-gate-card p { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.api-gate-error {
  border: 1px solid var(--ac);
  background: color-mix(in oklch, var(--ac) 7%, white);
  color: var(--ac-ink);
  font-family: var(--mono);
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.api-gate-card input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  margin-bottom: 12px;
}
.api-gate-card input:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ac) 12%, transparent);
}
.api-gate-btn {
  width: 100%;
  font: inherit;
  padding: 10px 14px;
  border: 1px solid var(--ac);
  background: var(--ac);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: filter 120ms ease;
}
.api-gate-btn:hover { filter: brightness(1.05); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .page { padding: 24px 20px 36px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: none; }
  .kpi:nth-child(1), .kpi:nth-child(2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 820px) {
  :root { --label-w: 170px; }
  .controls { gap: 14px; }
}

/* ---------- Print ---------- */
@media print {
  body::before { display: none; }
  body { background: white; }
  .page { padding: 12mm; max-width: none; }
  .chart, .kpis, .controls { box-shadow: none; }
  .bar { transform: scaleX(1) !important; opacity: 1 !important; }
  .modal-backdrop, .api-gate { display: none; }
}
