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

html,
body {
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f3f5fa;
    color: #202638;
    overflow: hidden;
}

.page {
    width: min(100%, 1760px);
    margin: 0 auto;
    background: white;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 48px rgba(28, 39, 70, 0.06);
}

.brand-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px clamp(24px, 4vw, 64px);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    flex: 0 0 auto;
}

.landing {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    align-items: center;
    overflow: hidden;
    padding: clamp(14px, 2.5vh, 32px) clamp(24px, 4vw, 64px);
    background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
}

.landing-row {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    gap: 22px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.hero,
.already-insured,
.how-it-works {
    min-width: 0;
    text-align: left;
    padding: clamp(20px, 2.2vw, 32px);
    border: 1px solid #e8ebf4;
    border-radius: 18px;
    background: white;
    box-shadow: 0 10px 30px rgba(36, 49, 87, 0.06);
}

.hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-color: #e2e7ff;
    background: linear-gradient(145deg, #f1f3ff 0%, #fafaff 100%);
}

.already-insured {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero h1 {
    max-width: 15ch;
    margin-bottom: 14px;
    color: #202744;
    font-size: clamp(26px, 2.4vw, 38px);
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.hero p {
    max-width: 42ch;
    margin-bottom: 24px;
    color: #5e667a;
    font-size: 15px;
    line-height: 1.6;
}

.carrier-search-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.carrier-search-form .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.carrier-search-form label {
    color: #555e73;
    font-size: 13px;
    font-weight: 600;
}

.carrier-search-form input,
.carrier-search-form select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #d9deea;
    border-radius: 9px;
    background: #fff;
    color: #232a3b;
    font-size: 15px;
    font-family: inherit;
}

.primary-btn {
    grid-column: 1 / -1;
    min-height: 46px;
    padding: 11px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.primary-btn:focus-visible,
.secondary-btn-lg:focus-visible,
.carrier-search-form input:focus-visible,
.carrier-search-form select:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.35);
    outline-offset: 2px;
}

.carrier-results {
    flex: 0 0 auto;
    margin-top: 14px;
    text-align: left;
    max-height: min(28vh, 280px);
    overflow-y: auto;
}

.carrier-results.hidden {
    display: none;
}

.carrier-results ul {
    list-style: none;
}

.carrier-results li {
    padding: 10px 12px;
    border: 1px solid #e5e8f0;
    border-radius: 9px;
    margin-bottom: 7px;
    font-size: 14px;
}

.carrier-results .empty-note {
    font-size: 13px;
    color: #666;
}

.already-insured h2,
.how-it-works h2 {
    margin-bottom: 12px;
    color: #252c40;
    font-size: 21px;
    letter-spacing: -0.02em;
}

.already-insured p {
    margin-bottom: 22px;
    color: #61697b;
    font-size: 14px;
    line-height: 1.65;
}

.secondary-btn-lg {
    padding: 11px 18px;
    border: 1px solid #667eea;
    color: #667eea;
    background: white;
    border-radius: 9px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.secondary-btn-lg:hover {
    background: #667eea;
    color: white;
}

.steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
}

.steps li {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 10px 12px;
    background: #f7f8fc;
    border: 1px solid #eff0f5;
    border-radius: 10px;
    font-size: 13px;
    color: #454d60;
}

.step-num {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    font-weight: 700;
    font-size: 12px;
}

.site-footer {
    text-align: center;
    padding: 12px 16px;
    font-size: 12px;
    color: #888;
    border-top: 1px solid #eee;
    flex: 0 0 auto;
}

.site-footer a {
    color: #667eea;
    text-decoration: none;
}

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

.footer-sep {
    margin: 0 6px;
}

.legal-page {
    padding: 40px 24px;
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.6;
    color: #333;
    flex: 1;
    overflow-y: auto;
    width: 100%;
}

.legal-page h1 {
    font-size: 24px;
    margin: 16px 0;
    color: #222;
}

.legal-page h2 {
    font-size: 16px;
    margin: 24px 0 8px;
    color: #222;
}

.legal-page p,
.legal-page li {
    font-size: 14px;
    color: #444;
}

.legal-page ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

.legal-page a {
    color: #667eea;
}

.legal-notice {
    background: #fff8e6;
    border: 1px solid #f0d98c;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #6b5900;
}

.back-link {
    display: inline-block;
    font-size: 13px;
    color: #667eea;
    text-decoration: none;
    margin-bottom: 8px;
}

.back-link:hover {
    text-decoration: underline;
}

.policy-analysis {
    display: flex;
    flex: 0 0 34%;
    min-height: 0;
    padding: 0 clamp(24px, 4vw, 64px) 20px;
}

.page.has-carrier-results .policy-analysis {
    flex-basis: 25%;
}

.policy-analysis:not(.has-results) .analysis-results {
    display: none;
}

.policy-analysis:not(.has-results) {
    display: none;
}

.analysis-results {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
    margin: 0;
    padding: 16px 20px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #fff;
}

.messages {
    display: block;
}

.policy-report {
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.policy-report p {
    margin: 0 0 10px;
}

.policy-report p:last-child {
    margin-bottom: 0;
}

.policy-report ol,
.policy-report ul {
    margin: 8px 0 12px;
    padding-left: 24px;
}

.policy-report li {
    margin-bottom: 6px;
}

.policy-report a {
    color: #3f5bd8;
    overflow-wrap: anywhere;
}

.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    color: #667eea;
    font-size: 14px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.upload-form {
    margin-top: 0;
}

.upload-form.has-file {
    margin-top: 8px;
}

.selected-file-name {
    color: #666;
    font-size: 11px;
    overflow-wrap: anywhere;
}

/* Responsive */
@media (max-width: 960px) {
    body {
        overflow-y: auto;
    }

    .page {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: visible;
    }

    .landing {
        flex: 0 0 auto;
    }

    .landing-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-height: 0;
        height: auto;
    }

    .how-it-works {
        grid-column: 1 / -1;
    }

    .policy-analysis {
        flex: 0 0 40vh;
        min-height: 240px;
    }
}

@media (min-width: 961px) and (max-height: 850px) {
    .brand-header {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .landing {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .landing-row {
        gap: 14px;
    }

    .hero,
    .already-insured,
    .how-it-works {
        padding: 18px;
    }

    .hero h1 {
        margin-bottom: 8px;
        font-size: clamp(24px, 2vw, 30px);
    }

    .hero p {
        margin-bottom: 12px;
        font-size: 14px;
        line-height: 1.4;
    }

    .carrier-search-form {
        gap: 10px;
    }

    .carrier-search-form input,
    .carrier-search-form select,
    .primary-btn {
        min-height: 40px;
    }

    .carrier-search-form input,
    .carrier-search-form select {
        padding: 7px 10px;
    }

    .already-insured h2,
    .how-it-works h2 {
        margin-bottom: 8px;
        font-size: 18px;
    }

    .already-insured p {
        margin-bottom: 14px;
        font-size: 13px;
        line-height: 1.45;
    }

    .secondary-btn-lg {
        padding: 9px 14px;
    }

    .steps {
        gap: 8px;
        margin-top: 12px;
    }

    .steps li {
        gap: 9px;
        padding: 7px 9px;
        font-size: 12px;
    }

    .step-num {
        width: 24px;
        height: 24px;
    }

    .site-footer {
        padding-top: 6px;
        padding-bottom: 6px;
    }
}

@media (max-width: 700px) {
    body {
        overflow: auto;
    }

    .page {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .landing {
        display: block;
        padding: 22px 18px;
    }

    .landing-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        min-height: 0;
    }

    .hero,
    .already-insured,
    .how-it-works {
        padding: 22px;
    }

    .landing-row > section {
        min-height: 0;
    }

    .hero {
        min-height: 0;
    }

    .carrier-results {
        flex: 0 0 auto;
        max-height: min(38vh, 320px);
    }

    .how-it-works {
        grid-column: auto;
    }

    .policy-analysis {
        flex-basis: 42vh;
        min-height: 220px;
        padding: 0 18px 20px;
    }

    .analysis-results {
        padding: 16px;
    }
}

@media (max-width: 380px) {
    .carrier-search-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .primary-btn {
        grid-column: auto;
    }
}
