:root {
    --primary: #2563eb;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --danger: #ef4444;
    --danger-dark: #b91c1c;
    --success: #22c55e;
    --border: #cbd5e1;
    --item-height: 50px;
    --header-height: 60px;
    --sidebar-width: 300px;
    --bg-header: #007bff;
    /* --bg-sidebar: #f0f8ff; */
    --bg-sidebar: #f4f4f4;
    --text-color: #333;
    --sidebar-text: #333;
    --accent-color: #0056b3;
    /* Dunkleres Blau für aktive Links */
    --accent-color-rgb: 0, 86, 179;
    /* Das gleiche Blau als RGB-Werte */
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    overflow: hidden;
}

.wrapper {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    align-items: flex-start;
    /* Wichtig für Sticky-Elemente */
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid #ddd;
    transition: margin-left var(--transition-speed) ease, left var(--transition-speed) ease;
    overflow-y: auto;
    flex-shrink: 0;
    /* Verhindert, dass die Sidebar gequetscht wird */

    /* NEU: Fixierung auf Desktop */
    position: sticky;
    top: var(--header-height);
    /* Bleibt unterhalb des Headers "kleben" */
    height: calc(100vh - var(--header-height));
    /* Volle Resthöhe des Bildschirms */
    overflow-y: auto;
    /* Falls das Menü länger als der Bildschirm ist, ist es in sich scrollbar */
}

/* Desktop-Verstecken via Margin */
.sidebar.hidden {
    margin-left: calc(var(--sidebar-width) * -1);
}

/* Styling für die Links in der menu.html */
.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    border-bottom: 1px solid #e0e0e0;
}

.sidebar ul li a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: var(--sidebar-text);
    transition: background 0.2s;
}

.sidebar ul li a:hover {
    background-color: #e0f0ff;
}

/* Aktiver Link */
.sidebar ul li a.active-link {
    background-color: var(--accent-color);
    /* background: linear-gradient(90deg, rgba(var(--accent-color-rgb), 1.0) 0%, transparent 100%); */
    color: white;
    font-weight: bold;
}

/* Styling für den Header innerhalb der Sidebar */
.sidebar-header {
    padding: 20px 10px;
    /* Abstand oben/unten und seitlich */
    border-bottom: 1px solid #ddd;
    /* Optionale Trennlinie zum Menü */
    text-align: center;
    /* Zentriert den Text horizontal */
}

.sidebar-header h3 {
    margin: 0;
    /* Entfernt Standard-Abstände des Browsers */
    font-size: 1.2rem;
    /* Größe nach Bedarf anpassen */
    color: var(--sidebar-text);
    /* Weißer Text für dunkle Sidebar */
}

/* --- 6. Mobile Anpassungen (Overlay) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    backdrop-filter: blur(2px);
    /* Optionaler moderner Blur-Effekt */
}

@media (max-width: 768px) {
    .wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: var(--sidebar-width);
        height: calc(100vh - var(--header-height));
        margin-left: 0;
        transform: translateX(-100%);
        transition: transform var(--transition-speed) ease;
        z-index: 1100;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar.active ~ .sidebar-overlay {
        display: block;
    }

    .container {
        width: 100%;
        padding: 2rem 1rem 2rem 1rem;
    }
}

.container {
    width: 100%;
    flex-grow: 1;
    padding: 2rem 2rem 2rem 2rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height));
}

.content {
    max-width: 1000px;
    margin: 0 auto;
}

.main-header {
    height: var(--header-height);
    background: var(--bg-header);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1200;
    /* Ganz oben */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#menu-toggle {
    background: #0056b3;
    border: none;
    color: white;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 1.2rem;
    margin-right: 20px;
    border-radius: 4px;
    transition: background 0.2s;
}

#menu-toggle:hover {
    background: #004080;
}

.site-title {
    font-size: 1.3rem;
    font-weight: bold;
}

a[id],
.site-title a {
    color: inherit;
    /* gleiche Farbe wie normaler Text */
    text-decoration: none;
    /* kein Unterstrich */
    cursor: default;
    /* ganz normaler Maus-Pfeil */
}

a[id],
.site-title a:hover {
    color: inherit;
    /* keine Farbänderung */
    text-decoration: none;
    /* kein Unterstrich */
    cursor: pointer;
    /* HAND-CURSOR */
}

.nav-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s ease;
    /* Schöner Übergang beim Deaktivieren */
}

/* Hover-Effekt (optional, für besseres Feedback) */
.nav-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

/* DER WICHTIGE TEIL: Wenn der Button deaktiviert ist */
.nav-btn:disabled {
    background: #cbd5e1;
    /* Ein neutrales Grau */
    cursor: not-allowed;
    opacity: 0.6;
}

.card {
    background: var(--card-bg);
    padding: 12px 16px;
    /* Oben/Unten 12px, Rechts/Links 16px statt überall 20px */
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
    /* Weniger Abstand zur nächsten Karte */
}

