:root {
    --bg-color: #000000;
    --card-bg: #000000;
    --accent-blue: #11A9ED;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --separator: #1c1c1e;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
    overflow-x: hidden; /* Prevent any horizontal overflow */
    max-width: 100vw;
}

/* App Header */
.app-header {
    text-align: center;
    padding: 60px 20px 40px 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app-header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -2px;
    margin-bottom: 5px;
    text-transform: none;
}

.app-header p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 6px;
    font-weight: 300;
    margin-bottom: 30px;
}

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

/* Dashboard Content */
.dashboard {
    padding: 20px 40px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 40px;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
        max-width: 100%;
    }
    .app-header {
        text-align: center;
        align-items: center;
    }
}

.sensor-section {
    border-right: 1px solid var(--separator);
    padding-right: 20px;
    min-width: 0;
    overflow: hidden;
}

.sensor-section:last-child {
    border-right: none;
    padding-right: 0;
}

@media (max-width: 1024px) {
    .sensor-section {
        border-right: none;
        padding-right: 0;
        border-bottom: 4px solid #1c1c1e;
        padding-bottom: 20px;
    }
    
    .sensor-section:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
}

.section-title {
    font-size: 1.2rem;
    font-weight: 800;
    padding: 20px 20px 10px 20px;
    color: var(--text-primary);
    text-align: center;
    background-color: #111111;
    border-radius: 8px 8px 0 0;
}

.chart-card {
    border-bottom: 1px solid var(--separator);
    padding: 20px 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.chart-card:last-child {
    border-bottom: none;
}

.card-header {
    display: flex;
    align-items: center;
    padding: 0 20px 15px 20px;
    color: var(--text-primary);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 400;
}

.stats-row {
    display: flex;
    padding: 0 20px 20px 20px;
    gap: 40px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

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

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

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
    margin-top: 5px;
}

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

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

.app-footer {
    padding: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.sensor-tabs {
    display: flex;
    justify-content: space-around;
    padding: 10px 20px 20px 20px;
    border-bottom: 1px solid var(--separator);
    margin-bottom: 15px;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.3s ease, transform 0.2s ease;
    padding: 10px;
    border-radius: 12px;
}

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

.tab-btn.active {
    opacity: 1;
    transform: scale(1.05);
}

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

.stats-row {
    display: flex;
    padding: 0 20px 20px 20px;
    gap: 30px;
    align-items: center;
}

.stat-main {
    display: flex;
    flex-direction: column;
}

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

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

.stat-secondary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 80px;
}

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

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

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

.stat-label-small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-right: 10px;
}

.stat-date { 
    font-size: 0.65rem; 
    color: var(--text-secondary); 
    text-align: right; 
    margin-top: 4px; 
    letter-spacing: 0.3px;
}
.stat-divider {
    height: 1px;
    background-color: var(--separator);
    width: 100%;
    margin: 8px 0;
}
.stat-label-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: normal;
    margin-top: 8px;
    letter-spacing: 0.5px;
}

.battery-status {
    font-size: 1.0rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 25px;
    display: inline-flex;
    align-items: center;
    opacity: 0.8;
}
.battery-icon {
    width: 30px;
    height: 15px;
    border: 1.2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    position: relative;
    margin-left: 8px;
    padding: 1.5px;
}
.battery-icon::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 4px;
    width: 2px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 1.5px 1.5px 0;
}
.battery-level {
    height: 100%;
    border-radius: 1.2px;
    transition: width 0.5s ease;
}
.battery-text {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--text-primary);
}
.sensor-section.pv-full-width {
    grid-column: 1 / -1;
    border-right: none;
    padding-right: 0;
    border-top: 4px solid #1c1c1e;
    padding-top: 20px;
    min-width: 0;
    overflow: hidden;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .app-header {
        padding: 40px 15px 30px 15px;
        text-align: center;
        align-items: center;
    }
    .app-header h1 {
        font-size: 2.2rem;
        letter-spacing: -1px;
        text-align: center;
        width: 100%;
    }
    .app-header p {
        font-size: 1rem;
        letter-spacing: 4px;
        margin-bottom: 20px;
        text-align: center;
        width: 100%;
    }
    .app-header::after {
        width: 200px;
        margin: 0 auto;
    }
    .dashboard {
        padding: 10px;
        gap: 20px;
    }
    .section-title {
        text-align: center;
        width: 100%;
    }
    .chart-container {
        padding: 0 5px;
        width: 100%;
        margin: 0 auto;
        box-sizing: border-box;
    }
    .chart-card {
        width: 100%;
    }
    .sensor-section {
        width: 100%;
    }
    .sensor-section.pv-full-width {
        width: 100%;
    }
    .stats-row {
        flex-wrap: wrap !important;
        gap: 15px !important;
        padding: 0 10px 20px 10px !important;
        justify-content: center !important;
    }
    .stat-main {
        width: 100% !important;
        text-align: center;
        align-items: center;
    }
    .stat-main > div {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
    }
    .stat-main > div > div {
        padding-left: 0 !important;
        border-left: none !important;
        text-align: center;
    }
    .stat-secondary {
        padding-left: 0 !important;
        border-left: none !important;
    }
    .card-header {
        justify-content: center;
        text-align: center;
    }
    .card-header h2 {
        text-align: center;
    }
    .sensor-tabs {
        justify-content: center;
    }
}

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

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

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

.nav-btn:hover:not(:disabled) {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(17, 169, 237, 0.3);
}

.nav-btn:active:not(:disabled) {
    transform: translateY(0) 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: 180px;
    text-align: center;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Ensure symmetry */
#pv-nav-right {
    /* Use opacity instead of visibility to maintain layout symmetry if desired, 
       but here we want to allow the label to stay centered. 
       Actually, keep visibility: hidden for the right one when at today. */
}

/* Responsive adjustments for flex containers to prevent horizontal overflow */
@media (max-width: 768px) {
    .stats-row > .stat-main > div {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 15px !important;
    }
    .stats-row {
        justify-content: center !important;
    }
    /* Prevent layout overflow from container padding */
    body, html {
        overflow-x: hidden;
    }
}
