/* ==========================================================================
   MARKET INSIDER - MODERN DATA GRID (OPTIMIZED & FIXED)
   ========================================================================== */

/* 1. VARIABLEN & THEMES */
:root {
    /* --- UI BASIS (MD3) --- */
    --bg-app:       #f9f9ff;
    --bg-panel:     #ffffff; /* from surface-container-lowest */
    --text-main:    #111c2d;
    --text-muted:   #424754;
    --border-color: #c2c6d6;
    --border-strong:#727785;

    /* --- MD3 Surfaces --- */
    --surface-container:     #e7eeff;
    --surface-container-low: #f0f3ff;
    --surface-container-high:#dee8ff;
    --surface-dim:           #cfdaf2;
    --primary-container:     #2170e4;
    --on-primary-container:  #fefcff;
    --secondary:             #545f73;
    --secondary-container:   #d5e0f8;
    --tertiary:              #825100;
    --tertiary-container:    #a36700;
    --on-tertiary-container: #fffbff;

    /* --- RADIEN --- */
    --radius-xs:  0.125rem; /* new: DEFAULT */
    --radius-sm:  0.25rem;  /* new: lg */
    --radius-md:  0.5rem;   /* new: xl */
    --radius-lg:  0.75rem;  /* new: full */
    --radius-full: 9999px;

    /* --- LAYOUT --- */
    --toolbar-height: 42px;

    /* --- BUTTONS (Light) --- */
    --btn-bg:       #ffffff;
    --btn-text:     #111c2d;
    --btn-border:   #c2c6d6;
    --btn-shadow:   0 1px 2px rgba(0,0,0,0.05);

    /* Primary Action (Blau MD3) */
    --btn-primary-bg:    #0058be;
    --btn-primary-hover: #004a9e; /* Unchanged, kept from original */
    --btn-primary-text:  #ffffff;

    /* --- PIVOT FARBEN --- */
    /* Header & Level 0 */
    --pvt-header-bg:  #1e293b;
    --pvt-header-txt: #f1f5f9;

    /* Level 1: deutlich erkennbar als Gruppe */
    --pvt-lvl1-bg:    #e2e8f0;
    --pvt-lvl1-txt:   #1a1a2e;

    /* Level 2 & Daten */
    --pvt-lvl2-bg:    #f1f5f9;
    --pvt-lvl2-txt:   #1a1a2e;
    --pvt-bg-even:    #ffffff;
    --pvt-bg-odd:     #f8fafc;

    /* Spalten Summen — ttl_line/ttl_share dunkelst → clevel0 → clevel1 → clevel2 hellst */
    --pvt-col-total: #c2c8d2; /* Gesamt (ttl_line/ttl_share): dunkelster Ton */
    --pvt-col-0-bg: #d0d5dd; --pvt-col-0-txt: #1a1a2e; /* clevel0: kräftig */
    --pvt-col-1-bg: #dfe3ea; --pvt-col-1-txt: #1a1a2e; /* clevel1: mittel */
    --pvt-col-2-bg: #ebeef3; --pvt-col-2-txt: #1a1a2e; /* clevel2: dezent */

    /* Header-Overlay: Spaltenfarben halbtransparent über Header-Hintergrund */
    --pvt-col-total-overlay: rgba(194, 200, 210, 0.45);
    --pvt-col-0-overlay: rgba(208, 213, 221, 0.38);
    --pvt-col-1-overlay: rgba(223, 227, 234, 0.30);
    --pvt-col-2-overlay: rgba(235, 238, 243, 0.22);

    /* Interaktion */
    --pvt-hover:      rgba(59, 130, 246, 0.08);
    --pvt-marked:     #fef3c7;
    --pvt-marked-txt: #000000;

    /* Sekundäre Flächen (z.B. KPI-Kacheln) */
    --bg-secondary:    #f0f3ff;
    --text-secondary:  #545f73;

    /* Card-Hintergrund (Light) */
    --bg-card: #ffffff;

    /* Links */
    --link-color:       #0058be;
    --link-hover:       #004a9e;
    --link-visited:     #4a2d8a;

    /* Icons (Light Mode: Orange) */
    --theme-icon-color: #825100;
}

[data-theme="dark"] {
    /* --- UI DARK (MD3 Dark) --- */
    --bg-app:       #121318;
    --bg-panel:     #1d1e25;
    --text-main:    #e2e2e9;
    --text-muted:   #c4c6d0;
    --border-color: #2e3038;
    --border-strong:#44474f;

    /* --- MD3 Dark Surfaces --- */
    --surface-container:     #1d1e25;
    --surface-container-low: #191a20;
    --surface-container-high:#272830;
    --surface-dim:           #121318;
    --primary-container:     #004a9e;
    --on-primary-container:  #d8e2ff;
    --secondary:             #bcc7de;
    --secondary-container:   #3c475a;
    --tertiary:              #ffb95f;
    --tertiary-container:    #653e00;
    --on-tertiary-container: #ffddb8;

    /* --- BUTTONS (Dark) --- */
    --btn-bg:       #272830;
    --btn-text:     #e2e2e9;
    --btn-border:   #44474f;
    --btn-shadow:   0 1px 3px rgba(0,0,0,0.5);

    --btn-primary-bg:    #adc6ff;
    --btn-primary-hover: #d8e2ff;
    --btn-primary-text:  #001a3d;

    /* --- PIVOT DARK --- */
    /* Header (thead): dunkelstes Schwarz */
    --pvt-header-bg: #0a0a0a; --pvt-header-txt:#e0e0e0;

    /* Zeilen-Gruppen: Level 0 = dunkelst, höhere Levels heller */
    --pvt-lvl1-bg:   #282828; --pvt-lvl1-txt:  #e0e0e0;
    --pvt-lvl2-bg:   #1e1e1e; --pvt-lvl2-txt:  #e0e0e0;

    /* Datenzeilen: neutrales Schwarz */
    --pvt-bg-even:   #111111;
    --pvt-bg-odd:    #141414;

    /* Spalten-Summen: ttl_line/ttl_share dunkelst → clevel0 → clevel1 → clevel2 hellst */
    --pvt-col-total: #050505; /* Gesamt (ttl_line/ttl_share): fast schwarz = dunkelst */
    --pvt-col-0-bg: #181818; --pvt-col-0-txt: #e0e0e0; /* clevel0: dunkel */
    --pvt-col-1-bg: #1e1e1e; --pvt-col-1-txt: #e0e0e0; /* clevel1: mittel */
    --pvt-col-2-bg: #252525; --pvt-col-2-txt: #e0e0e0; /* clevel2: hellst */

    /* Header-Overlay: Spaltenfarben halbtransparent über Header-Hintergrund */
    --pvt-col-total-overlay: rgba(255, 255, 255, 0.18);
    --pvt-col-0-overlay: rgba(255, 255, 255, 0.14);
    --pvt-col-1-overlay: rgba(255, 255, 255, 0.10);
    --pvt-col-2-overlay: rgba(255, 255, 255, 0.06);

    /* Akzentfarbe Blau nur für Interaktion */
    --pvt-hover:     rgba(59, 130, 246, 0.12);
    --pvt-marked:    #854d0e;
    --pvt-marked-txt:#ffffff;

    /* Sekundäre Flächen (z.B. KPI-Kacheln) */
    --bg-secondary:    #1d1e25;
    --text-secondary:  #bcc7de;

    /* Card-Hintergrund (Dark) */
    --bg-card: #1d1e25;

    /* Links (Dark: helles Blau, gut lesbar auf dunklem Hintergrund) */
    --link-color:       #8ab4f8;
    --link-hover:       #adc6ff;
    --link-visited:     #c58af9;

    /* Icons (Dark Mode: Blau-Akzent) */
    --theme-icon-color: #adc6ff;
}

