/*
 * AI-UI for SAP – gemeinsames Design-System (Single Source of Truth).
 * Kanonische UI-CSS für das Portal UND alle angeschlossenen Fach-Apps.
 *
 *   <link rel="stylesheet" href="/portalauth/assets/ui.css">
 *
 * Stylesets: assets/stylesets/<name>.css überschreibt nur die Tokens (Gpaifw\Ui\Styleset,
 * Auswahl je Benutzer unter „Mein Konto“). Ohne Styleset = Classic.
 *
 * Regeln: nur diese Design-Tokens (CSS-Variablen unten) und Basis-Klassen verwenden –
 * NICHT je App eigene Farben/Abstände erfinden. App-spezifische Feinheiten in einer
 * kleinen eigenen CSS NACH dieser Datei laden (überschreibt gezielt). Keine Inline-
 * Styles (CSP style-src 'self'). Details: portalauth/docs/ui-standard.md.
 *
 * Basis-Klassen: .topbar/.brand/.logo/.hauptnav/.benutzer · .wrap · .kacheln/.kachel
 * · .btn(.sekundaer/.gefahr/.klein) · .feld/.zeile · .meldung(.ok/.fehler/.info)
 * · table/.karte-box/.badge · .subnav · .login-box/.login-brand.
 */
:root {
    /* Grundtokens. Ein Styleset (assets/stylesets/<name>.css) überschreibt nur diese
       Variablen und lädt ggf. Schriften – Komponenten bleiben gleich. Werte hier = Classic. */
    --primaer: #0d3b66;           /* Interaktion, Kopfzeile, Überschriften-Akzent */
    --primaer-hell: #1b5a97;
    --primaer-weich: #e7eff7;
    --akzent: #f2a900;            /* Markierung: Logo, aktive Reiter, Linien */
    --bg: #f4f6f9;
    --karte: #ffffff;
    --flaeche-2: #eef3f9;         /* Symbolfelder, Zähler, Sekundärknöpfe */
    --flaeche-3: #fafbfd;         /* Zeilen-Hover */
    --eingabe-bg: #ffffff;
    --rand: #e2e7ee;
    --text: #1c2733;
    --dezent: #6b7787;
    --ok: #1f8a4c;
    --ok-weich: #e7f6ec;
    --ok-rand: #bfe6cd;
    --warn: #b3261e;              /* historisch: Fehler/Gefahr (rot) */
    --fehler-weich: #fdecea;
    --fehler-rand: #f5c6c2;
    --info-weich: #eaf1fb;
    --info-rand: #cbdcf3;
    --achtung: #b86200;           /* Status „Achtung“ (orange) */
    --achtung-weich: #fff5e0;
    --admin-weich: #fdeccd;
    --admin-text: #96591a;
    --topbar-bg: var(--primaer);
    --topbar-text: #ffffff;
    --topbar-link: #d7e2f0;
    --topbar-dezent: #cdd9e8;
    --radius: 10px;
    --radius-klein: 7px;
    --radius-pille: 20px;
    --schatten: 0 1px 3px rgba(16,32,56,.08), 0 4px 14px rgba(16,32,56,.06);
    --schatten-hover: 0 6px 20px rgba(16,32,56,.12);
    --schrift: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --schrift-titel: var(--schrift);
    --schrift-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --titel-gewicht: 700;
    --serie-1: var(--primaer-hell); --serie-2: #7fb3d5; --serie-3: #9aa6b1;   /* Diagramme */
    --grafik-akzent: var(--warn);   /* Markierung oben links an Grafiken */

    /* Alte Namen – Apps verwenden sie in eigener CSS weiter. */
    --wk-blau: var(--primaer);
    --wk-blau-hell: var(--primaer-hell);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--schrift);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}
