:root {
    --rn-red: #bb312e;
    --rn-red-dark: #8d211f;
    --rn-red-deep: #a52826;
    --rn-black: #111111;
    --rn-charcoal: #1b1b1d;
    --rn-cream: #f4f0e8;
    --rn-cream-light: #fbf8f2;
    --rn-card: #ffffff;
    --rn-soft: #f6f2ec;
    --rn-tan: #d7c7ae;
    --rn-text: #171717;
    --rn-muted: #666666;
    --rn-border: rgba(17, 17, 17, 0.12);
    --shadow: 0 18px 45px rgba(17, 17, 17, 0.16);
    --shadow-soft: 0 12px 28px rgba(17, 17, 17, 0.10);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--rn-text);
    background: var(--rn-cream);
}

body {
    line-height: 1.45;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.page-shell {
    width: 100%;
    min-height: 100vh;
    padding: 0 0 42px;
}

.site-header {
    width: 100%;
    min-height: 116px;
    padding: 18px clamp(18px, 5vw, 54px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 26px;
    background: var(--rn-red);
    color: #fff;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.12);
    position: relative;
    z-index: 10;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
    color: inherit;
    text-decoration: none;
}

.brand-logo-shell {
    position: relative;
    width: 112px;
    min-width: 112px;
    min-height: 82px;
    display: grid;
    place-items: center;
    background: #f7f2e9;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.brand-logo {
    width: 96px;
    max-height: 72px;
    object-fit: contain;
    display: block;
}

.brand-logo-fallback {
    display: none;
    width: 70px;
    height: 70px;
    border-radius: 16px;
    place-items: center;
    background: linear-gradient(135deg, var(--rn-red), var(--rn-red-dark));
    color: #fff;
    font-size: 1.35rem;
    font-weight: 950;
    letter-spacing: -0.06em;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.24);
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.logo-fallback-on .brand-logo-fallback {
    display: grid;
}

.site-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: clamp(18px, 3vw, 32px);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.site-nav a,
.footer-nav a {
    color: inherit;
    text-decoration: none;
}

.site-nav a {
    color: #fff;
    opacity: 0.98;
}

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

.site-nav .nav-cta {
    font-weight: 900;
}

.estimator-hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(17, 17, 17, 0.76), rgba(17, 17, 17, 0.46)),
        linear-gradient(135deg, #28221f 0%, #1b1b1d 48%, var(--rn-red-dark) 48%, var(--rn-red) 100%);
    border-bottom: 1px solid rgba(17, 17, 17, 0.12);
}

.estimator-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 14px),
        radial-gradient(circle at 82% 16%, rgba(255, 255, 255, 0.16), transparent 22rem);
    pointer-events: none;
}

.estimator-hero-content {
    position: relative;
    width: min(1560px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0 42px;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--rn-red);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.76rem;
    font-weight: 900;
}

.estimator-hero .eyebrow {
    color: #f7d8d6;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(2.1rem, 5.2vw, 4rem);
    letter-spacing: -0.055em;
    line-height: 0.98;
    font-weight: 950;
}

.estimator-hero p:last-child {
    max-width: 760px;
    margin: 0;
    font-size: clamp(1rem, 2vw, 1.28rem);
    color: rgba(255, 255, 255, 0.86);
}

h2 {
    margin-bottom: 8px;
    font-size: 1.22rem;
    letter-spacing: -0.025em;
}

.muted {
    color: var(--rn-muted);
    margin-bottom: 16px;
}

.estimator-layout {
    width: min(1560px, calc(100% - 32px));
    margin: 24px auto 0;
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}

.panel,
.map-panel {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.control-panel {
    background: rgba(255, 255, 255, 0.97);
    padding: 24px;
    max-height: clamp(560px, calc(100vh - 240px), 760px);
    overflow: auto;
    border: 1px solid rgba(187, 49, 46, 0.12);
}

.map-panel {
    position: relative;
    overflow: hidden;
    min-height: clamp(560px, calc(100vh - 240px), 760px);
    background: #d9d9d9;
    border: 1px solid rgba(187, 49, 46, 0.20);
}

#map {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#map .gm-style > div:first-child {
    transform: scale(var(--map-visual-scale, 1));
    transform-origin: center center;
}

.map-panel.artificial-zoom-active {
    border-color: rgba(187, 49, 46, 0.45);
}

