/* تأجير — تصميم رسمي هادئ: أسطح مسطحة، حدود رفيعة، لون أساسي واحد، بلا ظلال ولا تدرجات. */
:root {
  --desk: #E8EBEF;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --line: #E2E5EA;
  --line-2: #CBD1D9;
  --text: #151C26;
  --text-2: #475262;
  --text-3: #626C7A;
  --primary: #163A61;
  --primary-press: #0F2C4B;
  --primary-soft: #EDF1F6;
  --primary-line: #D3DCE8;
  --danger: #8E2B2B;
  /* أصفر المعدات: لمسة هوية فقط (الأيقونة، خط التبويب النشط). لا يُستخدم للنصوص ولا للمبالغ ولا للحالات */
  --accent: #D9A21B;
  --focus: 0 0 0 3px rgba(22, 58, 97, .16);
  --r: 8px;
  --r-sm: 6px;
  --appbar: 56px;
  --tabbar: 62px;
  --bar: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
svg.ic { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.row-amount, .stat-n, .kv-v, .code-box { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.danger-text { color: var(--danger); }

/* الإطار */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
@media (min-width: 520px) {
  body { background: var(--desk); }
  #app { border-inline: 1px solid var(--line); }
  .tabbar, .bar { border-inline: 1px solid var(--line); }
}

.flow > * + * { margin-top: 16px; }
.flow > .sec-head { margin-top: 24px; }
.flow > .sec-head:first-child { margin-top: 0; }
.flow > .sec-head + * { margin-top: 8px; }
.flow-sm > * + * { margin-top: 10px; }

/* الشريط العلوي */
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--appbar);
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.appbar-title {
  flex: 1; min-width: 0;
  padding: 0 8px;
  font-size: 17px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar-btn {
  height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-sm);
}
.appbar-btn:hover { background: var(--bg); }
.appbar-text { padding: 0 12px; color: var(--primary); font-weight: 600; font-size: 14px; }

.main { padding: 16px 16px 24px; }
.main.has-tabbar { padding-bottom: calc(var(--tabbar) + var(--safe-b) + 24px); }
.main.has-bar { padding-bottom: calc(var(--bar) + var(--safe-b) + 24px); }

/* البحث */
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; right: 14px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; height: 48px;
  padding: 0 44px 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r);
  outline: none; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--text-3); font-size: 14.5px; }
