/* Hintergrundwerk – ruhig, klar, mobile first.
   Grundregeln gelten fürs Handy; ab 760 px bzw. 1000 px kommt mehr nebeneinander. */

:root {
  --akzent: #2457a6;          /* die eine Akzentfarbe */
  --akzent-hell: #e8eef8;
  --text: #1d2330;
  --leise: #5d6675;
  --linie: #e3e6ec;
  --flaeche: #f6f7f9;
  --weiss: #ffffff;
  --gruen: #1d7f46;  --gruen-hell: #e7f4ec;
  --gelb: #b47b00;   --gelb-hell: #fdf4dd;
  --rot: #c0352b;    --rot-hell: #fbeceb;
  --radius: 12px;
  --schatten: 0 1px 2px rgb(20 30 50 / .06), 0 2px 8px rgb(20 30 50 / .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--flaeche); font-size: 1rem; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .2rem 0 .4rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
a { color: var(--akzent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--akzent); outline-offset: 2px;
}
.leise { color: var(--leise); }
.klein { font-size: .875rem; }
.rechts { text-align: right; }
.text-rot { color: var(--rot); }

/* ---- Kopf ------------------------------------------------------------ */
.kopf {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem;
  padding: .6rem 1rem; background: var(--weiss); border-bottom: 1px solid var(--linie);
}
.marke { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; margin-right: auto; }
.marke .betrieb { display: block; font-weight: 400; font-size: .8rem; color: var(--leise); line-height: 1.2; }
.navi { display: flex; align-items: center; gap: .1rem; overflow-x: auto; }
.navi a, .link-knopf {
  padding: .5rem .6rem; border-radius: 8px; color: var(--leise); text-decoration: none; white-space: nowrap;
}
.navi a[aria-current="page"] { color: var(--akzent); background: var(--akzent-hell); font-weight: 600; }
.navi form { margin: 0; }
.link-knopf { background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; }

.inhalt { max-width: 1180px; margin: 0 auto; padding: 1rem; }

/* ---- Testbanner (BELEGAGENT_TESTBANNER=1) ---------------------------- */
.testbanner {
  margin: 0; padding: .55rem 1rem; text-align: center; font-weight: 600; font-size: .95rem;
  background: var(--gelb-hell); color: #6b4a00; border-bottom: 1px solid #f0dca8;
}
.login-marke { margin: 0; font-weight: 700; color: var(--akzent); letter-spacing: .02em; }

/* ---- Meldungen -------------------------------------------------------- */
.meldung { margin: 0 0 .75rem; padding: .75rem 1rem; border-radius: var(--radius); background: var(--gruen-hell); }
.meldung-hinweis { background: var(--gelb-hell); }
.meldung-fehler { background: var(--rot-hell); color: #7d1f18; }
.meldung a { font-weight: 600; margin-left: .25rem; }

/* ---- Karten, Knöpfe, Formulare ----------------------------------------- */
.karte {
  background: var(--weiss); border-radius: var(--radius); box-shadow: var(--schatten);
  padding: 1rem; margin-bottom: 1rem;
}
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .65rem 1.2rem; border-radius: 10px; border: 1px solid var(--akzent);
  background: var(--akzent); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.knopf:hover { filter: brightness(1.08); }
.knopf:disabled { opacity: .55; cursor: progress; }
.knopf-gross { min-height: 56px; font-size: 1.05rem; width: 100%; }
.knopf-breit { width: 100%; }
.knopf-zweit { background: var(--weiss); color: var(--akzent); }
.knopf-leise { background: var(--weiss); color: var(--text); border-color: var(--linie); }

.formular label { display: block; margin-bottom: .85rem; font-size: .9rem; color: var(--leise); }
.formular input, .formular select {
  display: block; width: 100%; margin-top: .25rem; min-height: 46px; padding: .55rem .7rem;
  font: inherit; font-size: 1rem; color: var(--text);   /* 16 px: iPhone zoomt sonst beim Tippen hinein */
  border: 1px solid #cfd4dc; border-radius: 9px; background: var(--weiss);
}
.formular fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.formular fieldset:disabled input { background: var(--flaeche); color: var(--leise); }
.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }

/* ---- Login ------------------------------------------------------------ */
.login { max-width: 420px; margin: 8vh auto 0; padding: 1.5rem; }

/* ---- Kacheln ----------------------------------------------------------- */
.kacheln { display: grid; grid-template-columns: 1fr; gap: .75rem; margin-bottom: 1rem; }
.kachel {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 1rem;
  background: var(--weiss); border-radius: var(--radius); box-shadow: var(--schatten);
  padding: .85rem 1rem; color: var(--text); text-decoration: none; border-left: 4px solid transparent;
}
.kachel:hover { box-shadow: 0 0 0 2px var(--akzent-hell), var(--schatten); }
.kachel-achtung { border-left-color: var(--gelb); }
.kachel-titel { font-weight: 600; }
.kachel-zahl { font-size: 1.5rem; font-weight: 700; grid-row: span 2; align-self: center; font-variant-numeric: tabular-nums; }
.kachel-unter { color: var(--leise); font-size: .875rem; }

/* ---- Hochladen ---------------------------------------------------------- */
.aktionen { display: grid; gap: .75rem; margin-bottom: 1.25rem; }
.ablage { margin: 0; }
.datei-eingabe { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.ablage-feld {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  min-height: 110px; padding: 1rem; text-align: center; cursor: pointer;
  border: 2px dashed #b9c6dd; border-radius: var(--radius); background: var(--weiss);
}
.ablage-titel { color: var(--akzent); font-weight: 700; font-size: 1.1rem; }
.datei-eingabe:focus-visible + .ablage-feld { outline: 3px solid var(--akzent); outline-offset: 2px; }
.ablage-feld:hover, .ablage-feld.drueber { border-color: var(--akzent); background: var(--akzent-hell); }
.ablage-feld.beschaeftigt { opacity: .6; pointer-events: none; }
.laeuft { margin: .5rem 0 0; text-align: center; color: var(--akzent); font-weight: 600; }
.laeuft::before { content: ""; display: inline-block; width: .9em; height: .9em; margin-right: .5em; vertical-align: -.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: drehen 1s linear infinite; }
@keyframes drehen { to { transform: rotate(360deg); } }
.nur-gross { display: none; }
.export { margin: 0; }

/* ---- Liste ------------------------------------------------------------- */
.reiter { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: none; }
.reiter a {
  flex: none; padding: .45rem .85rem; border-radius: 999px; background: var(--weiss);
  border: 1px solid var(--linie); color: var(--text); text-decoration: none; font-size: .925rem;
}
.reiter a[aria-current="true"] { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.suche { margin: .25rem 0 .75rem; }
.suche input {
  width: 100%; min-height: 46px; padding: .55rem .9rem; font: inherit; font-size: 1rem;
  border: 1px solid #cfd4dc; border-radius: 999px; background: var(--weiss);
}

.belege { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.belege-kopf { display: none; }
.beleg-zeile {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas:
    "ampel lieferant betrag" "ampel datum status" "ampel faellig faellig";
  gap: .1rem .75rem; align-items: center;
  padding: .8rem 1rem; background: var(--weiss); border-radius: var(--radius); box-shadow: var(--schatten);
  color: var(--text); text-decoration: none;
}
.beleg-zeile:hover { box-shadow: 0 0 0 2px var(--akzent-hell), var(--schatten); }
.ampel-kurz { grid-area: ampel; display: flex; flex-direction: column; align-items: center; gap: .15rem;
  font-size: .72rem; color: var(--leise); min-width: 3.4rem; }
.lieferant { grid-area: lieferant; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.datum { grid-area: datum; color: var(--leise); font-size: .875rem; }
.betrag { grid-area: betrag; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { grid-area: status; color: var(--leise); font-size: .875rem; text-align: right; }
.faellig { grid-area: faellig; color: var(--leise); font-size: .875rem; }
.faellig:empty { display: none; }
.leer { padding: 2rem 1rem; text-align: center; color: var(--leise); background: var(--weiss); border-radius: var(--radius); }

/* Ampel: immer Punkt UND Text – nicht nur Farbe */
.punkt { display: inline-block; width: .85rem; height: .85rem; border-radius: 50%; flex: none; }
.punkt-gruen { background: var(--gruen); }
.punkt-gelb { background: var(--gelb); }
.punkt-rot { background: var(--rot); }

.exporte { margin-top: 1.5rem; color: var(--leise); }
.exporte summary { cursor: pointer; }

/* ---- Beleg-Detail ---------------------------------------------------- */
.brotkrume { display: flex; justify-content: space-between; margin: 0 0 .5rem; }
.beleg-kopf { margin-bottom: 1rem; }
.beleg-kopf p { margin: .2rem 0; }
.betrag-gross { color: var(--text); font-size: 1.15rem; }
.schilder { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem !important; }
.schild, .ampel-schild {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 999px;
  background: var(--weiss); border: 1px solid var(--linie); font-size: .9rem;
}
.ampel-schild { font-weight: 600; border: 0; }
.ampel-gruen { background: var(--gruen-hell); color: var(--gruen); }
.ampel-gelb { background: var(--gelb-hell); color: #845a00; }
.ampel-rot { background: var(--rot-hell); color: var(--rot); }

.gruende ul { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: .5rem; }
.grund { padding: .6rem .8rem; border-radius: 9px; border-left: 4px solid var(--gelb); background: var(--gelb-hell); }
.grund-rot { border-left-color: var(--rot); background: var(--rot-hell); }
.grund strong { display: block; }
.tipp { display: block; font-size: .925rem; }
.grund details { margin-top: .2rem; color: var(--leise); }
.grund summary { cursor: pointer; font-size: .85rem; }
.grund-ok { margin: 0; color: var(--gruen); }

.entscheidung { display: grid; gap: .6rem; margin-bottom: 1rem; }
.entscheidung form { margin: 0; }
.entscheidung .link-knopf { justify-self: start; padding-left: 0; color: var(--leise); }
.hinweis-text { margin: 0; color: var(--leise); }

.original .seite { display: block; width: 100%; height: auto; margin-bottom: .5rem;
  border: 1px solid var(--linie); border-radius: 6px; background: #fff; }
.xml { max-height: 60vh; overflow: auto; font-size: .8rem; white-space: pre-wrap; word-break: break-all;
  background: var(--flaeche); padding: .75rem; border-radius: 8px; }

.steuer { width: 100%; border-collapse: collapse; margin: .25rem 0 1rem; }
.steuer th { text-align: left; font-weight: 500; font-size: .85rem; color: var(--leise); padding: 0 .3rem .2rem 0; }
.steuer td { padding: 0 .3rem .4rem 0; vertical-align: middle; white-space: nowrap; }
.steuer input, .steuer select { margin-top: 0; }

.verlauf summary { cursor: pointer; font-weight: 600; }
.verlauf ol { margin: .75rem 0 0; padding-left: 1.2rem; display: grid; gap: .4rem; }

/* ---- Lieferanten, Protokoll ---------------------------------------------- */
.neue-lieferanten, .lieferanten { list-style: none; margin: 0; padding: 0; }
.neue-lieferanten li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .75rem 0; border-top: 1px solid var(--linie); }
.neue-lieferanten form { margin: 0; }
.lieferanten li { padding: .6rem 0; border-top: 1px solid var(--linie); }
.lieferanten li span { display: block; }
.protokoll { list-style: none; padding: .25rem 1rem; }
.protokoll li { display: grid; padding: .6rem 0; border-top: 1px solid var(--linie); }
.protokoll li:first-child, .lieferanten li:first-child, .neue-lieferanten li:first-child { border-top: 0; }

/* ---- Größere Bildschirme ------------------------------------------------- */
@media (min-width: 760px) {
  .inhalt { padding: 1.5rem; }
  .kacheln { grid-template-columns: repeat(3, 1fr); }
  .kachel { grid-template-columns: 1fr; }
  .kachel-zahl { grid-row: auto; font-size: 1.9rem; }
  .aktionen { grid-template-columns: 1fr minmax(260px, 340px); align-items: stretch; }
  .export .knopf { height: 100%; }
  .nur-gross { display: inline; }
  .entscheidung { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: center; }
  .entscheidung .hinweis-text, .entscheidung .link-knopf { grid-column: 1 / -1; }
  .suche { max-width: 360px; }
  .liste-bereich { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0 1rem; }
  .liste-bereich #liste { grid-column: 1 / -1; }
}
@media (min-width: 1000px) {
  /* Liste als Tabelle */
  .belege { gap: 0; background: var(--weiss); border-radius: var(--radius); box-shadow: var(--schatten); overflow: hidden; }
  .belege-kopf, .beleg-zeile {
    display: grid; grid-template-columns: 5.5rem minmax(0, 2.4fr) 7rem 8rem minmax(0, 1.6fr) 9rem;
    grid-template-areas: none; gap: 1rem; padding: .7rem 1rem;
  }
  .belege-kopf { font-size: .8rem; color: var(--leise); border-bottom: 1px solid var(--linie); }
  .beleg-zeile { box-shadow: none; border-radius: 0; border-bottom: 1px solid var(--linie); }
  .belege li:last-child .beleg-zeile { border-bottom: 0; }
  .beleg-zeile:hover { box-shadow: none; background: var(--akzent-hell); }
  .ampel-kurz, .lieferant, .datum, .betrag, .status, .faellig { grid-area: auto; }
  .ampel-kurz { flex-direction: row; justify-content: flex-start; font-size: .875rem; gap: .45rem; }
  .status { text-align: left; }
  .faellig:empty { display: block; }
  /* Detail: Original links, Felder rechts */
  .beleg-raster { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
  .felder { position: sticky; top: 1rem; }
}
