* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Inter', sans-serif; 
}

html {
    scrollbar-gutter: stable;
}

/* --- 1. GRUNDLAYOUT (BODY) --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f4f4; /* Hellgrauer Hintergrund */
    color: #333;
    margin: 0 auto; /* Zentriert die Seite horizontal */
    padding: 20px;
    max-width: 1400px; /* Die Seite wird nie breiter als 1000px */
    background-color: #fff; /* Der Inhaltbereich ist weiß */
    min-height: 100vh;
    box-shadow: 0 0 10px rgba(0,0,0,0.05); /* Leichter Schatten links/rechts */
}

/* --- 2. MENÜ (NAVIGATION) --- */
/* --- 2. MENÜ (NAVIGATION) --- */
.menu {
    background-color: #f8f9fa;
    padding: 10px 20px;       /* Etwas weniger Padding oben/unten, mehr seitlich */
    margin-bottom: 25px;
    border-bottom: 1px solid #ddd;
    border-radius: 5px;
    
    /* NEU: Flexbox sorgt für perfekte Ausrichtung */
    display: flex;
    flex-wrap: wrap;          /* Erlaubt Umbruch, wenn der Bildschirm zu klein ist */
    align-items: center;      /* Vertikal zentrieren */
    gap: 15px;                /* Abstand zwischen den Links */
}

.menu a {
    text-decoration: none;
    color: #555;
    font-weight: bold;
    padding: 5px 0;           /* Klickbare Fläche etwas erhöhen */
}

.menu a:hover {
    color: #007bff;
    text-decoration: underline;
}

/* Der Abmelden-Button wird automatisch nach rechts geschoben */
.menu-logout {
    margin-left: auto;        /* Das ist der Flexbox-Trick für "ganz rechts" */
    color: #dc3545 !important;
    border: 1px solid #dc3545; /* Optional: Roter Rahmen sieht schick aus */
    padding: 5px 10px !important;
    border-radius: 4px;
}

.menu-logout:hover {
    background-color: #dc3545;
    color: white !important;
    text-decoration: none !important;
}

/* Clearfix wird bei Flexbox nicht mehr benötigt, kann weg oder bleiben (stört nicht) */
.clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* --- 3. TABELLEN --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    margin-bottom: 20px;
}
th, td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}
th {
    background-color: #f2f2f2;
    font-weight: bold;
}
/* Jede zweite Zeile etwas dunkler (Zebra-Look) */
tr:nth-child(even) {
    background-color: #f9f9f9;
}
tr:hover {
    background-color: #e9ecef; /* Highlight beim Drüberfahren */
}

/* --- 4. FORMULARE --- */
input[type="text"], 
input[type="password"], 
input[type="number"], 
input[type="date"], 
select, 
textarea {
    padding: 10px;
    margin: 5px 0 15px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Padding zählt zur Breite dazu */
    width: 100%; /* Standardmäßig volle Breite, kann überschrieben werden */
}
/* Ausnahme für nebeneinanderliegende Felder */
form select, form input {
    width: auto; 
    min-width: 200px;
}

