/* MailArchive – Designsystem
 * Semantische Tokens für Hell- und Dunkelmodus. Auswahl über <html data-theme="light|dark|system">
 * (theme-init.js setzt das Attribut vor dem ersten Zeichnen, damit nichts aufblitzt).
 * Komponenten verwenden ausschließlich Tokens, keine festen Farbwerte. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --surface-3: #e4e8ed;
  --border: #dde2e8;
  --border-strong: #c7ced7;
  --text: #17202b;
  --muted: #566273;
  --faint: #7d8898;
  --accent: #2b6e70;
  --accent-strong: #1f5557;
  --accent-soft: #e0efee;
  --accent-contrast: #ffffff;
  --ok: #257046;
  --ok-soft: #e1f2e7;
  --warn: #8a5a00;
  --warn-soft: #fbefd6;
  --crit: #b3261e;
  --crit-soft: #fbe5e3;
  --info-soft: #e4eef8;
  --focus: #2b6e70;
  --overlay: rgba(12, 18, 26, .48);
  --shadow-sm: 0 1px 2px rgba(15, 23, 35, .06);
  --shadow: 0 1px 2px rgba(15, 23, 35, .05), 0 4px 14px rgba(15, 23, 35, .05);
  --shadow-lg: 0 16px 48px rgba(10, 16, 24, .22);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-lg: 16px; --text-xl: 20px; --text-2xl: 24px;
  color-scheme: light;
}

/* Dunkel: explizit gewählt oder Systemeinstellung */
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #161d24; --surface-2: #1c252e; --surface-3: #243039; --border: #27323d; --border-strong: #354350;
  --text: #e4e9ef; --muted: #a0abb8; --faint: #768291; --accent: #5fb3ab; --accent-strong: #84c9c1; --accent-soft: #17302f;
  --accent-contrast: #0c1a1a; --ok: #6bc792; --ok-soft: #173024; --warn: #e5b85c; --warn-soft: #362b14; --crit: #f08a80;
  --crit-soft: #3a1d1b; --info-soft: #182838; --focus: #84c9c1; --overlay: rgba(0, 0, 0, .62);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.25);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0f1419; --surface: #161d24; --surface-2: #1c252e; --surface-3: #243039; --border: #27323d; --border-strong: #354350;
    --text: #e4e9ef; --muted: #a0abb8; --faint: #768291; --accent: #5fb3ab; --accent-strong: #84c9c1; --accent-soft: #17302f;
    --accent-contrast: #0c1a1a; --ok: #6bc792; --ok-soft: #173024; --warn: #e5b85c; --warn-soft: #362b14; --crit: #f08a80;
    --crit-soft: #3a1d1b; --info-soft: #182838; --focus: #84c9c1; --overlay: rgba(0, 0, 0, .62);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.25);
    --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: var(--text-base)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: var(--text-2xl); font-weight: 650; margin: 0; letter-spacing: -.015em; line-height: 1.25; }
h2 { font-size: var(--text-lg); font-weight: 620; margin: 0 0 var(--space-3); }
h3 { font-size: var(--text-base); font-weight: 620; margin: var(--space-4) 0 var(--space-2); }
p { margin: 0 0 var(--space-3); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- Layout */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; font-weight: 700; font-size: var(--text-lg); letter-spacing: -.01em; }
.logo { display: inline-flex; }
.logo img { height: 30px; width: auto; display: block; }
.logo.large img { height: 52px; }
.logo .logo-dark { display: none; }
:root[data-theme="dark"] .logo .logo-light { display: none; }
:root[data-theme="dark"] .logo .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .logo .logo-light { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .logo .logo-dark { display: block; }
}
.mobile-bar .mark { height: 28px; width: 28px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-contrast); flex: none; }
.brand-mark svg { width: 16px; height: 16px; }
.tenant-switch { margin: 0 4px var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.tenant-switch label { font-size: var(--text-xs); color: var(--muted); font-weight: 600; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .05em; }
.tenant-switch select { margin-top: 4px; padding: 6px 30px 6px 10px; font-weight: 620; font-size: var(--text-sm); text-overflow: ellipsis; background-color: var(--surface); border-color: var(--border); }
.tenant-switch select:hover { border-color: var(--border-strong); }
.tenant-switch.all select { border-color: var(--warn); }
.tenant-switch.all { border-color: var(--warn); background: var(--warn-soft); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--muted); font-weight: 530; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 4px; font-weight: 650; }
.sidebar-foot { margin-top: auto; padding: var(--space-3) 10px 0; border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted); display: grid; gap: 6px; }
.sidebar-foot .who { font-weight: 620; color: var(--text); }
.sidebar-foot .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.theme-switch button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; min-height: 0; }
.theme-switch button:hover { color: var(--text); background: var(--surface); }
.theme-switch button[aria-checked="true"] { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-switch.labeled button { padding: 6px 12px; font-size: var(--text-sm); }
.main { padding: var(--space-6) var(--space-8) 64px; min-width: 0; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.context-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); font-size: var(--text-sm); color: var(--muted); }
.mobile-bar { display: none; }

