:root {
  /* Backgrounds */
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.05);
  --panel2: rgba(255, 255, 255, 0.03);
  --overlay: rgba(0, 0, 0, 0.72);

  /* Borders */
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.08);

  /* Text */
  --text: black;
  --muted: red;
  --main: rgba(42, 102, 255, 0.85);


  /* Status */
  --success: rgba(28, 196, 91, 0.18);
  --warning: rgba(255, 193, 7, 0.18);
  --danger: rgba(255, 77, 77, 0.18);
  --info: rgba(45, 212, 191, 0.18);

  /* Radius + Shadow */
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.28);

  /* Typography */
  --fs-xs: 14px;
  --fs-sm: 15px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 20px;

  --lh: 1.45;
}

/* =========================
   3) Topbar (Optional)
   ========================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.75);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: rgba(42, 102, 255, 0.18);
  border: 1px solid rgba(42, 102, 255, 0.35);
}

.brand-title {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: var(--fs-lg);
}

.brand-sub {
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-top: 2px;
}

.userbox {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* =========================
   4) Layout Grid
   ========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  text-align: center;
  gap: 16px;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   5) Cards
   ========================= */
.card {
  width: 100%;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow);
}

.card.wide {
  grid-column: 1 / -1;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 800;
}

.pill {
  font-size: var(--fs-xs);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
}

/* =========================
   6) Fields
   ========================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.inline {
  min-width: 180px;
}

label {
  font-size: var(--fs-xs);
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text);
  outline: none;
  font-size: var(--fs-md);
  background-color: var(--bg-darker);
  border: 1px solid #444;
}

input::placeholder,
textarea::placeholder {
  color: rgba(168, 179, 207, 0.75);
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(42, 102, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(42, 102, 255, 0.15);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

/* =========================
   7) Filters Row
   ========================= */
.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filters .field {
  flex: 1;
}

.mono {
  font-family: "Noto Sans Mono", "Cairo", monospace;
  color: white;
  font-size: var(--fs-md);
}

.full {
  width: 100%;
}

/* =========================
   9) Table
   ========================= */
.table-wrap {
  width: 100%;
  overflow: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: center;
  font-size: var(--fs-xs);
  color: white;
  background: rgba(11, 16, 32, 0.92);
  border-bottom: 1px solid var(--border);
  padding: 12px;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
  text-align: center;
  font-size: var(--fs-md);
}

td.qr-cell {
  text-align: center;
  white-space: nowrap;
}


.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table .mono {
  font-family: "Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: var(--fs-md);
}

/* shipped row highlight */
.row-shipped {
  background: rgba(28, 196, 91, 0.06);
}

/* =========================
   10) Badges
   ========================= */
.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  justify-content: center;
  align-items: center;
  color: var(--text);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.modal-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  justify-content: center;
  align-items: center;
  color: white;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.white {
  text-align: center;
  align-items: center;
  justify-content: center;
  color: white;
}

select.white option {
  color: black;
}

.badge.created {
  background: var(--info);
}

.badge.packed {
  background: var(--warning);
}

.badge.in_transit {
  background: rgba(42, 102, 255, 0.18);
}

.badge.shipped {
  background: var(--success);
}

/* Actions in row */
td.actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* =========================
   11) Empty state
   ========================= */
.empty {
  color: var(--muted);
  text-align: center;
  padding: 18px !important;
  font-size: var(--fs-sm);
}

/* =========================
   12) Pager
   ========================= */
.pager {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pager-info {
  color: var(--muted);
  font-size: var(--fs-sm);
  border: 1px dashed var(--border);
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.02);
}

/* =========================
   13) Output Box (Optional)
   ========================= */
.output {
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  min-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: var(--fs-sm);
}

/* =========================
   14) Page Overlay (Optional)
   ========================= */
.page-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 16, 32, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.page-overlay .reviewed-msg {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  max-width: 560px;
  width: calc(100% - 32px);
  text-align: center;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* =========================
   15) RTL Tweaks
   ========================= */
/* html[dir="rtl"] .table thead th,
html[dir="rtl"] .table tbody td {
    text-align: right;
}

html[dir="rtl"] .pager {
    flex-direction: row-reverse;
}

html[dir="rtl"] td.actions {
    justify-content: flex-start;
} */

/* ==========================================================
   16) Modal (DARK + Consistent with Dashboard Theme)
   - Requested: modal background black
   - Better typography + colors
   ========================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: none;
  align-items: center !important;
  justify-content: center !important;
  width: 100%;
  z-index: 9999;
  padding: 12px;
  overscroll-behavior: contain;
}

/* The modal container itself (black/dark) */
.modal {
  position: relative;
  background: rgba(10, 14, 28, 0.96);
  border: 1px solid var(--border);
  width: min(1200px, 95vw);
  border-radius: var(--r-lg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);

  max-height: calc(100vh - 40px);
  overflow: hidden;
  /* مهم */
  display: flex;
  flex-direction: column;
}

/* اقفل سكرول الصفحة الخلفية */
body.modal-open {
  overflow: hidden;
}

/* Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--text-light);
  background: rgba(0, 0, 0, 0.1);
}

.modal-header .btn:hover {
  color: var(--main-color);
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-light);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Close button */
.modal-close {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Body */
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Footer */
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
}

/* If you placed a .card inside modal, keep it consistent */
.modal .card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  box-shadow: none;
}

/* ==========================================================
   17) Dual Pane (Inside Modal) - Refined
   ========================================================== */

.dual-wrap {
  display: grid;
  grid-template-columns: 1fr 92px 1fr;
  gap: 14px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .dual-wrap {
    grid-template-columns: 1fr;
  }

  .mid-buttons {
    order: 3;
    flex-direction: row;
    justify-content: center;
  }
}

/* Pane */
.pane {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pane-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-light);
}

.pane-body {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: rgba(0, 0, 0, 0.18);
  overflow: auto;
  padding: 10px;
  flex: 1;
}

/* Suborder card */
.suborder-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 10px;
}

.suborder-top {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.suborder-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.suborder-meta .chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.03);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* Items list */
.suborder-items {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-md);
  padding: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.item-img {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  object-fit: cover;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  flex: 0 0 auto;
}

.item-thumb {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0, 0, 0, .04);
  display: inline-block;
}

.item-info {
  flex: 1;
  min-width: 180px;
}

.item-title {
  font-weight: 800;
  font-size: var(--fs-sm);
  margin: 0;
  color: var(--text-light);
}

.item-sub {
  color: var(--muted);
  font-size: var(--fs-md);
  margin-top: 2px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.item-sub .mono {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* Middle buttons */
.mid-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
}

.mid-buttons .btn {
  width: 92px;
  justify-content: center;
}

/* Top actions (in modal card) */
.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.top-actions .field {
  min-width: 220px;
}

.muted {
  color: var(--muted);
  font-size: var(--fs-xs);
}

.empty-box {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.02);
  font-size: var(--fs-sm);
}

.align-center {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.qr-preview-box {
  border: 1px solid #ddd;
  border-radius: 10px;
  width: 180px;
  height: 180px;
  padding: 6px;
  background: transparent;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden;
}

.qr-preview-box canvas,
.qr-preview-box img,
.qr-preview-box svg {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.qr-placeholder {
  font-size: 12px;
  color: #111;
  text-align: center;
  line-height: 1.3;
}

.row-error {
  background: #ffecec;
}

.row-error input {
  border: 1px solid #ff6b6b;
}