a { color: var(--primaer-hell); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--topbar-bg); color: var(--topbar-text);
    padding: 0 1.25rem; height: 56px;
}
.topbar .brand a { color: var(--topbar-text); font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.topbar .brand a:hover { text-decoration: none; }
.logo {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px; border-radius: 6px;
    background: var(--akzent); color: var(--primaer); font-weight: 800; font-size: .8rem;
}
.hauptnav { display: flex; gap: 1.1rem; margin-left: .5rem; }
.hauptnav a { color: var(--topbar-link); font-size: .95rem; }
.hauptnav a:hover { color: var(--topbar-text); text-decoration: none; }
.benutzer { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.benutzer .wer { color: var(--topbar-dezent); font-size: .9rem; }
.btn-abmelden { color: var(--topbar-text); border: 1px solid rgba(255,255,255,.35); padding: .3rem .7rem; border-radius: var(--radius-klein); font-size: .85rem; }
.btn-abmelden:hover { background: rgba(255,255,255,.12); text-decoration: none; }

/* Layout */
.wrap { max-width: 1100px; margin: 2rem auto; padding: 0 1.25rem; }
h1 { font-size: 1.5rem; margin: 0 0 .3rem; font-family: var(--schrift-titel); font-weight: var(--titel-gewicht); }
h2 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; font-family: var(--schrift-titel); font-weight: var(--titel-gewicht); }
.dezent { color: var(--dezent); }
.unter { color: var(--dezent); margin: 0 0 1.5rem; }

/* Kachel-Dashboard */
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.kachel {
    display: block; background: var(--karte); border: 1px solid var(--rand);
    border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--schatten);
    transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease;
}
.kachel:hover { transform: translateY(-2px); border-color: var(--primaer-hell); text-decoration: none; box-shadow: var(--schatten-hover); }
.kachel .kicon {
    display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 9px;
    background: var(--flaeche-2); font-size: 1.3rem; margin-bottom: .7rem;
}
.kachel .knam { font-weight: 600; color: var(--text); font-size: 1.02rem; }
.kachel .kbeschr { color: var(--dezent); font-size: .88rem; margin-top: .25rem; min-height: 2.4em; }
.kachel .krolle { display: inline-block; margin-top: .6rem; font-size: .72rem; color: var(--primaer);
    background: var(--primaer-weich); border-radius: var(--radius-pille); padding: .12rem .6rem; }

.leer { background: var(--karte); border: 1px dashed var(--rand); border-radius: var(--radius);
    padding: 2rem; text-align: center; color: var(--dezent); }

/* Login */
.login-box { max-width: 360px; margin: 6vh auto; background: var(--karte); border: 1px solid var(--rand);
    border-radius: var(--radius); padding: 2rem; box-shadow: var(--schatten); }
.login-box h1 { text-align: center; margin-bottom: 1.2rem; font-size: 1.2rem; color: var(--dezent); font-weight: 500; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: .5rem; font-weight: 700;
    font-size: 1.15rem; color: var(--primaer); margin-bottom: .3rem; }
.login-brand .logo { width: 34px; height: 34px; font-size: .9rem; }

/* Formular */
.feld { margin-bottom: 1rem; }
.feld label { display: block; font-size: .85rem; color: var(--dezent); margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=email], select {
    width: 100%; padding: .55rem .65rem; border: 1px solid var(--rand); border-radius: var(--radius-klein);
    font-size: .95rem; background: var(--eingabe-bg); color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primaer-hell); outline-offset: -1px; border-color: var(--primaer-hell); }
.btn { display: inline-block; background: var(--primaer); color: #fff; border: 0; border-radius: var(--radius-klein);
    padding: .55rem 1.1rem; font-size: .95rem; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--primaer-hell); text-decoration: none; }
.btn.sekundaer { background: var(--flaeche-2); color: var(--primaer); }
.btn.gefahr { background: var(--warn); }
.btn.klein { padding: .3rem .6rem; font-size: .82rem; }
.voll { width: 100%; }
.zeile { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.zeile .feld { margin-bottom: 0; }

/* Meldungen */
.meldung { padding: .7rem .9rem; border-radius: var(--radius-klein); margin-bottom: 1rem; font-size: .92rem; }
.meldung.fehler { background: var(--fehler-weich); color: var(--warn); border: 1px solid var(--fehler-rand); }
.meldung.ok { background: var(--ok-weich); color: var(--ok); border: 1px solid var(--ok-rand); }
.meldung.info { background: var(--info-weich); color: var(--primaer); border: 1px solid var(--info-rand); }

/* Tabellen (Verwaltung) */
.karte-box { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius);
    box-shadow: var(--schatten); padding: 1.2rem 1.3rem; margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--rand); vertical-align: middle; }
th { color: var(--dezent); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--flaeche-3); }
.tabelle-scroll { overflow-x: auto; }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: var(--radius-pille); }
.badge.admin { background: var(--admin-weich); color: var(--admin-text); }
.badge.user { background: var(--primaer-weich); color: var(--primaer); }
.badge.aus { background: var(--fehler-weich); color: var(--warn); }
.badge.an { background: var(--ok-weich); color: var(--ok); }

