/* ============================================================================
   لوحة تحكم كاتشوو — نظام التصميم
   عربية RTL · جوال أولًا · وضع فاتح/داكن تلقائي
   ========================================================================== */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --border: #e2e7ec;
  --text: #1a2330;
  --muted: #647080;
  --brand: #0d8a7b;
  --brand-600: #0a6f63;
  --brand-50: #e5f5f2;
  --brand-ink: #ffffff;

  --new: #2f6fdd;
  --assigned: #6b5bd6;
  --out: #e07b1a;
  --delivered: #1a9b55;
  --returned: #d64545;
  --rescheduled: #c48a00;
  --cancelled: #7b8794;

  --ok: #1a9b55;
  --warn: #c48a00;
  --danger: #d64545;
  --info: #2f6fdd;

  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 4px 14px rgba(20, 30, 45, 0.05);
  --shadow-lg: 0 10px 40px rgba(15, 25, 40, 0.22);
  --radius: 12px;
  --sidebar: 244px;
  --font:
    'Segoe UI', Tahoma, 'Noto Sans Arabic', 'Noto Naskh Arabic', system-ui, -apple-system,
    sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1520;
    --surface: #182130;
    --surface-2: #1f2a3b;
    --border: #2b374a;
    --text: #e8edf3;
    --muted: #93a0b2;
    --brand: #2fc3ad;
    --brand-600: #48d5c0;
    --brand-50: #143a37;
    --brand-ink: #0b1a18;
    --new: #6ea1ff;
    --assigned: #a094ff;
    --out: #ffa24d;
    --delivered: #4cd08a;
    --returned: #ff7b7b;
    --rescheduled: #f0c24a;
    --cancelled: #a4b0bf;
    --ok: #4cd08a;
    --warn: #f0c24a;
    --danger: #ff7b7b;
    --info: #6ea1ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.3;
}
h1 {
  font-size: 22px;
}
h2 {
  font-size: 18px;
}
h3 {
  font-size: 16px;
}
a {
  color: var(--brand-600);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button {
  font-family: inherit;
}
.num,
.mono {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.bold {
  font-weight: 700;
}
.center {
  text-align: center;
}
.grow {
  flex: 1 1 auto;
  min-width: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.between {
  justify-content: space-between;
}
.hidden {
  display: none !important;
}
.nowrap {
  white-space: nowrap;
}
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}
.ok {
  color: var(--ok);
}
.warn {
  color: var(--warn);
}
.danger {
  color: var(--danger);
}
.info {
  color: var(--info);
}

/* ---------------------------------------------------------------- الهيكل */
.app {
  display: grid;
  /* minmax(0,1fr) لا 1fr: وإلا مدّد جدولٌ عريض عمود المحتوى فوق عرض الشاشة (شاشة 1000–1150px) بدل أن يتمرّر داخل بطاقته */
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 16px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand b {
  font-size: 16px;
  display: block;
}
.brand span {
  font-size: 12px;
  color: var(--muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: start;
  font-size: 15px;
}
.nav-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-600);
}
.nav-item .badge-count {
  margin-inline-start: auto;
}
.nav-sep {
  height: 1px;
  background: var(--border);
  margin: 10px 4px;
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-50);
  color: var(--brand-600);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.main {
  min-width: 0;
  padding: 22px 26px 60px;
  max-width: 1400px;
  width: 100%;
}
.topbar {
  display: none;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head .sub {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}

/* شريط سفلي للجوال */
.bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .sidebar.open {
    display: flex;
    position: fixed;
    inset: 0 0 0 auto;
    width: min(300px, 86vw);
    z-index: 60;
    height: 100vh;
    box-shadow: var(--shadow-lg);
  }
  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(10, 16, 28, 0.5);
    z-index: 55;
  }
  .topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .topbar h1 {
    font-size: 17px;
  }
  .main {
    padding: 14px 14px 96px;
  }
  .bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 45;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    background: none;
    border: 0;
    padding: 6px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
  }
  .bottom-nav button.active {
    color: var(--brand-600);
  }
  .page-head h1 {
    font-size: 19px;
  }
}