/* 2. APP LAYOUT (Full Screen) */
html, body {
    height: 100vh;
    margin: 0; padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

a { color: var(--link-color); }
a:hover { color: var(--link-hover); }
a:visited { color: var(--link-visited); }

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background-color: var(--bg-app);
}

/* Header Animation (Compact Mode) */
.app-header {
    flex: 0 0 auto;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    max-height: 300px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
                opacity 0.3s ease, padding 0.3s ease;
}

body.compact-mode .app-header {
    max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; border-bottom: none;
}
/*
h1 { margin: 0; 
   padding: 10px 0px;
   letter-spacing: -0.01em; border-bottom: 0px solid var(--border-color); 
}*/
p, li { margin: 0; padding: 6px 16px; font-size: 0.9375rem; line-height: 1.5; color: var(--text-muted); }
ul { list-style: none; padding-left: 1.2em; }
ul > li { position: relative; }
ul > li::before {
  content: "›";
  position: absolute;
  left: -0.35em;
  color: var(--border-strong);
  font-weight: 700;
}

/* 3. TOOLBAR (Fixiert Links-Mitte-Rechts) */
.app-toolbar {
    flex: 0 0 auto;
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between; /* WICHTIG: Verteilt die Gruppen */
    padding: 0 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-strong);
    position: relative;
/*    z-index: 1000; */
}

/* Gruppen-Reset: Keine automatischen Margins mehr */
.toolbar-group { display: flex; align-items: center; gap: 8px; margin: 0; }
/* Spezifische Klassen aus deinem HTML */
.pivot-toolbar { display: flex; align-items: center; }
.pivot-toolbar-group { display: flex; gap: 8px; }

.pivot-toolbar-sep, .toolbar-sep {
    width: 1px; height: 24px; background: var(--border-color); margin: 0 5px;
}

/* 4. BUTTONS (Universal & Pivot) */
/* Wir fassen .pivot-btn und .app-btn zusammen */
.pivot-btn, .app-btn {
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    box-shadow: var(--btn-shadow);

    border-radius: var(--radius-md);
    padding: 0 12px;
    height: 30px;
    font-size: 0.90rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
}

.pivot-btn:hover, .app-btn:hover {
    border-color: var(--border-strong);
    background-color: var(--bg-panel);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 88, 190, 0.1);
}

.pivot-btn:active, .app-btn:active, .pivot-btn.active, .app-btn.active {
    transform: translateY(0);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    background-color: var(--border-color);
}

/* Primary Action (Blau) */
.pivot-btn.btn-primary, .app-btn.primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(0, 88, 190, 0.3);
}
.pivot-btn.btn-primary:hover, .app-btn.primary:hover {
    background-color: var(--btn-primary-hover);
    box-shadow: 0 2px 6px rgba(0, 88, 190, 0.35);
}

.pivot-btn svg, .app-btn svg { width: 16px; height: 16px; stroke-width: 2.5; }

/* Toolbar Input (z.B. Date-Picker) */
.toolbar-input {
  height: 30px;
  padding: 0 8px;
  font-size: 0.90rem;
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--btn-text);
  box-shadow: var(--btn-shadow);
  transition: all 0.15s ease-in-out;
}
.toolbar-input:focus {
  outline: none;
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Theme Toggle Special */
#btn-theme-toggle .theme-icon { 
    color: var(--theme-icon-color); font-size: 1.3em; transition: transform 0.3s; 
}
#btn-theme-toggle:hover .theme-icon { transform: rotate(20deg); }

/* 5. WORKSPACE & TABLE CONTAINER */
.app-workspace {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    min-height: 0;
    padding: 0px 0px;
}
.app-workspace.loading {
    pointer-events: none;
    position: relative;
}
.app-workspace.loading > *:not(.page-loading-overlay) {
    opacity: 0.4;
    transition: opacity 0.15s;
}
.app-workspace.loading > .page-loading-overlay {
    opacity: 1;
}

#pivot-table-container {
    flex: 1;
    overflow: auto;
    width: 100%;
    position: relative;
    background-color: var(--bg-app);
    padding-top: 0; margin-top: 0;
}

/* 6. PIVOT TABLE STRUKTUR */
table.pivot {
    border-collapse: separate; /* Wichtig für Sticky Headers */
    border-spacing: 0;
    width: 100%; min-width: 100%;
    table-layout: auto;
    white-space: nowrap;
    font-size: 0.875rem;
    margin-top: 0;
}

