.ordini-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    --page-gutter: 1.5rem;
    --section-space: 3rem;
    background:
        linear-gradient(180deg, rgba(16, 12, 10, 0.88) 0%, rgba(16, 12, 10, 0.94) 100%),
        url("/images/Legno2.jpg") center/cover no-repeat fixed;
}

.ordini-page main {
    flex: 1;
    padding: var(--section-space) var(--page-gutter) 4rem;
}

.ordini-shell {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--section-space);
}

.ordini-intro {
    max-width: 38rem;
}

.ordini-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--wood);
    margin: 0 0 0.65rem;
    font-weight: 600;
}

.ordini-title {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    font-weight: 500;
    line-height: 1.12;
    margin: 0 0 0.85rem;
    color: var(--paper);
}

.ordini-lede {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--paper-2);
    max-width: 32rem;
}

.ordini-summary {
    margin: 1rem 0 0;
    font-size: 0.88rem;
    color: var(--wood);
    letter-spacing: 0.02em;
}

.ordini-band {
    padding-top: var(--section-space);
    border-top: 1px solid rgba(243, 235, 224, 0.22);
}

.ordini-loading,
.ordini-error {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.45;
    grid-column: 1 / -1;
}

.ordini-error {
    color: #e8b4b4;
}

.ordini-empty {
    text-align: left;
    padding: 0.5rem 0 1rem;
}

.ordini-empty-lede {
    margin: 0 0 0.45rem;
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--paper);
}

.ordini-empty-hint {
    margin: 0 0 1.25rem;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 26rem;
}

.ordini-list {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

/* Modulo ordine — contenuto bottega, non legacy */
.ordine-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 1.15rem 1rem 1rem;
    background:
        linear-gradient(180deg, rgba(243, 235, 224, 0.035) 0%, transparent 42%),
        rgba(26, 20, 16, 0.52);
    border: 1px solid rgba(243, 235, 224, 0.14);
    border-radius: 0;
}

.ordine-card-head {
    margin-bottom: 0.85rem;
}

.ordine-date {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wood);
}

.ordine-date i {
    font-size: 0.95em;
    opacity: 0.92;
}

.ordine-meta {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.35;
    color: var(--paper);
    font-family: var(--font-display);
    font-weight: 500;
    cursor: pointer;
}

.ordine-meta strong {
    color: var(--wood);
    font-weight: 600;
}

.ordine-meta-sep {
    color: var(--muted);
    font-weight: 400;
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.ordine-card-body {
    margin-bottom: 0.15rem;
}

/* Pezzi — foto integrate, senza cerchi bianco-contraste */
.ordine-pezzi {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.2rem 0 0.3rem;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 165, 116, 0.35) transparent;
    -webkit-overflow-scrolling: touch;
}

.ordine-pezzi::-webkit-scrollbar {
    height: 5px;
}

.ordine-pezzi::-webkit-scrollbar-thumb {
    background: rgba(196, 165, 116, 0.35);
    border-radius: 3px;
}

.ordine-pezzo {
    flex: 0 0 auto;
    width: 6.875rem;
    min-width: 6.875rem;
    max-width: 6.875rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.3rem 0.35rem;
    background:
        linear-gradient(180deg, rgba(243, 235, 224, 0.045) 0%, transparent 52%),
        rgba(16, 12, 10, 0.48);
    border: 1px solid rgba(243, 235, 224, 0.1);
    border-radius: 0;
    text-align: center;
    color: inherit;
    font: inherit;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ordine-pezzo-clickable {
    cursor: pointer;
}

.ordine-pezzo-clickable:hover {
    background:
        linear-gradient(180deg, rgba(243, 235, 224, 0.08) 0%, transparent 52%),
        rgba(22, 17, 14, 0.62);
    border-color: rgba(196, 165, 116, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.ordine-pezzo-clickable:hover .ordine-pezzo-img-wrap {
    border-color: rgba(196, 165, 116, 0.38);
}

.ordine-pezzo-img-wrap {
    width: 3.65rem;
    height: 3.65rem;
    border-radius: 4px;
    overflow: hidden;
    padding: 0;
    border: 1px solid rgba(243, 235, 224, 0.1);
    background: rgba(16, 12, 10, 0.55);
    box-shadow: inset 0 0 0 1px rgba(243, 235, 224, 0.06);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.ordine-pezzo-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 4px;
    filter:
        drop-shadow(0 1px 2px rgba(0, 0, 0, 0.28))
        drop-shadow(0 3px 6px rgba(0, 0, 0, 0.18));
}

.ordine-pezzo-img-wrap--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ordine-pezzo-name {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--paper);
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ordine-pezzo-meta {
    font-size: 0.65rem;
    color: var(--muted);
    line-height: 1.15;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ordine-pezzi-empty {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
    font-style: italic;
}

.ordine-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(243, 235, 224, 0.1);
}

.ordine-toggle-details {
    padding: 0;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 0.88rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.ordine-toggle-details:hover {
    color: var(--paper-2);
}

.ordine-toggle-icon {
    font-size: 0.62rem;
    text-decoration: none;
    transition: transform 0.25s ease;
}

.ordine-card.expanded .ordine-toggle-icon {
    transform: rotate(180deg);
}

.ordine-review-btn {
    min-width: auto;
    padding: 0.45rem 0.95rem;
    font-size: 0.82rem;
}

.ordine-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(243, 235, 224, 0.08);
    animation: ordine-details-in 0.22s ease-out;
}

@keyframes ordine-details-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ordine-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.65rem 1.25rem;
    margin: 0;
}

.ordine-details-grid dt {
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.ordine-details-grid dd {
    margin: 0.15rem 0 0;
    font-size: 0.95rem;
    color: var(--paper);
    font-weight: 500;
}

/* Modali */
.ordini-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ordini-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.ordini-modal-content {
    position: relative;
    z-index: 1;
    width: min(480px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(196, 165, 116, 0.08) 0%, transparent 38%),
        var(--ink-2);
    border: 1px solid rgba(243, 235, 224, 0.18);
    color: var(--paper);
    padding: 1.35rem 1.25rem 1.15rem;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.ordini-modal-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--wood);
}

.ordini-modal-title {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 4vw, 1.4rem);
    font-weight: 500;
    line-height: 1.25;
    margin: 0 2rem 0.45rem 0;
    color: var(--paper);
}

.ordini-modal-lede {
    margin: 0 0 1rem;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--muted);
}

