/* Zahlenwende – Oberfläche: schwarze Icon-Leiste, helle zweite Spalte mit Zählern, ruhige Karten.
   Marke: Tinte #0B0B0F, Magenta #D3155F (Marke, Hauptaktionen), Volt #C6F24E nur als Störer (Handlungsbedarf),
   Navy #26324F sekundär. Schrift: Inter (selbst gehostet). Icons: Phosphor (MIT).
   Alle Farben sind Tokens; helles und dunkles Set. Standard folgt prefers-color-scheme,
   <html data-theme="light|dark"> (gesetzt von /js/theme.js) erzwingt eine Darstellung. */
@font-face { font-family: Inter; src: url(/fonts/inter-var.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  /* Marke (in beiden Modi gleich) */
  --brand-ink: #0B0B0F; --brand-mag: #D3155F; --brand-volt: #C6F24E; --brand-navy: #26324F;
  --on-volt: #0B0B0F; --on-accent: #ffffff;

  /* Flächen */
  --bg: #F6F6F8; --panel: #ffffff; --subtle: #F7F7F9; --fill: #F1F1F4; --fill-hover: #EAEAEE; --hover: #FAFAFB;
  --line: #ECECF0; --line-strong: #DCDCE3; --input-bg: #ffffff; --topbar-bg: rgba(246, 246, 248, .82);
  /* Text */
  --text: #0B0B0F; --text-2: #3D3F4A; --muted: #5E616B; --faint: #72747F;
  /* Akzent */
  --accent: #D3155F; --accent-hover: #B80F51; --accent-text: #B80F51; --accent-soft: #FDEEF4; --accent-line: #F6C3D7;
  --volt: #C6F24E;
  --navy: #26324F; --navy-soft: #E9ECF4; --navy-text: #26324F;
  /* Status */
  --ok: #0B7A52; --ok-bg: #E5F6EE; --warn: #945600; --warn-bg: #FFF3DB; --bad: #C2102C; --bad-bg: #FDECEF; --bad-line: #F5C2CB;
  --info: #2D4A8F; --info-bg: #EBEFFA;
  /* Invers (Icon-Leiste, Hero-Kachel, Toasts, Sammelleiste) */
  --rail-bg: #0B0B0F; --rail-line: transparent; --rail-item: #8B8D98; --rail-item-hover: #D9DAE0; --rail-active-bg: #24252D;
  --inverse-bg: #0B0B0F; --inverse-text: #ffffff; --inverse-muted: #A4A6B0; --inverse-fill: #24252D; --inverse-line: transparent;
  --nav-active-bg: #0B0B0F; --nav-active-text: #ffffff; --nav-active-count: rgba(255, 255, 255, .16);
  --toast-bg: #0B0B0F; --toast-text: #ffffff;
  /* Diagramme */
  --chart-1: #0B0B0F; --chart-2: #D3155F; --chart-3: #8F0E40; --chart-base: #E2E2E8;
  /* Schatten, Fokus, Maße */
  --shadow-pop: 0 18px 48px -12px rgba(11, 11, 15, .22), 0 2px 6px rgba(11, 11, 15, .06);
  --shadow-sm: 0 1px 2px rgba(11, 11, 15, .06);
  --backdrop: rgba(11, 11, 15, .38);
  --focus: 0 0 0 4px rgba(211, 21, 95, .16);
  --radius: 20px; --radius-md: 14px; --radius-sm: 12px; --radius-xs: 8px;
  --rail-w: 72px; --subnav-w: 236px;
}

/* Dunkles Set: einmal als Systemvorgabe (ohne erzwungenes Hell), einmal erzwungen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B0B0F; --panel: #131419; --subtle: #17181E; --fill: #1E1F26; --fill-hover: #272830; --hover: #181920;
    --line: #22232B; --line-strong: #33343E; --input-bg: #0F1014; --topbar-bg: rgba(11, 11, 15, .82);
    --text: #F3F3F6; --text-2: #C9CAD1; --muted: #A2A4AE; --faint: #7C7E88;
    --accent: #D3155F; --accent-hover: #E62E75; --accent-text: #FF6FA2; --accent-soft: rgba(211, 21, 95, .18); --accent-line: rgba(211, 21, 95, .45);
    --navy-soft: rgba(124, 146, 210, .16); --navy-text: #AFC0EE;
    --ok: #3DDC97; --ok-bg: rgba(61, 220, 151, .12); --warn: #FFB547; --warn-bg: rgba(255, 181, 71, .12);
    --bad: #FF7085; --bad-bg: rgba(255, 112, 133, .13); --bad-line: rgba(255, 112, 133, .4);
    --info: #9DB2FF; --info-bg: rgba(157, 178, 255, .13);
    --rail-bg: #060608; --rail-line: #1B1C22; --rail-item: #8B8D98; --rail-active-bg: #1E1F26;
    --inverse-bg: linear-gradient(135deg, #1C1D24, #0F1015); --inverse-line: #22232B; --inverse-fill: #24252D;
    --nav-active-bg: #F3F3F6; --nav-active-text: #0B0B0F; --nav-active-count: rgba(0, 0, 0, .1);
    --toast-bg: #26272F; --toast-text: #F3F3F6;
    --chart-1: #F3F3F6; --chart-2: #D3155F; --chart-3: #FF6FA2; --chart-base: #2C2D36;
    --shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, .7), 0 0 0 1px #2C2D36;
    --shadow-sm: none;
    --backdrop: rgba(0, 0, 0, .6);
    --focus: 0 0 0 4px rgba(255, 111, 162, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0F; --panel: #131419; --subtle: #17181E; --fill: #1E1F26; --fill-hover: #272830; --hover: #181920;
  --line: #22232B; --line-strong: #33343E; --input-bg: #0F1014; --topbar-bg: rgba(11, 11, 15, .82);
  --text: #F3F3F6; --text-2: #C9CAD1; --muted: #A2A4AE; --faint: #7C7E88;
  --accent: #D3155F; --accent-hover: #E62E75; --accent-text: #FF6FA2; --accent-soft: rgba(211, 21, 95, .18); --accent-line: rgba(211, 21, 95, .45);
  --navy-soft: rgba(124, 146, 210, .16); --navy-text: #AFC0EE;
  --ok: #3DDC97; --ok-bg: rgba(61, 220, 151, .12); --warn: #FFB547; --warn-bg: rgba(255, 181, 71, .12);
  --bad: #FF7085; --bad-bg: rgba(255, 112, 133, .13); --bad-line: rgba(255, 112, 133, .4);
  --info: #9DB2FF; --info-bg: rgba(157, 178, 255, .13);
  --rail-bg: #060608; --rail-line: #1B1C22; --rail-item: #8B8D98; --rail-active-bg: #1E1F26;
  --inverse-bg: linear-gradient(135deg, #1C1D24, #0F1015); --inverse-line: #22232B; --inverse-fill: #24252D;
  --nav-active-bg: #F3F3F6; --nav-active-text: #0B0B0F; --nav-active-count: rgba(0, 0, 0, .1);
  --toast-bg: #26272F; --toast-text: #F3F3F6;
  --chart-1: #F3F3F6; --chart-2: #D3155F; --chart-3: #FF6FA2; --chart-base: #2C2D36;
  --shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, .7), 0 0 0 1px #2C2D36;
  --shadow-sm: none;
  --backdrop: rgba(0, 0, 0, .6);
  --focus: 0 0 0 4px rgba(255, 111, 162, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: var(--bg); }
body { font: 14px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; overflow-x: hidden; }
h1, h2, h3, h4 { font-family: inherit; color: var(--text); margin: 0; line-height: 1.2; }
h1 { font-size: 30px; font-weight: 800; letter-spacing: -.035em; line-height: 1.1; }
h2 { font-size: 16px; font-weight: 750; letter-spacing: -.015em; }
h3 { font-size: 14px; font-weight: 650; letter-spacing: -.005em; }
p { margin: 0 0 10px; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
::selection { background: var(--accent-soft); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); }
details > summary { cursor: pointer; }

/* Icons (Phosphor-Sprite) */
.i { width: 18px; height: 18px; fill: currentColor; flex: none; vertical-align: -3px; }
.i.lg { width: 22px; height: 22px; }
.i.sm { width: 15px; height: 15px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) var(--subnav-w) minmax(0, 1fr); min-height: 100vh; }
.app.no-subnav { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.app.no-subnav .subnav { display: none; }

/* Icon-Leiste */
.rail { background: var(--rail-bg); border-right: 1px solid var(--rail-line); color: var(--rail-item); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0; position: sticky; top: 0; height: 100vh; z-index: 5; }
.rail a.logo { display: grid; place-items: center; width: auto; padding: 0; margin-bottom: 14px; border-radius: 10px; }
.rail a.logo:hover { background: none; }
.rail .logo img { width: 38px; height: 38px; display: block; border-radius: 9px; }
.rail a, .rail .rail-btn { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 0 8px; border-radius: 0; color: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: .01em; text-decoration: none; border: 0; background: none; line-height: 1.2; text-align: center; }
.rail a .i { width: 22px; height: 22px; }
.rail a:hover { color: var(--rail-item-hover); background: rgba(255, 255, 255, .05); text-decoration: none; }
/* Aktiver Eintrag: Band über die ganze Breite der Leiste mit Magenta-Kante links */
.rail a.active { color: #fff; background: var(--rail-active-bg); box-shadow: inset 3px 0 0 var(--brand-mag); }
.rail a.active .i { color: var(--brand-mag); }
.rail .badge-dot { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--brand-volt); color: var(--on-volt); font-size: 10.5px; font-weight: 750; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--rail-bg); font-variant-numeric: tabular-nums; }
.rail .spacer { flex: 1; }
.rail .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rail .rail-user { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; margin-top: 6px; }
.rail .rail-user .avatar { width: 34px; height: 34px; }

