:root {
    --bg: radial-gradient(circle at 10% 10%, #ffe8ba 0%, #fff8e8 35%, #fffdf7 100%);
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #b45309;
    --accent-strong: #92400e;
    --line: #f1e6d2;
    --ok: #065f46;
    --error: #991b1b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background: var(--bg);
    scroll-behavior: smooth;
}

.layout {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 0 1rem 1rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

/* When the app is showing only the authentication view (app shell hidden),
   center the layout in the middle of the viewport for a compact login UX.
   We toggle `body.auth-only` from JS when the authenticated state is false. */
body.auth-only .layout {
    min-height: 100dvh;
    display: grid; /* keep existing grid behaviour */
    align-items: center; /* vertical centering */
    justify-items: center; /* horizontal centering of child elements */
    padding-top: 0; /* reduce top offset so centering feels natural */
    padding-bottom: 0.5rem;
}

#app-shell:not(.hidden) {
    --app-shell-gap: 1rem;
    display: grid;
    gap: var(--app-shell-gap);
    grid-column: 1 / -1;
}

#app-shell.hidden {
    display: none;
}

.hero {
    padding: 5px 1.25rem 1.25rem;
    border-radius: 0 0 1rem 1rem;
    background: linear-gradient(135deg, #1f2937, #374151);
    color: #fff;
    box-shadow: 0 16px 40px rgba(17, 24, 39, 0.2);
    animation: slide-in 350ms ease-out;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.hero-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.hero-brand-copy {
    min-width: 0;
}

.app-logo {
    display: block;
    border-radius: 1.15rem;
    object-fit: contain;
    border: 2px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.2);
}

.app-logo--hero {
    width: 74px;
    height: 74px;
    flex-shrink: 0;
}

.app-logo--auth {
    width: 92px;
    height: 92px;
    margin: 0 auto 0.65rem;
    border-color: #bfdbfe;
}

.hero h1 {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.hero-manager-label {
    margin: 0.4rem 0 0;
    color: #dbeafe;
    font-size: 0.88rem;
    font-weight: 700;
}

.hero p {
    margin: 0.5rem 0 0;
    color: #e5e7eb;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 8px 20px rgba(180, 83, 9, 0.08);
    animation: fade-up 400ms ease both;
}

.card:nth-of-type(2) {
    animation-delay: 100ms;
}

.auth-card {
    width: min(560px, 100%);
    justify-self: center;
    grid-column: 1 / -1;
}

.auth-copy {
    margin: 0.35rem 0 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

#login-form #login-button {
    margin-top: 0.7rem;
}

.session-bar {
    margin-top: 0.85rem;
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    color: #f9fafb;
    font-size: 0.82rem;
    font-weight: 700;
    position: relative;
}

.session-bar .ghost {
    min-height: 36px;
    padding: 0.28rem 0.56rem;
    border-radius: 0.6rem;
    font-size: 0.74rem;
    white-space: nowrap;
    background: rgba(229, 231, 235, 0.95);
}

.pricing-rule-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #fef3c7;
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    padding: 0.24rem 0.58rem;
    white-space: nowrap;
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    width: 100%;
    padding: 0.22rem;
    border-radius: 0.7rem;
    background: rgba(15, 23, 42, 0.28);
    overflow: hidden;
    min-width: 0;
}

.session-actions-overflow {
    position: relative;
    justify-self: end;
}

.session-actions-overflow-toggle {
    min-height: 36px;
    padding: 0.28rem 0.56rem;
    border-radius: 0.6rem;
    font-size: 0.74rem;
}

.session-actions-overflow-menu {
    position: absolute;
    top: calc(100% + 0.32rem);
    right: 0;
    z-index: 60;
    min-width: 220px;
    display: grid;
    gap: 0.22rem;
    padding: 0.38rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 0.7rem;
    background: #f8fafc;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.24);
}

.session-actions-overflow-item {
    width: 100%;
    min-height: 36px;
    justify-content: flex-start;
    border: 1px solid #e2e8f0;
    border-radius: 0.55rem;
    background: #ffffff;
    color: #1f2937;
    font-size: 0.78rem;
    font-weight: 700;
}

.session-actions-overflow-item:hover {
    background: #eff6ff;
    color: #1e3a8a;
    border-color: #bfdbfe;
}

.session-actions-overflow-item:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
}

.session-bar.has-actions-overflow .session-actions {
    display: none;
}

.session-bar.has-actions-overflow .session-actions-overflow-toggle {
    display: inline-flex;
}

.change-password-form {
    margin-top: 0.75rem;
    padding: 0.8rem;
    border: 1px solid rgba(229, 231, 235, 0.65);
    border-radius: 0.85rem;
    background: rgba(17, 24, 39, 0.22);
}

.change-password-form label {
    margin-top: 0.5rem;
    color: #e5e7eb;
    font-size: 0.82rem;
}

.change-password-form input {
    min-height: 40px;
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(255, 255, 255, 0.96);
}

.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 5.6rem;
}

.password-visibility-toggle {
    position: absolute;
    top: 50%;
    right: 0.4rem;
    transform: translateY(-50%);
    min-height: 36px;
    padding: 0.25rem 0.55rem;
    border-radius: 0.55rem;
    font-size: 0.75rem;
    font-weight: 800;
    background: #334155;
    color: #f8fafc;
}

.password-visibility-toggle:hover {
    background: #1e293b;
}

.change-password-form .actions {
    margin-top: 0.75rem;
}

.change-password-form .message {
    margin-top: 0.55rem;
    color: #e5e7eb;
}

.change-password-form .message.success {
    color: #86efac;
}

.change-password-form .message.error {
    color: #fca5a5;
}

.app-top-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 calc(-1 * var(--app-shell-gap, 1rem) - 2px);
    padding: 0.45rem 0.55rem;
    position: sticky;
    top: 0;
    z-index: 50;
    border: 0;
    border-radius: 0;
    background: linear-gradient(135deg, #1f2937, #374151);
    box-shadow: 0 16px 40px rgba(17, 24, 39, 0.2);
}

