:root {
  --red: #c8102e;
  --red-dark: #9c0c23;
  --bg: #f2f3f5;
  --card: #ffffff;
  --border: #dcdfe3;
  --text: #23272b;
  --muted: #6b7280;
  --yellow: #fff176;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--red-dark); }

.topbar {
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-logo { height: 42px; border-radius: 4px; background: #fff; padding: 2px; }
.brand-sub { font-size: 0.95rem; opacity: 0.9; }
.nav-logout { background: none; border: none; color: #fff; text-decoration: underline; cursor: pointer; font-size: 0.9rem; padding: 0.4rem 0.6rem; }
.nav-logout:hover { background: rgba(255,255,255,0.2); }

.topnav { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.topnav a {
  color: #fff;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.topnav a:hover, .topnav a.active { background: rgba(255,255,255,0.2); }

.content { padding: 1rem 1.2rem 3rem; max-width: 1500px; margin: 0 auto; }

h2 { margin-top: 0; }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: -0.4rem; }

/* buttons */
.btn, button, summary.btn {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover, button:hover { background: #f0f0f0; }
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); }
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; }
.btn-danger { color: var(--red-dark); }
.btn-icon, .btn-icon-sm {
  background: none; border: none; cursor: pointer; font-size: 0.95rem; color: var(--muted);
}
.btn-icon-sm { font-size: 0.8rem; }
.btn-icon:hover, .btn-icon-sm:hover { color: var(--red-dark); }
.btn-nav {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.3rem 0.7rem; text-decoration: none; color: var(--text);
}

summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }

.dropdown-details { position: relative; display: inline-block; }
.dropdown-details > summary { list-style: none; }
.popover-form {
  position: absolute; z-index: 20; top: 110%; left: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.7rem; display: flex; flex-direction: column; gap: 0.4rem; min-width: 220px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.popover-form input, .popover-form select { padding: 0.3rem; }

/* plan bar */
.planbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.6rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.6rem 0.9rem; margin-bottom: 1rem;
}
.planbar-datum { display: flex; align-items: center; gap: 0.5rem; }
.datum-label { font-weight: 600; margin-left: 0.4rem; }
.planbar-aktionen { display: flex; gap: 0.5rem; align-items: center; }
.inline-form { display: inline; }

/* plan layout */
.plan-page .content { max-width: none; }
.plan-layout { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; align-items: start; }
.plan-sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
@media (max-width: 900px) { .plan-layout { grid-template-columns: 1fr; } }

.site-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; grid-column: span 1;
}
.site-box.site-liste { background: #fafbfc; }

.site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.4rem; }
.site-head h3 { margin: 0.1rem 0 0.3rem; font-size: 1.05rem; flex: 1; }
.site-head h3 .plz { color: var(--red-dark); font-weight: 700; margin-right: 0.3rem; }
.site-head-actions { display: flex; gap: 0.2rem; flex-shrink: 0; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.1rem; padding: 0 0.3rem; user-select: none; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.site-box.dragging { opacity: 0.4; }
.sortable-list li[draggable="true"] { cursor: grab; }
.sortable-list li.dragging { opacity: 0.4; }
.sortable-list { min-height: 1.6rem; }

.zeit-badge {
  display: inline-block; background: #ffb74d; color: #4a2c00; font-weight: 600;
  padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; margin-bottom: 0.5rem;
}

.zeilen-tabelle { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-bottom: 0.4rem; }
.zeilen-tabelle th { text-align: left; font-size: 0.75rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); padding: 0.2rem 0.4rem; }
.zeilen-tabelle td { padding: 0.25rem 0.4rem; border-bottom: 1px solid #eef0f2; vertical-align: top; }
.zeilen-tabelle td.hl { background: var(--yellow); }

.zeilen-liste { list-style: none; margin: 0 0 0.4rem; padding: 0; font-size: 0.88rem; }
.zeilen-liste li { display: flex; justify-content: space-between; align-items: center; padding: 0.15rem 0.2rem; border-bottom: 1px solid #eef0f2; }
.zeilen-liste li.hl { background: var(--yellow); }
.hl-toggle { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.8rem; line-height: 1; padding: 0 0.15rem; }
.hl-toggle.aktiv { color: #f2b400; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.35rem; }

details.add-row-details, details.add-site-details, details.add-details { margin-top: 0.4rem; }
details.add-row-details summary, details.add-site-details summary { font-size: 0.85rem; color: var(--red-dark); }

.row-form, .site-form, .entity-form {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.5rem;
  background: #f7f8fa; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem;
}
.row-form input, .row-form select, .site-form input, .site-form select, .entity-form input, .entity-form select {
  padding: 0.35rem 0.4rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
}
.hl-check { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 0.2rem; }
.oder { font-size: 0.8rem; color: var(--muted); }

/* kolonnen */
.kolonne-box {
  border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.6rem;
  margin-bottom: 0.6rem; background: #fbfbfc;
}
.kolonne-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.kolonne-titel { font-weight: 700; color: var(--red-dark); }
.maschinen-label { font-size: 0.75rem; color: var(--muted); font-weight: 600; margin: 0.3rem 0 0.1rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; width: 100%; max-width: 360px; text-align: center;
}
.login-logo { max-width: 220px; margin-bottom: 1rem; }
.login-form { display: flex; flex-direction: column; gap: 0.6rem; text-align: left; margin-top: 1rem; }
.login-form label { font-size: 0.85rem; color: var(--muted); }
.login-form input { padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; }
.login-form button { margin-top: 0.5rem; }
.zurueck { display: block; margin-top: 1rem; font-size: 0.85rem; }
.fehler { color: var(--red-dark); font-weight: 600; }
.erfolg { color: #2e7d32; font-weight: 600; }

/* sidebar */
.sidebar { display: flex; flex-direction: column; gap: 0.8rem; }
.side-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.9rem; }
.side-box h4 { margin: 0 0 0.4rem; color: var(--red-dark); }
.side-box ul { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; }
.side-box .leer { color: var(--muted); font-size: 0.85rem; margin: 0; }
.side-box.status-drop-zone.drop-hover { outline: 2px dashed var(--red); outline-offset: 2px; background: #fff4f2; }
.sortable-list.drop-hover-list { outline: 2px dashed var(--red); outline-offset: 2px; background: #fff4f2; border-radius: 4px; }
.datum-klein { color: var(--muted); font-size: 0.78rem; }

/* entity tables (mitarbeiter/gruppen/baustellen) */
.entity-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.entity-table th, .entity-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.entity-table th { text-align: left; background: #f7f8fa; }
.entity-table input, .entity-table select { padding: 0.3rem; border: 1px solid var(--border); border-radius: 6px; width: 100%; }
.entity-table tr.inactive-row { opacity: 0.5; }
.row-actions { display: flex; gap: 0.3rem; white-space: nowrap; }

.mitarbeiter-toolbar { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.7rem; position: sticky; top: 0; background: var(--bg); padding: 0.4rem 0; z-index: 5; }
.mitarbeiter-toolbar .suche-feld { flex: 0 1 320px; padding: 0.45rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; }
.mitarbeiter-toolbar .hint { margin: 0; }

/* print view - alles auf eine A3-Seite: Mehrspalten-Fluss statt Grid, damit
   unterschiedlich hohe Boxen keinen Platz verschwenden (kein zeilenweises Raster). */
.print-body { background: #fff; padding: 5mm; font-size: 12.6pt; }
.print-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 2.5px solid var(--red); padding-bottom: 0.15rem; margin-bottom: 0.3rem; }
.print-header-left { text-align: left; }
.print-header-center { text-align: center; }
.print-logo { width: 425px; height: auto; }
.print-title { font-size: 22.3pt; }
.print-header-right { text-align: right; }
.print-datum { font-weight: 600; font-size: 13.1pt; }
.print-zeit-badge { display: inline-block; background: #ffb74d; color: #4a2c00; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 13.8pt; margin-top: 0.2rem; }
.druck-aktionen { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.ausrichtung-umschalter { display: flex; gap: 0.3rem; }

.print-grid { columns: 8; column-gap: 2.8mm; }
.print-body.portrait .print-grid { columns: 5; }
.print-site-block {
  break-inside: avoid; margin-bottom: 2mm;
  border: 2.6px solid var(--red-dark); border-radius: 3px; padding: 0.7mm 1.3mm;
}
.print-site-block .print-box { border: none; padding: 0; margin-bottom: 0.4mm; }
.print-site-block .print-box + .print-box { border-top: 1px solid #999; padding-top: 0.6mm; margin-top: 0.5mm; }
.print-box { border: 1px solid #999; border-radius: 3px; padding: 0.6mm 1.2mm; break-inside: avoid; margin-bottom: 1mm; }
.print-box-head { font-weight: 700; margin-bottom: 0.2mm; font-size: 15.5pt; line-height: 1.0; }
.print-kostenstelle { color: var(--red-dark); margin-right: 0.3em; }
.print-side { background: #fafafa; }

.print-body .zeilen-tabelle { font-size: 10.7pt; margin-bottom: 0; }
.print-body .zeilen-tabelle td { padding: 0.1mm 0.5mm; line-height: 1.0; }
.print-body .zeilen-liste { font-size: 10.7pt; margin-bottom: 0; }
.print-body .zeilen-liste li { padding: 0.2mm 0.3mm; line-height: 1.08; flex-wrap: wrap; row-gap: 0.1mm; }

.print-body, .print-body * {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

@media print {
  .no-print { display: none; }
  body { padding: 0; }
}
