/* =====================================================================
   objectlink.de – Design-System
   Farben aus dem Logo: Marineblau (Navigation), Ozeanblau (Aktionen),
   Korall (Akzent). Ruhiger, heller Arbeitsbereich; Dunkelmodus inklusive.
   ===================================================================== */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Grundflächen */
  --bg-main: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f4f8;
  --bg-hover: #f7f9fc;
  --border-color: #dfe4ec;
  --border-subtle: #edf0f5;
  --border-input: #cfd6e1;

  /* Schrift */
  --text-primary: #12203a;
  --text-secondary: #4a5872;
  --text-muted: #7a879c;

  /* Marke */
  --accent-primary: #1b7fae;
  --accent-hover: #146a92;
  --accent-light: rgba(27, 127, 174, 0.10);
  --accent-ring: rgba(27, 127, 174, 0.22);
  --coral: #f0744a;
  --coral-light: rgba(240, 116, 74, 0.12);

  /* Status */
  --success-bg: #e9f7f1;
  --success-border: #b6e2cf;
  --success-text: #0f7a55;
  --danger-bg: #fdeeec;
  --danger-border: #f3c3bd;
  --danger-text: #c0392b;
  --warning-bg: #fff5e3;
  --warning-border: #f2d499;
  --warning-text: #9a5b00;

  /* Navigation (bleibt in beiden Modi dunkel) */
  --nav-bg: #0d2240;
  --nav-bg-2: #0a1b34;
  --nav-text: #b7c4d8;
  --nav-text-hover: #ffffff;
  --nav-active-bg: rgba(255, 255, 255, 0.09);
  --nav-section: #6f82a0;

  --table-header-bg: #f7f9fc;
  --table-input-bg: #ffffff;
  --icon-primary: var(--accent-primary);
  --icon-secondary: var(--text-muted);
  --md-icon-fg: #526075;
  --md-icon-bg: #b8c2d1;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 32, 58, 0.05);
  --shadow: 0 1px 2px rgba(16, 32, 58, 0.04), 0 4px 14px rgba(16, 32, 58, 0.05);
  --shadow-lg: 0 10px 30px rgba(16, 32, 58, 0.18);
  --sidebar-breite: 248px;
}

[data-theme="dark"] {
  --bg-main: #0b1322;
  --bg-surface: #111c2e;
  --bg-surface-elevated: #172438;
  --bg-hover: #15223a;
  --border-color: #23324a;
  --border-subtle: #1b293e;
  --border-input: #2c3d58;

  --text-primary: #e8eef7;
  --text-secondary: #aab7cb;
  --text-muted: #7c8aa1;

  --accent-primary: #4fb0dc;
  --accent-hover: #6cc0e6;
  --accent-light: rgba(79, 176, 220, 0.14);
  --accent-ring: rgba(79, 176, 220, 0.30);
  --coral: #ff8a5f;
  --coral-light: rgba(255, 138, 95, 0.16);

  --success-bg: rgba(31, 170, 120, 0.14);
  --success-border: rgba(31, 170, 120, 0.40);
  --success-text: #5fd3a6;
  --danger-bg: rgba(229, 83, 66, 0.14);
  --danger-border: rgba(229, 83, 66, 0.42);
  --danger-text: #ff9a8c;
  --warning-bg: rgba(242, 170, 50, 0.13);
  --warning-border: rgba(242, 170, 50, 0.40);
  --warning-text: #f5c66b;

  --nav-bg: #08111f;
  --nav-bg-2: #060d18;

  --table-header-bg: #142135;
  --table-input-bg: #0e1828;
  --md-icon-fg: #9aa8be;
  --md-icon-bg: #465773;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* ===================================================================== Basis */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }
ul, ol { padding-left: 1.25rem; }
ul.codes { padding-left: 0; }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--bg-surface-elevated); padding: 0.1em 0.35em; border-radius: 4px; }
strong { font-weight: 600; }
.ic { flex-shrink: 0; display: block; }
:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-ring); }

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ===================================================================== App-Rahmen */
/* Nie waagerecht scrollen – nur Tabellen (.table-responsive) und Reiter dürfen das intern */
html, body { max-width: 100%; overflow-x: clip; }
body { overflow-wrap: break-word; }
.app-shell { display: flex; min-height: 100vh; }
.card, .page-header, .form-row, .form-grid, .form-stack { min-width: 0; max-width: 100%; }
/* Grid-/Flex-Kinder dürfen schmaler werden als ihr Inhalt (sonst drücken sie die Seite breit) */
.akte-grid > *, .form-grid > *, .module-grid > *, .summary-cards-grid > *, .start-dashboard-grid > *, .container form { min-width: 0; max-width: 100%; }
img, video, iframe, pre { max-width: 100%; }
pre { overflow-x: auto; }
.app-shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.container { width: 100%; max-width: 1920px; margin: 0 auto; padding: 1.75rem 2rem 2.5rem; flex: 1; }

footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1rem;
  padding: 1rem 2rem; color: var(--text-muted); font-size: 0.8rem; margin-top: auto;
}