.app-top-nav__links {
    grid-column: 2;
    justify-self: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.app-top-nav__links a {
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fef3c7;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(253, 186, 116, 0.45);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-top-nav__links a:hover {
    background: rgba(255, 255, 255, 0.16);
}

.app-top-nav__links a.hidden {
    display: none;
}

.app-top-nav__account-actions {
    grid-column: 3;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.app-top-nav__action {
    min-height: 36px;
    border: 1px solid rgba(253, 186, 116, 0.45);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fef3c7;
    font-weight: 800;
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-top-nav__action:hover {
    background: rgba(255, 255, 255, 0.16);
}

.app-top-nav__action--icon {
    width: 36px;
    min-width: 36px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}

#new-order-section,
#orders-section,
#backoffice-section,
#managers-section {
    scroll-margin-top: 5rem;
}

label {
    display: block;
    margin: 0.75rem 0 0.35rem;
    font-weight: 700;
    font-size: 0.92rem;
}

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

input,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #fff;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
button:focus,
a:focus {
    outline: 3px solid rgba(180, 83, 9, 0.2);
    outline-offset: 1px;
}

.buyer-fields {
    display: block;
}

.buyer-name-search {
    position: relative;
}

.buyer-search-hint {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.buyer-search-results {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 12;
    display: grid;
    gap: 0.35rem;
    padding: 0.45rem;
    border: 1px solid #e5c48a;
    border-radius: 0.85rem;
    background: rgba(255, 251, 235, 0.98);
    box-shadow: 0 14px 32px rgba(120, 53, 15, 0.14);
}

.buyer-search-results__option {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid #f4c98a;
    border-radius: 0.7rem;
    background: #ffffff;
    color: #7c2d12;
    text-align: left;
}

.buyer-search-results__option:hover {
    background: #fff7ed;
    color: #7c2d12;
}

.buyer-search-results__name,
.buyer-search-results__phone {
    display: block;
}

.buyer-search-results__name {
    font-weight: 800;
}

.buyer-search-results__phone {
    color: var(--muted);
    font-size: 0.82rem;
}

.choice-group-block {
    margin-top: 0.9rem;
    padding: 0.85rem;
    border: 1px solid #ead8b7;
    border-radius: 0.9rem;
    background: linear-gradient(180deg, #fffaf0, #fffdf7);
}

.choice-groups {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
}

.choice-group-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.choice-group-header label {
    margin: 0;
}

.choice-feedback {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.choice-hint {
    margin: 0.35rem 0 0;
    color: #9a3412;
    font-size: 0.84rem;
    font-weight: 600;
}

.choice-feedback.is-selected {
    color: var(--ok);
}

.choice-grid {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

#new-order-section #color-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#new-order-section #size-choices {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-button {
    --choice-bg: #fff7ed;
    --choice-text: #7c2d12;
    --choice-border: #fdba74;
    --choice-selected-start: #b45309;
    --choice-selected-end: #92400e;
    --choice-selected-text: #ffffff;
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--choice-border);
    background: var(--choice-bg);
    color: var(--choice-text);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.choice-button:hover {
    background: color-mix(in srgb, var(--choice-bg) 80%, #ffffff 20%);
    color: var(--choice-text);
}

.choice-button.is-selected {
    background: linear-gradient(135deg, var(--choice-selected-start), var(--choice-selected-end));
    color: var(--choice-selected-text);
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(180, 83, 9, 0.24);
}

@media (min-width: 520px) {
    .choice-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ─── Pending items list ─────────────────────────────────────────────────────── */

.pending-section {
    margin-top: 1rem;
    padding: 0.85rem;
    border: 1.5px solid #d1fae5;
    border-radius: 0.9rem;
    background: linear-gradient(180deg, #f0fdf4, #f7fef9);
}

.pending-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.pending-title {
    font-weight: 800;
    font-size: 0.92rem;
    color: #065f46;
}

.pending-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    grid-auto-rows: 44px;
}

.pending-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    height: 44px;
    padding: 0.35rem 0.65rem;
    background: #ffffff;
    border: 1px solid #a7f3d0;
    border-radius: 0.6rem;
    font-weight: 700;
    box-sizing: border-box;
}

.pending-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.pending-dot--white  { background: #ffffff; }
.pending-dot--red    { background: #ef4444; }
.pending-dot--yellow { background: #f59e0b; }
.pending-dot--orange { background: #f97316; }
.pending-dot--blue   { background: #3b82f6; }
.pending-dot--green  { background: #22c55e; }

.pending-item-label {
    flex: 1;
    font-size: 0.9rem;
    color: #065f46;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pending-item-remove {
    min-height: unset;
    height: 36px;
    width: 36px;
    padding: 0;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 50%;
    font-size: 0.75rem;
    line-height: 1;
}

.pending-item-remove:hover {
    background: #fca5a5;
    color: #7f1d1d;
    transform: none;
}

.place-orders-btn {
    width: 100%;
    background: linear-gradient(135deg, #059669, #065f46);
    color: #fff;
    font-size: 1rem;
}

.choice-button--white {
    --choice-bg: #ffffff;
    --choice-text: #334155;
    --choice-border: #cbd5e1;
    --choice-selected-start: #475569;
    --choice-selected-end: #1e293b;
}

.choice-button--red {
    --choice-bg: #fee2e2;
    --choice-text: #991b1b;
    --choice-border: #fca5a5;
    --choice-selected-start: #dc2626;
    --choice-selected-end: #991b1b;
}

.choice-button--yellow {
    --choice-bg: #fef3c7;
    --choice-text: #92400e;
    --choice-border: #fcd34d;
    --choice-selected-start: #f59e0b;
    --choice-selected-end: #b45309;
}

.choice-button--orange {
    --choice-bg: #ffedd5;
    --choice-text: #9a3412;
    --choice-border: #fdba74;
    --choice-selected-start: #f97316;
    --choice-selected-end: #c2410c;
}

.choice-button--blue {
    --choice-bg: #dbeafe;
    --choice-text: #1d4ed8;
    --choice-border: #93c5fd;
    --choice-selected-start: #2563eb;
    --choice-selected-end: #1e40af;
}

.choice-button--green {
    --choice-bg: #dcfce7;
    --choice-text: #166534;
    --choice-border: #86efac;
    --choice-selected-start: #16a34a;
    --choice-selected-end: #166534;
}

.actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

button,
.join-link,
.sms-link,
.whatsapp-link,
.pickup-whatsapp-link {
    border: 0;
    border-radius: 0.75rem;
    min-height: 36px;
    padding: 0.65rem 1rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

button,
.join-link,
.sms-link,
.whatsapp-link,
.pickup-whatsapp-link {
    background: var(--accent);
    color: #fff;
    transition: transform 120ms ease, background 120ms ease;
}

button:hover,
.join-link:hover,
.sms-link:hover,
.whatsapp-link:hover,
.pickup-whatsapp-link:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

.whatsapp-link {
    background: #16a34a;
}

.whatsapp-link:hover {
    background: #15803d;
}

.pickup-whatsapp-link {
    background: #0f766e;
}

.pickup-whatsapp-link:hover {
    background: #115e59;
}

.sms-link {
    background: #2563eb;
}

.sms-link:hover {
    background: #1d4ed8;
}

.sms-link.is-sent {
    background: #d1d5db;
    color: #374151;
}

.sms-link.is-sent:hover,
.whatsapp-link.is-sent:hover {
    background: #9ca3af;
    color: #1f2937;
}

.whatsapp-link.is-sent {
    background: #d1d5db;
    color: #374151;
}

.delete-btn {
    background: #dc2626;
}

.delete-btn:hover {
    background: #b91c1c;
}

.delete-btn:disabled {
    background: #9ca3af;
    color: #374151;
    cursor: not-allowed;
}

button.ghost {
    background: #e5e7eb;
    color: #374151;
}

.hidden {
    display: none;
}

.message {
    margin: 0.75rem 0 0;
    min-height: 1.25rem;
    font-weight: 600;
}

.message.success {
    color: var(--ok);
}

.message.error {
    color: var(--error);
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.orders-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.email-orders-btn {
    background: linear-gradient(135deg, #0f766e, #115e59);
    color: #fff;
    min-height: 36px;
    padding: 0.5rem 0.8rem;
    border-radius: 0.6rem;
    font-size: 0.82rem;
}

.email-orders-btn:hover {
    background: linear-gradient(135deg, #0d9488, #0f766e);
}

.email-orders-btn:disabled {
    background: #9ca3af;
    color: #374151;
    cursor: not-allowed;
}

.orders-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.orders-toggle input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.orders-toggle__track {
    position: relative;
    width: 2.35rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #d6d3d1;
    box-shadow: inset 0 0 0 1px rgba(68, 64, 60, 0.12);
    transition: background 0.16s ease, box-shadow 0.16s ease;
}

.orders-toggle__track::after {
    content: "";
    position: absolute;
    top: 0.18rem;
    left: 0.18rem;
    width: 0.89rem;
    height: 0.89rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
    transition: transform 0.16s ease;
}

.orders-toggle input:checked + .orders-toggle__track {
    background: #0f766e;
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.2);
}

.orders-toggle input:checked + .orders-toggle__track::after {
    transform: translateX(1.1rem);
}

.orders-toggle input:focus-visible + .orders-toggle__track {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

.orders-toggle__label {
    white-space: nowrap;
}

.orders-search-label {
    margin-top: 0.65rem;
    font-size: 0.84rem;
}

#orders-search {
    margin-top: 0.25rem;
}

.pill {
    background: #fef3c7;
    color: #7c2d12;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-weight: 800;
}

.orders-list {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.75rem;
}

.buyer-orders-group {
    border: 1px solid #f3dcb5;
    border-radius: 0.95rem;
    background: linear-gradient(180deg, #fff8ef, #fffdf8);
    padding: 0.75rem;
    display: grid;
    gap: 0.65rem;
}

.buyer-orders-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.2rem 0.15rem;
    position: relative;
    padding-right: 5.5rem;
}

.buyer-orders-group-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.buyer-orders-group-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.buyer-orders-group-action {
    min-height: 36px;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
}

.buyer-orders-group-amount {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #f59e0b;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    padding: 0.24rem 0.58rem;
    white-space: nowrap;
}

.buyer-orders-group-amount--top-right {
    position: absolute;
    top: 0.2rem;
    right: 0.15rem;
}

.buyer-orders-group-buyer {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 800;
    color: #9a3412;
}

.buyer-orders-group-total {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    background: #fde68a;
    color: #92400e;
}

.buyer-orders-group-toggle {
    background: #1f2937;
}

.buyer-orders-group-toggle:hover {
    background: #111827;
}

.buyer-orders-group-list {
    display: grid;
    gap: 0.6rem;
}

.orders-more-info {
    border: 1px dashed #fdba74;
    background: #fff7ed;
    border-radius: 0.8rem;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.orders-more-text {
    margin: 0;
    color: #9a3412;
    font-size: 0.86rem;
    font-weight: 700;
}

.orders-show-more-btn {
    min-height: 36px;
    padding: 0.45rem 0.8rem;
    border-radius: 0.65rem;
    background: #1f2937;
}

.orders-show-more-btn:hover {
    background: #111827;
}

.backoffice-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 0.65rem;
    margin-top: 0.7rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
}

.backoffice-title-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.backoffice-summary-card {
    border: 1px solid #f2dfbe;
    border-radius: 0.8rem;
    padding: 0.6rem;
    background: #fffbf4;
    min-width: 150px;
}

.backoffice-summary-card h3 {
    margin: 0;
    font-size: 0.8rem;
    color: #9a3412;
}

.backoffice-summary-card p {
    margin: 0.25rem 0 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #1f2937;
}

.backoffice-summary-tags {
    margin-top: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.backoffice-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    background: #fef3c7;
    color: #7c2d12;
}

.backoffice-controls {
    margin-top: 0.8rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.45rem 0.65rem;
    align-items: end;
}

.backoffice-controls label {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    color: #6b7280;
}

.backoffice-controls input,
.backoffice-controls select {
    width: 100%;
    min-height: 38px;
    border: 1px solid #d6d3d1;
    border-radius: 0.6rem;
    padding: 0.45rem 0.55rem;
    background: #ffffff;
}

.backoffice-columns {
    margin-top: 0.55rem;
    padding: 0.55rem 0.6rem;
    border: 1px dashed #f1cc95;
    border-radius: 0.75rem;
    background: #fffaf2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.7rem;
    align-items: center;
}

.backoffice-columns-title {
    font-size: 0.76rem;
    font-weight: 800;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.backoffice-columns-reset {
    min-height: 36px;
    padding: 0.2rem 0.55rem;
    border-radius: 0.5rem;
    font-size: 0.74rem;
    font-weight: 800;
    background: #1f2937;
}

.backoffice-columns-reset:hover {
    background: #111827;
}

.backoffice-column-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    font-size: 0.76rem;
    font-weight: 700;
    color: #374151;
}

.backoffice-column-toggle input {
    width: auto;
    min-height: auto;
}

.backoffice-table-wrap {
    margin-top: 0.85rem;
    overflow: auto;
    border: 1px solid #e7dcc9;
    border-radius: 0.75rem;
    max-height: 68vh;
    background: #fff;
}

.backoffice-table {
    width: 100%;
    border-collapse: collapse;
    min-width: max(980px, 100%);
    font-size: 0.82rem;
}

.backoffice-table th,
.backoffice-table td {
    border-bottom: 1px solid #eee4d1;
    padding: 0.45rem 0.5rem;
    text-align: left;
    vertical-align: top;
}

.backoffice-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fffbf4;
    color: #92400e;
    font-weight: 800;
}

.backoffice-table .bo-col-hidden {
    display: none;
}

.backoffice-table .bo-sticky {
    position: sticky;
    z-index: 2;
    background: #fffdfa;
}

.backoffice-table th.bo-sticky {
    z-index: 4;
    background: #fff7ed;
}

.backoffice-table .bo-sticky-1 {
    left: 0;
    min-width: 110px;
}

.backoffice-table .bo-sticky-2 {
    left: 110px;
    min-width: 220px;
}

.backoffice-table .bo-sticky-3 {
    left: 330px;
    min-width: 155px;
    border-right: 1px solid #f1e2ca;
    box-shadow: 10px 0 14px -10px rgba(146, 64, 14, 0.5);
}

.backoffice-table tbody tr:hover {
    background: #fffcf8;
}

.backoffice-table tbody tr:hover .bo-sticky {
    background: #fffcf8;
}

.backoffice-group-row td {
    background: #fff7ed;
    color: #9a3412;
    font-weight: 800;
    border-bottom-color: #fdba74;
}

.backoffice-row-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.backoffice-row-status.is-pending {
    background: #fef3c7;
    color: #92400e;
}

.backoffice-row-status.is-confirmed {
    background: #dbeafe;
    color: #1e40af;
}

.backoffice-row-status.is-picked-up {
    background: #ccfbf1;
    color: #115e59;
}

.backoffice-row-status.is-canceled {
    background: #fee2e2;
    color: #991b1b;
}

.backoffice-actions {
    display: inline-flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.backoffice-actions button {
    min-height: 36px;
    padding: 0.25rem 0.55rem;
    border-radius: 0.5rem;
    font-size: 0.72rem;
}

.backoffice-actions .edit {
    background: #1f2937;
}

.backoffice-actions .pickup {
    background: #0f766e;
}

.backoffice-actions .cancel {
    background: #b91c1c;
}

.backoffice-actions button:disabled {
    background: #9ca3af;
    color: #374151;
    cursor: not-allowed;
}

.backoffice-note-chip {
    min-height: 28px;
    border: 1px solid #93c5fd;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 0.12rem 0.55rem;
    font-size: 0.74rem;
    font-weight: 800;
}

.backoffice-note-chip:hover {
    background: #dbeafe;
}

.manager-form {
    margin-top: 0.6rem;
}

.managers-list {
    margin-top: 0.8rem;
    display: grid;
    gap: 0.65rem;
}

.managers-empty {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.manager-item {
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    padding: 0.8rem;
    background: #fffcf6;
}

.manager-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
}

.manager-item-title {
    margin: 0;
    font-size: 0.95rem;
}

.manager-item-detail {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.manager-status {
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.manager-badges {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.manager-status.is-active {
    background: #dcfce7;
    color: #166534;
}

.manager-status.is-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.manager-status.is-super-admin {
    background: #dbeafe;
    color: #1e40af;
}

.manager-item-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.manager-toggle,
.manager-reset-password,
.manager-edit-profile {
    min-height: 36px;
    padding: 0.45rem 0.75rem;
    border-radius: 0.6rem;
    font-size: 0.82rem;
}

.manager-edit-profile {
    background: #0369a1;
}

.manager-edit-profile:hover {
    background: #075985;
}

.manager-toggle.on {
    background: #16a34a;
}

.manager-toggle.on:hover {
    background: #15803d;
}

.manager-toggle.off {
    background: #b91c1c;
}

.manager-toggle.off:hover {
    background: #991b1b;
}

.manager-reset-password {
    background: #1f2937;
}

.manager-reset-password:hover {
    background: #111827;
}

.order-item {
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    padding: 0.9rem;
    background: #fffcf6;
    display: grid;
    gap: 0.75rem;
}

.order-item.is-canceled {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.order-item.is-picked-up {
    background: #ecfeff;
    border-color: #99f6e4;
}

.order-code {
    display: inline-flex;
    align-items: center;
    width: 100%;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: -0.015em;
}

.order-paid-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    padding: 0.22rem 0.5rem;
}

.order-amount-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #f59e0b;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    padding: 0.24rem 0.58rem;
    white-space: nowrap;
}

.order-payment-note {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    color: #92400e;
    background: #fff7ed;
    border: 1px dashed #fdba74;
    border-radius: 0.55rem;
    padding: 0.35rem 0.5rem;
}

.order-buyer,
.order-details {
    margin: 0.2rem 0 0;
    color: var(--muted);
}

.order-sms-status {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    font-weight: 700;
}

.order-sms-status.pending {
    color: #9a3412;
}

.order-sms-status.sent {
    color: #065f46;
}

.order-sms-status.canceled {
    color: #7f1d1d;
}

.order-sms-status.picked-up {
    color: #0f766e;
}

.order-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.payment-btn {
    background: #2563eb;
}

.payment-btn:hover {
    background: #1d4ed8;
}

.payment-btn:disabled {
    background: #9ca3af;
    color: #374151;
    cursor: not-allowed;
}

.sms-link,
.whatsapp-link,
.pickup-whatsapp-link,
.confirmation-channel-dialog__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.sms-link.hidden,
.whatsapp-link.hidden,
.pickup-whatsapp-link.hidden,
.confirmation-channel-dialog__button.hidden {
    display: none;
}

.action-icon {
    font-size: 0.95em;
    line-height: 1;
}

.confirmation-channel-dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.confirmation-channel-dialog {
    border: none;
    border-radius: 1rem;
    padding: 0;
    width: min(92vw, 460px);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
}

.confirmation-channel-dialog__panel {
    padding: 1.1rem;
    background: #fff;
    border-radius: 1rem;
}

.confirmation-channel-dialog__eyebrow {
    margin: 0 0 0.3rem;
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.confirmation-channel-dialog__panel h2 {
    margin: 0;
    font-size: 1.2rem;
}

.confirmation-channel-dialog__description {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.confirmation-channel-dialog__amount {
    margin: 0.6rem 0 0;
    color: #92400e;
    font-size: 0.9rem;
    font-weight: 800;
}

.confirmation-channel-dialog__note-label {
    display: block;
    margin-top: 0.7rem;
    color: #6b7280;
    font-size: 0.78rem;
    font-weight: 800;
}

.confirmation-channel-dialog__note {
    width: 100%;
    margin-top: 0.35rem;
    border: 1px solid #d6d3d1;
    border-radius: 0.65rem;
    padding: 0.5rem 0.6rem;
    font: inherit;
    resize: vertical;
    min-height: 84px;
}

.confirmation-channel-dialog__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-top: 1rem;
}

.pickup-confirmation-dialog__actions {
    grid-template-columns: minmax(0, 1fr);
}

.confirmation-channel-dialog__actions.is-single-channel {
    grid-template-columns: minmax(0, 1fr);
}

.confirmation-channel-dialog__button,
.confirmation-channel-dialog__close {
    min-height: 36px;
    border-radius: 0.8rem;
    font-weight: 800;
}

.confirmation-channel-dialog__button--sms {
    background: #2563eb;
}

.confirmation-channel-dialog__button--sms:hover {
    background: #1d4ed8;
}

.confirmation-channel-dialog__button--whatsapp {
    background: #16a34a;
}

.confirmation-channel-dialog__button--whatsapp:hover {
    background: #15803d;
}

.confirmation-channel-dialog__button--pickup {
    background: #0f766e;
}

.confirmation-channel-dialog__button--pickup:hover {
    background: #0d9488;
}

.confirmation-channel-dialog__button--pickup-all {
    background: #16a34a;
}

.confirmation-channel-dialog__button--pickup-all:hover {
    background: #15803d;
}

.confirmation-channel-dialog__button--pending {
    background: #374151;
}

.confirmation-channel-dialog__button--pending:hover {
    background: #1f2937;
}

.confirmation-channel-dialog__close {
    width: 100%;
    margin-top: 0.65rem;
    background: #e5e7eb;
    color: #1f2937;
}

.pickup-confirmation-dialog__group {
    margin-top: 0.8rem;
    border: 1px solid #ccfbf1;
    border-radius: 0.8rem;
    background: #f0fdfa;
    padding: 0.7rem;
}

.pickup-confirmation-dialog__summary,
.pickup-confirmation-dialog__orders {
    margin: 0;
    color: #134e4a;
    font-size: 0.86rem;
}

.pickup-confirmation-dialog__summary {
    font-weight: 800;
}

.pickup-confirmation-dialog__orders {
    margin-top: 0.35rem;
    padding-left: 1.1rem;
    overflow-wrap: anywhere;
}

.pickup-confirmation-dialog__orders li + li {
    margin-top: 0.25rem;
}

.edit-btn {
    background: #1f2937;
}


.order-manager-meta {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}
.pickup-btn {
    background: #0f766e;
}

.pickup-btn:hover {
    background: #0d9488;
}

.pickup-btn:disabled {
    background: #9ca3af;
    color: #374151;
    cursor: not-allowed;
}

@media (min-width: 760px) {
    .layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .hero {
        grid-column: span 2;
    }

    .backoffice-summary {
        grid-template-columns: repeat(5, minmax(150px, 1fr));
    }
}

@media (min-width: 760px) {
    body:not(.ua-mobile-phone) #app-shell {
        grid-template-columns: minmax(340px,1fr) minmax(320px, 1fr);
        /* Show the managers pane on its own full-width row above the New/Orders
           row on wider (desktop) viewports so the top header covers all visible
           sections (Nuevo, Pedidos, Managers). When managers are not available
           the JS toggles `:not(.has-managers-section)` and the alternate
           template is used. */
        grid-template-areas:
            'nav nav'
            'hero hero'
            'managers managers'
            'new orders'
            'backoffice backoffice';
        align-items: start;
        justify-content: center;
    }

    /* When the New Order section is hidden (order_close_mode_enabled), allow
       the Orders section to span both grid columns so it fills the freed
       horizontal space on larger viewports. The JS toggles the
       `no-new-order` class on #app-shell when the mode is active. */
    body:not(.ua-mobile-phone) #app-shell.no-new-order {
        grid-template-areas:
            'nav nav'
            'hero hero'
            'orders orders'
            'backoffice backoffice';
    }

    body:not(.ua-mobile-phone) #app-shell:not(.has-managers-section) {
        grid-template-areas:
            'nav nav'
            'hero hero'
            'new orders'
            'backoffice backoffice';
    }

    body:not(.ua-mobile-phone) #app-shell > .app-top-nav {
        grid-area: nav;
    }

    body:not(.ua-mobile-phone) #app-shell > .hero {
        grid-area: hero;
    }

    body:not(.ua-mobile-phone) #new-order-section {
        grid-area: new;
        margin: 0;
        max-width: 100%;
        min-height: calc(100dvh - 11rem);
    }

    body:not(.ua-mobile-phone) #orders-section {
        grid-area: orders;
    }

    body:not(.ua-mobile-phone) #orders-section .orders-list {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        align-items: start;
    }

    body:not(.ua-mobile-phone) #managers-section {
        grid-area: managers;
    }

    body:not(.ua-mobile-phone) #backoffice-section {
        grid-area: backoffice;
    }
}

@media (min-width: 1180px) {
    body:not(.ua-mobile-phone) #app-shell {
        grid-template-columns: minmax(330px, 380px) minmax(520px, 1fr) minmax(280px, 360px);
        grid-template-areas:
            'nav nav nav'
            'hero hero hero'
            'new orders managers'
            'backoffice backoffice backoffice';
        justify-content: center;
    }

    body:not(.ua-mobile-phone) #app-shell:not(.has-managers-section) {
        grid-template-columns: minmax(330px, 380px) minmax(860px, 1fr);
        grid-template-areas:
            'nav nav'
            'hero hero'
            'new orders'
            'backoffice backoffice';
    }

    /* Large breakpoint: same behavior when New Order is hidden so Orders
       expand across the primary content columns. */
    body:not(.ua-mobile-phone) #app-shell.no-new-order {
        grid-template-areas:
            'nav nav nav'
            'hero hero hero'
            'orders orders orders'
            'backoffice backoffice backoffice';
    }

    body:not(.ua-mobile-phone) #orders-section {
        min-height: calc(100dvh - 11rem);
    }
}

/* -------------------------------------------------------------------------
   Desktop overrides for precise column fractions per product request:
   - When super-admin (has-managers-section): 1/4 new, 2/4 orders, 1/4 managers
   - If new-order is disabled (.no-new-order) keep managers at 1/4 and let
     orders span the left two columns (3/4)
   - When NOT super-admin (no managers): orders take 3/4 (new + orders)
   - When NOT super-admin and new-order disabled: orders take full width
   These rules are placed after the main 1180px block so they override earlier
   templates while keeping existing look/spacing intact.
   ------------------------------------------------------------------------- */
@media (min-width: 1180px) {
    /* Super-admin layout: three columns with 1 / 2 / 1 fractional split */
    body:not(.ua-mobile-phone) #app-shell.has-managers-section {
        grid-template-columns: 1fr 2fr 1fr;
        grid-template-areas:
            'nav nav nav'
            'hero hero hero'
            'new orders managers'
            'backoffice backoffice backoffice';
        justify-content: center;
    }

    /* When new-order is disabled but managers visible: orders span first two cols */
    body:not(.ua-mobile-phone) #app-shell.has-managers-section.no-new-order {
        grid-template-columns: 1fr 2fr 1fr;
        grid-template-areas:
            'nav nav nav'
            'hero hero hero'
            'orders orders managers'
            'backoffice backoffice backoffice';
    }

    /* Non-super-admin (managers absent): two-column layout with 1/4 - 3/4 split */
    body:not(.ua-mobile-phone) #app-shell:not(.has-managers-section) {
        grid-template-columns: 1fr 3fr;
        grid-template-areas:
            'nav nav'
            'hero hero'
            'new orders'
            'backoffice backoffice';
        justify-content: center;
    }

    /* Non-super-admin + new-order disabled: orders take full width */
    body:not(.ua-mobile-phone) #app-shell:not(.has-managers-section).no-new-order {
        grid-template-columns: 1fr;
        grid-template-areas:
            'nav'
            'hero'
            'orders'
            'backoffice';
    }

    /* Ensure orders min-height behaviour is preserved */
    body:not(.ua-mobile-phone) #orders-section {
        min-height: calc(100dvh - 11rem);
    }
}

body.ua-mobile-phone .layout {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

body.ua-mobile-phone #app-shell {
    --app-shell-gap: 0.75rem;
    min-height: calc(var(--app-vh, 1vh) * 100);
    gap: var(--app-shell-gap);
    --mobile-action-height: 36px;
    --mobile-action-padding-y: 0.34rem;
    --mobile-action-padding-x: 0.52rem;
    --mobile-action-font-size: 0.78rem;
}

body.ua-mobile-phone #app-shell .session-bar .ghost,
body.ua-mobile-phone #app-shell .session-actions-overflow-toggle,
body.ua-mobile-phone #app-shell .session-actions-overflow-item,
body.ua-mobile-phone #app-shell .actions button,
body.ua-mobile-phone #app-shell .payment-btn,
body.ua-mobile-phone #app-shell .pickup-btn,
body.ua-mobile-phone #app-shell .delete-btn,
body.ua-mobile-phone #app-shell .edit-btn,
body.ua-mobile-phone #app-shell .sms-link,
body.ua-mobile-phone #app-shell .whatsapp-link,
body.ua-mobile-phone #app-shell .pickup-whatsapp-link,
body.ua-mobile-phone #app-shell .buyer-orders-group-action,
body.ua-mobile-phone #app-shell .buyer-orders-group-toggle,
body.ua-mobile-phone #app-shell .email-orders-btn,
body.ua-mobile-phone #app-shell .orders-show-more-btn,
body.ua-mobile-phone #app-shell .place-orders-btn {
    min-height: var(--mobile-action-height);
    padding: var(--mobile-action-padding-y) var(--mobile-action-padding-x);
    font-size: var(--mobile-action-font-size);
}

