/* خط Almarai محفوظ داخل التطبيق (يعمل بدون إنترنت ولا يعتمد على Google). رخصة SIL OFL 1.1 */
@font-face { font-family: 'Almarai'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/almarai-400-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Almarai'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/almarai-400-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Almarai'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/almarai-700-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Almarai'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/almarai-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Almarai'; font-style: normal; font-weight: 800; font-display: swap; src: url(fonts/almarai-800-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Almarai'; font-style: normal; font-weight: 800; font-display: swap; src: url(fonts/almarai-800-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* ألوان العلامة: أداة tools/new-client.js (والتطبيق العام عبر js/tenant.js) تستبدل هذه الخمسة بلون الزبون.
     --brand-fill = لون الزبون نفسه، أو أغمق منه قليلًا إن كان فاتحًا لا يُقرأ عليه نص أبيض (تباين 4.5:1) */
  --teal-900: #0b4a44;
  --teal-700: #0f766e;
  --teal-600: #14958a;
  --teal-100: #e6f5f3;
  --brand-fill: #0f766e;

  /* الأساس */
  --bg: #f4f4f6;
  --ink: #17171c;
  --muted: #75757f;      /* نص ثانوي على البطاقات البيضاء */
  --muted-bg: #6b6b75;   /* نص ثانوي فوق الخلفية الرمادية (تباين 4.5:1) */
  --nav-idle: #9a9aa3;

  /* ألوان هادئة ثابتة */
  --debt-bg: #ffe1d2;   --debt-ink: #7a2e0e;
  --visits-bg: #e6e0ff; --visits-ink: #3b2a8a; --visits-bar: #5b45d6;
  --visit-bg: #d8f3e5;  --visit-ink: #0e5a36;
  --pay-bg: #fff3c4;    --pay-ink: #6b4e00;
  --ret-bg: #dcecff;    --ret-ink: #0b3f7a;
  --wa: #25d366;        --wa-ink: #063b1d;   /* نص داكن: الأبيض على #25d366 تباينه 2:1 فقط */

  /* أسماء قديمة مستعملة داخل الشاشات (تبقى لتعمل كما هي) */
  --amber: var(--pay-ink);
  --amber-bg: var(--pay-bg);
  --red: #b42318;
  --red-bg: #ffe4df;
  --green: #0e7a43;
  --green-bg: var(--visit-bg);
  --gray-50: var(--bg);
  --gray-100: #ececf0;
  --gray-300: #dedee4;
  --gray-500: var(--muted);
  --gray-700: #3a3a42;
  --gray-900: var(--ink);
  --white: #ffffff;

  --radius-xl: 26px;   /* بطاقات كبيرة */
  --radius: 22px;      /* عناصر القوائم */
  --radius-sm: 14px;   /* الحقول والأزرار الصغيرة */
  --shadow: 0 1px 2px rgba(23, 23, 28, 0.03);
  --shadow-lg: 0 10px 30px rgba(23, 23, 28, 0.1);
  --ring: 0 0 0 4px color-mix(in srgb, var(--teal-700) 22%, transparent);
  --brand-gradient: var(--brand-fill);
  --nav-h: 70px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  direction: rtl;
  font-family: 'Almarai', 'Segoe UI', Tahoma, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

#app {
  padding: 14px 16px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)) 16px;
  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;
}

b, strong { font-weight: 700; }