/* Zweite Spalte */
.subnav { background: var(--panel); border-right: 1px solid var(--line); color: var(--text-2); padding: 20px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.subnav .title { color: var(--text); font-weight: 750; font-size: 18px; letter-spacing: -.02em; padding: 4px 22px 12px; }
.subnav .group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 18px 24px 6px; }
/* Einträge als Bänder von Kante zu Kante (kein Kasten); die Zähler-Pille bleibt rund. */
.subnav a { display: flex; align-items: center; gap: 10px; padding: 9px 22px 9px 24px; border-radius: 0; color: var(--text-2); font-size: 13.5px; font-weight: 550; text-decoration: none; }
.subnav a .i { width: 18px; height: 18px; color: var(--faint); }
.subnav a:hover { background: var(--fill); color: var(--text); text-decoration: none; }
.subnav a.active { background: var(--nav-active-bg); color: var(--nav-active-text); }
.subnav a.active .i { color: var(--nav-active-text); }
.subnav a .count { margin-left: auto; font-size: 11.5px; font-weight: 650; color: var(--muted); background: var(--fill); border-radius: 99px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.subnav a .count.zero { color: var(--faint); background: transparent; font-weight: 550; }
.subnav a .count.alert { background: var(--brand-volt); color: var(--on-volt); }
.subnav a.active .count { background: var(--nav-active-count); color: var(--nav-active-text); }
.subnav a.active .count.alert { background: var(--brand-volt); color: var(--on-volt); }

/* Hauptbereich und Kopfzeile */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 32px; background: var(--topbar-bg); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; }
.topbar .tenant { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); min-width: 0; white-space: nowrap; }
.topbar .tenant .i { color: var(--faint); }
.topbar .tenant > span { overflow: hidden; text-overflow: ellipsis; }
.topbar select.tenant-select { height: 36px; border: 1px solid var(--line-strong); background: var(--input-bg); border-radius: 10px; padding: 0 10px; font-weight: 650; color: var(--text); max-width: 260px; }
.topbar .search { flex: 0 1 460px; min-width: 200px; position: relative; }
.topbar .search input { width: 100%; height: 40px; border: 1px solid var(--line-strong); background: var(--input-bg); border-radius: 12px; padding: 0 54px 0 40px; color: var(--text); }
.topbar .search input::placeholder { color: var(--faint); }
.topbar .search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.topbar .search > .i { position: absolute; left: 13px; top: 11px; color: var(--faint); pointer-events: none; }
.topbar .search kbd { position: absolute; right: 10px; top: 9px; font: 600 11px/1 Inter, system-ui, sans-serif; color: var(--muted); background: var(--fill); border-radius: 6px; padding: 5px 7px; pointer-events: none; }
.topbar .spacer { flex: 1; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line-strong); font-weight: 600; font-size: 12.5px; color: var(--text); white-space: nowrap; text-decoration: none; }
.status-chip:hover { text-decoration: none; background: var(--hover); }
.status-chip .led { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status-chip.ok .led { background: var(--ok); }
.status-chip.bad { color: var(--bad); border-color: var(--bad-line); }
.status-chip.bad .led { background: var(--bad); }
.icon-btn { position: relative; border: 1px solid transparent; background: transparent; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text); flex: none; padding: 0; }
.icon-btn:hover { background: var(--fill); }
.topbar .icon-btn { border-color: var(--line-strong); background: var(--panel); }
.topbar .icon-btn:hover { background: var(--hover); }
.topbar .icon-btn.user-btn { border: 0; background: none; width: 40px; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-mag); color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; letter-spacing: .02em; }
.content { padding: 28px 32px 60px; outline: none; }
.content:focus, .content:focus-visible { outline: none; box-shadow: none; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 0 0 22px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Hinweise */
.banner { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius-md); padding: 13px 16px; margin-bottom: 14px; background: var(--navy-soft); color: var(--navy-text); border: 1px solid transparent; }
.banner .i { margin-top: 2px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner b { color: inherit; font-weight: 700; }
.banner a:not(.btn) { color: inherit; text-decoration: underline; }
.banner .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Karten und Kacheln ---------- */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.grid.two { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
.grid.halves { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-width: 0; }
.card-head h2 { font-size: 15px; }
.card.flush > .card-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { text-decoration: none; border-color: var(--line-strong); }

.grid.kpis-main { grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(0, 1fr)); }
.grid.kpis-small { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.kpis-small .kpi { padding: 14px 18px; }
.kpis-small .kpi .value { font-size: 22px; }
.kpi { display: flex; flex-direction: column; gap: 6px; cursor: default; padding: 18px 20px; position: relative; overflow: hidden; }
.kpi[href] { cursor: pointer; color: inherit; text-decoration: none; transition: border-color .12s; }
.kpi[href]:hover { border-color: var(--line-strong); text-decoration: none; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .value { font-weight: 800; font-size: 30px; letter-spacing: -.04em; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .meta { color: var(--muted); font-size: 12.5px; }
.kpi.accent .value { color: var(--accent-text); }
.kpi.hero { background: var(--inverse-bg); border-color: var(--inverse-line); color: var(--inverse-text); }
.kpi.hero[href]:hover { border-color: var(--inverse-line); filter: brightness(1.12); }
.kpi.hero .label, .kpi.hero .meta { color: var(--inverse-muted); }
.kpi.hero .value { color: var(--inverse-text); }
.kpi.hero .volt { color: var(--brand-volt); font-weight: 700; }
.kpi .kpi-ring { position: absolute; right: 18px; top: 18px; }
.kpi .kpi-ring circle { fill: none; stroke-width: 5; }
.kpi .kpi-ring .track { stroke: rgba(255, 255, 255, .14); }
.kpi .kpi-ring .val { stroke: var(--brand-volt); stroke-linecap: round; }

/* Balken (Altersstruktur, Stufen, Fortschritt) */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 120px; gap: 12px; align-items: center; font-size: 13px; }
.bar { height: 10px; background: var(--fill); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--chart-1); border-radius: 99px; }
.bar.accent > span { background: var(--chart-2); }
.flow { display: flex; gap: 5px; align-items: center; margin: 4px 0 14px; }
.flow > span { height: 10px; border-radius: 99px; min-width: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; }
.c-0 { background: var(--chart-base); } .c-1 { background: var(--chart-1); } .c-2 { background: var(--chart-2); } .c-3 { background: var(--chart-3); } .c-4 { background: var(--brand-navy); }

/* ---------- Buttons und Formulare ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border: 1px solid transparent; border-radius: 12px; padding: 0 16px; background: var(--accent); color: var(--on-accent); font-weight: 650; font-size: 13.5px; line-height: 1.2; white-space: nowrap; text-decoration: none; box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px -8px rgba(211, 21, 95, .55); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--hover); border-color: var(--faint); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: var(--fill); }
.btn.danger { background: var(--panel); color: var(--bad); border-color: var(--bad-line); box-shadow: none; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.navy { background: var(--text); color: var(--panel); box-shadow: none; }
.btn.navy:hover { background: var(--text-2); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }
.btn .i { width: 16px; height: 16px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 650; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err, .err { font-size: 12.5px; color: var(--bad); font-weight: 550; }
.err:empty { display: none; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 14px; background: var(--input-bg); color: var(--text); transition: border-color .12s, box-shadow .12s; }
select.input { padding-right: 34px; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--faint); }
.input:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); }
.input[disabled], .input[readonly] { background: var(--subtle); color: var(--muted); }
textarea.input { resize: vertical; min-height: 120px; line-height: 1.5; }
.input.mono, textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 16px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 12px 0 0 12px; min-width: 0; }
.input-group .addon { display: flex; align-items: center; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 12px 12px 0; padding: 0 13px; background: var(--subtle); color: var(--muted); white-space: nowrap; }
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.checkbox input { width: 17px; height: 17px; flex: none; }

/* Schalter */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch input:disabled + .track { opacity: .5; }

/* Reiter und Segmente */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; background: var(--fill); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--text); }
.seg button.active, .seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 550; color: var(--text); }
.chip:hover { background: var(--hover); text-decoration: none; }
.chip.on { background: var(--nav-active-bg); border-color: var(--nav-active-bg); color: var(--nav-active-text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Status-Pillen */
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--fill); color: var(--text-2); vertical-align: middle; }
.badge .i { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.volt { background: var(--brand-volt); color: var(--on-volt); }
.badge.navy { background: var(--text); color: var(--panel); }
.badge.test { background: var(--navy-soft); color: var(--navy-text); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; letter-spacing: .02em; color: var(--faint); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort { opacity: .4; margin-left: 3px; }
.tbl th.sorted { color: var(--text); }
.tbl th.sorted .sort { opacity: 1; color: var(--accent-text); }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--hover); }
.tbl tbody tr.selected { background: var(--accent-soft); }
.tbl td.check, .tbl th.check { width: 40px; padding-right: 0; }
.tbl .primary { font-weight: 650; color: var(--text); }
a.primary:hover { color: var(--accent-text); }
.tbl .sub { font-size: 12px; color: var(--faint); }
.tbl td.num .sub { color: var(--muted); }
/* Aktionsspalte (Spalte mit actions:true) bleibt bei breiten Tabellen rechts sichtbar. */
.tbl td.col-actions, .tbl th.col-actions { position: sticky; right: 0; background: var(--panel); box-shadow: -10px 0 10px -10px rgba(0, 0, 0, .18); white-space: nowrap; }
.tbl th.col-actions { z-index: 1; }
.tbl tbody tr.clickable:hover td.col-actions { background: var(--hover); }
.tbl tbody tr.selected td.col-actions { background: var(--panel); }
.cust { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cust > div { min-width: 0; }
.ava { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 750; color: #fff; flex: none; letter-spacing: .02em; }
.ava-0 { background: #D3155F; } .ava-1 { background: #26324F; } .ava-2 { background: #0B0B0F; } .ava-3 { background: #6B4EFF; } .ava-4 { background: #0F8A5F; } .ava-5 { background: #B5487A; }
:root[data-theme="dark"] .ava-2 { background: #3A3B45; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ava-2 { background: #3A3B45; } }
.ava-1 { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.bulkbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--toast-bg); color: var(--toast-text); }
.bulkbar .btn.secondary { border-color: transparent; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty > .i { width: 44px; height: 44px; color: var(--faint); margin-bottom: 10px; padding: 10px; background: var(--fill); border-radius: 14px; box-sizing: content-box; }
.empty h3 { margin-bottom: 4px; font-size: 15px; }
.empty .btn { margin-top: 8px; }

/* Zeitstrahl */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 34px; }
.timeline li::before { content: ''; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--text-2); }
.timeline .dot .i { width: 13px; height: 13px; }
.timeline .dot.ok { background: var(--ok-bg); color: var(--ok); }
.timeline .dot.warn { background: var(--warn-bg); color: var(--warn); }
.timeline .dot.bad { background: var(--bad-bg); color: var(--bad); }
.timeline .dot.next { background: var(--accent); color: #fff; }
.timeline .when { font-size: 12px; color: var(--muted); }

/* Schublade (Detail rechts) */
.drawer-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 20; animation: fade .16s ease-out; }
.drawer { position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(640px, calc(100% - 20px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); z-index: 21; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; overflow: hidden; animation: slideIn .18s ease-out; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; flex: 1; }
.drawer-body .card { border-radius: var(--radius-md); }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; background: var(--subtle); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Dialog */
dialog.dlg { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 32px)); background: var(--panel); box-shadow: var(--shadow-pop); color: var(--text); }
dialog.dlg.wide { width: min(980px, calc(100% - 32px)); }
dialog.dlg::backdrop { background: var(--backdrop); }
.dlg-head { padding: 20px 22px 8px; display: flex; gap: 10px; align-items: center; }
.dlg-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.03em; }
.dlg-body { padding: 10px 22px 8px; max-height: 70vh; overflow-y: auto; }
.dlg-foot { padding: 14px 22px 20px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Toasts */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 40; width: max-content; max-width: calc(100% - 32px); }
.toast { display: flex; align-items: center; gap: 14px; background: var(--toast-bg); color: var(--toast-text); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow-pop); font-size: 13.5px; font-weight: 550; animation: pop .15s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast.bad { background: #5A1220; color: #FFE3E8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.bad { background: #5A1220; color: #FFE3E8; } }
.toast button { border: 0; background: none; color: var(--brand-volt); font-weight: 750; padding: 0; white-space: nowrap; }
.toast.bad button { color: #fff; text-decoration: underline; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Aufklappmenü */
.menu { position: absolute; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px; min-width: 230px; max-width: calc(100vw - 16px); color: var(--text); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; color: var(--text); font-size: 13.5px; }
.menu button .i, .menu a > .i { color: var(--muted); }
.menu button:hover, .menu a:hover { background: var(--fill); text-decoration: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .danger { color: var(--bad); }
.menu button:focus-visible, .menu a:focus-visible { outline: none; background: var(--fill); box-shadow: var(--focus); }

/* Vorschau (Mail in iframe – die Mail selbst bleibt hell wie im Postfach) */
.preview-frame { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; color-scheme: light; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--fill); color: var(--text); border-radius: 6px; padding: 2px 6px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; font-size: 15px; background: var(--fill); border-radius: 10px; padding: 10px 12px; word-break: break-all; }

/* Platzhalter-Chips im Editor */
.ph-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; border: 1px dashed var(--line-strong); background: var(--panel); border-radius: 7px; padding: 3px 8px; color: var(--text); }
.ph-chip:hover { border-color: var(--accent); color: var(--accent-text); }

/* Ladezustand */
.skeleton { background: linear-gradient(90deg, var(--fill) 25%, var(--subtle) 50%, var(--fill) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); min-height: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; } }

