/* Gastro Treuhand, Extraktions-Service: kleines, handgeschriebenes Stylesheet.
   Keine Frameworks, keine Webfonts. Alles hier, nichts inline (CSP: default-src 'self'). */

:root {
  --bg: #f6f6f3;
  --flaeche: #ffffff;
  --text: #1d2327;
  --text-leise: #566069;
  --linie: #cfd4d8;
  --linie-hell: #e6e9eb;
  --akzent: #1f5f8b;
  --akzent-dunkel: #174a6d;
  --fokus: #b45309;
  --ok-bg: #e6f4ea;
  --ok-rand: #2e7d4f;
  --fehler-bg: #fdecea;
  --fehler-rand: #b3261e;
  --info-bg: #e8f1f8;
  --info-rand: #1f5f8b;
  --warn-bg: #fff4d6;
  --warn-rand: #b7791f;
  --plus-bg: #e3f5e8;
  --minus-bg: #fde7e5;
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

h1 { font-size: 1.6rem; margin: 0 0 1rem; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; line-height: 1.3; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0 0 0.75rem; }

a { color: var(--akzent); text-underline-offset: 2px; }
a:hover { color: var(--akzent-dunkel); }

code, pre, .mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

/* Fokus: immer sichtbar, auch auf Tastatur */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--flaeche);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Kopf und Navigation */
.kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.5rem 1.5rem;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}
.marke { font-weight: 700; }
.hauptnav ul { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.hauptnav a {
  display: block;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
}
.hauptnav a:hover { background: var(--linie-hell); }
.hauptnav a.aktiv { background: var(--akzent); color: #fff; }
.kopf-konto { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.benutzer { color: var(--text-leise); }

.inhalt { max-width: 80rem; margin: 0 auto; padding: 1.5rem; }

/* Meldungen */
.flash-bereich:empty { display: none; }
.flash {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--info-rand);
  background: var(--info-bg);
  border-radius: 3px;
}
.flash-ok { border-color: var(--ok-rand); background: var(--ok-bg); }
.flash-error { border-color: var(--fehler-rand); background: var(--fehler-bg); }
.flash-warn { border-color: var(--warn-rand); background: var(--warn-bg); }

/* Karten und Formulare */
.karte {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin: 0 0 1.5rem;
}
.karte > :first-child { margin-top: 0; }
.schmal { max-width: 28rem; }

.formular { display: flex; flex-direction: column; gap: 0.35rem; }
.formular label { font-weight: 600; margin-top: 0.5rem; }
.formular .zeile { display: flex; flex-wrap: wrap; gap: 1rem; }
.formular .zeile > div { flex: 1 1 14rem; display: flex; flex-direction: column; gap: 0.35rem; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], input[type="file"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #8a949b;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { min-height: 8rem; resize: vertical; }
textarea.editor { min-height: 24rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9rem; }
input:disabled, select:disabled, textarea:disabled { background: var(--linie-hell); color: var(--text-leise); }
input[readonly] { background: var(--linie-hell); }

.hinweis { color: var(--text-leise); font-size: 0.9rem; margin: 0.25rem 0 0.5rem; }

/* Knöpfe */
.knopf, button.knopf {
  align-self: flex-start;
  margin-top: 0.75rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--akzent-dunkel);
  border-radius: 4px;
  background: var(--akzent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.knopf:hover { background: var(--akzent-dunkel); color: #fff; }
.knopf-zweit { background: var(--flaeche); color: var(--akzent-dunkel); }
.knopf-zweit:hover { background: var(--info-bg); color: var(--akzent-dunkel); }
.knopf-gefahr { background: var(--fehler-rand); border-color: #8c1d18; }
.knopf-gefahr:hover { background: #8c1d18; }
.knopf-klein { margin-top: 0; padding: 0.25rem 0.6rem; font-size: 0.9rem; }
.knopf-link {
  background: none;
  border: 0;
  padding: 0.25rem 0.5rem;
  color: var(--akzent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* htmx-Anzeige (includeIndicatorStyles ist aus, die Regeln stehen hier) */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request button[type="submit"] { opacity: 0.7; cursor: progress; }

/* Tabellen: lesbar auch mit vielen Zeilen */
.tabelle-rahmen { overflow-x: auto; border: 1px solid var(--linie); border-radius: 6px; background: var(--flaeche); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 0.45rem 0.75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--linie-hell); }
th { background: #eef0f2; font-weight: 600; white-space: nowrap; position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--linie); }
tbody tr:nth-child(even) { background: #fafaf8; }
tbody tr:hover { background: var(--info-bg); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
td.pfad { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88rem; word-break: break-word; }
td.leer { color: var(--text-leise); font-style: italic; }
tr.geloescht { color: var(--text-leise); text-decoration: line-through; }
tr.gestoert td:first-child { box-shadow: inset 4px 0 0 var(--fehler-rand); }

/* Statusmarken (Text bleibt immer dabei, Farbe ist nie das einzige Signal) */
.marke-status {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--linie);
  background: var(--linie-hell);
  font-size: 0.85rem;
  white-space: nowrap;
}
.status-done { background: var(--ok-bg); border-color: var(--ok-rand); }
.status-failed { background: var(--fehler-bg); border-color: var(--fehler-rand); }
.status-running, .status-pending { background: var(--info-bg); border-color: var(--info-rand); }

/* Flags */
.flag-grund { color: var(--text-leise); }
.flag-validierung, tr.flag-validierung td {
  background: var(--warn-bg);
  box-shadow: inset 4px 0 0 var(--warn-rand);
}
tr.flag-validierung:hover td { background: #ffeab0; }
.flag-validierung .flag-grund { color: var(--text); font-weight: 600; }

/* Diff (Prompts): <pre class="diff"> mit je einem <span class="diff-zeile ..."> pro Zeile */
pre.diff {
  margin: 0;
  padding: 0.5rem 0;
  overflow-x: auto;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 6px;
  line-height: 1.4;
}
.diff-zeile { display: block; padding: 0 0.75rem; white-space: pre-wrap; word-break: break-word; }
.diff-plus { background: var(--plus-bg); }
.diff-plus::before { content: "+ "; font-weight: 700; }
.diff-minus { background: var(--minus-bg); }
.diff-minus::before { content: "- "; font-weight: 700; }
.diff-kopf { color: var(--text-leise); background: var(--linie-hell); }
.diff-gleich { color: var(--text-leise); }

/* Kleinteile */
.leiste { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin: 0 0 1rem; }
.seitenwahl { display: flex; gap: 0.75rem; align-items: center; margin: 1rem 0; }
.schema-auswahl select { max-width: 100%; }
details > summary { cursor: pointer; font-weight: 600; }
.aktiv-marker { font-weight: 700; color: var(--ok-rand); }

/* Laptop und schmaler */
@media (max-width: 60rem) {
  .inhalt { padding: 1rem; }
  .kopf { padding: 0.5rem 1rem; }
  th, td { padding: 0.4rem 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