/* ===== شريط علوي: عنوان بسيط + زر رجوع مربع أبيض ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  color: var(--ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  margin: -14px -16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 66px;
}
.top-bar h1 {
  font-size: 20px;
  margin: 0;
  flex: 1;
  font-weight: 800;
  line-height: 1.35;
  min-width: 0;
}
.top-bar .back-btn,
.top-bar .icon-btn,
.sq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  background: var(--white);
  border: none;
  border-radius: 14px;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--spring), background 0.15s;
  flex-shrink: 0;
}
.top-bar .back-btn { font-size: 20px; width: 44px; padding: 0; }
.top-bar .icon-btn { font-size: 14px; padding: 0 14px; }
.top-bar .back-btn:active,
.top-bar .icon-btn:active,
.sq-btn:active { transform: scale(0.94); transition-duration: 0.1s; }

/* ===== رأس الشاشة الرئيسية ===== */
.home-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 0 16px;
}
.home-head .who { flex: 1; min-width: 0; }
.home-date { color: var(--muted-bg); font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-head h1 { margin: 2px 0 0; font-size: 22px; font-weight: 800; line-height: 1.35; }
.sq-btn { width: 46px; height: 46px; border-radius: 16px; position: relative; }
.sq-btn svg { width: 22px; height: 22px; }

/* ===== شبكة بينتو ===== */
.bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.tile {
  border-radius: var(--radius-xl);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  background: var(--white);
  color: var(--ink);
  transition: transform 0.35s var(--spring);
}
a.tile:active, button.tile:active { transform: scale(0.94); transition-duration: 0.1s; }
.tile-ico {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}
.tile-ico svg { width: 21px; height: 21px; }
.tile-label { font-size: 13px; font-weight: 700; }
.tile-num { overflow-wrap: anywhere; font-size: 22px; font-weight: 800; line-height: 1.3; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12.5px; font-weight: 700; opacity: 0.9; }
.tile-sales {
  grid-row: span 2;
  background: var(--brand-fill);
  color: var(--white);
  justify-content: flex-end;
  min-height: 210px;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--teal-700) 28%, transparent);
}
.tile-sales .tile-ico { background: rgba(255, 255, 255, 0.18); margin-bottom: auto; }
.tile-sales .tile-num { font-size: 30px; margin: 4px 0 2px; }
.tile-debt { background: var(--debt-bg); color: var(--debt-ink); }
.tile-visits { background: var(--visits-bg); color: var(--visits-ink); }
.tile-plain { background: var(--white); }
.mini-bar {
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--visits-bar) 18%, transparent);
  overflow: hidden;
  margin-top: 6px;
}
.mini-bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--visits-bar);
  transform-origin: right center;
  transition: transform 0.8s var(--ease);
}

/* دائرة الحرف الأول */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 17px;
  line-height: 1;
}
.tone-0 { background: var(--debt-bg); color: var(--debt-ink); }
.tone-1 { background: var(--visits-bg); color: var(--visits-ink); }
.tone-2 { background: var(--visit-bg); color: var(--visit-ink); }
.tone-3 { background: var(--pay-bg); color: var(--pay-ink); }
.tone-4 { background: var(--ret-bg); color: var(--ret-ink); }

/* بطاقة صف (صيدلية / مندوب) فيها دائرة الحرف */
.row-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.row-card .row-body { flex: 1; min-width: 0; }
.row-card .row-title { font-weight: 800; font-size: 15.5px; display: flex; justify-content: space-between; gap: 8px; }
.row-card .row-title > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row-card .row-sub { color: var(--muted); font-size: 13px; font-weight: 700; }
.due-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.due-card .btn { flex-shrink: 0; }

/* ===== شريط تنقل سفلي ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  background: var(--white);
  border-radius: 26px 26px 0 0;
  display: flex;
  align-items: stretch;
  z-index: 30;
  box-shadow: 0 -6px 24px rgba(23, 23, 28, 0.07);
}
.bottom-nav a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.15s;
}
.bottom-nav .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  color: var(--nav-idle);
  transition: transform 0.35s var(--spring), color 0.15s;
}
.bottom-nav .nav-icon svg { width: 23px; height: 23px; }
.bottom-nav a.active { color: var(--brand-fill); font-weight: 800; }
.bottom-nav a.active .nav-icon { color: var(--teal-700); }
.bottom-nav a:active .nav-icon { transform: scale(0.85); transition-duration: 0.1s; }
/* أيقونات الخطوط (SVG) */
.ico {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ===== بطاقات ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-xl);
  border: none;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-title {
  font-weight: 800;
  font-size: 15.5px;
  margin: 0 0 10px 0;
  color: var(--ink);
}
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.card-row + .card-row { border-top: 1px solid var(--gray-100); }

