:root {
    --primary: #00d4ff;
    --primary-dark: #00a8cc;
    --secondary: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Light theme */
[data-theme="light"] {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --secondary: #4f46e5;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --bg-dark: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] body {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 40px 20px 20px;
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.nav-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    color: var(--primary);
}

.nav-icon {
    font-size: 1.2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 48px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.5rem;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(20deg);
    border-color: var(--primary);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon {
    transition: transform 0.3s ease;
}

/* Price type toggle */
.price-type-toggle {
    margin-top: 20px;
    text-align: center;
}

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

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 60px;
    height: 30px;
    background: var(--bg-hover);
    border: 2px solid var(--border);
    border-radius: 30px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-slider {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
    border-color: var(--primary);
}

.toggle-label input:checked + .toggle-slider::before {
    transform: translateX(30px);
}

.toggle-text {
    display: flex;
    gap: 70px;
    font-weight: 600;
    font-size: 0.9rem;
}

.spot-text {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.total-text {
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.toggle-label input:checked ~ .toggle-text .spot-text {
    color: var(--text-muted);
}

.toggle-label input:checked ~ .toggle-text .total-text {
    color: var(--primary);
}

.price-info {
    margin-top: 10px;
    padding: 10px 15px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--primary);
    border-radius: 8px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.price-info small {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.input:hover {
    border-color: var(--primary-dark);
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.checkbox-group {
    margin-top: 25px;
}

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

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-label span {
    font-weight: 500;
}

.btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 212, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 2px solid var(--border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.3rem;
}

.result-highlight {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
}

.result-time {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
}

.result-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.result-detail {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

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

.stat-item {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}

.price-chart {
    background: var(--bg-dark);
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
}

.price-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.price-bar:hover {
    background: var(--bg-hover);
    transform: translateX(5px);
}

.price-time {
    font-weight: 600;
    min-width: 120px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.price-bar-fill {
    height: 30px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 6px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.price-value {
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.price-bar.cheapest .price-bar-fill {
    background: linear-gradient(90deg, var(--success) 0%, var(--primary) 100%);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.price-bar.expensive .price-bar-fill {
    background: linear-gradient(90deg, var(--warning) 0%, var(--danger) 100%);
}

/* Price table */
.price-table {
    background: var(--bg-dark);
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
}

.price-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.price-cell {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.price-cell:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.2);
}

.price-cell.cheapest {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.price-cell.expensive {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.price-cell.selected {
    border-color: var(--primary);
    background: rgba(0, 212, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.price-cell-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.price-cell-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.price-cell-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.price-cell.cheapest .price-cell-badge {
    background: var(--success);
    color: white;
}

.price-cell.expensive .price-cell-badge {
    background: var(--danger);
    color: white;
}

/* Selected periods list */
.selected-periods-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.period-item {
    background: var(--bg-dark);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.period-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.period-price {
    font-size: 1rem;
    color: var(--success);
    font-weight: 600;
}

.loading-section {
    text-align: center;
    padding: 60px 20px;
}

.loader {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.error-section {
    text-align: center;
    padding: 40px 20px;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--danger);
    border-radius: 12px;
    padding: 30px;
    display: inline-block;
}

.error-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

#error-text {
    color: var(--danger);
    font-weight: 600;
}

/* Page management */
.page {
    display: none;
}

.page.active {
    display: block;
}

.card-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Calculator specific styles */
.favorites-section {
    margin-bottom: 25px;
}

.favorites-section h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 600;
}

.appliance-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.appliance-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 10px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.appliance-btn:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.appliance-btn.preset {
    border-color: var(--secondary);
}

.appliance-btn.preset:hover {
    border-color: var(--secondary);
    background: rgba(99, 102, 241, 0.1);
}

.appliance-btn.favorite {
    border-color: var(--warning);
}

.appliance-btn.favorite:hover {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.appliance-icon {
    font-size: 1.5rem;
}

.appliance-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.appliance-watts {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.delete-favorite {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--danger);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.delete-favorite:hover {
    opacity: 1;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.calc-summary {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 25px;
}

.calc-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.calc-summary-item:last-child {
    border-bottom: none;
    padding-top: 20px;
    font-size: 1.2rem;
    font-weight: 700;
}

.calc-summary-label {
    color: var(--text-secondary);
    font-weight: 600;
}

.calc-summary-value {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.calc-periods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.calc-period-card {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.calc-period-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.calc-period-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.calc-period-value {
    font-size: 1.4rem;
    color: var(--success);
    font-weight: 700;
}

footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .card {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .price-time {
        min-width: 90px;
        font-size: 0.85rem;
    }
}