body:not(.ua-mobile-phone) #app-shell {
    --desktop-action-height: 36px;
    --desktop-action-padding-y: 0.38rem;
    --desktop-action-padding-x: 0.58rem;
    --desktop-action-font-size: 0.8rem;
}

body:not(.ua-mobile-phone) #app-shell .session-bar .ghost,
body:not(.ua-mobile-phone) #app-shell .session-actions-overflow-toggle,
body:not(.ua-mobile-phone) #app-shell .session-actions-overflow-item,
body:not(.ua-mobile-phone) #app-shell .actions button,
body:not(.ua-mobile-phone) #app-shell .payment-btn,
body:not(.ua-mobile-phone) #app-shell .pickup-btn,
body:not(.ua-mobile-phone) #app-shell .delete-btn,
body:not(.ua-mobile-phone) #app-shell .edit-btn,
body:not(.ua-mobile-phone) #app-shell .sms-link,
body:not(.ua-mobile-phone) #app-shell .whatsapp-link,
body:not(.ua-mobile-phone) #app-shell .pickup-whatsapp-link,
body:not(.ua-mobile-phone) #app-shell .buyer-orders-group-action,
body:not(.ua-mobile-phone) #app-shell .buyer-orders-group-toggle,
body:not(.ua-mobile-phone) #app-shell .email-orders-btn,
body:not(.ua-mobile-phone) #app-shell .orders-show-more-btn,
body:not(.ua-mobile-phone) #app-shell .place-orders-btn,
body:not(.ua-mobile-phone) #app-shell .manager-toggle,
body:not(.ua-mobile-phone) #app-shell .manager-reset-password,
body:not(.ua-mobile-phone) #app-shell .manager-edit-profile {
    min-height: var(--desktop-action-height);
    padding: var(--desktop-action-padding-y) var(--desktop-action-padding-x);
    font-size: var(--desktop-action-font-size);
}

