* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #142033;
  --muted: #718096;
  --line: #e6ebf2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #f59e0b;
  --warning-soft: #fff8e7;
  --danger: #dc2626;
  --shadow: 0 18px 55px rgba(15, 23, 42, .10);
  --card-shadow: 0 8px 28px rgba(15, 23, 42, .07);
  --radius: 22px;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, .08), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(14, 165, 233, .07), transparent 24%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

/* =========================
   LOGIN
========================= */

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 28px;
}

.login-background {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, .18), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(14, 165, 233, .15), transparent 30%);
}

.login-background::before,
.login-background::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
}

.login-background::before {
  width: 420px;
  height: 420px;
  top: -180px;
  right: -130px;
  background: rgba(37, 99, 235, .10);
}

.login-background::after {
  width: 360px;
  height: 360px;
  bottom: -180px;
  left: -120px;
  background: rgba(14, 165, 233, .09);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 28px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 34px;
}

.brand-icon,
.mini-logo {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(145deg, #2563eb, #0f172a);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .24);
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  font-size: 27px;
  background: linear-gradient(145deg, #f59e0b, #dc2626);
  box-shadow: 0 10px 22px rgba(245, 158, 11, .25);
}

.mini-logo {
  width: 39px;
  height: 39px;
  border-radius: 12px;
  font-size: 20px;
  background: linear-gradient(145deg, #f59e0b, #dc2626);
  box-shadow: 0 8px 18px rgba(245, 158, 11, .22);
}

.brand-name {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .2px;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.login-heading {
  margin-bottom: 26px;
}

.login-heading h1 {
  margin: 0 0 8px;
  font-size: 31px;
  line-height: 1.2;
  letter-spacing: -.8px;
}

.login-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.field {
  margin-bottom: 17px;
}

.field label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
}

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  top: 50%;
  right: 15px;
  z-index: 1;
  transform: translateY(-50%);
  font-size: 17px;
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  height: 54px;
  padding: 0 47px 0 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--text);
  background: var(--surface-soft);
  transition: .2s ease;
}

.input-wrap input::placeholder {
  color: #a0aec0;
}

.input-wrap input:focus {
  border-color: rgba(37, 99, 235, .55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .09);
}

.login-error {
  margin: 4px 0 14px;
  padding: 11px 13px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  color: #b91c1c;
  background: #fef2f2;
  font-size: 13px;
}

.login-btn {
  width: 100%;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px 0 20px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #0f4cdb);
  box-shadow: 0 12px 25px rgba(37, 99, 235, .24);
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 15px 30px rgba(37, 99, 235, .30);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: .65;
  cursor: wait;
  transform: none;
}

.login-arrow {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .16);
  font-size: 18px;
}

.login-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 25px;
  color: #9aa5b5;
  font-size: 11px;
}

/* =========================
   TOP BAR
========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(230, 235, 242, .9);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 74px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.topbar-brand,
.driver-profile,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar-brand {
  gap: 10px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text strong {
  font-size: 13px;
}

.brand-text span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.driver-profile {
  justify-content: center;
  gap: 10px;
}

.driver-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #eef4ff;
  font-size: 19px;
}

.driver-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.driver-info strong {
  font-size: 13px;
}

.driver-info span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #526074;
  background: #fff;
  font-size: 20px;
  transition: .18s ease;
}

.icon-btn:hover {
  color: var(--primary);
  border-color: #cbd8ef;
  background: #f7faff;
  transform: translateY(-1px);
}

.logout-icon:hover {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff7f7;
}

.icon-btn.spin {
  animation: spin .8s linear infinite;
}

/* =========================
   MAIN
========================= */

.main-content {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 45px;
}

.welcome-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--primary);
  background: #eaf1ff;
  font-size: 11px;
  font-weight: 800;
}

.welcome-section h1 {
  margin: 7px 0 4px;
  font-size: clamp(25px, 4vw, 35px);
  letter-spacing: -.9px;
}

