:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card2: #232730;
  --accent: #16a34a;
  --accent2: #22c55e;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --border: #2c313c;
  --danger: #ef4444;
  --blue: #3b82f6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  direction: ltr;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}

.badge {
  font-size: 13px;
  color: var(--muted);
  background: var(--card2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

input, select {
  width: 100%;
  padding: 14px 14px;
  font-size: 17px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  outline: none;
}

input:focus, select:focus { border-color: var(--accent2); }
select { appearance: none; -webkit-appearance: none; }

button {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary { background: var(--accent); }
.btn-primary:active { background: var(--accent2); }
.btn-secondary { background: var(--card2); border: 1px solid var(--border); }
.btn-link {
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  width: auto;
  padding: 8px;
  margin: 0;
}

button:disabled { opacity: .55; cursor: not-allowed; }

.status {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  display: none;
}
.status.show { display: block; }
.status.info { background: #1e293b; color: #cbd5e1; }
.status.ok { background: #14321f; color: #86efac; }
.status.err { background: #3a1717; color: #fca5a5; }

.loc-box {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}
.loc-box b { color: var(--text); }

.hi { font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.hi b { color: var(--accent2); }

/* Amount due in the current 10-day window (driver home) */
.due-card {
  margin-top: 16px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.due-period { font-size: 13px; color: var(--muted); }
.due-amount { font-size: 30px; font-weight: 800; color: var(--accent2); margin: 4px 0; line-height: 1.1; }
.due-count { font-size: 13px; color: var(--muted); }
.due-card .report-table { font-size: 13px; }
.due-card .empty { padding: 18px 10px; }

/* Owner dashboard */
.delivery {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.delivery .row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.delivery .name { font-weight: 700; font-size: 16px; }
.delivery .time { font-size: 12px; color: var(--muted); }
.delivery .order {
  display: inline-block;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 14px;
  margin: 4px 0;
}
.delivery .area { font-size: 14px; color: var(--text); margin: 6px 0; }
.delivery a.map {
  color: var(--blue);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.del-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 10px;
  flex-shrink: 0;
}
.del-btn:active { background: rgba(239, 68, 68, .12); }

/* Payment status badge (Paid / Pending) */
.pay-badge {
  width: auto;
  margin: 0;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid;
  cursor: pointer;
  display: inline-block;
  color: #fff;
}
.pay-badge.paid { background: #14321f; color: #86efac; border-color: #14532d; }
.pay-badge.pending { background: #3a2a12; color: #fbbf24; border-color: #78350f; }
.pay-badge:disabled { opacity: .6; cursor: default; }

/* Selection / payment action buttons */
.pay-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.pay-mark-all {
  width: auto;
  margin: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}
.pay-mark-all:active { background: var(--accent2); }

/* "Mark selected Paid / Pending" buttons */
.pay-mark-sel {
  width: auto;
  margin: 0;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  color: #fff;
}
.pay-mark-sel.paid { background: var(--accent); }
.pay-mark-sel.paid:active { background: var(--accent2); }
.pay-mark-sel.pending { background: var(--card2); color: var(--text); border: 1px solid var(--border); }

/* Per-driver "Mark Paid" button (summary report) */
.pay-mark-driver {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}
.pay-mark-driver:active { background: var(--accent2); }

/* Selection checkboxes inside the report table */
.report-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent2);
  cursor: pointer;
  vertical-align: middle;
}

.r-pay { font-size: 14px; margin-top: 6px; }

/* تلميح السعر */
.price-hint { font-size: 14px; margin-top: 8px; min-height: 18px; color: var(--muted); }
.price-hint.ok { color: var(--accent2); font-weight: 700; }
.price-hint.warn { color: #fbbf24; }

.btn-secondary { margin-top: 4px; }

/* التقرير */
.report-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.report-head { margin-bottom: 12px; font-size: 14px; line-height: 1.8; }
.report-head .r-driver b { color: var(--accent2); }
.report-head .r-period { color: var(--muted); }

.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th, .report-table td {
  border: 1px solid var(--border);
  padding: 8px 6px;
  text-align: center;
}
.report-table thead th { background: var(--card2); color: var(--muted); }
.report-table td.num { font-weight: 700; }
.report-table tfoot td {
  background: var(--card2);
  font-weight: 700;
  font-size: 15px;
}
.report-table tfoot td.total { color: var(--accent2); }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -3px;
  margin-left: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Confirmation popup ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 22px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: pop .22s ease;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-check {
  width: 72px; height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 44px;
  line-height: 72px;
  font-weight: 700;
}
.modal-title { margin: 0 0 16px; font-size: 22px; color: var(--accent2); }
.modal.error .modal-check { background: var(--danger); }
.modal.error .modal-title { color: var(--danger); }
.modal-details {
  text-align: start;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.md-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.md-row:last-child { border-bottom: none; }
.md-row span { color: var(--muted); }
.md-row b { color: var(--text); text-align: end; }

/* ===== الطباعة / حفظ PDF ===== */
@media print {
  body { background: #fff; color: #000; }
  .no-print, .topbar, .btn-link, .btn-secondary, .btn-primary { display: none !important; }
  .wrap { max-width: 100%; padding: 0; }
  .report-card { border: none; padding: 0; }
  .report-head .r-driver b { color: #000; }
  .report-head .r-period { color: #333; }
  .report-table th, .report-table td { border: 1px solid #999; color: #000; }
  .report-table thead th { background: #eee; color: #000; }
  .report-table tfoot td { background: #eee; }
  .report-table tfoot td.total { color: #000; }
}