/* ---------------------------------------------------------------- عناصر */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.grid {
  display: grid;
  gap: 14px;
}
.grid.c2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.c3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.c4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.tiles {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
@media (max-width: 900px) {
  .grid.c3,
  .grid.c4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .grid.c2 {
    grid-template-columns: 1fr;
  }
  .grid.tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tile {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: start;
  cursor: default;
}
.tile.click {
  cursor: pointer;
}
.tile.click:hover {
  border-color: var(--brand);
}
.tile .t-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.tile .t-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.tile .t-sub {
  font-size: 12.5px;
  color: var(--muted);
}
.tile.tone-ok .t-value {
  color: var(--ok);
}
.tile.tone-warn .t-value {
  color: var(--warn);
}
.tile.tone-danger .t-value {
  color: var(--danger);
}
.tile.tone-brand .t-value {
  color: var(--brand-600);
}

/* أزرار */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}
.btn.primary:hover:not(:disabled) {
  background: var(--brand-600);
}
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover:not(:disabled) {
  filter: brightness(0.92);
  background: var(--danger);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand-600);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--brand-50);
}
.btn.sm {
  padding: 5px 11px;
  font-size: 13px;
  border-radius: 8px;
}
.btn.lg {
  padding: 13px 20px;
  font-size: 16px;
  border-radius: 12px;
}
.btn.block {
  width: 100%;
}
.btn.icon {
  padding: 8px;
}
.icon-svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.btn.sm .icon-svg {
  width: 15px;
  height: 15px;
}