/* ---------------------------------------------------------------- Karten & Raster */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-5); min-width: 0; }
.card + .card { margin-top: var(--space-4); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: var(--space-4); }
.grid > .card + .card { margin-top: 0; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.equal > * { display: flex; flex-direction: column; }
.grid.equal > * > .grow { flex: 1; }
.stat .label { color: var(--muted); font-size: var(--text-sm); }
.stat .value { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--faint); font-size: var(--text-xs); margin-top: 2px; }
.section { margin-top: var(--space-6); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-title h2 { margin: 0; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px var(--space-3); font-size: var(--text-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.metrics .m-label { color: var(--muted); font-size: var(--text-xs); }
.metrics .m-value { font-size: var(--text-sm); font-weight: 560; }

/* ---------------------------------------------------------------- Buttons & Formulare */
button, .btn { font: inherit; font-size: var(--text-sm); font-weight: 580; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; line-height: 1.3; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
button.primary:hover, .btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.danger { color: var(--crit); border-color: var(--crit); background: transparent; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small, .btn.small { padding: 4px 10px; font-size: var(--text-xs); }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
label { display: block; font-weight: 580; font-size: var(--text-sm); margin-bottom: 5px; }
.field { margin-bottom: var(--space-4); }
.field .help { color: var(--muted); font-size: var(--text-xs); margin-top: 5px; }
input:not([type]), input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], input[type=color], select, textarea {
  font: inherit; font-size: var(--text-base); width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
}
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238b95a5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 8px; cursor: pointer; }
select[multiple] { background-image: none; padding-right: 10px; }
option, optgroup { background-color: var(--surface); color: var(--text); }
input[type=color] { padding: 2px; height: 38px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; margin-bottom: 6px; }
.check input { margin-top: 3px; flex: none; }
.check.sub-check { margin-left: 24px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.form-grid .full { grid-column: 1 / -1; }
.inline-fields { display: grid; grid-template-columns: minmax(80px, 110px) minmax(0, 1fr); gap: var(--space-2); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; border-top: 1px solid var(--border); margin: var(--space-5) calc(-1 * var(--space-6)) calc(-1 * var(--space-5)); padding: var(--space-3) var(--space-6); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.form-actions .left { margin-right: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4) var(--space-1); margin: 0 0 var(--space-4); }
legend { font-size: var(--text-xs); font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }

/* ---------------------------------------------------------------- Menü (Aktionen) */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; display: grid; }
.menu-list button { border: 0; justify-content: flex-start; background: transparent; width: 100%; padding: 8px 10px; font-weight: 520; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
/* In horizontal scrollenden Tabellen: am Bildschirm ausrichten (app.js setzt die Position), sonst Scrollbalken */
.table-wrap .menu-list { position: fixed; visibility: hidden; }
.table-wrap .menu-list.placed { visibility: visible; }

/* ---------------------------------------------------------------- Tabellen */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.data th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
table.data td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.card > .table-wrap:first-child, .card.flush { padding: 0; }
.card.flush table.data th:first-child, .card.flush table.data td:first-child { padding-left: var(--space-5); }
.card.flush table.data th:last-child, .card.flush table.data td:last-child { padding-right: var(--space-5); }

/* ---------------------------------------------------------------- Status */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 620; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.outline { background: transparent; border-color: var(--border-strong); }
.badge .ico { font-size: 11px; line-height: 1; }
.tenant-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 620; font-size: var(--text-xs); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.tenant-chip .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.alert { border-radius: var(--radius); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); background: var(--surface); display: flex; gap: var(--space-3); align-items: flex-start; }
.alert + .alert { margin-top: var(--space-2); }
.alert .ico { font-weight: 700; width: 18px; flex: none; text-align: center; }
.alert.warning { background: var(--warn-soft); border-color: transparent; }
.alert.critical { background: var(--crit-soft); border-color: transparent; }
.alert.info { background: var(--info-soft); border-color: transparent; }
.alert.success { background: var(--ok-soft); border-color: transparent; }
.alert .title { font-weight: 640; }
.alert .detail { color: var(--muted); font-size: var(--text-sm); }
.alert.warning .title, .alert.warning .ico { color: var(--warn); }
.alert.critical .title, .alert.critical .ico { color: var(--crit); }
.alert.success .title, .alert.success .ico { color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .title { font-weight: 620; color: var(--text); margin-bottom: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.warn-text { color: var(--warn); }
.small { font-size: var(--text-xs); }
.nowrap { white-space: nowrap; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.warn > span { background: var(--warn); }
.meter.crit > span { background: var(--crit); }

/* ---------------------------------------------------------------- Quellenkarten */
.source-card { display: flex; flex-direction: column; gap: var(--space-3); }
.source-card .card-head { margin-bottom: 0; }
.source-card .kind { color: var(--muted); font-size: var(--text-sm); }
.source-card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------------------------------------------------------------- Suche */
.search-layout { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.searchbar { display: flex; gap: var(--space-2); }
.searchbar input { font-size: 15px; padding: 10px 12px; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); margin-top: var(--space-3); }
.filters label { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.result-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.result { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: block; color: inherit; }
.result:hover { background: var(--surface-2); text-decoration: none; }
.result.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.result .row1 { display: flex; justify-content: space-between; gap: 8px; }
.result .from { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .date { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.result .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .snippet { color: var(--muted); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.result-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-xs); color: var(--muted); gap: 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
.preview { position: sticky; top: var(--space-4); }

/* ---------------------------------------------------------------- Nachricht */
.msg-head h2 { font-size: 18px; margin-bottom: 10px; word-break: break-word; }
.body-frame { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #ffffff; min-height: 380px; height: 62vh; }
.att-list { display: flex; flex-direction: column; gap: 6px; }
.att { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.att .name { font-weight: 560; word-break: break-all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: var(--space-4) 0 var(--space-3); flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 10px; }
.tabs button.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
pre.raw { background: var(--surface-2); border-radius: 8px; padding: 12px; overflow: auto; max-height: 420px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

/* ---------------------------------------------------------------- Hilfe */
.help-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.help-toc { position: sticky; top: var(--space-4); display: grid; gap: 2px; font-size: var(--text-sm); }
.help-toc a { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.help-toc a:hover, .help-toc a.active { background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; }
.help-layout > * { min-width: 0; }
.help-section { scroll-margin-top: 16px; }
.help-section table { display: block; overflow-x: auto; }
.help-section + .help-section { margin-top: var(--space-5); }
.help-section .lead { color: var(--muted); }
details.more { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-top: var(--space-3); }
details.more > summary { cursor: pointer; font-weight: 580; font-size: var(--text-sm); }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 12px 36px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: 12px; display: grid; place-items: center; }

/* ---------------------------------------------------------------- Anmeldung */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { justify-content: center; padding: 8px 0 10px; }
.login-card .lead { text-align: center; color: var(--muted); margin-bottom: var(--space-5); }
.login-foot { text-align: center; color: var(--faint); font-size: var(--text-xs); margin-top: var(--space-4); max-width: 400px; }
.login-foot a, .sidebar-foot a.faint { color: inherit; }
.about .brand { display: flex; justify-content: center; padding: 4px 0 8px; }
.qr { display: flex; justify-content: center; background: #ffffff; border-radius: 8px; padding: 8px; margin: 10px 0; }
.qr svg { width: 200px; height: 200px; }

/* ---------------------------------------------------------------- Dialoge (einheitliche Größen) */
.modal-back { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.modal.sm { max-width: 460px; }
.modal.md { max-width: 640px; }
.modal.lg { max-width: 880px; }
.modal-head { padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: var(--text-lg); }
.modal-body { padding: var(--space-5) var(--space-6); }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; }
.toast.error { background: var(--crit); color: #ffffff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.secret-box { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--border-strong); padding: 10px; border-radius: 8px; word-break: break-all; font-size: 15px; text-align: center; letter-spacing: .04em; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 30px; justify-content: center; }

/* ---------------------------------------------------------------- Responsiv */
@media (max-width: 1200px) {
  .grid.cols-4, .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-layout > *, .grid > * { min-width: 0; }
  .main { padding: var(--space-5) var(--space-5) 48px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 22% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100%; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; font-weight: 700; }
  .mobile-bar .tenant-chip { margin-left: auto; }
  .main { padding: var(--space-4) var(--space-4) 48px; }
  .grid.cols-4, .metrics, .form-grid, .filters, .help-toc { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .form-actions { margin-left: calc(-1 * var(--space-4)); margin-right: calc(-1 * var(--space-4)); padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal-body, .modal-head { padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal-back { padding: 8px; }
}