/* Admin-Subnav */
.subnav { display: flex; gap: 1rem; border-bottom: 1px solid var(--rand); margin-bottom: 1.4rem; }
.subnav a { padding: .55rem .2rem; color: var(--dezent); border-bottom: 2px solid transparent; }
.subnav a.aktiv { color: var(--primaer); border-bottom-color: var(--akzent); font-weight: 600; }
.subnav a:hover { text-decoration: none; color: var(--primaer); }

.aktion-form { display: inline; }
.rechts { text-align: right; }
.rechts-block { display: block; margin-top: .6rem; text-align: right; }
.kicon-klein { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
    background: var(--flaeche-2); font-size: .95rem; vertical-align: middle; margin-right: .3rem; }
textarea { width: 100%; padding: .55rem .65rem; border: 1px solid var(--rand); border-radius: var(--radius-klein);
    background: var(--eingabe-bg); color: var(--text); font-family: var(--schrift-mono); font-size: .85rem; resize: vertical; }
.zeile label { font-size: .9rem; color: var(--text); display: inline-flex; align-items: center; gap: .35rem; }
.fuss { max-width: 1100px; margin: 2rem auto; padding: 1rem 1.25rem; color: var(--dezent);
    font-size: .82rem; display: flex; justify-content: space-between; border-top: 1px solid var(--rand); }

/* Dashboard: Fachbereich-Reiter + Gruppen */
.bereich-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 1.6rem; }
.bereich-tab { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius-pille);
    padding: .38rem .9rem; font-size: .9rem; color: var(--text); cursor: pointer; transition: all .12s ease; }