/* ===== عناصر قائمة ===== */
.list-item {
  background: var(--white);
  border-radius: var(--radius);
  border: none;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: block;
  transition: transform 0.35s var(--spring), box-shadow 0.15s;
}
a.list-item:active, .row-card.list-item:active { transform: scale(0.94); transition-duration: 0.1s; }
.list-item.row-card { display: flex; }
.avatar svg { width: 20px; height: 20px; }
.list-item-title {
  font-weight: 800;
  font-size: 15.5px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.list-item-sub {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.list-item-meta {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== شارات ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.8;
}
.badge-amber { background: var(--pay-bg); color: var(--pay-ink); }
.badge-red { background: var(--debt-bg); color: var(--debt-ink); }
.badge-green { background: var(--visit-bg); color: var(--visit-ink); }
.badge-teal { background: var(--teal-100); color: var(--brand-fill); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* ===== أزرار ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  cursor: pointer;
  width: 100%;
  min-height: 52px;
  text-align: center;
  user-select: none;
  transition: transform 0.35s var(--spring), box-shadow 0.15s, background 0.15s, filter 0.15s;
}
.btn:active { transform: scale(0.94); transition-duration: 0.1s; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary {
  background: var(--brand-fill);
  color: var(--white);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--teal-700) 26%, transparent);
}
.btn-primary:active { filter: brightness(0.94); }
.btn-secondary { background: var(--teal-100); color: var(--brand-fill); }
.btn-outline {
  background: var(--white);
  color: var(--ink);
  border-color: transparent;
  box-shadow: var(--shadow);
}
.btn-outline:active { background: var(--gray-100); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-whatsapp { background: var(--wa); color: var(--wa-ink); }
.btn-sm { padding: 8px 14px; font-size: 14px; min-height: 40px; width: auto; border-radius: 14px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  left: 18px;
  width: 60px;
  height: 60px;
  border-radius: 20px;
  background: var(--teal-700);
  color: var(--white);
  font-size: 28px;
  border: none;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== نماذج ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 800;
  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,
.search-box,
.qty-stepper input {
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.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%;
  min-width: 0;
  padding: 12px 14px;
  min-height: 50px;
  border-radius: 14px;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.search-box:focus,
.qty-stepper input:focus {
  border-color: var(--teal-700);
  box-shadow: var(--ring);
}
.field input::placeholder, .field textarea::placeholder, .search-box::placeholder { color: #8e8e98; }
.field textarea { min-height: 88px; resize: vertical; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-chip {
  flex: 1;
  text-align: center;
  padding: 11px 8px;
  border-radius: 14px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  color: var(--gray-700);
  min-width: 90px;
  transition: transform 0.35s var(--spring), background 0.15s, border-color 0.15s;
}
.radio-chip:active { transform: scale(0.94); transition-duration: 0.1s; }
.radio-chip input { display: none; }
.radio-chip.checked {
  border-color: var(--teal-700);
  background: var(--teal-100);
  color: var(--brand-fill);
  box-shadow: inset 0 0 0 1px var(--teal-700);
}

/* ===== أخرى ===== */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  margin: 22px 2px 10px;
}
.empty-state {
  text-align: center;
  color: var(--muted-bg);
  padding: 40px 20px;
  font-size: 15px;
}
.search-box {
  width: 100%;
  padding: 12px 44px 12px 14px;
  min-height: 50px;
  border-radius: 16px;
  border-color: transparent;
  margin-bottom: 14px;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2375757f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat right 14px center;
  box-shadow: var(--shadow);
}
.divider { height: 1px; background: var(--gray-100); margin: 10px 0; }
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qty-stepper button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  background: var(--teal-100);
  color: var(--brand-fill);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.3s var(--spring), background 0.15s;
}
.qty-stepper button:active { transform: scale(0.88); transition-duration: 0.1s; }
.qty-stepper input {
  width: 52px;
  text-align: center;
  padding: 7px 4px;
  border-radius: 12px;
}
.product-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.total-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  background: var(--white);
  padding: 12px 16px;
  border-radius: 20px;
  border: none;
  box-shadow: var(--shadow-lg);
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
}

/* ===== تنبيهات ===== */
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--white);
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--spring);
}
a.alert-item:active { transform: scale(0.94); transition-duration: 0.1s; }
.alert-item .icon {
  font-size: 19px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.alert-item.warn .icon { background: var(--pay-bg); }
.alert-item.danger .icon { background: var(--debt-bg); }
.alert-item.due .icon { background: var(--visit-bg); }
.alert-item.due .txt { color: inherit; }
.alert-item.due .btn { flex-shrink: 0; }
.alert-item .txt { flex: 1; font-size: 13.5px; color: var(--muted); font-weight: 700; min-width: 0; }
.alert-item .txt b { display: block; margin-bottom: 2px; color: var(--ink); font-size: 15px; font-weight: 800; }

/* ===== توست: ينزلق من الأسفل ===== */
#toast-host {
  position: fixed;
  bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.25s var(--ease), transform 0.45s var(--spring);
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }

