body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #121418; /* Satter dunkler Raum */
    padding: 10px; /* Reduziert für mehr Platz auf kleinen Handys */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: #ffffff;
}
.detail-container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    background: #2c313c; /* NOCHMALS AUFGEHELLT: Deutlich lesbareres Graphitgrau */
    padding: 12px; /* Weniger Randabstand erhöht die nutzbare Breite */
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    border: 1px solid #3d4454; 
}
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px; /* Kleinerer Abstand lässt Felder wachsen */
    margin-bottom: 15px;
    width: 100%;
}
.kpi-card {
    background: #1a1c23; 
    padding: 8px 4px; /* Sehr flach und breit gehalten */
    border-radius: 10px;
    text-align: center;
    border: 1px solid #343a46;
    overflow: hidden; /* Verhindert das Ausbrechen von Text */
}
.kpi-card h3 { 
    margin: 0; 
    font-size: 11px; /* Etwas kleiner für mehr Platz */
    color: #ffffff; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    font-weight: bold; 
}
.kpi-card p { 
    margin: 4px 0 0 0; 
    font-size: 18px; /* FIX: Verkleinert, um Zeilenumbrüche bei großen Werten zu verhindern */
    font-weight: bold; 
    color: #ffffff;
    white-space: nowrap; /* FIX: Zwingt die Zahl in eine einzige Zeile */
}

/* --- Diagrammbereich --- */
.chart-wrapper {
    position: relative;
    height: 240px;
    margin-bottom: 5px;
    padding-left: 35px;
}
.y-axis {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 10px;
    color: #ffffff; 
    font-weight: bold;
    padding: 0;
    z-index: 5;
    pointer-events: none;
}
.chart-box {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    height: 100%;
    position: relative;
    border-left: 2px solid #ffffff; 
}
.zero-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 3px;
    background-color: #ffffff; 
    z-index: 2;
}
.grid-line-50 {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    border-top: 1px dashed #4e5667; 
    z-index: 1;
}
.chart-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0 1px; /* Minimierter Balkenabstand für mehr Balkenbreite */
    position: relative;
    z-index: 3;
}
.chart-half {
    flex: 1;
    display: flex;
    justify-content: center;
    position: relative;
    width: 100%;
}
.chart-half.top { align-items: flex-end; }
.chart-half.bottom { align-items: flex-start; }

.bar {
    width: 85%; /* Breitere Balken für das 2-Stunden-Raster */
    transition: height 0.5s ease-in-out;
}
.bar.einspeisung { background-color: #00ff66; border-radius: 2px 2px 0 0; }
.bar.bezug { background-color: #ff3344; border-radius: 0 0 2px 2px; }

.chart-column:hover .tooltip { display: block; }
.tooltip {
    display: none;
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff; 
    color: #0f1013;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 9999 !important; /* FIX 1: Absolut vorderste Ebene erzwingen */
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.7);
    font-weight: bold;
}

/* FIX 2: Wenn eine Spalte gehalten/gehovert wird, bekommt sie sofort Vorrang vor den Nachbarspalten */
.chart-column:hover, .chart-column:active {
    z-index: 9998 !important;
}


.chart-labels {
    display: flex;
    justify-content: space-between;
    padding-left: 35px;
    margin-bottom: 15px;
    color: #ffffff; 
    font-size: 9px; /* Leicht verkleinert für das dichte 2h-Raster */
    font-weight: bold; 
    border-top: 1px solid #4e5667;
    padding-top: 5px;
}
.chart-labels span {
    flex: 1;
    text-align: center;
    white-space: nowrap;
}
.legend-box {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 12px;
    margin-bottom: 15px;
    color: #ffffff;
    font-weight: bold;
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-color { width: 12px; height: 12px; border-radius: 3px; }

.selector-nav {
    display: flex;
    background: #1a1c23;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 1px solid #343a46;
}
.selector-nav button {
    flex: 1;
    border: none;
    background: none;
    padding: 10px;
    font-size: 13px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    color: #a0aab5;
    transition: background 0.2s, color 0.2s;
}
.selector-nav button.active {
    background: #434956;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    color: #ffffff;
}

/* --- NEU: Sichtbarer, harmonischer Darkmode-Zurück-Button --- */
.nav-dark-back {
    display: block;
    text-align: center;
    padding: 12px;
    background-color: #434956; /* Gut sichtbares, dezentes Mittelgrau */
    color: #ffffff !important;
    border: 1px solid #525a6c;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: background-color 0.2s;
    margin-top: 5px;
}
.nav-dark-back:active {
    background-color: #343a46; /* Visuelles Feedback beim Drücken */
}

/* --- CSS-Effekt für die Live-Aktualisierung (Ultra-fein) --- */
.fade-flash {
    animation: fadeFlashAnim 0.25s ease-out; /* Von 0.6s auf schnelle 0.25s verkürzt */
}

@keyframes fadeFlashAnim {
    0% {
        opacity: 0.4; /* Startet etwas sanfter */
    }
    100% {
        opacity: 1;
    }
}
