:root {
  --cream: #F8F4EF;
  --forest: #2C3D2E;
  --gold: #C8A96A;
  --earth: #2A1F14;
  --stone: #8B8680;
  --card: #ffffff;
  --good: #3f7d4e;
  --bad: #b4543a;
  --line: #e7ded2;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  background: var(--cream);
  color: var(--earth);
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 28px;
  background: var(--forest);
  color: var(--cream);
}
header.topbar .brand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 24px;
  letter-spacing: 2px;
  font-weight: 600;
}
header.topbar nav { display: flex; gap: 20px; margin-left: auto; }
header.topbar nav a {
  color: var(--cream);
  text-decoration: none;
  opacity: .75;
  font-size: 14px;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
}
header.topbar nav a:hover, header.topbar nav a.active { opacity: 1; border-color: var(--gold); }
header.topbar .logout-link {
  color: var(--cream);
  text-decoration: none;
  opacity: .75;
  font-size: 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
header.topbar .logout-link:hover { opacity: 1; }

main { max-width: 1180px; margin: 0 auto; padding: 28px; }

h1 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; font-size: 30px; margin: 0 0 4px; }
h2 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; font-size: 21px; margin: 0 0 14px; }
.sub { color: var(--stone); font-size: 14px; margin: 0 0 24px; }
.note { font-size: 13px; color: var(--stone); }

select, input, textarea, button {
  font-family: inherit; font-size: 14px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--earth);
  min-height: 44px;
}