.map-overlay {
    position: absolute;
    z-index: 30;
    background: rgba(255, 255, 255, 0.94);
    color: var(--rn-text);
    border: 1px solid var(--rn-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 0.9rem;
    max-width: min(440px, calc(100% - 24px));
}

.map-tip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 8px;
}

.map-tip-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(187, 49, 46, 0.12);
    color: var(--rn-red);
    font-size: 1.15rem;
    line-height: 1;
    font-weight: 950;
    display: grid;
    place-items: center;
}

.top-left {
    top: 14px;
    left: 14px;
}

.top-right {
    top: 14px;
    right: 14px;
}

.area-badge {
    font-weight: 900;
    padding: 10px 16px;
    min-width: 150px;
    text-align: center;
}

.bottom-right {
    right: 14px;
    bottom: 14px;
    font-weight: 800;
}

.bottom-left {
    left: 14px;
    bottom: 18px;
}

.map-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    border-radius: 18px;
    padding: 8px;
    max-width: calc(100% - 28px);
}

.map-action-btn {
    border: 0;
    border-radius: 999px;
    min-height: 40px;
    padding: 9px 13px;
    font-weight: 900;
    background: #f0ebe4;
    color: #1d1d1d;
    box-shadow: none;
}

.map-action-btn.primary {
    background: linear-gradient(135deg, var(--rn-red), var(--rn-red-dark));
    color: #ffffff;
}

.map-action-btn.danger {
    background: #221d1c;
    color: #fff;
}

.map-action-btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.map-step-prompt {
    left: 50%;
    bottom: 128px;
    transform: translateX(-50%);
    border-radius: 16px;
    background: rgba(17, 17, 17, 0.88);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.16);
    font-weight: 850;
    text-align: center;
    max-width: min(520px, calc(100% - 28px));
}

.map-zoom-badge {
    right: 14px;
    top: 68px;
    font-weight: 900;
    background: rgba(17, 17, 17, 0.82);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.16);
}

.map-control-note {
    margin: 12px 0 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(187, 49, 46, 0.08);
    border: 1px solid rgba(187, 49, 46, 0.18);
    color: #4b403d;
    font-weight: 700;
}

.step-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(187, 49, 46, 0.1);
    color: var(--rn-red);
    border: 1px solid rgba(187, 49, 46, 0.22);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.74rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

label {
    display: block;
    margin: 13px 0 7px;
    font-weight: 800;
    font-size: 0.92rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--rn-border);
    border-radius: var(--radius-sm);
    padding: 12px 13px;
    background: #fff;
    color: var(--rn-text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(187, 49, 46, 0.75);
    box-shadow: 0 0 0 4px rgba(187, 49, 46, 0.12);
}

textarea {
    resize: vertical;
}

