/*
  FlexAI: ein Stylesheet, keine Inline-Stile (CSP style-src 'self').
  Basis (Schrift, Farben hell/dunkel, Abstände, Knöpfe) wortgleich aus der Website web/src/styles/global.css.
  Der Test tests/test_oberflaeche.py prüft, dass die :root-Variablen beider Dateien gleich sind.
  Darüber das Portal-Layout nach dem Vorbild der Videoauswertung (E6): Seitenleiste, Karten, Schritt-Leiste.
*/

/* Schrift: Geist Sans variabel, lokal (OFL 1.1, Lizenz: /static/fonts/OFL-Geist.txt). */
@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Fallback";
  src: local("Arial");
  size-adjust: 104.9%;
  ascent-override: 95.8%;
  descent-override: 28.1%;
  line-gap-override: 0%;
}

/* --- Basis wie Website ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
:root {
  color-scheme: light dark;
  --bg: #FFFFFF; --surface: #F5F6F8; --text: #111318; --muted: #5B6170;
  --accent: #2450E0; --accent-hover: #1B3FB8; --on-accent: #FFFFFF;
  --field: #868C9B; --line: #E3E5EA; --danger: #B42318;
  --sp-4: 4px; --sp-8: 8px; --sp-12: 12px; --sp-16: 16px; --sp-24: 24px; --sp-32: 32px; --sp-48: 48px; --sp-64: 64px;
  --section: clamp(64px, 12vw, 128px);
  --container: 1120px; --gutter: 16px;
  --r-card: 12px; --r-ctl: 10px; --header-h: 64px;
  --fs-display: clamp(40px, 1.6rem + 4vw, 72px);
  --fs-h2: clamp(28px, 1.3rem + 2vw, 44px);
  --font: "Geist", "Geist Fallback", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0B0D12; --surface: #141821; --text: #ECEEF3; --muted: #A3A9B8; --accent: #8AA4FF; --accent-hover: #A5B8FF; --on-accent: #0B0D12; --field: #5F6678; --line: #232836; --danger: #FF8A80; }
}
@media (min-width: 640px) { :root { --gutter: 32px; } }
/* Nur Portal: Erfolgsfarbe (Website hat keine), gleiche Logik hell/dunkel. */
html { --ok: #067647; -webkit-text-size-adjust: 100%; }
@media (prefers-color-scheme: dark) { html { --ok: #6CE9A6; } }

body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
h1, h2, h3, p, ul, ol, figure { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
.container { width: min(var(--container), 100% - 2 * var(--gutter)); margin-inline: auto; }
.h2 { font-size: var(--fs-h2); font-weight: 600; line-height: 1.15; letter-spacing: -.02em; }
.h3 { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.lead { font-size: 20px; line-height: 1.5; }
.small { font-size: 14px; line-height: 1.5; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus-visible { outline: 0; }

.link { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; transition: color 120ms ease-out; }
.link:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-8); min-height: 44px; padding: 0 20px; border: 1px solid transparent; border-radius: var(--r-ctl); font: 500 16px/1 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color 120ms ease-out, border-color 120ms ease-out; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { background: transparent; color: var(--text); border-color: var(--field); }
.btn-quiet:hover { border-color: var(--text); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .6; cursor: not-allowed; }
.btn[aria-disabled="true"] { cursor: progress; }
.btn-klein { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-gefahr { color: var(--danger); }
.skip { position: absolute; left: var(--sp-16); top: -120px; z-index: 30; }
.skip:focus-visible { top: var(--sp-8); }
.chip { display: inline-flex; align-items: center; padding: 2px 10px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.4; letter-spacing: .02em; white-space: nowrap; }
.wm { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.wm span { color: var(--accent); }

/* Formulare */
.formular { display: grid; gap: var(--sp-24); }
.feld { display: grid; gap: var(--sp-8); min-width: 0; }
.feld label, .feld .label { font-weight: 500; }
.feld-gruppe { display: grid; gap: var(--sp-24); }
@media (min-width: 760px) { .feld-gruppe { grid-template-columns: 1fr 1fr; } }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--field); border-radius: var(--r-ctl); background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-klein { min-height: 36px; padding: 4px 10px; font-size: 15px; }
.fehlertext { color: var(--danger); font-size: 14px; }
.hinweis { padding: var(--sp-12) var(--sp-16); border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); }
.hinweis-ok { border-color: var(--ok); }
.hinweis-fehler { border-color: var(--danger); color: var(--text); }
.status { min-height: 1.6em; margin-top: var(--sp-16); color: var(--muted); }
.aktionen { display: flex; flex-wrap: wrap; gap: var(--sp-12); margin-top: var(--sp-32); }
.abstand-oben { margin-top: var(--sp-32); }
.js .nur-ohne-js { display: none; }

/* --- Öffentliche Seiten (Login, Einladung): schlicht wie die Website --------------------- */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: var(--sp-24); height: var(--header-h); }
.logo { display: inline-flex; align-items: center; min-height: 44px; }
.bar-end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-4); }
.sprache-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--sp-12); border-radius: var(--r-ctl); color: var(--text); font-weight: 500; font-size: 14px; text-decoration: none; }
.sprache-link:hover { background: var(--surface); }
.sprache-link[aria-current] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .35em; }
.page { padding-top: clamp(40px, 6vw, 80px); }
.page .lead { margin-top: var(--sp-16); color: var(--muted); }
.narrow { max-width: 512px; }
.karte-einzeln .formular { margin-top: var(--sp-32); }
.schritte-klein { margin-top: var(--sp-24); padding-left: 1.25em; color: var(--muted); }
.schritte-klein li + li { margin-top: var(--sp-4); }
.trenner { display: flex; align-items: center; gap: var(--sp-16); margin-top: var(--sp-48); color: var(--muted); font-size: 14px; }
.trenner::before, .trenner::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.site-footer { margin-top: var(--section); border-top: 1px solid var(--line); padding-block: var(--sp-32); }
.fuss-zeile { display: flex; flex-wrap: wrap; gap: var(--sp-8) var(--sp-24); align-items: center; }

