/* واجهة مستودع: أهداف لمس كبيرة، تباين عالٍ، وقراءة سريعة بيد واحدة. */
:root {
  --bg: #f4f6f8; --card: #fff; --ink: #14202b; --muted: #64748b;
  --line: #dbe2ea; --brand: #0f766e; --brand-ink: #fff;
  --ok: #15803d; --warn: #b45309; --warn-bg: #fff7ed; --danger: #b91c1c;
  --shadow: 0 1px 3px rgba(16,32,48,.09), 0 6px 18px rgba(16,32,48,.06);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1418; --card: #16212a; --ink: #e8eef3; --muted: #93a4b3;
    --line: #26343f; --brand: #14b8a6; --brand-ink: #04211f;
    --ok: #22c55e; --warn: #f59e0b; --warn-bg: #2a1f0d; --danger: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 system-ui, "Segoe UI", Tahoma, sans-serif;
  overscroll-behavior-y: contain;
}

/* ── الشاشات ── */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }
.pad { padding: 16px; padding-bottom: 120px; flex: 1; }

.bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  padding-top: max(12px, env(safe-area-inset-top));
}
.bar strong { flex: 1; font-size: 1.05rem; }
.bar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink); font-size: 20px; cursor: pointer;
}
.icon-btn:active { background: var(--bg); }

/* ── العناصر العامة ── */
.muted { color: var(--muted); }
.section-title { font-size: .95rem; color: var(--muted); margin: 24px 0 10px; font-weight: 600; }
.lead { color: var(--muted); margin-top: 0; }
.err { color: var(--danger); font-size: .9rem; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: .8rem; color: var(--muted); white-space: nowrap;
}
.chip.cod { background: #fef3c7; color: #92400e; border-color: #fcd34d; font-weight: 700; }
@media (prefers-color-scheme: dark) { .chip.cod { background: #422006; color: #fde68a; border-color: #78350f; } }

.btn {
  min-height: 52px; padding: 0 20px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.small { min-height: 42px; padding: 0 14px; }
.btn.big { min-height: 58px; font-size: 1.05rem; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 14px; font: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ── تسجيل الدخول ── */
.login-wrap { margin: auto; width: min(420px, 100%); padding: 24px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand h1 { font-size: 1.35rem; margin: 12px 0 4px; }

/* ── زر المسح ── */
.scan-hero {
  width: 100%; border: 0; border-radius: 20px; padding: 34px 20px;
  background: var(--brand); color: var(--brand-ink); cursor: pointer;
  display: grid; gap: 4px; justify-items: center; box-shadow: var(--shadow);
  font: inherit; font-weight: 700; font-size: 1.2rem;
}
.scan-hero:active { transform: scale(.99); }
.scan-icon { font-size: 44px; line-height: 1; }
.scan-hero small { font-weight: 500; opacity: .85; font-size: .85rem; }

.manual { display: flex; gap: 8px; margin: 14px 0 0; }
.manual input { margin: 0; }
.manual .btn { flex: 0 0 auto; }

/* ── الماسح ── */
.scan-screen { background: #000; position: relative; }
#cam { width: 100%; height: 100dvh; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 22% 10% auto; height: 190px;
  border: 3px solid rgba(255,255,255,.9); border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}
.scan-bar {
  position: absolute; inset: auto 0 0; padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  display: grid; gap: 12px; justify-items: center;
}
.scan-bar span { color: #fff; font-size: .9rem; }
.scan-bar .btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }

/* ── شاشة الطلب ── */
.ord-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ord-meta { display: grid; }
.ord-meta span:first-child { font-weight: 700; font-size: 1.1rem; }
.badges { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }

.warn {
  background: var(--warn-bg); color: var(--warn); border-right: 5px solid currentColor;
  padding: 12px 16px; font-weight: 600; font-size: .93rem;
}
.warn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.notes-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.cust-note {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600;
}
.staff-notes { display: grid; gap: 8px; }
.staff-note { font-size: .9rem; border-right: 3px solid var(--line); padding-right: 10px; }
.staff-note b { font-size: .8rem; color: var(--muted); font-weight: 600; }
.note-add { display: flex; gap: 8px; margin-top: 12px; }
.note-add input { margin: 0; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
#bar-fill { height: 100%; width: 0; background: var(--ok); transition: width .25s; }

.items { display: grid; gap: 12px; }
.item {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); cursor: pointer;
}
.item.checked { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--card)); }
.item img, .item .noimg {
  width: 74px; height: 74px; border-radius: 10px; object-fit: cover;
  background: var(--bg); flex: 0 0 auto;
}
.item .noimg { display: grid; place-items: center; font-size: .7rem; color: var(--muted); text-align: center; }
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 600; line-height: 1.35; }
.item-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.item-qty { font-size: 1.5rem; font-weight: 800; flex: 0 0 auto; min-width: 46px; text-align: center; }
.tick {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; flex: 0 0 auto; font-size: 18px; color: transparent;
}
.item.checked .tick { background: var(--ok); border-color: var(--ok); color: #fff; }

.actions {
  position: fixed; inset: auto 0 0; display: flex; gap: 10px; padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.actions .btn { flex: 1; }

/* ── القوائم ── */
.list { display: grid; gap: 10px; }
.row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.row.repeat { border-color: var(--warn); }
.row-main { min-width: 0; }
.row-main b { display: block; }
.row-main small { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; }
.stat small { color: var(--muted); font-size: .78rem; }

.awb-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 14px 0; }
.awb-box code { font-size: 1.05rem; font-weight: 700; }

/* ── تنبيهات ── */
.toast {
  position: fixed; inset: auto 16px calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 14px 18px; border-radius: var(--r);
  text-align: center; font-weight: 600; box-shadow: var(--shadow);
}
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--danger); color: #fff; }
.net-bar {
  position: fixed; inset: 0 0 auto; z-index: 60; background: var(--danger); color: #fff;
  text-align: center; padding: 8px; font-size: .88rem; font-weight: 600;
}