.search input:focus { border-color: var(--primary); box-shadow: var(--focus); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* الأرقام */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
}
.stats-2 { grid-template-columns: 1fr 1.4fr; }
.stat { padding: 12px 14px; min-width: 0; }
.stat + .stat { border-inline-start: 1px solid var(--line); }
.stat-n { font-size: 21px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.stat-l { margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
button.stat { text-align: right; cursor: pointer; }
button.stat:hover { background: var(--surface-2); }
.stats { overflow: hidden; }
/* شريط «اليوم» في الرئيسية */
.today {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  text-align: right;
}
.today:hover { background: var(--surface-2); }
.today-lbl { flex: none; font-size: 13px; font-weight: 600; color: var(--primary); padding-inline-end: 10px; border-inline-end: 1px solid var(--line); }
.today-val { flex: 1; min-width: 0; font-size: 14px; color: var(--text-2); }
.today-val b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* رؤوس الأقسام */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sec-title { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.tool {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2);
}
.tool:hover { border-color: var(--text-3); color: var(--text); }
.list-count { font-size: 12.5px; color: var(--text-3); }
.page-note { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.footnote { text-align: center; font-size: 12.5px; color: var(--text-3); }

/* القوائم */
.group {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden;
}
.group.pad { padding: 16px; }
.group.pad p { font-size: 14.5px; color: var(--text-2); }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px;
  text-align: right;
  background: var(--surface);
}
.row + .row, .row + .day-head, .row + .btn-row { border-top: 1px solid var(--line); }
.row[data-go], button.row { cursor: pointer; }
.row[data-go]:hover, button.row:hover, a.row:hover { background: var(--surface-2); }
/* الأسئلة الشائعة: سؤال مطوي يفتح بالنقر */
.faq-item + .faq-item { border-top: 1px solid var(--line); }
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px; cursor: pointer; list-style: none;
  font-size: 15px; font-weight: 600;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { background: var(--surface-2); }
.faq-chev { flex: none; color: var(--text-3); transform: rotate(-90deg); }
.faq-item[open] .faq-chev { transform: rotate(90deg); }
.faq-item p { padding: 0 14px 14px; font-size: 14.5px; line-height: 1.75; color: var(--text-2); }

/* خطوات تثبيت التطبيق */
.inst-step { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; line-height: 1.7; }
.inst-step .step { margin-top: 2px; }
.inst-step b { font-weight: 600; }
.inst-ic { display: inline-flex; vertical-align: -3px; color: var(--primary); }

/* فلتر الفترة في السجل، وزر «عرض المزيد» */
.filter-row { display: flex; align-items: center; gap: 10px; }
.filter-row .label { margin: 0; flex: none; }
.input-sm { height: 40px; width: auto; flex: 1; max-width: 200px; font-size: 14.5px; }
.filter-row .list-count { margin-inline-start: auto; }
.more-btn { height: 44px; font-weight: 500; color: var(--primary); }

/* شريط النسخة التجريبية في الرئيسية */
.demo-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-line); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2);
}
.demo-strip svg { color: var(--primary); }
.demo-strip span { flex: 1; }
.demo-strip a { flex: none; font-weight: 600; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

/* نافذة رسائل النظام في الرئيسية: رسالة واحدة ظاهرة مع التنقل بينها */
.msg-box {
  padding: 10px 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-line); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2);
}
.msg-main { display: flex; align-items: flex-start; gap: 8px; }
.msg-main > svg { flex: none; margin-top: 2px; color: var(--primary); }
.msg-text { flex: 1; line-height: 1.6; }
.msg-x { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin: -2px -4px 0 0; color: var(--text-3); background: none; border: 0; cursor: pointer; }
.msg-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-inline-start: 24px; }
.msg-btn { font: inherit; font-weight: 600; color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.msg-nav { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 2px; font: inherit; font-size: 12px; color: var(--text-3); background: none; border: 0; padding: 2px 0; cursor: pointer; }
.msg-warn { background: #FBF4E4; border-color: #EBD9AE; }
.msg-warn .msg-main > svg { color: var(--accent); }

/* نافذة بدء التجربة الفعلية */
.facts { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.7; }
.row-main { flex: 1; min-width: 0; }
.row-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.row-title { min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amount { flex: none; font-weight: 600; font-size: 15px; white-space: nowrap; }
.row-amount small { font-weight: 400; font-size: 12px; color: var(--text-3); }
.row-sub { min-width: 0; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt-sub { flex: none; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.row-meta { margin-top: 1px; font-size: 13px; color: var(--text-3); }
.row-meta.st-rented { color: var(--primary); }
.closed-mark { display: inline-flex; vertical-align: -3px; margin-inline-end: 6px; color: var(--text-3); }
.row-closed .row-title, .row-closed .row-amount { color: var(--text-2); font-weight: 500; }
.pending-mark { display: inline-flex; vertical-align: -3px; margin-inline-end: 6px; color: var(--primary); }
.note-link { width: 100%; text-align: right; align-items: center; cursor: pointer; }
.note-link > div { flex: 1; }
.note-link:hover { border-color: var(--primary); }
.seg.fit button { flex: 1 1 auto; padding: 0 10px; white-space: nowrap; font-size: 13.5px; }
.row-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-foot .row-meta { margin-top: 0; }
.row-actions { display: flex; gap: 8px; flex: none; }
.row-foot .row-actions { margin-block: 4px -2px; }
.row-foot .icon-btn { width: 36px; height: 36px; }
.row-ic {
  width: 36px; height: 36px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: var(--bg); color: var(--text-2);
}
.chev { flex: none; color: var(--text-3); }
.code-box {
  flex: none; min-width: 44px; height: 44px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--text-2);
}
.icon-btn:hover { border-color: var(--text-3); color: var(--text); }
.icon-btn.plain { border-color: transparent; }
.icon-btn.plain:hover { background: var(--bg); }
.group-foot {
  display: flex; justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-size: 14px; color: var(--text-2);
}
.group-foot b { font-weight: 600; color: var(--text); }
.day-head {
  padding: 7px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 500; color: var(--text-3);
}
.shop-block { padding: 16px; }
.shop-block h2 { font-size: 16px; font-weight: 600; }
.shop-block p { margin-top: 2px; font-size: 13.5px; color: var(--text-3); }

/* مفتاح / قيمة */
.kv-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 11px 14px; font-size: 14.5px;
}
.kv-row + .kv-row, .kv-row + .row, .row + .kv-row { border-top: 1px solid var(--line); }
.kv-k { color: var(--text-2); }
.kv-v { font-weight: 500; text-align: left; }
.kv-row.strong .kv-k, .kv-row.strong .kv-v { color: var(--text); font-weight: 600; }
.kv-row.total { background: var(--surface-2); border-top-color: var(--line-2); }
.kv-row.total .kv-k { color: var(--text); font-weight: 600; }
.kv-row.total .kv-v { font-size: 17px; font-weight: 700; }

.badge {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  white-space: nowrap;
}
.badge-open { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }

/* الأزرار */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r);
  font-size: 15px; font-weight: 600; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-press); }