/* --- Portal: Seitenleiste + Hauptbereich ------------------------------------------------- */
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 900px) { .app { grid-template-columns: 264px 1fr; } }
.seitenleiste { display: flex; flex-direction: column; gap: var(--sp-16); padding: var(--sp-16); background: var(--surface); border-bottom: 1px solid var(--line); }
@media (min-width: 900px) {
  .seitenleiste { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: var(--sp-24) var(--sp-16); border-bottom: 0; border-right: 1px solid var(--line); }
}
.seitenleiste-kopf { padding: 0 var(--sp-8); }
.marke { display: inline-flex; min-height: 44px; align-items: center; }
.firma-name { margin-top: -4px; }
.neu-knopf { width: 100%; }
.icon { width: 20px; height: 20px; flex: none; }
.nav-liste { list-style: none; padding: 0; display: flex; gap: var(--sp-4); overflow-x: auto; }
@media (min-width: 900px) { .nav-liste { flex-direction: column; overflow: visible; } }
.nav-liste a, .nav-knopf { display: flex; align-items: center; gap: var(--sp-12); min-height: 44px; padding: 0 var(--sp-12); border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--text); font: 500 15px/1.2 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color 120ms ease-out; }
.nav-liste a:hover, .nav-knopf:hover { background: var(--bg); }
.nav-liste a[aria-current="page"] { background: var(--bg); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.nav-knopf { width: 100%; }
.seitenleiste-fuss { display: grid; gap: var(--sp-8); margin-top: auto; padding-top: var(--sp-16); border-top: 1px solid var(--line); }
.sprache-form { display: flex; gap: var(--sp-8); }
.benutzer-zeile { padding: 0 var(--sp-12); overflow: hidden; text-overflow: ellipsis; }
.hauptbereich { min-width: 0; padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 56px) var(--sp-64); }
.hauptbereich > * { max-width: 1040px; }
.seitenkopf { display: grid; gap: var(--sp-12); justify-items: start; margin-bottom: var(--sp-32); }
.seitenkopf .lead { max-width: 680px; }
.abschnitt { margin-top: var(--sp-64); }
.abschnitt > .h3 { margin-bottom: var(--sp-24); }
.abschnitt-eng { margin-top: var(--sp-32); }
.abschnitt-eng > .h3 { margin-bottom: var(--sp-16); }