/* حقول */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field > label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.field .hint {
  font-size: 12.5px;
  color: var(--muted);
}
.input,
select.input,
textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
textarea.input {
  resize: vertical;
  min-height: 84px;
}
.input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: transparent;
}
.input.err {
  border-color: var(--danger);
}
.search {
  position: relative;
  min-width: 220px;
  flex: 1 1 240px;
}
.search .icon-svg {
  position: absolute;
  inset-inline-start: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.search .input {
  padding-inline-start: 36px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* شارات وشرائح */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge.s-NEW {
  color: var(--new);
  background: color-mix(in srgb, var(--new) 13%, transparent);
}
.badge.s-ASSIGNED {
  color: var(--assigned);
  background: color-mix(in srgb, var(--assigned) 13%, transparent);
}
.badge.s-OUT {
  color: var(--out);
  background: color-mix(in srgb, var(--out) 14%, transparent);
}
.badge.s-DELIVERED {
  color: var(--delivered);
  background: color-mix(in srgb, var(--delivered) 14%, transparent);
}
.badge.s-RETURNED {
  color: var(--returned);
  background: color-mix(in srgb, var(--returned) 13%, transparent);
}
.badge.s-RESCHEDULED {
  color: var(--rescheduled);
  background: color-mix(in srgb, var(--rescheduled) 16%, transparent);
}
.badge.s-CANCELLED {
  color: var(--cancelled);
  background: color-mix(in srgb, var(--cancelled) 16%, transparent);
}
.badge.t-ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}
.badge.t-warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
}
.badge.t-danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}
.badge.t-info {
  color: var(--info);
  background: color-mix(in srgb, var(--info) 14%, transparent);
}
.badge.t-brand {
  color: var(--brand-600);
  background: var(--brand-50);
}
.badge-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  display: inline-flex;
  gap: 7px;
  align-items: center;
}
.chip:hover {
  border-color: var(--brand);
}
.chip.on {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}
.chip .cnt {
  font-size: 12px;
  opacity: 0.85;
}
.chip.danger {
  border-color: var(--danger, #c0392b);
  color: var(--danger, #c0392b);
}
.chip.warn {
  border-color: var(--warn, #b7791f);
  color: var(--warn, #b7791f);
}
.chip.danger.on,
.chip.warn.on {
  color: #fff;
}
.chip.danger.on {
  background: var(--danger, #c0392b);
}
.chip.warn.on {
  background: var(--warn, #b7791f);
}
.tbl tr.row-warn td {
  background: color-mix(in srgb, var(--warn, #b7791f) 9%, transparent);
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  border: 0;
  background: none;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  font-size: 15px;
}
.tab.on {
  color: var(--brand-600);
  border-bottom-color: var(--brand);
}

/* جداول */
.table-wrap {
  overflow-x: auto;
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
.tbl th {
  text-align: start;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.tbl td {
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr.click {
  cursor: pointer;
}
.tbl tbody tr.click:hover {
  background: var(--surface-2);
}
.tbl tr.sel {
  background: var(--brand-50);
}
.tbl .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.tbl tfoot td {
  font-weight: 800;
  background: var(--surface-2);
}
@media (max-width: 760px) {
  table.tbl.cards,
  .tbl.cards thead,
  .tbl.cards tbody,
  .tbl.cards tr,
  .tbl.cards td {
    display: block;
    width: 100%;
  }
  .tbl.cards thead {
    display: none;
  }
  .tbl.cards tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 8px 4px;
    background: var(--surface);
  }
  .tbl.cards td {
    border: 0;
    padding: 5px 12px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: end;
  }
  .tbl.cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    font-size: 12.5px;
    text-align: start;
    flex: none;
  }
  .tbl.cards td[data-label=''],
  .tbl.cards td.nolabel {
    justify-content: flex-end;
  }
  .tbl.cards td.nolabel::before,
  .tbl.cards td[data-label='']::before {
    display: none;
  }
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
}

/* حوارات */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 28, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade 0.12s;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  animation: pop 0.14s;
}
.modal.wide {
  width: min(820px, 100%);
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(560px, 100%);
  background: var(--surface);
  z-index: 100;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide 0.16s;
}
.drawer-body {
  overflow-y: auto;
  padding: 16px 18px 40px;
  flex: 1;
}
@media (max-width: 900px) {
  .overlay.sheet {
    align-items: flex-end;
    padding: 0;
  }
  .overlay.sheet .modal {
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    animation: rise 0.18s;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes pop {
  from {
    transform: scale(0.97);
    opacity: 0;
  }
}
@keyframes slide {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
}
@keyframes rise {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
}

/* تنبيهات */
.toasts {
  position: fixed;
  bottom: 18px;
  inset-inline-start: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 36px));
}
@media (max-width: 900px) {
  .toasts {
    bottom: 84px;
    inset-inline: 12px;
    max-width: none;
  }
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 11px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: rise 0.18s;
}
.toast.ok {
  background: var(--ok);
  color: #fff;
}
.toast.err {
  background: var(--danger);
  color: #fff;
}
.alert {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14.5px;
}
.alert.warn {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}
.alert.danger {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.alert.info {
  background: color-mix(in srgb, var(--info) 10%, transparent);
  border-color: color-mix(in srgb, var(--info) 40%, transparent);
}
.alert.ok {
  background: color-mix(in srgb, var(--ok) 10%, transparent);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}
.empty .e-ico {
  width: 46px;
  height: 46px;
  margin: 0 auto 10px;
  opacity: 0.55;
}
.empty h3 {
  color: var(--text);
  margin-bottom: 4px;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-pad {
  display: grid;
  place-items: center;
  padding: 50px;
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* خط زمني */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline li {
  position: relative;
  padding: 0 22px 16px 0;
  border-inline-end: 2px solid var(--border);
  margin-inline-end: 6px;
}
.timeline li::before {
  content: '';
  position: absolute;
  inset-inline-end: -7px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}
.timeline li:last-child {
  border-inline-end-color: transparent;
  padding-bottom: 0;
}
.timeline .tl-title {
  font-weight: 700;
}
.timeline .tl-meta {
  font-size: 12.5px;
  color: var(--muted);
}

/* أجزاء خاصة */
.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  font-size: 14.5px;
}
.kv dt {
  color: var(--muted);
  font-weight: 600;
}
.kv dd {
  margin: 0;
  word-break: break-word;
}
.receipt-thumb {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 170px;
  padding: 10px 4px 0;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}
.bar {
  width: 100%;
  max-width: 46px;
  background: var(--brand);
  border-radius: 8px 8px 3px 3px;
  min-height: 3px;
  transition: height 0.3s;
}
.bar.today {
  background: var(--out);
}
.bar-val {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.bar-lbl {
  font-size: 12px;
  color: var(--muted);
}
.attn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: start;
  width: 100%;
  font-size: 14.5px;
}
.attn:hover {
  border-color: var(--brand);
}
.attn .n {
  font-size: 20px;
  font-weight: 800;
  min-width: 34px;
  text-align: center;
}
.attn.warn .n {
  color: var(--warn);
}
.attn.danger .n {
  color: var(--danger);
}
.attn.info .n {
  color: var(--info);
}
.order-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.order-card .oc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.oc-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.oc-actions .full {
  grid-column: 1 / -1;
}
.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.method-btn {
  padding: 12px 6px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.method-btn.on {
  border-color: var(--brand);
  background: var(--brand-50);
  color: var(--brand-600);
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--brand-50), var(--bg));
}
.login-card {
  width: min(410px, 100%);
  padding: 28px;
}
.copy-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  direction: ltr;
  font-family: Consolas, monospace;
  font-size: 13.5px;
  overflow-x: auto;
}
.pill-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.var-chip {
  font-family: Consolas, monospace;
  direction: ltr;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  cursor: pointer;
  font-size: 13px;
}
.var-chip:hover {
  border-color: var(--brand);
}
.sticky-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 5;
  border-radius: 0 0 var(--radius) var(--radius);
  flex-wrap: wrap;
}
input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
  cursor: pointer;
}

@media print {
  .sidebar,
  .topbar,
  .bottom-nav,
  .btn,
  .toasts,
  .page-head .row,
  .tabs,
  .no-print {
    display: none !important;
  }
  .app {
    display: block;
  }
  .main {
    padding: 0;
    max-width: none;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card {
    box-shadow: none;
    border-color: #ccc;
    break-inside: avoid;
  }
}

/* ============================================================================ خط سير المندوب */
.route-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
  background: var(--brand-50);
  border-radius: var(--radius);
}
.route-cta .ico {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
}
.route-cta .ico .icon-svg {
  width: 24px;
  height: 24px;
}
.route-cta .txt {
  flex: 1;
  min-width: 0;
}
.route-cta .txt b {
  display: block;
  font-size: 16px;
}
.route-cta .txt span {
  color: var(--muted);
  font-size: 13.5px;
}
@media (max-width: 560px) {
  .route-cta {
    flex-wrap: wrap;
  }
  .route-cta .btn {
    width: 100%;
  }
}
.route-sum {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 15px;
}
.route-sum b {
  font-size: 18px;
}
.route-legs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}
.stops {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.stop {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.stop .seq {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  background: var(--brand);
  color: var(--brand-ink);
}
.stop.far .seq {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px dashed var(--border);
}
.stop .top {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
}
.stop .top b {
  font-size: 16px;
}
.stop .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13.5px;
}
.stop .meta .km {
  color: var(--brand-600);
  font-weight: 700;
}
.stop .meta .cod {
  color: var(--text);
  font-weight: 800;
  font-size: 15px;
}
.stop .acts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.stop .acts .btn {
  flex: 1 1 auto;
  justify-content: center;
}

/* خريطة خط السير */
.route-map {
  height: 300px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--surface-2);
  direction: ltr;
}
@media (min-width: 900px) {
  .route-map {
    height: 380px;
  }
}
.route-map.big {
  height: 62vh;
}
.route-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pin-wrap {
  background: none;
  border: 0;
}
.pin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 800 15px/1 var(--font);
  color: #fff;
  background: #0d8a7b;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s;
}
.pin.approx {
  border-style: dashed;
  background: #2f6fdd;
}
.pin.multi {
  width: auto;
  min-width: 32px;
  padding: 0 9px;
  border-radius: 16px;
  white-space: nowrap;
}
.pin.sel {
  transform: scale(1.35);
  background: #d64545;
  z-index: 10;
}
.route-arrow {
  color: #ffffff;
  text-shadow:
    0 0 3px #0a6f63,
    0 0 3px #0a6f63,
    0 0 2px #0a6f63;
  font-size: 13px;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}
.pin-me {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(26, 115, 232, 0.25);
}
.stop-now {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 2px solid var(--brand);
  border-radius: 12px;
  background: var(--brand-50);
}
.stop-now .seq {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  background: var(--brand);
  color: var(--brand-ink);
}
.stop-now .lbl {
  font-size: 12.5px;
  color: var(--brand-600);
  font-weight: 700;
}
.stop-now .nm {
  font-size: 17px;
}
.stop.on {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent);
}
.stop {
  cursor: pointer;
}
@media (max-width: 560px) {
  .stop-now {
    flex-wrap: wrap;
  }
  .stop-now .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================================ التقارير والطباعة */
.print-only { display: none; }
.period-bar { margin-bottom: 14px; }
.period-actions { margin-top: 10px; gap: 8px; }
.lnk { color: var(--brand-600); font-weight: 700; text-decoration: none; }
.lnk:hover { text-decoration: underline; }

.doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  max-width: 1100px;
  margin: 0 auto 24px;
  color: var(--text);
}
.doc-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 3px double #0d6f64;
}
.doc-logo { width: 64px; height: 64px; object-fit: contain; }
.doc-id { flex: 1; min-width: 0; }
.doc-store { font-size: 14px; font-weight: 700; color: #0d6f64; letter-spacing: .2px; }
.doc-title { margin: 2px 0 0; font-size: 24px; font-weight: 800; }
.doc-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }
.doc-meta { margin: 0; display: grid; grid-template-columns: auto auto; gap: 2px 10px; font-size: 12.5px; }
.doc-meta dt { color: var(--muted); }
.doc-meta dd { margin: 0; font-weight: 600; }
.doc-sec { margin-bottom: 22px; }
.doc-sec h3 {
  margin: 0 0 8px;
  padding: 5px 10px;
  font-size: 15px;
  background: #e8f0ef;
  color: #0a4d45;
  border-inline-start: 4px solid #0d6f64;
  break-after: avoid;
}
.doc-note { font-size: 12.5px; color: var(--muted); margin: 4px 0 8px; }
.doc-empty { padding: 14px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 6px; }
.doc-foot { margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); text-align: center; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } .doc { padding: 16px 12px; } .doc-head { flex-wrap: wrap; } }

