/* =============================================================================
   El Boutique — shared stylesheet
   One source for tokens, layout primitives and components. Storefronts override
   only the --primary / --font tokens, which are injected per store.
   ========================================================================== */

:root {
    --primary: #ff4d00;
    --primary-dark: #d94100;
    --primary-soft: rgba(255, 77, 0, 0.08);
    --secondary: #111318;

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;

    --text: #14181f;
    --text-muted: #6b7480;
    --border: #e3e7ec;

    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info: #2563eb;
    --info-bg: #dbeafe;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 22px;
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.04);
    --shadow: 0 4px 18px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 12px 34px rgba(16, 24, 40, 0.10);

    --font: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-ui: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;

    --nav-height: 64px;
    --bottom-nav-height: 66px;
}

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Nothing may push the page sideways. `clip` rather than `hidden` because
   `hidden` turns the element into a scroll container, which silently kills
   `position: sticky` on the storefront header. */
html, body { overflow-x: clip; max-width: 100%; }

@supports not (overflow: clip) {
    html, body { overflow-x: hidden; }
}

img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
    position: absolute; top: -100px; right: 1rem; z-index: 5000;
    background: var(--primary); color: #fff; padding: .8rem 1.4rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.skip-link:focus { top: 0; }

/* --- Typography ---------------------------------------------------------- */
h1, h2, h3, h4 { line-height: 1.3; font-weight: 800; text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
h3 { font-size: 1.1rem; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: .85rem; }
.text-price { color: var(--primary); font-weight: 900; }
.nums { font-variant-numeric: tabular-nums; }

/* --- Layout -------------------------------------------------------------- */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 1.25rem; }
.container-narrow { max-width: 720px; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
.section { padding-block: 2rem; }

/* --- Buttons ------------------------------------------------------------- */
.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-add {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .7rem 1.35rem; border: 1px solid transparent; border-radius: var(--radius-sm);
    font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    text-align: center; white-space: nowrap;
}
.btn-primary, .btn-add { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-add:hover { background: var(--primary-dark); box-shadow: 0 6px 16px rgba(255,77,0,.25); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-sm { padding: .4rem .8rem; font-size: .82rem; }
.btn-lg { padding: .95rem 2rem; font-size: 1.05rem; }
.btn:disabled, .btn-primary:disabled, [aria-disabled="true"] {
    opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important;
}
.btn-icon {
    width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-icon:hover { background: var(--border); }
.btn-icon.danger { color: var(--danger); }

/* --- Forms --------------------------------------------------------------- */
.form-group { margin-bottom: 1.15rem; }
.form-group > label, .form-label {
    display: block; margin-bottom: .45rem; font-weight: 700; font-size: .9rem;
}
.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: .35rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"],
input[type="email"], input[type="date"], input[type="datetime-local"], input[type="search"],
input[type="url"], select, textarea {
    width: 100%; padding: .75rem .9rem; font: inherit; font-size: .95rem;
    color: var(--text); background: var(--surface);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
input[aria-invalid="true"], .has-error input, .has-error select { border-color: var(--danger); }
textarea { resize: vertical; min-height: 90px; }
input[type="file"] {
    width: 100%; padding: .8rem; background: var(--surface-2);
    border: 1.5px dashed var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
input[type="color"] { width: 72px; height: 44px; padding: 3px; border-radius: var(--radius-sm); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
legend { padding-inline: .5rem; font-weight: 800; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 54px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer; background: #cbd2da;
    border-radius: 30px; transition: .25s;
}
.switch .slider::before {
    content: ""; position: absolute; width: 22px; height: 22px; left: 4px; bottom: 4px;
    background: #fff; border-radius: 50%; transition: .25s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(24px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--primary-soft); }

/* --- Cards / surfaces ----------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.5rem;
}
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 1rem; }

/* --- Alerts --------------------------------------------------------------- */
.alert {
    display: flex; align-items: flex-start; gap: .65rem;
    padding: .9rem 1.1rem; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .92rem; margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert i { margin-top: .2rem; flex: none; }
.alert-success { background: var(--success-bg); color: #14532d; border-color: #bbf7d0; }
.alert-error   { background: var(--danger-bg);  color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--warning-bg); color: #78350f; border-color: #fde68a; }
.alert-info    { background: var(--info-bg);    color: #1e3a8a; border-color: #bfdbfe; }

/* --- Badges --------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .7rem; border-radius: 999px;
    font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #15803d; }
.badge-danger  { background: var(--danger-bg);  color: #b91c1c; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-info    { background: var(--info-bg);    color: #1d4ed8; }
.badge-muted   { background: var(--surface-2);  color: var(--text-muted); }

.status-pending    { background: #fff3e0; color: #c2620a; }
.status-processing { background: #e3f2fd; color: #1565c0; }
.status-shipped    { background: #ede7f6; color: #6a1b9a; }
.status-delivered  { background: #e8f5e9; color: #2e7d32; }
.status-cancelled  { background: #ffebee; color: #c62828; }
.status-returned   { background: #eceff1; color: #455a64; }

/* --- Tables --------------------------------------------------------------- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.data-table th {
    text-align: start; padding: .9rem 1rem; font-size: .82rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: .9rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .cell-empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); flex: none; }

/* --- Modal ---------------------------------------------------------------- */
.modal {
    display: none; position: fixed; inset: 0; z-index: 2000;
    background: rgba(10, 14, 20, .6); backdrop-filter: blur(4px);
    overflow-y: auto; padding: 1.25rem;
}
.modal[open], .modal.is-open { display: block; }
.modal-content {
    background: var(--surface); width: 100%; max-width: 680px; margin: 3rem auto;
    padding: 1.75rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    animation: modal-in .22s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-footer { display: flex; gap: .75rem; margin-top: 1.75rem; flex-wrap: wrap; }
.modal-footer .btn-primary, .modal-footer .btn-secondary { flex: 1; min-width: 140px; }

/* --- Pagination ----------------------------------------------------------- */
.pagination { display: flex; gap: .35rem; justify-content: center; margin: 2rem 0; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 40px; padding: .5rem .75rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    font-weight: 700; font-size: .9rem; text-align: center;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* --- Empty states --------------------------------------------------------- */
.empty-state { text-align: center; padding: 4rem 1.5rem; }
.empty-state i { font-size: 3.4rem; color: #c6ccd4; margin-bottom: 1.25rem; display: block; }
.empty-state h3 { margin-bottom: .5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* --- Error page ----------------------------------------------------------- */
.error-page { display: grid; place-items: center; min-height: 100vh; padding: 2rem; }
.error-box { text-align: center; max-width: 480px; }
.error-code { font-size: 5rem; font-weight: 900; color: var(--primary); line-height: 1; }
.error-box h1 { margin: .5rem 0 1rem; }
.error-box p { color: var(--text-muted); margin-bottom: 2rem; }

/* --- Language switcher ---------------------------------------------------- */
.lang-switcher { display: inline-flex; gap: .2rem; background: var(--surface-2); padding: .25rem; border-radius: 999px; }
.lang-switcher a {
    padding: .3rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 700;
    color: var(--text-muted);
}
.lang-switcher a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* =============================================================================
   Storefront
   ========================================================================== */
.store-body { padding-bottom: calc(var(--bottom-nav-height) + 1rem); }

.store-header {
    position: sticky; top: 0; z-index: 100; background: var(--surface);
    padding: .75rem 1rem; display: flex; align-items: center; gap: .85rem;
    box-shadow: var(--shadow-sm);
}
.store-header .store-logo { height: 40px; width: 40px; border-radius: 10px; object-fit: cover; flex: none; }
.store-header h1, .store-header h2 { font-size: 1.05rem; font-weight: 800; }

.search-bar { flex: 1; min-width: 0; }
.search-bar form { display: flex; align-items: center; gap: .5rem; background: var(--surface-2); border-radius: 999px; padding: .45rem .9rem; }
.search-bar input { border: none; background: transparent; padding: 0; font-size: .9rem; box-shadow: none !important; }
.search-bar button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0; }

.cart-link { position: relative; color: var(--text); font-size: 1.25rem; padding: .25rem; }
.cart-count {
    position: absolute; top: -4px; inset-inline-end: -6px; min-width: 18px; height: 18px;
    padding: 0 4px; background: var(--primary); color: #fff; border-radius: 999px;
    font-size: .65rem; font-weight: 800; display: grid; place-items: center;
}
.cart-count[hidden] { display: none; }

.hscroll { display: flex; gap: .75rem; overflow-x: auto; padding: 1rem; scrollbar-width: none; scroll-snap-type: x mandatory; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: none; }

.cat-chip { text-align: center; width: 78px; }
.cat-chip .cat-icon {
    width: 56px; height: 56px; margin: 0 auto .4rem; background: var(--surface);
    border-radius: 50%; display: grid; place-items: center;
    color: var(--primary); font-size: 1.35rem; box-shadow: var(--shadow-sm);
    transition: transform .15s ease;
}
.cat-chip:hover .cat-icon { transform: translateY(-3px); }
.cat-chip span { font-size: .74rem; font-weight: 700; display: block; line-height: 1.3; }

.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; padding: .75rem; }
@media (min-width: 700px)  { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; position: relative; display: flex; flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.product-card .product-img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.product-card .product-info { padding: .7rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.product-title {
    font-size: .88rem; font-weight: 600; line-height: 1.35; height: 2.4em;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.product-price { color: var(--primary); font-weight: 900; font-size: 1.05rem; margin-top: auto; }
.product-price .currency { font-size: .72rem; font-weight: 700; }
.old-price { text-decoration: line-through; color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.discount-tag {
    position: absolute; top: .6rem; inset-inline-end: .6rem; z-index: 3;
    background: var(--primary); color: #fff; padding: .15rem .5rem;
    border-radius: 6px; font-size: .72rem; font-weight: 800;
}
.stock-tag {
    position: absolute; top: .6rem; inset-inline-start: .6rem; z-index: 3;
    background: rgba(17,19,24,.82); color: #fff; padding: .15rem .5rem;
    border-radius: 6px; font-size: .7rem; font-weight: 700;
}
.rating-line { font-size: .75rem; color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }
.rating-line .fa-star { color: #f59e0b; }

.bottom-nav {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 1000; height: var(--bottom-nav-height);
    background: var(--surface); border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-item {
    flex: 1; text-align: center; font-size: .68rem; font-weight: 700; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .35rem 0;
    position: relative;
}
.bottom-nav .nav-item i { font-size: 1.15rem; }
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-badge {
    position: absolute; top: .1rem; inset-inline-end: 22%; min-width: 16px; height: 16px;
    background: var(--primary); color: #fff; border-radius: 999px; font-size: .6rem;
    display: grid; place-items: center; padding: 0 3px;
}

.sticky-footer {
    position: fixed; bottom: var(--bottom-nav-height); inset-inline: 0; z-index: 1000;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: .75rem 1rem;
    display: flex; align-items: center; gap: .85rem;
}

.qty-selector { display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.qty-selector button {
    width: 40px; height: 44px; border: none; background: var(--surface);
    font-size: 1.1rem; font-weight: 700; cursor: pointer; color: var(--text);
}
.qty-selector button:hover:not(:disabled) { background: var(--surface-2); }
.qty-selector button:disabled { opacity: .4; cursor: not-allowed; }
.qty-selector input {
    width: 46px; text-align: center; border: none; background: transparent;
    font-weight: 700; padding: 0; box-shadow: none !important;
}

.variant-group { margin-bottom: 1.1rem; }
.variant-title { font-size: .9rem; font-weight: 700; display: block; margin-bottom: .5rem; }
.variant-options { display: flex; gap: .5rem; flex-wrap: wrap; }
.variant-pill {
    background: var(--surface); border: 1.5px solid var(--border); padding: .45rem 1rem;
    border-radius: var(--radius-sm); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; gap: .4rem; transition: .15s;
}
.variant-pill:hover { border-color: var(--primary); }
.variant-pill.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.variant-pill:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.variant-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }

.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-header {
    width: 100%; display: flex; justify-content: space-between; align-items: center;
    padding: 1.1rem 0; background: none; border: none; font: inherit;
    font-size: 1rem; font-weight: 700; cursor: pointer; text-align: start; color: var(--text);
}
.accordion-content { padding-bottom: 1.1rem; color: #4b5563; font-size: .92rem; line-height: 1.7; }
.accordion-item:not([open]) .accordion-content { display: none; }

.cart-item {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem; display: flex; gap: .9rem; align-items: flex-start;
}
.cart-item img { width: 78px; height: 78px; border-radius: var(--radius-sm); object-fit: cover; flex: none; }
.cart-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .4rem; }

.summary-line { display: flex; justify-content: space-between; font-size: .92rem; padding: .35rem 0; }
.summary-line.total { font-size: 1.1rem; font-weight: 900; border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .75rem; }

.checkout-bar {
    position: fixed; bottom: calc(var(--bottom-nav-height) + .75rem); inset-inline: 5%; z-index: 1000;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .85rem 1.25rem; display: flex; justify-content: space-between; align-items: center;
    box-shadow: var(--shadow-lg); gap: 1rem;
}

.wallet-box {
    background: var(--warning-bg); border: 2px dashed var(--primary);
    padding: 1.25rem; border-radius: var(--radius); text-align: center; margin: 1.25rem 0;
}
.wallet-number { font-size: 1.8rem; font-weight: 900; color: var(--primary); display: block; margin: .35rem 0; letter-spacing: .05em; }

/* Prize wheel */
.wheel-modal { position: fixed; inset: 0; z-index: 2000; background: rgba(8,10,14,.88); display: none; place-items: center; padding: 1.25rem; }
.wheel-modal.is-open { display: grid; }
.wheel-stage { text-align: center; color: #fff; max-width: 400px; width: 100%; }
.wheel-wrap { position: relative; width: min(300px, 78vw); margin: 1.5rem auto; }
.wheel-wrap canvas { width: 100%; height: auto; border-radius: 50%; box-shadow: 0 0 0 8px rgba(255,255,255,.1); }
.wheel-pointer {
    position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
    width: 0; height: 0; border-inline: 14px solid transparent; border-top: 26px solid var(--primary);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); z-index: 2;
}
.gamify-btn {
    position: fixed; inset-inline-end: 1rem; bottom: calc(var(--bottom-nav-height) + 1rem); z-index: 900;
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--primary); color: #fff; font-size: 1.4rem;
    display: grid; place-items: center; box-shadow: 0 8px 22px rgba(255,77,0,.4);
}

/* Reviews */
.star-input { display: inline-flex; flex-direction: row-reverse; gap: .35rem; }
.star-input input { position: absolute; opacity: 0; width: 0; }
.star-input label { font-size: 1.7rem; color: #d7dce2; cursor: pointer; transition: color .12s; }
.star-input label:hover, .star-input label:hover ~ label, .star-input input:checked ~ label { color: #f59e0b; }
.star-input input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }
.review { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.review:last-child { border-bottom: none; }

/* =============================================================================
   Dashboards (merchant + admin)
   ========================================================================== */
.panel-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 268px; flex: none; position: fixed; top: 0; bottom: 0; z-index: 1000;
    background: var(--surface); border-inline-end: 1px solid var(--border);
    padding: 1.5rem 1rem; overflow-y: auto;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}
[dir="rtl"] .sidebar { right: 0; border-inline-end: none; border-inline-start: 1px solid var(--border); }
[dir="ltr"] .sidebar { left: 0; }

.sidebar .brand {
    display: flex; align-items: center; gap: .65rem; font-size: 1.1rem; font-weight: 900;
    color: var(--primary); margin-bottom: 1.75rem; padding: 0 .5rem;
}
.sidebar .brand small { display: block; font-size: .72rem; font-weight: 600; color: var(--text-muted); }
.nav-menu { list-style: none; display: flex; flex-direction: column; gap: .15rem; }
.nav-menu a {
    display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem;
    border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem; color: var(--text);
    transition: background .15s, color .15s;
}
.nav-menu a i { width: 20px; text-align: center; color: var(--text-muted); }
.nav-menu a:hover { background: var(--surface-2); }
.nav-menu a.active { background: var(--primary-soft); color: var(--primary); }
.nav-menu a.active i { color: var(--primary); }
.nav-menu .nav-section {
    font-size: .7rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: .08em; padding: 1.1rem .9rem .35rem;
}
.nav-menu .count-pill {
    margin-inline-start: auto; background: var(--danger); color: #fff;
    border-radius: 999px; font-size: .68rem; font-weight: 800; padding: .05rem .45rem;
}

.panel-main { flex: 1; min-width: 0; padding: 1.75rem 2rem 4rem; }
[dir="rtl"] .panel-main { margin-right: 268px; }
[dir="ltr"] .panel-main { margin-left: 268px; }

.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap;
}
.panel-header h1 { font-size: 1.4rem; }

.menu-toggle {
    display: none; width: 42px; height: 42px; border: 1px solid var(--border);
    background: var(--surface); border-radius: var(--radius-sm); font-size: 1.15rem;
    cursor: pointer; color: var(--text);
}
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 999; background: rgba(10,14,20,.5); backdrop-filter: blur(3px); }
.sidebar-overlay.is-open { display: block; }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(105%); box-shadow: var(--shadow-lg); }
    [dir="ltr"] .sidebar { transform: translateX(-105%); }
    .sidebar.is-open { transform: translateX(0); }
    .panel-main { margin: 0 !important; padding: 1.25rem 1rem 4rem; }
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; box-shadow: var(--shadow-sm);
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
}
.stat-card h3 { font-size: .8rem; font-weight: 700; color: var(--text-muted); margin-bottom: .35rem; }
.stat-card .value { font-size: 1.55rem; font-weight: 900; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .trend { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.stat-icon {
    width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary); font-size: 1.15rem;
}
.stat-card.good .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.warn .stat-icon { background: var(--warning-bg); color: var(--warning); }

.panel-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 1.5rem; margin-bottom: 1.5rem;
}
.panel-card > h2 { font-size: 1.1rem; margin-bottom: 1.15rem; }

.filter-bar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }
.filter-bar .form-group { margin: 0; flex: 1 1 180px; }

.timeline { list-style: none; border-inline-start: 2px solid var(--border); padding-inline-start: 1.25rem; }
.timeline li { position: relative; padding-bottom: 1.15rem; }
.timeline li::before {
    content: ""; position: absolute; inset-inline-start: -1.6rem; top: .45rem;
    width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface);
}
.timeline .when { font-size: .76rem; color: var(--text-muted); }

.sparkbar { display: flex; align-items: flex-end; gap: 3px; height: 56px; }
.sparkbar span { flex: 1; background: var(--primary-soft); border-radius: 3px 3px 0 0; min-height: 2px; }
.sparkbar span.peak { background: var(--primary); }

/* =============================================================================
   Public marketing pages
   ========================================================================== */
.public-body { padding-top: var(--nav-height); }

.public-nav {
    position: fixed; top: 0; inset-inline: 0; z-index: 1000; height: var(--nav-height);
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border); display: flex; align-items: center;
}
.public-nav .brand-link img { border-radius: 10px; }
.public-links { display: flex; align-items: center; gap: 1.25rem; }
.public-links a { font-weight: 700; font-size: .92rem; color: var(--text-muted); }
.public-links a:hover, .public-links a.active { color: var(--primary); }
.public-links a.btn-primary { color: #fff; }

@media (max-width: 900px) {
    .public-nav .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }

    /* `backdrop-filter` establishes a containing block for fixed-position
       descendants, which would anchor the drawer inside this 64px-tall bar
       instead of the viewport — collapsing it to a stub under the header. The
       drawer lives inside the nav, so the effect has to go at mobile widths;
       an opaque background replaces it. */
    .public-nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }

    /* The drawer opens from the same edge the toggle sits on — the inline-end,
       which is the left in RTL and the right in LTR. `inset-inline-end` handles
       the anchor, but `translateX` is a physical axis and is NOT mirrored by
       `dir`, so the off-screen offset has to be signed per direction. Getting
       this wrong slides the panel into the page instead of out of it. */
    .public-links {
        position: fixed; top: var(--nav-height); bottom: 0; inset-inline-end: 0; z-index: 999;
        width: min(300px, 84vw);
        background: var(--surface); border-inline-start: 1px solid var(--border);
        flex-direction: column; align-items: stretch; justify-content: flex-start;
        gap: .35rem; padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
        overflow-y: auto; overscroll-behavior: contain;
        box-shadow: var(--shadow-lg);
        transition: transform .3s cubic-bezier(.16, 1, .3, 1);
    }
    [dir="rtl"] .public-links { transform: translateX(-110%); }   /* inline-end = left  */
    [dir="ltr"] .public-links { transform: translateX(110%); }    /* inline-end = right */
    .public-links.is-open     { transform: translateX(0); }

    /* Children stretch to the panel, so nothing spills past its edge. */
    .public-links a {
        padding: .75rem .9rem; border-radius: var(--radius-sm);
        text-align: start; white-space: normal;
    }
    .public-links a:hover { background: var(--surface-2); }
    .public-links a.btn-primary,
    .public-links a.btn-sm { width: 100%; justify-content: center; margin-top: .5rem; }
    .public-links .lang-switcher {
        display: flex; width: 100%; margin-top: .75rem;
        justify-content: stretch; flex-wrap: wrap; gap: .25rem;
    }
    .public-links .lang-switcher a { flex: 1 1 auto; text-align: center; padding: .45rem .5rem; }
}

.hero {
    display: grid; gap: 3rem; align-items: center; padding: 4rem 0 5rem;
    grid-template-columns: 1fr;
}
@media (min-width: 900px) { .hero { grid-template-columns: 1.05fr .95fr; } }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.2rem); font-weight: 900; line-height: 1.15; margin-bottom: 1.25rem; }
.hero h1 span { color: var(--primary); }
.hero p.lede { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 2rem; max-width: 52ch; }
.hero-actions { display: flex; gap: .85rem; flex-wrap: wrap; }
.hero-figure { position: relative; }
.hero-figure img { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 8px solid var(--surface); }

.section-head { text-align: center; max-width: 620px; margin: 0 auto 2.5rem; }
.section-tag {
    display: inline-block; color: var(--primary); font-weight: 800; font-size: .78rem;
    letter-spacing: .12em; text-transform: uppercase; margin-bottom: .75rem;
}

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.feature-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 2rem 1.65rem; transition: transform .2s ease, border-color .2s ease;
}
.feature-card:hover { transform: translateY(-5px); border-color: var(--primary); }
.feature-card i { font-size: 1.9rem; color: var(--primary); margin-bottom: 1rem; display: block; }
.feature-card h3 { margin-bottom: .5rem; }
.feature-card p { color: var(--text-muted); font-size: .93rem; }

.store-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 2rem 1.5rem; text-align: center; display: flex; flex-direction: column;
    align-items: center; gap: .55rem; transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.store-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--primary); }
.store-card .avatar {
    width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--surface); box-shadow: var(--shadow); margin-bottom: .75rem;
}
.store-card .btn-primary { margin-top: auto; width: 100%; }

.public-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 3rem 0 1.5rem; margin-top: 4rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2rem; }
.footer-grid h4 { font-size: .95rem; margin-bottom: .75rem; }
.footer-grid a { display: block; color: var(--text-muted); font-size: .9rem; padding: .2rem 0; }
.footer-grid a:hover { color: var(--primary); }
.footer-base { border-top: 1px solid var(--border); margin-top: 2rem; padding-top: 1.5rem; text-align: center; }

/* =============================================================================
   Mobile refinements
   Everything below assumes a phone in either direction. `translateX` and
   `float` are physical axes and are never mirrored by `dir`, so anything using
   them is declared per-direction; everything else uses logical properties.
   ========================================================================== */

@media (max-width: 900px) {
    /* --- Public navigation ------------------------------------------------- */
    .public-nav { padding-inline: 0; }
    .public-nav .container { gap: .75rem; }
    .public-nav .brand-link img { height: 38px; width: 38px; }

    /* The toggle must sit at the inline-end, next to the edge its drawer opens
       from, in both directions. */
    .public-nav .container.row-between { justify-content: space-between; }
    .public-nav .menu-toggle { order: 3; margin-inline-start: auto; }
    .public-nav .brand-link { order: 1; }
    .public-links { order: 2; }

    /* --- Hero --------------------------------------------------------------- */
    .hero { padding: 2.5rem 0 3rem; gap: 2rem; text-align: center; }
    .hero h1 { font-size: clamp(1.75rem, 7.5vw, 2.4rem); }
    .hero p.lede { font-size: 1rem; margin-inline: auto; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .hero-actions .btn-primary,
    .hero-actions .btn-secondary { width: 100%; }
    .hero .row { justify-content: center; gap: 1.5rem !important; }
    .hero-figure img { border-width: 5px; }

    /* --- Sections ----------------------------------------------------------- */
    .section { padding-block: 1.5rem; }
    .section-head { margin-bottom: 1.5rem; }
    .feature-card { padding: 1.5rem 1.25rem; }
    .footer-grid { gap: 1.5rem; text-align: start; }
}

@media (max-width: 600px) {
    :root { --nav-height: 58px; }

    .container { padding-inline: 1rem; }

    /* --- Forms and filters --------------------------------------------------- */
    /* Filter rows become a single column; a half-width date field on a 320px
       screen is unusable. */
    .filter-bar { flex-direction: column; align-items: stretch; gap: .75rem; }
    .filter-bar .form-group { flex: 1 1 auto; width: 100%; }
    .filter-bar button { width: 100%; }
    .form-grid { grid-template-columns: 1fr; gap: .85rem; }

    /* --- Panels -------------------------------------------------------------- */
    .panel-header { gap: .75rem; }
    .panel-header h1 { font-size: 1.15rem; }
    .panel-header .row:last-child { width: 100%; }
    .panel-header .row:last-child > * { flex: 1 1 auto; justify-content: center; }
    .panel-card { padding: 1.1rem; border-radius: var(--radius-sm); }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
    .stat-card { padding: .9rem; flex-direction: column; gap: .5rem; }
    .stat-card .stat-icon { width: 34px; height: 34px; font-size: .95rem; }
    .stat-card .value { font-size: 1.2rem; }

    /* --- Tables --------------------------------------------------------------- */
    /* The horizontal scroller is the intended behaviour; make it discoverable
       and keep it inside its card rather than widening the page. */
    .table-responsive {
        margin-inline: -1.1rem; padding-inline: 1.1rem;
        scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
    }
    .data-table th, .data-table td { padding: .7rem .6rem; }

    /* --- Modals --------------------------------------------------------------- */
    .modal { padding: 0; }
    .modal-content {
        margin: 0; min-height: 100%; max-width: none;
        border-radius: 0; padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
    }
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer > * { width: 100%; min-width: 0; }

    /* --- Storefront ----------------------------------------------------------- */
    .store-header { padding: .6rem .75rem; gap: .6rem; }
    .store-header h1, .store-header h2 { font-size: .98rem; }
    .product-grid { gap: .6rem; padding: .6rem; }

    /* Sticky bars must clear the home indicator and never overflow. */
    .sticky-footer { flex-wrap: nowrap; gap: .6rem; padding-inline: .75rem; }
    .sticky-footer .btn-add-cart, .sticky-footer .btn-primary { min-width: 0; }
    .qty-selector button { width: 36px; }
    .qty-selector input { width: 36px; }

    .checkout-bar { inset-inline: .75rem; padding: .7rem .9rem; gap: .6rem; }
    .checkout-bar .btn-primary { padding-inline: 1.1rem; }

    .cart-item { padding: .75rem; gap: .7rem; }
    .cart-item img { width: 64px; height: 64px; }

    /* --- Loyalty --------------------------------------------------------------- */
    .wheel-wrap { width: min(280px, 72vw); }
    .gamify-btn { width: 50px; height: 50px; font-size: 1.2rem; }

    /* --- Auth cards ------------------------------------------------------------ */
    .auth-card { padding: 1.75rem 1.25rem !important; }

    /* --- Pagination ------------------------------------------------------------ */
    .pagination a, .pagination span { min-width: 36px; padding: .45rem .55rem; font-size: .85rem; }
}

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .hero h1 { font-size: 1.6rem; }
}

/* Landscape phones: a full-height drawer would be taller than the viewport. */
@media (max-width: 900px) and (max-height: 460px) {
    .public-links, .sidebar { padding-block: .75rem; }
    .modal-content { min-height: auto; }
}

/* --- Print (invoices) ------------------------------------------------------ */
@media print {
    .no-print, .sidebar, .bottom-nav, .sticky-footer, .menu-toggle { display: none !important; }
    body { background: #fff; }
    .panel-main { margin: 0 !important; padding: 0 !important; }
    .card, .panel-card { border: none; box-shadow: none; }
}