.divider {
    height: 1px;
    background: var(--rn-border);
    margin: 22px 0;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.quote-btn,
.ghost-btn {
    border: 0;
    border-radius: 999px;
    min-height: 44px;
    padding: 11px 16px;
    font-weight: 900;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-btn,
.quote-btn {
    background: linear-gradient(135deg, var(--rn-red), var(--rn-red-dark));
    color: #fff;
    box-shadow: 0 12px 22px rgba(187, 49, 46, 0.26);
}

.secondary-btn {
    background: #f0ebe4;
    color: #1d1d1d;
}

.danger-btn {
    background: #221d1c;
    color: #fff;
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.32);
    backdrop-filter: blur(12px);
    white-space: nowrap;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover,
.quote-btn:hover,
.ghost-btn:hover {
    transform: translateY(-1px);
}

.quote-btn {
    width: 100%;
    margin-top: 18px;
    font-size: 1rem;
    min-height: 50px;
}

.full {
    width: 100%;
}

.field-grid,
.form-grid.two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.drawing-status,
.service-warning,
.form-message {
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 14px;
    font-size: 0.92rem;
}

.drawing-status {
    background: #f6f2ec;
    border: 1px solid var(--rn-border);
    color: #35302b;
}

.service-warning {
    background: #fff4df;
    border: 1px solid #e9c37a;
    color: #68410a;
}

.section-list {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.section-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--rn-border);
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.9rem;
}

.section-item button {
    border: 0;
    background: rgba(187, 49, 46, 0.1);
    color: var(--rn-red);
    font-weight: 900;
    border-radius: 999px;
    padding: 6px 9px;
}

.result-card {
    margin-top: 18px;
    border: 1px solid rgba(187, 49, 46, 0.23);
    background: linear-gradient(180deg, #fff, #fff8f3);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: 0 16px 30px rgba(187, 49, 46, 0.12);
}

.result-label {
    color: var(--rn-muted);
    font-weight: 800;
    margin-bottom: 4px;
}

.result-price {
    color: var(--rn-red);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 950;
    letter-spacing: -0.05em;
    line-height: 1;
}

.result-tax {
    color: var(--rn-text);
    font-weight: 900;
    margin: 6px 0 14px;
}

.result-details {
    display: grid;
    gap: 7px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.result-details div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px dashed rgba(17, 17, 17, 0.15);
    padding-bottom: 6px;
}

.fine-print,
.upload-note {
    color: var(--rn-muted);
    font-size: 0.84rem;
    margin-top: 14px;
}

.site-footer {
    width: min(1420px, calc(100% - 32px));
    margin: 42px auto 0;
    padding: 34px 0 16px;
    border-top: 1px solid rgba(17, 17, 17, 0.10);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    color: #1b1b1d;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    font-weight: 700;
}

.footer-brand img {
    width: 86px;
    height: 86px;
    object-fit: contain;
    background: #f7f2e9;
}

.footer-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    color: #2f2f32;
}

.hidden,
.honeypot {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(8px);
}

.modal-card {
    position: relative;
    width: min(620px, 100%);
    max-height: min(820px, calc(100vh - 36px));
    overflow: auto;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 34px 100px rgba(0, 0, 0, 0.42);
    padding: 30px;
}

.lead-card {
    width: min(760px, 100%);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    background: #f3eee7;
    color: var(--rn-text);
    font-size: 1.5rem;
    line-height: 1;
}

.help-list {
    padding-left: 22px;
    display: grid;
    gap: 8px;
}

.checkbox-row {
    display: grid;
    grid-template-columns: 20px 1fr;
    align-items: start;
    gap: 10px;
    font-weight: 600;
    line-height: 1.35;
}

.checkbox-row input {
    width: auto;
    margin-top: 3px;
}

.checkbox-row a {
    color: var(--rn-red);
    font-weight: 900;
}

.form-message.success {
    background: #effaf1;
    border: 1px solid #b5ddb9;
    color: #155d23;
}

.form-message.error {
    background: #fff0ee;
    border: 1px solid #f0b6ae;
    color: #8d211f;
}

.success-panel {
    text-align: center;
    padding: 18px 6px;
}

.success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--rn-red);
    color: #fff;
    font-size: 2rem;
    font-weight: 950;
}

.roof-svg-overlay,
.roof-drawing-surface {
    position: absolute;
    inset: 0;
}

.roof-svg-overlay {
    z-index: 12;
    pointer-events: none;
    overflow: visible;
}

.roof-drawing-surface {
    z-index: 11;
    pointer-events: none;
    cursor: crosshair;
    touch-action: none;
    background: transparent;
}

.roof-drawing-surface.active {
    pointer-events: none;
}

.roof-handle-layer {
    position: absolute;
    inset: 0;
    z-index: 16;
    pointer-events: none;
}

.roof-point-hitbox {
    position: absolute;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(187, 49, 46, 0.001);
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.roof-point-hitbox.dragging {
    cursor: grabbing;
}

.roof-svg-section {
    fill: rgba(187, 49, 46, 0.26);
    stroke: #bb312e;
    stroke-width: 3px;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.25));
}

.roof-svg-section.selected {
    fill: rgba(187, 49, 46, 0.34);
    stroke-width: 5px;
}

.roof-svg-draft-line {
    fill: none;
    stroke: #bb312e;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.25));
}

.roof-svg-point {
    fill: #bb312e;
    stroke: #ffffff;
    stroke-width: 2.5px;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.30));
}

.roof-svg-point.closeable {
    fill: #111111;
    stroke-width: 3px;
}