.bereich-tab:hover { border-color: var(--primaer-hell); }
.bereich-tab.aktiv { background: var(--primaer); color: #fff; border-color: var(--primaer); }
.bereich-tab .tab-zahl { display: inline-block; margin-left: .3rem; font-size: .72rem; opacity: .7; }
.bereich-sektion { margin-bottom: 1.8rem; }
.bereich-sektion[hidden] { display: none; }
.bereich-titel { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; color: var(--primaer);
    margin: 0 0 .8rem; padding-bottom: .4rem; border-bottom: 2px solid var(--akzent); }
.bereich-zahl { font-size: .75rem; color: var(--dezent); background: var(--flaeche-2); border-radius: var(--radius-pille); padding: .05rem .5rem; }

/* Abstands-Utilities (statt Inline-Styles, CSP-konform) */
.mt-1 { margin-top: .75rem; }
.mt-2 { margin-top: 1rem; }

/* Checkbox-Label in einer .zeile (z. B. „exakt spiegeln") */
.wahl { white-space: nowrap; }

/* Vorschau der Rechte-Übernahme (Berechtigungen): Zeilen nach Aktion einfärben */
.plan-neu       td { background: var(--ok-weich); }
.plan-aendern   td { background: var(--achtung-weich); }
.plan-entfernen td { background: var(--fehler-weich); }
.plan-gleich    td { color: var(--dezent); }

/* --------------------------------------------------------------------------
 * Kundenlogo und -name in der Kopfzeile.
 * Hier und nicht in einer App: die Marke erscheint in JEDER Anwendung, also
 * gehoert der Stil in das geteilte Stylesheet. Hoehe begrenzt, Breite folgt —
 * ein Logo kommt in jedem Seitenverhaeltnis, die Kopfzeile darf davon nicht
 * wachsen.
 * -------------------------------------------------------------------------- */
.brand .logo-bild { height: 28px; width: auto; max-width: 160px; vertical-align: middle; border-radius: 4px; }
.brand .kunde     { font-weight: 400; opacity: .85; }
.fuss .kunde      { opacity: .85; }

/* --------------------------------------------------------------------------
 * hidden bleibt hidden.
 *
 * Das HTML-Attribut wirkt ueber die Browser-Vorgabe "display: none". Sobald
 * eine App demselben Element ein eigenes display gibt — .sa-anhang { display:
 * flex } etwa — schlaegt das die Vorgabe, weil Klassen- und Attributselektor
 * dieselbe Spezifitaet haben und die spaetere Regel gewinnt. Das Element bleibt
 * dann sichtbar, obwohl das JavaScript es korrekt auf hidden setzt.
 *
 * Genau so ist im SAP-AI-Agenten der Anhang-Balken dauerhaft stehen geblieben,
 * mitsamt einem <img> ohne src — also dem Symbol fuer ein kaputtes Bild.
 *
 * !important ist hier bewusst gesetzt: die Regel soll nicht von der Reihenfolge
 * der Stylesheets abhaengen (ui.css wird mal vor, mal nach der App-CSS
 * geladen), und "unsichtbar" ist keine Gestaltungsfrage, sondern eine Zusage.
 * Dieselbe Loesung waehlt normalize.css.
 * -------------------------------------------------------------------------- */
[hidden] { display: none !important; }

/* Zahlen in Tabellen: gleich breite Ziffern, rechtsbündig */
.zahl { font-variant-numeric: tabular-nums; text-align: right; }

/* ==========================================================================
 * Bedienstandard (docs/BEDIENUNG.md): Reiter im Kopf, „Letzte Läufe“, Live-Log,
 * Status-Badges, Statuszeile laufender Jobs. Markup erzeugt Gpaifw\Web\Livelog,
 * das Verhalten assets/livelog.js. Nur Tokens – passt zu allen Stylesets.
 * -------------------------------------------------------------------------- */
:root { --live-punkt: #3ddc84; }            /* „hier läuft etwas“ in der dunklen Kopfzeile */

/* Reiter: aktiver Reiter mit Akzentlinie unten, Punkt bei laufendem Lauf, „← Portal“ */
.hauptnav { align-self: stretch; align-items: stretch; }
.hauptnav a { display: flex; align-items: center; padding: 0 .1rem; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.hauptnav a.aktiv { color: var(--topbar-text); font-weight: 600; border-bottom-color: var(--akzent); }
.reiter-punkt { color: var(--live-punkt); font-size: .75em; margin-right: .15rem; }
.portal-link { color: var(--topbar-link); font-size: .9rem; white-space: nowrap; }
.portal-link:hover { color: var(--topbar-text); text-decoration: none; }

/* Status-Badges der Läufe: wartet/läuft blau, fertig grün, Fehler/abgebrochen rot */
.badge.s-wartet, .badge.s-laeuft { background: var(--info-weich); color: var(--primaer); }
.badge.s-fertig { background: var(--ok-weich); color: var(--ok); }
.badge.s-fehler, .badge.s-abgebrochen { background: var(--fehler-weich); color: var(--warn); }

/* „Letzte Läufe“ */
table.laeufe .num { text-align: right; font-variant-numeric: tabular-nums; }
table.laeufe .nowrap, .live-tab .nowrap { white-space: nowrap; }
table.laeufe td.letzte-meldung { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dezent); }
p.mehr { margin: .5rem 0 0; font-size: .9rem; }

/* Statuszeile eines laufenden Jobs auf einer Fachseite */
.job-laeuft [data-job-zeile] { font-weight: 600; margin-left: .3rem; }

/* Live-Log: Kopf mit Modus und Anzeige, Tabelle Zeit · Stufe · Meldung mit begrenzter Höhe */
.live-kopf { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; margin: .3rem 0 .7rem; font-size: .9rem; }
.live-kopf .klein { font-size: .85rem; }
.live-an { color: var(--ok); font-weight: 600; }
.live-aus { color: var(--dezent); }
.livelog { max-height: 68vh; overflow-y: auto; background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); }
.live-tab { font-size: .85rem; }
.live-tab th, .live-tab td { padding: .35rem .6rem; }
.live-tab thead th { position: sticky; top: 0; z-index: 1; background: var(--karte); box-shadow: 0 1px 0 var(--rand); }
.live-tab td:first-child { width: 1%; white-space: nowrap; }
.live-tab td:nth-child(2) { width: 1%; white-space: nowrap; color: var(--dezent); }
.live-tab td:last-child { word-break: break-word; }
.live-tab .mono { font-family: var(--schrift-mono); }
.live-tab tr.live-lauf td { background: var(--flaeche-2); font-weight: 600; color: var(--text); border-top: 2px solid var(--rand); }
.live-tab tr.live-lauf.s-fehler td, .live-tab tr.live-lauf.s-abgebrochen td { color: var(--warn); }
.live-tab tr.live-lauf.s-fertig td:last-child { color: var(--ok); }
.live-tab tr.ev-err td { background: var(--fehler-weich); color: var(--warn); }


/* Schnellstart (Strg+K, assets/schnellstart.js): optionaler Knopf in der Kopfzeile (Schnellstart::knopf) */
.gp-ss-knopf { background: transparent; border: 1px solid rgba(255,255,255,.35); color: var(--topbar-link); border-radius: var(--radius-klein);
    padding: .2rem .55rem; font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.gp-ss-knopf:hover { color: var(--topbar-text); background: rgba(255,255,255,.12); }
.gp-ss-knopf kbd { font: .75rem var(--schrift-mono); }
