:root {
    --brown: #2f1c19;
    --brown-soft: #3d2823;
    --brown-mid: #4a312b;
    --gold: #a6894d;
    --gold-deep: #8d7340;
    --gold-ink: #6f5a32;
    --gold-soft: #e4d3ae;
    --ivory: #f7f3ea;
    --cream: #fbf8f3;
    --stone: #e9e0d1;
    --muted: #7d7168;
    --ink: #241815;
    --line: rgba(166, 137, 77, 0.38);
    --available: #3e6b4f;
    --occupied: #8d7340;
    --open: #b5532f;
    --topbar-h: 64px;
}

* { box-sizing: border-box; }

body.staff-body,
body.staff-login-page {
    font-family: 'Tajawal', 'Noto Kufi Arabic', sans-serif;
    background: var(--ivory);
    color: var(--ink);
    margin: 0;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, .staff-brand strong, .table-no, .kitchen-table {
    font-family: 'Noto Kufi Arabic', 'Tajawal', sans-serif;
}

a { color: var(--gold-ink); }

.staff-muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn-staff-primary {
    background: var(--brown);
    border: 1px solid var(--brown);
    color: var(--gold-soft);
    font-weight: 700;
    border-radius: 12px;
}
.btn-staff-primary:hover,
.btn-staff-primary:focus {
    background: var(--brown-soft);
    border-color: var(--brown-soft);
    color: #fff;
}
.btn-staff-primary:disabled {
    background: var(--stone);
    border-color: var(--stone);
    color: var(--muted);
}
.btn-staff-outline {
    border: 1px solid var(--line);
    color: var(--gold-ink);
    background: transparent;
    border-radius: 10px;
    font-weight: 700;
}
.btn-staff-outline:hover {
    background: var(--brown);
    color: var(--gold-soft);
}
.form-control:focus,
.form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(166, 137, 77, 0.22);
}

/* ---------- Top bar ---------- */
.staff-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 18px;
    background: var(--brown);
    color: var(--ivory);
    border-bottom: 1px solid rgba(166, 137, 77, 0.35);
}
.staff-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ivory);
    text-decoration: none;
    flex: none;
}
.staff-brand img {
    height: 40px;
    width: auto;
    background: var(--cream);
    border-radius: 8px;
    padding: 4px 6px;
}
.staff-brand span { display: flex; flex-direction: column; line-height: 1.15; }
.staff-brand strong { font-size: 1.05rem; color: var(--ivory); }
.staff-brand small { font-size: 0.66rem; letter-spacing: 0.16em; color: var(--gold-soft); }