.roof-svg-point.editable {
    pointer-events: all;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

html.rn-point-dragging,
body.rn-point-dragging {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

html.rn-point-dragging .map-panel,
html.rn-point-dragging .roof-handle-layer,
html.rn-point-dragging .roof-point-hitbox {
    touch-action: none;
    overscroll-behavior: none;
}

.roof-svg-point.editable:hover,
.roof-svg-point.dragging {
    fill: #111111;
    stroke-width: 3.5px;
}

.rn-property-pin {
    position: absolute;
    z-index: 18;
    width: 54px;
    height: 68px;
    transform: translate(-50%, -100%);
    pointer-events: auto;
    cursor: grab;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

.rn-property-pin.dragging {
    cursor: grabbing;
}

.rn-property-pin-svg {
    position: absolute;
    left: 0;
    top: 0;
    width: 54px;
    height: 68px;
    display: block;
    overflow: visible;
}

.rn-property-pin-shape {
    fill: #bb312e;
    stroke: #ffffff;
    stroke-width: 3.5px;
    vector-effect: non-scaling-stroke;
}

.rn-property-pin-circle {
    fill: #ffffff;
    stroke: rgba(0, 0, 0, 0.08);
    stroke-width: 1px;
}

.rn-property-pin-logo {
    position: absolute;
    left: 50%;
    top: 27px;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 2px;
    box-sizing: border-box;
    pointer-events: none;
}

.rn-property-pin-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 1160px) {
    .site-nav {
        gap: 18px;
        font-size: 0.95rem;
    }
}

@media (max-width: 1050px) {
    .site-header {
        min-height: auto;
        flex-wrap: wrap;
    }

    .site-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        padding-top: 4px;
    }

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

    .control-panel {
        display: contents;
        max-height: none;
        padding: 0;
        overflow: visible;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .mobile-step-card {
        background: rgba(255, 255, 255, 0.97);
        padding: 24px;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow);
        border: 1px solid rgba(187, 49, 46, 0.12);
    }

    .mobile-step-card-pre {
        order: 1;
    }

    .map-panel {
        min-height: 62vh;
        order: 2;
    }

    .mobile-step-card-details {
        order: 3;
    }

    .desktop-step-divider {
        display: none;
    }
}

@media (max-width: 680px) {
    .site-header {
        padding: 14px 16px;
        gap: 12px;
    }

    .site-nav {
        display: none;
    }

    .ghost-btn {
        margin-left: auto;
    }

    .brand-logo-shell {
        width: 74px;
        min-width: 74px;
        min-height: 58px;
    }

    .brand-logo {
        width: 68px;
        max-height: 52px;
    }

    .brand-logo-fallback {
        width: 58px;
        height: 58px;
        border-radius: 14px;
        font-size: 1.1rem;
    }

    .estimator-hero-content,
    .estimator-layout,
    .site-footer {
        width: min(100% - 18px, 1560px);
    }

    .estimator-hero-content {
        padding: 26px 0 30px;
    }

    h1 {
        font-size: clamp(2rem, 9vw, 2.8rem);
    }

    .estimator-layout {
        margin-top: 14px;
    }

    .control-panel,
    .modal-card,
    .mobile-step-card {
        padding: 18px;
        border-radius: 18px;
    }

    .map-panel {
        min-height: 58vh;
        border-radius: 18px;
    }

    .button-grid,
    .field-grid,
    .form-grid.two {
        grid-template-columns: 1fr;
    }

    .map-overlay.top-left {
        top: 10px;
        left: 10px;
        right: auto;
        border-radius: 14px;
    }

    .map-overlay.area-badge {
        min-width: 138px;
        max-width: calc(100% - 20px);
    }

    .map-overlay.top-right {
        top: 62px;
        left: 10px;
        right: 10px;
        border-radius: 14px;
    }

    .map-tip {
        align-items: flex-start;
    }

    .map-overlay.bottom-right {
        right: 10px;
        bottom: 10px;
    }

    .map-overlay.bottom-left {
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
    }

    .map-actions {
        justify-content: center;
    }

    .map-action-btn {
        flex: 1 1 auto;
        min-width: 82px;
        padding-inline: 10px;
    }

    .roof-point-hitbox {
        width: 54px;
        height: 54px;
    }

    .map-step-prompt {
        left: 10px;
        right: 10px;
        bottom: 138px;
        transform: none;
        max-width: none;
        border-radius: 14px;
    }

    .map-zoom-badge {
        top: 64px;
        right: 10px;
        border-radius: 999px;
    }

    .result-details div {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 18px;
        align-items: baseline;
    }

    .result-details div span {
        min-width: 0;
    }

    .result-details div strong {
        text-align: right;
        white-space: nowrap;
    }

    .site-footer {
        margin-top: 28px;
        padding-top: 24px;
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-brand img {
        width: 72px;
        height: 72px;
    }
}
