/* Chatbot Scanner – Farben und Bausteine nach design/ (theme.css). Hell/Dunkel: System, ueberschreibbar per data-theme. */
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); }

:root {
  color-scheme: light;
  --bg:#f4f5f7; --surface:#ffffff; --surface-2:#f0f2f5; --line:#dfe2e8;
  --ink:#14161b; --ink-2:#2c3039; --muted:#5d6371;
  --accent:#4338ca; --on-accent:#ffffff; --accent-soft:#eceefe; --accent-line:#c9cdfb; --accent-text:#3730a3;
  --ok:#2f9e57; --ok-bg:#e3f4e8; --ok-ink:#1d6b35;
  --warn:#e5a50a; --warn-bg:#fdf1d6; --warn-ink:#7a5200;
  --bad:#d63939; --bad-bg:#fbe3e3; --bad-ink:#9b1c1c;
  --neutral-bg:#eceef2; --neutral-ink:#3b404a;
  --chat-user:#2c3039; --chat-user-ink:#ffffff; --chat-bot:#ffffff; --chat-bot-ink:#14161b; --chat-bg:#eef0f3;
  --shadow:0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:#0e1015; --surface:#161920; --surface-2:#1d212a; --line:#2a2f3a;
    --ink:#f1f3f7; --ink-2:#d3d7df; --muted:#9aa1ae;
    --accent:#8f94fb; --on-accent:#0e1015; --accent-soft:#23264a; --accent-line:#3a3f78; --accent-text:#b4b7ff;
    --ok:#3fbf6c; --ok-bg:#13301f; --ok-ink:#7ddc9d;
    --warn:#f0b429; --warn-bg:#3a2d0c; --warn-ink:#f3c860;
    --bad:#f05252; --bad-bg:#3d1717; --bad-ink:#ff9a9a;
    --neutral-bg:#252a34; --neutral-ink:#c4c9d3;
    --chat-user:#3a3f4b; --chat-user-ink:#ffffff; --chat-bot:#1d212a; --chat-bot-ink:#f1f3f7; --chat-bg:#11141a;
    --shadow:0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:#0e1015; --surface:#161920; --surface-2:#1d212a; --line:#2a2f3a;
  --ink:#f1f3f7; --ink-2:#d3d7df; --muted:#9aa1ae;
  --accent:#8f94fb; --on-accent:#0e1015; --accent-soft:#23264a; --accent-line:#3a3f78; --accent-text:#b4b7ff;
  --ok:#3fbf6c; --ok-bg:#13301f; --ok-ink:#7ddc9d;
  --warn:#f0b429; --warn-bg:#3a2d0c; --warn-ink:#f3c860;
  --bad:#f05252; --bad-bg:#3d1717; --bad-ink:#ff9a9a;
  --neutral-bg:#252a34; --neutral-ink:#c4c9d3;
  --chat-user:#3a3f4b; --chat-user-ink:#ffffff; --chat-bot:#1d212a; --chat-bot-ink:#f1f3f7; --chat-bg:#11141a;
  --shadow:0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 15px; line-height: 1.45; color: var(--ink-2); background: var(--bg); }