.staff-nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.staff-nav::-webkit-scrollbar { display: none; }
.staff-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 10px;
    color: #e9e0d1;
    text-decoration: none;
    white-space: nowrap;
    font-weight: 500;
}
.staff-nav a:hover,
.staff-nav a.active {
    background: var(--brown-mid);
    color: var(--gold-soft);
}
.staff-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}
.staff-user-name { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.staff-user-name em {
    font-style: normal;
    font-size: 0.72rem;
    background: rgba(166, 137, 77, 0.25);
    color: var(--gold-soft);
    padding: 2px 8px;
    border-radius: 999px;
}
.staff-logout {
    color: var(--gold-soft);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(166, 137, 77, 0.35);
}
.staff-logout:hover { color: #fff; background: var(--brown-mid); }

.staff-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 18px 40px;
}

@media (max-width: 767px) {
    .staff-topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
    .staff-nav { order: 3; flex-basis: 100%; }
    .staff-nav a span { font-size: 0.86rem; }
    .staff-user { margin-inline-start: auto; }
    .staff-user-name { display: none; }
    .staff-main { padding: 14px 12px 96px; }
}

/* ---------- Hero / panels ---------- */
.staff-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.staff-hero h1 { font-size: 1.45rem; margin: 0 0 4px; color: var(--brown); }
.staff-hero p { margin: 0; color: var(--muted); }

.staff-panel {
    background: var(--cream);
    border: 1px solid var(--stone);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 18px;
}
.staff-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.staff-panel-head h2 { font-size: 1.1rem; margin: 0; color: var(--brown); }
.staff-panel-head h2 i { color: var(--gold-deep); margin-inline-end: 6px; }

.staff-empty {
    text-align: center;
    color: var(--muted);
    padding: 28px 12px;
}
.staff-empty i { font-size: 1.8rem; color: var(--gold); margin-bottom: 8px; display: block; }
.staff-empty p { margin: 0; }
.staff-empty.small { padding: 22px 8px; }

/* ---------- Tables ---------- */
.table-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.table-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.is-available { background: var(--available); }
.dot.is-occupied { background: var(--occupied); }
.dot.is-open_order { background: var(--open); }
.dot.is-locked { background: #6a5b52; }
.dot.is-inactive { background: #b7aea6; }

.table-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.table-toolbar .is-active { box-shadow: inset 0 0 0 2px #8d7340; }
.table-selection-summary { margin: 0 0 12px; font-weight: 700; }

.table-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
@media (min-width: 700px) {
    .table-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
    .table-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
button.table-tile { width: 100%; font: inherit; cursor: pointer; }
.table-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 112px;
    padding: 12px 8px;
    border-radius: 16px;
    background: #fff;
    border: 2px solid var(--stone);
    text-decoration: none;
    color: var(--ink);
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.table-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(47, 28, 25, 0.1); color: var(--ink); }
.table-no { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.table-state { font-size: 0.82rem; font-weight: 700; }
.table-tile small { font-size: 0.72rem; color: var(--muted); }
.table-tile.is-available { border-color: rgba(62, 107, 79, 0.45); }
.table-tile.is-available .table-state { color: var(--available); }
.table-tile.is-occupied { border-color: rgba(141, 115, 64, 0.6); background: #fdf8ee; }
.table-tile.is-occupied .table-state { color: var(--occupied); }
.table-tile.is-open_order { border-color: rgba(181, 83, 47, 0.6); background: #fdf1ec; }
.table-tile.is-open_order .table-state { color: var(--open); }
.table-tile.is-locked {
    border-color: #c4b8aa;
    background: #f4f1ec;
    color: #5c534c;
    cursor: not-allowed;
}
.table-tile.is-locked:hover { transform: none; box-shadow: none; color: #5c534c; }
.table-tile.is-locked .table-state { color: #6a5b52; }
.table-tile.is-inactive { background: #f6f3ef; color: #8a817a; border-style: dashed; }
.table-tile.is-inactive:hover { transform: none; box-shadow: none; }
.table-tile.is-picked { background: #fff6d8; border-color: #c4a15a; box-shadow: inset 0 0 0 2px #8d7340; }
.table-lock-note {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.35;
    color: #6d645e;
    margin-top: 4px;
}
.table-lock-banner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #f4f1ec;
    border: 1px solid #c4b8aa;
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
    color: #4a403a;
}
.table-lock-banner > i { margin-top: 2px; color: #6a5b52; }
.table-lock-banner p { margin: 2px 0 0; }
.table-lock-banner[hidden],
.table-lock-banner.d-none { display: none !important; }

.table-chip {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 3px 10px;
    border: 1px solid currentColor;
}
.table-chip.is-available { color: var(--available); }
.table-chip.is-occupied { color: var(--occupied); }
.table-chip.is-open_order { color: var(--open); }
.table-chip.is-locked { color: #6a5b52; }

/* ---------- Status pills ---------- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
.status-pill.is-new { background: #fdeee8; color: #a3401f; }
.status-pill.is-preparing { background: #fbf1da; color: #7a5a12; }
.status-pill.is-ready { background: #e6f2ea; color: #2f6343; }

/* ---------- Orders (waiter) ---------- */
.order-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.order-filters button {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--gold-ink);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.85rem;
    font-weight: 700;
}
.order-filters button.active { background: var(--brown); border-color: var(--brown); color: var(--gold-soft); }

.order-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
}
.order-card {
    background: #fff;
    border: 1px solid var(--stone);
    border-inline-start: 4px solid var(--stone);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.order-card.status-sent { border-inline-start-color: #c4542c; }
.order-card.status-preparing { border-inline-start-color: #c49a2c; }
.order-card.status-ready { border-inline-start-color: #3e7b55; background: #f6fbf7; }
.order-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.order-card header strong { display: block; font-size: 1.05rem; color: var(--brown); }
.order-card header span { font-size: 0.82rem; color: var(--muted); }
.ready-hint {
    margin: 0;
    background: #e6f2ea;
    color: #2f6343;
    border-radius: 10px;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 0.88rem;
}
.order-items { list-style: none; margin: 0; padding: 0; }
.order-items li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--stone); font-size: 0.92rem; }
.order-items li:last-child { border-bottom: 0; }
.order-items .qty { font-weight: 700; color: var(--gold-ink); min-width: 30px; }
.order-items em,
.kitchen-items em,
.cart-line em,
.review-note {
    display: block;
    font-style: normal;
    font-size: 0.8rem;
    color: #a3401f;
}
.order-items li.is-cancelled,
.kitchen-items li.is-cancelled { text-decoration: line-through; opacity: 0.55; }
.order-notes {
    margin: 0;
    background: var(--ivory);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.88rem;
    color: var(--brown-soft);
}
.order-notes i { color: var(--gold-deep); }
.order-card footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.order-meta { font-size: 0.78rem; color: var(--muted); }
.order-total { font-weight: 700; color: var(--brown); }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Order builder ---------- */
.page-builder .staff-main { max-width: 1500px; }
.builder {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}
@media (min-width: 992px) {
    .builder { grid-template-columns: minmax(0, 1fr) 390px; align-items: start; }
    .builder-cart {
        position: sticky;
        top: calc(var(--topbar-h) + 16px);
        max-height: calc(100vh - var(--topbar-h) - 32px);
    }
}
.builder-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.builder-table { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.builder-table-no {
    font-family: 'Noto Kufi Arabic', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--brown);
}
.builder-change { font-size: 0.85rem; font-weight: 700; }
.builder-search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.builder-search i { position: absolute; top: 50%; inset-inline-start: 12px; transform: translateY(-50%); color: var(--muted); }
.builder-search input { padding-inline-start: 36px; border-radius: 12px; min-height: 44px; }

.cat-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 12px;
    scrollbar-width: thin;
}
.cat-chips button {
    flex: none;
    border: 1px solid var(--line);
    background: var(--cream);
    color: var(--brown-soft);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 700;
    min-height: 42px;
}
.cat-chips button.active { background: var(--gold); border-color: var(--gold); color: var(--brown); }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.product-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    text-align: start;
    background: #fff;
    border: 1px solid var(--stone);
    border-radius: 14px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.product-tile:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 8px 18px rgba(47, 28, 25, 0.1); }
.product-tile img,
.product-tile-ph {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--stone);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 1.6rem;
}
.product-tile-body { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; }
.product-tile-name { font-weight: 700; font-size: 0.92rem; color: var(--ink); line-height: 1.35; }
.product-tile-price { font-weight: 700; font-size: 0.88rem; color: var(--gold-ink); }
.product-tile.is-off { opacity: 0.5; cursor: not-allowed; }
.product-tile.is-off:hover { transform: none; box-shadow: none; border-color: var(--stone); }
.in-cart {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brown);
    color: var(--gold-soft);
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.builder-cart {
    background: var(--cream);
    border: 1px solid var(--stone);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cart-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--stone);
    background: var(--brown);
    color: var(--ivory);
}
.cart-head h2 { font-size: 1.02rem; margin: 0; flex: 1; color: var(--ivory); }
.cart-head .btn-link { color: #f3b8a4 !important; text-decoration: none; font-weight: 700; }
.cart-head .btn-close { filter: invert(1); }
.cart-lines { flex: 1; overflow-y: auto; padding: 6px 14px; min-height: 120px; }
.cart-line {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--stone);
}
.cart-line:last-child { border-bottom: 0; }
.cart-line-main { min-width: 0; }
.cart-line-main strong { display: block; font-size: 0.95rem; }
.cart-line-unit { font-size: 0.75rem; color: var(--muted); }
.cart-line-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.cart-line-total { font-weight: 700; font-size: 0.9rem; color: var(--brown); }
.mini-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.mini-stepper button {
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--brown);
}
.mini-stepper button:hover { background: var(--gold-soft); }
.mini-stepper span { min-width: 26px; text-align: center; font-weight: 700; }
.cart-line-actions { display: flex; gap: 4px; }
.cart-line-actions button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--stone);
    background: #fff;
    color: var(--gold-ink);
    font-size: 0.8rem;
}
.cart-line-actions button[data-act="remove"] { color: #b03a1f; }
.cart-foot { padding: 12px 16px 16px; border-top: 1px solid var(--stone); background: #fff; }
.cart-foot .form-label { font-size: 0.85rem; font-weight: 700; color: var(--brown-soft); }
.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    font-size: 1.1rem;
}
.cart-total-row strong { color: var(--brown); font-size: 1.3rem; }

.cart-fab {
    position: fixed;
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: 14px;
    right: 14px;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--brown);
    color: var(--ivory);
    box-shadow: 0 12px 30px rgba(36, 24, 21, 0.3);
    font-weight: 700;
}
.cart-fab span:nth-child(2) { flex: 1; text-align: start; }
.cart-fab-count {
    min-width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--brown);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
@media (max-width: 991px) {
    .builder-cart {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 1040;
        max-height: 88vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(105%);
        transition: transform 0.25s ease;
        box-shadow: 0 -12px 40px rgba(36, 24, 21, 0.3);
    }
    .builder-cart.is-open { transform: translateY(0); }
}

/* Item modal */
.item-modal-media img { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.item-modal-title { font-size: 1.25rem; margin: 0 0 4px; color: var(--brown); }
.item-modal-desc { color: var(--muted); font-size: 0.9rem; margin: 0 0 6px; }
.item-modal-price { font-weight: 700; color: var(--gold-ink); font-size: 1.1rem; }
.qty-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.qty-stepper button { width: 52px; border: 0; background: var(--ivory); color: var(--brown); font-size: 1rem; }
.qty-stepper button:hover { background: var(--gold-soft); }
.qty-stepper input {
    width: 70px;
    border: 0;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    min-height: 52px;
    -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.quick-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.quick-notes button {
    border: 1px dashed var(--line);
    background: transparent;
    color: var(--brown-soft);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.82rem;
}
.quick-notes button.active { background: var(--gold-soft); border-style: solid; border-color: var(--gold); font-weight: 700; }
.modal-content { border-radius: 18px; overflow: hidden; border: 1px solid var(--stone); }
.review-table td, .review-table th { vertical-align: middle; }
.review-table tfoot th { font-size: 1.1rem; color: var(--brown); }
.success-check {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto;
    background: #e6f2ea;
    color: #2f6343;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Toasts ---------- */
.staff-toasts {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100% - 24px));
    pointer-events: none;
}
.staff-toast {
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 10px 28px rgba(36, 24, 21, 0.2);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.staff-toast.is-success { background: var(--brown); color: var(--gold-soft); }
.staff-toast.is-error { background: #a3401f; color: #fff; }
.staff-toast.is-hiding { opacity: 0; transform: translateY(-8px); }

/* ---------- Login ---------- */
.staff-login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--brown) !important;
}
.staff-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--cream);
    border: 1px solid var(--stone);
    border-radius: 18px;
    padding: 34px 28px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}
.staff-login-logo { height: 76px; width: auto; margin-bottom: 10px; }
.staff-login-card h1 { font-size: 1.5rem; color: var(--brown); margin: 0; }
.staff-login-en { letter-spacing: 0.22em; color: var(--gold); margin: 2px 0 6px; font-size: 0.85rem; }
.password-field { position: relative; }
.password-field .form-control { padding-left: 74px; }
.password-toggle {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--brown);
    font-weight: 700;
    min-height: 36px;
    padding: 4px 6px;
}
.password-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .table-tile, .product-tile, .builder-cart, .staff-toast { transition: none; }
}
