/* Unverändert aus ai-gateway (apps/web/src/styles/tokens.css, tokens.md v1.1, adorsys-Styleguide). Einzige Stelle mit Hex-Werten. */
:root {
  /* Typografie */
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-size-base: 14px;
  --line-height-base: 1.45;

  /* Neutral */
  --bg-app: #f5f6f8;
  --bg-surface: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-hover-row: #fafbfc;
  --bg-chip: #f0f2f5;
  --text-primary: #0f1a2a;
  --text-secondary: #556173;
  /* Styleguide Grau-80 (v1.1): AA auf bg-surface, bg-subtle, bg-hover-row */
  --text-muted: #6e7380;
  --border-strong: #d5dae1;
  --border: #e3e6eb;
  --border-subtle: #edf0f4;
  --underline: #c9d0da;
  /* Rand von Eingabefeldern, Auswahllisten, Checkboxen (Styleguide Grau-80, 3:1, v1.1) */
  --border-input: #6e7380;

  /* Primär */
  --primary: #2350d8;
  --primary-hover: #1a3ca6;
  --primary-subtle: #e8eefc;
  --primary-selected: #f2f6fe;
  --on-primary: var(--bg-surface);

  /* Status */
  --success-text: #1e6b44;
  --success-strong: #1e7b4c;
  --success-bg: #e6f4ec;
  --warning-text: #9a4508;
  --warning-strong: #b4530a;
  --warning-bg: #fdf0e4;
  --warning-bg-soft: #fdf6ee;
  --danger: #b42318;
  --danger-border: #f3c7b5;
  --over-budget: #c2410c;
  --neutral-badge-text: #4a5565;
  --neutral-badge-bg: #edf0f4;

  /* Sidebar (dunkel) */
  --nav-bg: #0e1726;
  --nav-text: #b8c3d6;
  --nav-text-muted: #8c9ab3;
  --nav-text-active: #ffffff;
  --nav-active-bg: #1c2940;
  --nav-hover-bg: #16223a;
  --nav-card-bg: #121d30;
  --nav-card-border: #24324a;
  --nav-divider: var(--nav-card-border);
  /* Fokus auf dunklem Grund: Styleguide Akzent-Hellblau (v1.1; primary hat dort nur 2,7:1) */
  --nav-focus: #25a8db;

  /* Diagramme (Reihenfolge der Serien; 2–5 unter 3:1 → immer mit Beschriftung oder Tabelle) */
  --chart-1: #1e3fae;
  --chart-2: #5b8def;
  --chart-3: #e07b26;
  --chart-4: #f2c14e;
  --chart-5: #c3cad5;
  --chart-single: var(--primary);
  --chart-highlight: var(--text-primary);

  /* Größen (tokens.md → Abstände, Größen, Formen) */
  --sidebar-width: 248px;
  --topbar-height: 70px;
  --content-max-width: 1440px;
  --control-lg: 44px;
  --control-md: 40px;
  --control-sm: 36px;

  /* Formen */
  --radius-control: 8px;
  --radius-card: 12px;
  --radius-tile: 10px;
  --radius-chip: 6px;
  --radius-pill: 999px;
  --shadow-popover: 0 8px 24px rgba(15, 26, 42, 0.1);
  /* Overlay hinter Dialogen: text-primary mit Transparenz */
  --overlay: rgba(15, 26, 42, 0.4);
}

/*
 * Look & Feel des AI Gateway (tokens.md → Komponentenmuster), ohne Tailwind nachgebaut.
 * Nur Token-Variablen aus tokens.css, keine eigenen Hex-Werte.
 */

@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'); }

/* MARK: Basis */

*, ::before, ::after { box-sizing: border-box; border-color: var(--border); }
html {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
code, .mono { font-family: var(--font-mono); font-size: 12px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }

/* Typostufen */
.text-display { font-size: 28px; letter-spacing: -0.02em; font-weight: 600; line-height: 1.2; }
.text-title { font-size: 18px; font-weight: 600; }
.text-heading { font-size: 16px; font-weight: 600; }
.text-small { font-size: 13px; }
.text-caption { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }

/* MARK: App-Shell */

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--bg-surface); padding: 8px 16px; border-radius: var(--radius-control); box-shadow: var(--shadow-popover); }

.shell { min-height: 100svh; background: var(--bg-app); }
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
}