table.pivot.pivot-layout-frozen td,
table.pivot.pivot-layout-frozen th {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Column Resize */
table.pivot th .col-resize-handle {
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 310;
}
table.pivot th .col-resize-handle:hover {
    background-color: var(--md-sys-color-primary, #3b82f6);
    opacity: 0.5;
}
table.pivot.col-resizing {
    cursor: col-resize;
    user-select: none;
}
.col-resize-guide {
    position: fixed;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--md-sys-color-primary, #3b82f6);
    opacity: 0.7;
    z-index: 9999;
    pointer-events: none;
}

table.pivot th, table.pivot td {
    padding: 4px 8px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background-clip: padding-box;
    box-sizing: border-box;
}

/* 7. STICKY HEADERS & COLUMNS (Z-Index Fixed) */

/* A) Standard Header */
table.pivot thead th, table.pivot thead td {
    position: sticky; top: 0;
    z-index: 100;
    background-color: var(--pvt-header-bg);
    color: var(--pvt-header-txt);
    font-weight: 600;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--border-strong);
}

/* Sort-Animation */
@keyframes pivot-sort-spin {
    to { transform: rotate(360deg); }
}
table.pivot thead th .sort-spinner {
    display: inline-block;
    width: 10px; height: 10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: pivot-sort-spin 0.4s linear infinite;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.75;
}
table.pivot tbody.is-sorting tr {
    opacity: 0.4;
    transition: opacity 0.1s;
}

/* B) Filter Row (Muss über Header, aber UNTER Tree Spalte) */
table.pivot thead tr.filter-row td,
table.pivot thead tr.filter-row th {
    background-color: var(--bg-panel);
    z-index: 101; 
    padding: 0px; /* FIX: Inputs sollen Zelle füllen */
}

/* C) Sticky Spalte (Tree) - WICHTIG: Z-Index muss > 101 sein! */
table.pivot tbody th.tree,
table.pivot tbody td.tree {
    position: sticky; left: 0;
    z-index: 110 !important; /* FIX: Höher als Filterzeile (101) */
    background-color: var(--bg-app);
    border-right: 2px solid var(--border-strong) !important;
}

/* D) Super Ecke (Oben Links) - FIX: Nur erste Zeile, nicht Filterzeile */
table.pivot thead tr:first-child th.tree,
table.pivot thead tr:first-child th:first-child {
    position: sticky; left: 0;
    z-index: 300 !important; /* Ganz oben */
    background-color: var(--pvt-header-bg) !important;
    border-right: 2px solid var(--border-strong) !important;
    border-bottom: 1px solid var(--border-strong);
}

/* E) Filterzeile erste Zelle (Muss auch sticky sein!) */
tr.pivot-filter-row th:first-child {
    position: sticky; left: 0;
    z-index: 201 !important; /* Höher als normale Filterzellen (101) */
    background-color: var(--bg-panel) !important;
    border-right: 2px solid var(--border-strong);
}

/* F) Generisch fixierte Spalten (pivot-col-fixed) */
table.pivot th.pivot-col-fixed,
table.pivot td.pivot-col-fixed {
    position: sticky !important;
    z-index: 110 !important;
    background-color: var(--bg-app);
}
table.pivot th.pivot-col-fixed-last,
table.pivot td.pivot-col-fixed-last {
    border-right: 2px solid var(--border-strong) !important;
}

table.pivot thead th.pivot-col-fixed {
    z-index: 299 !important;
    background-color: var(--pvt-header-bg) !important;
}

tr.pivot-filter-row th.pivot-col-fixed,
tr.pivot-filter-row td.pivot-col-fixed {
    z-index: 200 !important;
    background-color: var(--bg-panel) !important;
}

/* 8. ZEILEN & SPALTEN STYLES (Color Fixed) */

/* Level 0 */
table.pivot tr.pvtlvl0 th, table.pivot tr.pvtlvl0 td {
    background-color: var(--pvt-header-bg) !important;
    color: var(--pvt-header-txt) !important;
    font-weight: bold;
}
/* Level 1 */
table.pivot tr.pvtlvl1 th, table.pivot tr.pvtlvl1 td {
    background-color: var(--pvt-lvl1-bg) !important;
    color: var(--pvt-lvl1-txt) !important;
    border-top: 1px solid var(--border-strong);
}

table.pivot th.text,
table.pivot td.text { 
  text-align: left !important; 
}

/* Custom column classes */
.mono-font {
    font-family: "Courier New", Courier, monospace;
    font-weight: bold;
}

/* --- Summenspalten Farben --- */
/* Prinzip: Gesamt (ttl_line/ttl_share) dunkelst → clevel0 → clevel1 → clevel2 hellst */

/* A) BODY-Zellen (td) — volle Spaltenfarbe */

table.pivot td.ttl_line {
    background-color: var(--pvt-col-total) !important;
    color: var(--text-main) !important;
    border-left: 2px solid var(--pvt-border-strong) !important;
    font-weight: bold;
}
table.pivot td.ttl_share {
    background-color: var(--pvt-col-total) !important;
    color: var(--text-main) !important;
    font-weight: bold;
}
table.pivot td.ttl_col.clevel0 {
    background-color: var(--pvt-col-0-bg) !important;
    color: var(--text-main) !important;
    border-left: 2px solid var(--pvt-border-strong) !important;
    font-weight: bold;
}
table.pivot td.ttl_col.clevel1 {
    background-color: var(--pvt-col-1-bg) !important;
    color: var(--text-main) !important;
    border-left: 1px solid var(--border-strong) !important;
    font-weight: 600;
}
table.pivot td.ttl_col.clevel2 {
    background-color: var(--pvt-col-2-bg) !important;
    color: var(--text-main) !important;
    border-left: 1px solid var(--border-color) !important;
    font-weight: normal;
}

/* B) HEADER-Zellen (thead th) — Header-Farbe bleibt, Spaltenfarbe als Overlay */
/* box-shadow inset mischt die Spaltenfarbe halbtransparent über die Header-Farbe */

table.pivot thead th.ttl_line {
    background-color: var(--pvt-header-bg) !important;
    color: var(--pvt-header-txt) !important;
    box-shadow: inset 0 0 0 9999px var(--pvt-col-total-overlay) !important;
    border-left: 2px solid var(--pvt-border-strong) !important;
}
table.pivot thead th.ttl_share {
    background-color: var(--pvt-header-bg) !important;
    color: var(--pvt-header-txt) !important;
    box-shadow: inset 0 0 0 9999px var(--pvt-col-total-overlay) !important;
}
table.pivot thead th.ttl_col.clevel0 {
    background-color: var(--pvt-header-bg) !important;
    color: var(--pvt-header-txt) !important;
    box-shadow: inset 0 0 0 9999px var(--pvt-col-0-overlay) !important;
    border-left: 2px solid var(--pvt-border-strong) !important;
}
table.pivot thead th.ttl_col.clevel1 {
    background-color: var(--pvt-header-bg) !important;
    color: var(--pvt-header-txt) !important;
    box-shadow: inset 0 0 0 9999px var(--pvt-col-1-overlay) !important;
    border-left: 1px solid var(--border-strong) !important;
}
table.pivot thead th.ttl_col.clevel2 {
    background-color: var(--pvt-header-bg) !important;
    color: var(--pvt-header-txt) !important;
    box-shadow: inset 0 0 0 9999px var(--pvt-col-2-overlay) !important;
    border-left: 1px solid var(--border-color) !important;
}

/* Tree Padding & Alignment */
table.pivot tr.pvtlvl2 th.tree { padding-left: 20px !important; }
table.pivot tr.pvtlvl3 th.tree { padding-left: 35px !important; }
table.pivot tr.pvtlvl4 th.tree { padding-left: 50px !important; }
table.pivot td { text-align: right; }
table.pivot th.text { text-align: left; }

/* Zebra Striping – Klassen statt :nth-child (verhindert O(n²) Selector-Matching beim Sortieren) */
table.pivot tr.tr-even td { background-color: var(--pvt-bg-even); }
table.pivot tr.tr-odd  td { background-color: var(--pvt-bg-odd); }

/* Details Spalten (Normalisierung) */
th.pivot-tree-details, td.pivot-tree-details {
    font-weight: normal; position: static; /* Scrollt mit */
}

/* 9. INTERAKTION & DETAILS TOGGLE */

/* Hover */
.pivot_over { background-color: var(--pvt-hover) !important; cursor: crosshair; }

/* Selection */
table.pivot tr.pivot_marked th,
table.pivot tr.pivot_marked td {
    background-color: var(--pvt-marked) !important;
    color: var(--pvt-marked-txt) !important;
}
/* Cross-Hover Highlight */
table.pivot td.pivot_over, table.pivot th.pivot_over {
    background-color: var(--pvt-marked) !important;
    color: var(--pvt-marked-txt) !important;
    position: relative; z-index: 2000 !important; /* Über Sticky Header */
    outline: 1px solid rgba(0,0,0,0.1); outline-offset: -1px;
}

/* DETAILS AUSBLENDEN (FIX: !important zwingend erforderlich) */
.pivot-tree-hide {
    display: none !important; 
    visibility: collapse !important;
}

/* 10. ICONS (SVG Data URI + Click Fix) */
span.pivot-collapse {
    width: 14px; height: 14px; display: inline-block; margin-right: 8px;
    vertical-align: middle;
    cursor: pointer; 
    
    /* FIX: Hoher Z-Index damit Klick funktioniert */
    position: relative; 
    z-index: 2005 !important; 
    
    background-size: contain; background-repeat: no-repeat; background-position: center;
    opacity: 0.7; transition: opacity 0.2s;
}
span.pivot-collapse:hover { opacity: 1; transform: scale(1.1); }

.pivot-collapse-minus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");
}
.pivot-collapse-plus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'%3E%3C/line%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");
}
/* Dark Mode Invertierung */
[data-theme="dark"] .pivot-collapse-minus, [data-theme="dark"] .pivot-collapse-plus { filter: invert(1); }

/* 11. POPOVER & PANEL (Fixed Positioning) */
.app-popover, .pivot-popover-panel {
    display: none;
    position: fixed; /* Fix: Panel bleibt am Viewport */
    z-index: 9000;
    
    background-color: var(--bg-panel);
    border: 1px solid var(--border-strong);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    border-radius: 8px;
    min-width: 300px; max-width: 450px;
    
    opacity: 0; transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.app-popover.visible, .app-popover.show { opacity: 1; transform: translateY(0); }

.popover-header {
    padding: 10px 15px; font-weight: 600; 
    border-bottom: 1px solid var(--border-color); background: var(--bg-app);
    display: flex; justify-content: space-between; align-items: center;
}
.popover-body { padding: 15px; max-height: 60vh; overflow-y: auto; }
.popover-footer {
    padding: 10px 15px; border-top: 1px solid var(--border-color);
    text-align: right; background: var(--bg-app);
}

/* Form Elements im Popover */
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
}
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; color: var(--text-muted); }
.form-control, input.pivot_input_filter {
    width: 100%; box-sizing: border-box; padding: 6px;
    border: 1px solid var(--border-color); border-radius: 3px;
    background-color: var(--bg-app); color: var(--text-main);
}

