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

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-alt: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #facc15;
    --accent-dim: #a16207;
    --orange: #fb923c;
    --green: #4ade80;
    --blue: #38bdf8;
    --red: #f87171;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(180deg, #1a2744 0%, var(--bg) 100%);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.25rem;
}

header .date {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Solar Score Ring */
.solar-score-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 1rem;
}

.solar-score-ring {
    position: relative;
    width: 160px;
    height: 160px;
}

.solar-score-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--surface-alt);
    stroke-width: 10;
}

.ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
    transition: stroke-dashoffset 1s ease, stroke 0.5s ease;
}

.score-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 400px;
}

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.metric-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
}

.metric-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Sun Times Bar */
.sun-times {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.sun-bar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.sun-endpoint {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

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

.sun-time {
    font-size: 1.1rem;
    font-weight: 600;
}

.sun-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.sun-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sun-progress-track {
    position: relative;
    height: 8px;
    background: var(--surface-alt);
    border-radius: 4px;
    overflow: visible;
}

.sun-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), var(--accent), var(--orange));
    border-radius: 4px;
    width: 0;
    transition: width 1s ease;
}

.sun-marker {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    transition: left 1s ease;
    filter: drop-shadow(0 0 4px rgba(250, 204, 21, 0.6));
    display: none;
}

.daylight-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Chart */
.chart-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.chart-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}

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

/* Breakdown */
.breakdown-section {
    padding: 0;
}

.breakdown-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.breakdown-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.breakdown-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.breakdown-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.breakdown-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* Forecast Table */
.forecast-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.forecast-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--surface-alt);
    white-space: nowrap;
}

tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.4);
    white-space: nowrap;
}

tbody tr:hover {
    background: rgba(250, 204, 21, 0.04);
}

tbody tr.current-hour {
    background: rgba(250, 204, 21, 0.1);
    font-weight: 600;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

footer a {
    color: var(--blue);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Loading state */
.loading {
    opacity: 0.5;
}

/* Battery Calculator Section */
.battery-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    border: 1px solid var(--surface-alt);
}

.battery-header {
    text-align: center;
    margin-bottom: 2rem;
}

.battery-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.battery-intro {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 600px;
    margin: 0 auto;
}

.battery-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.battery-inputs h3,
.season-toggle-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.input-group {
    margin-bottom: 0.875rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.rate-hint {
    font-weight: 400;
    font-size: 0.7rem;
    opacity: 0.7;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--surface-alt);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.calc-button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 0.5rem;
}

.calc-button:hover {
    opacity: 0.9;
}

/* Battery Results */
.battery-results {
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.results-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    gap: 0.75rem;
    padding: 2rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px dashed var(--surface-alt);
}

.results-placeholder-icon {
    font-size: 2rem;
}

.results-active {
    gap: 0.75rem;
}

.result-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.result-icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.result-info {
    flex: 1;
}

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

.result-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.result-value.savings {
    color: var(--green);
}

.result-value.warning {
    color: var(--orange);
}

.result-value.battery-size {
    color: var(--blue);
}

.result-value.payback {
    color: var(--accent);
}

/* Product Comparison Cards */
.products-comparison {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.product-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    border: 1px solid var(--surface-alt);
    position: relative;
    transition: border-color 0.2s, transform 0.2s;
}

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

.product-best {
    border-color: var(--product-color);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.1);
}

.product-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: var(--bg);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.product-tier {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--product-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.product-capacity {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--product-color);
    margin-bottom: 0.15rem;
}

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

.product-price-per {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.product-stats {
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    border-top: 1px solid var(--surface-alt);
    border-bottom: 1px solid var(--surface-alt);
    margin-bottom: 0.75rem;
}

.product-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.product-stat-value {
    font-size: 1rem;
    font-weight: 700;
}

.product-stat-value.savings {
    color: var(--green);
}

.product-stat-value.payback {
    color: var(--accent);
}

.product-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 0.1rem;
}

.product-highlight {
    font-size: 0.75rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.product-warranty {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.result-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Season Toggle */
.season-toggle-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--surface-alt);
}

.season-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.season-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 1px solid var(--surface-alt);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.season-btn.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 700;
}

.season-btn:hover:not(.active) {
    border-color: var(--accent-dim);
    color: var(--text);
}

.season-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.season-stat {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.season-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.season-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Money Shot */
.money-shot {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.money-shot-card {
    text-align: center;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    min-width: 140px;
}

.money-shot-card.sell {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.money-shot-card.buy {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.money-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.money-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--red);
}

.money-shot-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.money-shot-gap {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.money-shot-gap strong {
    color: var(--accent);
    font-size: 1.1rem;
}

/* Quote Form */
.quote-form-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--surface-alt);
}

.quote-form-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--green);
    margin-bottom: 0.5rem;
}

.quote-intro {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.quote-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    line-height: 1.5;
}

.quote-submit {
    padding: 0.75rem;
    background: var(--green);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.quote-submit:hover {
    opacity: 0.9;
}

.quote-success {
    text-align: center;
    padding: 2rem;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--green);
    color: var(--bg);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.quote-success h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.quote-success p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 640px) {
    header h1 {
        font-size: 1.5rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .sun-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .sun-endpoint {
        flex-direction: row;
        gap: 0.5rem;
    }

    .sun-progress-container {
        width: 100%;
    }

    .products-comparison {
        grid-template-columns: 1fr;
    }

    .battery-layout {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .season-results {
        grid-template-columns: 1fr;
    }

    .money-shot {
        flex-direction: column;
    }

    .money-shot-arrow {
        transform: rotate(90deg);
    }
}
