:root {
    --oms-primary: #4f46e5;
    --oms-primary-2: #6366f1;
    --oms-teal: #0ea5a4;
    --oms-bg: #f4f6fb;
    --oms-card: #ffffff;
    --oms-text: #1e2333;
    --oms-muted: #6b7280;
    --oms-border: #e5e7f0;
    --oms-radius: 18px;
    --oms-shadow: 0 6px 24px rgba(30, 35, 51, .07);
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
}

* { -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    background: var(--oms-bg);
    color: var(--oms-text);
    font-family: "Rubik", "Segoe UI", "Noto Sans Hebrew", "Noto Sans Arabic", Tahoma, sans-serif;
    font-size: 17px;
    overscroll-behavior-y: contain;
}
.btn-primary { --bs-btn-bg: var(--oms-primary); --bs-btn-border-color: var(--oms-primary); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; }
.btn-outline-primary { --bs-btn-color: var(--oms-primary); --bs-btn-border-color: var(--oms-primary); --bs-btn-hover-bg: var(--oms-primary); --bs-btn-hover-border-color: var(--oms-primary); }
.btn { border-radius: 12px; }
.btn-lg { border-radius: 14px; padding: .8rem 1.2rem; }
.form-control, .form-select { border-radius: 12px; border-color: var(--oms-border); min-height: 48px; }
.form-control:focus, .form-select:focus { border-color: var(--oms-primary-2); box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .18); }

/* splash */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--oms-bg); z-index: 2000; }