.sidebar-col { display: none; background: var(--nav-bg); }
@media (min-width: 1024px) {
  .sidebar-col { display: block; }
  .sidebar-col > .sidebar { position: sticky; top: 0; height: 100svh; overflow-y: auto; }
}
/* Unter 1024 px: Menü als Seitenblatt, ohne Skript über eine Checkbox */
#nav-toggle:checked ~ .sidebar-col { display: block; position: fixed; inset: 0 auto 0 0; z-index: 50; width: var(--sidebar-width); max-width: 85vw; overflow-y: auto; }
#nav-toggle:checked ~ .nav-overlay { display: block; }
.nav-overlay { display: none; position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
@media (min-width: 1024px) { #nav-toggle:checked ~ .nav-overlay { display: none; } }

.sidebar { display: flex; flex-direction: column; min-height: 100%; padding: 24px 14px 20px; background: var(--nav-bg); color: var(--nav-text); }
.sidebar-brand { padding: 0 10px 24px; }
.sidebar-brand img { height: 28px; width: auto; display: block; }
.sidebar-brand p { margin-top: 20px; font-size: 13px; font-weight: 500; color: var(--nav-text-muted); }
.nav-section { display: flex; flex-direction: column; }
.nav-section + .nav-section { margin-top: 16px; }
.nav-section.divider::before { content: ''; display: block; margin: 0 12px 12px; border-top: 1px solid var(--nav-divider); }
.nav-label { padding: 4px 12px 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--nav-text-muted); }
.nav-section ul { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: var(--control-lg); padding: 0 12px;
  border-radius: var(--radius-control); color: var(--nav-text); font-size: 14px;
}
.nav-link:hover { background: var(--nav-hover-bg); color: var(--nav-text-active); }
.nav-link:focus-visible { outline: 2px solid var(--nav-focus); outline-offset: -2px; }
.nav-link.active { background: var(--nav-active-bg); color: var(--nav-text-active); font-weight: 500; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--nav-text-muted); font-variant-numeric: tabular-nums; }

.content-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: var(--topbar-height); padding: 0 16px; background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
@media (min-width: 640px) { .topbar { padding: 0 32px; } }
.menu-button {
  display: flex; align-items: center; justify-content: center; width: var(--control-lg); height: var(--control-lg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--bg-surface); color: var(--text-primary); cursor: pointer;
}
.menu-button:hover { background: var(--bg-subtle); }
@media (min-width: 1024px) { .menu-button { display: none; } }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-meta { display: flex; flex-direction: column; gap: 4px; min-width: 126px; font-size: 13px; color: var(--text-secondary); }
.meter { height: 6px; border-radius: 4px; background: var(--border-subtle); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.meter > span.danger { background: var(--danger); }
.avatar {
  display: flex; align-items: center; justify-content: center; width: var(--control-lg); height: var(--control-lg);
  border-radius: var(--radius-pill); background: var(--primary-subtle); color: var(--primary); font-weight: 600; font-size: 13px;
}

main { width: 100%; max-width: var(--content-max-width); margin: 0 auto; padding: 28px 16px 48px; outline: none; }
@media (min-width: 640px) { main { padding: 28px 32px 48px; } }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* MARK: Seitenkopf */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header > div:first-child { min-width: 0; }
.page-header h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-header p { margin-top: 4px; color: var(--text-secondary); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumb { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.crumb a { color: var(--text-secondary); }

/* MARK: Kacheln, Karten */

.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-tile {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 20px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-card); color: var(--text-primary);
}
a.stat-tile:hover { border-color: var(--border-strong); color: var(--text-primary); }
a.stat-tile.selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.stat-tile .label { font-size: 13px; color: var(--text-secondary); }
.stat-tile .value { font-size: 28px; letter-spacing: -0.02em; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-tile .value.danger { color: var(--danger); }
.stat-tile .value.warning { color: var(--warning-text); }
.stat-tile .value.success { color: var(--success-text); }
.stat-tile .meta { font-size: 13px; color: var(--text-secondary); }

.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-card); min-width: 0; }
.card-body { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 0; }
.card-head + .card-body { padding-top: 12px; }
.card-head + .table-wrap { margin-top: 12px; }
.card-foot { padding: 12px 14px 16px; font-size: 13px; color: var(--text-secondary); border-top: 1px solid var(--border-subtle); }
.card.danger-zone { border-color: var(--danger-border); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.grid-policy { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); align-items: start; }
@media (max-width: 1100px) { .grid-policy { grid-template-columns: 1fr; } }

/* Fakten (Label/Wert) */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; }
.facts dt { color: var(--text-secondary); font-size: 13px; }
.facts dd { min-width: 0; overflow-wrap: anywhere; }
.facts-wide { grid-template-columns: max-content 1fr max-content 1fr; }
@media (max-width: 900px) { .facts-wide { grid-template-columns: max-content 1fr; } }

/* MARK: Tabs, Filter */

.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 14px 12px 12px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab .count { color: var(--text-secondary); font-weight: 400; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 14px 12px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); width: 16px; height: 16px; }
.search input[type=search] { padding-left: 34px; }

/* MARK: Formulare, Buttons */

input[type=text], input[type=search], input[type=password], textarea, select {
  width: 100%; min-height: var(--control-md); padding: 8px 12px; font: inherit; color: var(--text-primary);
  background: var(--bg-surface); border: 1px solid var(--border-input); border-radius: var(--radius-control);
}
textarea { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-sm); padding: 0 14px;
  font: inherit; font-size: 13px; font-weight: 600; border-radius: var(--radius-control); cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-primary);
}
.btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { color: var(--danger); background: var(--bg-subtle); }
.btn-lg { min-height: var(--control-lg); width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }

/* MARK: Tabellen */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { padding: 10px 8px; text-align: left; font-size: 13px; font-weight: 500; color: var(--text-secondary); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 8px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 14px; }
th:last-child, td:last-child { padding-right: 14px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover-row); }
th.num, td.num { text-align: right; }
table.compact td { padding-top: 8px; padding-bottom: 8px; }
.name-link { color: var(--text-primary); font-weight: 500; text-decoration: underline; text-decoration-color: var(--underline); text-underline-offset: 3px; }
.name-link:hover { color: var(--primary); text-decoration-color: currentColor; }
.cell-sub { font-size: 13px; color: var(--text-secondary); }
.chip { display: inline-block; padding: 1px 8px; border-radius: var(--radius-chip); background: var(--bg-chip); font-size: 13px; }

/* MARK: Badges, Hinweise */

.badge {
  display: inline-flex; align-items: center; width: fit-content; padding: 2px 8px; border-radius: var(--radius-pill);
  border: 1px solid transparent; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--bg-surface); color: var(--danger); border-color: var(--danger-border); }
.badge-neutral { background: var(--neutral-badge-bg); color: var(--neutral-badge-text); }
.badge-info { background: var(--primary-subtle); color: var(--primary); }

.info-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-tile); background: var(--primary-subtle); color: var(--primary); font-size: 13px; }
.alert { padding: 12px 14px; border-radius: var(--radius-tile); font-size: 13px; }
.alert-danger { color: var(--danger); background: var(--bg-surface); border: 1px solid var(--danger-border); }
.alert-success { color: var(--success-text); background: var(--success-bg); }

/* Hinweis-Kachel: Icon links, Titel 14/600, Meta 13/secondary, Hintergrund in Statusfarbe */
.notice-list { display: flex; flex-direction: column; gap: 10px; }
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-tile); background: var(--bg-subtle); }
.notice .icon { margin-top: 1px; }
.notice-critical { background: var(--warning-bg-soft); border: 1px solid var(--danger-border); }
.notice-critical .icon { color: var(--danger); }
.notice-warning { background: var(--warning-bg); }
.notice-warning .icon { color: var(--warning-strong); }
.notice-info { background: var(--primary-selected); }
.notice-info .icon { color: var(--primary); }
.notice-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice-meta { margin-top: 2px; font-size: 13px; color: var(--text-secondary); white-space: pre-line; }
.notice-items { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }

.state-ok { color: var(--success-text); font-weight: 500; }
.state-bad { color: var(--danger); font-weight: 600; }
.state-unknown { color: var(--text-muted); }

/* Verlauf: ein Balken je Report, älteste links */
.strip { display: flex; gap: 3px; height: 28px; align-items: stretch; }
.strip span { flex: 1; max-width: 14px; border-radius: 3px; }
.strip-ok { background: var(--success-strong); }
.strip-attention { background: var(--warning-strong); }
.strip-critical { background: var(--danger); }
.strip-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.strip-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.strip-legend .l-ok::before { background: var(--success-strong); }
.strip-legend .l-attention::before { background: var(--warning-strong); }
.strip-legend .l-critical::before { background: var(--danger); }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary .chevron { transition: transform 0.15s; color: var(--text-secondary); }
details[open] > summary .chevron { transform: rotate(90deg); }

.empty { padding: 48px 20px; text-align: center; color: var(--text-secondary); }
.empty h2 { color: var(--text-primary); margin-bottom: 6px; }

.field-list dt { font-family: var(--font-mono); font-size: 12px; margin-top: 10px; }
.field-list dd { font-size: 13px; color: var(--text-secondary); }

/* MARK: Anmeldung (AuthLayout) */

.auth { display: flex; flex-direction: column; min-height: 100svh; background: var(--bg-app); }
.auth-header {
  display: flex; align-items: center; gap: 16px; height: var(--topbar-height); padding: 0 16px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
@media (min-width: 640px) { .auth-header { padding: 0 32px; } }
.auth-header img { height: 28px; width: auto; }
.auth-header .sep { height: 24px; border-left: 1px solid var(--border-strong); }
.auth-main { display: flex; flex: 1; justify-content: center; align-items: flex-start; padding: 64px 16px 48px; }
.auth-card { display: flex; flex-direction: column; gap: 24px; width: 100%; max-width: 420px; padding: 32px 28px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }

[data-w="0"]{width:0%}[data-w="5"]{width:5%}[data-w="10"]{width:10%}[data-w="15"]{width:15%}[data-w="20"]{width:20%}[data-w="25"]{width:25%}[data-w="30"]{width:30%}[data-w="35"]{width:35%}[data-w="40"]{width:40%}[data-w="45"]{width:45%}[data-w="50"]{width:50%}[data-w="55"]{width:55%}[data-w="60"]{width:60%}[data-w="65"]{width:65%}[data-w="70"]{width:70%}[data-w="75"]{width:75%}[data-w="80"]{width:80%}[data-w="85"]{width:85%}[data-w="90"]{width:90%}[data-w="95"]{width:95%}[data-w="100"]{width:100%}