/* 12. DROPDOWN MENÜS (Report Switcher) */
/* =========================================
   12. FILTER ZEILE (UNIFORMITY FIX)
   ========================================= */

/* A) Container für MultiSelect auf 100% zwingen */
.pivot-filter-row .ms-options-wrap {
    width: 100% !important;
    height: 100% !important;
    display: block !important; 

}
table.pivot tr.pivot-filter-row th {
    padding: 0px;
}

/* B) DIE "GLEICHMACHUNG" (Input, Select & MultiSelect Button) */
.pivot-filter-row input.pivot_input_filter,
.pivot-filter-row select.pivot_input_filter,
.pivot-filter-row .ms-options-wrap > button {
    /* 1. Layout & Größe */
    width: 100% !important;
    height: 100% !important;
    min-height: 26px !important; /* Fixe Höhe für alle */
    max-height: 26px !important; 
    
    display: block ; /* FIX: Fill cell width */
    box-sizing: border-box !important;
    
    /* 2. Reset der Optik (Rahmen weg, Zellen-Rahmen nutzen) */
    background-color: var(--bg-app) !important;
    color: var(--text-main) !important;
    border: none !important; 
    border-radius: 0 !important;
    box-shadow: none !important;
    
    /* 3. Typografie & Ausrichtung */
    padding: 0 6px !important;   /* Einheitlicher Innenabstand */
    font-size: 0.9em !important;
    line-height: 26px !important; /* Vertikal zentrieren */
    font-family: inherit !important;
    text-align: left !important;
}

/* C) Speziell für den MultiSelect Button (Flexbox für Text + Pfeil) */
.pivot-filter-row .ms-options-wrap > button {
    display: flex !important;
/*    align-items: center !important; */
    justify-content: space-between !important; /* Text links, Pfeil rechts */
}
/* Den Text im Button beschneiden, falls zu lang */
.pivot-filter-row .ms-options-wrap > button > span {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* D) Fokus Effekt (Blauer Rahmen INNEN) */
.pivot-filter-row input.pivot_input_filter:focus,
.pivot-filter-row select.pivot_input_filter:focus,
.pivot-filter-row .ms-options-wrap > button:focus,
.pivot-filter-row .ms-options-wrap.ms-active > button {
    outline: none !important;
    box-shadow: inset 0 0 0 2px #3b82f6 !important; /* Fokus sichtbar machen */
    background-color: var(--bg-app) !important;
    z-index: 2; /* Damit der Rahmen über Nachbarn liegt */
}

/* E) Dropdown Menüs (Styling) */
.pivot-dropdown-menu, .ms-options {
    position: absolute; top: 100%; left: 0; z-index: 1001 !important;
    min-width: 220px; background: var(--bg-panel) !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px; padding: 5px 0;
}

/* Links im Menü */
.pivot-dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 15px; color: var(--text-main);
    text-decoration: none; font-size: 0.95em;
}
.pivot-menu-icon { flex: 0 0 18px; width: 18px; height: 18px; opacity: 0.6; }
.pivot-menu-icon svg { width: 100%; height: 100%; }
.pivot-dropdown-trigger .pivot-menu-icon { width: 16px; height: 16px; flex-basis: 16px; vertical-align: middle; display: inline-flex; margin-right: 5px; }
.pivot-dropdown-trigger .pivot-menu-icon svg { width: 16px; height: 16px; }
.pivot-dropdown-item:hover, .pivot-dropdown-item.active { 
    background-color: var(--pvt-lvl1-bg); 
}

/* MultiSelect Checkbox-Liste Styles */
.ms-options ul { list-style: none; padding: 0; margin: 0; }
.ms-options li { padding: 4px 8px; cursor: pointer; }
.ms-options li:hover { background-color: var(--pvt-lvl1-bg); }
.ms-options label { display: block; width: 100%; cursor: pointer; color: var(--text-main); }
.ms-selectall { color: var(--btn-primary-bg) !important; padding: 5px 10px; display: block; font-weight: bold; text-decoration: none; border-bottom: 1px solid var(--border-color); }

/* Suchfeld im MultiSelect */
.ms-search input {
    width: 96% !important; margin: 2% !important;
    border: 1px solid var(--border-color) !important;
}

