/* Cleaned Stone Center AI Chat CSS */
:root {
    --page-bg:#f8fafc; --surface:#fff; --surface-soft:#f3f4f6;
    --border:#dbe1ea; --text:#111827; --muted:#6b7280;
    --primary:#2563eb; --primary-hover:#1d4ed8; --tag-bg:#eaf1ff;
    --assistant-bg:#f3f4f6; --dark:#111827;
    --shadow:0 4px 16px rgba(15,23,42,.07);
}
*{box-sizing:border-box}
html,body{overflow-x:hidden}
img{max-width:100%}
textarea,input,button{max-width:100%}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}

.chat-page{
    width:100%;max-width:1180px;margin:0 auto;padding:18px;
    overflow-x:hidden;color:var(--text);background:var(--page-bg);
    font-family:Arial,sans-serif;
}
.page-title{margin:0 0 12px}
.new-chat-link{display:inline-block;margin-bottom:20px;font-weight:600}
.layout{display:grid;grid-template-columns:220px minmax(0,1fr);gap:24px;align-items:start}
main{min-width:0}

/* Sidebar */
aside{
    position:sticky;top:20px;padding:16px;border:1px solid var(--border);
    border-radius:14px;background:var(--surface);box-shadow:var(--shadow);
}
.chat-list-item{margin-bottom:9px;line-height:1.35}