/* ---- Seitenleiste */
.sidebar {
  width: var(--sidebar-breite); flex-shrink: 0;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  color: var(--nav-text);
  display: flex; flex-direction: column; gap: 1rem;
  position: sticky; top: 0; height: 100vh; padding: 1.15rem 0.9rem 0.9rem;
  overflow-y: auto; z-index: 40;
}
.sidebar-header { padding: 0 0.35rem; }
.navbar-brand { display: flex; align-items: center; gap: 0.65rem; text-decoration: none !important; min-width: 0; }
.logo-img { width: 36px; height: 36px; border-radius: 9px; display: block; flex-shrink: 0; }
.brand-text { display: inline-flex; flex-direction: column; width: fit-content; min-width: 0; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); line-height: 1.15; width: max-content; }
.brand-accent { color: var(--coral); }
.brand-subline { font-size: 0.82rem; font-weight: 500; letter-spacing: 0.01em; color: var(--text-muted); line-height: 1.3; white-space: nowrap; width: max-content; }
.sidebar .brand-name { color: #ffffff; }
.sidebar .brand-subline { color: rgba(255, 255, 255, 0.85); }

.mandant-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff; text-decoration: none !important; transition: background 0.15s;
}
.mandant-switch:hover { background: rgba(255, 255, 255, 0.11); color: #fff; }
.mandant-switch .ic { color: var(--nav-text); }
.mandant-text { display: flex; flex-direction: column; min-width: 0; }
.mandant-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--nav-section); font-weight: 600; }
.mandant-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mandant-switch.leer { border-style: dashed; border-color: var(--coral); }
.mandant-switch.leer .mandant-name { color: var(--coral); }

.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--nav-section); padding: 0.9rem 0.75rem 0.35rem;
}
.nav-section:first-child { padding-top: 0.2rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.75rem; border-radius: 8px;
  color: var(--nav-text); font-weight: 500; font-size: 0.93rem; text-decoration: none !important;
  position: relative; transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: var(--nav-text-hover); }
.nav-link.active { background: var(--nav-active-bg); color: #fff; font-weight: 600; }
.nav-link.active::before {
  content: ""; position: absolute; left: -0.9rem; top: 22%; bottom: 22%; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--coral);
}
.nav-link.active .ic { color: var(--coral); }
.nav-link.disabled { opacity: 0.4; pointer-events: none; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 0.6rem; padding-top: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.user-card {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.55rem; border-radius: var(--radius);
  text-decoration: none !important; color: #fff; transition: background 0.15s;
}
.user-card:hover, .user-card.active { background: rgba(255, 255, 255, 0.07); color: #fff; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--coral), #e35d8f); color: #fff; font-weight: 700; font-size: 0.8rem; text-transform: uppercase;
}
.user-text { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.74rem; color: var(--nav-section); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-actions { display: flex; gap: 0.35rem; padding: 0 0.2rem; }
.sidebar-actions form { display: inline; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.icon-btn-badge {
  position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px; background: var(--coral); color: #fff;
  font-size: 0.62rem; font-weight: 700; line-height: 15px; text-align: center;
}
.sidebar .icon-btn.active { background: var(--nav-active-bg); color: #fff; }
.sidebar .icon-btn { color: var(--nav-text); }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.icon-btn:hover { background: var(--bg-surface-elevated); }
.theme-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: none; }

/* ---- Kopfzeile für kleine Bildschirme */
.topbar { display: none; }
.sidebar-backdrop { display: none; }

/* ---- Anmeldeseiten */
.anon-shell { min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-light), transparent 70%), var(--bg-main); }
.anon-header { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 2rem; }
.anon-shell .container { max-width: 1100px; }
.anon-shell footer { justify-content: center; }

/* ===================================================================== Seitenkopf */
.page-header { margin-bottom: 1.5rem; }
.page-header:not(.page-header-row) > * + * { margin-top: 0.35rem; }
.page-header h1 { font-size: 1.65rem; }
.page-header > p:first-child { font-size: 0.88rem; }
.page-header p { color: var(--text-secondary); }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; }
.page-title h1 { font-size: 1.65rem; }
.page-title p { color: var(--text-secondary); margin-top: 0.25rem; }

