:root {
  --bg: #f4f5f7;
  --karte: #ffffff;
  --text: #1c2330;
  --text-2: #5d6675;
  --linie: #dfe2e8;
  --akzent: #1f3a68;
  --akzent-hell: #e8edf6;
  --gruen: #1d7a46;
  --gruen-hell: #e3f3e9;
  --rot: #b42318;
  --rot-hell: #fdeceb;
  --gelb: #8a5a00;
  --gelb-hell: #fff4d6;
  --radius: 8px;
  --schatten: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }

header#kopf {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--karte); border-bottom: 1px solid var(--linie); position: sticky; top: 0; z-index: 10;
}
.marke { display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.marke img { height: 28px; max-width: 120px; object-fit: contain; }
#aussteller-wahl { width: auto; max-width: 260px; font-weight: 600; border-color: transparent; background: transparent; padding: 6px 8px; cursor: pointer; }
#aussteller-wahl:hover { border-color: var(--linie); background: var(--bg); }
body.mandant #aussteller-wahl { background: #fff3e0; border-color: #f0b46a; color: #8a4b00; }
#mandant-balken {
  background: #fff3e0; color: #8a4b00; border-bottom: 1px solid #f0b46a; padding: 8px 24px; font-size: 13px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; top: 56px; z-index: 9;
}
#mandant-balken button { padding: 3px 10px; font-size: 13px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { padding: 8px 12px; border-radius: 6px; color: var(--text-2); text-decoration: none; white-space: nowrap; }
nav a:hover { background: var(--bg); color: var(--text); }
nav a.aktiv { background: var(--akzent-hell); color: var(--akzent); font-weight: 600; }
.benutzer { position: relative; }
.menue {
  position: absolute; right: 0; top: 36px; background: var(--karte); border: 1px solid var(--linie);
  border-radius: var(--radius); box-shadow: var(--schatten); padding: 6px; min-width: 200px; display: flex; flex-direction: column;
}
.menue a, .menue button { padding: 8px 10px; text-align: left; border-radius: 4px; color: var(--text); text-decoration: none; }
.menue a:hover, .menue button:hover { background: var(--bg); }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.titelzeile { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.titelzeile .rechts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--schatten); }
.gedimmt { color: var(--text-2); }
.klein { font-size: 12px; }

button, .knopf {
  font: inherit; border: 1px solid var(--linie); background: var(--karte); color: var(--text);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
button:hover, .knopf:hover { background: var(--bg); }
button.primaer, .knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; }
button.primaer:hover { filter: brightness(1.1); }
button.gefahr { color: var(--rot); }
button.gefahr:hover { background: var(--rot-hell); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--akzent); }
button:disabled { opacity: .5; cursor: default; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
input, select, textarea {
  font: inherit; color: var(--text); border: 1px solid var(--linie); border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%;
}
select { max-width: 100%; text-overflow: ellipsis; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent-hell); border-color: var(--akzent); }
textarea { resize: vertical; min-height: 60px; }
input[type=checkbox] { width: auto; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.raster .breit { grid-column: 1 / -1; }
.raster .zwei { grid-column: span 2; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--linie); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--linie); vertical-align: top; }
tr.klickbar { cursor: pointer; }
tr.klickbar:hover td { background: #fafbfc; }
td.zahl, th.zahl { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabelle-rahmen { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.entwurf { background: #eef0f3; color: var(--text-2); }
.badge.offen { background: var(--gelb-hell); color: var(--gelb); }
.badge.ueberfaellig { background: var(--rot-hell); color: var(--rot); }
.badge.bezahlt { background: var(--gruen-hell); color: var(--gruen); }
.badge.storniert, .badge.storno { background: #f0eef6; color: #5b4b8a; }

.kennzahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kennzahl { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--schatten); }
.kennzahl .wert { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kennzahl .wert.rot { color: var(--rot); }

.filter { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter input { max-width: 280px; }
.filter select { width: auto; }

/* Positionen */
.positionen td { padding: 6px 4px; }
.positionen input, .positionen textarea { padding: 5px 7px; }
.positionen textarea { min-height: 34px; height: 34px; min-width: 220px; }
.positionen .c-menge { width: 80px; }
.positionen .c-einheit { width: 90px; }
.positionen .c-artnr { width: 100px; }
.positionen .c-preis { width: 120px; }
.positionen .c-ust { width: 80px; }
.positionen .c-gesamt { width: 110px; }
.positionen .c-aktion { width: 70px; white-space: nowrap; }
.summen { margin-left: auto; width: 340px; max-width: 100%; margin-top: 12px; }
.summen div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.summen .gesamt { font-weight: 700; border-top: 1px solid var(--linie); margin-top: 4px; padding-top: 8px; font-size: 16px; }

.hinweisbox { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.hinweisbox.fehler { background: var(--rot-hell); color: var(--rot); }
.hinweisbox.warnung { background: var(--gelb-hell); color: var(--gelb); }
.hinweisbox.info { background: var(--akzent-hell); color: var(--akzent); }
.hinweisbox ul { margin: 6px 0 0; padding-left: 20px; }

.anmeldung { max-width: 380px; margin: 10vh auto; }
.anmeldung form { display: flex; flex-direction: column; gap: 12px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2330; color: #fff;
  padding: 10px 16px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; max-width: 90vw;
}
#toast.sichtbar { opacity: 1; }
#toast.fehler { background: var(--rot); }

dialog { border: 0; border-radius: 10px; padding: 0; width: min(720px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog .dialog-kopf { padding: 16px 20px; border-bottom: 1px solid var(--linie); font-weight: 600; font-size: 16px; }
dialog .dialog-inhalt { padding: 18px 20px; max-height: 70vh; overflow: auto; }
dialog .dialog-fuss { padding: 12px 20px; border-top: 1px solid var(--linie); display: flex; justify-content: flex-end; gap: 8px; }

.logo-vorschau { border: 1px dashed var(--linie); border-radius: var(--radius); padding: 12px; display: flex; align-items: center; justify-content: center; min-height: 90px; background: #fafbfc; }
.logo-vorschau img { max-height: 80px; max-width: 100%; }
.konto { display: grid; grid-template-columns: 1.2fr 1.6fr 1fr auto auto; gap: 8px; align-items: end; margin-bottom: 8px; }

.eingang-detail .parteien { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.eingang-detail pre { white-space: pre-wrap; margin: 0; font: inherit; }

@media (max-width: 720px) {
  header#kopf { padding: 0 12px; gap: 10px; }
  #aussteller-wahl { max-width: 150px; }
  #kopf-logo { display: none; }
  #mandant-balken { padding: 8px 12px; }
  main { padding: 16px; }
  .konto { grid-template-columns: 1fr 1fr; }
  .eingang-detail .parteien { grid-template-columns: 1fr; }
  .raster .zwei { grid-column: auto; }
}
