/* Errands ("اطلب موصّل"): customer request + tracking, courier errand board,
   courier ledger ("دفتري") and the admin errand centre. Touch targets ≥ 48px. */

.errand-page .tracking-shell { width: min(820px, calc(100% - 32px)) !important; }
.errand-hero { margin: 8px 0 18px; text-align: start; }
.errand-hero h1 { margin: 6px 0 8px; font-size: clamp(28px, 5vw, 42px); line-height: 1.15; }
.errand-hero p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.errand-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.errand-steps li { display: flex; gap: 8px; align-items: flex-start; padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--line); font-size: 14px; }
.errand-steps li b { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 13px; }

.errand-form { display: grid; gap: 16px; }
.errand-card { padding: 18px; border-radius: 22px; background: rgba(255, 255, 255, .96); border: 1px solid rgba(85, 62, 45, .11); box-shadow: 0 14px 40px rgba(58, 38, 23, .08); display: grid; gap: 12px; min-width: 0; }
.errand-card > h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 19px; }
.errand-card > h2 svg { width: 22px; height: 22px; color: var(--orange); }
.errand-card > p.errand-hint { margin: 0; color: var(--muted); font-size: 14px; }
.errand-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 700; min-width: 0; }
.errand-card input, .errand-card textarea, .errand-card select { width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 14px; border: 1px solid #dcd3c5; background: #fff; font: inherit; font-size: 16px; color: inherit; box-sizing: border-box; }
.errand-card textarea { min-height: 84px; resize: vertical; }
.errand-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.errand-items { display: grid; gap: 10px; }
.errand-item-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.errand-qty { display: inline-flex; align-items: center; border: 1px solid #dcd3c5; border-radius: 14px; overflow: hidden; background: #fff; }
.errand-qty button { width: 48px; min-height: 50px; border: 0; background: #fff7ef; font-size: 22px; font-weight: 800; cursor: pointer; color: inherit; }
.errand-qty output { min-width: 34px; text-align: center; font-weight: 800; }
.errand-icon-button { display: inline-grid; place-items: center; width: 50px; min-height: 50px; border-radius: 14px; border: 1px solid #f1c9b7; background: #fff4ee; color: #b42318; cursor: pointer; }
.errand-icon-button svg, .errand-secondary svg, .errand-primary svg { width: 20px; height: 20px; }
.errand-secondary, .errand-primary, .errand-danger { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 18px; border-radius: 16px; font: inherit; font-size: 16px; font-weight: 800; cursor: pointer; text-decoration: none; }
.errand-secondary { border: 1px dashed #d6b9a6; background: #fffaf5; color: #9a3412; }
.errand-primary { border: 0; background: var(--orange-ink, #c2410c); color: #fff; font-size: 17px; font-weight: 800; box-shadow: 0 10px 24px rgba(240, 90, 36, .25); }
.errand-primary:disabled, .errand-secondary:disabled, .errand-danger:disabled { opacity: .55; cursor: not-allowed; }
.errand-danger { border: 1px solid #f4b4a8; background: #fff1ee; color: #b42318; }
.errand-check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; min-height: 48px; font-weight: 700; }
.errand-check input { width: 22px; min-height: 22px; height: 22px; }

.errand-fee { display: grid; gap: 6px; padding: 16px; border-radius: 18px; background: #fff4e6; border: 1px solid #f5d9b4; }
.errand-fee strong { font-size: 26px; color: #9a3412; }
.errand-fee small { color: #6b4b2f; font-size: 13px; line-height: 1.5; }
.errand-error { padding: 12px 14px; border-radius: 14px; background: #fff1ee; color: #b42318; border: 1px solid #f4b4a8; font-weight: 700; }
.errand-success { display: grid; gap: 12px; text-align: center; }
.errand-success .errand-pin, .errand-pin { display: inline-block; margin: 0 auto; padding: 10px 22px; border-radius: 16px; background: #17201c; color: #fff; font-size: 34px; letter-spacing: .3em; font-weight: 900; direction: ltr; }
.errand-success a { justify-self: center; }

.errand-status-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 4px 0 10px; padding: 0; list-style: none; }
.errand-status-steps li { padding: 10px 6px; border-radius: 12px; background: #f1ece4; color: var(--muted); font-size: 13px; font-weight: 800; text-align: center; }
.errand-status-steps li.done { background: var(--green); color: #fff; }
.errand-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.errand-list li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #faf6f0; }
.errand-money { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.errand-money span { display: grid; gap: 4px; padding: 12px; border-radius: 14px; background: #faf6f0; }
.errand-money small { color: var(--muted); font-size: 12px; }
.errand-money b { font-size: 18px; }
.errand-receipt { width: 100%; max-height: 360px; object-fit: contain; border-radius: 16px; background: #f1ece4; }

/* Courier errand board and active errand */
.courier-errands .job-list article { align-items: center; }
.courier-errand-items { margin: 6px 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.courier-errand-items li { padding: 4px 10px; border-radius: 999px; background: #fff4e6; font-size: 13px; }
.courier-errand-actions { display: grid; gap: 10px; }
.courier-errand-actions button, .courier-errands .job-list button, .courier-ledger button { min-height: 52px; font-size: 16px; }
.courier-errand-upload { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; border-radius: 16px; border: 2px dashed #d6b9a6; background: #fffaf5; font-weight: 800; cursor: pointer; }
.courier-errand-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.courier-errand-cost { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.courier-errand-cost input, .courier-errand-pin input { min-height: 56px; font-size: 20px; padding: 8px 14px; border-radius: 14px; border: 1px solid #dcd3c5; width: 100%; box-sizing: border-box; }

/* Ledger ("دفتري") — courier and admin */
.ledger-ranges { display: flex; flex-wrap: wrap; gap: 8px; }
.ledger-ranges button { min-height: 48px; padding: 8px 16px; border-radius: 14px; border: 1px solid #dcd3c5; background: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.ledger-ranges button[aria-pressed="true"] { background: var(--green); color: #fff; border-color: var(--green); }
.ledger-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.ledger-totals span { display: grid; gap: 4px; padding: 12px; border-radius: 14px; background: #faf6f0; }
.ledger-totals small { font-size: 12px; color: var(--muted); }
.ledger-totals b { font-size: 18px; }
.ledger-table-wrap { overflow-x: auto; }
.ledger-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.ledger-table th, .ledger-table td { padding: 10px 8px; border-bottom: 1px solid #eee5d8; text-align: start; white-space: nowrap; }
.ledger-table th { position: static !important; top: auto !important; background: #f6f1ea; font-size: 12px; color: #6b6255; }
.ledger-table td { vertical-align: top; }
.ledger-table td.negative { color: #b42318; font-weight: 800; }
.ledger-table td.positive { color: #9a3412; font-weight: 800; }
.ledger-note { font-size: 13px; color: var(--muted); }

/* Admin errand centre */
.admin-errands .errand-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.admin-errands .errand-kpis span { display: grid; gap: 4px; padding: 14px; border-radius: 16px; background: #faf6f0; }
.admin-errands .errand-kpis small { font-size: 12px; color: var(--muted); }
.admin-errands .errand-kpis b { font-size: 22px; }
.admin-errands .errand-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.admin-errands .errand-filters select, .admin-errands .errand-filters input { min-height: 44px; padding: 6px 10px; border-radius: 12px; border: 1px solid #dcd3c5; font: inherit; }
.admin-errands .errand-filters button, .admin-errands td button { min-height: 44px; padding: 6px 12px; border-radius: 12px; border: 1px solid #dcd3c5; background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.admin-errands .errand-status { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #f1ece4; font-size: 12px; font-weight: 800; }
.admin-errands .errand-status.delivered { background: #dff3e8; color: #1f6b4f; }
.admin-errands .errand-status.refused, .admin-errands .errand-status.cancelled { background: #fff1ee; color: #b42318; }

@media (max-width: 640px) {
  .errand-two, .errand-steps { grid-template-columns: 1fr; }
  .errand-money, .ledger-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .errand-status-steps li { font-size: 12px; }
}

@media print {
  .print-area { padding: 12mm; }
  .print-area .no-print, .print-area button, .print-area .ledger-ranges, .print-area .errand-filters { display: none !important; }
  .ledger-table, .print-area table { min-width: 0; font-size: 12px; }
  .ledger-table th, .ledger-table td, .print-area th, .print-area td { border-bottom: 1px solid #999; white-space: normal; }
}

/* Section header actions (refresh / print) sit in one row on every width. */
.admin-errands > header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-errands > header > .no-print { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-errands > header > .no-print button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 6px 12px; border-radius: 12px; border: 1px solid #dcd3c5; background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.admin-privacy .errand-kpis span { background: #f3f6f4; }
.admin-privacy .errand-kpis b { color: #1f4d36; }