.card h2 {
    margin-top: 0;
    margin-bottom: 10px;
    /* Kleiner, definierter Abstand nach unten */
    font-size: 1.1rem;
    /* Etwas dezenter */
    line-height: 1.2;
}

/* Formular Layout */
#finance-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

#finance-form input,
#finance-form select {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    flex: 1;
}

#add-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

#add-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

/* Progress Bar */
.progress-container {
    width: 100%;
    max-width: 750px;
    /* Verhindert, dass der Balken zu lang wird */
    height: 12px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 15px;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: var(--success);
    transition: width 0.4s;
}

#list-wrapper {
    height: 350px;
    /* 5 Items à 70px */
    overflow: hidden;
    /* Das Guckloch-Prinzip */
    position: relative;
    /* Anker für die Liste */
    border: 1px solid #ebe3e3;
    /* Damit du die Grenzen siehst */
    /* background: #1a1a1a;  */
    /* Optional: Hintergrund für die Liste */
}

#custom-scrollbar {
    position: absolute;
    top: 5px;
    /* Ein wenig Abstand zum Rand oben */
    bottom: 5px;
    /* Ein wenig Abstand zum Rand unten */
    right: 4px;
    /* Etwas Abstand von der rechten Kante */
    width: 6px;
    /* Schön schmal */
    background: rgba(200, 200, 200, 0.2);
    /* Leichtes Hellgrau, transparent */
    border-radius: 10px;
    pointer-events: none;
    /* Verhindert, dass die Schiene Klicks abfängt */
}

/* Der bewegliche Balken */
#scroll-thumb {
    width: 100%;
    /* NEU: Eine Standard-Höhe, damit er beim Laden sofort da ist */
    height: 50px;
    min-height: 20px;

    background: rgba(150, 150, 150, 0.6);
    border-radius: 10px;

    /* WICHTIG: Er muss sichtbar sein */
    display: block !important;

    transition: transform 0.1s linear, height 0.2s ease;
}

#scroll-thumb.non-scrollable {
    background: rgba(150, 150, 150, 0.3);
    opacity: 0.6;
    height: 100% !important;
}

/* Optional: Hover-Effekt, wenn man mit der Maus über den Wrapper geht */
#list-wrapper:hover #scroll-thumb {
    background: rgba(100, 100, 100, 0.8);
    /* Wird etwas dunkler beim Hover */
}

/* Liste & Transaktionen */
#transaction-list {
    /* Deine restlichen Styles (Padding, List-Style etc.) einfach so lassen */
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    will-change: transform;
    /* Sagt dem Browser: "Achtung, das bewegt sich smooth!" */
}

/* Die Zeile: Alles in einer Reihe */
#transaction-list li {
    height: var(--item-height);
    display: flex;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 15px !important;
    border-bottom: 1px solid #eee !important;
    box-sizing: border-box;
    /* WICHTIG: Padding wird nicht zur Höhe addiert */
}

/* Datum und Beschreibung nebeneinander */
.transaction-date {
    display: inline-block !important;
    /* NICHT MEHR BLOCK */
    font-size: 0.85rem !important;
    color: #64748b !important;
    margin-right: 15px !important;
    /* ABSTAND ZUR BESCHREIBUNG */
    font-family: monospace;
    /* Sieht bei Daten sauberer aus */
}

/* Rechter Block: Betrag und Button */
.amount-display {
    margin-right: 20px !important;
    /* ABSTAND ZUM BUTTON */
    font-weight: bold !important;
    display: inline-block !important;
}

/* Farben für die Beträge */
.total-positive {
    color: #22c55e !important;
}

.total-negative {
    color: #ef4444 !important;
}

/* 1. Der Standard-Zustand (Blau) */
.delete-btn {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border: none !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 0.85rem !important;

    /* WICHTIG: Kein fettgedruckter Text, damit die Breite gleich bleibt */
    font-weight: 500 !important;

    /* Fixe Mindestbreite, damit der Text "Sicher?" nicht mehr Platz braucht als "Löschen" */
    min-width: 80px !important;
    transition: background-color 0.2s ease !important;

    /* Verhindert das Zucken durch Layout-Sprünge */
    display: inline-block !important;
    text-align: center !important;
}

/* 2. Der Hover-Zustand */
.delete-btn:hover {
    background-color: #1d4ed8 !important;
}

/* 3. Der Warn-Zustand (Rot) - OHNE scale und OHNE extra bold */
.delete-btn.btn-danger {
    background-color: #ef4444 !important;
    color: white !important;

    /* Wir lassen font-weight und transform weg, damit nichts zuckt */
    transform: none !important;
}

.filter-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.stats-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.stats-row {
    display: grid;
    grid-template-columns: 100px 1fr 1fr 1fr;
    /* Feste Breite für Beschriftung */
    align-items: center;
    padding: 8px;
    border-radius: 4px;
}

.stats-row.header {
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 1px solid #eee;
}

.filter-row {
    background-color: rgba(0, 0, 0, 0.03);
    /* Leichte Abhebung des Filters */
}

.footer-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
}