input[type="submit"] {
    background-color: #28a745; /* Grün */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}
input[type="submit"]:hover {
    background-color: #218838;
}

/* Container für Formulare */
.form-box {
    background-color: #f8f9fa;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 20px;
}

/* --- 5. MELDUNGEN & TEXTE --- */
h1 { color: #2c3e50; }
h2, h3 { color: #34495e; }

.error { color: #dc3545; font-weight: bold; }   /* Rot */
.success { color: #28a745; font-weight: bold; } /* Grün */

.typ-kauf { color: green; font-weight: bold; }
.typ-verkauf { color: red; font-weight: bold; }
.typ-dividende { color: blue; font-weight: bold; }

.text-right { text-align: right; }


/* ---------------------------------------------------
   ZARTE & MODERNE DATENTABELLE (Universal)
   --------------------------------------------------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.9em; /* Etwas kleinere, elegantere Schrift */
    color: #444;      /* Weiches Dunkelgrau statt hartem Schwarz */
    box-shadow: 0 1px 4px rgba(0,0,0,0.05); /* Sehr sanfter Schatten */
    border-radius: 6px;
    overflow: hidden; /* Damit die runden Ecken wirken */
}

.data-table th {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
    color: #666;
    font-weight: 600;
    background-color: #fdfdfd; /* Fast weiß, nur ein Hauch von Grau */
    white-space: nowrap;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f2f2f2; /* Extrem zarte, kaum sichtbare Linie */
    vertical-align: middle;
}

/* Letzte Linie entfernen, sieht sauberer aus */
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Leichter Hover-Effekt für die Zeilen */
.data-table tbody tr:hover {
    background-color: #fafafa;
}


/* ---------------------------------------------------
   PIVOT TABELLE (Dividenden Matrix)
   --------------------------------------------------- */
.pivot-table { 
    table-layout: fixed; 
    width: 100%; 
}

.pivot-table th, .pivot-table td { 
    padding: 8px 6px; 
    font-size: 0.9em; 
    white-space: nowrap; 
}

/* 1. Spalte (Namen) auf 20% Breite */
.pivot-table th:first-child, .pivot-table td:first-child { 
    width: 20%; 
    max-width: 250px; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* Spaltenköpfe (Jahre oben) zwingend fett! */
.pivot-table thead th {
    font-weight: bold !important;
    color: #333;
}

/* Fußzeile (Grauer Balken unten) zwingend fett! */
.pivot-table tfoot th { 
    background-color: #e9ecef; 
    font-weight: bold !important; 
    color: #333; 
    border-top: 2px solid #ccc; 
}

/* Das Wort "Gesamt" unten nach rechts an die Zahlen schieben */
.pivot-table tfoot th:first-child { 
    text-align: right !important; 
    padding-right: 15px; 
}

/* Alle Zellen mit Werten zwingend rechtsbündig */
.pivot-table th.pivot-val, 
.pivot-table td.pivot-val { 
    text-align: right !important; 
}

/* Leere Jahre (-) rechtsbündig & unauffällig */
.pivot-null { 
    text-align: right !important; 
    color: #ccc; 
}

.stats-grid { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 200px; background: #28a745; color: white; padding: 20px; border-radius: 8px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.stat-box.highlight { background: #6f42c1; } 
.stat-box h3 { margin: 0 0 10px 0; font-size: 1em; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-box .value { font-size: 2em; font-weight: bold; }
.chart-container { background: #fff; padding: 20px; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 30px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); overflow-x: auto; }

/* ==========================================================================
   TOP NAVIGATION BAR & SIDEBAR
   ========================================================================== */

.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    background-color: #fff;
    padding: 0 5%; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000; 
    height: 70px; 
    width: 100%; 
    box-sizing: border-box; /* Verhindert horizontalen Scrollbalken trotz 100% width + padding */
}

.navbar-left {
    display: flex;
    align-items: center;
}

.burger-btn {
    font-size: 26px;
    cursor: pointer;
    background: none;
    border: none;
    color: #333;
    margin-right: 20px;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.burger-btn:hover { color: #007bff; }

.brand-logo {
    font-size: 1.4em; 
    font-weight: 800; 
    color: #0f172a; 
    text-decoration: none;
    letter-spacing: -0.5px;
    margin-right: 15px; 
}
.brand-logo span { color: #007bff; }

.header-image {
    height: 35px; 
    width: auto;
    border-radius: 4px; 
}

.navbar-right {
    display: flex;
    align-items: center;
}

.btn-portal-login {
    background: #007bff;
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: 0.2s;
}
.btn-portal-login:hover { background: #0056b3; transform: translateY(-1px); }

/* --- Die Sidebar (Das eigentliche Menü) --- */
.sidebar {
    height: 100%;
    width: 300px;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: -300px;
    background-color: #2b3035;
    overflow-x: hidden;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 20px;
    background: #1a1d20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3c4248;
}

.sidebar-header h2 {
    margin: 0;
    color: #fff;
    font-size: 1.2em;
}

.close-sidebar {
    color: #aaa;
    font-size: 30px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.close-sidebar:hover { color: #fff; }

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-content a, .sidebar-dropdown-btn {
    padding: 16px 20px;
    text-decoration: none;
    font-size: 1.05em;
    color: #ced4da;
    display: block;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    outline: none;
    border-bottom: 1px solid #3c4248;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}

.sidebar-content a:hover, .sidebar-dropdown-btn:hover {
    color: #fff;
    background-color: #3c4248;
    border-left: 4px solid #007bff;
    padding-left: 16px;
}

/* Dropdown Container innerhalb der Sidebar (Administration) */
.sidebar-dropdown-container {
    display: none;
    background-color: #212529;
}

.sidebar-dropdown-container a {
    padding-left: 50px;
    font-size: 0.95em;
    border-bottom: 1px solid #2b3035;
}

.sidebar-dropdown-container a:hover {
    padding-left: 46px;
}

.caret { float: right; transition: transform 0.3s; }
.sidebar-dropdown-btn.active .caret { transform: rotate(180deg); }

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 9998;
    display: none;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

.spacer { flex-grow: 1; }

.logout-link { 
    background: #dc3545 !important; 
    color: white !important; 
    font-weight: bold; 
    border-top: none !important;
    text-align: center !important;
    margin-top: auto;
}
.logout-link:hover { 
    background: #c82333 !important; 
    border-left: none !important;
    padding-left: 20px !important;
}