/* طلبيات الفروع - ألوان لوجو Daddy's Burger: أصفر #FFC400 وأسود وأبيض
   التخطيط: شريط علوي أسود فيه اللوجو والتنقل، والمحتوى على أرضية فاتحة دافية، والأصفر للأزرار والحالة النشطة */
:root {
  --yellow: #FFC400;
  --yellow-soft: #FFF3C4;
  --yellow-deep: #E0AC00;
  --black: #0b0b0b;
  --ink: #1b1a17;
  --muted: #6d6a62;
  --paper: #f7f6f2;
  --card: #ffffff;
  --line: #e4e1d8;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --info: #1d5fb8;
  --info-soft: #e4eefb;
  --warn: #b25e00;
  --warn-soft: #fdeedd;
  --bad: #c0352b;
  --bad-soft: #fbe5e3;
  --font: "Cairo", Tahoma, "Segoe UI", Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.boot { min-height: 100vh; display: grid; place-items: center; background: var(--black); }

/* ---------- الشريط العلوي ---------- */
.topbar {
  background: var(--black);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 44px; height: auto; }
.brand b { font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.brand small { display: block; color: var(--yellow); font-size: 12px; font-weight: 600; line-height: 1.2; }
.userbox { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.userbox .who { text-align: left; line-height: 1.3; }
.userbox .who span { color: #bdb9ad; display: block; font-size: 12px; }
.icon-btn {
  background: transparent; border: 1px solid #3a3933; color: #fff; border-radius: 8px;
  padding: 5px 10px; cursor: pointer; font-size: 13px;
}
.icon-btn:hover { border-color: var(--yellow); color: var(--yellow); }

.nav {
  max-width: 1200px; margin: 0 auto;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; text-decoration: none; color: #d8d4c8;
  padding: 8px 14px 10px; font-weight: 700; font-size: 14px;
  border-bottom: 3px solid transparent;
}
.nav a:hover { color: #fff; }
.nav a.active { color: var(--yellow); border-bottom-color: var(--yellow); }
.nav .badge { background: var(--yellow); color: var(--black); border-radius: 99px; padding: 0 7px; font-size: 12px; margin-inline-start: 4px; }

/* ---------- المحتوى ---------- */
main {
  max-width: 1200px; margin: 0 auto;
  padding-block: 20px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 800; text-wrap: balance; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 16px; }
.section-title { font-size: 15px; font-weight: 800; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- الأزرار والحقول ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 14px;
  cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--yellow); border-color: var(--yellow); color: var(--black); }
.btn-primary:hover { background: var(--yellow-deep); border-color: var(--yellow-deep); }
.btn-dark { background: var(--black); border-color: var(--black); color: #fff; }
.btn-dark:hover { background: #2a2925; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, .chip:focus-visible, .nav a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 10px; min-height: 40px; font-size: 15px;
}
.input:focus { border-color: var(--ink); outline: none; }
textarea.input { min-height: 70px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 700; font-size: 13px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { flex: 1 1 150px; max-width: 220px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--black); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--black); border-color: var(--black); color: var(--yellow); }

/* ---------- الحالات ---------- */
.pill { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.st-new { background: var(--yellow-soft); color: #7a5a00; }
.st-preparing { background: var(--info-soft); color: var(--info); }
.st-shipped { background: var(--warn-soft); color: var(--warn); }
.st-received { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: #eeece6; color: var(--muted); text-decoration: line-through; }
.late { background: var(--bad-soft); color: var(--bad); }

/* ---------- ملخص أعلى الصفحة ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; text-align: start; }
.stat:hover { border-color: var(--ink); }
.stat b { display: block; font-size: 26px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 700; }
.stat.hot { background: var(--black); color: #fff; border-color: var(--black); }
.stat.hot b { color: var(--yellow); }
.stat.hot span { color: #d8d4c8; }
.notice { background: var(--yellow-soft); border: 1px solid #f1dc8f; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f0eee7; font-weight: 800; font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbfaf5; }
td.n, th.n { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.cat-row td { background: var(--black); color: var(--yellow); font-weight: 800; font-size: 13px; padding: 5px 12px; }
tr.total td { font-weight: 800; background: #f0eee7; }
td.diff { color: var(--bad); font-weight: 800; }
.qty-in { width: 96px; text-align: center; min-height: 36px; padding: 4px 6px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- نموذج الطلبية ---------- */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.order-side { position: sticky; top: 120px; display: flex; flex-direction: column; gap: 12px; }
.item-list { display: flex; flex-direction: column; }
.item-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: 0; }
.item-row.has { background: #fffbea; }
.item-row .nm { font-weight: 700; }
.item-row .un { color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 18px; font-weight: 800; cursor: pointer; line-height: 1; }
.stepper button:hover { border-color: var(--ink); }
.stepper input { width: 70px; text-align: center; min-height: 36px; padding: 2px 4px; }
.cat-head { background: var(--black); color: var(--yellow); font-weight: 800; padding: 6px 14px; font-size: 13px; position: sticky; top: 108px; z-index: 2; }
.summary-list { max-height: 260px; overflow: auto; font-size: 13px; }
.summary-list div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.mobile-bar { display: none; }

/* ---------- تفاصيل الطلبية ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 20px; }
.meta-grid div span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.meta-grid div b { font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }

/* ---------- الدخول ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; background: var(--black);
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; border-top: 8px solid var(--yellow); }
.login-card img { width: 120px; align-self: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 20px; font-weight: 800; }
.err { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 14px; }

/* ---------- نافذة منبثقة وتنبيه ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-size: 18px; font-weight: 800; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; margin-top: 4px; }
#toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--black); color: #fff; border-inline-start: 5px solid var(--yellow);
  padding: 10px 18px; border-radius: 10px; font-weight: 700; z-index: 60; max-width: calc(100% - 32px);
}
#toast.bad { border-inline-start-color: var(--bad); }

.tabs-inline { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .order-layout, .two-col { grid-template-columns: minmax(0, 1fr); }
  .order-side { position: static; }
  .order-side .side-submit { display: none; }
  .cat-head { top: 100px; }
  .mobile-bar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--black); color: #fff; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  }
  .mobile-bar b { color: var(--yellow); }
  .brand b { font-size: 15px; }
  .userbox .who { display: none; }
}
@media (max-width: 480px) {
  .modal .row2 { grid-template-columns: 1fr; }
  .filters .field { max-width: none; }
  th, td { padding: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .stat { transition: background .15s, border-color .15s, color .15s; }
}