.welcome-section p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.orders-counter {
  min-width: 92px;
  padding: 11px 15px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.orders-counter span {
  display: block;
  font-size: 23px;
  font-weight: 900;
}

.orders-counter small {
  color: var(--muted);
  font-size: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 80px;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.stat-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 15px;
  font-size: 21px;
  font-weight: 900;
}

.pending-icon {
  background: var(--warning-soft);
}

.done-icon {
  color: var(--success);
  background: var(--success-soft);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: 21px;
}

.tabs {
  display: flex;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(15, 23, 42, .04);
}

.tab {
  min-width: 105px;
  height: 37px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  transition: .18s ease;
}

.tab:hover {
  color: var(--text);
  background: #f4f7fb;
}

.tab.active {
  color: #fff;
  background: var(--text);
}

/* =========================
   ORDERS
========================= */

.orders-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.order-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--card-shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px rgba(15, 23, 42, .09);
}

.order-card.is-done {
  border-color: #d7efdf;
  background: linear-gradient(180deg, #fff, #fbfffc);
}

.order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.order-number {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.order-number span {
  color: var(--muted);
  font-size: 11px;
}

.order-number strong {
  font-size: 17px;
}

.delivery-status {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #a16207;
  background: var(--warning-soft);
  font-size: 10px;
  font-weight: 800;
}

.delivery-status.ok {
  color: #15803d;
  background: var(--success-soft);
}

/* =========================
   CUSTOMER
========================= */

.customer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.customer-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  background: #f1f5f9;
  font-size: 18px;
}

.customer-main {
  min-width: 0;
  flex: 1;
}

.customer-main h2 {
  overflow: hidden;
  margin: 0 0 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.phone-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.action-icon {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--success);
  background: var(--success-soft);
  text-decoration: none;
  font-size: 18px;
}

/* =========================
   ORDER DETAILS
========================= */

.order-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 10px 0;
}

.info-item {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 11px;
  background: #f8fafc;
}

.info-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}

.info-item strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item {
  grid-column: 1 / -1;
}

.note-item strong {
  white-space: normal;
  line-height: 1.4;
}

/* =========================
   TOTAL
========================= */

.order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 13px;
  background: #f5f8ff;
}

.order-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.order-total strong {
  color: var(--primary-dark);
  font-size: 15px;
}

/* =========================
   PAYMENT
========================= */

.payment-section {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.payment-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.payment-title > span {
  font-size: 11px;
  font-weight: 800;
}

.payment-current {
  color: var(--muted);
  font-size: 9px;
  text-align: left;
}

.payment-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.payment-btn {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #526074;
  background: #fff;
  transition: .18s ease;
}

.payment-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  background: #f8fafc;
}

.payment-btn.selected {
  color: var(--primary-dark);
  border-color: #93b4f7;
  background: #edf4ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .06);
}

.payment-btn:disabled {
  opacity: .58;
  cursor: not-allowed;
}

.payment-btn span {
  font-size: 16px;
}

.payment-btn strong {
  font-size: 10px;
}

/* =========================
   ACTIONS
========================= */

.order-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 8px;
  margin-top: 10px;
}

.location-btn,
.btn-deliver {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 13px;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  transition: .18s ease;
}

.location-btn {
  border: 1px solid #bfdbfe;
  color: var(--primary-dark);
  background: #eff6ff;
}

.location-btn:hover {
  background: #e0edff;
}

.btn-deliver {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 9px 20px rgba(22, 163, 74, .18);
}

.btn-deliver:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 23px rgba(22, 163, 74, .24);
}

.btn-deliver:disabled {
  cursor: not-allowed;
  opacity: .7;
  box-shadow: none;
}

/* =========================
   LOADING / EMPTY
========================= */

.loading,
.empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 45px 20px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fff;
}

.empty .big {
  display: block;
  margin-bottom: 10px;
  font-size: 31px;
}

/* =========================
   TOAST
========================= */