/* Messages */
.message-row{
    display:flex;align-items:flex-start;gap:12px;width:100%;
    margin-bottom:22px;scroll-margin-top:20px;
}
.message-column{min-width:0;width:100%}
.message-avatar{
    flex:0 0 38px;display:flex;align-items:center;justify-content:center;
    width:38px;height:38px;margin-top:21px;border-radius:12px;
    font-size:12px;font-weight:800;letter-spacing:-.02em;user-select:none;
}
.message-row.assistant .message-avatar{
    color:#fff;background:linear-gradient(135deg,#111827,#334155);
    box-shadow:0 5px 14px rgba(15,23,42,.18);
}
.message-row.user{flex-direction:row-reverse}
.message-row.user .message-column{max-width:78%}
.message-row.user .message-avatar{
    color:#1d4ed8;background:#dbeafe;border:1px solid #bfdbfe;
}
.message-meta{margin:0 0 6px;color:#64748b;font-size:12px;font-weight:700;letter-spacing:.02em}
.message-row.user .message-meta{text-align:right}
.message-bubble{
    width:fit-content;max-width:760px;padding:14px 16px;
    border:1px solid transparent;border-radius:16px;
    box-shadow:0 2px 8px rgba(15,23,42,.05);
}
.message-row.assistant .message-bubble{
    color:#1e293b;background:#fff;border-color:#e2e8f0;border-top-left-radius:5px;
}
.message-row.user .message-bubble{
    margin-left:auto;color:#172554;
    background:linear-gradient(135deg,#eaf2ff,#dfeafe);
    border-color:#c7d8fb;border-top-right-radius:5px;
}
.chat-text{unicode-bidi:plaintext;white-space:normal;color:inherit;font-size:15px;line-height:1.65}
.chat-text p{margin:0 0 10px;padding:0;color:inherit;font-size:inherit;line-height:inherit}
.chat-text p:last-child{margin-bottom:0}
.message-role{display:inline-block;margin-bottom:8px;font-weight:800}
.message-row.assistant .message-column>.recommendation-title,
.message-row.assistant .message-column>.recommendation-cards,
.message-row.assistant .message-column>.quote-box,
.message-row.assistant .message-column>.accessory-offer,
.message-row.assistant .message-column>.postcode-card,
.message-row.assistant .message-column>.service-form{margin-top:14px}

/* General form controls */
.chat-form{margin-top:18px}
textarea{
    width:100%;min-height:100px;padding:12px;border:1px solid #cbd5e1;
    border-radius:10px;background:var(--surface);font:inherit;resize:vertical;
}
button{
    margin-top:8px;padding:10px 18px;border:1px solid transparent;border-radius:9px;
    color:#fff;background:var(--primary);font:inherit;font-weight:600;cursor:pointer;
    transition:background .2s ease,transform .2s ease;
}
button:hover{background:var(--primary-hover);transform:translateY(-1px)}

/* Recommendation cards */
.recommendation-title{margin:18px 0 10px}
.recommendation-cards{
    direction:ltr;display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));
    gap:16px;margin-top:14px;text-align:left;align-items:stretch;
}
.recommendation-card{
    min-width:0;overflow:hidden;display:flex;flex-direction:column;gap:10px;
    padding:14px;border:1px solid var(--border);border-radius:16px;
    background:var(--surface);box-shadow:var(--shadow);
}
.recommendation-card.rtl-card{direction:rtl;text-align:right}
.recommendation-image{width:100%;height:190px;object-fit:contain;border-radius:12px;background:#eef2f7}
.recommendation-name{margin:2px 0 0;font-size:21px;line-height:1.25}
.match-info{padding-bottom:9px;border-bottom:1px solid #e5e7eb}
.match-score{display:flex;justify-content:space-between;gap:12px;margin:0 0 7px;font-size:14px}
.matched-tags{display:flex;flex-wrap:wrap;gap:6px}
.tag-badge{
    display:inline-flex;align-items:center;padding:4px 9px;border-radius:999px;
    color:#1e3a8a;background:var(--tag-bg);font-size:12px;line-height:1.2;white-space:nowrap;
}
.card-meta{display:grid;gap:5px}
.card-meta p,.card-description{margin:0;line-height:1.4}
.card-description{color:var(--muted);font-size:14px}
.price-row{margin-top:2px!important}
.price-value{color:var(--text);font-size:20px;font-weight:700}
.price-unit{color:var(--muted);font-size:14px}
.select-material-form{margin-top:10px;padding-top:4px}
.select-material-form button{width:100%;margin-top:0}

/* =========================================================
   Customer onboarding
   ========================================================= */

.customer-onboarding {
    width: 100%;
    max-width: 860px;
    margin: 0 auto 24px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

.customer-onboarding-header {
    padding: 30px 32px 25px;
    text-align: center;
    background:
        radial-gradient(
            circle at top right,
            rgba(37, 99, 235, 0.11),
            transparent 34%
        ),
        linear-gradient(
            180deg,
            #ffffff,
            #f8fbff
        );
}

.customer-onboarding-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    padding: 6px 11px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 12px;
    font-weight: 800;
}

.customer-onboarding-header h2 {
    max-width: 620px;
    margin: 0 auto 10px;
    color: #0f172a;
    font-size: clamp(25px, 4vw, 36px);
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.customer-onboarding-intro {
    max-width: 650px;
    margin: 0 auto;
    padding: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
    text-align: center;
}

.customer-process {
    display: grid;
    grid-template-columns: auto minmax(30px, 1fr) auto minmax(30px, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: 0 32px;
    padding: 18px 0;
    border-top: 1px solid #edf0f4;
    border-bottom: 1px solid #edf0f4;
}

.customer-process-step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.customer-process-step.is-active {
    color: #1d4ed8;
}

.customer-process-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #dbe1ea;
    border-radius: 50%;
    color: #64748b;
    background: #ffffff;
    font-size: 12px;
    font-weight: 800;
}

.customer-process-step.is-active .customer-process-number {
    border-color: var(--primary);
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.22);
}

.customer-process-line {
    height: 1px;
    background: #dbe1ea;
}

.customer-form-section {
    padding: 26px 32px 8px;
}

.customer-form-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.customer-form-heading h3 {
    margin: 0 0 5px;
    color: #172033;
    font-size: 21px;
    line-height: 1.25;
}

.customer-form-heading p {
    margin: 0;
    padding: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.customer-required-note {
    flex: 0 0 auto;
    padding: 5px 9px;
    border-radius: 999px;
    color: #64748b;
    background: #f1f5f9;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.customer-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 17px;
}

.customer-onboarding .form-group {
    display: grid;
    gap: 7px;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.customer-onboarding label {
    display: block;
    margin: 0;
    padding: 0;
    color: #273249;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.customer-onboarding label > span {
    color: #dc2626;
}

.customer-input-wrapper {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #ffffff;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.customer-input-wrapper:focus-within {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
}

.customer-input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    border-right: 1px solid #e2e8f0;
    color: #2563eb;
    background: #f8fafc;
    font-size: 15px;
    font-weight: 700;
}

.customer-onboarding input[type="text"],
.customer-onboarding input[type="email"],
.customer-onboarding input[type="tel"] {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 47px;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-radius: 0;
    color: var(--text);
    background: transparent;
    font: inherit;
    font-size: 13px;
    line-height: 1.4;
    outline: none;
    box-shadow: none;
}

.customer-onboarding input::placeholder {
    color: #94a3b8;
}

.customer-form-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: center;
    gap: 24px;

    margin-top: 20px;
    padding: 22px 32px 28px;

    border-top: 1px solid #edf0f4;
}

.customer-privacy-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;

    width: 100%;
    max-width: 430px;

    margin: 0;
    padding: 0;

    color: #64748b;
    font-size: 12px;
    line-height: 1.55;
}

.customer-privacy-note > span {
    flex: 0 0 auto;
    line-height: 1.4;
}

.customer-start-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    width: 100%;
    min-width: 0;
    min-height: 50px;

    margin: 0;
    padding: 12px 20px;

    border: 0;
    border-radius: 11px;

    color: #ffffff;
    background: linear-gradient(
        135deg,
        #2563eb,
        #1d4ed8
    );

    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);

    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.customer-start-button:hover {
    background: linear-gradient(
        135deg,
        #1d4ed8,
        #1e40af
    );
}

