:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --accent: #a855f7;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --grid: #e5e7eb;
  --band: #f9fafb;
  --band-alt: #f3f4f6;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --accent: #8b5cf6;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --grid: #334155;
  --band: #1e293b;
  --band-alt: #334155;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid);
  background: var(--panel);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  transition: color 0.3s ease;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
  transition: color 0.3s ease, transform 0.2s ease;
}

.logo:hover .logo-icon {
  transform: scale(1.05);
}

.logo-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  font-weight: 800;
  letter-spacing: -0.8px;
}

[data-theme="dark"] .logo-text {
  background: linear-gradient(135deg, #60a5fa, #a78bfa, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; }
.divider { width: 1px; height: 28px; background: var(--grid); margin: 0 4px; }
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.04s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}
button:hover { 
  background: var(--band); 
  border-color: var(--muted); 
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:disabled:hover { background: var(--panel); border-color: var(--grid); }
.fullwidth { width: 100%; margin-top: 8px; }

.app-main {
  display: grid;
  grid-template-columns: var(--left-panel-width, 380px) 1fr;
  gap: 0;
  height: calc(100vh - 64px);
}

.left-panel {
  padding: 12px;
  border-right: 2px solid var(--grid); /* stronger separation */
  background: var(--panel);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  position: relative;
  min-width: 320px;
  max-width: 60vw;
  height: fit-content;
}

.left-panel::after {
  content: '';
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  background: transparent;
  cursor: ew-resize;
  z-index: 10;
}

.left-panel:hover::after {
  background: var(--primary);
  opacity: 0.3;
}
.task-table { width: 100%; border-collapse: collapse; }
.task-table th, .task-table td { padding: 6px 6px; border-bottom: 1px solid var(--grid); font-size: 13px; height: 35px; vertical-align: middle; box-sizing: border-box; }
.task-table th:first-child, .task-table td:first-child { text-align: left; }
.task-table th:first-child { padding-left: 25px; }
.task-table td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }
.task-table th:nth-child(2), .task-table td:nth-child(2) { width: 96px; min-width: 96px; text-align: right; flex-shrink: 0; }
.task-row-parent { background: #f1f1f1; }
.task-row-parent:hover { background: var(--band-alt); }
[data-theme="dark"] .task-row-parent { background: var(--band-alt); }
[data-theme="dark"] .task-row-parent:hover { background: var(--band-alt); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 12px; background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff; }
.badge.warn { background: #fff7ed; color: #9a3412; border-color: #ffedd5; }
.badge.ok { background: #ecfdf5; color: #065f46; border-color: #d1fae5; }

[data-theme="dark"] .badge { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
[data-theme="dark"] .badge.warn { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
[data-theme="dark"] .badge.ok { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
.task-table thead th { height: 35px; }
.task-name { display: flex; align-items: center; gap: 6px; }
.caret { width: 0; height: 0; border-left: 6px solid var(--muted); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform 0.15s ease, border-color 0.3s ease; cursor: pointer; }
.caret.expanded { transform: rotate(90deg); }

/* Moderne Einrückungssymbole für Unteraufgaben */
.indent-line {
  position: absolute;
  left: 0;
  top: 50%;
  width: 12px;
  height: 1px;
  background: var(--muted);
  opacity: 0.4;
  transform: translateY(-50%);
}

.indent-line::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 1px;
  height: 50%;
  background: var(--muted);
  opacity: 0.4;
  transform: translateY(-50%);
}

.indent-line::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 0;
  height: 0;
  border-left: 3px solid var(--muted);
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
  opacity: 0.4;
  transform: translateY(-50%);
}

/* Letzte Ebene - nur horizontaler Pfeil */
.indent-line.last-level {
  height: 1px;
  width: 12px;
  top: 50%;
}

.indent-line.last-level::before {
  display: none;
}

.indent-line.last-level::after {
  right: 0;
}

.task-name {
  position: relative;
}
.indent-0 { padding-left: 4px; }
.indent-1 { padding-left: 16px; }
.indent-2 { padding-left: 28px; }
.indent-3 { padding-left: 40px; }
.linklike { background: none; border: none; color: var(--text); padding: 2px 4px; cursor: pointer; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; width: 100%; text-align: left; position: relative; }
.linklike:hover { background: var(--band); }

/* Tooltip System */
.task-tooltip {
  position: absolute;
  background: var(--text);
  color: var(--panel);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.task-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.task-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
}

.task-tooltip::after {
  top: 100%;
  border-top-color: var(--text);
}

.task-tooltip[style*="--arrow-direction: bottom"]::after {
  top: -8px;
  border-top-color: transparent;
  border-bottom-color: var(--text);
}
.actions-col { width: 1%; white-space: nowrap; }
.icon-btn { padding: 6px 8px; border-radius: 8px; }
.icon-danger { border-color: #fde2e2; background: #fff5f5; color: #b91c1c; }
.icon-danger:hover { border-color: #fecaca; background: #fee2e2; }

[data-theme="dark"] .icon-danger { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.1); color: #fca5a5; }
[data-theme="dark"] .icon-danger:hover { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.2); }

.gantt-panel { position: relative; }
.gantt-scroll { width: 100%; height: 100%; overflow: auto; touch-action: pinch-zoom pan-x pan-y; }
.gantt-svg { width: 2400px; min-height: 1400px; display: block; background: var(--panel); transition: background-color 0.3s ease; }
.gantt-row-band { fill: var(--band); }
.gantt-row-band.alt { fill: var(--band-alt); }
.gantt-handle { fill: rgba(17,24,39,0.12); cursor: ew-resize; }
.gantt-handle:hover { fill: rgba(17,24,39,0.22); }

[data-theme="dark"] .gantt-handle { fill: rgba(241,245,249,0.12); }
[data-theme="dark"] .gantt-handle:hover { fill: rgba(241,245,249,0.22); }
.gantt-handle-left { fill: rgba(37,99,235,0.15); }
.gantt-handle-right { fill: rgba(37,99,235,0.15); }
.gantt-handle-left:hover { fill: rgba(37,99,235,0.25); }
.gantt-handle-right:hover { fill: rgba(37,99,235,0.25); }
.gantt-touch-area { fill: transparent; cursor: ew-resize; }
.gantt-resize-strip { fill: rgba(107,114,128,0.6); cursor: ew-resize; }
.gantt-resize-strip:hover { fill: rgba(107,114,128,0.8); }
.gantt-resize-strip-left { fill: rgba(107,114,128,0.6); }
.gantt-resize-strip-right { fill: rgba(107,114,128,0.6); }
.gantt-resize-strip-left:hover { fill: rgba(107,114,128,0.8); }
.gantt-resize-strip-right:hover { fill: rgba(107,114,128,0.8); }
.gantt-bar.selected { outline: 2px solid rgba(37,99,235,0.35); }

/* Urban colorful polish */
.toolbar button { border-radius: 9999px; }
/* Gantt SVG background is handled by CSS variables */
.gantt-bar { rx: 8; ry: 8; }
.gantt-bar.selected { box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.gantt-grid-line { stroke: var(--grid); stroke-width: 1; }
.gantt-today { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 4; }
.gantt-bar { rx: 6; ry: 6; fill: var(--primary); opacity: 0.95; }
.gantt-bar:hover { opacity: 1; filter: drop-shadow(0 1px 6px rgba(37,99,235,0.25)); }
.gantt-parent-hull { 
  fill: rgba(37, 99, 235, 0.1); 
  stroke: var(--primary); 
  stroke-width: 1; 
  stroke-dasharray: 4,4; 
  opacity: 0.8;
  pointer-events: none;
}
.gantt-parent-hull:hover { 
  opacity: 1; 
  stroke-width: 2;
}
.gantt-label { fill: var(--text); font-size: 12px; pointer-events: none; }
.gantt-axis { fill: var(--muted); font-size: 11px; }

@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; }
  .left-panel { height: 42vh; overflow: auto; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .gantt-panel { height: 58vh; }
}
.modal { position: fixed; inset: 0; display: none; }
.modal[aria-hidden="false"] { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.25); }
.modal-card { position: relative; margin: 10vh auto; width: min(560px, 92vw); background: var(--panel); border: 1px solid var(--grid); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); transition: background-color 0.3s ease, border-color 0.3s ease; }
.modal-header { padding: 16px 18px; border-bottom: 1px solid var(--grid); display: flex; align-items: center; gap: 12px; }
.modal-header h2 { font-size: 18px; margin: 0; }
.modal-body { padding: 14px 16px; display: grid; gap: 12px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--grid); display: flex; gap: 8px; align-items: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-row { display: grid; gap: 6px; }
.form-row label { color: var(--muted); font-size: 12px; }
.modal-card { transform: translateY(8px); opacity: 0; animation: modalIn 220ms ease forwards; }
@keyframes modalIn { to { transform: translateY(0); opacity: 1; } }
.modal-backdrop { backdrop-filter: blur(2px); }
.btn-primary { background: #2563eb; color: white; border-color: #2563eb; }
.btn-danger { background: #fff5f5; color: #b91c1c; border-color: #fecaca; }

/* Light theme accents for better readability on white */
.app-footer { color: var(--muted); padding: 8px 16px; }


