:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #0f0f0f;
  --muted: #4a4a4a;
  --accent: #000000;
  --border: #e5e5e5;
  --soft: #f2f2f2;
  --row: #f7f7f7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f6f7f8 0%, #ffffff 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.auth-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.auth-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 250px;
  height: auto;
  flex: 0 0 auto;
}

.brand-title {
  font-weight: 700;
}

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

.header-actions button {
  margin-left: 8px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--soft);
  font-size: 12px;
}

.status-actions button { margin-left: 8px; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 96px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  position: sticky;
  top: 0;
  height: calc(100vh - 96px);
  overflow: auto;
}

.sidebar a {
  display: block;
  padding: 6px 8px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}

.sidebar a:hover {
  background: var(--soft);
}
.sidebar a.active {
  background: #000;
  color: #fff;
}

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 8px 6px;
}

.content {
  padding: 16px 20px 40px;
}

.section { display: none; }
.section.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.sub-title {
  font-size: 13px;
  font-weight: 600;
  margin: 6px 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 8px 0 12px;
}

.mini-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--soft);
}

.mini-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.mini-value { font-size: 16px; font-weight: 700; margin-top: 6px; }

.hint { color: var(--muted); font-size: 12px; }
.budget-summary { margin-top: 8px; font-size: 13px; }
.budget-summary strong { font-weight: 700; }
.budget-fx {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 8px 0;
}
.budget-fx label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.budget-fx input {
  width: 92px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

button.primary {
  background: #000;
  color: #fff;
}

.table-wrap { overflow-x: auto; width: 100%; max-width: 100%; }

table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 12px;
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

th {
  background: var(--soft);
  text-align: left;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
}

tr:nth-child(even) td { background: var(--row); }
th:nth-child(even) { background: #ececec; }
td:nth-child(even) { background: #f2f2f2; }
tr:nth-child(even) td:nth-child(even) { background: #ebebeb; }

td[contenteditable="true"]:focus {
  outline: 2px solid #000;
  background: #fff;
}

select.owner-select, select.dep-select, select.status-select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 12px;
}

input[type="date"] {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 12px;
}

table.table-notes td {
  min-height: 36px;
  white-space: pre-wrap;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  color: #fff;
  background: #6b6b6b;
}
.status-badge.offen { background: #6b6b6b; }
.status-badge.geplant { background: #1f6feb; }
.status-badge.in-arbeit { background: #0f9d58; }
.status-badge.blockiert { background: #d32f2f; }
.status-badge.erledigt { background: #2e7d32; }
.status-badge.backlog { background: #6b6b6b; }
.status-badge.in-review { background: #f59e0b; }
.status-badge.done { background: #2e7d32; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  color: #fff;
  font-weight: 700;
}

.pill.must { background: #000; }
.pill.should { background: #3c3c3c; }
.pill.can { background: #6b6b6b; }

.actions-col {
  width: 74px;
}

.row-action {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
}

.row-action + .row-action { margin-left: 4px; }

.eval-icons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 10px 0;
  align-items: stretch;
}
.eval-wheel-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 4px;
  font-size: 12px;
  color: #1f2937;
}
.eval-wheel-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wheel-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}
.wheel-dot.ws { background: #2563eb; }
.wheel-dot.wd { background: #16a34a; }
.wheel-dot.caster { background: #9ca3af; }
.eval-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
  min-height: 132px;
  display: flex;
  flex-direction: column;
}
.eval-card svg {
  width: 100%;
  max-width: 140px;
  height: 56px;
  min-height: 56px;
  display: block;
  margin: 0 auto;
  flex: 0 0 56px;
}
.eval-card svg .vehicle {
  fill: #ffffff;
  stroke: #0f172a;
  stroke-width: 2;
}
.eval-card svg .ws {
  fill: #2563eb;
}
.eval-card svg .wd,
.eval-card svg .wd-track {
  fill: #16a34a;
}
.eval-card svg .caster {
  fill: #9ca3af;
}
.eval-card svg .arrow {
  stroke: #0f172a;
  stroke-width: 2;
  fill: none;
}
.eval-card h4 {
  margin: 6px 0 2px;
  font-size: 13px;
  text-align: center;
}
.eval-card p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.eval-card.winner {
  border-color: #1f6feb;
  background: #eef5ff;
}

.gantt {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: #fff;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 10px rgba(11, 18, 32, 0.04);
  --gantt-day: 12px;
  --gantt-major: 84px;
}

.gantt-header {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.gantt-header-major,
.gantt-header-days {
  display: grid;
  grid-auto-flow: column;
}

.gantt-header-major div {
  padding: 8px 10px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
  color: #1f2937;
}

.gantt-header-days {
  border-top: 1px solid #dbe3ee;
}

.gantt-header-days div {
  text-align: center;
  padding: 4px 0;
  border-right: 1px solid #e4eaf3;
  color: #334155;
  font-weight: 600;
  font-size: 10px;
}

.gantt-row {
  position: relative;
  height: 32px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.gantt-row:last-child { border-bottom: none; }

.gantt-bars {
  position: relative;
  height: 100%;
  background-image:
    repeating-linear-gradient(
      to right,
      rgba(15, 23, 42, 0.05) 0,
      rgba(15, 23, 42, 0.05) 1px,
      transparent 1px,
      transparent var(--gantt-day)
    ),
    repeating-linear-gradient(
      to right,
      rgba(37, 99, 235, 0.12) 0,
      rgba(37, 99, 235, 0.12) 1px,
      transparent 1px,
      transparent var(--gantt-major)
    );
}

.gantt-bar {
  position: absolute;
  height: 18px;
  top: 7px;
  background: #000;
  border-radius: 6px;
  cursor: grab;
  display: flex;
  align-items: center;
  color: #fff;
  font-size: 10px;
  padding: 0 6px;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(11, 18, 32, 0.25);
}

.gantt-bar.status-offen { background: #6b6b6b; }
.gantt-bar.status-plant { background: #1f6feb; }
.gantt-bar.status-in-arbeit { background: #0f9d58; }
.gantt-bar.status-blockiert { background: #d32f2f; }
.gantt-bar.status-erledigt { background: #2e7d32; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  margin: 6px 0 8px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 2px;
  background: #000;
}
.legend .offen i { background: #6b6b6b; }
.legend .geplant i { background: #1f6feb; }
.legend .arbeit i { background: #0f9d58; }
.legend .blockiert i { background: #d32f2f; }
.legend .erledigt i { background: #2e7d32; }

.gantt-svg {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.gantt-milestone {
  stroke: #111;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.gantt-milestone-label {
  font-size: 10px;
  fill: #111;
}

.gantt-bar .handle {
  width: 6px;
  height: 14px;
  background: #fff;
  opacity: 0.6;
  border-radius: 4px;
  cursor: ew-resize;
}

.gantt-row-label {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 11px;
  color: #111827;
  font-weight: 600;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 6px;
  border-radius: 5px;
}

@media print {
  .gantt { page-break-inside: avoid; }
}

@media print {
  .app-header, .status-bar, .sidebar, .toolbar, .hint, .row-action { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { border: none; }
  table { page-break-inside: avoid; }
}

@media print {
  table.table-notes td { font-size: 12px; }
  .table-notes { border: none; }
  .table-notes tr { page-break-inside: avoid; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
}