/* Reiter: eine Zeile, bei Platzmangel waagerecht scrollbar */
.tabs {
  display: flex; gap: 0.25rem; margin-top: 1.1rem; border-bottom: 1px solid var(--border-color);
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button[role="tab"] {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.6rem 0.85rem; color: var(--text-secondary); font: inherit; font-weight: 500; font-size: 0.92rem;
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none !important; border-radius: 6px 6px 0 0; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.tabs a:hover, .tabs button[role="tab"]:hover { color: var(--text-primary); background: var(--bg-hover); }
.tabs a.active, .tabs button[role="tab"][aria-selected="true"] {
  color: var(--accent-primary); border-bottom-color: var(--accent-primary); font-weight: 600;
}
.tabs a.folgt { opacity: 0.5; }
.tabs button[role="tab"].tab-action { color: var(--accent-primary); }
.tabs button[role="tab"].tab-action[aria-selected="true"] { background: var(--accent-light); }
/* Fixierte Reiter: bleiben beim Scrollen oben stehen (z. B. Aboverwaltung) */
.tabs.tabs-fixiert {
  position: sticky; top: 0; z-index: 15; margin: -0.25rem 0 1rem; padding-top: 0.35rem;
  background: var(--bg-main);
}

/* Versammlungs-Übersicht: Karten-Tabs & strukturierte Formulare */
.vs-card-heading { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.vs-tabs { margin-top: 0.25rem; margin-bottom: 1rem; }
.vs-panel[hidden] { display: none; }
.vs-empty { color: var(--text-muted); font-size: 0.9rem; margin: 0.25rem 0; }
.vs-form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.95rem 1.1rem;
  max-width: 780px; align-items: start;
}
.vs-form-grid .vs-full { grid-column: 1 / -1; }
.vs-form-grid label {
  display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.84rem; font-weight: 500; color: var(--text-secondary);
}
.vs-form-grid input, .vs-form-grid select, .vs-form-grid textarea {
  font: inherit; font-size: 0.93rem; color: var(--text-primary); background: var(--table-input-bg);
  border: 1px solid var(--border-input); border-radius: 8px; padding: 0.55rem 0.75rem; min-height: 40px;
  width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
.vs-form-grid textarea { min-height: 96px; resize: vertical; }
.vs-form-grid input:focus, .vs-form-grid select:focus, .vs-form-grid textarea:focus {
  outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-ring);
}
.vs-form-grid label.check { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--text-primary); }
.vs-form-grid label.check input { width: 17px; height: 17px; min-height: 0; padding: 0; }
.vs-form-actions { grid-column: 1 / -1; padding-top: 0.25rem; }
@media (max-width: 640px) { .vs-form-grid { grid-template-columns: 1fr; } }

.heading-with-icon { display: inline-flex; align-items: center; gap: 0.5rem; }
.md-ic { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.md-ic .md-bg { fill: var(--md-icon-bg); }
.md-ic .md-fg { fill: var(--md-icon-fg); }

/* ===================================================================== Karten */
.card {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.card-title {
  font-size: 1.02rem; font-weight: 650; margin-bottom: 1rem; color: var(--text-primary);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
}
.card-title .hint { margin-top: 0; font-weight: 400; }
.card > .table-responsive:first-child { margin-top: -0.25rem; }

/* Kennzahlen */
.summary-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(165px, 100%), 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent-primary); }
.stat-card.stat-success::before { background: var(--success-text); }
.stat-card.stat-danger::before { background: var(--danger-text); }
.stat-card.stat-warning::before { background: var(--coral); }
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.3rem; font-variant-numeric: tabular-nums; }
.stat-subtext { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Startseite: Module */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 0.9rem; }
.module-card {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius);
  padding: 1rem 1.1rem; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.module-card:hover { border-color: var(--accent-primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.module-card h3 { font-size: 0.98rem; margin-bottom: 0.3rem; }
.module-card p { color: var(--text-secondary); font-size: 0.88rem; }
.module-card .badge { margin-top: 0.7rem; }

/* Schlüssel-Wert-Listen */
.kv { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 0.55rem 1.25rem; font-size: 0.92rem; }
.kv dt { color: var(--text-muted); }
.kv dd { word-break: break-word; }

/* Akten-Layout (zweispaltig) */
.akte-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 0 1.25rem; align-items: start; }
.eintrag { padding: 0.7rem 0; border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 0.25rem; position: relative; padding-right: 2.5rem; }
.eintrag:last-of-type { border-bottom: none; }
.eintrag > form { position: absolute; right: 0; top: 0.6rem; }
.eintrag.inaktiv { opacity: 0.55; }
.eintrag .unter { margin-left: 1rem; font-size: 0.88rem; padding-top: 0.25rem; }

/* ===================================================================== Tabellen */
.tabelle-scroll { overflow-x: auto; max-width: 100%; }
.table-responsive { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-surface); }
.excel-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.92rem; text-align: left; }
.excel-table th {
  background: var(--table-header-bg); color: var(--text-muted); font-weight: 600; font-size: 0.74rem;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--border-color);
  white-space: normal; hyphens: manual; position: sticky; top: 0; z-index: 1;
}
.excel-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.excel-table tbody tr:last-child td { border-bottom: none; }
.excel-table tbody tr { transition: background 0.1s; }
.excel-table tbody tr:hover td { background: var(--bg-hover); }
.excel-table td a { font-weight: 500; }
.excel-table .zahl, .excel-table td.zahl, .excel-table th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.excel-table tfoot td { font-weight: 650; background: var(--table-header-bg); border-top: 1px solid var(--border-color); border-bottom: none; }
.excel-table tr.neue-zeile td { background: var(--accent-light); }
.excel-table tr.neue-zeile:hover td { background: var(--accent-light); }
.section-header-row td { background: var(--bg-surface-elevated) !important; color: var(--accent-primary); font-weight: 700; }
.summary-row td { background: var(--table-header-bg) !important; font-weight: 700; }
tr.zeile-leer td { color: var(--text-secondary); }
tr.zeile-leer td:first-child { box-shadow: inset 3px 0 0 var(--coral); }
tr.zeile-fehler td { background: var(--danger-bg); }
tr.zeile-warnung td { color: var(--danger-text); }
tr.inaktiv td { opacity: 0.55; }
tr.kuenftig td { color: var(--accent-primary); }
tr.optional { display: none; }
td.actions { white-space: nowrap; text-align: right; }
/* Lange Werte ohne Leerzeichen (E-Mail, IBAN …) dürfen umbrechen, statt die Tabelle zu verbreitern */
.excel-table td.umbruch { overflow-wrap: anywhere; min-width: 9rem; }
td.actions > *, td.actions form { display: inline-flex; vertical-align: middle; }
td.actions > * + * { margin-left: 0.35rem; }

