:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-bg: #eef2ff;
    --accent-light: #c7d2fe;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    overflow-x: hidden;
}

h1:focus, h2:focus, h3:focus {
    outline: none;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

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

/* Hero Section */
.hero-section {
    padding: 4rem 0 3rem;
    text-align: center;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 50%, #c7d2fe 100%);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.hero-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
    animation: pulse 8s ease-in-out infinite;
    pointer-events: none;
}

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

.hero-content {
    position: relative;
    z-index: 1;
    margin-bottom: 2.5rem;
}

.hero-badge {
    display: inline-block;
    padding: 0.375rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0 0 1rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Search Card */
.search-card {
    position: relative;
    z-index: 10;
    max-width: 640px;
    margin: 0 auto;
}

.search-card-inner {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-btn:hover:not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.search-btn:active:not(.disabled) {
    transform: translateY(0);
}

.search-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Banners */
.error-banner, .warning-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    font-size: 0.9375rem;
}

.error-banner {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.warning-banner {
    background: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Results Section */
.results-section {
    padding: 3rem 0;
}

.results-header {
    margin-bottom: 1.5rem;
}

.results-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.results-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.network-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.network-badge.success {
    background: var(--success-bg);
    color: #065f46;
}

.network-badge.muted {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.empty-state svg {
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.empty-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Loading State */
.loading-state {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.loading-pulse {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Offers Grid */
.offers-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.speed-group {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: visible;
}

.speed-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.speed-group-title {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.speed-value {
    color: var(--accent-primary);
}

.speed-unit {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.speed-group-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.offers-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1px;
    background: var(--border-color);
}

.offers-row > * {
    background: var(--bg-card);
}

/* Provider Pill Logo */
.provider-pill-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}

/* Form Elements */
.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-outline-primary {
    background: transparent;
    color: var(--accent-primary);
    border-color: var(--border-color);
}

.btn-outline-primary:hover {
    background: var(--accent-bg);
    border-color: var(--accent-primary);
}

.rounded-pill {
    border-radius: 999px !important;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
}

.badge.bg-success {
    background: var(--success-bg) !important;
    color: #065f46 !important;
}

.badge.bg-warning {
    background: var(--warning-bg) !important;
    color: #92400e !important;
}

.badge.bg-light {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
}

/* Address Suggestions */
.address-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
}

.list-group-item {
    display: block;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.list-group-item:hover {
    background: var(--bg-secondary);
}

.list-group-item .fw-semibold {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.list-group-item small {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Alert Light */
.alert-light {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Spinner */
.spinner-border {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Blazor Error UI */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Loader */
.loader-container {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--bg-primary);
}

.loader-content {
    position: relative;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loader-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 180px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: var(--shadow-xl);
    animation: logoPulse 2s ease-in-out infinite;
}

.loader-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.loader-text {
    margin-top: 2rem;
    text-align: center;
    min-width: 260px;
    max-width: 90vw;
}

.loading-percentage {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.loading-percentage::after {
    content: var(--blazor-load-percentage-text, "0%");
}

.loading-messages {
    position: relative;
    height: 1.5em;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.loading-messages span {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    white-space: nowrap;
    animation: messageCycle 12s linear infinite;
}

.loading-messages span:nth-child(1) { animation-delay: 0s; }
.loading-messages span:nth-child(2) { animation-delay: 2.4s; }
.loading-messages span:nth-child(3) { animation-delay: 4.8s; }
.loading-messages span:nth-child(4) { animation-delay: 7.2s; }
.loading-messages span:nth-child(5) { animation-delay: 9.6s; }

@keyframes messageCycle {
    0%, 18% { opacity: 1; }
    22%, 100% { opacity: 0; }
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); box-shadow: var(--shadow-xl); }
    50% { transform: scale(1.03); box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.25); }
}

/* Loader - mobile */
@media (max-width: 480px) {
    .loader-logo-wrap {
        width: 130px;
        height: 130px;
    }

    .loader-text {
        margin-top: 1.5rem;
        min-width: unset;
        width: 90vw;
    }

    .loading-percentage {
        font-size: 1.5rem;
    }

    .loading-messages {
        font-size: 0.8rem;
    }
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.25rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero-section {
        padding: 3rem 0 2rem;
    }

    .results-title {
        font-size: 1.375rem;
    }

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

/* Compare Page */
.compare-section {
    padding: 3rem 0;
}

.compare-prompt {
    text-align: center;
    margin-bottom: 2rem;
}

.compare-prompt-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.compare-prompt-sub {
    color: var(--text-muted);
    margin: 0;
}

.deals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

/* Comparison Result */
.comparison-result {
    padding: 3rem 0 4rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.comp-cell.header-deal-a {
    background: var(--accent-primary) !important;
    color: white !important;
}

.comp-cell.header-deal-b {
    background: #8b5cf6 !important;
    color: white !important;
}

.comparison-result-title {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 2rem;
}

/* Verdicts */
.verdict-title {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 1.5rem;
    text-align: center;
}

.verdict-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.verdict-summary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.verdict-summary h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
}

.summary-list {
    margin: 0;
    padding-left: 1.25rem;
    list-style: disc;
}

.summary-list li {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.375rem;
}

.summary-list li:last-child {
    margin-bottom: 0;
}

.summary-list li strong {
    color: var(--text-primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .deals-grid {
        grid-template-columns: 1fr;
    }

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

/* Dev Override */
.search-card-inner {
    position: relative;
}

.dev-override-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.dev-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #f59e0b;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.dev-info {
    font-size: 0.8125rem;
    color: #92400e;
    flex: 1;
}

/* Site Footer */
.site-footer {
    background: #ffffff;
    color: var(--text-secondary);
    padding: 1.5rem 0 0;
    border-top: 2px solid var(--accent-primary);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    gap: 1.25rem 2rem;
    padding-bottom: 1.25rem;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.footer-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
}

.footer-brand-text {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.footer-brand-highlight {
    color: var(--accent-primary);
}

.footer-tagline {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.55;
    color: #64748b;
    max-width: 30ch;
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.footer-heading {
    margin: 0 0 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.footer-col a {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    width: fit-content;
}

.footer-col a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: #64748b;
}

.footer-disclaimer {
    font-style: italic;
}

@media (max-width: 768px) {
    .site-footer {
        padding: 1rem 0 0;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        padding-bottom: 0.75rem;
    }

    .footer-brand-col {
        grid-column: 1 / -1;
    }

    .footer-brand {
        margin-bottom: 0;
    }

    .footer-tagline {
        display: none;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.625rem 0;
    }
}