/* Dashboard */
.dashboard-container { max-width: 900px; margin: 0 auto; padding: 20px; font-size: 1rem; }
.dashboard-section { margin-bottom: 30px; }
.dashboard-section h2 { font-size: 1.25rem; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.dashboard-section p { font-size: 0.95rem; line-height: 1.6; color: var(--text-muted); padding: 0; }
.dashboard-reports { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.dashboard-report-card {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px; border: 1px solid var(--border-color); border-radius: 6px;
    text-decoration: none; color: var(--text-main); transition: all 0.15s ease-in-out;
}
.dashboard-report-card:hover {
    border-color: var(--border-strong); background: var(--bg-panel);
    transform: translateY(-2px); box-shadow: 0 2px 8px rgba(59,130,246,0.12);
}
.dashboard-card-icon { flex-shrink: 0; width: 36px; height: 36px; color: var(--text-muted); }
.dashboard-card-icon svg { width: 100%; height: 100%; }
.dashboard-report-card:hover .dashboard-card-icon { color: var(--text-main); }
.dashboard-card-text h3 { font-size: 1.05rem; margin: 0 0 4px 0; }
.dashboard-card-text p { font-size: 0.9rem; margin: 0; color: var(--text-muted); padding: 0; }

/* Filter Tooltip */
.pivot-filter-tooltip {
    position: absolute; display: none; background-color: var(--bg-panel); color: var(--text-main);
    border: 1px solid var(--border-strong); box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    padding: 10px; border-radius: 4px; font-size: 0.85em; z-index: 10000;
    min-width: 150px; line-height: 1.4em; pointer-events: none;
}
.pivot-filter-tooltip strong { display: block; margin-bottom: 5px; border-bottom: 1px solid var(--border-color); }
.pivot-filter-tooltip code { background: var(--bg-panel); padding: 0 4px; border-radius: 2px; font-family: monospace; font-weight: bold; }

/* 13. HEATMAP */
table.pivot.show-heatmap {
  --heat-bull: 34, 197, 94;
  --heat-bear: 239, 68, 68;
  --heat-bull-solid: #22c55e;
  --heat-bear-solid: #ef4444;
}
table.pivot.show-heatmap.heatmap-cb {
  --heat-bull: 59, 130, 246;
  --heat-bear: 249, 115, 22;
  --heat-bull-solid: #3b82f6;
  --heat-bear-solid: #f97316;
}
table.pivot.show-heatmap .heat-bull-1 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.1) !important; }
table.pivot.show-heatmap .heat-bull-2 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.2) !important; }
table.pivot.show-heatmap .heat-bull-3 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.3) !important; }
table.pivot.show-heatmap .heat-bull-4 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.4) !important; }
table.pivot.show-heatmap .heat-bull-5 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.5) !important; color:#fff!important; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
table.pivot.show-heatmap .heat-bull-6 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.6) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bull-7 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.7) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bull-8 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.8) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bull-9 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 0.9) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bull-10{ box-shadow: inset 0 0 0 9999px rgba(var(--heat-bull), 1.0) !important; color:#fff!important; }

table.pivot.show-heatmap .heat-bear-1 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.1) !important; }
table.pivot.show-heatmap .heat-bear-2 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.2) !important; }
table.pivot.show-heatmap .heat-bear-3 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.3) !important; }
table.pivot.show-heatmap .heat-bear-4 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.4) !important; }
table.pivot.show-heatmap .heat-bear-5 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.5) !important; color:#fff!important; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
table.pivot.show-heatmap .heat-bear-6 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.6) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bear-7 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.7) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bear-8 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.8) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bear-9 { box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 0.9) !important; color:#fff!important; }
table.pivot.show-heatmap .heat-bear-10{ box-shadow: inset 0 0 0 9999px rgba(var(--heat-bear), 1.0) !important; color:#fff!important; }

/* Tree Mini-Bars */
table.pivot td.tree { padding-right: 8px; position: relative; }
.mini-heat-bar {
  position: absolute; top: 4px; bottom: 4px; right: 0; display: flex; gap: 1px; z-index: 10; pointer-events: none;
}
.mini-heat-bar i { width: 4px; height: 100%; display: block; border-radius: 1px; }
.mini-heat-bar .heat-bull-10 { background-color: var(--heat-bull-solid, #22c55e); }
.mini-heat-bar .heat-bear-10 { background-color: var(--heat-bear-solid, #ef4444); }

.heat-sort-icons {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    pointer-events: auto;
    z-index: 11;
}
.heat-sort-icon,
.heat-trend-icon {
    cursor: pointer;
    opacity: 0.45;
    font-size: 13px;
    pointer-events: auto;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.heat-sort-icon:hover,
.heat-trend-icon:hover {
    opacity: 1;
}
.heat-sort-icon.active,
.heat-trend-icon.active {
    opacity: 1;
}
.heat-sort-icon .sort-dir,
.heat-trend-icon .sort-dir {
    font-size: 10px;
    margin-left: 1px;
}

.ms-options-wrap.ms-active > .ms-options {
    visibility: visible;
    text-align: left;
    font-weight: normal;
}

/* =========================================
   12b. MULTISELECT DROPDOWN LISTE (FIXED)
   ========================================= */

/* Der Container der Liste */
.ms-options { 
    /* WICHTIG: Scrollbar X töten */
    overflow-x: hidden !important;
    overflow-y: auto !important; /* Vertikal scrollen erlaubt */
    
    /* Layout */
    position: absolute; top: 100%; left: 0; z-index: 1001 !important;
    min-width: 220px; max-width: 400px; /* Begrenzte Breite verhindert Riesen-Menüs */
    
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px; 
    padding: 5px 0;
    margin-top: 1px;
}

/* Die Liste selbst */
.ms-options ul { 
    list-style: none !important; 
    padding: 0 !important; 
    margin: 0 !important; 
}

/* Das einzelne Item (Zeile) */
.ms-options li { 
    padding: 4px 8px !important; 
    cursor: pointer; 
    margin: 0 !important;
    list-style: none !important;
}

.ms-options li:hover { 
    background-color: var(--pvt-lvl1-bg) !important; 
}

/* Das Label (Text + Checkbox) - Hier passiert der Fix für den Scrollbalken */
.ms-options li label { 
    display: block !important; 
    width: 100% !important; 
    cursor: pointer; 
    color: var(--text-main) !important;
    
    /* TEXT ABSCHNEIDEN statt Scrollbalken */
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    
    /* Sicherstellen, dass Input und Text sauber ausgerichtet sind */
    line-height: 1.1
}

/* Checkbox im Dropdown etwas Abstand geben */
.ms-options li label input {
    margin-right: 6px !important;
    vertical-align: middle;
}

/* Select All Link */
.ms-selectall { 
    color: var(--btn-primary-bg) !important; 
    padding: 5px 10px; 
    display: block; 
    font-weight: bold; 
    text-decoration: none; 
    border-bottom: 1px solid var(--border-color); 
    font-size: 0.9em;
}
.ms-selectall:hover {
    text-decoration: underline;
}

/* Suchfeld im MultiSelect (falls aktiviert) */
.ms-search input {
    width: 94% !important; 
    margin: 4px 3% !important; /* Zentriert mit Abstand */
    box-sizing: border-box !important;
    border: 1px solid var(--border-color) !important;
    padding: 4px !important;
}


/* =========================================
   FIX: Nobleclem MultiSelect Overflow
   ========================================= */

/* 1. Den Wrapper als Anker setzen */
.pivot-filter-row .ms-options-wrap,
.ms-options-wrap {
    position: relative !important;
    z-index: 1005; /* Muss höher sein als die Zeile */
    overflow: visible !important; /* WICHTIG: Darf Inhalt nicht verstecken */
}

/* 2. Die Liste selbst: Aus dem Container lösen */
.pivot-filter-row .ms-options-wrap > .ms-options,
.ms-options-wrap > .ms-options {
    position: absolute !important; 
    z-index: 99999 !important; /* Ganz nach oben über alle Modals/Dropdowns */
    
    /* Falls es immer noch abgeschnitten wird, nutze diesen "Notfall-Hack":
       position: fixed !important; 
       (Achtung: 'fixed' bewegt sich nicht mit, wenn man scrollt, 
       funktioniert aber garantiert gegen Abschneiden) */
       
    margin-top: 1px !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
    
    /* Scrollbar innerhalb der Liste erzwingen */
    max-height: 300px !important; 
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* 14. DYNAMIC GLOBAL FILTER PANEL LAYOUT */
#panel-global-filter.app-popover {
    min-width: 300px;
    max-width: 90vw;
    width: auto;
}

#panel-global-filter .popover-body {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between rows */
}

.form-row {
    display: flex;
    flex-direction: row;
    gap: 15px; /* Space between items in a row */
    flex-wrap: wrap;
}

/* Default sizing for items in a form row */
.form-row > * {
    flex-grow: 1;
    flex-basis: 0;
    min-width: 150px;
}

/* Width helper classes */
.form-row > .w-100 {
    flex-grow: 1;
    flex-basis: 100%;
}

.form-row > .w-75 {
    flex-grow: 1;
    flex-basis: calc(75% - 7.5px);
}

.form-row > .w-50 {
    flex-grow: 1;
    flex-basis: calc(50% - 7.5px);
}

.form-row > .w-33 {
    flex-grow: 1;
    flex-basis: calc(33.333% - 10px);
}

.form-row > .w-25 {
    flex-grow: 1;
    flex-basis: calc(25% - 11.25px);
}

/* Flexibles Baukasten-System für das Beschreibungs-Layout */
.desc-wrapper {
    display: flex;
    flex-direction: column; /* Stapelt die Reihen (.desc-row) untereinander */
    gap: 10px; /* Abstand zwischen den Reihen */
    width: 100%;
    padding: 0 16px;
}
.desc-row {
    display: flex;
    flex-direction: row; /* Ordnet die Spalten (.desc-col) nebeneinander an */
    flex-wrap: wrap;
    gap: 15px; /* Abstand zwischen den Spalten */
    align-items: stretch; /* Alle Spalten in einer Reihe haben die gleiche Höhe */
}
.desc-col {
    flex-grow: 1; /* Standard: Spalten teilen sich den Platz */
    flex-basis: 0;
    min-width: 200px;
}
.desc-col h4 {
    margin: 0 0 4px 0;
    font-size: 0.875rem;
    font-weight: 600;
}
.desc-col p {
    margin: 0;
    font-size: 0.90rem;
    line-height: 1.4;
}
.insight {
    font-size: 0.90rem;
    padding: 6px 10px;
    background-color: rgba(59, 130, 246, 0.05);
    border-left: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 0 4px 4px 0;
    height: 100%;
}
[data-theme="dark"] .insight {
    background-color: rgba(96, 165, 250, 0.08);
    border-left-color: rgba(96, 165, 250, 0.3);
}
.desc-chart-container {
    height: 140px;
    background-color: var(--bg-app);
    border-radius: 4px;
    padding: 5px;
    width: 100%;
}
/* Helferklassen für Spaltenbreite */
.desc-col.col-100 { flex-basis: 100%; flex-grow: 0; }
.desc-col.col-50 { flex-basis: calc(50% - 7.5px); flex-grow: 0; }
.desc-col.col-33 { flex-basis: calc(33.333% - 10px); flex-grow: 0; }

/* =========================================
   15. DETAIL-SEITEN (ReportDetail)
   ========================================= */
.detail-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 16px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.detail-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.detail-card-title {
    margin: 0;
    padding: 10px 16px;
    font-size: 0.9375rem;
    font-weight: 700;
    background: var(--pvt-header-bg);
    color: var(--pvt-header-txt);
    border-bottom: 1px solid var(--border-strong);
}

.detail-card-body {
    padding: 0;
    overflow-x: auto;
}

/* Key-Value Tabelle (Stammdaten) */
.detail-kv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.detail-kv-table th {
    text-align: left;
    padding: 8px 16px;
    width: 180px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.detail-kv-table td {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

/* Einfache Datentabellen in Detail-Karten */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.90rem;
    white-space: nowrap;
}
.detail-table thead th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    background: var(--pvt-lvl1-bg);
    color: var(--pvt-lvl1-txt);
    border-bottom: 1px solid var(--border-strong);
    position: sticky;
    top: 0;
}
.detail-table tbody td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}
.detail-table tbody tr:nth-child(even) td {
    background-color: var(--pvt-bg-even);
}
.detail-table tbody tr:nth-child(odd) td {
    background-color: var(--pvt-bg-odd);
}
.detail-table tbody tr:hover td {
    background-color: var(--pvt-hover);
}

/* Links in Pivot-Tabellen */
table.pivot a {
    color: inherit;
    text-decoration: none;
}
table.pivot a::after {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-left: 5px;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.4;
}
table.pivot a:hover::after {
    opacity: 0.8;
}

/* Links in Detail-Tabellen */
.detail-table a, .detail-kv-table a {
    color: inherit;
    text-decoration: none;
}
.detail-table a::after, .detail-kv-table a::after {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-left: 5px;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.4;
}
.detail-table a:hover::after, .detail-kv-table a:hover::after {
    opacity: 0.8;
}

/* Button Spinner (inline im Button-Text) */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* PAGE LOADING OVERLAY */
.page-loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
}
.page-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--btn-primary-bg);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   AUTH / USERMANAGEMENT STYLES
   ========================================================================== */

/* ── Guest Layout ────────────────────────────────────────────────────────── */
.app-shell--guest {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-panel);
}
.app-shell--guest .app-header {
  position: static;
  text-align: center;
  border: none;
  background: transparent;
  padding: 24px 0 0;
}
.app-workspace--guest {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  padding: 24px;
}

/* ── Auth Card ───────────────────────────────────────────────────────────── */
.auth-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-card-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
  color: var(--text-main);
}
.auth-subtitle {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Auth Form ───────────────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
.auth-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.90rem;
  font-weight: 600;
  color: var(--text-main);
}
.auth-field--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-field-row {
  display: flex;
  gap: 12px;
}
.auth-field-row .auth-field {
  flex: 1;
}
.auth-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-app);
  color: var(--text-main);
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.auth-input:focus {
  outline: none;
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.90rem;
  color: var(--text-main);
}