/* Eingaben in Tabellen: dezent wie Text, sichtbar beim Darüberfahren/Bearbeiten */
.excel-table input:not([type=checkbox]), .excel-table select {
  width: 100%; min-width: 90px; padding: 0.4rem 0.55rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-primary); font: inherit; font-size: 0.9rem; transition: border-color 0.15s, background 0.15s;
}
.excel-table tr:hover input:not([type=checkbox]):not(:disabled), .excel-table tr:hover select:not(:disabled) { border-color: var(--border-input); background: var(--table-input-bg); }
.excel-table input:focus, .excel-table select:focus { outline: none; border-color: var(--accent-primary) !important; background: var(--table-input-bg) !important; box-shadow: 0 0 0 3px var(--accent-ring); }
.excel-table tr.neue-zeile input:not([type=checkbox]), .excel-table tr.neue-zeile select { border-color: var(--border-input); background: var(--table-input-bg); }
.excel-table input:disabled, .excel-table select:disabled { color: var(--text-primary); opacity: 1; -webkit-text-fill-color: var(--text-primary); appearance: none; }
.excel-table .w-s { min-width: 64px; }
.excel-table .w-xs { min-width: 54px; max-width: 76px; }
.excel-table .w-z { min-width: 86px; text-align: right; }

/* ===================================================================== Formulare */
.form-row { display: flex; flex-wrap: wrap; gap: 0.85rem 1rem; align-items: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 0.95rem 1.1rem; align-items: end; }
.form-grid label.breit { grid-column: span 2; }
.form-stack { display: flex; flex-direction: column; gap: 1rem; }

.form-row label, .form-grid label, .form-stack label, .voll-label {
  display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.84rem; font-weight: 500; color: var(--text-secondary);
}
.label-text { display: inline; }
.req-mark { color: var(--danger-text); font-weight: 700; margin-left: 0.15rem; }
.form-row input, .form-row select, .form-grid input, .form-grid select, .form-stack input, .form-stack select,
textarea.voll, .voll-label input, .restore-form select, .restore-form input, select, textarea {
  font: inherit; font-size: 0.93rem; color: var(--text-primary); background: var(--table-input-bg);
  border: 1px solid var(--border-input); border-radius: 8px; padding: 0.55rem 0.75rem; min-height: 40px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input, .form-row select { min-width: min(220px, 100%); max-width: 100%; }
input[type=file] { padding: 0.45rem; }
textarea.voll { width: 100%; min-height: 80px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.8; }
.form-row input:focus, .form-row select:focus, .form-grid input:focus, .form-grid select:focus, .form-stack input:focus,
textarea:focus, select:focus, .voll-label input:focus {
  outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-ring);
}
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent-primary); cursor: pointer; }
label.check, .form-row label.check, .form-grid label.check, .checkgruppe label.check {
  flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--text-primary); cursor: pointer;
}
.form-row label.check input { min-width: 0; min-height: 0; }
.checkgruppe { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; margin-top: 1rem; align-items: center; font-size: 0.9rem; }
.checkgruppe > span { color: var(--text-muted); font-weight: 500; }
.checkgruppe.breit { grid-column: 1 / -1; margin-top: 0; }
.voll-label { margin-top: 0.9rem; }
.restore-form { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.restore-form select, .restore-form input { min-height: 34px; padding: 0.35rem 0.55rem; font-size: 0.85rem; }

details.neu { margin-top: 1rem; border-top: 1px dashed var(--border-color); padding-top: 0.8rem; }
details.neu summary {
  cursor: pointer; color: var(--accent-primary); font-weight: 600; font-size: 0.9rem; list-style: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
details.neu summary::-webkit-details-marker { display: none; }
details.neu summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--accent-light); font-weight: 700; }
details.neu[open] summary::before { content: "–"; }
details.neu form { margin-top: 0.9rem; }

/* ===================================================================== Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 38px; padding: 0.5rem 1rem; font: inherit; font-size: 0.9rem; font-weight: 600; line-height: 1.2;
  border-radius: 8px; border: 1px solid var(--border-input); cursor: pointer; text-decoration: none !important;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff !important; box-shadow: 0 1px 2px rgba(16, 32, 58, 0.12); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 12px var(--accent-ring); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary) !important; border-color: var(--border-input); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent-primary); }
.btn-sm { min-height: 30px; padding: 0.3rem 0.7rem; font-size: 0.82rem; border-radius: 7px; }
.btn.danger { color: var(--danger-text) !important; border-color: var(--danger-border); background: var(--bg-surface); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger-text); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

a.btn-link, button.btn-link {
  background: none; border: none; padding: 0.2rem 0.1rem; color: var(--accent-primary); font: inherit; font-size: 0.9rem;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; text-decoration: none;
}
a.btn-link:hover, button.btn-link:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
button.btn-link.danger, a.btn-link.danger { color: var(--danger-text); }
.eintrag > form .btn-link.danger, td .btn-link.danger { width: 28px; height: 28px; justify-content: center; border-radius: 7px; padding: 0; }
.eintrag > form .btn-link.danger:hover, td .btn-link.danger:hover { background: var(--danger-bg); text-decoration: none; }

/* ===================================================================== Badges & Hinweise */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid transparent; vertical-align: middle;
}
.badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-info { background: var(--accent-light); color: var(--accent-primary); border-color: transparent; }
.badge-secondary { background: var(--bg-surface-elevated); color: var(--text-secondary); border-color: var(--border-color); }