/* Darstellungswahl (Konto) */
.theme-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-choice button { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--panel); color: var(--text); font-weight: 650; text-align: left; }
.theme-choice button:hover { border-color: var(--faint); }
.theme-choice button[aria-checked="true"] { border-color: var(--accent); box-shadow: var(--focus); }
.theme-choice .swatch { width: 100%; height: 46px; border-radius: 9px; border: 1px solid var(--line); display: flex; overflow: hidden; }
.theme-choice .swatch span { flex: 1; }
.sw-light { background: #F6F6F8; } .sw-light-panel { background: #ffffff; } .sw-dark { background: #0B0B0F; } .sw-dark-panel { background: #1E1F26; } .sw-mag { background: #D3155F; flex: 0 0 10px !important; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side { background: #0B0B0F; color: #fff; padding: 44px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-side .wordmark { height: 64px; width: auto; align-self: flex-start; display: block; }
.auth-side h2 { color: #fff; font-size: 56px; line-height: 1.0; letter-spacing: -.045em; font-weight: 850; margin: auto 0 18px; max-width: 560px; }
.auth-side h2 em { font-style: normal; color: var(--brand-mag); }
.auth-side p { color: #A4A6B0; font-size: 16px; max-width: 460px; margin: 0 0 28px; }
.auth-side .points { display: flex; gap: 10px; flex-wrap: wrap; }
.auth-side .points span { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 99px; background: #24252D; font-size: 13px; font-weight: 600; color: #E5E6EA; }
.auth-side .points .i { color: var(--brand-volt); }
.auth-side .sticker { position: absolute; right: 56px; top: 110px; transform: rotate(8deg); background: var(--brand-volt); color: var(--on-volt); font-weight: 850; font-size: 15px; letter-spacing: -.01em; padding: 14px 18px; border-radius: 18px; line-height: 1.25; box-shadow: 0 20px 40px -12px rgba(198, 242, 78, .35); }
.auth-side .sticker .i { vertical-align: -3px; }
.auth-side .sticker small { display: block; font-weight: 600; font-size: 12px; }
.auth-side .foot { margin-top: 40px; font-size: 12px; color: #8B8D98; }
.auth-main { display: grid; place-items: center; padding: 32px; background: var(--panel); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .wordmark-sm { display: none; height: 44px; width: auto; margin-bottom: 28px; }
.auth-card h1 { margin-bottom: 8px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.auth-card .btn { width: 100%; height: 48px; font-size: 14.5px; margin-top: 4px; }
.auth-card .secure { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); background: var(--subtle); border-radius: 12px; padding: 10px 12px; margin-top: 16px; }
.auth-foot { margin-top: 22px; font-size: 12.5px; color: var(--muted); }
/* Einladung: Schrittanzeige und Bestätigungscode (wie Slack/Notion: ein Feld, Einfügen des ganzen Codes) */
.auth-card .step { font-size: 12px; font-weight: 650; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.auth-card .code-input { height: 58px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 24px; letter-spacing: .32em; text-indent: .32em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-card .code-input::placeholder { letter-spacing: .32em; }
.auth-card .code-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.auth-card .text-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 650; color: var(--accent-text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.auth-card .text-link:hover { text-decoration: underline; }
.auth-card .text-link[disabled] { color: var(--muted); cursor: default; text-decoration: none; }
.auth-card .text-link .i { width: 14px; height: 14px; }
.auth-card .banner { margin-bottom: 18px; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}

/* ---------- Geteilte Rechnungsansicht (wie Outlook): Liste links, Detail rechts ---------- */
.invx-det, .invx-backdrop, .det-back { display: none; }
.content:has(> .invx.has-sel) { padding: 0; }
.invx.has-sel { display: grid; grid-template-columns: minmax(340px, 1fr) 560px; height: calc(100vh - 64px); }
.invx.has-sel .invx-list { overflow-y: auto; min-width: 0; background: var(--panel); border-right: 1px solid var(--line); }
.invx.has-sel .page-head { padding: 18px 20px 10px; margin: 0; align-items: center; flex-wrap: nowrap; gap: 10px; }
.invx.has-sel .page-head h1 { font-size: 22px; letter-spacing: -.03em; }
.invx.has-sel .page-head .sub { display: none; }
.invx.has-sel .page-head .actions { flex-wrap: nowrap; }
.invx.has-sel .page-head .actions .btn { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.invx.has-sel .invx-send .banner { margin: 0 20px 10px; }
.invx.has-sel .invx-card { border: 0; border-radius: 0; background: transparent; overflow: visible; }
.invx.has-sel .invx-card > .card-head { padding: 0 20px 12px; border-bottom: 0; }
.invx.has-sel .invx-card > .bulkbar { position: sticky; top: 0; z-index: 2; }
.invx.has-sel .invx-det { display: block; overflow-y: auto; min-width: 0; background: var(--bg); }

/* Kompakte Zeilen */
.invx-rows { outline: none; }
.li { display: flex; gap: 12px; align-items: center; padding: 13px 20px; border-top: 1px solid var(--line); cursor: pointer; position: relative; outline: none; }
.li:hover { background: var(--hover); }
.li:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-line); }
.li.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.li.on:focus-visible { box-shadow: inset 3px 0 0 var(--accent), inset 0 0 0 2px var(--accent-line); }
.li.checked:not(.on) { background: var(--fill); }
.li-pick { position: relative; flex: none; width: 30px; height: 30px; display: block; }
.li-pick .li-check { position: absolute; left: 6px; top: 6px; margin: 0; width: 18px; height: 18px; opacity: 0; cursor: pointer; z-index: 1; }
.li:hover .li-pick .li-check, .li-pick .li-check:focus-visible, .picking .li-pick .li-check { opacity: 1; }
.li:hover .li-pick .ava, .li-pick .li-check:focus-visible + .ava, .picking .li-pick .ava { visibility: hidden; }
label.li-pick .ava { position: absolute; inset: 0; }
.li-main { flex: 1; min-width: 0; }
.li-name { display: flex; align-items: center; gap: 6px; font-weight: 650; color: var(--text); }
.li-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-side { text-align: right; flex: none; max-width: 48%; }
.li-amt { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.li-side .badge { margin-top: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Detail */
.det { padding: 22px 24px 40px; display: grid; gap: 14px; align-content: start; }
.det-head { display: flex; align-items: flex-start; gap: 12px; }
.det-titles { flex: 1; min-width: 0; outline: none; }
.det-h { font-size: 24px; font-weight: 800; letter-spacing: -.03em; overflow-wrap: anywhere; }
.det-s { color: var(--muted); font-size: 13px; margin-top: 4px; }
.det-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.det-badges:empty { display: none; }
.det-acts { display: flex; gap: 8px; flex: none; }
.det-ib { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--panel); display: grid; place-items: center; color: var(--muted); padding: 0; flex: none; }
.det-ib:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.det-ib[disabled] { opacity: .5; }
.det-body { display: grid; gap: 14px; min-width: 0; }
.det-body > .banner { margin: 0; }
.mini3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-width: 0; }
.mini-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.mini-v { font-size: 20px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--text); overflow-wrap: anywhere; line-height: 1.3; }
.mini.accent .mini-v { color: var(--accent-text); }
.mini.mail .mini-v { font-size: 14px; font-weight: 700; letter-spacing: -.01em; padding-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini.bad .mini-v { color: var(--bad); }
.mini-n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mini-n .badge { margin-top: 2px; }
.det-next { background: var(--inverse-bg); border: 1px solid var(--inverse-line); color: var(--inverse-text); border-radius: 18px; padding: 16px 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.next-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-mag); color: #fff; display: grid; place-items: center; flex: none; }
.next-t { flex: 1 1 200px; min-width: 0; }
.next-t1 { font-weight: 700; color: var(--inverse-text); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.next-t2 { font-size: 12.5px; color: var(--inverse-muted); }
.next-b { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.btn.inv { background: transparent; color: var(--inverse-text); border-color: rgba(255, 255, 255, .22); box-shadow: none; }
.btn.inv:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .4); }
.btn.inv.ghost-inv { border-color: transparent; }
.det-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; min-width: 0; }
.det-card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.det-card-h h3 { font-size: 14px; font-weight: 750; }
.det-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.det .kv { grid-template-columns: 130px 1fr; }
/* Verlauf: erledigt = gefüllt, aktuell = Magenta, später = Umriss */
.det .timeline li { padding: 0 0 14px 38px; }
.det .timeline li:last-child { padding-bottom: 0; }
.det .timeline li::before { left: 12px; top: 30px; bottom: 0; }
.det .timeline .dot { width: 26px; height: 26px; border: 2px solid var(--line-strong); background: var(--panel); color: var(--faint); }
.det .timeline .dot.ok { background: var(--text); border-color: var(--text); color: var(--panel); }
.det .timeline .dot.next { background: var(--accent); border-color: var(--accent); color: #fff; }
.det .timeline .dot.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.det .timeline .dot.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.det .timeline li > .row { font-weight: 650; font-size: 13.5px; color: var(--text); }
@media (max-width: 1300px) {
  .invx.has-sel { grid-template-columns: minmax(320px, 1fr) 500px; }
}
/* Unter 1100 px: Detail als Blatt von rechts über der Liste */
@media (max-width: 1100px) {
  .invx.has-sel { grid-template-columns: minmax(0, 1fr); }
  .invx.has-sel .invx-backdrop { display: block; position: fixed; inset: 0; background: var(--backdrop); z-index: 20; animation: fade .16s ease-out; }
  .invx.has-sel .invx-det { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 21; border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: slideIn .18s ease-out; }
}
/* Unter 900 px: Detail als eigene Seite mit Zurück */
@media (max-width: 900px) {
  .content:has(> .invx.has-sel) { padding: 0 0 calc(96px + env(safe-area-inset-bottom)); }
  .invx.has-sel { display: block; height: auto; }
  .invx.has-sel .invx-list, .invx.has-sel .invx-backdrop { display: none; }
  .invx.has-sel .invx-det { position: static; width: auto; border: 0; box-shadow: none; overflow: visible; animation: none; }
  .det { padding: 14px 16px 24px; }
  .det-back { display: inline-flex; justify-self: start; margin-left: -8px; }
  .det-close { display: none; }
  .det-head { flex-wrap: wrap; }
  .det-h { font-size: 22px; }
  .mini3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini3 .mini.mail { grid-column: 1 / -1; }
  .next-b { margin-left: 0; width: 100%; }
  .next-b .btn { flex: 1; }
  .det .kv { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Breakpoints ---------- */
/* Zwischen 900 und 1500 px: Nebenspalten (hide:'md') ausblenden, damit Aktionen ohne Querscrollen erreichbar sind. */
@media (max-width: 1500px) {
  .tbl .hide-md { display: none; }
}
@media (max-width: 1280px) {
  .topbar .status-chip .chip-text-long { display: none; }
}
@media (max-width: 1280px) {
  .grid.kpis-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .auth-side h2 { font-size: 44px; }
  .auth-side .sticker { right: 32px; }
}
@media (max-width: 900px) {
  .app, .app.no-subnav { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; align-content: start; }
  .main { display: contents; }
  .topbar { grid-row: 1; }
  .subnav { grid-row: 2; }
  .content { grid-row: 3; min-width: 0; }
  .rail { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: calc(64px + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom); flex-direction: row; justify-content: space-around; gap: 2px; border-right: 0; border-top: 1px solid var(--rail-line); }
  .rail a.logo, .rail .spacer, .rail .rail-bottom { display: none; }
  .rail a { flex: 1; width: auto; padding: 7px 2px 6px; max-width: 96px; border-radius: 14px; }
  .rail a.active { box-shadow: none; }
  .rail .badge-dot { right: calc(50% - 24px); top: 2px; }
  .subnav { position: sticky; top: 56px; z-index: 3; height: auto; padding: 8px 12px; flex-direction: row; align-items: center; gap: 4px; overflow-x: auto; white-space: nowrap; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav .title, .subnav .group { display: none; }
  .subnav a { flex: none; padding: 6px 10px; border-radius: 10px; }
  .topbar { height: 56px; padding: 0 16px; gap: 8px; }
  .topbar .search, .topbar .status-chip { display: none; }
  .topbar .tenant { flex: 1; }
  .topbar select.tenant-select { max-width: 100%; min-width: 0; flex: 1; }
  .content { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 26px; }
  .page-head { margin-bottom: 18px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .card { padding: 18px 16px; }
  .card.flush > .card-head { padding: 14px 16px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 16px; }
  .tbl th:last-child, .tbl td:last-child { padding-right: 16px; }
  .kpi .value { font-size: 24px; }
  .grid.kpis-main { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis-main .kpi.hero { grid-column: 1 / -1; }
  .kpis-main .kpi:not(.hero) { padding: 14px; }
  .kpis-main .kpi:not(.hero) .value { font-size: 20px; }
  .grid.kpis-small { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .auth-card .wordmark-sm { display: block; }
  .auth-main { place-items: start center; padding: 48px 20px; }
  .bar-row { grid-template-columns: 80px 1fr 90px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .tbl .hide-sm { display: none; }
  .drawer { top: 0; right: 0; bottom: 0; width: 100%; border-radius: 0; border: 0; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (min-width: 901px) {
  .topbar .user-btn { display: none; }
}

/* Mahnprofile: Profil-Kacheln, Vorlagen, abweichende Einstellungen, Zuordnungsregeln */
.profile-grid, .tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tpl-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.profile-tile, .tpl-tile { display: flex; flex-direction: column; align-items: stretch; gap: 4px; text-align: left; min-width: 0; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.profile-tile:hover, .tpl-tile:hover { background: var(--hover); }
.profile-tile[aria-pressed="true"], .tpl-tile[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.pt-name { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.pt-name .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-name .i { color: var(--accent-text); flex: none; }
.pt-meta { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.pt-meta.faint { color: var(--faint); }
.ov-title { margin: 18px 0 4px; }
.ov-switch { margin: 6px 0 4px; }
.ov-list { border-top: 1px solid var(--line); }
.ov-row { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ov-label { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.ov-label .small { font-weight: 400; }
.ov-value { min-width: 0; }
.ov-inherit { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 13px; }
.ov-narrow { max-width: 180px; }
.ov-time { gap: 8px; flex-wrap: nowrap; }
.ov-time .input { width: 120px; }
.profile-pill { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.profile-pill .i { width: 14px; height: 14px; color: var(--accent-text); }
.rule-pos { display: inline-flex; flex-direction: column; gap: 2px; }
.rule-pos .icon-btn { width: 26px; height: 22px; }
.rule-cond { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-off { opacity: .55; }
.cond-row { display: grid; grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.cond-row .cond-args { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.cond-row .cond-args .input { width: auto; min-width: 0; }
select.input.filter-select { width: auto; min-width: 170px; max-width: 240px; }
.profile-cell { max-width: 180px; white-space: normal; }
@media (max-width: 900px) {
  .ov-row, .cond-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