table.rt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.rt th, table.rt td { padding: 7px 9px; border: 1px solid #cdd6df; text-align: right; vertical-align: top; }
table.rt thead th { background: #0d6f64; color: #fff; font-weight: 700; border-color: #0d6f64; white-space: nowrap; }
table.rt tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
table.rt tfoot td { background: #e8f0ef; color: #0a4d45; font-weight: 800; border-top: 2px solid #0d6f64; }
table.rt.dense th, table.rt.dense td { padding: 4px 8px; font-size: 12.5px; }
table.rt .n { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.rt tr { break-inside: avoid; }
table.rt thead { display: table-header-group; }
table.rt tfoot { display: table-footer-group; }

table.kv-t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv-t th, table.kv-t td { padding: 6px 9px; border-bottom: 1px solid #d9e0e7; }
table.kv-t th { text-align: right; font-weight: 500; }
table.kv-t th small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
table.kv-t td.n { text-align: left; unicode-bidi: plaintext; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
table.kv-t tr.strong th, table.kv-t tr.strong td { font-weight: 800; background: #eef5f4; border-top: 1px solid #0d6f64; }
table.kv-t tr.final th, table.kv-t tr.final td { border-bottom: 3px double #0d6f64; font-size: 15.5px; }
table.kv-t tr.warn td { color: #9a6a00; }

.chart { margin: 6px 0 10px; }
.chart svg { width: 100%; height: auto; max-height: 190px; }
.chart-cap { font-size: 11.5px; color: var(--muted); text-align: center; }
.defs { margin: 0; padding-inline-start: 20px; font-size: 12.5px; line-height: 1.9; color: var(--muted); }
.sign-row { display: flex; justify-content: space-between; gap: 20px; margin-top: 36px; font-size: 13px; }

@page { size: A4 portrait; margin: 12mm 11mm 16mm; @bottom-center { content: "صفحة " counter(page) " من " counter(pages); font: 9pt sans-serif; color: #555; } }
@page land { size: A4 landscape; margin: 10mm 10mm 14mm; @bottom-center { content: "صفحة " counter(page) " من " counter(pages); font: 9pt sans-serif; color: #555; } }
.doc.land { page: land; }

@media print {
  html, body { background: #fff !important; }
  .sidebar, .topbar, .bottom-nav, .toasts, .tabs, .page-head, .period-bar, .no-print, .btn { display: none !important; }
  .print-only { display: block !important; }
  .app { display: block !important; }
  .main { padding: 0 !important; max-width: none !important; margin: 0 !important; }
  .doc { border: 0; box-shadow: none; border-radius: 0; padding: 0; max-width: none; margin: 0; color: #000; }
  .doc.brk + .doc.brk { break-before: page; page-break-before: always; }
  .doc-sec { break-inside: auto; }
  .doc-sec h3 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.rt thead th, table.rt tfoot td, table.kv-t tr.strong th, table.kv-t tr.strong td, .doc-sec h3, .pin { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.rt { font-size: 10.5pt; }
  table.rt.dense { font-size: 9.5pt; }
  .doc.land table.rt { font-size: 9.5pt; }
  .table-wrap { overflow: visible !important; }
  .doc-foot { position: static; }
  a.lnk { color: #000; text-decoration: none; }
  .two-col { grid-template-columns: 1fr 1fr !important; gap: 14px; }
}

/* ============================================================================
   صفحات المندوب (طلباتي / ختام اليوم) — جوال بيد واحدة تحت الشمس
   كل القواعد داخل .courier-ui فلا تتأثر شاشات الإدارة. أهداف اللمس ≥ 48px، وحدود أوضح، وتباين أعلى للشارات.
   ========================================================================== */
:root {
  --topbar-h: 58px;
}
.topbar {
  min-height: var(--topbar-h);
}
/* لا يُعيد المتصفح تحميل التطبيق بسحب الشاشة للأسفل أثناء عمل المندوب (زر التحديث ظاهر) */
body:has(.courier-ui) {
  overscroll-behavior-y: contain;
}
.file-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
label.btn {
  position: relative;
  cursor: pointer;
}
.hint-line {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 2px 4px;
}
.change-line {
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--brand-50);
  color: var(--brand-600);
  font-weight: 700;
}
.toast-act {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  font-weight: 800;
  border-radius: 9px;
  padding: 6px 14px;
  min-height: 36px;
  cursor: pointer;
  font-family: inherit;
}
.reason-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reason-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
}
.reason-btn.on {
  border-color: var(--brand);
  background: var(--brand-50);
}
.reason-tag {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
}
.reason-tag.ret {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}
.seg {
  display: flex;
  gap: 8px;
}
.seg.wrap {
  flex-wrap: wrap;
}
.seg button {
  flex: 1 1 auto;
  min-height: 46px;
  padding: 8px 14px;
  border-radius: 11px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.seg button.on {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
}
.quick-msg {
  justify-content: flex-start;
  text-align: start;
  height: auto;
  padding: 12px 14px;
  white-space: normal;
}

.courier-ui .btn {
  min-height: 48px;
  font-size: 15.5px;
}
.courier-ui .btn.sm {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
}
.courier-ui .btn.icon {
  min-width: 48px;
  padding: 0;
}
.courier-ui .chip {
  min-height: 44px;
  padding: 8px 15px;
  font-size: 14.5px;
}
.courier-ui .input {
  min-height: 48px;
  font-size: 16px;
}
.cr-summary {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  margin-inline: -14px;
  padding: 10px 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
@media (min-width: 901px) {
  .cr-summary {
    top: 0;
    margin-inline: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
}
.cr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cr-big {
  font-size: 19px;
}
.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand-600);
  cursor: pointer;
}
.cr-progress {
  height: 10px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 6px 0 8px;
  border: 1px solid var(--border);
}
.cr-progress i {
  display: block;
  height: 100%;
  background: var(--delivered);
  border-radius: 99px;
  transition: width 0.4s;
}
.cr-money {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 14.5px;
}
.net-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
  font-size: 14px;
}
.start-day {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--brand-50);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
}
.cr-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cr-search {
  position: relative;
}
.cr-search .icon-svg {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.cr-search .input {
  width: 100%;
  padding-inline-start: 42px;
}
.cr-sec {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.cr-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 4px 12px;
}
.cr-group > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  font-weight: 800;
  cursor: pointer;
}
.cr-group[open] > summary {
  margin-bottom: 8px;
}
.cr-group .stack {
  padding-bottom: 12px;
}

.cu-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.cu-card.next {
  border: 2px solid var(--brand);
}
.cu-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cu-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.cu-name {
  font-size: 19px;
  line-height: 1.35;
}
.seq {
  flex: none;
  inline-size: 34px;
  block-size: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: 15px;
}
.amount-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
}
.amount-box b {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.amount-box small {
  inline-size: 100%;
  font-weight: 600;
  opacity: 0.85;
}
.amount-box.due {
  background: color-mix(in srgb, var(--warn) 18%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--warn) 70%, transparent);
  color: var(--text);
}
.amount-box.free {
  background: color-mix(in srgb, var(--ok) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
  font-size: 15px;
}
.cu-addr {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
}
.chip-copy {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.cu-note {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent);
  font-size: 15px;
}
.cu-items {
  line-height: 1.5;
}
.nav-btn {
  background: var(--brand-50);
  color: var(--brand-600);
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  min-height: 52px;
  font-size: 16.5px;
}
.cu-contact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.cu-contact .btn {
  padding-inline: 6px;
}
.btn.deliver {
  min-height: 56px;
  font-size: 18px;
  border-radius: 14px;
}
.btn.fail {
  min-height: 48px;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: var(--surface);
}
.cu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.cu-row .seq {
  inline-size: 30px;
  block-size: 30px;
  font-size: 14px;
}
.cu-row .amt {
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
}
.amt.due {
  color: var(--text);
  background: color-mix(in srgb, var(--warn) 22%, transparent);
  padding: 3px 10px;
  border-radius: 10px;
}
.amt.free {
  color: var(--ok);
}
.cu-row .chev {
  color: var(--muted);
  display: inline-flex;
}
.day-hero {
  text-align: center;
  padding: 18px 12px;
  border-radius: 16px;
  background: var(--brand-50);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
}
.day-big {
  font-size: 40px;
  font-weight: 900;
  color: var(--brand-600);
  letter-spacing: -1px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-size: 16px;
  cursor: pointer;
}
.check-row input {
  inline-size: 24px;
  block-size: 24px;
  accent-color: var(--brand);
}

/* تباين أعلى في الضوء الساطع (الوضع الفاتح فقط): حدود أوضح وألوان شارات أغمق */
@media (prefers-color-scheme: light) {
  .courier-ui {
    --border: #b9c2cd;
    --muted: #4f5b6b;
    --out: #8f4a00;
    --rescheduled: #7a5600;
    --delivered: #157a43;
    --assigned: #4d3fb5;
    --new: #1f55b8;
    --warn: #8a5d00;
    --ok: #157a43;
    --danger: #b32d2d;
    --info: #1f55b8;
    --brand: #0a6f63;
    --brand-600: #075a50;
  }
}
/* «وضع الشمس»: تباين عالٍ يدويًا (يُحفظ على الجهاز) */
html[data-contrast='high'] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #000000;
  --muted: #2b3440;
  --border: #1a2330;
  --brand: #00594f;
  --brand-600: #00443d;
  --brand-50: #d9f1ed;
  --out: #7a3d00;
  --rescheduled: #664600;
  --delivered: #0d6b37;
  --assigned: #3f3299;
  --new: #174aa6;
  --warn: #6e4a00;
  --ok: #0d6b37;
  --danger: #a31f1f;
  --info: #174aa6;
  color-scheme: light;
}
html[data-contrast='high'] .btn,
html[data-contrast='high'] .card,
html[data-contrast='high'] .cu-card,
html[data-contrast='high'] .cu-row,
html[data-contrast='high'] .input {
  border-width: 2px;
}
html[data-contrast='high'] .badge {
  border: 1.5px solid currentColor;
}

/* ====================================================================== سرعة الاستجابة */
/* لمسة فورية بلا تأخير نقر ولا وميض، وتأكيد بصري لحظي قبل أن يردّ الخادم */
button,
.btn,
.chip,
.nav-item,
[role='button'],
.click,
select,
summary,
label.btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled),
.chip:active,
.nav-item:active,
.bottom-nav button:active,
.cu-row:active {
  transform: scale(0.97);
  opacity: 0.88;
  transition: none;
}
tr.click:active {
  background: var(--surface-2);
}

/* شريط «جارٍ العمل»: يظهر أعلى الصفحة إن تأخّر أي طلب أكثر من 0.2ث (الطلبات السريعة لا تُظهره) */
html[data-busy]::before {
  content: '';
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--brand), transparent) no-repeat;
  background-size: 40% 100%;
  animation:
    busybar 1s linear infinite,
    busyshow 0s linear 0.2s both;
}
@keyframes busybar {
  from {
    background-position: -40% 0;
  }
  to {
    background-position: 140% 0;
  }
}
@keyframes busyshow {
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  html[data-busy]::before {
    background: var(--brand);
    animation: busyshow 0s linear 0.2s both;
  }
}

/* قائمة تُعرض ريثما تصل نتيجة الفلتر الجديد: خافتة بدل الفراغ أو الدائرة */
.is-placeholder {
  opacity: 0.5;
  transition: opacity 0.15s 0.12s;
}

/* الخادم المجاني ينام ويحتاج نصف دقيقة ليستيقظ: بعد 7 ثوانٍ من التأخّر نقول ذلك صراحةً بدل أن يبدو التطبيق معلَّقًا */
html[data-slow]::after {
  content: 'جارٍ الاتصال بالخادم… قد يستغرق دقيقة إن كان نائمًا';
  position: fixed;
  inset-block-start: 10px;
  inset-inline: 0;
  margin-inline: auto;
  width: max-content;
  max-width: calc(100vw - 32px);
  background: var(--text);
  color: var(--bg);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

/* زر يبدو كرابط نصي (روابط ثانوية في شاشة الدخول) */
.linklike {
  background: none;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  text-align: center;
  text-decoration: underline;
  font: inherit;
}