.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  padding: 13px 17px;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  color: #166534;
  background: #f0fdf4;
  box-shadow: 0 14px 35px rgba(15, 23, 42, .13);
  font-size: 12px;
  font-weight: 700;
}

.toast.err {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

/* =========================
   ANIMATION
========================= */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   TABLET
========================= */

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

  .topbar-inner {
    grid-template-columns: 1fr auto;
  }

  .driver-profile {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    padding-bottom: 9px;
  }

  .topbar {
    padding-top: 5px;
  }

  .main-content {
    padding-top: 22px;
  }
}

/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {
  .login-view {
    padding: 17px;
  }

  .login-card {
    padding: 25px 20px;
    border-radius: 23px;
  }

  .login-heading h1 {
    font-size: 27px;
  }

  .topbar-inner {
    width: min(100% - 22px, 1180px);
    min-height: 66px;
  }

  .brand-text {
    display: none;
  }

  .main-content {
    width: min(100% - 22px, 1120px);
    padding-top: 18px;
    padding-bottom: 30px;
  }

  .welcome-section {
    align-items: flex-start;
  }

  .welcome-section h1 {
    font-size: 27px;
  }

  .welcome-section p {
    max-width: 280px;
    line-height: 1.6;
  }

  .orders-counter {
    min-width: 76px;
    padding: 9px 10px;
  }

  .stats-grid {
    gap: 8px;
  }

  .stat-card {
    min-height: 72px;
    padding: 11px;
  }

  .stat-icon {
    width: 39px;
    height: 39px;
    border-radius: 12px;
    font-size: 18px;
  }

  .stat-card strong {
    font-size: 18px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    min-width: 0;
    padding: 0 7px;
    font-size: 11px;
  }

  .order-card {
    padding: 13px;
    border-radius: 18px;
  }

  .order-card-head {
    margin-bottom: 9px;
  }

  .customer-row {
    padding-bottom: 8px;
  }

  .order-details {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 0;
  }

  .info-item {
    padding: 7px 9px;
  }

  .note-item {
    grid-column: auto;
  }

  .payment-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .payment-current {
    text-align: right;
  }

  .payment-btn {
    min-height: 40px;
  }

  .order-actions {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 8px;
  }

  .location-btn,
  .btn-deliver {
    min-height: 42px;
    font-size: 10px;
  }
}

/* =========================
   SMALL MOBILE
========================= */

@media (max-width: 390px) {
  .login-card {
    padding: 22px 17px;
  }

  .brand-mark {
    margin-bottom: 27px;
  }

  .payment-btn strong,
  .location-btn strong,
  .btn-deliver strong {
    font-size: 10px;
  }

  .order-actions {
    gap: 6px;
  }

  .order-card {
    padding: 12px;
  }
}
/* إخفاء خانات الكمية الفارغة من الفاتورة */
.info-item:has([data-f="chicken_qtys"]),
.info-item:has([data-f="plate_qtys"]) {
  display: none !important;
}


/* =========================
   التعديلات المطلوبة
========================= */

/* عناوين أقسام المنتجات أوضح وأكبر */
.products-section-title strong {
  font-size: 18px !important;
  font-weight: 900 !important;
}

/* بيانات الأوزان والمقطعات 19px */
.product-value {
  font-size: 19px !important;
  font-weight: 900 !important;
  line-height: 1.8 !important;
  white-space: pre-line !important;
}

/* إخفاء أسماء الحقول والأيقونات القديمة داخل أقسام المنتجات */
.products-section .product-label,
.products-section .products-icon,
.products-section-title small {
  display: none !important;
}

/* تكبير بيانات الإمارة والمنطقة نفسها */
.customer-location-grid .info-item strong {
  font-size: 16px !important;
  font-weight: 900 !important;
  line-height: 1.5 !important;
  white-space: normal !important;
}

/* زر التسليم أخضر قبل التسليم */
.btn-deliver {
  background: #16a34a !important;
  color: #fff !important;
  font-size: 16px !important;
  font-weight: 900 !important;
  opacity: 1 !important;
}

