:root {
  --accent: #1f4e79;
  --accent-hover: #163a58;
  --accent-light: #dce6f1;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #222;
  --muted: #666;
  --red: #b3261e;
  --yellow: #8a6d00;
  --green: #1e7d32;
  --border: #ddd;
  --phase-anreise: #ffcc80;
  --phase-aufbau: #a5d6a7;
  --phase-veranstaltung: #ef5350;
  --phase-abbau: #66bb6a;
  --phase-abreise: #ffe082;
}
[data-theme="dunkel"] {
  --bg: #1a1d21;
  --surface: #24282d;
  --surface-2: #2c3136;
  --text: #e8e8e8;
  --muted: #9aa0a6;
  --border: #3a3f45;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.proto-tag { font-size: 11px; background: rgba(255,255,255,.2); padding: 2px 6px; border-radius: 4px; margin-left: 6px; }
.topbar nav { display: flex; gap: 16px; flex: 1; align-items: center; }
.topbar nav a { color: white; opacity: .9; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }

.nav-group { position: relative; padding: 4px 0; }
.nav-group-label { cursor: pointer; opacity: .9; user-select: none; color: white; display: inline-block; padding: 4px 0; }
.nav-group:hover .nav-group-label, .nav-group:focus-within .nav-group-label { opacity: 1; text-decoration: underline; }
.nav-dropdown {
  display: none;
  position: absolute; top: 100%; left: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); min-width: 220px;
  /* Kein margin-top-Abstand zum Label - sonst schliesst sich das Dropdown beim
     Ueberqueren der Luecke, bevor die Maus einen Menuepunkt erreicht. Der
     optische Abstand kommt stattdessen aus padding-top (bleibt Teil der
     hoverbaren Flaeche). */
  padding: 10px 0 6px 0; margin-top: 0;
}
.nav-group:hover .nav-dropdown, .nav-group:focus-within .nav-dropdown { display: block; }
.nav-dropdown a { display: block; color: var(--text) !important; opacity: 1; padding: 8px 14px; font-size: 14px; }
.nav-dropdown a:hover { background: var(--accent-light); text-decoration: none; }

.back-link { margin-bottom: 10px; }
.back-link a { color: var(--muted); font-size: 13px; }