body.ua-mobile-phone #new-order-section {
    width: 100vw;
    max-width: 100vw;
    min-height: calc(var(--app-vh, 1vh) * 100);
    margin-inline: calc(50% - 50vw);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

body.ua-mobile-phone.is-landscape #new-order-section {
        padding: 0.55rem;
}

body.ua-mobile-phone.is-landscape #new-order-section #order-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(220px, 34vw);
        grid-template-areas:
            'left pending'
            'choices pending'
            'actions pending'
            'message pending';
    grid-template-rows: auto 1fr auto auto;
        gap: 0.4rem 0.55rem;
    align-content: stretch;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields {
        grid-area: left;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
        column-gap: 0.5rem;
        row-gap: 0.14rem;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields label {
        margin: 0;
        font-size: 0.78rem;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields input {
        min-height: 36px;
        padding: 0.3rem 0.5rem;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields label[for="buyer_name"] {
    grid-column: 1;
    grid-row: 1;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields #buyer_name {
    grid-column: 1;
    grid-row: 2;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields .buyer-name-search {
    grid-column: 1;
    grid-row: 2 / span 2;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields .buyer-name-search #buyer_name {
    grid-column: auto;
    grid-row: auto;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields .buyer-search-hint {
    margin-top: 0.18rem;
    line-height: 1.2;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields label[for="buyer_phone"] {
    grid-column: 2;
    grid-row: 1;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields #buyer_phone {
    grid-column: 2;
    grid-row: 2;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields label[for="manager_note"] {
    grid-column: 1 / span 2;
    grid-row: 4;
}

body.ua-mobile-phone.is-landscape #new-order-section .buyer-fields #manager_note {
    grid-column: 1 / span 2;
    grid-row: 5;
    min-height: 52px;
    padding: 0.38rem 0.5rem;
}

body.ua-mobile-phone.is-landscape #new-order-section .choice-groups {
        grid-area: choices;
}

body.ua-mobile-phone.is-landscape #new-order-section .actions {
        grid-area: actions;
}

body.ua-mobile-phone.is-landscape #new-order-section .message {
        grid-area: message;
        margin-top: 0.1rem;
}

body.ua-mobile-phone.is-landscape #new-order-section #pending-section:not(.hidden) {
        grid-area: pending;
        margin-top: 0;
        display: flex;
        flex-direction: column;
        align-content: stretch;
        align-self: stretch;
        min-height: 0;
        height: 100%;
        max-height: none;
}

body.ua-mobile-phone.is-landscape #new-order-section #pending-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

body.ua-mobile-phone.is-landscape #orders-section .orders-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

@media (max-width: 560px) {
    .session-bar {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .session-actions {
        justify-content: flex-start;
    }

    .session-actions-overflow {
        justify-self: end;
    }

    .hero-brand {
        align-items: flex-start;
    }

    .app-logo--hero {
        width: 62px;
        height: 62px;
    }

    .backoffice-controls {
        grid-template-columns: 1fr;
    }

    .backoffice-table .bo-sticky {
        position: static;
        min-width: auto;
    }
}

@media (max-width: 760px) {
    .layout {
        width: 100%;
        max-width: 100%;
        padding: 0;
        gap: 0.75rem;
    }

    #new-order-section {
        width: 100vw;
        max-width: 100vw;
        min-height: 100dvh;
        margin-inline: calc(50% - 50vw);
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        padding: 0.85rem;
        display: flex;
        flex-direction: column;
        --new-order-control-height: clamp(38px, 5.8dvh, 44px);
        --new-order-button-height: 36px;
        --new-order-gap: clamp(0.3rem, 1.8dvh, 0.6rem);
        --new-order-font-size: clamp(0.78rem, 2.7vw, 0.92rem);
    }

    #new-order-section #order-form {
        flex: 1;
        display: grid;
        align-content: start;
        gap: var(--new-order-gap);
        min-height: 0;
    }

    .buyer-orders-group-header {
        padding-right: 0.15rem;
    }

    .buyer-orders-group-amount--top-right {
        position: static;
        margin-left: auto;
    }

    #new-order-section {
        padding: 0.85rem;
    }

    #new-order-section h2 {
        margin: 0 0 0.55rem;
        font-size: 1.15rem;
    }

    #new-order-section label,
    #new-order-section .choice-feedback,
    #new-order-section .choice-hint,
    #new-order-section .pending-item-label,
    #new-order-section .pending-title,
    #new-order-section .message {
        font-size: var(--new-order-font-size);
    }

    #new-order-section label {
        margin: 0.3rem 0 0.14rem;
        line-height: 1.2;
    }

    #new-order-section input {
        min-height: var(--new-order-control-height);
        padding: clamp(0.3rem, 1.35dvh, 0.52rem) clamp(0.46rem, 2.2vw, 0.72rem);
    }

    #new-order-section .choice-groups {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: clamp(0.42rem, 2vw, 0.7rem);
    }

    #new-order-section .choice-group-block {
        margin-top: 0;
        padding: clamp(0.42rem, 1.5dvh, 0.7rem);
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #new-order-section .choice-grid {
        margin-top: 0.28rem;
        grid-template-columns: 1fr;
        gap: clamp(0.24rem, 0.9dvh, 0.42rem);
    }

    #new-order-section .choice-button {
        min-height: 44px;
        padding: 0.36rem 0.36rem;
        font-size: clamp(0.76rem, 2.6vw, 0.9rem);
    }

    #new-order-section .actions {
        margin-top: clamp(0.2rem, 1.1dvh, 0.5rem);
        gap: clamp(0.3rem, 1.5vw, 0.55rem);
    }

    #new-order-section .actions button {
        min-height: var(--new-order-button-height);
        padding: 0.45rem 0.55rem;
        flex: 1 1 0;
    }

    #new-order-section .pending-section {
        margin-top: clamp(0.15rem, 1dvh, 0.45rem);
        padding: clamp(0.42rem, 1.4dvh, 0.75rem);
    }

    #new-order-section .pending-list {
        max-height: clamp(88px, 20dvh, 220px);
        overflow-y: auto;
    }

    #new-order-section.new-order-has-pending {
        --new-order-control-height: clamp(36px, 5.2dvh, 40px);
        --new-order-button-height: 36px;
        --new-order-gap: clamp(0.24rem, 1.3dvh, 0.45rem);
        --new-order-font-size: clamp(0.74rem, 2.4vw, 0.86rem);
    }

    #new-order-section.new-order-has-pending .pending-list {
        max-height: clamp(104px, 23dvh, 245px);
    }

}

