/* آفاق — تطبيق طلبات المندوبين. نفس هوية البرنامج: حبر، زجاج مضبب، كهرماني. */
@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --ink: #1F2B2C;
    --ink-2: #3B494A;
    --muted: #6A7776;
    --frost: #EDF1F0;
    --frost-2: #E3E9E7;
    --line: #D6DDDB;
    --paper: #FFFFFF;
    --amber: #B5651D;
    --amber-deep: #8F4E14;
    --amber-soft: #F7EADB;
    --glass: #2E6E68;
    --glass-soft: #DDEBE8;
    --red: #B23A30;
    --red-soft: #F8E3E0;
    --r-sm: 8px;
    --r: 12px;
    --focus: 0 0 0 3px rgba(181, 101, 29, .28);
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
    font-family: "Plex Arabic", "Segoe UI", Tahoma, sans-serif; font-size: 16px; line-height: 1.5;
    color: var(--ink); background: var(--frost); font-variant-numeric: tabular-nums;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ltr { direction: ltr; text-align: right; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.5em; margin: 8px 0 0; font-size: 14px; }

/* عناصر */
.input {
    width: 100%; height: 46px; padding: 0 12px; margin-top: 4px; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--paper); outline: none; font-size: 16px; /* 16px يمنع تكبير iPhone */
}
.input:focus { border-color: var(--amber); box-shadow: var(--focus); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.btn {
    height: 46px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--paper);
    font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.primary:active { background: var(--amber-deep); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* الدخول */
.login { max-width: 420px; margin: 0 auto; padding: 48px 20px; }
.login .logo { display: block; width: 180px; margin: 0 auto 12px; background: #fff; border-radius: var(--r); padding: 10px 18px; }
.login h1 { text-align: center; font-size: 22px; margin: 0; }
.login > p { text-align: center; margin: 4px 0 20px; }
.login .card { padding: 16px; }

/* الهيكل */
.top {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--ink); color: #fff;
}
.top > div { flex: 1; display: flex; align-items: baseline; gap: 8px; }
.top b { font-size: 18px; }
.top small { color: #A9B8B5; }
.top .btn.ghost { color: #DCE4E2; }
.net { background: var(--red); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 10px; }
.tab { padding: 14px 16px calc(150px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

.tabs {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: 1fr 1fr;
    background: var(--paper); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs button { height: 56px; border: 0; background: none; font-weight: 600; color: var(--muted); position: relative; }
.tabs button.on { color: var(--ink); box-shadow: inset 0 3px 0 var(--amber); }
.count { display: inline-block; min-width: 20px; height: 20px; line-height: 20px; margin-inline-start: 6px; padding: 0 6px; border-radius: 10px; background: var(--amber); color: #fff; font-size: 12px; }

/* المواد */
.search { position: sticky; top: 58px; z-index: 4; background: var(--frost); padding: 12px 0 10px; }
/* صف لكل مادة: صورة صغيرة + الاسم + العدّاد — أسرع من البطاقات الكبيرة مع عشرات المواد */
.grid { display: flex; flex-direction: column; gap: 8px; }
.prod {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 8px;
    display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 10px;
}
.prod.on { border-color: var(--amber); box-shadow: var(--focus); }
.prod .img {
    width: 64px; height: 64px; border-radius: var(--r-sm); background: var(--frost); border: 0; padding: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.prod .img img { width: 100%; height: 100%; object-fit: contain; }
.prod .img span { color: var(--muted); font-size: 11px; }
.prod .name { font-size: 15px; font-weight: 600; line-height: 1.35; }
.qty { display: grid; grid-template-columns: 40px 64px 40px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.prod.on .qty { border-color: var(--amber); }
.qty button { height: 44px; border: 0; background: var(--frost); font-size: 22px; font-weight: 600; cursor: pointer; }
.qty button:active { background: var(--frost-2); }
.qty input { border: 0; text-align: center; font-weight: 700; font-size: 17px; min-width: 0; outline: none; background: var(--paper); }
.qty input:focus { box-shadow: inset 0 0 0 2px var(--amber); }

.sendbar {
    position: fixed; inset-inline: 0; bottom: calc(56px + var(--safe-b)); z-index: 6; padding: 10px 16px;
    background: linear-gradient(to top, var(--frost) 70%, rgba(237, 241, 240, 0));
}
.sendbar .btn { height: 52px; font-size: 17px; max-width: 688px; margin: 0 auto; display: flex; }

/* طلباتي */
.bar-title { display: flex; align-items: center; justify-content: space-between; }
.bar-title h2 { margin: 0; font-size: 20px; }
.order { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); margin-top: 10px; }
.order > button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; background: none; text-align: start; cursor: pointer; }
.order .who { flex: 1; min-width: 0; }
.order .who b { display: block; }
.order .who small { color: var(--muted); }
.order .body { padding: 0 14px 12px; border-top: 1px solid var(--frost-2); }
.pill { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.new { background: var(--amber-soft); color: var(--amber-deep); }
.pill.ok { background: var(--glass-soft); color: var(--glass); }
.pill.no { background: var(--red-soft); color: var(--red); }
.pill.off { background: var(--frost-2); color: var(--muted); }

.lines { list-style: none; margin: 8px 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--frost-2); }
.lines li b { direction: ltr; }

/* المراجعة */
.sheet-layer { position: fixed; inset: 0; z-index: 20; background: rgba(31, 43, 44, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
    width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; background: var(--paper); border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(16px + var(--safe-b)); border-top: 4px solid var(--amber); animation: up .18s ease-out;
}
.sheet h2 { margin: 0; }
.sheet-actions { display: grid; gap: 6px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

.toast {
    position: fixed; inset-inline: 16px; bottom: calc(130px + var(--safe-b)); z-index: 30; margin: 0 auto; max-width: 480px;
    background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 28px rgba(31, 43, 44, .28);
}
.toast.error { background: var(--red); }

/* ---------- الأسعار (المندوب) ---------- */
.prod .mid { min-width: 0; display: grid; gap: 4px; }
.prod .price { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; color: var(--muted); }
.prod .price-in {
    width: 84px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
    font-size: 15px; font-weight: 600; text-align: center; direction: ltr; outline: none; color: var(--ink);
}
.prod .price-in:focus { border-color: var(--amber); box-shadow: var(--focus); }
.prod .price-in.empty { border-color: var(--amber); background: var(--amber-soft); }
.lines li span small { display: block; color: var(--muted); font-size: 13px; direction: ltr; text-align: right; }
.total { font-weight: 700; font-size: 17px; text-align: end; margin: 6px 0; }

/* ---------- الحالات ---------- */
.pill.ready { background: var(--glass); color: #fff; }
.ready-note { color: var(--glass); font-weight: 600; margin: 6px 0; }
.small { font-size: 13px; }
.good { color: var(--glass); }
.bad { color: var(--red); }
.dim { color: var(--muted); }

/* ---------- المشرف ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line); background: var(--paper); font-size: 14px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.input.sm { height: 36px; width: auto; margin: 0; font-size: 14px; }
.summary { font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.mini { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.mini th { text-align: start; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 4px 6px; border-bottom: 1px solid var(--line); }
.mini td { padding: 7px 4px; border-bottom: 1px solid var(--frost-2); }
.mini td:not(:first-child), .mini th:not(:first-child) { text-align: end; direction: ltr; white-space: nowrap; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; margin: 6px 0; }

/* ---------- المجهّز ---------- */
.prep { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-top: 10px; }
.prep.done { opacity: .7; }
.prep-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.prep-head small { display: block; color: var(--muted); }
.prep-lines { list-style: none; padding: 0; margin: 10px 0; }
.prep-lines li { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--frost-2); }
.prep-lines li b { font-size: 20px; direction: ltr; }
.pimg { width: 48px; height: 48px; border-radius: 6px; background: var(--frost); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: contain; }
.prep-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prep .btn.primary.block { background: var(--glass); border-color: var(--glass); height: 52px; font-size: 17px; }

/* ---------- عرض الإشعارات ---------- */
.pushbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; background: var(--amber-soft); color: var(--amber-deep); font-size: 14px; }
.pushbar span { flex: 1 1 200px; }

/* عدد الكراتين */
.cartons { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 12px; font-size: 14px; }
.cartons small { display: block; color: var(--muted); font-size: 12px; }
.stepper { display: grid; grid-template-columns: 44px 56px 44px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.stepper button { height: 42px; border: 0; background: var(--frost); font-size: 22px; font-weight: 600; cursor: pointer; }
.stepper input { border: 0; text-align: center; font-weight: 700; font-size: 17px; min-width: 0; outline: none; background: var(--paper); }
.stepper input:focus { box-shadow: inset 0 0 0 2px var(--amber); }
.lines li.deliv { color: var(--ink-2); }
.prep-cartons { margin: 8px 0 0; font-size: 16px; }