.alert {
  padding: 0.85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.25rem; border: 1px solid; border-left-width: 4px;
  font-size: 0.92rem;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); border-left-color: var(--success-text); }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); border-left-color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); border-left-color: var(--coral); }
.alert ul { padding-left: 1.2rem; margin-top: 0.3rem; }
.alert-inline { color: var(--danger-text); font-size: 0.85rem; }
.hint { color: var(--text-muted); font-size: 0.86rem; margin-top: 0.9rem; }
.auth-links { text-align: center; }
.auth-links a { color: var(--accent-primary); font-weight: 500; }

/* Passwortfeld mit Auge */
.pw-feld { position: relative; display: flex; flex-direction: column; }
.pw-feld input { width: 100%; padding-right: 2.75rem !important; }
.pw-auge {
  position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center;
  justify-content: center; width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text-muted); cursor: pointer; padding: 0;
}
.pw-auge:hover, .pw-auge:focus-visible { color: var(--text-primary); background: var(--bg-hover, rgba(127,127,127,0.12)); outline: none; }
.kopf { color: var(--text-muted); }
ul.liste { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.92rem; }

/* Verteilungsbalken */
.balken { background: var(--bg-surface-elevated); border-radius: 999px; height: 8px; min-width: 120px; overflow: hidden; }
.balken span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-primary), #35a6c9); border-radius: 999px; }

/* Änderungsprotokoll */
.diff { font-size: 0.84rem; line-height: 1.45; min-width: 300px; word-break: break-word; }
.diff s { color: var(--danger-text); }