/* ── Auth Buttons ────────────────────────────────────────────────────────── */
.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.auth-btn:hover {
  border-color: var(--border-strong);
}
.auth-btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.auth-btn--primary:hover {
  background: var(--btn-primary-hover);
}
.auth-btn--danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.auth-btn--danger:hover {
  background: #dc2626;
}
.auth-btn--sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}
.auth-btn--small {
  padding: 4px 12px;
  font-size: 0.8rem;
}

/* ── OAuth Buttons ───────────────────────────────────────────────────────── */
.auth-btn--oauth {
  width: 100%;
  padding: 10px 16px;
  margin-top: 8px;
  background: #fff;
  color: #374151;
  border: 1px solid var(--border-color, #d1d5db);
  text-decoration: none;
  font-weight: 500;
}
.auth-btn--oauth:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}
.auth-btn--google {
  border-left: 3px solid #4285f4;
}
.auth-btn--microsoft {
  border-left: 3px solid #00a4ef;
}
.auth-divider {
  display: flex;
  align-items: center;
  margin: 16px 0 8px;
  color: #9ca3af;
  font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color, #e5e7eb);
}
.auth-divider span {
  padding: 0 12px;
}

/* ── OAuth Provider Profil ───────────────────────────────────────────────── */
.oauth-provider-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.oauth-provider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.oauth-provider-row:last-child {
  border-bottom: none;
}
.oauth-provider-label {
  font-weight: 600;
  min-width: 80px;
}

/* ── Auth Alerts ─────────────────────────────────────────────────────────── */
.auth-alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.auth-alert ul {
  margin: 0;
  padding-left: 18px;
}
.auth-alert--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.auth-alert--success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
[data-theme="dark"] .auth-alert--error {
  background: #2a1215;
  color: #fca5a5;
  border-color: #7f1d1d;
}
[data-theme="dark"] .auth-alert--success {
  background: #0f2417;
  color: #86efac;
  border-color: #14532d;
}