/* ===== الاشتراك: شاشة الانتهاء + شريط العدّ ===== */
.lock-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 48px 8px 24px;
}
.lock-screen .lock-icon {
  font-size: 44px;
  width: 92px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  background: var(--teal-100);
  margin-bottom: 4px;
}
.lock-screen h1 { font-size: 23px; font-weight: 800; color: var(--ink); margin: 0; }
.lock-screen p { margin: 0; line-height: 1.9; }
.lock-screen .lock-note { color: var(--muted-bg); font-size: 14px; margin-bottom: 8px; }
.btn-link {
  background: none;
  border: none;
  color: var(--muted-bg);
  text-decoration: underline;
  text-underline-offset: 4px;
  font-size: 14px;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
}
.license-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--pay-bg);
  color: var(--pay-ink);
  border: none;
  border-radius: 18px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}
.license-banner .txt { flex: 1; }
.license-banner .btn { flex-shrink: 0; }

/* ===== شاشة الدخول ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: -14px -16px 0;
  padding: 0 18px 24px;
}
.login-hero {
  background: var(--brand-fill);
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  margin: 0 -18px -36px;
  padding: calc(48px + env(safe-area-inset-top)) 20px 64px;
  border-radius: 0 0 32px 32px;
  font-size: 15px;
}
.login-hero h1 { color: var(--white); font-size: 26px; font-weight: 800; margin: 14px 0 2px; }
.login-logo {
  width: 84px;
  height: 84px;
  border-radius: 26px;
  background: var(--white);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  animation: pop 0.6s var(--spring) backwards;
}
.login-card { position: relative; padding: 22px 18px 14px; box-shadow: var(--shadow-lg); }

/* ===== شبكة "المزيد" ===== */
.grid-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-menu a {
  background: var(--white);
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow);
  padding: 18px 12px;
  text-align: center;
  font-weight: 800;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.35s var(--spring);
}
.grid-menu a:active { transform: scale(0.94); transition-duration: 0.1s; }
.grid-menu a:last-child:nth-child(odd) { grid-column: span 2; }
.grid-menu .nav-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.grid-menu a:nth-child(5n + 1) .nav-icon { background: var(--visits-bg); color: var(--visits-ink); }
.grid-menu a:nth-child(5n + 2) .nav-icon { background: var(--visit-bg); color: var(--visit-ink); }
.grid-menu a:nth-child(5n + 3) .nav-icon { background: var(--pay-bg); color: var(--pay-ink); }
.grid-menu a:nth-child(5n + 4) .nav-icon { background: var(--ret-bg); color: var(--ret-ink); }
.grid-menu a:nth-child(5n + 5) .nav-icon { background: var(--debt-bg); color: var(--debt-ink); }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 14.5px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 800; }