/* ---------- Buttons: primär/sekundär ---------- */
button, .btn-primary, .btn-secondary {
  cursor: pointer; font-weight: 500; border-radius: 8px; padding: 10px 18px;
  min-height: 44px; min-width: 44px;
}
button, .btn-primary {
  background: var(--forest); color: var(--cream); border: none;
}
button:hover, .btn-primary:hover { background: #243121; }
.btn-secondary {
  background: #fff; color: var(--forest); border: 1px solid var(--forest);
}
.btn-secondary:hover { background: #f0ebe2; }
button:disabled, .btn-primary:disabled, .btn-secondary:disabled { opacity: .5; cursor: default; }

/* ---------- Reiter (Versand / Retouren) ---------- */
.tabs { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.tab {
  background: #fff; color: var(--forest); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 22px; min-height: 44px; font-weight: 500;
}
.tab.active { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.tab-panel[hidden] { display: none; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 40px; width: 320px; text-align: center;
}
.login-card h1 { font-size: 26px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.warn-box { background: #fbf3e6; border: 1px solid var(--gold); border-radius: 8px; padding: 10px; font-size: 13px; margin-bottom: 8px; }
.error-banner { background: #f7e8e3; border: 1px solid var(--bad); color: var(--bad); border-radius: 8px; padding: 10px; font-size: 13px; margin-bottom: 8px; }

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast { background: var(--forest); color: var(--cream); border-radius: 8px; padding: 10px 16px; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.toast-error { background: var(--bad); }
.toast-success { background: var(--good); }

/* ---------- Versand: Testmodus-Banner ---------- */
.testmodus-banner {
  background: #fbf3e6; border: 1px solid var(--gold); color: var(--earth);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-weight: 600;
  font-size: 15px; text-align: center;
}

.versand-kopf { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.versand-kopf h1 { margin-right: auto; }

/* ---------- Versand: Liste ---------- */
.listen-kopf { display: flex; justify-content: flex-end; margin-bottom: 12px; }

.gruppen-abschnitt { margin-bottom: 26px; }
.gruppen-abschnitt h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; }

.bestellkarte {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.bestellkarte input[type="checkbox"] {
  width: 28px; height: 28px; min-width: 28px; min-height: 28px; margin-top: 2px; accent-color: var(--forest);
}
.bestellkarte-inaktiv { opacity: .55; cursor: default; }
.bestellkarte-inhalt { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.bestellkarte-kopf { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; flex-wrap: wrap; }
.bestellkarte-name { font-size: 16px; }
.bestellkarte-ort { color: var(--stone); font-weight: 500; }
.bestellkarte-artikel { font-size: 14px; word-break: break-word; }
.bestellkarte-gewicht { font-size: 13px; color: var(--stone); }
.bestellkarte-warnung {
  font-size: 13px; color: var(--bad); background: #f7e8e3; border-radius: 6px; padding: 6px 10px;
  margin-top: 4px;
}
.bestellkarte-hinweis {
  font-size: 13px; color: var(--forest); background: var(--cream); border-radius: 6px; padding: 6px 10px;
  margin-top: 4px;
}

/* ---------- Versand: Fortschritt / Ergebnis ---------- */
.fortschritt-bereich, .ergebnis-bereich { margin: 30px 0; }
.ergebnis-buttons { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.btn-gross { padding: 18px 26px; font-size: 17px; border-radius: 12px; text-decoration: none; text-align: center; flex: 1 1 260px; }
a.btn-gross { display: inline-flex; align-items: center; justify-content: center; }
.anleitung { font-size: 14px; color: var(--stone); margin: 4px 0; }

.ergebnis-liste, #ergebnis-liste { margin-top: 16px; }
.ergebnis-zeile {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; background: var(--card);
  border: 1px solid var(--line);
}
.ergebnis-zeile.ergebnis-fehler { background: #f7e8e3; border-color: var(--bad); color: var(--bad); }
.ergebnis-zeile.ergebnis-warnung { background: #fbf3e6; border-color: var(--gold); }
.ergebnis-name { font-weight: 600; }
.ergebnis-info { font-size: 13px; }
.ergebnis-fehler-text { color: var(--bad); }

/* ---------- Versand: Verlauf ---------- */
.verlauf-bereich { margin: 30px 0; }
.verlauf-bereich summary { cursor: pointer; font-weight: 600; font-size: 16px; padding: 10px 0; min-height: 44px; display: flex; align-items: center; }
.verlauf-lauf { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; background: var(--card); }
.verlauf-lauf-kopf { font-weight: 600; margin-bottom: 8px; }
.verlauf-links { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.verlauf-link-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 8px;
  background: var(--cream, #f0ebe2); border: 1px solid var(--line);
  color: var(--forest); font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.verlauf-link-btn:hover { background: #f0ebe2; }
.verlauf-sendung { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 0; }

/* ---------- Versand: Sticky-Hauptbutton ---------- */
.sticky-bar {
  position: sticky; bottom: 0; background: var(--cream); padding: 14px 0 20px;
  border-top: 1px solid var(--line); margin-top: 20px;
}
.sticky-bar button { width: 100%; font-size: 18px; padding: 18px; border-radius: 12px; }

/* ---------- Versand: Dialoge (<dialog>, kein confirm()) ---------- */
dialog {
  border: none; border-radius: 14px; padding: 24px; max-width: 420px; width: calc(100% - 40px);
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; }
.dialog-buttons { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; }
.dialog-buttons button { min-width: 120px; }

/* ---------- Versand: Fehler ---------- */
#versand-fehler { margin-bottom: 18px; }

/* ---------- Retouren: Status-Chip ---------- */
.status-chip {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px;
  background: var(--cream); border: 1px solid var(--line); color: var(--forest);
}
.status-chip-requested { background: #fbf3e6; border-color: var(--gold); color: var(--earth); }
.status-chip-open { background: #e9f2ea; border-color: var(--good); color: var(--good); }

/* ---------- Retouren: Karte ---------- */
.retourenkarte {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.retourenkarte-kopf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; margin-bottom: 6px; }
.retourenkarte-ort { color: var(--stone); font-weight: 500; font-size: 14px; }
.retourenkarte-artikel { font-size: 14px; margin-bottom: 4px; }
.retourenkarte-artikel-zeile { padding: 2px 0; }
.retourenkarte-datum { font-size: 13px; color: var(--stone); margin-bottom: 8px; }
.retourenkarte-aktionen { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.retourenkarte-hinweis {
  font-size: 13px; color: var(--bad); background: #f7e8e3; border-radius: 6px; padding: 6px 10px;
  margin-top: 6px;
}
.retourenkarte-label-info { font-size: 13px; color: var(--stone); }

/* ---------- Retouren: Toggle-Schalter ---------- */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 0; font-size: 14px;
}
.toggle { position: relative; display: inline-block; width: 54px; height: 32px; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-slider {
  position: absolute; inset: 0; background: #d8d0c2; border-radius: 999px; transition: background .15s;
  pointer-events: none;
}
.toggle-slider::before {
  content: ""; position: absolute; height: 26px; width: 26px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle input:checked + .toggle-slider { background: var(--good); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ---------- Retouren: Mengen-Stepper ---------- */
.positions-zeile {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.positions-titel { flex: 1 1 100%; font-weight: 600; }
.positions-verfuegbar { font-size: 12px; color: var(--stone); flex: 1 1 100%; margin-top: -6px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  min-width: 44px; min-height: 44px; border-radius: 8px; font-size: 20px; padding: 0;
  background: var(--forest); color: var(--cream); border: none;
}
.stepper-wert { min-width: 32px; text-align: center; font-weight: 600; font-size: 16px; }
.positions-grund { flex: 1 1 220px; min-width: 160px; }

/* ---------- Retouren: Suche ---------- */
.suche-zeile { display: flex; gap: 10px; margin-bottom: 14px; }
.suche-zeile input[type="search"] { flex: 1; }
.suchtreffer {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  background: var(--card);
}
.suchtreffer:hover { background: #f0ebe2; }
.suchtreffer-info { display: flex; flex-direction: column; gap: 2px; }
.suchtreffer-name { font-weight: 600; }
.suchtreffer-details { font-size: 13px; color: var(--stone); }

/* ---------- Retouren: großer Dialog (Neue Retoure) ---------- */
dialog.dialog-gross { max-width: 640px; }
.feld-label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
#neu-notiz { width: 100%; font-family: inherit; }

/* ---------- Retouren: Spinner ---------- */
.spinner-row[hidden] { display: none; }
.spinner-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--stone); margin: 10px 0; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--forest); animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Retouren: Ergebnis-Dialog ---------- */
.ergebnis-erfolg { color: var(--good); font-weight: 600; }
.ergebnis-hinweis { font-size: 14px; color: var(--stone); margin-top: 8px; }