/* ===================================================================== Anmeldung & 2FA */
.auth-box {
  max-width: 440px; margin: 3rem auto; background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: 18px; padding: 2rem 2rem 1.75rem; box-shadow: var(--shadow-lg);
}
.auth-box h1 { font-size: 1.45rem; margin-bottom: 1.25rem; }
.auth-box .btn-primary { width: 100%; min-height: 44px; font-size: 0.95rem; }
.code-input { font-size: 1.45rem !important; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }
.steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; margin: 1rem 0; font-size: 0.93rem; }
.qr { background: #fff; padding: 0.6rem; border-radius: var(--radius); width: 220px; max-width: 100%; margin: 0.7rem 0; border: 1px solid var(--border-color); }
.qr svg { width: 100%; height: auto; display: block; }
.secret { font-size: 0.95rem; word-spacing: 0.3em; }
.codes { list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem 1rem; margin: 1rem 0 1.25rem; font-size: 1.05rem; }

/* ===================================================================== Responsiv */
@media (max-width: 1000px) {
  .container { padding: 1.25rem 1.1rem 2rem; }
  footer { padding: 1rem 1.1rem; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 17, 31, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 30; }
  body.menu-offen .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .topbar {
    display: flex; align-items: center; gap: 0.6rem; position: sticky; top: 0; z-index: 20;
    padding: 0.55rem 1rem; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); box-shadow: var(--shadow-sm);
  }
  .topbar .brand-subline { display: none; }
  .tabs.tabs-fixiert { top: 52px; } /* unter der fixierten Kopfleiste (ca. 53 px), 1 px überlappt deren Rand */
  .topbar .logo-img { width: 30px; height: 30px; }
  .topbar-mandant {
    margin-left: auto; font-size: 0.8rem; font-weight: 600; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    padding: 0.3rem 0.7rem; border-radius: 999px; background: var(--accent-light);
  }
  .topbar .topbar-news { flex-shrink: 0; }
  .topbar .navbar-brand { flex-shrink: 0; }
  .topbar-mandant { min-width: 0; flex-shrink: 1; }
  .start-hero-top { display: none; }
  .topbar:not(:has(.topbar-mandant)) .topbar-news { margin-left: auto; }
  .akte-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  html { font-size: 14.5px; }
  .btn { white-space: normal; text-align: center; max-width: 100%; }
  .container form[style*="display:flex"], .container div[style*="display:flex"] { flex-wrap: wrap; }
  .form-grid label.breit { grid-column: span 1; }
  .form-row input, .form-row select { min-width: 0; width: 100%; }
  .form-row label { width: 100%; }
  .card { padding: 1rem; border-radius: var(--radius); }
  .page-header h1 { font-size: 1.4rem; }
  .anon-header { padding: 0.9rem 1rem; }
  .auth-box { margin: 1.5rem auto; padding: 1.5rem 1.25rem; }
  .kv { grid-template-columns: 1fr; gap: 0.1rem; }
  .kv dd { margin-bottom: 0.5rem; }
}
@media print {
  .sidebar, .topbar, footer, .form-row, .tabs { display: none !important; }
  .app-shell { display: block; }
  .card, .auth-box { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* ===================================================================== Startseite & Listenbausteine */
.page-header-row > :first-child { margin-right: auto; }
.eyebrow { font-size: 0.78rem !important; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--coral) !important; }
.hero-card { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.hero-card > div:nth-child(2) { flex: 1; min-width: min(240px, 100%); }
.hero-card p { color: var(--text-secondary); margin-top: 0.3rem; }
.hero-icon, .module-icon, .liste-icon {
  display: grid; place-items: center; flex-shrink: 0; border-radius: 12px; background: var(--accent-light); color: var(--accent-primary);
}
.hero-icon { width: 56px; height: 56px; }
.stat-link { text-decoration: none !important; color: inherit; transition: border-color 0.15s, transform 0.15s; }
.stat-link:hover { border-color: var(--accent-primary); transform: translateY(-1px); color: inherit; }
.liste-zeile {
  display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 0.6rem; margin: 0 -0.6rem; border-radius: var(--radius);
  color: inherit; text-decoration: none !important; transition: background 0.12s;
}
.liste-zeile:hover { background: var(--bg-hover); color: inherit; }
.liste-zeile + .liste-zeile { border-top: 1px solid var(--border-subtle); }
.liste-icon { width: 38px; height: 38px; border-radius: 10px; }
.liste-icon.warn { background: var(--coral-light); color: var(--coral); }
.liste-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.liste-text strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste-text span { font-size: 0.84rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leerzustand { display: flex; align-items: center; gap: 0.85rem; color: var(--text-muted); padding: 0.4rem 0; }
.leerzustand .ic { color: var(--success-text); }
.module-icon { width: 38px; height: 38px; border-radius: 10px; margin-bottom: 0.7rem; }
.module-card.geplant .module-icon { background: var(--bg-surface-elevated); color: var(--text-muted); }
details.technik > summary { cursor: pointer; margin-bottom: 0; list-style: none; }
details.technik > summary::-webkit-details-marker { display: none; }
details.technik > summary::after { content: "anzeigen"; font-size: 0.82rem; font-weight: 500; color: var(--accent-primary); }
details.technik[open] > summary { margin-bottom: 1rem; }
details.technik[open] > summary::after { content: "ausblenden"; }

/* Dunkelmodus: dunkle Schrift auf hellem Hauptknopf (Kontrast) */
[data-theme="dark"] .btn-primary { color: #06121f !important; }
[data-theme="dark"] .btn-primary:hover { color: #06121f !important; }
.excel-table td > a.btn:first-child { white-space: nowrap; }

.mandant-switch.statisch, .mandant-switch.statisch:hover { background: rgba(255, 255, 255, 0.04); cursor: default; }
span.topbar-mandant { color: var(--accent-primary); }

/* Modulkarten: nur fertige sind Links; geplante wirken bewusst nicht klickbar */
a.module-card { display: block; color: inherit; text-decoration: none !important; }
a.module-card:hover { color: inherit; }
.module-card.geplant { opacity: 0.6; background: var(--bg-surface-elevated); border-style: dashed; }
.module-card.geplant:hover { border-color: var(--border-color); box-shadow: none; transform: none; }

/* Buchhaltung */
.negativ { color: var(--danger-text); }
tr.storniert td { color: var(--text-muted); text-decoration: line-through; }
tr.storniert td:last-child, tr.storniert td:nth-last-child(2) { text-decoration: none; }
tr.ueberfaellig td:first-child { color: var(--danger-text); font-weight: 600; }
li.danger { color: var(--danger-text); }

/* ===== Einkauf: Split-View Belegerfassung (wie ea / Arbeitsblatt) ===== */
.ek-ai-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: 9px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.9rem;
}
.ek-ai-title { font-weight: 700; font-size: 0.95rem; color: var(--text-primary); }
.ek-ai-sub { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.15rem; }
.ek-ai-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.ek-status-box {
  padding: 0.55rem 0.85rem;
  border-radius: 7px;
  margin-bottom: 0.9rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
}
.ek-status-box.info { background: var(--accent-light); border-color: var(--accent-primary); color: var(--accent-primary); }
.ek-status-box.ok { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.ek-status-box.warn { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.ek-status-box.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }

.ek-split-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(340px, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .ek-split-grid { grid-template-columns: 1fr; }
}

.ek-preview-box {
  min-height: 520px;
  height: 68vh;
  background: var(--bg-main);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.35rem;
}
.ek-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  padding: 1.5rem;
  max-width: 320px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.ek-preview-placeholder strong { color: var(--text-primary); font-size: 0.95rem; }

/* ===================================================================== News & Zähler */
.nav-count {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.42rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}
.nav-count-gray {
  background: rgba(255, 255, 255, 0.14);
  color: var(--nav-text);
}
.nav-count-orange {
  background: var(--coral);
  color: #fff;
}

.news-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.news-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.38rem;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.news-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.news-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.35fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 960px) {
  .news-layout { grid-template-columns: 1fr; }
}

.news-list-card { padding: 0; overflow: hidden; }
.news-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--table-header-bg);
}
.news-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.news-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.news-toolbar-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.news-btn-danger:not(:disabled):hover {
  color: var(--danger-text) !important;
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.news-list {
  display: flex;
  flex-direction: column;
}
.news-item {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.12s;
}
.news-item:last-child { border-bottom: none; }
.news-row-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  transition: background 0.12s;
}
.news-row-head:hover { background: var(--bg-hover); }
.news-item.is-open > .news-row-head {
  background: var(--accent-light);
}
.news-item .news-check {
  flex-shrink: 0;
  cursor: pointer;
}
.news-row-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.news-row-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}
.news-row-right {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.news-row-chevron {
  display: inline-flex;
  color: var(--text-muted);
  transition: transform 0.16s ease;
}
.news-row-toggle[aria-expanded="true"] .news-row-chevron {
  transform: rotate(90deg);
  color: var(--accent-primary);
}
.news-row-body {
  padding: 0.9rem 1.2rem 1.1rem 2.95rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
}
.news-row-body[hidden] { display: none; }
.news-row-content {
  font-size: 0.93rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.news-row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}
.news-row-actions-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.news-item-icon {
  display: inline-flex;
  align-items: center;
  margin-top: 0.15rem;
  flex-shrink: 0;
  color: var(--text-muted);
}
.news-list-empty {
  justify-content: flex-start;
  padding: 1rem;
}
.news-list-empty .ic,
.news-reader-empty .ic,
.news-item-icon .ic {
  color: var(--text-muted);
}
.news-item-link {
  flex: 1;
  min-width: 0;
  text-decoration: none !important;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.news-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.news-item-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.93rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.news-item.is-unread .news-item-title {
  font-weight: 700;
}
.news-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  flex-shrink: 0;
}
.news-item-date {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.news-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.news-reader-card {
  min-height: 360px;
  display: flex;
  flex-direction: column;
}
.news-reader-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.news-reader-badges {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}
.news-reader-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-primary);
}
.news-reader-meta {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.news-reader-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.news-reader-body {
  padding: 1.15rem 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
}
.news-reader-footer {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}
.news-reader-empty {
  margin: auto;
}

/* ===================================================================== Startseite (Hero, Dashboard & Leistungsportfolio) */
.start-hero {
  position: relative;
  overflow: hidden;
  padding: 1.5rem 1.75rem;
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface) 62%, var(--accent-light) 100%);
  border-color: var(--border-color);
}
.start-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--nav-bg) 0%, var(--accent-primary) 60%, var(--coral) 100%);
}
.start-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.start-hero-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}
.start-hero-logo-wrap {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: var(--nav-bg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  padding: 6px;
}
.start-hero-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  display: block;
}
.start-hero-brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.start-hero-appname {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1;
  width: max-content;
}
.start-hero-subline {
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--accent-primary);
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin-top: 0.22rem;
  width: max-content;
}
.start-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.start-hero-welcome h1 {
  font-size: 1.55rem;
  margin-top: 0.15rem;
}
.start-hero-context {
  color: var(--text-secondary);
  margin-top: 0.3rem;
  font-size: 0.94rem;
}

