:root {
    --rt-bg: #f4f1ec;
    --rt-surface: #ffffff;
    --rt-ink: #1c1917;
    --rt-muted: #78716c;
    --rt-line: #e7e0d8;
    --rt-brand: #c2410c;
    --rt-brand-dark: #9a3412;
    --rt-navy: #1c1917;
    --rt-sidebar: #1c1410;
    --rt-ok: #15803d;
    --rt-warn: #b45309;
    --rt-danger: #b91c1c;
    --rt-shadow: 0 10px 30px rgba(28, 20, 16, .08);
}

* { box-sizing: border-box; }

html, body.app-body {
    height: 100%;
    margin: 0;
}

body.app-body {
    background: var(--rt-bg);
    color: var(--rt-ink);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    overflow: hidden;
}

.app-shell {
    display: flex;
    height: 100dvh;
    overflow: hidden;
}

.sidebar {
    flex: 0 0 260px;
    width: 260px;
    max-width: 260px;
    background: var(--rt-sidebar);
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    position: sticky;
    top: 0;
    color: #fafaf9;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    height: 100dvh;
    overflow: auto;
}

.sidebar .brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar .brand small { color: #a8a29a; letter-spacing: .12em; text-transform: uppercase; font-size: .68rem; }
.sidebar .nav-link {
    color: #d6d3d1;
    border-radius: 10px;
    padding: .65rem .85rem;
    margin: .15rem .75rem;
    display: flex;
    gap: .65rem;
    align-items: center;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
    background: rgba(194, 65, 12, .22);
    color: #fff;
}
.sidebar .nav-section {
    padding: .9rem 1.25rem .25rem;
    color: #a8a29a;
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.topbar {
    background: var(--rt-surface);
    border-bottom: 1px solid var(--rt-line);
    padding: .85rem 1.25rem;
}

.card-rt {
    background: var(--rt-surface);
    border: 1px solid var(--rt-line);
    border-radius: 16px;
    box-shadow: var(--rt-shadow);
}

.stat-card {
    border: 0;
    border-radius: 18px;
    padding: 1.1rem 1.2rem;
    color: #fff;
    min-height: 120px;
}
.stat-card .label { opacity: .85; font-size: .85rem; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; }
.bg-rt-1 { background: linear-gradient(135deg, #c2410c, #ea580c); }
.bg-rt-2 { background: linear-gradient(135deg, #1c1917, #44403c); }
.bg-rt-3 { background: linear-gradient(135deg, #15803d, #16a34a); }
.bg-rt-4 { background: linear-gradient(135deg, #1e3a5f, #2563eb); }

.portion-choice {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    border: 1px solid var(--rt-line);
    border-radius: 12px;
    padding: .85rem 1rem;
    margin-bottom: .5rem;
    background: #fff;
    color: var(--rt-ink);
    cursor: pointer;
}
.portion-choice.active {
    border-color: var(--rt-brand);
    background: #ffedd5;
    color: var(--rt-ink);
}
.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--rt-brand);
    --bs-btn-border-color: var(--rt-brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--rt-brand-dark);
    --bs-btn-hover-border-color: var(--rt-brand-dark);
    --bs-btn-focus-shadow-rgb: 194, 65, 12;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--rt-brand-dark);
    --bs-btn-active-border-color: var(--rt-brand-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--rt-brand);
    --bs-btn-disabled-border-color: var(--rt-brand);
    background: var(--rt-brand);
    border-color: var(--rt-brand);
    color: #fff;
    font-weight: 600;
}
.btn-brand:hover,
.btn-brand:focus,
.btn-brand:active,
.btn-brand.active {
    background: var(--rt-brand-dark);
    border-color: var(--rt-brand-dark);
    color: #fff;
}

.btn-outline-dark {
    --bs-btn-color: var(--rt-ink);
    --bs-btn-border-color: #44403c;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--rt-ink);
    --bs-btn-hover-border-color: var(--rt-ink);
    color: var(--rt-ink);
    border-color: #44403c;
    background: #fff;
    font-weight: 600;
}
.btn-outline-dark:hover,
.btn-outline-dark:focus {
    background: var(--rt-ink);
    border-color: var(--rt-ink);
    color: #fff;
}

.btn-outline-secondary {
    --bs-btn-color: #44403c;
    --bs-btn-border-color: #a8a29a;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #44403c;
    --bs-btn-hover-border-color: #44403c;
    color: #44403c;
    border-color: #a8a29a;
    background: #fff;
    font-weight: 600;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background: #44403c;
    border-color: #44403c;
    color: #fff;
}

.btn-outline-danger {
    font-weight: 600;
    background: #fff;
}

.table thead th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--rt-muted);
    border-bottom-color: var(--rt-line);
}

.badge-soft {
    background: #ffedd5;
    color: #9a3412;
}

.product-tile {
    border: 1px solid var(--rt-line);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    height: 100%;
    transition: transform .12s ease, box-shadow .12s ease;
}
.product-tile:hover { transform: translateY(-2px); box-shadow: var(--rt-shadow); }
.product-tile .thumb {
    height: 140px;
    background: #f5f0ea;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.login-wrap {
    min-height: 100vh;
    background: radial-gradient(circle at top left, #ea580c 0%, #1c1410 42%, #0c0a09 100%);
}
.login-card {
    border: 0;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.35);
}

.pos-shell { min-height: 100vh; background: #ece7e1; }
.pos-top {
    background: #1c1410;
    color: #fff;
    padding: .7rem 1rem;
}
.pos-grid { display: grid; grid-template-columns: 1fr 380px; min-height: calc(100vh - 58px); }
.pos-products { padding: 1rem; overflow: auto; }
.pos-cart {
    background: #fff;
    border-left: 1px solid var(--rt-line);
    display: flex;
    flex-direction: column;
}
.pos-item {
    border: 0;
    border-radius: 14px;
    background: #fff;
    text-align: left;
    padding: .7rem;
    width: 100%;
    box-shadow: 0 6px 16px rgba(28,20,16,.06);
}
.pos-item .price { color: var(--rt-brand); font-weight: 700; }
.cat-chip {
    border: 0;
    background: #fff;
    border-radius: 999px;
    padding: .4rem .9rem;
    margin: 0 .35rem .5rem 0;
}
.cat-chip.active { background: var(--rt-brand); color: #fff; }
.pay-btn { min-height: 56px; font-size: 1.05rem; font-weight: 700; }

.table-tile {
    border: 0;
    border-radius: 18px;
    min-height: 120px;
    color: #fff;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
    box-shadow: var(--rt-shadow);
}
.table-tile:hover { color: #fff; transform: translateY(-2px); }
.table-available { background: linear-gradient(135deg, #15803d, #22c55e); }
.table-occupied { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.table-reserved { background: linear-gradient(135deg, #b45309, #f59e0b); }
.table-paying { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }

.kds-shell { background: #140f0d; color: #fafaf9; min-height: 100vh; }
.kds-top { background: #1c1410; padding: .75rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.kds-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 1rem; min-height: calc(100vh - 56px); }
.kds-col { background: rgba(255,255,255,.04); border-radius: 18px; padding: .9rem; }
.kds-col header h2 { font-size: 1.15rem; margin: 0; }
.kds-count { background: rgba(255,255,255,.12); border-radius: 999px; padding: .15rem .65rem; font-weight: 700; }
.kds-cards { display: flex; flex-direction: column; gap: .75rem; margin-top: .85rem; }
.kds-card { background: #fff; color: #1c1917; border-radius: 16px; padding: .9rem 1rem; box-shadow: var(--rt-shadow); }
.kds-number { font-size: 1.45rem; font-weight: 800; }
.kds-meta, .kds-time { color: #78716c; font-size: .85rem; }
.kds-card ul { margin: .7rem 0; padding-left: 1.1rem; }
.kds-note { color: #c2410c; font-size: .85rem; }
.kds-btn { background: var(--rt-brand); color: #fff; font-weight: 700; min-height: 44px; }
.kds-btn:hover { background: var(--rt-brand-dark); color: #fff; }
.kds-queued .kds-btn { background: #b45309; }
.kds-preparing .kds-btn { background: #1d4ed8; }
.kds-ready .kds-btn { background: #15803d; }
.kds-empty { color: #a8a29a; text-align: center; margin-top: 2rem; }

.delivery-card {
    display: block;
    border: 1px solid var(--rt-line);
    border-radius: 12px;
    padding: .75rem .85rem;
    margin-bottom: .65rem;
    color: var(--rt-ink);
    background: #fafaf9;
}
.delivery-card:hover { border-color: var(--rt-brand); color: var(--rt-ink); }

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

html:has(.menu-shell),
body.menu-shell {
    height: 100%;
    margin: 0;
    overflow: hidden;
}
.menu-shell {
    height: 100dvh;
    background: #2a211c;
    color: var(--rt-ink);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    overflow: hidden;
}
.menu-frame {
    width: 100%;
    max-width: 430px;
    height: 100dvh;
    margin: 0 auto;
    background: var(--rt-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(28, 20, 16, .08), 0 20px 50px rgba(28, 20, 16, .28);
}
.menu-top {
    flex: 0 0 auto;
    z-index: 20;
    background: var(--rt-sidebar); color: #fff;
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
    padding: .85rem 1rem;
    padding-top: max(.85rem, env(safe-area-inset-top, 0px));
}
.menu-body {
    padding: 1rem;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.menu-tools { flex: 0 0 auto; }
.menu-body #grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.menu-item {
    min-height: 118px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.menu-bar,
.menu-dock {
    flex: 0 0 auto;
    z-index: 25;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    width: 100%;
    background: #fff;
    border-top: 1px solid var(--rt-line);
    box-shadow: 0 -8px 24px rgba(28, 20, 16, .08);
    padding: .75rem 1rem;
    padding-bottom: max(.75rem, env(safe-area-inset-bottom, 0px));
}
.menu-bar .btn { min-height: 44px; }
.menu-cart {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: min(100%, 430px);
    max-height: min(82dvh, 640px);
    overflow: auto;
    background: #fff;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    box-shadow: var(--rt-shadow);
    transform: translate(-50%, 110%);
    transition: transform .2s ease;
    z-index: 40;
}
.menu-cart.open { transform: translate(-50%, 0); }
.menu-backdrop,
.menu-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 20, 16, .45);
    z-index: 35;
}
.menu-backdrop.open,
.menu-scrim.open { display: block; }
.menu-shell input.form-control,
.menu-shell select.form-select { font-size: 16px; }
.menu-shell .modal-dialog { max-width: min(400px, calc(100% - 1.5rem)); }

.swal2-popup {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif !important;
    border-radius: 16px !important;
    color: var(--rt-ink);
}
.swal2-title { color: var(--rt-ink) !important; }
.swal2-styled.swal2-confirm {
    border-radius: 10px !important;
    font-weight: 600 !important;
}
.swal2-styled.swal2-cancel {
    border-radius: 10px !important;
}

.purchase-pick {
    min-height: 42px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.purchase-search-list {
    max-height: 360px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.purchase-search-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--rt-line);
    border-radius: 12px;
    padding: .75rem 1rem;
    background: #fff;
    color: var(--rt-ink);
}

.purchase-search-item:hover,
.purchase-search-item:focus {
    border-color: var(--rt-brand);
    background: #ffedd5;
}

.purchase-search-item .meta {
    font-size: .8rem;
    color: var(--rt-muted);
}

@media (max-width: 991px) {
    body.app-body { overflow: auto; }
    .app-shell { display: block; height: auto; min-height: 100dvh; overflow: visible; }
    .sidebar { width: 100%; max-width: none; flex: none; height: auto; min-height: auto; position: relative; }
    .app-main { height: auto; overflow: visible; }
    .pos-grid { grid-template-columns: 1fr; }
    .pos-cart { border-left: 0; border-top: 1px solid var(--rt-line); min-height: 50vh; }
    .kds-grid { grid-template-columns: 1fr; }
}