/* Karten */
.karten { display: grid; gap: var(--sp-16); grid-template-columns: 1fr; list-style: none; padding: 0; }
@media (min-width: 640px) { .karten { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .karten { grid-template-columns: repeat(3, 1fr); } }
.karte { position: relative; display: flex; flex-direction: column; gap: var(--sp-12); padding: var(--sp-24); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-card); transition: border-color 120ms ease-out; }
.karten .karte:hover { border-color: var(--field); }
.karte-kopf { display: flex; align-items: center; justify-content: space-between; color: var(--accent); }
.karte-kopf .icon { width: 24px; height: 24px; }
.karte-link { margin-top: auto; display: inline-flex; align-items: center; min-height: 44px; }
.karte-link::after { content: ""; position: absolute; inset: -1px; border-radius: var(--r-card); }
.karte-link:focus-visible { outline: 0; }
.karte-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Schritte (nummeriert) */
.steps { counter-reset: step; display: grid; gap: var(--sp-32); grid-template-columns: 1fr; list-style: none; padding: 0; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { counter-increment: step; border-top: 1px solid var(--line); padding-top: var(--sp-16); }
.steps li::before { content: counter(step); display: block; margin-bottom: var(--sp-8); color: var(--accent); font-size: 22px; font-weight: 600; line-height: 1.3; }
.steps p { margin-top: var(--sp-8); color: var(--muted); max-width: 34ch; }
.schritt-titel { font-size: 17px; font-weight: 600; }

/* Assistent: Schritt-Leiste + «So geht dieser Schritt» + Arbeitsfläche */
.schrittleiste { display: flex; gap: var(--sp-8); list-style: none; padding: 0; margin-bottom: var(--sp-32); overflow-x: auto; }
.schrittleiste li { display: flex; align-items: center; gap: var(--sp-8); flex: 1 0 auto; min-height: 44px; padding: 0 var(--sp-16) 0 var(--sp-8); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.schrittleiste li[aria-current="step"] { border-color: var(--accent); color: var(--text); }
.schritt-nr { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); font-size: 14px; }
.schrittleiste li[aria-current="step"] .schritt-nr { background: var(--accent); color: var(--on-accent); }
.assistent { display: grid; gap: var(--sp-16); }
@media (min-width: 1000px) { .assistent { grid-template-columns: minmax(260px, 1fr) 2fr; align-items: start; } }
.punkte-liste { padding-left: 1.25em; color: var(--muted); }
.punkte-liste li + li { margin-top: var(--sp-8); }
.platzhalter { min-height: 200px; justify-content: center; border-style: dashed; background: var(--surface); }
.ablauf { display: grid; gap: var(--sp-12); list-style: none; padding: 0; }
.ablauf li { display: grid; gap: var(--sp-8); justify-items: start; padding: var(--sp-12) var(--sp-16); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.knopf-vorschau { display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 500; }

/* Listen und Tabellen */
.liste { list-style: none; padding: 0; display: grid; gap: var(--sp-8); }
.liste-eintrag { display: grid; gap: var(--sp-12); align-items: center; padding: var(--sp-16); border: 1px solid var(--line); border-radius: var(--r-card); }
@media (min-width: 900px) { .liste-eintrag { grid-template-columns: 1fr auto auto; } }
.liste-text { display: grid; gap: 2px; min-width: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--sp-8); align-items: center; }
.inline-form .input { width: 200px; }
.inline-form .fehlertext { flex-basis: 100%; }
.kunde { margin-top: var(--sp-16); }
.kunde-name { font-size: 17px; font-weight: 600; }
.tabelle-rahmen { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 15px; }
.tabelle th, .tabelle td { padding: var(--sp-8) var(--sp-12); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tabelle th { color: var(--muted); font-weight: 500; font-size: 14px; }
.tabelle tr:last-child td { border-bottom: 0; }
.link-box { display: grid; gap: var(--sp-8); margin-bottom: var(--sp-24); }
.kopier-zeile { display: flex; gap: var(--sp-8); }
.kopier-zeile .input { flex: 1; min-width: 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; }
#einladung-ergebnis:not(:empty) { margin-top: var(--sp-24); }

/* htmx: laufende Anfrage dezent anzeigen (ohne Inline-Stile von htmx) */
.htmx-request { opacity: .6; transition: opacity 120ms ease-out; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