.btn-primary:disabled { background: #9AA6B5; }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.btn-secondary:hover { border-color: var(--text-3); }
.btn-ghost { color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-row { display: flex; gap: 8px; padding: 12px 14px; }
.btn-row .btn { flex: 1; height: 44px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* النماذج */
.form-sec {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
}
.form-sec > * + *, .group.pad.flow > * + * { margin-top: 14px; }
.form-sec.invalid { border-color: var(--danger); }
.form-sec-head { display: flex; align-items: center; gap: 10px; }
.form-sec-head h2 { font-size: 15.5px; font-weight: 600; }
.step {
  width: 24px; height: 24px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.opt { margin-inline-start: 4px; font-size: 12.5px; font-weight: 400; color: var(--text-3); }
.input {
  width: 100%; height: 48px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r);
  outline: none; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--primary); box-shadow: var(--focus); }
.input::placeholder { color: #A3ABB6; }
.input:disabled { background: var(--bg); color: var(--text-3); }
.textarea { height: auto; min-height: 76px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
select.input {
  padding-left: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236F7988' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
}
.ltr-input { direction: ltr; text-align: right; }
.field.invalid .input { border-color: var(--danger); }
.field.invalid .label { color: var(--danger); }
.input-affix { position: relative; }
.input-affix .input { padding-left: 52px; }
.affix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--text-3); pointer-events: none; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--text-3); }
.hint b { color: var(--text); font-weight: 600; }
.field .hint { margin-top: 6px; }
.field .seg { margin-top: 8px; }
#nr-match:empty { display: none; }
.note {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-line); border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-2);
}
.note svg { margin-top: 3px; color: var(--primary); }
.note b { color: var(--text); font-weight: 600; }

.seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r);
  overflow: hidden;
}
.seg button { flex: 1; height: 42px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.seg button + button { border-inline-start: 1px solid var(--line-2); }
.seg button.on { background: var(--primary); color: #fff; font-weight: 600; }

.add-btn {
  width: 100%; height: 48px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface);
  border: 1px dashed var(--line-2); border-radius: var(--r);
  font-size: 14.5px; font-weight: 600; color: var(--primary);
}
.add-btn:hover { border-color: var(--primary); }

/* الصور */
.capture {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 16px;
  background: var(--bg);
  border: 1px dashed var(--line-2); border-radius: var(--r);
  color: var(--text-2);
}
.capture:hover { border-color: var(--primary); }
.capture b { font-size: 15px; color: var(--primary); }
.capture span { font-size: 13px; color: var(--text-3); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo {
  position: relative; aspect-ratio: 1;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden;
}
button.photo { padding: 0; cursor: zoom-in; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-x {
  position: absolute; top: 6px; left: 6px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(21, 28, 38, .75); color: #fff; border-radius: 50%;
}
.photo-add {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 500; color: var(--primary);
}
.photo-full { display: block; width: 100%; border-radius: var(--r-sm); }

/* الاختيار */
.check {
  width: 22px; height: 22px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1.5px solid var(--line-2); border-radius: 5px;
  color: transparent;
}
.row-check.on .check, .ret-row.on .ret-check .check { background: var(--primary); border-color: var(--primary); color: #fff; }
.ret-row + .ret-row { border-top: 1px solid var(--line); }
.ret-check { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: right; }
.ret-calc {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px 12px; padding-inline-start: 48px;
}
.ret-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  overflow: hidden;
}
.stepper button { width: 40px; height: 38px; font-size: 19px; color: var(--text-2); }
.stepper button:hover:not(:disabled) { background: var(--bg); }
.stepper button:disabled { color: var(--line-2); }
.stepper span {
  min-width: 76px; height: 38px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border-inline: 1px solid var(--line-2);
  font-size: 14px; color: var(--text-2);
}
.stepper b { font-size: 15px; font-weight: 600; color: var(--text); }
.stepper-sm { flex: none; }
.stepper-sm button { width: 36px; height: 34px; }
.stepper-sm span { min-width: 36px; height: 34px; }
.qty { font-weight: 600; color: var(--primary); }
.row-meta b { font-weight: 600; color: var(--text-2); }
.pick-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: right; }
.row-check { cursor: default; }
.ret-lbl { font-size: 13.5px; color: var(--text-2); }
.ret-lbl b { margin: 0 3px; font-size: 15px; font-weight: 600; color: var(--text); }
.ret-head { display: flex; align-items: center; padding-inline-end: 14px; }
.ret-head .ret-check { flex: 1; min-width: 0; }
/* عدّاد عمودي: + / العدد / − */
.vstepper {
  flex: none; width: 40px; margin-block: 10px;
  display: flex; flex-direction: column;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  overflow: hidden;
}
.vstepper button { height: 30px; font-size: 18px; color: var(--text-2); }
.vstepper button:hover:not(:disabled) { background: var(--bg); }
.vstepper button:disabled { color: var(--line-2); }
.vstepper span {
  height: 30px; display: flex; align-items: center; justify-content: center;
  border-block: 1px solid var(--line-2);
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
}
/* مربع اختيار صغير بعنوان (إرجاع الكل) */
.mini-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.mini-check .check { width: 18px; height: 18px; border-radius: 4px; }
.mini-check.on .check { background: var(--primary); border-color: var(--primary); color: #fff; }

/* الأشرطة السفلية */
.tabbar, .bar {
  position: fixed; bottom: 0; left: 50%; z-index: 30;
  width: 100%; max-width: 480px;
  transform: translateX(-50%);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar { display: flex; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b); }
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 500; color: var(--text-3);
}
.tab.on { position: relative; color: var(--primary); font-weight: 600; }
.tab.on::before {
  content: ''; position: absolute; top: -1px; left: 28%; right: 28%;
  height: 3px; background: var(--accent); border-radius: 0 0 3px 3px;
}
.tab-new { color: var(--text-2); }
.tab-new .tab-ic {
  width: 40px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: var(--r-sm);
}
.bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); }
.bar .btn { flex: 1; }
.bar-summary { flex: 1; min-width: 0; font-size: 13px; line-height: 1.35; color: var(--text-3); }
.bar-summary b { display: block; font-size: 15px; font-weight: 600; color: var(--text); }
.bar-summary + .btn { flex: none; min-width: 148px; }

/* النافذة السفلية */
.sheet-root { position: fixed; inset: 0; z-index: 50; }
.sheet-back { position: absolute; inset: 0; background: rgba(15, 21, 30, .45); }
.sheet {
  position: absolute; bottom: 0; left: 50%;
  width: 100%; max-width: 480px; max-height: 88vh; max-height: 88dvh;
  transform: translateX(-50%);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 12px 12px 0 0;
  padding-bottom: var(--safe-b);
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 8px 8px 16px; padding-inline-start: 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 { font-size: 16px; font-weight: 600; }
.sheet-body { flex: 1; padding: 16px; overflow: auto; }
.sheet-body > p { font-size: 14.5px; color: var(--text-2); }
.sheet-body.center { padding: 28px 16px 20px; text-align: center; }
.sheet-body.center h3 { font-size: 17px; font-weight: 600; }
.sheet-body.center p { margin-top: 4px; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.code-display {
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  direction: ltr; text-align: center;
  font: 600 19px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 1px;
}

/* الإشعار */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); z-index: 60;
  width: max-content; max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 10px 16px;
  background: #1B2330; color: #fff; border-radius: var(--r-sm);
  font-size: 14px;
}

/* الحالات */
.empty {
  padding: 28px 16px; text-align: center;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
}
.empty-t { font-weight: 600; color: var(--text-2); }
.empty-s { margin-top: 4px; font-size: 13.5px; color: var(--text-3); }
.done { padding: 16px 0 4px; text-align: center; }
.done-mark {
  width: 56px; height: 56px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--primary); border-radius: 50%;
  color: var(--primary);
}
.done h1 { font-size: 19px; font-weight: 600; }
.done-no { margin-top: 6px; color: var(--text-2); }
.done-no b { margin-inline-start: 6px; font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }

/* القفل */
.lock {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 64px 24px calc(28px + var(--safe-b));
  background: var(--surface);
}
.lock-top { text-align: center; }
.lock-mark {
  width: 52px; height: 52px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  color: var(--primary);
}
.lock-logo { display: block; width: 128px; height: 128px; object-fit: contain; margin: 0 auto 14px; }
.lock h1 { font-size: 18px; font-weight: 600; }
.lock p { margin-top: 6px; font-size: 14.5px; color: var(--text-2); }
.lock .err { color: var(--danger); }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin-top: 28px; }
.pin-dots span { width: 14px; height: 14px; border: 1.5px solid var(--line-2); border-radius: 50%; }
.pin-dots span.on { background: var(--primary); border-color: var(--primary); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 320px; margin: 0 auto; }
.keypad button {
  height: 60px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r);
  font-size: 22px; font-weight: 500;
}
.keypad button:active { background: var(--line); }
.lock-hint { margin-top: 16px; text-align: center; font-size: 12.5px; color: var(--text-3); }

/* الطباعة: رمز الاسترداد فقط */
@media print {
  #app, .sheet-back, .sheet-head, .sheet-foot, .note { display: none !important; }
  .sheet { position: static; transform: none; max-height: none; }
}

/* ========================================================
   تحديثات الجوال الحديثة (Modern Mobile Experience)
   ======================================================== */

/* شاشة الكاونتر النقية (المستوى الأول أمام الزبون) */
.counter-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px 20px calc(24px + var(--safe-b));
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.counter-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 40px;
}
.counter-logo-box {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 32px;
  font-weight: 700;
  box-shadow: 0 10px 25px -5px rgba(22, 58, 97, 0.28);
  margin-bottom: 16px;
}
/* الشعار المرفوع دائري وفيه كتابة: يُعرض كبيراً بلا إطار */
.counter-logo-box.has-img { width: 190px; height: 172px; border-radius: 0; background: transparent; box-shadow: none; }
.counter-logo-box img, .logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.counter-shop-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.counter-sub {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--text-3);
  font-weight: 500;
}
.counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-2);
}
.counter-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-bottom: 8px;
  width: 100%;
}
.counter-hero-btn {
  width: 100%;
  height: 60px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 12px 26px -6px rgba(22, 58, 97, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.counter-hero-btn:active {
  transform: scale(0.97);
  background: var(--primary-press);
}
.counter-hero-btn .hero-ic {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(217, 162, 27, 0.18);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.swipe-handle-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 10px;
  width: 100%;
  text-align: center;
}
.swipe-pill {
  width: 48px;
  height: 5px;
  border-radius: 3px;
  background: var(--line-2);
  transition: background 0.2s;
  animation: handlePulse 2.4s infinite ease-in-out;
}
@keyframes handlePulse {
  0%, 100% { transform: translateY(0); opacity: 0.65; }
  50% { transform: translateY(-4px); opacity: 1; }
}
.swipe-handle-bar:hover .swipe-pill {
  background: var(--primary);
}
.swipe-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* بطاقات السندات العصرية (Minimalist Native App Cards) */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rental-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px 12px;
  box-shadow: 0 2px 8px -2px rgba(21, 28, 38, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease;
  cursor: pointer;
}
.rental-card:active {
  transform: scale(0.985);
}
.rental-card.row-closed {
  opacity: 0.82;
  background: var(--surface-2);
}

/* الرأس: اسم العميل والمعدات يميناً، والمبلغ البارز يساراً */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-title-group {
  flex: 1;
  min-width: 0;
}
.renter-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-subtitle {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 3px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  line-height: 1.4;
}
.card-items {
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.sub-sep {
  color: var(--line-2);
  font-size: 11px;
}
.duration-text {
  color: var(--text-3);
  font-weight: 500;
  font-size: 12px;
}
.duration-text.duration-active {
  color: #8C6200;
  font-weight: 600;
}

/* الكتلة المالية البارزة في اليسار */
.card-amount-group {
  text-align: left;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.card-amount-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  line-height: 1.2;
}
.card-amount-num {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  margin-top: 2px;
}
.card-amount-num.danger {
  color: var(--danger);
}
.card-amount-num.success {
  color: #0F763E;
}

/* التذييل: رقم السند والدفعة يميناً، وأزرار الاتصال والواتساب السريعة يساراً */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(226, 229, 234, 0.7);
}
.card-foot-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
}
.rec-no {
  font-weight: 600;
  color: var(--text-3);
}
.rec-paid {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.card-act-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  transition: background-color 0.15s, transform 0.1s;
}
.card-act-link:active {
  transform: scale(0.92);
}
.card-act-link:hover {
  background: var(--primary-soft);
}
.card-act-link.wa {
  color: #0F763E;
}
.card-act-link.wa:hover {
  background: #E8F8EE;
}
.act-sep {
  width: 1px;
  height: 12px;
  background: var(--line-2);
  display: inline-block;
  margin: 0 2px;
}
.closed-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}

