:root {
  --gruen: #1f6f3d;
  --gruen-hell: #e8f3ec;
  --gruen-dunkel: #17542e;
  --text: #16181d;
  --text-leise: #6b7280;
  --text-sehr-leise: #9ca3af;
  --grund: #f6f7f8;
  --flaeche: #ffffff;
  --rand: #e3e5e9;
  --rand-stark: #cbd0d8;
  --rot: #b42318;
  --rot-hell: #fdeceb;
  --gelb: #b45309;
  --gelb-hell: #fef4e6;
  --blau: #1d4ed8;
  --blau-hell: #eaf0fe;
  --schatten: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--grund);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gruen); }

/* ---------------------------------------------------------------- Gerüst */
#app { display: flex; min-height: 100vh; align-items: flex-start; }

nav.seitenleiste {
  width: 208px; flex: 0 0 208px;
  background: var(--flaeche);
  border-right: 1px solid var(--rand);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.marke {
  display: flex; align-items: center; gap: 9px;
  padding: 0 8px 18px; font-weight: 650; font-size: 15px; letter-spacing: -.01em;
}
.marke .logo {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--gruen); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
nav.seitenleiste a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 13.5px;
}
nav.seitenleiste a[hidden] { display: none; }
nav.seitenleiste .abschnitt[hidden] { display: none; }
nav.seitenleiste a:hover { background: var(--grund); }
nav.seitenleiste a.aktiv { background: var(--gruen-hell); color: var(--gruen-dunkel); font-weight: 550; }
nav.seitenleiste a .zeichen { width: 17px; text-align: center; opacity: .8; font-size: 14px; }
nav.seitenleiste .abschnitt {
  padding: 16px 9px 5px; font-size: 10.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-sehr-leise);
}
nav.seitenleiste .fuss { margin-top: auto; padding: 12px 9px 0; font-size: 11px; color: var(--text-sehr-leise); }

