:root {
    --bg-color: #000000;
    --card-bg: rgba(20, 20, 24, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-hover: rgba(255, 255, 255, 0.16);
    --accent-blue: #11A9ED;
    --accent-yellow: #FFD60A;
    --accent-orange: #FF9F0A;
    --accent-green: #32D74B;
    --text-primary: #ffffff;
    --text-secondary: #a8a8ad;
    --text-tertiary: #6e6e73;
    --separator: rgba(255, 255, 255, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 0%, rgba(17, 169, 237, 0.08) 0%, transparent 60%);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
    padding-bottom: 50px;
    overflow-x: hidden;
    max-width: 100vw;
    min-height: 100vh;
}

/* App Header */
.app-header {
    text-align: center;
    padding: 50px 20px 36px 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeInDown 0.8s ease forwards;
}

.app-header h1 {
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 6px;
    background: linear-gradient(180deg, #ffffff 60%, rgba(255, 255, 255, 0.75) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 7px;
    font-weight: 400;
    margin-bottom: 26px;
}

/* Minimalist Gradient Divider */
.app-header::after {
    content: '';
    display: block;
    width: 240px;
    height: 2px;
    background: linear-gradient(90deg, rgba(17,169,237,0) 0%, rgba(17,169,237,0.85) 30%, rgba(255,214,10,0.85) 70%, rgba(255,214,10,0) 100%);
    border-radius: 2px;
}

/* Dashboard Grid Layout */
.dashboard {
    padding: 10px 36px;
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
}

@media (max-width: 1120px) {
    .dashboard {
        grid-template-columns: minmax(0, 1fr);
        gap: 22px;
        padding: 10px 20px;
    }
}

/* Unified Card Design */
.sensor-section {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px 20px 20px 20px;
    min-width: 0;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                border-color 0.25s ease, 
                box-shadow 0.25s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

.sensor-section:hover {
    border-color: var(--card-border-hover);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6);
}

.sensor-section:nth-child(1) { animation-delay: 0.08s; }
.sensor-section:nth-child(2) { animation-delay: 0.16s; }
.sensor-section:nth-child(3) { animation-delay: 0.24s; }
.sensor-section:nth-child(4) { animation-delay: 0.32s; }
.sensor-section:nth-child(5) { animation-delay: 0.40s; }
.sensor-section:nth-child(6) { animation-delay: 0.48s; }

.sensor-section.pv-full-width {
    grid-column: 1 / -1;
    padding: 28px 26px 24px 26px;
}

/* Card Header */
.card-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 16px 4px;
    border-bottom: 1px solid var(--separator);
    margin-bottom: 16px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    letter-spacing: -0.2px;
}

/* Battery Badge */
.battery-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.battery-text {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
}

.battery-icon {
    width: 24px;
    height: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    position: relative;
    padding: 1.5px;
    display: flex;
    align-items: center;
}

.battery-icon::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 2px;
    width: 2px;
    height: 5px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 0 1.5px 1.5px 0;
}

.battery-level {
    height: 100%;
    border-radius: 1px;
    transition: width 0.5s ease;
}

/* Segmented Control Tabs */
.sensor-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: rgba(0, 0, 0, 0.45);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 20px;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 10px 8px;
    border-radius: 10px;
    user-select: none;
}

.tab-btn:hover {
    opacity: 0.85;
    background-color: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.09);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.stat-value-huge {
    font-size: 2.35rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    transition: color 0.5s ease;
}

.stat-unit-huge {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-left: 4px;
    font-weight: 600;
}

.stat-label-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 6px;
    letter-spacing: 0.3px;
}

/* Secondary Min/Max Stats */
.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: stretch;
}

.dynamic-stats {
    transition: opacity 0.3s ease;
}

.stat-secondary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 10px 14px;
}

.stat-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.stat-label-small {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-value-small {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
}

.stat-unit-small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 2px;
}

.stat-date { 
    font-size: 0.72rem; 
    color: var(--text-secondary); 
    text-align: right; 
    margin-top: 3px; 
    letter-spacing: 0.2px;
}

.stat-divider {
    height: 1px;
    background-color: var(--separator);
    width: 100%;
    margin: 8px 0;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 360px;
    width: 100%;
    max-width: 100%;
    padding: 0 4px;
    box-sizing: border-box;
}

.chart-container canvas {
    max-width: 100% !important;
}

/* PV Chart Navigation */
.chart-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 10px 18px;
    margin-bottom: 22px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #000;
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(17, 169, 237, 0.35);
}

.nav-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.nav-btn:disabled {
    opacity: 0.2;
    cursor: default;
    background: transparent;
}

.date-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 160px;
    text-align: center;
    letter-spacing: 0.3px;
}

/* PV Stats Tiles */
.pv-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-card .stat-value-group {
    display: flex;
    align-items: baseline;
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
}

.stat-card .stat-unit {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-left: 4px;
}

.stat-card .stat-date {
    margin-top: 6px;
    text-align: left;
    font-size: 0.72rem;
}

/* PV Yield Summary: same visual weight as all other statistic cards */
.pv-yield-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 0 0 24px;
}

/* Kühlschrank Legend & Door Badge */
.chart-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 4px 0 16px 0;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

#refrigerator-door-status {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Footer */
.app-footer {
    padding: 40px 20px 20px 20px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes valuePulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.value-updated {
    animation: valuePulse 0.35s ease;
}

/* Responsive Mobile Layout */
@media (max-width: 768px) {
    .app-header {
        padding: 36px 16px 24px 16px;
    }
    .app-header h1 {
        font-size: 2.2rem;
        letter-spacing: -1px;
    }
    .app-header p {
        font-size: 0.95rem;
        letter-spacing: 4px;
        margin-bottom: 20px;
    }
    .app-header::after {
        width: 180px;
    }
    .dashboard {
        padding: 6px 12px;
        gap: 18px;
    }
    .sensor-section {
        padding: 20px 14px 16px 14px;
        border-radius: 16px;
    }
    .sensor-section.pv-full-width {
        padding: 20px 14px 16px 14px;
    }
    .chart-container {
        height: 300px;
        padding: 0;
    }
    .stat-value-huge {
        font-size: 1.9rem;
    }
    .stats-row {
        flex-direction: column;
        gap: 10px;
    }
    .stat-secondary {
        margin-left: 0 !important;
        width: 100%;
    }
    .pv-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .pv-yield-strip {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 20px;
    }
    .chart-navigation {
        gap: 14px;
    }
    .date-label {
        min-width: 120px;
        font-size: 0.95rem;
    }
}