@media (max-width: 600px) and (max-height: 940px) {
    #new-order-section {
        padding: 0.68rem;
    }

    #new-order-section h2 {
        margin: 0 0 0.45rem;
        font-size: 1.08rem;
    }

    #new-order-section label {
        margin: 0.32rem 0 0.14rem;
        font-size: 0.81rem;
    }

    #new-order-section input {
        min-height: 38px;
        padding: 0.38rem 0.56rem;
        border-radius: 0.62rem;
    }

    #new-order-section .choice-group-block {
        margin-top: 0.42rem;
        padding: 0.44rem;
        border-radius: 0.72rem;
    }

    #new-order-section .choice-groups {
        gap: 0.35rem;
    }

    #new-order-section .choice-feedback {
        font-size: 0.73rem;
    }

    #new-order-section .choice-hint {
        display: none;
    }

    #new-order-section .choice-grid {
        margin-top: 0.3rem;
        grid-template-columns: 1fr;
        gap: 0.28rem;
    }

    #new-order-section .choice-button {
        min-height: 44px;
        padding: 0.36rem 0.3rem;
        font-size: 0.8rem;
    }

    #new-order-section .actions {
        margin-top: 0.5rem;
        gap: 0.32rem;
    }

    #new-order-section .actions button {
        min-height: 36px;
        padding: 0.34rem 0.52rem;
        font-size: 0.82rem;
    }

    #new-order-section .message {
        margin-top: 0.36rem;
        min-height: 0.85rem;
        font-size: 0.76rem;
    }
}

