* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: #252525;
    font-family: Arial, Helvetica, sans-serif;
    background: #f7f7f3;
}

a {
    color: inherit;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(16px, 4vw, 56px);
    background: #ffffff;
    border-bottom: 1px solid #dddddd;
}

.brand {
    display: flex;
    align-items: center;
}

.brand img {
    width: 172px;
    height: auto;
}

.site-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.site-header nav a {
    padding: 8px 12px;
    border-radius: 4px;
    text-decoration: none;
    background: #ece9df;
}

.site-header nav a.active {
    color: #ffffff;
    background: #2f6f73;
}

.bottom-nav,
.mobile-current-page {
    display: none;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px clamp(16px, 4vw, 40px) 28px;
}

.page-heading {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    margin-bottom: 12px;
}

.page-heading h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.2;
}

.page-heading p {
    justify-self: center;
    margin: 0;
    line-height: 1.5;
    text-align: center;
}


.order-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.order-steps {
    position: sticky;
    top: 92px;
    padding: 18px;
    color: #4c585b;
    border: 1px solid #d8d8d0;
    border-radius: 6px;
    background: #ece9df;
}

.order-steps ol {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.order-steps li {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border-left: 4px solid transparent;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.52);
    line-height: 1.3;
}

.order-steps li.active {
    color: #ffffff;
    border-left-color: #f1c84c;
    background: #2f6f73;
}

.order-steps span {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.order-form {
    display: grid;
    gap: 18px;
}

.form-section {
    display: grid;
    gap: 16px;
    padding: 20px;
    border: 1px solid #d8d8d0;
    border-radius: 6px;
    background: #ffffff;
}

.form-section h2,
.form-errors h2 {
    margin: 0;
    color: #1f565a;
    font-size: 21px;
    line-height: 1.25;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 14px;
}

.delivery-address-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.delivery-recipient {
    margin-bottom: 14px;
}

.delivery-contact,
.delivery-address-summary {
    margin: 0;
    font-weight: 400;
}

.field {
    display: grid;
    align-content: start;
    gap: 7px;
    min-width: 0;
    font-weight: 700;
}

.field.wide {
    grid-column: span 2;
}

.field.compact {
    max-width: 360px;
}

.field input,
.field select,
.field textarea,
.academic-year-select,
.quantity input {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    color: #252525;
    font: inherit;
    border: 2px solid #9aa9a6;
    border-radius: 4px;
    background: #ffffff;
}

.academic-year-select.is-next-year {
    color: #174d50;
    font-weight: 700;
    border-color: #2f6f73;
    background: #e5f3f1;
    box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.16);
}

.academic-year-select .next-academic-year {
    font-weight: 700;
}