/* بعد التسليم يصبح أحمر ويظل أحمر */
.order-card.is-done .btn-deliver,
.btn-deliver:disabled {
  background: #dc2626 !important;
  color: #fff !important;
  opacity: 1 !important;
  cursor: default !important;
  box-shadow: none !important;
}


/* تحسينات إضافية للموبايل — الحفاظ على ألوان وتصميم فروج الزين */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

@media (max-width: 600px) {
  .login-view {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(14px, env(safe-area-inset-top)) 12px
      max(14px, env(safe-area-inset-bottom));
  }

  .login-card {
    width: 100%;
    max-width: 430px;
    padding: 24px 18px;
  }

  .input-wrap input {
    min-height: 50px;
    font-size: 16px;
  }

  .topbar {
    padding-top: env(safe-area-inset-top);
  }

  .topbar-inner {
    width: calc(100% - 20px);
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .topbar-brand {
    min-width: 0;
  }

  .topbar-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .driver-profile {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .driver-info strong,
  .driver-info span {
    overflow-wrap: anywhere;
  }

  .main-content {
    width: calc(100% - 20px);
    padding-top: 16px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .welcome-section {
    gap: 10px;
  }

  .welcome-section > div:first-child {
    min-width: 0;
  }

  .welcome-section h1 {
    font-size: clamp(22px, 6vw, 27px);
    line-height: 1.3;
  }

  .welcome-section p {
    max-width: 100%;
    font-size: 13px;
    line-height: 1.7;
  }

  .orders-counter {
    min-width: 68px;
    padding: 8px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    min-width: 0;
    gap: 9px;
    padding: 10px;
  }

  .stat-card span {
    font-size: 11px;
    line-height: 1.5;
  }

  .stat-card strong {
    font-size: 18px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
  }

  .tab {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 40px;
    padding: 8px 4px;
    line-height: 1.4;
    white-space: normal;
  }

  .orders-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .order-card {
    width: 100%;
    min-width: 0;
    padding: 12px;
    border-radius: 16px;
  }

  .order-card-head {
    align-items: flex-start;
  }

  .order-number strong {
    overflow-wrap: anywhere;
  }

  .delivery-status {
    max-width: 52%;
    padding: 5px 8px;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
  }

  .customer-main h2 {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.5;
  }

  .phone-link {
    display: inline-block;
    padding: 4px 0;
    overflow-wrap: anywhere;
  }

  .customer-location-grid,
  .order-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .info-item {
    min-width: 0;
    padding: 8px;
  }

  .info-item strong {
    overflow-wrap: anywhere;
  }

  .note-item {
    grid-column: 1 / -1;
  }

  .products-section {
    min-width: 0;
  }

  .products-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-box {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .product-value {
    font-size: clamp(17px, 4.7vw, 19px) !important;
    line-height: 1.8 !important;
    overflow-wrap: anywhere;
  }

  .order-total {
    gap: 8px;
  }

  .order-total strong {
    font-size: 16px;
    overflow-wrap: anywhere;
    text-align: left;
  }

  .payment-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .payment-current {
    max-width: 100%;
    text-align: right;
    line-height: 1.5;
  }

  .payment-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .payment-btn {
    min-width: 0;
    min-height: 46px;
    padding: 8px 5px;
  }

  .payment-btn strong {
    font-size: 11px;
    line-height: 1.4;
  }

  .order-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .location-btn,
  .btn-deliver {
    min-width: 0;
    min-height: 48px;
    padding: 8px 5px;
    font-size: 13px !important;
    line-height: 1.4;
    text-align: center;
  }

  .location-btn strong,
  .btn-deliver strong {
    font-size: inherit;
  }

  .toast {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-width: none;
    line-height: 1.6;
  }
}

@media (max-width: 360px) {
  .main-content {
    width: calc(100% - 16px);
  }

  .welcome-section {
    align-items: flex-start;
  }

  .orders-counter {
    min-width: 60px;
  }

  .stat-card {
    gap: 7px;
    padding: 8px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 16px;
  }

  .customer-location-grid,
  .order-details {
    grid-template-columns: minmax(0, 1fr);
  }

  .note-item {
    grid-column: auto;
  }

  .order-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* =========================================================
   توافق مع عناصر app.js الحالية: الماستر ورسوم التوصيل
   ========================================================= */

/* شارة الفاتورة المدفوعة مقدمًا */
.paid-advance-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 18px;
  border: 2px solid #fecaca;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  box-shadow: 0 5px 14px rgba(185, 28, 28, .18);
  font-size: clamp(18px, 3vw, 28px);
  line-height: 1.25;
  font-weight: 900;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* رسوم التوصيل والإجمالي النهائي */
.delivery-fee-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid #facc15;
  border-radius: 12px;
  color: #854d0e;
  background: #fff8d9;
  font-weight: 800;
  line-height: 1.6;
}

.delivery-grand-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  color: #166534;
  background: #f0fdf4;
  font-weight: 900;
  line-height: 1.6;
}

.delivery-fee-row > *,
.delivery-grand-total-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* زر صورة البوابة/الفيلا */
.gate-photo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  color: #1d4ed8;
  background: #eff6ff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.gate-photo-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.gate-photo-btn:disabled {
  opacity: .6;
  cursor: wait;
  transform: none;
}

/* تحسينات توافق لصفحات الماستر التي ينشئها app.js */
.master-wrap,
.master-page,
.master-section-content,
.master-customer-balances,
.master-orders-layout,
.master-table-wrap,
.master-balance-table-wrap {
  min-width: 0;
  max-width: 100%;
}

.master-wrap {
  width: min(1440px, calc(100% - 32px));
  margin-inline: auto;
}

.master-nav {
  direction: rtl;
}

.master-nav-btn {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
}

.master-table-wrap,
.master-balance-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.master-table,
.master-balance-table {
  border-collapse: collapse;
}

.master-edit-form input,
.master-edit-form select,
.master-edit-form textarea,
.master-balance-search,
.master-filter {
  max-width: 100%;
  min-width: 0;
  font: inherit;
}

.master-edit-form input:focus,
.master-edit-form select:focus,
.master-edit-form textarea:focus,
.master-balance-search:focus,
.master-filter:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}

.master-modal {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.master-modal-card {
  margin-block: auto;
}

.master-old-transfer-card,
.master-stat,
.master-balance-stat {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .master-wrap {
    width: calc(100% - 20px);
  }

  .master-nav {
    top: 64px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 9px 10px;
  }

  .master-nav-btn {
    min-height: 43px;
    padding: 8px;
    border-radius: 11px;
    font-size: 12px;
  }

  .master-balance-stats,
  .master-page[data-view="reports"] .master-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .master-balance-toolbar,
  .master-actions,
  .master-actions-row {
    align-items: stretch;
  }

  .master-balance-search {
    width: 100%;
    min-width: 0;
  }

  .master-edit-grid,
  .master-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .master-modal {
    padding: 10px;
  }

  .master-modal-card {
    width: 100%;
    max-height: calc(100dvh - 20px);
    border-radius: 16px;
  }

  .delivery-fee-row,
  .delivery-grand-total-row {
    align-items: flex-start;
    flex-wrap: wrap;
    font-size: 13px;
  }

  .paid-advance-badge {
    padding: 9px 14px;
    font-size: 21px;
  }
}

@media (max-width: 420px) {
  .master-wrap {
    width: calc(100% - 14px);
  }

  .master-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding-inline: 7px;
  }

  .master-nav-btn {
    min-height: 40px;
    padding: 7px 5px;
    font-size: 11px;
  }

  .master-balance-stats,
  .master-page[data-view="reports"] .master-stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .master-customer-balances {
    padding: 10px;
  }

  .master-old-transfer-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gate-photo-btn {
    width: 100%;
  }
}
