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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
}

.container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,.10);
    padding: 40px;
    width: 100%;
    max-width: 620px;
}

h1 {
    font-size: 1.5rem;
    color: #1a202c;
    margin-bottom: 6px;
}

.subtitle {
    font-size: .875rem;
    color: #718096;
    margin-bottom: 28px;
}

label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px;
}

.input-row {
    display: flex;
    gap: 10px;
}

input[type="text"] {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1rem;
    color: #2d3748;
    outline: none;
    transition: border-color .2s;
}

input[type="text"]:focus {
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66,153,225,.15);
}

button {
    padding: 11px 20px;
    background: #3182ce;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s;
}

button:hover { background: #2b6cb0; }

/* Result card */
.result-card {
    margin-top: 28px;
    border: 1px solid #bee3f8;
    border-radius: 10px;
    background: #ebf8ff;
    overflow: hidden;
}

.result-card .card-header {
    background: #3182ce;
    color: #fff;
    padding: 12px 20px;
    font-weight: 700;
    font-size: .95rem;
}

.result-card .card-body { padding: 20px; }

.result-matched {
    font-size: .8rem;
    color: #718096;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #bee3f8;
}

.result-matched span { font-weight: 600; color: #4a5568; }

/* ── Permit Jurisdiction Banner ── */
.permit-banner {
    background: #f0fff4;
    border: 2px solid #48bb78;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.permit-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #718096;
    font-weight: 700;
    margin-bottom: 4px;
}

.permit-jurisdiction {
    font-size: 1.35rem;
    font-weight: 800;
    color: #276749;
    line-height: 1.2;
    margin-bottom: 6px;
}

.permit-detail {
    font-size: .82rem;
    color: #4a5568;
    line-height: 1.4;
    margin-bottom: 12px;
}

.permit-detail strong { color: #276749; }

/* Contact row */
.dept-contact {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.dept-phone {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .95rem;
    font-weight: 700;
    color: #276749;
    text-decoration: none;
    padding: 6px 14px;
    background: #c6f6d5;
    border-radius: 6px;
    transition: background .2s;
}

.dept-phone:hover { background: #9ae6b4; }

.dept-link {
    font-size: .85rem;
    color: #2b6cb0;
    text-decoration: none;
    padding: 6px 14px;
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    border-radius: 6px;
    transition: background .2s;
}

.dept-link:hover { background: #bee3f8; }

/* Permit search action */
.permit-action {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-permit-search {
    display: inline-block;
    padding: 12px 24px;
    background: #276749;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: background .2s;
}

.btn-permit-search:hover { background: #22543d; }

.permit-no-portal {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.permit-no-portal-label {
    font-size: .85rem;
    color: #718096;
    font-weight: 600;
}

.btn-call-dept {
    display: inline-block;
    padding: 10px 20px;
    background: #ed8936;
    color: #fff;
    font-size: .95rem;
    font-weight: 700;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: background .2s;
}

.btn-call-dept:hover { background: #dd6b20; }

.permit-action-note {
    font-size: .75rem;
    color: #a0aec0;
}

/* ── Property Details Card ── */
.property-card {
    border: 1px solid #bee3f8;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.property-header {
    background: #2b6cb0;
    color: #fff;
    padding: 10px 20px;
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.property-body { padding: 16px 20px; }

.property-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
}

.property-item {}

.property-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #a0aec0;
    font-weight: 700;
    margin-bottom: 2px;
}

.property-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #2b6cb0;
}

.property-source {
    font-size: .7rem;
    color: #a0aec0;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
    margin-top: 4px;
}

/* ── Building Codes Card ── */
.codes-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.codes-header {
    background: #2d3748;
    color: #fff;
    padding: 10px 20px;
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.codes-body { padding: 16px 20px; }

.codes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.code-item {}

.code-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #a0aec0;
    font-weight: 700;
    margin-bottom: 2px;
}

.code-value {
    font-size: .9rem;
    font-weight: 700;
    color: #2d3748;
}

/* Roofing section */
.roofing-section {
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
}

.roofing-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #4a5568;
    margin-bottom: 10px;
}

.roofing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.roofing-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.roofing-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #a0aec0;
    font-weight: 600;
}

.roofing-value {
    font-size: .9rem;
    font-weight: 700;
    color: #2d3748;
}

.roofing-value.yes {
    color: #276749;
}

.roofing-value.no {
    color: #c53030;
}

.roofing-value.conditional {
    color: #d69e2e;
    font-weight: 600;
}

.roofing-note {
    font-size: .8rem;
    color: #4a5568;
    line-height: 1.5;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 6px;
    border-left: 3px solid #cbd5e0;
}

/* Last verified */
.last-verified {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
    font-size: .75rem;
    color: #a0aec0;
    text-align: right;
}

.last-verified.stale {
    color: #c53030;
    font-weight: 600;
    background: #fff5f5;
    padding: 8px 12px;
    border-radius: 6px;
    border-top: none;
    text-align: left;
}

.roofing-note.note-important {
    background: #fffff0;
    border-left-color: #d69e2e;
    color: #744210;
}

/* ── Knowledge Base Card ── */
.kb-card {
    border: 1px solid #c3dafe;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.kb-header {
    background: #5a67d8;
    color: #fff;
    padding: 10px 20px;
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.kb-body { padding: 16px 20px; }

.kb-entry {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
}

.kb-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.kb-entry-name {
    font-size: .9rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 4px;
}

.kb-entry-info {
    font-size: .8rem;
    color: #718096;
    margin-bottom: 8px;
    line-height: 1.4;
}

.kb-files {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kb-file-link {
    display: inline-flex;
    align-items: center;
    font-size: .85rem;
    color: #5a67d8;
    text-decoration: none;
    padding: 6px 12px;
    background: #ebf4ff;
    border: 1px solid #c3dafe;
    border-radius: 6px;
    transition: background .2s;
}

.kb-file-link:hover {
    background: #c3dafe;
    color: #434190;
}

.kb-uploads { margin-top: 10px; }

.kb-uploads-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #718096;
    margin-bottom: 6px;
}

.kb-upload-link {
    background: #f7fafc;
    border-color: #e2e8f0;
    color: #4a5568;
}

.kb-upload-link:hover {
    background: #edf2f7;
    color: #2d3748;
}

/* ── Scope Defender Toggle ── */
.sd-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    margin-left: 12px;
    user-select: none;
}

.sd-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #5a67d8;
    cursor: pointer;
}

/* ── Address Info Grid ── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.info-item label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #a0aec0;
    font-weight: 700;
    margin-bottom: 3px;
}

.info-item .value {
    font-size: 1rem;
    font-weight: 700;
    color: #2d3748;
}

.info-item .value.highlight {
    color: #2b6cb0;
    font-size: 1.1rem;
}


/* ── Error ── */
.error-card {
    margin-top: 24px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 10px;
    padding: 16px 20px;
    color: #c53030;
    font-size: .9rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.error-icon {
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
    background: #c53030;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ── Print Header (hidden on screen) ── */
.print-header {
    display: none;
}

/* Print Actions */
.print-actions {
    margin-top: 20px;
    margin-bottom: -8px;
    text-align: right;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-download {
    padding: 9px 18px;
    background: #276749;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}

.btn-download:hover { background: #22543d; }
.btn-download:disabled { background: #a0aec0; cursor: wait; }

.btn-print {
    padding: 9px 18px;
    background: #718096;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}

.btn-print:hover { background: #4a5568; }

/* ── Print Styles ── */
@media print {
    .no-print,
    form,
    .subtitle,
    h1,
    .cache-badge {
        display: none !important;
    }

    body {
        background: #fff;
        padding: 0;
        display: block;
        font-size: 11pt;
    }

    .container {
        box-shadow: none;
        padding: 0 20px;
        max-width: 100%;
        border-radius: 0;
    }

    .print-header {
        display: block;
        margin-bottom: 24px;
        page-break-inside: avoid;
    }

    .print-header-top {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding-bottom: 14px;
        border-bottom: 3px solid #1a365d;
        margin-bottom: 12px;
    }

    .print-company-name {
        font-size: 1.5rem;
        font-weight: 800;
        color: #1a365d;
        letter-spacing: -0.01em;
    }

    .print-company-tagline {
        font-size: .85rem;
        color: #4a5568;
        font-weight: 600;
        margin-top: 2px;
    }

    .print-date {
        text-align: right;
    }

    .print-date-label {
        font-size: .65rem;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: #718096;
        font-weight: 700;
    }

    .print-date-value {
        font-size: .95rem;
        font-weight: 700;
        color: #1a365d;
    }

    .print-date-time {
        font-size: .75rem;
        color: #718096;
    }

    .print-address-bar {
        background: #edf2f7;
        border: 1px solid #cbd5e0;
        border-radius: 6px;
        padding: 12px 18px;
        font-size: .95rem;
        color: #1a202c;
        font-weight: 600;
    }

    .result-card {
        border: none;
        background: #fff;
        margin-top: 0;
    }

    .result-card .card-header {
        display: none;
    }

    .result-card .card-body {
        padding: 0;
    }

    .result-matched {
        display: none;
    }

    /* Permit banner — clean professional look */
    .permit-banner {
        border: 2px solid #276749;
        border-radius: 8px;
        background: #f0fff4;
        padding: 18px;
    }

    .permit-jurisdiction {
        font-size: 1.3rem;
        color: #276749;
    }

    .dept-contact {
        margin-bottom: 10px;
    }

    .dept-phone {
        background: transparent;
        padding: 0;
        color: #2d3748;
        font-weight: 600;
        font-size: .9rem;
    }

    .dept-link {
        background: transparent;
        border: none;
        padding: 0;
        color: #2b6cb0;
        font-size: .85rem;
    }

    /* Hide action buttons in print — just show info */
    .permit-action .btn-permit-search,
    .permit-action .btn-call-dept {
        display: inline-block;
        background: #fff !important;
        color: #1a365d !important;
        border: 1.5px solid #1a365d;
        font-size: .85rem;
        padding: 8px 16px;
    }

    .permit-action-note {
        display: none;
    }

    /* Property card */
    .property-card {
        border: 1.5px solid #2b6cb0;
        border-radius: 8px;
        margin-bottom: 16px;
    }

    .property-header {
        background: #2b6cb0;
        padding: 8px 18px;
        font-size: .8rem;
    }

    .property-value {
        font-size: 1.05rem;
        color: #1a365d;
    }

    /* Codes card */
    .codes-card {
        border: 1.5px solid #2d3748;
        border-radius: 8px;
        margin-bottom: 16px;
    }

    .codes-header {
        background: #1a365d;
        padding: 8px 18px;
        font-size: .8rem;
    }

    .roofing-value.yes {
        color: #276749;
        font-weight: 800;
    }

    .roofing-value.no {
        color: #9b2c2c;
        font-weight: 700;
    }

    .roofing-value.conditional {
        color: #b7791f;
        font-weight: 700;
    }

    .roofing-note {
        font-size: .78rem;
        background: #f7fafc;
        border-left: 3px solid #a0aec0;
        padding: 6px 10px;
        margin-top: 6px;
    }

    /* KB card */
    .kb-card {
        border: 1.5px solid #5a67d8;
        border-radius: 8px;
        margin-bottom: 16px;
    }

    .kb-header {
        background: #434190;
        padding: 8px 18px;
        font-size: .8rem;
    }

    .kb-file-link {
        background: transparent;
        border: 1px solid #a0aec0;
        color: #2d3748;
        font-size: .8rem;
        padding: 4px 10px;
        text-decoration: underline;
    }

    .kb-upload-link {
        border-color: #e2e8f0;
        color: #4a5568;
    }

    .kb-uploads-label {
        font-size: .7rem;
    }

    .kb-card {
        page-break-inside: avoid;
    }

    /* Address info grid */
    .info-grid {
        border: 1.5px solid #e2e8f0;
        border-radius: 8px;
        padding: 14px 18px;
        gap: 10px;
    }

    .info-item .value.highlight {
        color: #1a365d;
    }

    a { text-decoration: none; }

    /* Auto-research disclaimer */
    .last-verified {
        font-size: .72rem;
    }
}

/* ── PDF Download Rendering (applied temporarily during capture) ── */
.pdf-rendering .print-header {
    display: block;
    margin-bottom: 20px;
}

.pdf-rendering .print-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 3px solid #1a365d;
    margin-bottom: 12px;
}

.pdf-rendering .print-company-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1a365d;
}

.pdf-rendering .print-company-tagline {
    font-size: .85rem;
    color: #4a5568;
    font-weight: 600;
    margin-top: 2px;
}

.pdf-rendering .print-date { text-align: right; }
.pdf-rendering .print-date-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: #718096; font-weight: 700; }
.pdf-rendering .print-date-value { font-size: .95rem; font-weight: 700; color: #1a365d; }
.pdf-rendering .print-date-time { font-size: .75rem; color: #718096; }

.pdf-rendering .print-address-bar {
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 12px 18px;
    font-size: .95rem;
    color: #1a202c;
    font-weight: 600;
}

.pdf-rendering .no-print { display: none !important; }
.pdf-rendering .result-card .card-header { display: none; }
.pdf-rendering .result-card { border: none; background: #fff; }
.pdf-rendering .result-card .card-body { padding: 0; }
.pdf-rendering .result-matched { display: none; }
.pdf-rendering .cache-badge { display: none; }

.pdf-rendering .permit-banner {
    border: 2px solid #276749;
    border-radius: 8px;
    background: #f0fff4;
}

.pdf-rendering .permit-action-note { display: none; }
.pdf-rendering .dept-phone { background: transparent; padding: 0; color: #2d3748; }

.pdf-rendering .codes-header { background: #1a365d; }

/* KB card — PDF rendering */
.pdf-rendering .kb-header { background: #434190; }

.pdf-rendering .kb-card {
    border: 2px solid #5a67d8;
    border-radius: 8px;
    page-break-inside: avoid;
}

.pdf-rendering .kb-file-link {
    background: transparent;
    border: 1px solid #c3dafe;
    color: #434190;
    font-size: .8rem;
    padding: 5px 12px;
    text-decoration: underline;
}

.pdf-rendering .kb-upload-link {
    border-color: #e2e8f0;
    color: #4a5568;
}

.pdf-rendering .kb-uploads-label {
    font-size: .7rem;
    color: #718096;
}

.pdf-rendering .kb-entry-info {
    font-size: .75rem;
}

.pdf-rendering .info-grid {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 18px;
}

/* Cached result badge */
.cache-badge {
    display: inline-block;
    font-size: 11px;
    background: #f6e05e;
    color: #744210;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
    vertical-align: middle;
}