/* ── Auth Badges ─────────────────────────────────────────────────────────── */
.auth-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 10px;
  vertical-align: middle;
}
.auth-badge--success {
  background: #dcfce7;
  color: #166534;
}
.auth-badge--warning {
  background: #fef9c3;
  color: #854d0e;
}
.auth-badge--danger {
  background: #fee2e2;
  color: #991b1b;
}
.auth-badge--info {
  background: #dbeafe;
  color: #1e40af;
}
[data-theme="dark"] .auth-badge--success { background: #14532d; color: #86efac; }
[data-theme="dark"] .auth-badge--warning { background: #422006; color: #fde047; }
[data-theme="dark"] .auth-badge--danger  { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .auth-badge--info    { background: #1e3a5f; color: #93c5fd; }

/* ── Auth Footer / Links ─────────────────────────────────────────────────── */
.auth-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 0.90rem;
  color: var(--text-muted);
}
.auth-link {
  color: var(--btn-primary-bg);
  text-decoration: none;
  font-weight: 500;
}
.auth-link:hover {
  text-decoration: underline;
}

/* ── Auth Table ──────────────────────────────────────────────────────────── */
.auth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.90rem;
}
.auth-table th,
.auth-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.auth-table th {
  background: var(--bg-panel);
  font-weight: 600;
  color: var(--text-main);
  position: sticky;
  top: 0;
  z-index: 1;
}
.auth-table tbody tr:hover {
  background: var(--pvt-hover);
}
.user-alert-detail td {
  padding: 4px 12px 12px;
  background: var(--bg-panel);
}
.user-alert-detail .auth-table {
  font-size: 0.8rem;
}
.user-alert-detail .auth-table th {
  position: static;
}
.admin-filter-advanced {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-filter-advanced.hidden {
  display: none;
}

/* ── Profile Grid ────────────────────────────────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
  padding: 24px;
}
.profile-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.profile-card .auth-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.profile-card .auth-form > button:last-child {
  margin-top: auto;
}
.profile-card h3 {
  margin: 0 0 16px;
  color: var(--text-main);
}
.profile-card--wide {
  grid-column: 1 / -1;
}

/* ── Admin Container ─────────────────────────────────────────────────────── */
.admin-container {
  padding: 24px;
}
.admin-toolbar {
  margin-bottom: 16px;
}
.admin-search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}
.admin-pagination {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ── User Menu Dropdown ──────────────────────────────────────────────────── */
.user-menu-container {
  position: relative;
  z-index: 1010; /* Ensures this stacking context is above other toolbar items */
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-menu-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-dropdown {
  position: fixed;
  min-width: 200px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 10001;
  padding: 4px 0;
}
.user-menu-icon {
  display: inline-flex;
  align-items: center;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  flex-shrink: 0;
}
.user-menu-icon svg {
  width: 16px;
  height: 16px;
}
.user-menu-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.90rem;
  transition: background 0.1s;
}
.user-menu-item:hover {
  background: var(--pvt-hover);
}
.user-menu-item--danger {
  color: #ef4444;
}
.user-menu-item--primary {
  color: #2563eb;
  font-weight: 600;
}
.user-menu-sep {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* ── Gast-Banner ────────────────────────────────────────────────────────── */
.guest-banner-container {
  position: relative;
}
.guest-banner-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  cursor: pointer;
  padding: 4px 14px;
  border-radius: 6px;
  border: none;
  background: var(--btn-primary-bg, #2563eb);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.guest-banner-tab:hover {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.guest-banner-tab::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  animation: shiny-sweep 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shiny-sweep {
  0%   { left: -100%; }
  50%  { left: 150%; }
  100% { left: 150%; }
}
.guest-banner-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 9000;
  padding: 12px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.guest-banner-dropdown.visible {
  display: block !important;
  opacity: 1;
  transform: translateY(0);
}
.guest-banner-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.guest-banner-actions {
  display: flex;
  gap: 8px;
}
.guest-banner-actions .app-btn {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
}

/* ── Site-Toggle (Einstellungsseite) ────────────────────────────────────── */
.site-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.site-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.site-toggle__slider {
  position: absolute;
  inset: 0;
  background: var(--border-color, #cbd5e1);
  border-radius: 22px;
  transition: background 0.2s;
}
.site-toggle__slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.site-toggle input:checked + .site-toggle__slider {
  background: var(--btn-primary-bg, #2563eb);
}
.site-toggle input:checked + .site-toggle__slider::before {
  transform: translateX(18px);
}

/* ── Audit Details ───────────────────────────────────────────────────────── */
.audit-details {
  font-size: 0.75rem;
  max-width: 300px;
  max-height: 80px;
  overflow: auto;
  margin: 0;
  background: var(--bg-panel);
  padding: 4px 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stats-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stats-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--btn-primary-bg);
}
.stats-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Permission Matrix ───────────────────────────────────────────────────── */
.perm-matrix-wrapper {
  overflow-x: auto;
}
.perm-matrix .perm-matrix-category td {
  background: var(--bg-panel);
  font-size: 0.90rem;
  padding: 6px 12px;
}
.perm-matrix .perm-matrix-cell {
  text-align: center;
}
.perm-matrix .perm-matrix-role {
  text-align: center;
  min-width: 100px;
}

/* ── Roles List ──────────────────────────────────────────────────────────── */
.roles-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.role-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-panel);
}

/* ── Door Page (Guest Landingpage) ─────────────────────────────────────── */
.app-shell--door {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-app);
}
.app-workspace--door {
  flex: 1;
  width: 100%;
  padding: 0;
}
.door-page {
  width: 100%;
}

/* ── Door Nav ──────────────────────────────────────────────────────────── */
.door-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-color);
}
.door-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px;
}
.door-nav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}
.door-nav__logo {
  width: 24px;
  height: 24px;
  stroke: var(--btn-primary-bg);
}
.door-nav__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Door Buttons ──────────────────────────────────────────────────────── */
.door-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  border: none;
  line-height: 1.4;
}
.door-btn svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}
.door-btn--try svg {
  width: 1.2em;
  height: 1.2em;
  animation: door-pulse 2s ease-in-out infinite;
}
@keyframes door-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}
.door-btn--primary,
.door-btn--primary:visited {
  background: var(--btn-primary-bg);
  color: #fff;
}
.door-btn--primary:hover {
  background: var(--btn-primary-hover);
  color: #fff;
}
.door-btn--outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.door-btn--outline:hover {
  background: var(--bg-panel);
}
.door-btn--lg {
  padding: 12px 32px;
  font-size: 1rem;
}

/* ── Door Hero ─────────────────────────────────────────────────────────── */
.door-hero {
  text-align: center;
  padding: 80px 24px 64px;
  max-width: 720px;
  margin: 0 auto;
}
.door-hero__title {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-main);
  margin: 0 0 20px;
  letter-spacing: -0.02em;
}
.door-hero__subtitle {
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 32px;
}

/* ── Door Features ─────────────────────────────────────────────────────── */
.door-features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 64px;
}
.door-features__heading {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 40px;
}
.door-features__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
@media (max-width: 768px) {
  .door-features__grid {
    grid-template-columns: 1fr;
  }
  .door-hero__title {
    font-size: 1.8rem;
  }
  .door-hero {
    padding: 48px 16px 40px;
  }
}

/* ── Door Feature Card ─────────────────────────────────────────────────── */
.door-feature-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-app);
  transition: box-shadow 0.2s, transform 0.2s;
}
.door-feature-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}
.door-feature-card__preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 200px;
  background: #f0f4f8;
  border-bottom: 1px solid var(--border-color);
}
[data-theme="dark"] .door-feature-card__preview {
  background: #1a1f2e;
}
.door-feature-card__icon {
  width: 48px;
  height: 48px;
  color: var(--btn-primary-bg);
}
.door-feature-card__icon svg {
  width: 100%;
  height: 100%;
}
.door-feature-card__label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.door-feature-card__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 16px 16px 6px;
}
.door-feature-card__desc {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0 16px 16px;
}

/* ── Door CTA ──────────────────────────────────────────────────────────── */
.door-cta {
  text-align: center;
  padding: 64px 24px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
}
.door-cta__title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 12px;
}
.door-cta__text {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0 0 28px;
}
.door-cta__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Door Footer ───────────────────────────────────────────────────────── */
.door-footer {
  text-align: center;
  padding: 20px 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

/* AGB-Seite: Guest-Layout Override – kein Zentrieren, normaler Scroll */
.app-shell--guest:has(.agb-wrapper) {
  justify-content: flex-start;
}
.app-workspace--guest:has(.agb-wrapper) {
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
}
.agb-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.agb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}
.agb-logo-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.agb-logo-text {
  display: flex;
  flex-direction: column;
}
.agb-logo-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}
.agb-logo-company {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.agb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0;
}
.agb-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.agb-btn:hover {
  color: var(--text-main);
}
.agb-tabs {
  display: flex;
  gap: 4px;
}
.agb-tab {
  padding: 8px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}