[dir="rtl"] .customer-onboarding {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .customer-onboarding-header,
[dir="rtl"] .customer-onboarding-intro {
    text-align: center;
}

[dir="rtl"] .customer-input-icon {
    border-right: 0;
    border-left: 1px solid #e2e8f0;
}

@media (max-width: 640px) {
    .customer-onboarding {
        border-radius: 15px;
    }

    .customer-onboarding-header {
        padding: 24px 18px 21px;
    }

    .customer-onboarding-header h2 {
        font-size: 25px;
    }

    .customer-process {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin: 0 16px;
    }

    .customer-process-line {
        display: none;
    }

    .customer-process-step {
        align-items: center;
        flex-direction: column;
        gap: 5px;
        text-align: center;
        white-space: normal;
    }

    .customer-form-section {
        padding: 22px 16px 4px;
    }

    .customer-form-heading {
        flex-direction: column;
        gap: 10px;
    }

    .customer-form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .customer-form-footer {
        grid-template-columns: 1fr;
        gap: 16px;

        margin-top: 16px;
        padding: 18px 16px 22px;
    }

    .customer-privacy-note {
        max-width: none;
        font-size: 11px;
    }

    .customer-start-button {
        width: 100%;
        min-height: 48px;
    }
}


/* Additional services */
.service-form{
    width:100%;
    min-width:0;
    margin-top:18px;
    padding:20px;
    overflow:hidden;
    border:1px solid var(--border);
    border-radius:18px;
    background:var(--surface);
    box-shadow:var(--shadow);
}
.service-form-header{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:20px;
    margin-bottom:18px;
    padding-bottom:16px;
    border-bottom:1px solid #e5e7eb;
}
.service-form-header h3{margin:4px 0 6px;font-size:24px;line-height:1.2;letter-spacing:-.02em}
.service-form-header p{margin:0;padding:0;color:var(--muted);font-size:13px;line-height:1.5}
.service-form-step{color:var(--primary);font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
.service-optional-badge{
    flex:0 0 auto;
    padding:6px 11px;
    border:1px solid #e2e8f0;
    border-radius:999px;
    color:#475569;
    background:#f1f5f9;
    font-size:11px;
    font-weight:700;
}
.service-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
    width:100%;
    min-width:0;
}
.service-card{
    min-width:0;
    padding:16px;
    border:1px solid #e2e8f0;
    border-radius:14px;
    background:#fff;
    box-shadow:0 3px 10px rgba(15,23,42,.04);
}
.service-card--length{
    border-color:#bfdbfe;
    background:linear-gradient(180deg,#fff,#f8fbff);
}
.service-card-header{
    display:flex;
    align-items:center;
    gap:11px;
    min-width:0;
    margin-bottom:13px;
    padding-bottom:12px;
    border-bottom:1px solid #edf0f4;
}
.service-card-header>div{min-width:0}
.service-card-icon{
    flex:0 0 38px;
    display:flex;
    align-items:center;
    justify-content:center;
    width:38px;
    height:38px;
    border:1px solid #dbeafe;
    border-radius:11px;
    color:var(--primary);
    background:#eff6ff;
    font-size:17px;
    font-weight:700;
}
.service-card-header h4{margin:0;padding:0;overflow-wrap:anywhere;color:#172033;font-size:15px;line-height:1.35}
.service-card-header small{
    display:block;
    margin-top:2px;
    overflow-wrap:anywhere;
    color:var(--muted);
    font-size:10px;
    line-height:1.35;
}
.service-card-fields{display:grid;gap:8px;min-width:0}
.service-field{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:14px;
    width:100%;
    min-width:0;
    min-height:54px;
    margin:0;
    padding:9px 10px;
    border:1px solid #e5eaf1;
    border-radius:10px;
    color:#253047;
    background:#f8fafc;
    font-size:12px;
    font-weight:600;
    cursor:default;
}
.service-field-label{min-width:0;overflow-wrap:anywhere;line-height:1.35}
.service-input-unit{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    min-width:0;
    overflow:hidden;
    border:1px solid #cbd5e1;
    border-radius:9px;
    background:#fff;
    transition:border-color .2s ease,box-shadow .2s ease;
}
.service-input-unit:focus-within{
    border-color:var(--primary);
    box-shadow:0 0 0 3px rgba(37,99,235,.12);
}
.service-input-unit input[type=number]{
    display:block;
    width:100%;
    min-width:0;
    height:40px;
    margin:0;
    padding:7px 10px;
    border:0;
    border-radius:0;
    color:var(--text);
    background:transparent;
    font:inherit;
    font-size:14px;
    font-weight:700;
    text-align:right;
    outline:none;
    box-shadow:none;
}
.service-input-unit input[type=number]:focus{border:0;outline:none;box-shadow:none}
.service-unit{
    display:flex;
    align-items:center;
    align-self:stretch;
    padding:0 10px;
    border-left:1px solid #e2e8f0;
    color:#64748b;
    background:#f8fafc;
    font-size:11px;
    font-weight:700;
    white-space:nowrap;
}
.service-field--length .service-input-unit{width:176px}
.service-field--quantity .service-input-unit{width:112px}
.service-field:focus-within{border-color:#bfdbfe;background:#fff}
.service-form-footer{
    display:grid;
    grid-template-columns:minmax(240px,1fr) minmax(220px,320px);
    align-items:center;
    gap:20px;
    width:100%;
    margin-top:18px;
    padding:16px;
    border:1px solid #dbeafe;
    border-radius:12px;
    background:#f8fafc;
}
.service-form-footer p{
    position:relative;
    min-width:0;
    margin:0;
    padding:0 0 0 38px;
    color:#475569;
    font-size:12px;
    line-height:1.5;
}
.service-form-footer p::before{
    position:absolute;
    top:50%;
    left:0;
    display:flex;
    align-items:center;
    justify-content:center;
    width:28px;
    height:28px;
    content:"i";
    border:1px solid #bfdbfe;
    border-radius:50%;
    color:var(--primary);
    background:#eff6ff;
    font-size:14px;
    font-weight:800;
    transform:translateY(-50%);
}
.service-update-button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:100%;
    min-width:0;
    min-height:44px;
    margin:0;
    padding:11px 18px;
    border:0;
    border-radius:10px;
    color:#fff;
    background:var(--primary);
    box-shadow:0 6px 16px rgba(37,99,235,.18);
    font-size:14px;
    font-weight:700;
    white-space:nowrap;
}
.service-update-button:hover{color:#fff;background:var(--primary-hover)}

/* Quote */
.quote-box{
    margin-top:16px;padding:18px;border:1px solid var(--border);
    border-radius:14px;background:var(--surface);box-shadow:var(--shadow);
}
.quote-box h3{margin-top:0}
.quote-row{margin:6px 0}
.quote-total{margin-top:14px;font-size:1.1em;font-weight:700}
.quote-services li,.quote-pieces li{margin-bottom:8px}
.quote-item-content span{overflow-wrap:anywhere}
.quote-item-content small{color:var(--muted)}

/* Accessories */
.accessory-offer{
    margin-top:18px;padding:20px;border:1px solid #bfdbfe;
    border-radius:14px;background:#eff6ff;
}
.accessory-offer h3{margin:0 0 10px}
.discount-box{display:grid;gap:8px;margin:16px 0;padding:14px;border-radius:10px;background:#fff}
.discount-box p{margin:0}
.discount-box strong{color:#16a34a;font-size:18px}
.accessory-actions{display:flex;flex-wrap:wrap;gap:10px}
.accessory-actions form,.accessory-actions button{margin:0}
.secondary-button{border:1px solid #94a3b8;color:#334155;background:#fff}
.secondary-button:hover{color:#111827;background:#f1f5f9}
.selectable-product-card{
    position:relative;cursor:pointer;
    transition:border-color .2s ease,box-shadow .2s ease,transform .2s ease;
}
.selectable-product-card:hover{border-color:#93c5fd;transform:translateY(-2px)}
.product-radio{
    position:absolute;top:14px;right:14px;z-index:2;
    width:22px;height:22px;margin:0;accent-color:var(--primary);
}
.selectable-product-card:has(.product-radio:checked){
    border:2px solid var(--primary);box-shadow:0 6px 20px rgba(37,99,235,.18);
}
.product-select-indicator{
    display:block;width:100%;margin-top:auto;padding:11px 14px;
    border:1px solid var(--primary);border-radius:9px;color:var(--primary);
    background:#fff;text-align:center;font-weight:700;
}
.selectable-product-card:has(.product-radio:checked) .product-select-indicator{color:#fff;background:var(--primary)}
.selectable-product-card:has(.product-radio:checked) .product-select-indicator::before{content:"✓ "}
.accessory-confirmation-bar{
    position:sticky;bottom:12px;z-index:10;display:flex;align-items:center;
    justify-content:space-between;gap:16px;margin-top:18px;padding:14px 16px;
    border:1px solid #bfdbfe;border-radius:12px;background:rgba(239,246,255,.96);
    box-shadow:0 8px 24px rgba(15,23,42,.12);backdrop-filter:blur(8px);
}
.accessory-confirmation-bar button{margin:0}
.accessory-selection-summary{margin:0;color:#334155}
.accessory-panel-shell{
    margin-top:20px;padding:18px;border:1px solid var(--border);border-radius:16px;
    background:var(--assistant-bg);box-shadow:var(--shadow);scroll-margin-top:20px;
}
.accessory-selection-form{margin:0}

/* Live quote */
.live-quote{
    margin-top:22px;padding:18px;border:1px solid var(--border);
    border-radius:16px;background:var(--surface);box-shadow:var(--shadow);
}
.live-quote-header{
    display:flex;align-items:center;justify-content:space-between;
    padding-bottom:12px;border-bottom:1px solid #e5e7eb;
}
.live-quote-header h3{margin:0 0 4px;font-size:25px;letter-spacing:-.02em}
.quote-number{color:var(--muted);font-size:13px}
.live-quote-products{
    display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
    gap:14px;padding:18px 0;
}
.quote-product-card{
    min-width:0;overflow:hidden;display:flex;flex-direction:column;
    border:1px solid var(--border);border-radius:14px;background:#fff;
    transition:transform .2s ease,box-shadow .2s ease;
}
.quote-product-card:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(15,23,42,.09)}
.quote-product-image{
    width:100%;height:150px;padding:10px;object-fit:contain;
    border-bottom:1px solid var(--border);background:#f8fafc;
}
.quote-product-body{
    flex:1;display:flex;flex-direction:column;gap:5px;
    min-height:178px;padding:13px;
}
.quote-product-type{color:var(--primary);font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.04em}
.quote-product-name{overflow-wrap:anywhere;font-size:16px;line-height:1.35}
.quote-product-meta{color:var(--muted);font-size:13px}
.quote-product-price{margin-top:auto;padding-top:16px;font-size:21px;font-weight:700}
.live-quote-details{display:grid;gap:16px}
.quote-detail-section{
    padding:16px;border:1px solid var(--border);border-radius:14px;background:#fff;
}
.quote-detail-section h4{margin:0 0 12px;font-size:17px}
.quote-section-heading{
    display:flex;align-items:center;justify-content:space-between;
    gap:12px;margin-bottom:12px;
}
.quote-section-heading h4{margin:0}
.live-quote-totals{display:grid;gap:0;padding-top:0;border-top:0}
.live-quote-totals>div{
    display:flex;justify-content:space-between;gap:16px;
    padding:11px 0;border-bottom:1px solid #edf0f4;
}
.live-quote-totals>div:last-child{border-bottom:0}
.live-quote-totals>div span{color:#334155}
.live-quote-totals>div strong{white-space:nowrap}
.quote-subtotal-row{margin-top:4px;padding-top:14px!important;border-top:2px solid #dbe1ea;font-weight:700}
.discount-row{color:#16a34a}
.quote-saving-box{
    display:flex;align-items:center;justify-content:space-between;gap:16px;
    margin-top:8px;padding:13px 15px;border:1px solid #bbf7d0;
    border-radius:12px;color:#15803d;background:#f0fdf4;
}
.quote-saving-box>div{display:grid;gap:2px}
.saving-label{font-size:17px;font-weight:800}
.quote-saving-box strong{font-size:19px}
.live-quote-grand-total{
    display:flex;align-items:center;justify-content:space-between;
    min-height:92px;margin-top:12px;padding:20px 22px;border:0;border-radius:14px;
    color:#fff;background:linear-gradient(135deg,#111827,#1e293b);
}
.live-quote-grand-total span{font-size:18px;font-weight:700;letter-spacing:.01em}
.live-quote-grand-total strong{font-size:34px;line-height:1;letter-spacing:-.03em}
.live-quote-actions{display:flex;justify-content:flex-end;margin-top:-4px}
.quote-action-button{
    display:inline-flex;align-items:center;justify-content:center;
    min-width:190px;min-height:48px;padding:11px 18px;border-radius:10px;
    color:#fff;background:var(--primary);box-shadow:0 6px 16px rgba(37,99,235,.2);
    font-weight:700;text-decoration:none;
}
.quote-action-button:hover{color:#fff;background:var(--primary-hover);text-decoration:none}

/* Postcode and distance */
.postcode-card{
    margin-top:16px;padding:16px;border:1px solid #bfdbfe;
    border-radius:14px;background:#eff6ff;box-shadow:var(--shadow);
}
.postcode-card h3{margin:0 0 10px;font-size:18px}
.postcode-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:12px}
.postcode-actions form,.postcode-actions button{margin:0}
.postcode-form{
    display:grid;grid-template-columns:minmax(0,1fr) auto;
    gap:10px;align-items:end;margin-top:12px;
}
.postcode-form-field{display:grid;gap:6px}
.postcode-form label{font-weight:700}
.postcode-form input{
    width:100%;min-width:0;padding:11px 12px;border:1px solid #cbd5e1;
    border-radius:9px;background:#fff;font:inherit;
}
.postcode-form button{margin:0;white-space:nowrap}
.distance-card{
    margin-top:16px;overflow:hidden;border:1px solid #bbf7d0;
    border-radius:14px;background:#fff;box-shadow:var(--shadow);
}
.distance-card-header{
    display:flex;align-items:center;justify-content:space-between;gap:14px;
    padding:14px 16px;border-bottom:1px solid #dcfce7;background:#f0fdf4;
}
.distance-card-header h3{margin:0;font-size:18px}
.distance-badge{
    display:inline-flex;align-items:center;padding:5px 10px;border-radius:999px;
    color:#166534;background:#dcfce7;font-size:13px;font-weight:700;white-space:nowrap;
}
.distance-card-body{display:grid;gap:14px;padding:16px}
.distance-summary-grid,.distance-price-grid{
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;
}
.distance-summary-item,.distance-price-item{
    min-width:0;padding:12px;border:1px solid #e5e7eb;
    border-radius:10px;background:#f8fafc;
}
.distance-summary-item span,.distance-price-item span{
    display:block;margin-bottom:4px;color:var(--muted);font-size:13px;
}
.distance-summary-item strong,.distance-price-item strong{overflow-wrap:anywhere;font-size:17px}
.distance-total-row{
    display:flex;align-items:center;justify-content:space-between;gap:16px;
    padding:14px 16px;border-radius:11px;color:#fff;background:var(--dark);
}
.distance-total-row strong{font-size:21px}

/* Quote location */
.quote-location-section{border-color:#bbf7d0;background:#f8fff9}
.quote-location-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.quote-location-grid>div{
    min-width:0;padding:12px;border:1px solid #dcfce7;border-radius:10px;background:#fff;
}
.quote-location-grid span{display:block;margin-bottom:5px;color:var(--muted);font-size:12px}
.quote-location-grid strong{overflow-wrap:anywhere;font-size:15px}

/* RTL */
.rtl-box{direction:rtl;text-align:right}
.ltr{direction:ltr;unicode-bidi:isolate;display:inline-block}
[dir=rtl] body{text-align:right}
[dir=rtl] .live-quote-header,
[dir=rtl] .quote-detail-section,
[dir=rtl] .quote-saving-box,
[dir=rtl] .live-quote-grand-total,
[dir=rtl] .customer-info-box,
[dir=rtl] aside,
[dir=rtl] .service-form,
[dir=rtl] .service-form-header,
[dir=rtl] .service-card,
[dir=rtl] .service-field,
[dir=rtl] .service-form-footer,
[dir=rtl] .postcode-card{direction:rtl;text-align:right}
[dir=rtl] .live-quote-products{direction:rtl}
[dir=rtl] .quote-product-body{text-align:right}
[dir=rtl] .live-quote-totals>div{flex-direction:row-reverse}
[dir=rtl] .live-quote-actions{justify-content:flex-start}
[dir=rtl] .chat-form textarea{direction:rtl;text-align:right}
[dir=rtl] .product-radio{right:auto;left:14px}
[dir=rtl] .message-row{direction:rtl}
[dir=rtl] .message-row.user{flex-direction:row-reverse}
[dir=rtl] .message-row.user .message-meta{text-align:left}
[dir=rtl] .message-row.assistant .message-bubble{border-top-left-radius:16px;border-top-right-radius:5px}
[dir=rtl] .message-row.user .message-bubble{
    margin-right:auto;margin-left:0;border-top-right-radius:16px;border-top-left-radius:5px;
}
[dir=rtl] .service-form-footer p{padding-right:38px;padding-left:0}
[dir=rtl] .service-form-footer p::before{right:0;left:auto}
[dir=rtl] .quote-product-image{border-right:0;border-left:1px solid var(--border)}


[dir=rtl] .service-unit{
    border-right:1px solid #e2e8f0;
    border-left:0;
}
[dir=rtl] .service-input-unit input[type=number]{
    text-align:left;
}

/* Tablet */
@media (max-width:900px){
    .layout{grid-template-columns:1fr}
    aside{position:static;max-height:170px;overflow-y:auto}
    .chat-page{max-width:760px}
    .live-quote-products{grid-template-columns:1fr}
    .quote-product-card{display:grid;grid-template-columns:110px minmax(0,1fr)}
    .quote-product-image{
        width:110px;height:100%;min-height:120px;
        border-right:1px solid var(--border);border-bottom:0;
    }
    .quote-location-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
    .service-grid{grid-template-columns:1fr}
}

/* Mobile */
@media (max-width:640px){
    .chat-page{
        width:100%;margin:0 auto;
        padding:max(14px,env(safe-area-inset-top)) 10px max(16px,env(safe-area-inset-bottom));
    }
    .page-title{font-size:25px}
    .layout{gap:14px}
    aside{padding:13px;border-radius:12px}

    .message-row{gap:9px;margin-bottom:17px}
    .message-avatar{
        flex-basis:32px;width:32px;height:32px;margin-top:20px;
        border-radius:10px;font-size:10px;
    }
    .message-row.user .message-column{max-width:calc(100% - 42px)}
    .message-bubble{max-width:100%;padding:12px 13px;border-radius:14px}
    .chat-text{font-size:14px;line-height:1.6}

    .customer-info-box,.accessory-panel-shell,.live-quote,.quote-box{
        padding:13px;border-radius:12px;
    }
    .recommendation-cards{grid-template-columns:1fr}
    .recommendation-card{padding:11px;border-radius:12px}
    .recommendation-image{height:180px}
    .recommendation-name{font-size:18px}


    .service-form{
        width:100%;
        min-width:0;
        padding:13px;
        border-radius:14px;
        overflow:hidden;
    }
    .service-form-header{
        position:relative;
        flex-direction:column;
        gap:10px;
        margin-bottom:13px;
        padding-right:88px;
        padding-bottom:13px;
    }
    [dir=rtl] .service-form-header{padding-right:0;padding-left:88px}
    .service-form-header h3{font-size:20px}
    .service-optional-badge{position:absolute;top:0;right:0}
    [dir=rtl] .service-optional-badge{right:auto;left:0}
    .service-grid{
        grid-template-columns:minmax(0,1fr);
        gap:10px;
        width:100%;
        min-width:0;
    }
    .service-card{
        width:100%;
        min-width:0;
        max-width:100%;
        padding:12px;
        overflow:hidden;
        border-radius:12px;
    }
    .service-card-header{
        width:100%;
        min-width:0;
        margin-bottom:10px;
        padding-bottom:10px;
    }
    .service-card-icon{
        flex-basis:34px;
        width:34px;
        height:34px;
        border-radius:9px;
        font-size:15px;
    }
    .service-card-fields{width:100%;min-width:0}
    .service-field{
        grid-template-columns:minmax(0,1fr) auto;
        gap:9px;
        min-height:52px;
        padding:8px 9px;
    }
    .service-field--length{
        align-items:stretch;
        grid-template-columns:1fr;
    }
    .service-field--length .service-input-unit{width:100%}
    .service-field--quantity .service-input-unit{width:104px}
    .service-input-unit input[type=number]{height:38px;font-size:13px}
    .service-unit{padding:0 8px;font-size:10px}
    .service-form-footer{grid-template-columns:1fr;gap:12px;padding:13px}
    .service-form-footer p{width:100%;min-width:0;font-size:11px}
    .service-update-button{width:100%;min-height:46px}


    .accessory-confirmation-bar{align-items:stretch;flex-direction:column}
    .accessory-confirmation-bar button{width:100%}
    .accessory-actions{flex-direction:column}
    .accessory-actions form,.accessory-actions button{width:100%}

    .live-quote-header h3{font-size:22px}
    .live-quote-products{grid-template-columns:1fr;gap:10px;padding:14px 0}
    .quote-product-card{display:grid;grid-template-columns:92px minmax(0,1fr)}
    .quote-product-image{
        width:92px;height:100%;min-height:108px;padding:7px;
        border-right:1px solid var(--border);border-bottom:0;
    }
    .quote-product-body{min-height:0;padding:11px}
    .quote-product-price{padding-top:10px;font-size:18px}
    .quote-detail-section{padding:12px}
    .quote-section-heading{align-items:flex-start;flex-direction:column}
    .quote-location-grid{grid-template-columns:1fr}
    .live-quote-totals>div{align-items:center;flex-direction:row;padding:10px 0}
    .live-quote-totals>div span{flex:1}
    .quote-saving-box{align-items:flex-start;flex-direction:column;gap:5px}
    .live-quote-grand-total{align-items:flex-start;min-height:104px;padding:18px}
    .live-quote-grand-total strong{font-size:31px}
    .live-quote-actions,.quote-action-button{width:100%}

    .postcode-card,.distance-card-body{padding:14px}
    .postcode-actions{flex-direction:column}
    .postcode-actions form,.postcode-actions button{width:100%}
    .postcode-form{grid-template-columns:1fr}
    .postcode-form button{width:100%}
    .distance-card-header{align-items:flex-start;flex-direction:column}
    .distance-summary-grid,.distance-price-grid{grid-template-columns:1fr}
    .distance-total-row{align-items:flex-start;flex-direction:column}

    .chat-form{
        position:sticky;bottom:0;z-index:20;
        padding-top:10px;padding-bottom:max(8px,env(safe-area-inset-bottom));
        background:var(--page-bg);
    }
    .chat-form textarea{min-height:84px}
    .chat-form button{width:100%;min-height:44px}
}

@media (max-width:390px){
    .quote-product-card{grid-template-columns:82px minmax(0,1fr)}
    .quote-product-image{width:82px}
    .live-quote-totals>div{align-items:flex-start;flex-direction:column}
    .live-quote-grand-total strong{font-size:28px}
}

#chat-end{
    height:1px;
    scroll-margin-bottom:140px;
}

/* Compact recommendation cards */

.recommendation-cards {
    gap: 12px;
}

.recommendation-card {
    gap: 6px;
    padding: 12px;
    border-radius: 14px;
}

.recommendation-image {
    height: 165px;
    margin-bottom: 2px;
}

.recommendation-name {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.match-info {
    margin-top: 2px;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.match-score {
    margin: 0 0 6px;
    font-size: 13px;
}

.matched-tags {
    gap: 5px;
}

.tag-badge {
    padding: 3px 8px;
    font-size: 11px;
}

.card-meta {
    display: grid;
    gap: 4px;
    margin-top: 4px;
}

.card-meta p {
    margin: 0;
    padding: 0;
    line-height: 1.35;
}

.card-meta strong {
    font-size: 13px;
}

.price-row {
    margin-top: 4px !important;
    padding-top: 2px;
}

.price-value {
    font-size: 18px;
}

.price-unit {
    font-size: 12px;
}

.card-description {
    min-height: 0;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
}

.select-material-form {
    margin-top: 10px;
    padding-top: 0;
}

.select-material-form button {
    width:fit-content ;
    min-height: 42px;
    padding: 9px 12px;
    font-size: 13px;
}

/* =========================================================
   HTMX chat interaction
   ========================================================= */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}

.chat-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 10px;
}

.chat-loading {
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
}

.chat-loading-spinner {
    flex: 0 0 17px;
    width: 17px;
    height: 17px;
    border: 2px solid #bfdbfe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: chat-spin 0.75s linear infinite;
}

@keyframes chat-spin {
    to {
        transform: rotate(360deg);
    }
}

.chat-submit-button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 150px;
    min-height: 44px;
    margin: 0;
}

.chat-form.is-submitting textarea {
    opacity: 0.72;
}

.chat-form button:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

#chat-end {
    width: 100%;
    height: 1px;
    scroll-margin-bottom: 130px;
}

.empty-chat-message {
    padding: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    color: #64748b;
    background: #f8fafc;
    text-align: center;
}

@media (max-width: 640px) {
    .chat-form-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .chat-loading {
        min-height: 24px;
    }

    .chat-submit-button {
        width: 100%;
    }
}

[dir="rtl"] .chat-loading {
    direction: rtl;
    text-align: right;
}

/* =========================================================
   Accessory panel header
   ========================================================= */

.accessory-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.accessory-panel-header h2 {
    margin: 4px 0 6px;
    color: var(--text);
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.accessory-panel-header p {
    margin: 0;
    padding: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.accessory-panel-step {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.accessory-product-section
+ .accessory-product-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.accessory-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.accessory-section-heading h3 {
    margin: 0;
}

.accessory-section-heading > span {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 640px) {
    .accessory-panel-header h2 {
        font-size: 21px;
    }

    .accessory-section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .accessory-product-section
    + .accessory-product-section {
        margin-top: 18px;
        padding-top: 16px;
    }
}

/* =========================================================
   AI chat hero
   ========================================================= */

.chat-hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 22px;
    padding: 30px 32px;
    border: 1px solid #dbe7ff;
    border-radius: 22px;
    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #f7faff 52%,
            #edf4ff 100%
        );
    box-shadow:
        0 16px 38px rgba(37, 99, 235, 0.08);
    isolation: isolate;
}

.chat-hero-glow {
    position: absolute;
    z-index: -1;
    top: -130px;
    right: -100px;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background:
        radial-gradient(
            circle,
            rgba(37, 99, 235, 0.16) 0%,
            rgba(96, 165, 250, 0.07) 44%,
            transparent 72%
        );
    pointer-events: none;
}

.chat-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 30px;
}

.chat-hero-main {
    min-width: 0;
    max-width: 820px;
}

.ai-assistant-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 16px;
    padding: 7px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    background: rgba(239, 246, 255, 0.88);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.035em;
}

.ai-status-dot {
    position: relative;
    flex: 0 0 9px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #2563eb;
    box-shadow:
        0 0 0 4px rgba(37, 99, 235, 0.12);
}

.ai-status-dot::after {
    content: "";
    position: absolute;
    inset: -4px;
    border: 1px solid rgba(37, 99, 235, 0.28);
    border-radius: 50%;
    animation: ai-status-pulse 2s ease-out infinite;
}

@keyframes ai-status-pulse {
    0% {
        opacity: 0.8;
        transform: scale(0.7);
    }

    70%,
    100% {
        opacity: 0;
        transform: scale(1.7);
    }
}

.chat-hero .page-title {
    max-width: 760px;
    margin: 0;
    color: #0f172a;
    font-size: clamp(30px, 4vw, 47px);
    font-weight: 500;
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.chat-hero .page-subtitle {
    max-width: 780px;
    margin: 17px 0 0;
    padding: 0;
    color: #536176;
    font-size: 16px;
    line-height: 1.65;
}

.chat-hero-features {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 22px;
}

.hero-feature {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.hero-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    border-radius: 7px;
    color: #2563eb;
    background: #eaf2ff;
    font-size: 11px;
    font-weight: 900;
}

.chat-hero-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 12px;
}

.chat-hero .new-chat-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    padding: 10px 17px;
    border: 1px solid #2563eb;
    border-radius: 11px;
    color: #ffffff;
    background: #2563eb;
    box-shadow:
        0 7px 18px rgba(37, 99, 235, 0.2);
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.chat-hero .new-chat-link:hover {
    color: #ffffff;
    background: #1d4ed8;
    box-shadow:
        0 10px 24px rgba(37, 99, 235, 0.25);
    text-decoration: none;
    transform: translateY(-1px);
}

.ai-online-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #64748b;
    font-size: 11px;
    font-weight: 650;
}

.ai-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow:
        0 0 0 3px rgba(34, 197, 94, 0.13);
}

/* RTL */

[dir="rtl"] .chat-hero-glow {
    right: auto;
    left: -100px;
}

[dir="rtl"] .chat-hero {
    text-align: right;
}

[dir="rtl"] .chat-hero-content {
    direction: rtl;
}

[dir="rtl"] .chat-hero-actions {
    align-items: flex-start;
}

/* Tablet */

@media (max-width: 900px) {
    .chat-hero {
        padding: 25px;
    }

    .chat-hero-content {
        flex-direction: column;
        gap: 22px;
    }

    .chat-hero-actions {
        width: 100%;
        align-items: flex-start;
        flex-direction: row;
        justify-content: space-between;
    }

    [dir="rtl"] .chat-hero-actions {
        align-items: center;
    }
}

/* Mobile */

@media (max-width: 640px) {
    .chat-hero {
        margin-bottom: 16px;
        padding: 21px 18px;
        border-radius: 17px;
    }

    .ai-assistant-badge {
        margin-bottom: 13px;
        padding: 6px 10px;
        font-size: 10px;
    }

    .chat-hero .page-title {
        font-size: 29px;
        line-height: 1.13;
    }

    .chat-hero .page-subtitle {
        margin-top: 13px;
        font-size: 14px;
        line-height: 1.6;
    }

    .chat-hero-features {
        display: grid;
        gap: 9px;
        margin-top: 18px;
    }

    .hero-feature {
        white-space: normal;
    }

    .chat-hero-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .chat-hero .new-chat-link {
        width: 100%;
    }

    .ai-online-status {
        justify-content: center;
    }
}