#reset-view-btn {
    cursor: pointer;
    transition: opacity 0.2s;
    user-select: none;
    /* Verhindert Markieren beim Klicken */
}

#reset-view-btn:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Das ist das Sichtfenster. Es darf NICHT breiter als der Bildschirm werden! */
.chart-viewport {
    width: 100%;
    /* Nutze die verfügbare Breite des Browsers */
    max-width: 100vw;
    /* Absolut begrenzen auf Viewport-Width */
    overflow-x: auto;
    /* Zeige Scrollbalken, wenn der Inhalt zu breit ist */
    overflow-y: hidden;
    /* Verhindere vertikales Scrollen */
    border: 1px solid #333;
    display: block;
    /* Wichtig, damit width greift */
}

/* Der Bereich, in dem das Chart gezeichnet wird */
.chart-canvas-wrapper {
    height: 500px;
    /* Feste Höhe für die Grafik */
    position: relative;
    /* Notwendig für Chart.js */
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    padding: 0 10px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-top: 5px solid #ccc;
}

.stat-card.income {
    border-top-color: #2ecc71;
}

.stat-card.expense {
    border-top-color: #e74c3c;
}

.stat-card h3 {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    margin: 10px 0;
    color: #333;
}

.stat-month {
    font-size: 1rem;
    color: #999;
    font-style: italic;
}

.stat-card hr {
    border: 0;
    /* Entfernt den Standard-Rahmen */
    border-top: 1px solid #eeeeee;
    /* Sehr feine, helle Linie */
    margin: 15px 0;
    /* Abstand nach oben/unten */
    width: 100%;
    /* Volle Breite innerhalb des Paddings */
}

/* Optional: Den Bereich für den Durchschnitt etwas kleiner und grauer gestalten */
.stat-card small {
    display: block;
    /* Damit es auf einer neuen Zeile steht */
    color: #7f8c8d;
    /* Dezentes Grau */
    font-size: 0.85rem;
    /* Etwas kleiner als der Rest */
    font-weight: 500;
}

#avg-income,
#avg-expense {
    font-weight: bold;
    /* Die Zahlen im Durchschnitt hervorheben */
    color: #333;
}

.chart-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.control-group {
    display: flex;
    gap: 5px;
    /* Kleiner Abstand zwischen den Buttons einer Gruppe */
}

.btn-scroll {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-scroll:hover {
    background-color: #e9ecef;
    border-color: #ccc;
    color: #222;
}

/* Admin Controls */
.admin-controls .button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-controls .button-group.margin-top {
    margin-top: 15px;
}

.admin-controls .import-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #1e293b;
    font-size: 0.9rem;
}

.admin-controls .import-select {
    padding: 5px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: white;
}

.admin-controls #import-file-input {
    display: none;
}

.message-area {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 20px;
}

.message-area.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-area.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message-area.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.admin-controls .delete-btn.secondary {
    background-color: #4b5563 !important;
}

.admin-controls .delete-btn.danger {
    background-color: var(--danger) !important;
}

.admin-controls .delete-btn.primary {
    background-color: #2563eb !important;
}

.btn-scroll:active {
    transform: translateY(1px);
}

/* --- About Page Styling --- */

.about-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    /* Linke Spalte fix, rechte flexibel */
    gap: 15px 20px;
    /* Abstand zwischen Zeilen und Spalten */
    margin-top: 20px;
    align-items: baseline;
}

.about-label {
    font-weight: bold;
    color: var(--text-color);
    /* border-right: 2px solid var(--bg-header); */
    /* Ein kleiner Akzentpassend zum Header */
    padding-right: 15px;
}

.about-value {
    color: var(--text);
    font-style: italic;
    /* Optional, für eine leichtere Unterscheidung */
}

/* Mobile Optimierung: Falls der Bildschirm zu schmal wird, untereinander anzeigen */
@media (max-width: 600px) {
    .about-grid {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .about-label {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 2px;
        margin-top: 10px;
    }
}

.full-width-line {
    grid-column: 1 / -1;
    /* Zwingt das Element über die volle Breite */
    width: 100%;
    /* Stellt sicher, dass die Linie den Platz füllt */
    border: 0;
    /* Entfernt den Standard-Rahmen */
    border-top: 1px solid var(--border);
    /* Deine Definition für die Linie */
    margin: 10px 0;
    /* Abstand nach oben und unten */
}

.card h2 {
    background-color: #d9e6f3;
    /* Ein sehr helles Grau passend zu deinem Design */
    margin: -12px -16px 15px -16px;
    /* Gleicht das Padding der .card exakt aus */
    padding: 12px 16px;
    /* Gibt dem Text den Platz zum Rand zurück */
    border-bottom: 1px solid var(--border);
    border-top-left-radius: 12px;
    /* Ecken oben abrunden, damit sie zur Card passen */
    border-top-right-radius: 12px;
    font-size: 1.1rem;
    color: var(--text);
    font-weight: 600;
    letter-spacing: 0.02em;
    /* Verleiht der Überschrift etwas mehr Luft */
    text-transform: none;
    /* Behält deine normale Schreibweise bei */
}