.start-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 0 1.25rem;
  align-items: start;
}
.start-card {
  display: flex;
  flex-direction: column;
}
.start-card-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.start-card-heading .ic {
  color: var(--accent-primary);
}
.start-news-item.ungelesen strong {
  color: var(--text-primary);
}
.news-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--coral);
  margin-right: 0.35rem;
  vertical-align: middle;
}

.termin-datum {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.termin-datum.warn {
  background: var(--coral-light);
  color: var(--coral);
}
.termin-tag {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.termin-monat {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Leistungsportfolio */
.portfolio-section {
  padding: 1.4rem 1.5rem;
}
.portfolio-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 1120px) {
  .portfolio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.portfolio-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  color: inherit;
  text-decoration: none !important;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s;
}
a.portfolio-card:hover {
  background: var(--bg-surface);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  color: inherit;
}
.portfolio-card.inaktiv {
  opacity: 0.72;
}
.portfolio-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.portfolio-card-head .module-icon {
  margin-bottom: 0;
}
.portfolio-arrow {
  color: var(--text-muted);
  transition: transform 0.15s, color 0.15s;
}
a.portfolio-card:hover .portfolio-arrow {
  color: var(--accent-primary);
  transform: translateX(2px);
}
.portfolio-card h3 {
  font-size: 0.98rem;
  font-weight: 650;
  margin-bottom: 0.35rem;
}
.portfolio-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.48;
  flex: 1;
}
.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border-subtle);
}
.portfolio-tag {
  font-size: 0.71rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .start-hero {
    padding: 1.15rem 1.15rem;
  }
  .start-hero-logo-wrap {
    width: 48px;
    height: 48px;
  }
  .start-hero-appname {
    font-size: 1.72rem;
  }
  .start-dashboard-grid, .portfolio-grid {
    grid-template-columns: 1fr;
  }
}