.field textarea {
    resize: vertical;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.academic-year-select:focus-visible,
.quantity input:focus-visible,
.check-row:focus-within,
.lookup-option:focus-visible {
    outline: 3px solid rgba(47, 111, 115, 0.24);
    border-color: #2f6f73;
}

.business-registry-lookup {
    position: relative;
    display: grid;
    gap: 8px;
}

.lookup-results {
    display: grid;
    gap: 6px;
}

.lookup-results:empty {
    display: none;
}

.lookup-option {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 11px 12px;
    color: #252525;
    font: inherit;
    text-align: left;
    border: 1px solid #c7d4d1;
    border-radius: 4px;
    background: #f4f8f7;
    cursor: pointer;
}

.lookup-option:hover {
    border-color: #2f6f73;
    background: #e8f1ef;
}

.lookup-option strong {
    line-height: 1.3;
}

.lookup-option span,
.lookup-message {
    color: #4c585b;
    font-size: 14px;
    line-height: 1.35;
}

.lookup-message {
    padding: 10px 12px;
    border: 1px solid #d8d8d0;
    border-radius: 4px;
    background: #ffffff;
}

.product-list {
    display: grid;
    max-height: clamp(240px, calc(100vh - 390px), 650px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    border: 1px solid #d8d8d0;
    border-radius: 6px;
}

.product-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: end;
}

.order-layout[data-step="2"] .order-form {
    gap: 12px;
}

.order-layout[data-step="2"] .form-section {
    gap: 10px;
    padding: 16px;
}

.order-layout[data-step="2"] .product-row {
    padding-top: 8px;
    padding-bottom: 8px;
}

.order-layout[data-step="2"] .product-group-heading {
    padding-top: 7px;
    padding-bottom: 7px;
}

.order-layout[data-step="2"] .form-actions button,
.order-layout[data-step="2"] .form-actions a {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.product-price-note {
    display: grid;
    justify-items: end;
    margin: 0;
    color: #4c585b;
    font-size: 14px;
    line-height: 1.4;
    text-align: right;
}

.product-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 80px 55px 90px;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: #ffffff;
    border-top: 1px solid #ece9df;
}

.product-row:first-child {
    border-top: 0;
}

.product-head {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #4c585b;
    font-weight: 700;
    background: #f4f8f7;
    box-shadow: 0 1px 0 #d8d8d0;
}

.product-head span {
    text-align: center;
}

.product-price,
.product-line-total {
    text-align: right;
}

.product-discount {
    text-align: center;
}

.product-group-heading {
    padding: 9px 12px;
    color: #244f52;
    border-top: 1px solid #d8d8d0;
    background: #e4efed;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

.product-name {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.product-name strong {
    line-height: 1.3;
}

.product-price,
.product-line-total {
    font-weight: 700;
}

.product-total {
    margin: 0;
    text-align: right;
}

.quantity span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.check-row {
    display: inline-grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: start;
    justify-self: start;
    padding: 10px 12px;
    border: 1px solid #d8d8d0;
    border-radius: 4px;
    background: #f4f8f7;
    font-weight: 700;
}

.check-row input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: #2f6f73;
}

.check-row.is-unselected {
    color: #687376;
    background: #f0f1ef;
}

.invoice-party-name {
    margin: 0;
    color: #252525;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
}

.invoice-party-note {
    margin: -10px 0 0;
    color: #4c585b;
}

.invoice-party-address {
    margin: 0;
    color: #4c585b;
    font-size: 14px;
    line-height: 1.45;
}

.invoice-party-lookup[hidden] {
    display: none !important;
}

.invoice-payer-choice {
    display: grid;
    gap: 10px;
}

.invoice-party-lookup {
    width: 100%;
    max-width: 680px;
}

.form-errors {
    margin-bottom: 18px;
    padding: 16px 18px;
    color: #762b1f;
    border: 1px solid #d8988d;
    border-radius: 6px;
    background: #fff0ed;
}

.form-errors ul {
    margin: 10px 0 0;
    padding-left: 20px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.form-actions button,
.form-actions a,
.submitted a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 22px;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    border: 0;
    border-radius: 4px;
    background: #2f6f73;
    cursor: pointer;
}

.form-actions button:hover,
.form-actions button:focus-visible,
.form-actions a:hover,
.form-actions a:focus-visible,
.submitted a:hover,
.submitted a:focus-visible {
    background: #24575b;
}

.submitted {
    display: grid;
    gap: 14px;
    max-width: 620px;
    padding: 24px;
    border: 1px solid #d8d8d0;
    border-radius: 6px;
    background: #ffffff;
}

.submitted h1,
.submitted p {
    margin: 0;
}

.submitted a {
    justify-self: start;
}

.reference {
    color: #4c585b;
    overflow-wrap: anywhere;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px 18px;
    width: 100%;
    margin: 0 auto;
    padding: 20px clamp(16px, 4vw, 40px) 28px;
    text-align: center;
    color: #4c585b;
    font-size: 14px;
    border-top: 1px solid #d8d8d0;
}

.site-footer a {
    color: #005ea8;
    font-weight: 700;
    text-underline-offset: 2px;
}

@media (max-width: 760px) {
    body {
        padding-bottom: 74px;
    }

    .site-header {
        justify-content: center;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .site-header nav,
    .mobile-current-page {
        display: none;
    }

    .brand img {
        width: 138px;
    }

    .bottom-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
        background: #ffffff;
        border-top: 1px solid #d8d8d0;
        box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
    }

    .bottom-nav a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        min-height: 44px;
        padding: 7px 4px;
        color: #252525;
        font-size: 13px;
        font-weight: 700;
        text-align: center;
        text-decoration: none;
        border-radius: 4px;
        background: #ece9df;
    }

    .bottom-nav a.active {
        color: #ffffff;
        background: #2f6f73;
    }

    main {
        padding-bottom: 34px;
    }

    .page-heading {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .page-heading p {
        justify-self: start;
        text-align: left;
    }

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

    .order-steps {
        position: static;
        padding: 12px;
    }

    .order-steps ol {
        gap: 8px;
    }

    .delivery-address-fields,
    .field-grid,
    .product-row {
        grid-template-columns: 1fr;
    }

    .field.wide {
        grid-column: auto;
    }

    .field.compact {
        max-width: none;
    }

    .product-toolbar {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .product-price-note {
        justify-items: start;
        text-align: left;
    }

    .product-head {
        display: none;
    }

    .product-list {
        max-height: none;
        overflow-y: visible;
        overscroll-behavior: auto;
        scrollbar-gutter: auto;
    }

    .product-row {
        gap: 8px;
        padding: 14px;
    }

    .order-layout[data-step="2"] .product-row {
        padding: 14px;
    }

    .product-price::before {
        content: "Hind*: ";
        color: #4c585b;
        font-weight: 400;
    }

    .product-line-total::before {
        content: "Summa: ";
        color: #4c585b;
        font-weight: 400;
    }

    .product-discount:not(.product-discount-empty)::before {
        content: "AH%: ";
        color: #4c585b;
        font-weight: 400;
    }

    .form-actions button,
    .form-actions a {
        width: 100%;
    }
}

.field .field-error { color: #c00000; font-size: 0.875rem; }
.field-error:empty { display: none; }
.order-form [aria-invalid="true"],
.order-form .field [aria-invalid="true"]:focus-visible {
    border-color: #c00000;
    background-color: #fff5f5;
    box-shadow: 0 0 0 1px #c00000;
}
.field small { font-weight: 400; line-height: 1.4; }


.buyer-error { color: #b91c1c; }
.buyer-summary { display: grid; gap: 8px; margin: 16px 0; overflow-wrap: anywhere; }
#school-lookup-query { color: #1f565a; font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.buyer-summary p { margin: 0; min-height: 1.5em; }
.buyer-field-label { color: #6b7280; }
.buyer-locality > span:empty { display: none; }
.buyer-locality > span:not(:empty) ~ span:not(:empty)::before { content: ", "; }

#wizard-container .form-errors, #wizard-request-error { color: #b91c1c; }

.wizard-fields { border: 0; padding: 0; margin: 0; min-width: 0; }

.buyer-success { color: #1f565a; margin: 10px 0 0; }
.buyer-refresh-loading { display: none; }
.buyer-refresh.htmx-request .buyer-refresh-idle { display: none; }
.buyer-refresh.htmx-request .buyer-refresh-loading { display: inline; }
.buyer-refresh.htmx-request { cursor: wait; }

.field input[readonly] { background-color: #edf0ef; color: #606a68; border-color: #b8c1be; cursor: default; }