a { color: var(--accent-text); }
a:hover { color: var(--accent); }
input, textarea, button, select { font: inherit; }
::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; color: var(--ink); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; }
.leise { color: var(--muted); font-size: 13px; }
.versteckt { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Rahmen: Seitenleiste, Kopf, Inhalt --- */
.app { display: flex; min-height: 100vh; }
.side { width: 248px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.marke { display: flex; align-items: center; gap: 10px; padding: 4px 10px 24px; }
.marke-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.marke b { display: block; font-weight: 700; color: var(--ink); font-size: 16px; letter-spacing: -0.01em; }
.marke span { font-size: 12px; color: var(--muted); }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-link .zahl { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.konto { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.konto-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.konto b { display: block; color: var(--ink); font-weight: 600; }
.konto-links { display: flex; gap: 10px; margin-top: 2px; }
.konto-links a, .konto-links button { font-size: 12px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.kopf { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.kopf h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.kopf .pfad { font-size: 14px; color: var(--muted); }
.kopf .pfad a { color: var(--muted); }
.kopf-aktionen { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inhalt { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; }

/* Mobil: Kopfzeile oben, Leiste unten, Seitenleiste als Menue */
.mobil-kopf, .mobil-nav { display: none; }
@media (max-width: 860px) {
  .side { display: none; position: fixed; inset: 0 auto 0 0; z-index: 20; height: 100%; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .side.offen { display: flex; }
  .mobil-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .mobil-kopf .marke { padding: 0; }
  .mobil-kopf .marke-icon { width: 34px; height: 34px; border-radius: 9px; }
  .mobil-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: sticky; bottom: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); z-index: 10; }
  .mobil-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; font-size: 11px; font-weight: 600; text-decoration: none; color: var(--muted); }
  .mobil-nav a[aria-current="page"] { color: var(--accent-text); }
  .app { flex-direction: column; }
  .kopf { padding: 16px; }
  .kopf .theme-knopf { display: none; }
  .kopf h1 { font-size: 1.25rem; }
  .inhalt { padding: 16px 16px 32px; gap: 16px; }
}

/* --- Bausteine --- */
.karte { border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); min-width: 0; }
.karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.karte-kopf h2 { font-size: 1.125rem; font-weight: 600; }
.karte-inhalt { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.reihe { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }

.hinweis { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink); font-size: 14px; }
.hinweis svg { flex-shrink: 0; color: var(--accent-text); }
.hinweis.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn-ink); }
.hinweis.warn svg { color: var(--warn-ink); }
.hinweis.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--bad-ink); }
.hinweis.bad svg { color: var(--bad-ink); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi > span:first-child { font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .wert { font-size: 2.25rem; font-weight: 600; color: var(--ink); line-height: 1.1; }
.kpi .wert small { font-size: 1rem; font-weight: 400; color: var(--muted); }
.kpi.intern { border: 1px dashed var(--accent-line); box-shadow: none; }
.marker { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 600; }

.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.knopf:hover { background: var(--surface-2); color: var(--ink); }
.knopf.primaer { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.knopf.primaer:hover { filter: brightness(1.08); color: var(--on-accent); }
.knopf.gefahr { color: var(--bad-ink); border-color: var(--bad); background: var(--surface); }
.knopf.gefahr:hover { background: var(--bad-bg); }
.knopf.klein { min-height: 36px; padding: 0 14px; font-size: 13px; background: var(--surface-2); }
.knopf.klein.primaer { background: var(--accent); }
.knopf:disabled, .knopf[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.icon-knopf { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; flex-shrink: 0; }

/* Pills: Ampel, Freigabe-Status, Schwere */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; justify-self: start; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ohne-punkt::before { display: none; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); } .pill.ok::before { background: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); } .pill.warn::before { background: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); } .pill.bad::before { background: var(--bad); }
.pill.neutral { background: var(--neutral-bg); color: var(--neutral-ink); } .pill.neutral::before { background: var(--muted); }
.pill.akzent { background: var(--accent-soft); color: var(--accent-text); } .pill.akzent::before { background: var(--accent); }

.balken { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.balken > div { height: 6px; }

/* Tabellen als Grid-Zeilen (wie im Design); breite Tabellen scrollen horizontal */
.tabelle { overflow-x: auto; }
.tabelle .zeile { display: grid; gap: 12px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 14px; }
.tabelle .zeile.titel { padding: 10px 20px; background: var(--surface-2); border-top: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.zelle-2 { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.zelle-2 > :first-child { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }

.liste { list-style: none; margin: 0; padding: 8px 20px 16px; display: flex; flex-direction: column; }
.liste li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.liste li:last-child { border-bottom: 0; }
.rund-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--neutral-bg); color: var(--neutral-ink); }
.rund-icon.ok { background: var(--ok-bg); color: var(--ok-ink); }
.rund-icon.warn { background: var(--warn-bg); color: var(--warn-ink); }
.rund-icon.bad { background: var(--bad-bg); color: var(--bad-ink); }
.rund-icon.akzent { background: var(--accent-soft); color: var(--accent-text); }

/* Formulare */
.feld { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.feld > span { font-weight: 600; color: var(--ink); }
.feld small { color: var(--muted); font-size: 13px; }
.feld input:not([type="checkbox"]):not([type="radio"]), .feld select, .feld textarea {
  min-height: 44px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%;
}
.feld textarea { min-height: 88px; resize: vertical; }
.feld input:focus, .feld select:focus, .feld textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.feld-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.haken { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.haken input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.wahl { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.wahl:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.wahl input { margin-top: 3px; accent-color: var(--accent); }

.meldung { padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.meldung.fehler { background: var(--bad-bg); color: var(--bad-ink); }
.meldung.ok { background: var(--ok-bg); color: var(--ok-ink); }
.leer { padding: 32px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.laden { padding: 32px 20px; color: var(--muted); font-size: 14px; }

/* Chat (Live-Gespraech, Belege) */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 10px; background: var(--chat-bg); }
.blase { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.blase small { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; opacity: .7; margin-bottom: 2px; }
.blase.scanner { align-self: flex-end; background: var(--chat-user); color: var(--chat-user-ink); border-bottom-right-radius: 4px; }
.blase.bot { align-self: flex-start; background: var(--chat-bot); color: var(--chat-bot-ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }

/* Bestaetigung der Berechtigung */
.bestaetigung { margin: 0; padding: 16px; border: 1px solid var(--accent-line); border-radius: 10px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.bestaetigung legend { padding: 0 6px; font-weight: 600; color: var(--ink); }
.bedingungen { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.bedingungen summary { padding: 10px 12px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent-text); }
.bedingungen-text { padding: 0 12px 12px; max-height: 280px; overflow-y: auto; white-space: pre-line; font-size: 13px; color: var(--ink-2); }

/* Dialog (native <dialog>) */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
dialog h2 { font-size: 1.125rem; }
.dialog-knoepfe { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Anmelden / Passwort: Karte mittig */
.mitte { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.mitte .karte { width: min(420px, 100%); }
.mitte form { display: flex; flex-direction: column; gap: 16px; padding: 24px; }

@keyframes puls { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.puls { animation: puls 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .puls { animation: none; } }

/* Mobil-Anpassungen der Bausteine (nach den Basisregeln, sonst wirken sie nicht) */
@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .wert { font-size: 1.75rem; }
  .karte-kopf, .karte-inhalt { padding: 16px; }
  /* .tabelle.stapeln: Zeilen werden zu zweispaltigen Karten statt seitlich zu scrollen */
  .tabelle.stapeln > div { min-width: 0 !important; }
  .tabelle.stapeln .zeile { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; padding: 14px 16px; }
  .tabelle.stapeln .zeile.titel { display: none; }
  .tabelle.stapeln .zeile > :first-child { grid-column: 1 / -1; }
}
