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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000000;
    color: #ffffff;
    min-height: 100vh;
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 30px;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 10px;
    color: #ffffff;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 15px;
    color: #cccccc;
}

.last-update {
    font-size: 0.9rem;
    opacity: 0.7;
    color: #999999;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #cccccc;
}

.control-group select,
.control-group input {
    padding: 8px 15px;
    border: 1px solid #333333;
    border-radius: 8px;
    background: #1a1a1a;
    color: white;
    font-size: 0.9rem;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.control-group select option {
    background: #1a1a1a;
    color: white;
}

.control-group input::placeholder {
    color: #666666;
}

.chart-container {
    background: #111111;
    border: 1px solid #333333;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    position: relative;
}

#energyChart {
    width: 100%;
    height: 600px;
}

.data-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.info-card {
    background: #111111;
    border: 1px solid #333333;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.info-card h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 500;
    color: #ffffff;
}

.info-card div {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #cccccc;
}

.price-current {
    font-size: 2rem;
    font-weight: bold;
    color: #4ade80;
}

.price-high { color: #ef4444; }
.price-medium { color: #f59e0b; }
.price-low { color: #4ade80; }

/* Live Data Panel Styling */
.live-data-card {
    border-left: 4px solid #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.live-data-card h3 {
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-current-price {
    text-align: center;
    margin: 15px 0;
    padding: 15px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.live-current-price .price-current {
    font-size: 2.5rem;
    font-weight: bold;
    color: #10b981;
    line-height: 1;
}

.live-current-price .price-unit {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-top: 5px;
}

.live-current-price .price-time {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 8px;
    font-style: italic;
}

.price-unavailable {
    color: #f59e0b;
    font-style: italic;
    padding: 20px;
}

.live-stats {
    margin: 15px 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: #94a3b8;
    font-size: 0.9rem;
}

.stat-row span:last-child {
    color: #ffffff;
    font-weight: 500;
}

.live-update-time {
    font-size: 0.8rem;
    color: #6b7280;
    text-align: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.live-error {
    text-align: center;
    padding: 20px;
    color: #ef4444;
}

.error-details {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 5px;
}

/* Live Data Controls - Integrated into Chart below Legend */
.live-data-controls {
    position: absolute;
    /* Position will be set dynamically by JavaScript */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: rgba(17, 17, 17, 0.95);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    backdrop-filter: blur(10px);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    min-width: 150px;
}

.live-data-controls #end-period {
    background: #1a1a1a;
    border: 1px solid #444444;
    border-radius: 6px;
    padding: 8px 16px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.live-data-controls #end-period:hover {
    border-color: #10b981;
    background: #242424;
}

.live-data-controls #end-period:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.live-data-controls #end-period option {
    background: #1a1a1a;
    color: #ffffff;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    accent-color: #10b981;
    transform: scale(1.2);
}

.toggle-text {
    color: #ffffff;
    font-weight: 500;
}

.refresh-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
}

.refresh-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Live comparison styling */
.live-comparison {
    background: rgba(16, 185, 129, 0.1);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #10b981;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Date/Time Controls Styling */
.datetime-controls {
    background: rgba(17, 17, 17, 0.8);
    border: 1px solid #333333;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
}

.time-range-section h4 {
    color: #ffffff;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Simple Range Controls Styling */
.simple-range-controls {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #444444;
    margin-bottom: 15px;
}

.range-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.range-input-group {
    display: flex;
    flex-direction: column;
}

.range-input-group label {
    color: #cccccc;
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.range-input-group select {
    background: #1a1a1a;
    border: 1px solid #444444;
    border-radius: 6px;
    padding: 10px;
    color: #ffffff;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.range-input-group select:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.range-input-group select option {
    background: #1a1a1a;
    color: #ffffff;
}

.range-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Responsive adjustments for simple controls */
@media (max-width: 768px) {
    .range-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .range-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .apply-btn,
    .reset-btn {
        width: 100%;
        max-width: 200px;
    }
}

.apply-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.apply-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.reset-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
}

/* Range Info Display */
.range-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    color: #60a5fa;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Time Range Display in Live Panel */
.time-range-display {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    text-align: center;
}

.time-range-title {
    color: #60a5fa;
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.time-range-dates {
    color: #ffffff;
    font-size: 0.8rem;
    line-height: 1.3;
    margin-bottom: 5px;
}

.time-range-duration {
    color: #94a3b8;
    font-size: 0.8rem;
    font-style: italic;
}

/* Loading Indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #60a5fa;
    font-size: 1.1rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 25px;
    border-radius: 10px;
    border: 1px solid #60a5fa;
    z-index: 10;
}

/* Animation for live data updates */
.live-data-card.updating {
    animation: pulse-green 1s ease-in-out;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
    }
    100% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }
}

/* Status indicator for live data */
.live-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    margin-left: 5px;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard {
        padding: 15px;
    }
    
    .dashboard-header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    #energyChart {
        height: 400px;
    }
    
    .live-data-controls {
        position: static;
        margin: 0 auto 15px;
        max-width: fit-content;
    }
    
    .live-current-price .price-current {
        font-size: 2rem;
    }
    
    .stat-row {
        font-size: 0.85rem;
    }
    
    .range-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .range-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .apply-btn,
    .reset-btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .datetime-controls {
        padding: 15px;
        margin: 15px 0;
    }
    
    .time-range-section h4 {
        font-size: 1rem;
    }
    
    .quick-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .datetime-input-group input[type="datetime-local"] {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Focus states for accessibility */
.quick-btn:focus,
.apply-btn:focus,
.reset-btn:focus {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

.datetime-input-group input[type="datetime-local"]:focus {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .datetime-input-group input[type="datetime-local"] {
        color-scheme: dark;
        background: #0f0f0f;
        border-color: #555555;
    }
    
    .datetime-input-group input[type="datetime-local"]::-webkit-calendar-picker-indicator {
        filter: invert(1);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .datetime-controls {
        border-width: 2px;
        border-color: #ffffff;
    }
    
    .quick-btn {
        border-width: 2px;
    }
    
    .quick-btn.active {
        background: #0066cc;
        border-color: #ffffff;
    }
    
    .datetime-input-group input[type="datetime-local"] {
        border-width: 2px;
        border-color: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .quick-btn,
    .apply-btn,
    .reset-btn,
    .custom-range-inputs {
        transition: none;
    }
    
    .apply-btn:hover,
    .reset-btn:hover {
        transform: none;
    }
}

/* Error notification styles */
.error-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 450px;
    background: #1a1a1a;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

.error-notification.warning {
    border-left-color: #f59e0b;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.error-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.error-content {
    flex: 1;
    min-width: 0;
}

.error-message {
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.4;
}

.error-technical {
    color: #9ca3af;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    word-break: break-word;
}

.error-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.error-close:hover {
    color: #ffffff;
}

/* Print styles */
@media print {
    .datetime-controls {
        display: none;
    }
    .error-notification {
        display: none;
    }
}

/* Progressive enhancement loading fallback */
.chart-loading-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #ffffff;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(96, 165, 250, 0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chart-loading-fallback p {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Hide fallback once chart is initialized */
.chart-initialized .chart-loading-fallback {
    display: none;
}