.agb-tab:hover {
  color: var(--text-main);
}
.agb-tab--active {
  color: var(--text-main);
  border-bottom-color: var(--accent, #3b82f6);
  font-weight: 600;
}
.agb-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-main);
}
.agb-content h3 {
  font-size: 1.4em;
  margin: 0 0 16px;
}
.agb-content p {
  margin: 0 0 12px;
  font-size: 15px;
  padding: 0;
  color: var(--text-main);
}
.agb-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 24px 0;
}
.agb-content strong {
  color: var(--text-main);
}
.agb-content a {
  color: var(--accent, #3b82f6);
  text-decoration: underline;
}

/* AGB Druckansicht */
@media print {
  html, body {
    height: auto !important;
    width: auto !important;
    overflow: visible !important;
    font-size: 9pt !important;
    background: white !important;
    color: black !important;
  }
  body {
    display: block !important;
  }
  .app-shell,
  .app-shell--guest {
    display: block !important;
    height: auto !important;
    width: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: white !important;
  }
  .app-workspace,
  .app-workspace--guest {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .app-header,
  .agb-toolbar {
    display: none !important;
  }
  .agb-logo {
    border-bottom: 1px solid #ccc !important;
  }
  .agb-logo-name {
    color: black !important;
  }
  .agb-logo-company {
    color: #555 !important;
  }
  .agb-wrapper {
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: white !important;
  }
  .agb-content {
    font-size: 9pt !important;
    line-height: 1.5 !important;
    color: black !important;
  }
  .agb-content p {
    font-size: 9pt !important;
    padding: 0 !important;
    color: black !important;
  }
  .agb-content h3 {
    font-size: 11pt !important;
    color: black !important;
  }
  .agb-content strong {
    color: black !important;
  }
  .agb-content hr {
    border-top: 1px solid #ccc !important;
  }
  .agb-content a {
    color: black !important;
    text-decoration: none !important;
  }
  .agb-content a::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }
  .agb-content[style*="display:none"] {
    display: block !important;
    page-break-before: always;
  }
}

/* ==========================================================================
   WATCHLIST COMPONENTS
   ========================================================================== */

/* Dropdown auf StockDetail */
.wl-dropdown-container { position: relative; display: inline-block; }
.wl-dropdown-menu {
  background: var(--bg-app, #fff);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 220px;
  z-index: 1000;
}
.wl-dropdown-list { max-height: 240px; overflow-y: auto; padding: 4px 8px; }
.wl-dropdown-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-main);
}
.wl-dropdown-label:hover { background: var(--bg-panel, #f5f7fa); }
.wl-dropdown-label input[type="checkbox"] { width: 15px; height: 15px; }
.wl-dropdown-empty { color: var(--text-muted); font-size: 13px; padding: 8px 4px; }

/* Notiz-Elemente in Pivot-Tabelle */
.wl-note-text { color: var(--text-muted); font-size: 12px; }
.wl-note-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 1px 6px;
}
.wl-note-btn:hover { background: var(--bg-panel); color: var(--text-main); }

/* Drag-Handle für Sortierung */
.wl-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  padding: 0 6px;
  font-size: 14px;
  user-select: none;
}
.wl-drag-handle:active { cursor: grabbing; }

/* Checkbox für Bulk-Entfernen */
.wl-stock-checkbox { width: 15px; height: 15px; cursor: pointer; }

/* Select in Toolbar */
.app-select {
  padding: 4px 8px;
  border: 1px solid var(--btn-border, #cbd5e1);
  border-radius: 4px;
  background: var(--btn-bg, #fff);
  color: var(--btn-text, #1a1a2e);
  font-size: 13px;
  cursor: pointer;
}

/* ── Toast-Benachrichtigungen ─────────────────────────────────────── */
.app-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  max-width: 400px;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  opacity: 0;
  transform: translateX(40px);
  transition: opacity .3s, transform .3s;
  pointer-events: auto;
}
.app-toast-visible {
  opacity: 1;
  transform: translateX(0);
}
.app-toast-error {
  background: #dc2626;
  color: #fff;
}

/* ── Confirm-Dialog (Ersatz für native confirm()) ──────────────── */
.app-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: app-confirm-fadein .15s ease;
}
.app-confirm-overlay.app-confirm--closing {
  opacity: 0;
  transition: opacity .15s ease;
}
.app-confirm-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  padding: 20px 24px;
  min-width: 320px;
  max-width: 440px;
  animation: app-confirm-scalein .15s ease;
}
.app-confirm-body { margin-bottom: 20px; color: var(--text-main); line-height: 1.5; }
.app-confirm-body p { margin: 0 0 4px; }
.app-confirm-body p:last-child { margin-bottom: 0; }
.app-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.app-confirm-btn {
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: background .12s, box-shadow .12s;
}
.app-confirm-cancel {
  background: var(--btn-bg);
  color: var(--btn-text);
}
.app-confirm-cancel:hover { background: var(--surface-container-low); }
.app-confirm-ok {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.app-confirm-ok:hover { background: var(--btn-primary-hover); }
.app-confirm-ok--danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.app-confirm-ok--danger:hover { background: #b91c1c; }
@keyframes app-confirm-fadein { from { opacity: 0 } to { opacity: 1 } }
@keyframes app-confirm-scalein { from { transform: scale(0.95); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* ── Signal-Config Dialog ────────────────────────────────────────── */
.signal-config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signal-config-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 16px 20px;
  min-width: 320px;
  max-width: 420px;
}
.app-toast-success {
  background: #16a34a;
  color: #fff;
}
.app-toast-info {
  background: #2563eb;
  color: #fff;
}

/* ── Signal-Monitor ─────────────────────────────────────────── */
.signal-info-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.signal-row--qualified {
  border-left: 3px solid #2563eb;
}
.signal-row--unqualified {
  opacity: 0.45;
  border-left: 3px dashed var(--border-color, #e2e8f0);
}
.signal-row--unqualified:hover {
  opacity: 0.75;
}
.signal-preview {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 20px;
  max-height: 500px;
  overflow-y: auto;
  background: #fff;
}
[data-theme="dark"] .signal-preview {
  background: var(--bg-secondary, #1e293b);
}

/* ── Dokumentation Popover ─────────────────────────────────────────── */
.app-popover--doc {
  min-width: 400px;
  max-width: 700px;
}
.app-popover--doc .popover-body h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}
.app-popover--doc .popover-body p {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.doc-meta-table th {
  width: 120px;
  white-space: nowrap;
  font-size: 0.8rem;
}
.doc-meta-table td {
  font-size: 0.8rem;
}
.doc-info-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Dokumentation Admin-Seite ─────────────────────────────────────── */
.doc-page { max-width: 1400px; padding: 20px; font-size: 1rem; }
.doc-section { margin-bottom: 30px; }
.doc-section h2 { font-size: 1.25rem; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.doc-section p { font-size: 0.95rem; line-height: 1.6; color: var(--text-muted); padding: 0; }
.doc-page .doc-table {
  width: 100%;
  font-size: 0.85rem;
}
.doc-page .doc-table th {
  position: sticky;
  top: 0;
  background: var(--bg-app, #fff);
  z-index: 1;
  white-space: nowrap;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border-strong, #cbd5e1);
}
.doc-page .doc-table td {
  padding: 8px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.doc-report-card {
  padding: 1.5rem;
  margin-bottom: 1rem;
  background: var(--bg-secondary, #f8fafc);
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
}
.doc-report-card h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
  color: var(--text-heading, #1e293b);
}
.doc-report-card p {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.doc-report-card .detail-kv-table {
  margin-top: 0.75rem;
}

/* ==========================================================================
   SITE HEADER (Top-Level Navigation)
   ========================================================================== */

.site-header {
    position: sticky; /* Stays sticky, more robust than fixed for this layout */
    top: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .site-header {
    background: rgba(18, 19, 24, 0.85); /* Matches old zone-nav dark */
    box-shadow: none;
}

.site-header-inner {
    max-width: 1280px; /* Corresponds to max-w-7xl */
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: 5rem; /* 80px */
}

.site-header-brand {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
    text-decoration: none;
    white-space: nowrap;
}

.site-header-nav {
    display: flex;
    align-items: center;
    gap: 2rem; /* space-x-8 */
}

.site-header-nav-item {
    display: inline-flex;
    align-items: center;
    padding-bottom: 0.25rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.site-header-nav-item:hover {
    color: var(--text-main);
}

.site-header-nav-item.active {
    color: var(--btn-primary-bg);
    font-weight: 600;
    border-bottom-color: var(--btn-primary-bg);
}

.site-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-header-actions #btn-theme-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm, 4px);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    margin-left: auto;
}

.site-header-actions #btn-theme-toggle:hover {
    background: var(--hover-bg, rgba(0,0,0,0.05));
}

/* Adjust app-shell padding to account for fixed header height */
body:has(.site-header) .app-shell {
    height: calc(100vh - 5rem);
}


/* ==========================================================================
   GLOBALE FEINSCHLIFFE (MD3 Redesign)
   ========================================================================== */

:focus-visible {
    outline: 2px solid var(--btn-primary-bg);
    outline-offset: 2px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}