/* ===== هيكل التحميل (بدل "جارِ التحميل") ===== */
.skeleton-list { display: block; }
.skeleton-list i {
  display: block;
  height: 74px;
  border-radius: var(--radius);
  background: #e9e9ee;
  margin-bottom: 10px;
  animation: pulse 1.1s ease-in-out infinite alternate;
}
.skeleton-list i:nth-child(2) { animation-delay: 0.15s; }
.skeleton-list i:nth-child(3) { animation-delay: 0.3s; }
.skeleton-list i:nth-child(4) { animation-delay: 0.45s; }
.skeleton-list.sk-bento { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.skeleton-list.sk-bento i { margin: 0; height: 99px; border-radius: var(--radius-xl); }
.skeleton-list.sk-bento i:first-child { grid-row: span 2; height: auto; min-height: 210px; }

/* ===== الحركة (transform و opacity فقط) ===== */
@keyframes pop {
  0% { opacity: 0; transform: scale(0.85); }
  65% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.45; }
}
/* "backwards" لا "both": حتى لا تمنع الحركة تصغير الضغط بعد انتهائها */
.anim-pop { animation: pop 0.55s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 70ms); }
.anim-rise { animation: rise 0.4s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
#app.page-in { animation: page-in 0.22s var(--ease) backwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

@media (hover: hover) {
  .btn-primary:hover, .btn-whatsapp:hover { filter: brightness(1.05); }
  .btn-outline:hover, .btn-secondary:hover { filter: brightness(0.98); }
  a.list-item:hover, .grid-menu a:hover, a.alert-item:hover { box-shadow: 0 6px 18px rgba(23, 23, 28, 0.07); }
}

@media (min-width: 600px) {
  #app { padding-bottom: calc(var(--nav-h) + 34px); }
  .bottom-nav { max-width: 560px; margin: 0 auto; }
}

/* شاشات ضيقة جدًا (360px وأقل) */
@media (max-width: 370px) {
  #app { padding-left: 14px; padding-right: 14px; }
  .top-bar { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .bottom-nav { padding: 0 2px env(safe-area-inset-bottom); }
  .bottom-nav a { font-size: 10.5px; }
  .tile { padding: 14px; }
  .tile-sales .tile-num { font-size: 27px; }
}

/* ===== الفاتورة ===== */
.invoice-sheet {
  background: var(--white);
  border-radius: var(--radius-xl);
  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: #f0f0f2; }
.invoice-total-row td { font-weight: 700; background: #fafafa; }

@media print {
  .no-print, .bottom-nav, .fab, #toast-host { display: none !important; }
  body { background: #fff; }
  #app { max-width: 100%; padding: 0; margin: 0; animation: none !important; }
  .invoice-sheet { box-shadow: none; border-radius: 0; padding: 0; }
  .top-bar { display: none; }
  .card, .list-item { box-shadow: none; border: 1px solid #ddd; }
  * { animation: none !important; transition: none !important; }
}

/* مؤشر العمل بدون إنترنت وصندوق الإرسال (js/offline.js) */
.offline-pill {
  position: fixed;
  bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--white);
  background: var(--gray-700);
  box-shadow: 0 6px 18px rgba(23, 23, 28, 0.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.offline-pill.pill-offline { background: #475467; }
.offline-pill.pill-pending { background: var(--brand-fill); }
.offline-pill.pill-error { background: var(--red); }
@media print { .offline-pill { display: none !important; } }

/* شريط الإنجاز (أهداف المندوبين) */
.progress { height: 10px; background: var(--gray-100); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.progress > span { display: block; height: 100%; background: var(--teal-700); border-radius: 999px; transition: width .4s; }