/* ===================================================================== Geführte Tour */
.tour-spot {
  position: fixed; z-index: 1000; border-radius: var(--radius);
  box-shadow: 0 0 0 3px var(--coral), 0 0 0 9999px rgba(8, 17, 31, 0.55);
  transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, height 0.2s ease;
  pointer-events: none;
}
.tour-sperre { position: fixed; inset: 0; z-index: 999; background: transparent; }
.tour-sperre[hidden] { display: none; }
.tour-spot.ohne-ziel { box-shadow: 0 0 0 9999px rgba(8, 17, 31, 0.55); }
.tour-spot[hidden], .tour-pop[hidden] { display: none; }
.tour-pop {
  position: fixed; z-index: 1001; width: min(340px, calc(100vw - 24px));
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 1rem 1.1rem 0.9rem;
  transition: left 0.2s ease, top 0.2s ease;
}
.tour-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; }
.tour-zaehler { font-size: 0.75rem; font-weight: 600; color: var(--coral); letter-spacing: 0.02em; }
.tour-x { background: none; border: 0; color: var(--text-muted); font-size: 1.35rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.tour-x:hover { color: var(--text-primary); }
.tour-titel { margin: 0 0 0.4rem; font-size: 1.05rem; }
.tour-text { margin: 0 0 0.9rem; font-size: 0.9rem; line-height: 1.5; color: var(--text-secondary); }
.tour-aus { display: flex; align-items: center; gap: 0.45rem; margin: -0.2rem 0 0.8rem; font-size: 0.82rem; color: var(--text-secondary); cursor: pointer; user-select: none; }
.tour-aus input { margin: 0; width: 15px; height: 15px; accent-color: var(--accent-primary); cursor: pointer; }
.tour-fuss { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.tour-nav { display: flex; gap: 0.4rem; }
.tour-btn { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.tour-btn:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 1000px) {
  body.tour-aktiv .sidebar-backdrop { opacity: 0; pointer-events: none; }
  body.tour-aktiv .sidebar { transition: none; }
}

/* ===================================================================== Funktionen (Freischaltung) */
.excel-table td.mitte, .excel-table th.mitte { text-align: center; }
.excel-table td.rechts, .excel-table th.rechts { text-align: right; font-variant-numeric: tabular-nums; }
.excel-table tr.gruppe td { background: var(--bg-surface-elevated); color: var(--text-secondary); font-size: 0.82rem; letter-spacing: 0.02em; }
.excel-table tr.aktiv td { background: var(--accent-light); }
.funktions-matrix td .badge { margin-left: 0.3rem; }
.btn-danger { background: var(--danger-text); color: #fff; border: 1px solid var(--danger-text); }
.btn-danger:hover { filter: brightness(0.92); }

/* Testdaten: Ladehinweis */
.td-laeuft { display: flex; align-items: center; gap: 0.7rem; margin-top: 1rem; padding: 0.8rem 1rem; border-radius: var(--radius);
  background: var(--accent-light); color: var(--accent-primary); font-weight: 500; font-size: 0.92rem; }
.td-laeuft[hidden] { display: none; }
.td-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent;
  animation: td-dreh 0.8s linear infinite; flex: none; }
@keyframes td-dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .td-spinner { animation-duration: 2.4s; } }

/* Statuspunkt an „KI-Suche“: grün = KI eingerichtet, rot = nicht eingerichtet */
.ki-status { width: 9px; height: 9px; border-radius: 50%; margin-left: auto; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15); }
.ki-status.an { background: #22c55e; }
.ki-status.aus { background: #ef4444; }

/* ===================================================================== Dashboard: Kästchen anordnen */
.dashboard-leiste { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin: 0.5rem 0 0.75rem; }
.dashboard-titel { font-size: 1.15rem; margin: 0; color: var(--text-primary); }
.dashboard-knoepfe { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.dashboard-knoepfe [hidden] { display: none; }
.dashboard-hilfe { margin: 0; }
.start-dashboard-grid > .portfolio-section { grid-column: 1 / -1; }
/* Ausblenden: .start-card setzt display:flex – [hidden] muss gewinnen */
.start-dashboard-grid > [data-kachel][hidden] { display: none !important; }
.dashboard-ablage { background: #fff8d6; border: 1px dashed #e8cf6a; border-radius: var(--radius-lg);
  padding: 0.85rem 1rem; margin: 0 0 1.25rem; }
.dashboard-ablage[hidden] { display: none; }
.dashboard-ablage-titel { font-size: 0.82rem; font-weight: 600; color: #7a5b00; margin-bottom: 0.55rem; }
.dashboard-ablage-liste { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dashboard-ablage-eintrag { display: inline-flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.75rem;
  background: var(--bg-surface); border: 1px solid #e8cf6a; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 0.875rem; color: var(--text-primary); }
.dashboard-ablage-eintrag:hover { border-color: var(--accent-primary); }
.dashboard-ablage-aktion { color: var(--accent-primary); font-weight: 600; }
[data-theme="dark"] .dashboard-ablage { background: rgba(240, 200, 60, 0.10); border-color: rgba(240, 200, 60, 0.40); }
[data-theme="dark"] .dashboard-ablage-titel { color: #f0d27a; }
[data-theme="dark"] .dashboard-ablage-eintrag { border-color: rgba(240, 200, 60, 0.40); }
/* Lückenlos (dashboard.js setzt je Kästchen grid-row-end: span n) */
.start-dashboard-grid.masonry { grid-auto-rows: 4px; align-items: start; }
.start-dashboard-grid.anordnen > [data-kachel] { outline: 2px dashed var(--accent-primary); outline-offset: 3px; cursor: grab; }
.start-dashboard-grid.anordnen > [data-kachel].wird-gezogen { opacity: 0.45; cursor: grabbing; }
.dashboard-griff { display: flex; align-items: center; gap: 0.4rem; margin: -0.2rem 0 0.8rem; padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-color); }
.dashboard-griff-titel { flex: 1; font-size: 0.82rem; font-weight: 600; color: var(--accent-primary); user-select: none; }
.dashboard-griff .btn { min-width: 34px; padding-left: 0.5rem; padding-right: 0.5rem; }
@media (prefers-reduced-motion: no-preference) { .start-dashboard-grid > [data-kachel] { transition: opacity 0.15s; } }
.anon-recht a { color: inherit; } .anon-recht { margin-left: 1rem; }
