:root {
  --bg: #f6f6f3; --flaeche: #ffffff; --flaeche2: #f0efea; --text: #1f2328; --leise: #5f6670; --linie: #dcdad2;
  --akzent: #1f5f8b; --akzent-text: #ffffff; --gruen: #1f7a46; --gruen-bg: #e3f2e8; --gelb: #8a5a00; --gelb-bg: #fdf1d6;
  --rot: #a3261c; --rot-bg: #fbe4e1; --orange: #a84a05; --orange-bg: #ffe6c7; --blau: #1f5f8b; --blau-bg: #e1edf6; --grau-bg: #ecebe6; --test: #7a3e00; --test-bg: #ffe2b8;
  --radius: 8px; --schrift: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191c; --flaeche: #1f2226; --flaeche2: #262a2f; --text: #e8e6e1; --leise: #a3a8ae; --linie: #363b41;
    --akzent: #5aa3d6; --akzent-text: #0e1418; --gruen: #6fcf97; --gruen-bg: #183324; --gelb: #f2c36b; --gelb-bg: #3a2e14;
    --rot: #f08a80; --rot-bg: #3d1d1a; --orange: #fdba74; --orange-bg: #4a2c12; --blau: #7db8e0; --blau-bg: #17303f; --grau-bg: #2b2f34; --test: #ffcf91; --test-bg: #4a2f0f;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--schrift); }
a { color: var(--akzent); }
button, input, select, textarea { font: inherit; color: inherit; }
.modusband { background: var(--test-bg); color: var(--test); padding: 8px 16px; font-weight: 600; border-bottom: 1px solid var(--linie); }
.modusband.live { background: var(--rot-bg); color: var(--rot); }
.kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--flaeche); border-bottom: 1px solid var(--linie); flex-wrap: wrap; }
.marke { font-size: 15px; }
.profil { font-size: 12px; color: var(--leise); }
.rahmen { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 50px); }
.navi { background: var(--flaeche); border-right: 1px solid var(--linie); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.navi a { padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.navi a:hover { background: var(--flaeche2); }
.navi a.aktiv { background: var(--blau-bg); color: var(--blau); font-weight: 600; }
.inhalt { padding: 18px 22px 60px; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 22px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
.leise { color: var(--leise); }
.klein { font-size: 12px; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.kachel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 12px; }
.kachel .zahl { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kachel .text { color: var(--leise); font-size: 12px; }
.kachel .klein { margin-top: 4px; }
/* Verwaltung (Version 3.1): Berichte, Benutzer und Rechte, Anmeldung */
.navi[hidden], .navi a[hidden] { display: none; }
.navi[hidden] + .inhalt { grid-column: 1 / -1; }   /* Anmeldung und Einladung: ohne Navigation über die ganze Breite */
.knopfreihe.eng { margin: 0; gap: 4px; }
h2.berichtstitel { margin: 8px 0 0; font-size: 18px; }
.karte.einschub { background: var(--flaeche2); }
.rollenwahl { display: grid; gap: 6px; margin: 10px 0; }
label.wahl { display: flex; gap: 8px; align-items: baseline; font-size: 14px; color: var(--text); cursor: pointer; }
table.rechte th, table.rechte td { text-align: center; }
table.rechte th:first-child, table.rechte td:first-child { text-align: left; }
table.rechte input { width: 18px; height: 18px; }
.anmeldung { max-width: 420px; margin: 40px auto; }
.anmeldung .feld { margin: 10px 0; }
details > summary + .tabelle-wrap { margin-top: 6px; }
.tabelle-wrap { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { font-size: 12px; color: var(--leise); font-weight: 600; background: var(--flaeche2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tfoot td { border-bottom: 0; background: var(--flaeche2); }
tfoot tr:first-child td { border-top: 2px solid var(--linie); padding-top: 10px; }
tfoot tr.summe-kopf td { padding-bottom: 1px; }
tfoot tr.summe td { padding-top: 2px; padding-bottom: 2px; font-weight: 400; }
tfoot tr.total td { border-top: 2px solid var(--text); padding-top: 7px; padding-bottom: 10px; vertical-align: baseline; }
tfoot tr.total:first-child td { border-top: 2px solid var(--linie); }
tfoot tr.total td.zahl { font-weight: 700; font-size: 1.2em; }
tr.klickbar { cursor: pointer; }
tr.klickbar:hover td { background: var(--flaeche2); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; background: var(--grau-bg); }
.chip.gruen { background: var(--gruen-bg); color: var(--gruen); }
.chip.gelb { background: var(--gelb-bg); color: var(--gelb); }
.chip.rot { background: var(--rot-bg); color: var(--rot); }
.chip.blau { background: var(--blau-bg); color: var(--blau); }
.chip.test { background: var(--test-bg); color: var(--test); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.knopf { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--linie); background: var(--flaeche); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.knopf:hover { border-color: var(--akzent); }
.knopf.haupt { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); font-weight: 600; }
.knopf.gefahr { color: var(--rot); }
.knopf:disabled { opacity: .5; cursor: not-allowed; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; align-items: center; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 10px 0; }
.filter label, .feld label { display: block; font-size: 12px; color: var(--leise); margin-bottom: 2px; }
.kombi { position: relative; }
.kombi-liste { position: absolute; z-index: 30; top: 100%; left: 0; min-width: 100%; width: max-content; max-width: min(380px, calc(100vw - 16px)); max-height: 300px; overflow-y: auto; margin: 3px 0 0; padding: 4px 0; list-style: none; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .14); }
.kombi-liste li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 10px; cursor: pointer; }
.kombi-liste li.aktiv, .kombi-liste li[data-i]:hover { background: var(--flaeche2); }
.kombi-liste li.leer { cursor: default; }
input[type=text], input[type=date], input[type=number], select, textarea { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: 6px 8px; min-width: 0; }
textarea { width: 100%; min-height: 60px; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pdf { position: sticky; top: 10px; height: calc(100vh - 120px); min-height: 420px; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); overflow: hidden; }
.pdf iframe { width: 100%; height: 100%; border: 0; }
/* „Beleg vergrössern“: der Beleg über die ganze Breite, die Felder darunter. Nur dort, wo Beleg und Felder nebeneinander stehen. */
@media (min-width: 1101px) { .detail.gross { grid-template-columns: minmax(0, 1fr); } .detail.gross .pdf { position: static; height: calc(100vh - 90px); } }
@media (max-width: 1100px) { .nur-breit { display: none; } }
.ohne-beleg { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; color: var(--orange); background: var(--orange-bg); }
.felder { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.feld input, .feld select { width: 100%; }
.feld.leer input, .feld.leer select { border-color: var(--gelb); background: var(--gelb-bg); }
.feld.unsicher input { border-style: dashed; border-color: var(--gelb); }
.herkunft { font-size: 11px; color: var(--leise); margin-top: 2px; overflow-wrap: anywhere; }
.hinweis { padding: 8px 10px; border-radius: 6px; margin: 6px 0; display: flex; gap: 10px; justify-content: space-between; align-items: start; }
.hinweis.blockierend { background: var(--rot-bg); color: var(--rot); }
.hinweis.warnung { background: var(--gelb-bg); color: var(--gelb); }
.hinweis.info { background: var(--blau-bg); color: var(--blau); }
/* Zu prüfen: feste Rubrik oben im Beleg – am farbigen Rand auf einen Blick zu erkennen */
.pruefen { border-left: 6px solid var(--gruen); }
.pruefen.rot { border-left-color: var(--rot); }
.pruefen.gelb { border-left-color: var(--gelb); }
.pruefen h2 { margin: 0 0 6px; }
.pruefen p { margin: 6px 0 0; }
.pruefen details { margin-top: 8px; }
fieldset.wahl { border: 0; padding: 0; margin: 12px 0; min-width: 0; }
fieldset.wahl legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.wahlzeile { display: flex; gap: 8px; align-items: flex-start; padding: 6px; border-radius: 6px; cursor: pointer; }
.wahlzeile:hover { background: var(--grau-bg); }
.wahlzeile input[type=radio] { margin-top: 4px; flex: none; }
.wahlzeile > span { min-width: 0; }
.wahlzeile select, .wahlzeile input[type=text], .wahlzeile input[type=date] { display: block; margin-top: 4px; max-width: 100%; }
.hinweis.geklaert { background: var(--grau-bg); color: var(--leise); text-decoration: line-through; }
.status-zeile { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.status-zeile .kachel { padding: 8px 10px; min-width: 0; }
.status-zeile .chip { white-space: normal; max-width: 100%; }
.dialog { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dialog-box { background: var(--flaeche); border-radius: 10px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; padding: 18px; border: 1px solid var(--linie); }
.meldung { position: fixed; right: 16px; bottom: 16px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; max-width: min(460px, calc(100vw - 32px)); z-index: 60; }
.meldung.fehler { background: var(--rot); color: #fff; }
.abschnitt-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.anzahl { background: var(--grau-bg); border-radius: 999px; padding: 0 8px; font-size: 12px; margin-left: 6px; }
.ablage { border: 2px dashed var(--linie); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--leise); }
.ablage.voll { border-style: solid; color: var(--text); }
.ablage.ueber { border-color: var(--akzent); color: var(--akzent); }
.ablage-info { margin-top: 8px; font-size: 13px; overflow-wrap: anywhere; }
.ablage + .filter { margin-top: 12px; }
details > summary { cursor: pointer; padding: 4px 0; }
.ok { color: var(--gruen); } .nok { color: var(--rot); }
/* Status und Zahlart: Auswahl direkt in der Zeile. „Bezahlt“ grün, „Unklar“ orange. */
select.wahl-status, select.wahl-zahlart { appearance: none; -webkit-appearance: none; cursor: pointer; border-radius: 999px; padding: 3px 26px 3px 11px; line-height: 1.4; max-width: 100%;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
select.wahl-status { font-weight: 600; border-color: transparent; }
select.wahl-status.bezahlt { background-color: var(--gruen-bg); color: var(--gruen); }
select.wahl-status.unklar { background-color: var(--orange-bg); color: var(--orange); }
select.wahl-status.zubezahlen { background-color: var(--blau-bg); color: var(--blau); }
select.wahl-zahlart { background-color: var(--flaeche); }
select.wahl-zahlart.leer { color: var(--leise); }
select.wahl-status option, select.wahl-zahlart option { background: var(--flaeche); color: var(--text); font-weight: 400; }
select.wahl-status:disabled, select.wahl-zahlart:disabled { opacity: .6; }
.warn { color: var(--orange); }
/* Monatsprüfung */
.chip.orange { background: var(--orange-bg); color: var(--orange); }
button.chip { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
button.chip:hover { filter: brightness(.96); }
.mp-fertig { padding: 10px 14px; }
.mp-monat { margin: 6px 0 18px; scroll-margin-top: 12px; }
/* Rechnungs-Umrechner: der Invoice Converter läuft in einem Rahmen, dessen Höhe dem Inhalt folgt */
iframe.umrechner { display: block; width: 100%; min-height: 420px; border: 0; margin-top: 10px; }
.knopf.klein { padding: 3px 9px; font-size: 12px; }
.um-offen h2 { margin: 0 0 4px; font-size: 15px; }
.um-offen td.aktionen, .um-nein td.aktionen { white-space: nowrap; text-align: right; }
.um-nein { margin: 6px 0; }
.um-nein summary { cursor: pointer; }
/* Land: Ländercode vor dem Lieferanten, orange gestrichelt, solange er fehlt */
select.wahl-land { appearance: none; -webkit-appearance: none; cursor: pointer; width: 46px; padding: 3px 4px; border-radius: 6px; line-height: 1.4;
  text-align: center; text-align-last: center; font-weight: 600; letter-spacing: .02em; background-color: var(--flaeche); }
select.wahl-land.leer { border-style: dashed; border-color: var(--orange); color: var(--orange); }
select.wahl-land option { background: var(--flaeche); color: var(--text); font-weight: 400; }
td.td-land { white-space: nowrap; width: 1%; padding-right: 0; }
/* MwSt: Satz als Auswahl, orange gestrichelt, solange er fehlt */
select.wahl-mwst { appearance: none; -webkit-appearance: none; cursor: pointer; border-radius: 999px; padding: 3px 24px 3px 10px; line-height: 1.4; background-color: var(--flaeche);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
select.wahl-mwst.leer { border-style: dashed; border-color: var(--orange); color: var(--orange); }
select.wahl-mwst option { background: var(--flaeche); color: var(--text); }
td.td-mwst { white-space: nowrap; }
/* „Bezahlt am“: Datum neben dem Status */
input.wahl-datum { padding: 3px 9px; border-radius: 999px; font-size: 13px; line-height: 1.4; max-width: 150px; }
input.wahl-datum.leer { border-style: dashed; color: var(--leise); }
input.wahl-datum.offen { border-color: transparent; background: transparent; color: var(--leise); opacity: .55; }
input.wahl-datum.offen:hover, input.wahl-datum.offen:focus { border-color: var(--rand, currentColor); opacity: 1; }
input.wahl-titel { padding: 3px 9px; border-radius: 8px; font-size: 13px; line-height: 1.4; width: 160px; max-width: 100%; }
input.wahl-titel:disabled { opacity: .55; }
.zahlstand input.wahl-datum { font-size: 15px; padding: 5px 11px; }
/* Bexio: Knopf „An Bexio senden“ und Haken */
.bexio-zelle { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.knopf.senden { padding: 3px 11px; border-radius: 999px; line-height: 1.4; }
.knopf.aus { opacity: .5; cursor: not-allowed; }
.knopf.aus:hover { border-color: var(--linie); }
.haken { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 1.5px solid var(--linie); border-radius: 6px; background: var(--flaeche); font-weight: 700; font-size: 14px; line-height: 1; flex: none; }
.haken.an { border-color: var(--gruen); background: var(--gruen-bg); color: var(--gruen); }
.haken.an.test { border-color: var(--test); background: var(--test-bg); color: var(--test); }
.haken.fehler { border-color: var(--rot); background: var(--rot-bg); color: var(--rot); }
.filter .lbl { display: block; font-size: 12px; color: var(--leise); margin-bottom: 2px; }
.zahlstand .knopf.senden { font-size: 15px; padding: 5px 14px; }
.zahlstand .filter { margin: 0 0 6px; }
.zahlstand select { font-size: 15px; padding-top: 5px; padding-bottom: 5px; }
details.klappe > summary { padding: 0; }
details.klappe[open] > summary { margin-bottom: 8px; }
/* Bexio-Verbindung: das Token-Feld nimmt die Breite, die da ist */
.bx-feld { flex: 1 1 320px; max-width: 560px; min-width: 0; }
#bx_nr ul { margin: 6px 0 0; padding-left: 18px; }
#bx_nr li { margin: 4px 0; overflow-wrap: anywhere; }
#bx_nr li .knopf { white-space: normal; text-align: left; }
.bx-feld input { width: 100%; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: 6px 8px; font: inherit; color: inherit; }
code { font-size: 12px; background: var(--flaeche2); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
@media (max-width: 1100px) { .detail { grid-template-columns: minmax(0, 1fr); } .pdf { position: static; height: 70vh; } }
@media (max-width: 760px) {
  .rahmen { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .navi { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--linie); padding: 6px; }
  .navi a { white-space: nowrap; }
  .inhalt { padding: 14px 16px 60px; }
  .felder { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Interner Chat (Seitenleiste) und Spalte „Nr.“ in der Belegliste ---------- */
td.td-nr { white-space: nowrap; width: 1%; padding-right: 0; }
button.nr { border: 0; background: none; padding: 2px 4px; margin: 0 -4px; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; color: var(--blau); }
button.nr:hover { background: var(--blau-bg); }
button.nr.hat-chat::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; background: var(--orange); vertical-align: 1px; }
.chat { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--linie); position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; font-size: 13px; }
.chat summary { cursor: pointer; font-weight: 600; padding: 4px 10px 8px; }
.chat summary .anzahl { background: var(--orange-bg); color: var(--orange); }
#chat_inhalt, #chat_form, .chatwahl { display: grid; gap: 8px; }
#chat_inhalt { padding: 0 4px 8px; }
.chatwahl p { margin: 0; }
.chatliste { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.chatzeile { display: grid; gap: 2px; width: 100%; text-align: left; background: var(--flaeche2); border: 1px solid var(--linie); border-radius: 8px; padding: 6px 8px; cursor: pointer; overflow-wrap: anywhere; }
.chatzeile:hover { border-color: var(--akzent); }
.chatzeile.neu { background: var(--orange-bg); border-color: var(--orange); }
.chatzeile .anzahl { background: var(--orange); color: var(--flaeche); margin-left: 4px; }
.kuerzel { display: inline-block; min-width: 22px; padding: 0 4px; border: 1px solid var(--linie); border-radius: 999px; background: var(--flaeche); font-size: 11px; font-weight: 600; line-height: 16px; text-align: center; }
.chatlink { border: 0; background: none; padding: 0; color: var(--blau); cursor: pointer; text-align: left; justify-self: start; }
.chatlink:hover { text-decoration: underline; }
.chatkopf, .chatnachricht { background: var(--flaeche2); border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }
.chatverlauf { display: grid; gap: 6px; max-height: 34vh; overflow-y: auto; }
.chatverlauf p { margin: 0; }
.chatnachricht.ich { background: var(--blau-bg); }
.chatnachricht .erw { color: var(--blau); }
.chatreihe { display: flex; gap: 6px; }
.chatreihe input { flex: 1; width: 0; }
.chat .chips { align-items: center; }
.wahlchip { border: 1px solid var(--linie); background: var(--flaeche); border-radius: 999px; padding: 1px 8px; font-size: 12px; cursor: pointer; }
.wahlchip:hover { border-color: var(--akzent); }
.wahlchip[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
@media (max-width: 760px) {
  .navi { flex-wrap: wrap; }
  .chat { flex: 0 0 100%; position: static; max-height: none; margin-top: 4px; }
}