/* بطاقات المؤشرات العصرية (Metric Widgets) */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 8px -2px rgba(21, 28, 38, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.metric-card:active {
  transform: scale(0.97);
}
.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.metric-lbl {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}
.metric-ic-box {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.metric-ic-box.amber {
  background: #FFF8E6;
  color: #D9A21B;
}
.metric-ic-box.blue {
  background: var(--primary-soft);
  color: var(--primary);
}
.metric-val {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.metric-val small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
}
.metric-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-2);
}

/* شريط التنقل السفلي مع الزر البطل المرتفع */
.tab-hero-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.tab-hero-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -16px;
  border: 3px solid var(--surface);
  box-shadow: 0 8px 18px -3px rgba(22, 58, 97, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.tab-hero-btn:active {
  transform: scale(0.93);
}
.tab-hero-btn svg {
  color: var(--accent);
}
.tab-hero-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}

/* تحسينات فحص المعدة وحالة الصيانة عند الإرجاع */
.condition-picker {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.condition-pill {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.condition-pill.active-good {
  background: #E8F8EE;
  color: #0F763E;
  border-color: #55C788;
}
.condition-pill.active-maint {
  background: #FFF3CD;
  color: #856404;
  border-color: #FFEEBA;
}

/* تعديل سعر السطر اليومي عند التأجير */
.inline-rate-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.inline-rate-input {
  width: 84px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  text-align: center;
  font-weight: 600;
  background: var(--surface);
}

/* ==========================================================================
   تأثيرات الحركة التفاعلية والمايكرو-إنترآكشنز (Motion Design System)
   ========================================================================== */
@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* الحركة عند فتح الشاشة فقط: core.js يضع .enter على .main ثم يزيله،
   فلا تتكرر الحركة عند تحديث جزء من الشاشة (الكتابة في البحث، التحديد) */
.main.enter .cards-list .rental-card {
  animation: cardEnter 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.main.enter .cards-list .rental-card:nth-child(1) { animation-delay: 0.03s; }
.main.enter .cards-list .rental-card:nth-child(2) { animation-delay: 0.06s; }
.main.enter .cards-list .rental-card:nth-child(3) { animation-delay: 0.09s; }
.main.enter .cards-list .rental-card:nth-child(4) { animation-delay: 0.12s; }
.main.enter .cards-list .rental-card:nth-child(5) { animation-delay: 0.15s; }
.main.enter .cards-list .rental-card:nth-child(n+6) { animation-delay: 0.18s; }

.main.enter .metric-card {
  animation: cardEnter 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.main.enter .metric-card:nth-child(1) { animation-delay: 0.02s; }
.main.enter .metric-card:nth-child(2) { animation-delay: 0.05s; }

/* رد فعل لمسي للأزرار والتفاعلات الدقيقة */
.btn, .appbar-btn, .condition-pill, .card-action-btn, .counter-hero-btn {
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  will-change: transform;
}
.btn:active, .appbar-btn:active, .condition-pill:active {
  transform: scale(0.96);
}
.card-action-btn:active {
  transform: scale(0.90);
}

/* احترام تفضيل تقليل الحركة لتسهيل الوصول والأداء */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   أصناف مساعدة بدل التنسيقات المضمّنة في القوالب
   ========================================================================== */
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.inline-rate-box + .row-meta { margin-top: 2px; }

/* معدة مختارة في «تأجير جديد»: أسطر بعرض كامل، لا أعمدة متجاورة تتزاحم */
.nr-item { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; background: var(--surface); }
.nr-item + .nr-item { border-top: 1px solid var(--line); }
.nr-item-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nr-code {
  flex: none; padding: 2px 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.nr-name { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-item-head .icon-btn { flex: none; margin-inline-end: -8px; }
.nr-item-ctrl { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.nr-rate { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.nr-rate .inline-rate-input { width: 76px; }
.condition-picker { width: 100%; }
.ret-calc.ret-cond-row { padding-top: 0; }

/* مسودة مستعادة */
.draft-note { align-items: center; }
.draft-note > div { flex: 1; }

/* شعار المحل في الإعدادات */
.logo-field { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.logo-preview {
  width: 56px; height: 56px; border-radius: 16px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--accent); font-size: 24px; font-weight: 700;
}
.logo-preview.has-img { background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