@media (max-width: 600px) and (max-height: 860px) {
    .app-top-nav {
        gap: 0.35rem;
        padding: 0.35rem 0.4rem;
    }

    .app-top-nav__links a,
    .app-top-nav__action {
        font-size: 0.74rem;
        padding: 0.2rem 0.48rem;
    }

    .app-top-nav__action--icon {
        width: 34px;
        min-width: 34px;
        padding: 0;
    }
}

@media (max-width: 600px) and (min-height: 861px) {
    .app-top-nav {
        display: grid;
    }
}

@media (max-width: 430px) and (max-height: 852px) {
    #new-order-section {
        padding: 0.58rem;
    }

    #new-order-section input {
        min-height: 36px;
        padding: 0.32rem 0.5rem;
    }

    #new-order-section .choice-group-block {
        margin-top: 0.36rem;
        padding: 0.38rem;
    }

    #new-order-section .choice-groups {
        gap: 0.28rem;
    }

    #new-order-section .choice-button {
        min-height: 44px;
        padding: 0.3rem 0.24rem;
        font-size: 0.76rem;
    }

    #new-order-section .actions button {
        min-height: 36px;
        padding: 0.32rem 0.48rem;
        font-size: 0.8rem;
    }
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#new-order-section.order-closed {
    /* When order-close mode is active, hide the New Order section
       entirely across all UA modes. This replaces the older 'grayed'
       appearance and ensures the section does not take layout space. */
    display: none !important;
    pointer-events: none !important;
}

/* Ensure on mobile UA the new-order section is fully hidden when order-close
   mode is enabled. Some UA-specific flows may remove the `hidden` class; this
   rule is defensive and uses !important to avoid visual 'grayed' remnants. */
body.ua-mobile-phone #new-order-section.order-closed,
body.ua-mobile-phone #app-shell.no-new-order #new-order-section {
    display: none !important;
    opacity: 1 !important; /* reset opacity so display:none is the authoritative hiding rule */
    pointer-events: none !important;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