.subnav {
  background: var(--accent-light); border-bottom: 1px solid var(--border);
  padding: 6px 24px; display: flex; gap: 4px; flex-wrap: wrap;
}
.subnav a {
  color: var(--text); font-size: 13px; padding: 5px 10px; border-radius: 5px; opacity: .85;
}
.subnav a:hover { opacity: 1; background: rgba(255,255,255,.15); text-decoration: none; }
.subnav a.active { background: var(--surface); font-weight: 600; opacity: 1; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.userbox { font-size: 13px; opacity: .95; }
.userbox a { color: white; }
.role-badge { background: rgba(255,255,255,.2); padding: 1px 6px; border-radius: 4px; font-size: 11px; }

.content { max-width: 1100px; margin: 24px auto; padding: 0 16px 48px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

h1 { font-size: 24px; margin-bottom: 4px; }
h2 { font-size: 18px; color: var(--accent); margin-top: 32px; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card.warn .num { color: var(--red); }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: var(--accent-light); color: var(--accent); font-weight: 600; }
tr:hover td { background: var(--surface-2); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: white; color: var(--red); border: 1px solid var(--red); }
.btn.small { padding: 4px 10px; font-size: 12px; }

form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
form .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge-green { background: #e3f4e5; color: var(--green); }
.badge-yellow { background: #fff5da; color: var(--yellow); }
.badge-red { background: #fbe4e2; color: var(--red); }
.badge-gray { background: #eee; color: #555; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash-ok { background: #e3f4e5; color: var(--green); }
.flash-error { background: #fbe4e2; color: var(--red); }

.login-bg { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 32px; width: 340px; }
.login-box h1 { text-align: center; color: var(--accent); }
.login-box button { width: 100%; margin-top: 8px; }
.hint { margin-top: 20px; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 10px; border-radius: 6px; line-height: 1.6; }

.article-img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; background: #eee; }
.detail-grid { display: grid; grid-template-columns: 200px 1fr; row-gap: 10px; column-gap: 16px; font-size: 14px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }

.empty-state { color: var(--muted); font-style: italic; padding: 24px; text-align: center; }

/* Formular-/Detail-Reiter (angelehnt an Epirent: Artikel/Miete/Verkauf/Lieferanten) */
.form-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.form-tab-btn {
  background: none; border: none; padding: 9px 16px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  font-family: inherit;
}
.form-tab-btn:hover { color: var(--accent); }
.form-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.form-tab-panel { display: none; }
.form-tab-panel.active { display: block; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; }
.checkbox-row label { margin: 0; }

/* Grafische Lagerübersicht */
.warehouse-overview { display: flex; flex-wrap: wrap; gap: 18px; margin: 20px 0; align-items: flex-start; }
.rack-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; min-width: 240px; max-width: 340px; flex: 1 1 260px;
}
.rack-card h3 { margin: 0 0 10px; color: var(--accent); }
.level-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.level-label { width: 68px; flex-shrink: 0; font-size: 12px; color: var(--muted); }
.slot-row { display: flex; flex-wrap: wrap; gap: 6px; }
.slot-chip {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 44px; height: 38px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 10px; color: var(--text);
}
.slot-chip .slot-name { line-height: 1.2; }
.slot-chip .count { font-weight: 700; font-size: 12px; color: var(--accent); }
.slot-chip.occupied { background: var(--accent-light); border-color: var(--accent); }
.rack-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.rack-rename { display: flex; gap: 6px; margin-bottom: 10px; }
.rack-rename input { padding: 4px 6px; font-size: 14px; font-weight: 600; }
.wh-rename { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.wh-rename input { padding: 6px 8px; }
.add-rack-card { border: 2px dashed var(--border); background: var(--surface-2); }
.add-rack-card label { margin-bottom: 8px; }
.add-rack-card input { padding: 6px 8px; }

.btn.secondary.active { background: var(--accent); color: white; }

/* Kalender: Gantt-artige Monatsansicht mit farbcodierten Projektphasen */
/* table-layout:fixed + <colgroup> (siehe routes_calendar.py) sorgen dafuer,
   dass die Tagesspalten IMMER gleich schmal bleiben, egal wie viel Text in
   einer einzelnen Gantt-Zelle steht - langer Text wird abgeschnitten
   (text-overflow: ellipsis), statt die komplette Tabelle in die Breite zu
   ziehen. Horizontales Scrollen der Tabelle bleibt ueber den umschliessenden
   Container mit overflow-x:auto moeglich. */
.gantt-table { font-size: 12px; table-layout: fixed; border-collapse: collapse; }
.gantt-table th, .gantt-table td {
  padding: 2px 3px; text-align: center; white-space: nowrap; overflow: hidden;
  border: 1px solid var(--border);
}
.gantt-label { text-align: left !important; white-space: nowrap; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.gantt-daycell { font-size: 11px; color: var(--muted); }
.gantt-daycell.weekend { background: #fbe4e2; color: var(--red); }
/* Kompakte Zeilen im Excel-Vorbild: schmale Zeilenhoehe, Text darf ueber
   nachfolgende leere (phase-none) Zellen "ueberlaufen" statt abgeschnitten zu
   werden - dafuer braucht .gantt-cell hoehere Spezifitaet als die generische
   Zellregel oben (overflow: hidden) und einen z-index, damit der Text ueber
   die Hintergrundfarbe der folgenden Zelle gezeichnet wird. Duenne Gitterlinien
   (border: 1px solid var(--border)) auf jeder Zelle - genau wie im
   Excel-Vorbild des Nutzers - trennen Zeilen UND Tagesspalten optisch klar
   voneinander, auch wenn Text ueber die Zellgrenze hinauslaeuft. */
.gantt-table td.gantt-cell {
  height: 16px; font-size: 10.5px; font-weight: 600; color: #222;
  overflow: visible; text-overflow: clip; text-align: left; padding-left: 4px;
  position: relative;
}
.gantt-table td.gantt-cell > * { position: relative; z-index: 2; }
/* Zwischen zwei Projekt-/Mitarbeiter-Gruppen eine etwas kraeftigere Linie
   (analog zu einer staerkeren Excel-Zeilenlinie zwischen Datenbloecken). */
.gantt-table tr.gantt-group-start > td { border-top: 2px solid var(--accent); }
.gantt-overflow-link { color: inherit; text-decoration: none; }
.gantt-overflow-link:hover { text-decoration: underline; }
.phase-anreise { background: var(--phase-anreise); }
.phase-aufbau { background: var(--phase-aufbau); }
.phase-veranstaltung { background: var(--phase-veranstaltung); color: white; }
.phase-abbau { background: var(--phase-abbau); }
.phase-abreise { background: var(--phase-abreise); }
.phase-sonstig { background: #cfd8dc; }
.phase-none { background: transparent; }

.brand-logo { height: 28px; vertical-align: middle; margin-right: 6px; border-radius: 4px; }
.mode-toggle {
  background: rgba(255,255,255,.15); border: none; color: white; cursor: pointer;
  border-radius: 6px; padding: 4px 10px; font-size: 13px;
}
.mode-toggle:hover { background: rgba(255,255,255,.28); }

/* Grundeinstellungen: Seitenleiste mit Unterpunkten */
.settings-layout { display: flex; gap: 24px; align-items: flex-start; }
.settings-sidebar { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-sidebar a {
  display: block; padding: 9px 12px; border-radius: 6px; font-size: 14px; color: var(--text);
}
.settings-sidebar a:hover { background: var(--accent-light); text-decoration: none; }
.settings-sidebar a.active { background: var(--accent); color: white; font-weight: 600; }
.settings-content { flex: 1; min-width: 0; }
@media (max-width: 760px) {
  .settings-layout { flex-direction: column; }
  .settings-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
}

/* Sammelaktionen in Tabellenansichten (Checkbox-Auswahl + Bulk-Aktion) */
.bulk-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-light); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px;
}
.bulk-toolbar select, .bulk-toolbar input { width: auto; margin: 0; }

/* Material-Shop-Buchungsseite */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.shop-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.shop-card img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.shop-card .name { font-weight: 600; margin: 8px 0 2px; font-size: 14px; }
.shop-card .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.shop-cart { position: sticky; top: 12px; }
.scan-box { display: flex; gap: 8px; align-items: center; background: var(--accent-light); padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.scan-box input { width: auto; flex: 1; margin: 0; }

@media print {
  .topbar, .footer, .no-print { display: none !important; }
}

/* Mobile Inventur-Scan-Seite: eigene, schlanke Vollbild-Ansicht */
body.scan-body { margin: 0; background: var(--bg); }
.scan-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent); color: white; padding: 12px 16px; font-size: 15px;
}
.scan-report-link { color: white; opacity: .9; font-size: 13px; }
.scan-main { max-width: 480px; margin: 0 auto; padding: 16px; }
.scan-counts {
  display: flex; justify-content: space-around; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 14px;
  font-size: 13px; color: var(--muted); text-align: center;
}
.scan-counts strong { display: block; font-size: 22px; color: var(--accent); }
.scan-counts .scan-count-warn strong { color: var(--red); }
.scan-video-wrap { border-radius: 8px; overflow: hidden; margin-bottom: 10px; background: #000; }
.scan-video-wrap video { width: 100%; display: block; max-height: 260px; object-fit: cover; }
.scan-manual-form { display: flex; gap: 8px; margin-bottom: 14px; }
.scan-manual-form input { flex: 1; font-size: 16px; padding: 12px; margin: 0; }
.scan-manual-form button { padding: 0 18px; }
.scan-result {
  border-radius: 8px; padding: 16px; font-size: 15px; font-weight: 600; text-align: center;
  margin-bottom: 10px; min-height: 20px;
}
.scan-result-idle { background: var(--surface-2); color: var(--muted); font-weight: 400; }
.scan-result-ok { background: #e3f4e5; color: var(--green); }
.scan-result-warn { background: #fff5da; color: var(--yellow); }
.scan-result-dup { background: #eee; color: #555; }
.scan-result-error { background: #fbe4e2; color: var(--red); }

/* Digitale Unterschrift: Erfassungs-Modal (Canvas) auf der Job-Seite */
.wws-sig-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.wws-sig-box {
  background: var(--surface); border-radius: 10px; padding: 20px; max-width: 640px; width: 92%;
}
.wws-sig-box h3 { margin-top: 0; }
#wws-sig-canvas {
  width: 100%; height: 180px; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; touch-action: none; cursor: crosshair;
}
.wws-sig-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.wws-sig-actions input { flex: 1; min-width: 160px; margin: 0; }

/* Inventur: QR-Code zur mobilen Scan-Seite */
.qr-box { display: flex; justify-content: center; padding: 10px; background: #fff; border-radius: 8px; max-width: 260px; }
.qr-box svg { width: 100%; height: auto; }