.ordini-modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--paper-2);
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
}

.ordini-modal-close:hover {
    color: var(--paper);
}

.ordini-review-choice-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ordini-review-choice-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-size: 0.92rem;
    color: var(--paper);
    background: rgba(16, 12, 10, 0.55);
    border: 1px solid rgba(243, 235, 224, 0.14);
    border-radius: 0;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.ordini-review-choice-item:hover {
    border-color: rgba(196, 165, 116, 0.45);
    background: rgba(26, 20, 16, 0.75);
}

.ordini-review-choice-thumb {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(16, 12, 10, 0.65);
    border: 1px solid rgba(243, 235, 224, 0.1);
    display: grid;
    place-items: center;
}

.ordini-review-choice-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

.ordini-review-choice-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.ordini-review-choice-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.ordini-review-choice-name {
    font-weight: 500;
    color: var(--paper);
    line-height: 1.25;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ordini-review-choice-version {
    flex-shrink: 0;
    color: var(--wood);
    font-size: 0.78rem;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.ordini-review-choice-meta {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.2;
}

.ordini-review-scan-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
}

.ordini-review-scan-btn i {
    font-size: 1.05rem;
    opacity: 0.92;
}

.ordini-form-error {
    margin: 0 0 0.65rem;
    color: #e8b4b4;
    font-size: 0.88rem;
}

/* Scanner QR pacchetto */
.qr-scanner-popup {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: flex-start;
    justify-content: center;
}

.qr-scanner-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.qr-scanner-content {
    position: relative;
    z-index: 1;
    width: min(480px, 92vw);
    margin: 8vh auto 0;
    background: var(--ink-2);
    border: 1px solid var(--line);
    color: var(--paper);
    padding: 1rem 1.1rem 1.3rem;
}

.qr-scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.qr-scanner-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.qr-scanner-close {
    border: 0;
    background: transparent;
    color: var(--paper);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.qr-scanner-hint {
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Preview ricetta fullscreen */
.ordini-recipe-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding:
        max(0.75rem, env(safe-area-inset-top))
        max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom))
        max(0.75rem, env(safe-area-inset-left));
    box-sizing: border-box;
}

.ordini-recipe-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
}

.ordini-recipe-panel {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100dvh - 1.5rem);
    max-height: calc(100vh - 1.5rem);
    display: flex;
    flex-direction: column;
    background: var(--ink-2);
    border: 1px solid rgba(243, 235, 224, 0.16);
    border-radius: 4px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.ordini-recipe-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.15rem 0.65rem;
    border-bottom: 1px solid rgba(243, 235, 224, 0.12);
    flex-shrink: 0;
}

.ordini-recipe-head-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 0.5rem;
}

.ordini-recipe-head-actions .ordini-modal-close {
    position: static;
    top: auto;
    right: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ordini-recipe-open {
    color: var(--wood);
    font-size: 0.88rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ordini-recipe-open:hover {
    color: var(--paper);
}

.ordini-recipe-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.ordini-recipe-body .ordini-loading,
.ordini-recipe-body .ordini-form-error {
    padding: 1.25rem;
}

#recipe-preview-iframe {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 0;
    background: var(--ink);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .ordini-page main {
        padding-top: 2rem;
    }

    .ordine-card {
        padding: 1rem 0.85rem 0.9rem;
    }

    .ordine-pezzo {
        width: 5.3125rem;
        min-width: 5.3125rem;
        max-width: 5.3125rem;
        padding: 0.35rem 0.25rem 0.28rem;
    }

    .ordine-pezzo-img-wrap {
        width: 3.15rem;
        height: 3.15rem;
    }

    .ordini-recipe-modal {
        padding:
            max(0.65rem, env(safe-area-inset-top))
            max(0.65rem, env(safe-area-inset-right))
            max(0.65rem, env(safe-area-inset-bottom))
            max(0.65rem, env(safe-area-inset-left));
    }

    .ordini-recipe-panel {
        width: 100%;
    }
}