/* top bar */
.topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 12px;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--oms-border);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; min-width: 0; }
.brand-title { font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .8rem; color: var(--oms-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--oms-border);
    background: #fff; color: var(--oms-text); font-size: 1.35rem; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.96); }
.count-badge { position: absolute; top: -6px; left: -6px; font-size: .7rem; }
.net-badge { font-size: .8rem; padding: 6px 10px; border-radius: 999px; background: #dcfce7; color: #166534; white-space: nowrap; }
.net-badge.offline { background: #fee2e2; color: #991b1b; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.view { padding: 18px 18px calc(110px + env(safe-area-inset-bottom)); max-width: 1400px; margin: 0 auto; }
.page-title { font-weight: 700; font-size: 1.45rem; margin: 4px 0 16px; display: flex; align-items: center; gap: 10px; }
.page-title .bi { color: var(--oms-primary); }

/* cards */
.card-x { background: var(--oms-card); border-radius: var(--oms-radius); box-shadow: var(--oms-shadow); border: 1px solid var(--oms-border); }
.card-x .card-x-body { padding: 18px; }

/* login */
.login-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 460px; padding: 34px 30px; }
.login-card .logo { width: 88px; height: 88px; display: block; margin: 0 auto 14px; }
.lang-switch .btn { min-width: 90px; }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.tile {
    border: 0; border-radius: 22px; padding: 22px 18px; text-align: start; color: #fff; min-height: 150px;
    display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--oms-shadow);
    transition: transform .12s ease;
}
.tile:active { transform: scale(.97); }
.tile .bi { font-size: 2.4rem; opacity: .95; }
.tile .tile-title { font-size: 1.2rem; font-weight: 700; }
.tile .tile-sub { font-size: .85rem; opacity: .85; }
.t-indigo { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.t-teal { background: linear-gradient(135deg, #0ea5a4, #0891b2); }
.t-amber { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.t-rose { background: linear-gradient(135deg, #e11d48, #db2777); }
.t-sky { background: linear-gradient(135deg, #0284c7, #2563eb); }
.t-green { background: linear-gradient(135deg, #16a34a, #0d9488); }
.t-slate { background: linear-gradient(135deg, #475569, #334155); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat .stat-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.stat .stat-val { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat .stat-label { color: var(--oms-muted); font-size: .85rem; }

/* list items */
.list-item {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: #fff; border: 1px solid var(--oms-border);
    border-radius: 16px; margin-bottom: 10px; cursor: pointer;
}
.list-item:active { background: #f5f5ff; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { color: var(--oms-muted); font-size: .88rem; }
.avatar { width: 46px; height: 46px; border-radius: 14px; background: #eef2ff; color: var(--oms-primary); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

.search-box { position: relative; }
.search-box .bi { position: absolute; top: 50%; transform: translateY(-50%); right: 16px; color: var(--oms-muted); }
.search-box input { padding-right: 44px; height: 54px; font-size: 1.05rem; border-radius: 16px; }

/* order builder */
.builder { display: grid; grid-template-columns: 230px 1fr; gap: 18px; }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; } }
.cat-list { position: sticky; top: 90px; align-self: start; max-height: calc(100vh - 120px); overflow: auto; }
@media (max-width: 900px) { .cat-list { position: static; display: flex; gap: 8px; overflow-x: auto; max-height: none; padding-bottom: 6px; } }
.cat-btn {
    display: block; width: 100%; text-align: start; border: 1px solid var(--oms-border); background: #fff; border-radius: 14px;
    padding: 12px 14px; margin-bottom: 8px; font-weight: 500; white-space: nowrap;
}
@media (max-width: 900px) { .cat-btn { width: auto; margin: 0; } }
.cat-btn.active { background: var(--oms-primary); color: #fff; border-color: var(--oms-primary); }
.cat-btn .cnt { float: left; font-size: .8rem; opacity: .7; }

.order-head {
    position: sticky; top: 72px; z-index: 1000; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; margin-bottom: 14px;
}
.order-head .cust { flex: 1; min-width: 180px; }
.order-head .cust .name { font-weight: 700; font-size: 1.1rem; }
.order-total { font-size: 1.6rem; font-weight: 800; color: var(--oms-primary); white-space: nowrap; }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.p-card { background: #fff; border: 1px solid var(--oms-border); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.p-card.in-cart { border-color: var(--oms-primary-2); box-shadow: 0 0 0 2px rgba(99, 102, 241, .25); }
.p-card.unavailable { opacity: .55; }
.p-img { height: 150px; background: #f3f4f8; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.p-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.p-img .bi { font-size: 3rem; color: #c7cbe0; }
.p-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.p-name { font-weight: 600; line-height: 1.25; }
.p-meta { color: var(--oms-muted); font-size: .82rem; display: flex; gap: 10px; flex-wrap: wrap; }
.p-price { font-weight: 800; font-size: 1.15rem; }
.p-price .old { text-decoration: line-through; color: var(--oms-muted); font-weight: 400; font-size: .9rem; margin-inline-start: 6px; }
.p-badges { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.p-badges .badge { font-size: .72rem; }
.p-note-btn { position: absolute; top: 10px; left: 10px; }

.qty { display: flex; align-items: stretch; gap: 6px; }
.qty button { width: 48px; border-radius: 12px; border: 1px solid var(--oms-border); background: #f8f9ff; font-size: 1.3rem; }
.qty input { text-align: center; font-weight: 700; font-size: 1.1rem; }
.unit-toggle { display: flex; background: #f1f2f8; border-radius: 12px; padding: 3px; }
.unit-toggle button { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 7px 6px; font-size: .9rem; }
.unit-toggle button.active { background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .1); font-weight: 600; color: var(--oms-primary); }
.price-input { max-width: 120px; }

.cart-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--oms-border);
    display: flex; align-items: center; gap: 12px; box-shadow: 0 -6px 24px rgba(30, 35, 51, .08);
}
.cart-bar .info { flex: 1; }
.cart-bar .info .lines { color: var(--oms-muted); font-size: .9rem; }

/* review table */
.review-table td, .review-table th { vertical-align: middle; }
.free-line { background: #f0fdf4 !important; }
.totals { max-width: 420px; margin-inline-start: auto; }
.totals .row-t { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { font-size: 1.4rem; font-weight: 800; border-top: 2px solid var(--oms-border); margin-top: 6px; padding-top: 10px; color: var(--oms-primary); }

.status-badge { font-size: .8rem; padding: .4em .8em; border-radius: 999px; }
.st-0 { background: #fef3c7; color: #92400e; }
.st-1 { background: #dcfce7; color: #166534; }
.st-2 { background: #fee2e2; color: #991b1b; }
.st-3 { background: #e5e7eb; color: #374151; }
.st-p { background: #e0e7ff; color: #3730a3; }
.st-e { background: #fecaca; color: #7f1d1d; }

.empty { text-align: center; color: var(--oms-muted); padding: 50px 10px; }
.empty .bi { font-size: 3rem; display: block; margin-bottom: 10px; color: #c7cbe0; }

/* DataTables in RTL */
div.dt-container .dt-search input { border-radius: 12px; min-height: 44px; }
div.dt-container { font-size: .95rem; }
table.dataTable tbody tr { cursor: pointer; }

.gallery-img { max-height: 60vh; max-width: 100%; object-fit: contain; }
.swal2-popup { border-radius: 22px !important; font-family: inherit; }
.swal2-styled { border-radius: 12px !important; }
