:root {
  --teal-900: #0b4a44;
  --teal-700: #0f766e;
  --teal-600: #14958a;
  --teal-100: #e6f5f3;
  --amber: #b45309;
  --amber-bg: #fef3e0;
  --red: #b91c1c;
  --red-bg: #fde8e8;
  --green: #15803d;
  --green-bg: #e7f7ec;
  --gray-50: #f7f8f8;
  --gray-100: #eef0f0;
  --gray-300: #d4d8d8;
  --gray-500: #737f7e;
  --gray-700: #3c4544;
  --gray-900: #1c2322;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  direction: rtl;
  font-family: 'Segoe UI', Tahoma, Roboto, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#app {
  padding: 14px 14px calc(var(--nav-h) + 24px) 14px;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 16px;
}

/* ===== شريط علوي ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--teal-700);
  color: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.top-bar h1 {
  font-size: 18px;
  margin: 0;
  flex: 1;
  font-weight: 700;
}
.top-bar .back-btn {
  font-size: 20px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  border: none;
  color: var(--white);
}
.top-bar .icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--white);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
}

/* ===== شريط تنقل سفلي ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-100);
  display: flex;
  z-index: 30;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 600;
}
.bottom-nav a .nav-icon { font-size: 21px; }
.bottom-nav a.active { color: var(--teal-700); }

/* ===== بطاقات ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 10px 0;
  color: var(--teal-900);
}
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

/* ===== عناصر قائمة ===== */
.list-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: block;
}
.list-item-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.list-item-sub {
  color: var(--gray-500);
  font-size: 13.5px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.list-item-meta {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== شارات ===== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-teal { background: var(--teal-100); color: var(--teal-700); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* ===== أزرار ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  min-height: 50px;
}
.btn-primary { background: var(--teal-700); color: var(--white); }
.btn-primary:active { background: var(--teal-900); }
.btn-secondary { background: var(--teal-100); color: var(--teal-700); }
.btn-outline { background: var(--white); color: var(--teal-700); border: 1.5px solid var(--teal-600); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-whatsapp { background: #25d366; color: var(--white); }
.btn-sm { padding: 10px 14px; font-size: 14px; min-height: 40px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 16px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--teal-700);
  color: var(--white);
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--teal-700) 40%, transparent);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== نماذج ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--gray-700);
}
.field input[type="text"],
.field input[type="number"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-900);
}
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 12.5px; color: var(--gray-500); margin-top: 4px; }
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-chip {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-radius: 12px;
  border: 1.5px solid var(--gray-300);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  color: var(--gray-700);
  min-width: 90px;
}
.radio-chip input { display: none; }
.radio-chip.checked { border-color: var(--teal-700); background: var(--teal-100); color: var(--teal-700); }

/* ===== أخرى ===== */
.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-500);
  margin: 18px 0 10px 0;
}
.empty-state {
  text-align: center;
  color: var(--gray-500);
  padding: 40px 20px;
  font-size: 15px;
}
.search-box {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--gray-300);
  margin-bottom: 14px;
  background: var(--white);
}
.divider { height: 1px; background: var(--gray-100); margin: 10px 0; }
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qty-stepper button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  font-size: 18px;
  font-weight: 700;
}
.qty-stepper input {
  width: 50px;
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--gray-300);
}
.product-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.total-bar {
  position: sticky;
  bottom: calc(var(--nav-h));
  background: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

/* ===== تنبيهات ===== */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 8px;
}
.alert-item.warn { background: var(--amber-bg); }
.alert-item.danger { background: var(--red-bg); }
.alert-item.due { background: var(--green-bg); align-items: center; }
.alert-item.due .txt { color: inherit; }
.alert-item.due .btn { flex-shrink: 0; }
.alert-item .icon { font-size: 20px; }
.alert-item .txt { flex: 1; font-size: 14px; }
.alert-item .txt b { display: block; margin-bottom: 2px; }

/* ===== توست ===== */
#toast-host {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px);
  right: 0;
  left: 0;
  display: flex;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }

/* ===== شبكة "المزيد" ===== */
.grid-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-menu a {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 14px;
  text-align: center;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.grid-menu .nav-icon { font-size: 28px; }

.kv { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14.5px; }
.kv .k { color: var(--gray-500); }
.kv .v { font-weight: 700; }

@media (min-width: 600px) {
  #app { padding-bottom: calc(var(--nav-h) + 24px); }
}

/* ===== الفاتورة ===== */
.invoice-sheet {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  color: #111;
}
.invoice-header { text-align: center; }
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 12.5px;
}
.invoice-table th, .invoice-table td {
  border: 1px solid #ccc;
  padding: 6px 4px;
  text-align: center;
}
.invoice-table thead { background: var(--gray-100); }
.invoice-total-row td { font-weight: 700; background: #fafafa; }

@media print {
  .no-print, .bottom-nav, .fab { display: none !important; }
  body { background: #fff; }
  #app { max-width: 100%; padding: 0; margin: 0; }
  .invoice-sheet { box-shadow: none; border-radius: 0; padding: 0; }
}