main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1280px; }
.kopf { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.kopf h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.kopf .unterzeile { margin: 3px 0 0; color: var(--text-leise); font-size: 13px; }
.kopf .aktionen { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------- Bausteine */
.karte {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); box-shadow: var(--schatten);
}
.karte + .karte { margin-top: 16px; }
.karte > h2 {
  margin: 0; padding: 13px 16px; font-size: 14px; font-weight: 620;
  border-bottom: 1px solid var(--rand);
  display: flex; align-items: center; gap: 10px;
}
.karte > h2 .rechts { margin-left: auto; font-weight: 400; font-size: 12.5px; color: var(--text-leise); }
.karte .inhalt { padding: 16px; }

.gitter { display: grid; gap: 14px; }
.gitter.vier { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.gitter.zwei { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kennzahl { padding: 15px 16px; }
.kennzahl .titel { font-size: 12px; color: var(--text-leise); margin-bottom: 6px; }
.kennzahl .wert { font-size: 25px; font-weight: 640; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kennzahl .hinweis { font-size: 11.5px; color: var(--text-sehr-leise); margin-top: 4px; }
.kennzahl.warn .wert { color: var(--rot); }
.kennzahl.gut .wert { color: var(--gruen); }

/* --------------------------------------------------------------- Knöpfe */
button, .knopf {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 6px; border: 1px solid var(--rand-stark);
  background: var(--flaeche); cursor: pointer; font-size: 13px; font-weight: 500;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
button:hover, .knopf:hover { background: var(--grund); }
button.primaer, .knopf.primaer {
  background: var(--gruen); border-color: var(--gruen); color: #fff;
}
button.primaer:hover, .knopf.primaer:hover { background: var(--gruen-dunkel); }
button.gefahr { color: var(--rot); border-color: #f3c9c5; }
button.gefahr:hover { background: var(--rot-hell); }
button.leise { border-color: transparent; background: transparent; color: var(--text-leise); padding: 5px 8px; }
button.leise:hover { background: var(--grund); color: var(--text); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.klein, .knopf.klein { padding: 4px 9px; font-size: 12px; }

/* -------------------------------------------------------------- Formular */
.feld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.feld > label { font-size: 12px; font-weight: 550; color: var(--text-leise); }
.feld > .hinweis { font-size: 11.5px; color: var(--text-sehr-leise); }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
  padding: 7px 10px; border: 1px solid var(--rand-stark); border-radius: 6px;
  background: var(--flaeche); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gruen-hell); outline-offset: -1px; border-color: var(--gruen);
}
textarea { resize: vertical; min-height: 62px; line-height: 1.45; }
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
.feldreihe { display: grid; gap: 13px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.feldreihe.eng { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
label.schalter { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
label.schalter input { width: auto; }

/* --------------------------------------------------------------- Tabelle */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--text-leise);
  padding: 9px 12px; border-bottom: 1px solid var(--rand);
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--rand); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr.klickbar:hover { background: var(--grund); cursor: pointer; }
.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dick { font-weight: 600; }
.leise { color: var(--text-leise); }
.klein { font-size: 12px; }
.nummer { font-variant-numeric: tabular-nums; font-weight: 550; }

.marke-status {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap;
}
.status-entwurf { background: #eef0f3; color: #4b5563; }
.status-offen { background: var(--blau-hell); color: var(--blau); }
.status-teilbezahlt { background: var(--gelb-hell); color: var(--gelb); }
.status-bezahlt { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.status-ueberfaellig { background: var(--rot-hell); color: var(--rot); }
.status-storniert { background: #eef0f3; color: var(--text-sehr-leise); text-decoration: line-through; }
.status-verschickt_angebot { background: var(--blau-hell); color: var(--blau); }
.status-angenommen { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.status-abgelehnt { background: #eef0f3; color: var(--text-leise); }

.filterleiste {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--rand);
}
.filterleiste input[type=text] { max-width: 240px; }
.filterleiste select { width: auto; min-width: 120px; }

.leerzustand { padding: 44px 20px; text-align: center; color: var(--text-leise); }
.leerzustand .gross { font-size: 15px; color: var(--text); margin-bottom: 6px; font-weight: 550; }

/* --------------------------------------------------------------- Balken */
.balken { display: flex; align-items: flex-end; gap: 5px; height: 130px; padding: 0 2px; }
.balken .saeule { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; }
.balken .stab { background: var(--gruen); border-radius: 3px 3px 0 0; min-height: 2px; transition: .2s; }
.balken .saeule:hover .stab { background: var(--gruen-dunkel); }
.balken .beschriftung { font-size: 10px; text-align: center; color: var(--text-sehr-leise); }

/* -------------------------------------------------------------- Positionen */
.positionen { width: 100%; border-collapse: collapse; }
.positionen th { padding: 6px 8px; }
.positionen td { padding: 5px 6px; border-bottom: 1px solid var(--rand); }
.positionen input, .positionen select, .positionen textarea { padding: 6px 8px; font-size: 13px; }
.positionen textarea { min-height: 34px; font-size: 12.5px; }
.positionen .griff { cursor: grab; color: var(--text-sehr-leise); user-select: none; text-align: center; }
.positionen tr.zieht { opacity: .4; }
.summenblock { margin-left: auto; width: 320px; margin-top: 14px; }
.summenblock .zeile { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.summenblock .zeile.gesamt {
  border-top: 2px solid var(--text); margin-top: 6px; padding-top: 9px;
  font-size: 16px; font-weight: 650;
}

/* --------------------------------------------------------------- Dialog */
.schleier {
  position: fixed; inset: 0; background: rgba(16,24,40,.4);
  display: grid; place-items: center; padding: 20px; z-index: 100;
}
.dialog {
  background: var(--flaeche); border-radius: 10px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(16,24,40,.2);
}
.dialog.breit { max-width: 820px; }
.dialog h2 {
  margin: 0; padding: 16px 20px; font-size: 16px; font-weight: 620;
  border-bottom: 1px solid var(--rand);
}
.dialog .inhalt { padding: 20px; }
.dialog .fuss {
  padding: 14px 20px; border-top: 1px solid var(--rand);
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--flaeche);
}

/* ---------------------------------------------------------------- Meldung */
#meldungen { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.meldung {
  background: var(--text); color: #fff; padding: 11px 15px; border-radius: 7px;
  font-size: 13px; max-width: 400px; box-shadow: 0 8px 20px rgba(16,24,40,.22);
  animation: rein .18s ease-out;
}
.meldung.fehler { background: var(--rot); }
.meldung.erfolg { background: var(--gruen); }
@keyframes rein { from { opacity: 0; transform: translateY(8px); } }

.warnbox {
  background: var(--gelb-hell); border: 1px solid #f5d9ae; color: #7c3f06;
  padding: 11px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px;
}
.infobox {
  background: var(--blau-hell); border: 1px solid #c9d8fb; color: #1e40af;
  padding: 11px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px;
}

.reiter { display: flex; gap: 3px; border-bottom: 1px solid var(--rand); margin-bottom: 18px; flex-wrap: wrap; }
.reiter button {
  border: none; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; padding: 9px 13px; color: var(--text-leise); font-weight: 500;
}
.reiter button.aktiv { color: var(--gruen-dunkel); border-bottom-color: var(--gruen); font-weight: 600; }

@media (max-width: 820px) {
  #app { flex-direction: column; }
  nav.seitenleiste { width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; overflow-x: auto; padding: 10px; }
  nav.seitenleiste .abschnitt, nav.seitenleiste .fuss, .marke span { display: none; }
  main { padding: 18px 14px 50px; }
}
@media print {
  nav.seitenleiste, .kopf .aktionen, .filterleiste, button { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .karte { border: none; box-shadow: none; }
}


/* --------------------------------------------------------- Anmeldeseite */
body.anmeldeseite #app { display: none; }
#anmeldung:empty { display: none; }
#anmeldung {
  position: fixed; inset: 0; background: var(--grund);
  display: grid; place-items: center; padding: 20px; z-index: 300;
}
.anmeldekasten {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: 12px; padding: 30px; width: 100%; max-width: 340px;
  box-shadow: 0 10px 30px rgba(16,24,40,.08);
}
.anmeldekasten .marke.gross { font-size: 18px; padding: 0 0 18px; }
.anmeldekasten .marke.gross .logo { width: 32px; height: 32px; font-size: 16px; }
.anmeldefehler {
  background: var(--rot-hell); color: var(--rot); border: 1px solid #f3c9c5;
  padding: 9px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px;
}
nav.seitenleiste .fuss .dick { color: var(--text); }


/* ------------------------------------------------------------ Belegablage */
.ablagefeld {
  border: 2px dashed var(--rand-stark); border-radius: 8px;
  padding: 22px; text-align: center; color: var(--text-leise);
  font-size: 13px; cursor: pointer; margin: 6px 0 10px;
  transition: .15s;
}
.ablagefeld:hover, .ablagefeld.aktiv {
  border-color: var(--gruen); background: var(--gruen-hell); color: var(--gruen-dunkel);
}
