/* =========================================================
   مانی باکس — استایل اصلی
   ساختار: ۱) توکن‌ها  ۲) پایه  ۳) چیدمان  ۴) کامپوننت‌ها
           ۵) صفحه‌ها  ۶) ریسپانسیو
   ========================================================= */

/* ---------- ۱) توکن‌های رنگ و اندازه ---------- */
:root {
  /* رنگ اصلی: سبزآبی عمیق (اعتماد + مالی) */
  --primary: #0f766e;
  --primary-hover: #0b5f58;
  --primary-soft: #e3f4f1;
  --primary-ink: #ffffff;

  /* سطوح */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f5f5;
  --border: #ececec;
  --border-strong: #d6d9da;

  /* متن */
  --text: #0f1f24;
  --text-2: #4a5b61;   /* کنتراست ≥ ۷:۱ روی سفید */
  --text-3: #627378;   /* کنتراست ≥ ۴.۵:۱ روی سفید */

  /* وضعیت‌ها */
  --paid: #15803d;      --paid-soft: #e6f4ea;
  --overdue: #c62828;   --overdue-soft: #fdecec;
  --soon: #b45309;      --soon-soft: #fdf1e3;
  --future: #5b6b73;    --future-soft: #eef2f4;

  --chart-1: #0f766e;
  --chart-2: #9fd6cf;

  /* جهت بدهی/طلب */
  --recv: #0f766e;      --recv-soft: #e3f4f1;   /* طلب: به من می‌دهد */
  --pay: #6d28d9;       --pay-soft: #f1ebfd;    /* بدهی: من می‌دهم */

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: none;
  --shadow-lg: 0 12px 40px rgba(15, 31, 36, .14);
  --tap: 44px;               /* حداقل اندازهٔ لمسی */
  --sidebar-w: 248px;
  --bottomnav-h: 68px;
  --font: 'Vazirmatn', 'IRANSans', Tahoma, sans-serif;
}

[data-theme="dark"] {
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-soft: #11332f;
  --primary-ink: #04201c;

  --bg: #0d1112;
  --surface: #131819;
  --surface-2: #1a2022;
  --border: #232a2c;
  --border-strong: #323b3e;

  --text: #e7eff1;
  --text-2: #b2c2c7;
  --text-3: #8fa3a9;

  --paid: #4ade80;      --paid-soft: #12301f;
  --overdue: #f87171;   --overdue-soft: #3a1a1a;
  --soon: #fbbf24;      --soon-soft: #3a2a10;
  --future: #9aabb2;    --future-soft: #1d2b31;

  --chart-1: #2dd4bf;
  --chart-2: #1f5b54;
  --recv: #2dd4bf;      --recv-soft: #11332f;
  --pay: #c4b5fd;       --pay-soft: #2a2140;
  --shadow: none;
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}

/* ---------- ۲) پایه ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.4; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- ۳) چیدمان ---------- */
.layout { min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: none; flex-direction: column;
  padding: 20px 14px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center;
}
.brand-mark svg { width: 22px; height: 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap); padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }

.main { min-width: 0; padding-bottom: calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  min-height: 60px;
}
.topbar h1 { font-size: 19px; font-weight: 700; flex: 1; }
.topbar .back { margin-inline-start: -6px; }
.view { padding: 4px 16px 24px; max-width: 1200px; margin: 0 auto; }
.view:focus { outline: none; }

/* نوار پایین موبایل */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 25;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; font-size: 11.5px; color: var(--text-3); font-weight: 500;
}
.bottomnav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.bottomnav a svg { width: 23px; height: 23px; }
.fab {
  justify-self: center;
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--primary); color: var(--primary-ink);
  border: 0; display: grid; place-items: center;
  border-radius: 50%; width: 52px; height: 52px;
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.2; }

/* ---------- ۴) کامپوننت‌ها ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-head h2 { font-size: 15px; font-weight: 600; }
.section-head .count {
  font-size: 13px; font-weight: 500; padding: 0; color: var(--text-3); margin-inline-start: 6px;
}

/* دکمه‌ها */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 14.5px; white-space: nowrap;
  background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--overdue); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn {
  width: var(--tap); height: var(--tap); padding: 0;
  display: inline-grid; place-items: center;
  border-radius: 12px; border: 0; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* فرم */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12.5px; color: var(--overdue); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { padding: 12px 14px; min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--overdue); }
.input-group { position: relative; }
.input-group .suffix { position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-3); pointer-events: none; }
.input-group .input { padding-inline-end: 56px; }
.date-input { display: flex; align-items: center; justify-content: space-between; text-align: start; cursor: pointer; }
.date-input svg { color: var(--text-3); }
.form-grid { display: grid; gap: 16px; }

/* سوییچ */
.switch { position: relative; display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: inset-inline-start .2s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { outline: 3px solid var(--primary); outline-offset: 2px; }

/* چیپ‌های انتخاب */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13.5px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip:has(input:checked), .chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.chip:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }

/* برچسب وضعیت */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0; border-radius: 0;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: none !important;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-paid    { color: var(--paid);    background: var(--paid-soft); }
.st-overdue { color: var(--overdue); background: var(--overdue-soft); }
.st-soon    { color: var(--soon);    background: var(--soon-soft); }
.st-future  { color: var(--future);  background: var(--future-soft); }
.st-active  { color: var(--primary); background: var(--primary-soft); }

/* نوار پیشرفت */
.progress { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.progress.done > span { background: var(--paid); }

/* اسکلتون بارگذاری */
.skel { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } * { transition: none !important; } }

/* حالت خالی و خطا */
.empty { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .empty-ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty .empty-ic svg { width: 30px; height: 30px; }
.empty h3 { font-size: 16px; }
.empty p { color: var(--text-3); font-size: 14px; max-width: 320px; }
.empty.error .empty-ic { background: var(--overdue-soft); color: var(--overdue); }

/* toast */
.toasts { position: fixed; z-index: 100; inset-inline: 16px; bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 8px 10px 8px 16px; max-width: 460px; width: 100%;
  background: var(--text); color: var(--bg);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: 14px; animation: toast-in .22s ease-out;
}
.toast .t-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.toast.success .t-ic { background: var(--paid); color: #fff; }
.toast.error .t-ic { background: var(--overdue); color: #fff; }
.toast.info .t-ic { background: var(--primary); color: var(--primary-ink); }
.toast .t-ic svg { width: 16px; height: 16px; stroke-width: 2.4; }
.toast .t-msg { flex: 1; }
.toast .t-action { background: transparent; border: 0; color: var(--primary-hover); font-weight: 700; min-height: 36px; padding: 0 10px; }
[data-theme="dark"] .toast .t-action { color: var(--primary-ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* مودال / شیت پایین */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(5, 15, 18, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 92vh; overflow: auto;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: sheet-up .22s ease-out;
}
.modal::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 4px auto 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.modal-head h2 { font-size: 17px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .5; } }

/* منوی کوچک */
.menu { position: relative; }
.menu-list {
  position: absolute; z-index: 30; inset-inline-end: 0; top: calc(100% + 4px);
  min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.menu-list button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 0 12px; border: 0; background: transparent; border-radius: 10px; text-align: start; font-size: 14px; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--surface-2); }
.menu-list .danger { color: var(--overdue); }

/* تقویم شمسی */
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dp-title { font-weight: 700; font-size: 16px; display: flex; gap: 6px; }
.dp-title select { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); min-height: 40px; padding: 0 8px; font-weight: 700; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.dp-wd { font-size: 12px; color: var(--text-3); font-weight: 700; padding: 6px 0; }
.dp-day { min-height: var(--tap); border-radius: 12px; border: 0; background: transparent; font-size: 15px; }
.dp-day:hover { background: var(--surface-2); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); font-weight: 700; }
.dp-day.sel { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.dp-day.fri { color: var(--overdue); }
.dp-day.sel.fri { color: var(--primary-ink); }

/* ---------- ۵) صفحه‌ها ---------- */

/* ورود */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 28px 22px; }
.auth-card .brand { justify-content: center; padding: 0 0 6px; font-size: 22px; }
.auth-card .brand-mark { width: 48px; height: 48px; border-radius: 15px; }
.auth-sub { text-align: center; color: var(--text-3); margin-bottom: 22px; font-size: 14px; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; inset-inline-end: 2px; top: 2px; }
.pw-wrap .input { padding-inline-end: 50px; }
.form-error { background: var(--overdue-soft); color: var(--overdue); padding: 10px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; }

/* کارت‌های خلاصه */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .s-label { font-size: 12.5px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .s-label svg { display: none; }
.stat .s-value { font-size: 18px; font-weight: 700; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s-value small { font-size: 11.5px; font-weight: 500; color: var(--text-3); margin-inline-start: 3px; }
.stat .s-sub { font-size: 12px; color: var(--text-3); }
.stat.hero { grid-column: 1 / -1; padding: 20px 18px; color: var(--text); }
.stat.hero .s-value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.stat.hero .progress { height: 4px; border: 0; margin-top: 12px; background: var(--surface-2); }
.stat.danger .s-value { color: var(--overdue); }
.stat.ok .s-value { color: var(--paid); }
.stat.next-due { grid-column: 1 / -1; display: flex; flex-direction: row; align-items: center; gap: 12px; }
.next-due .nd-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; flex: none; }
.next-due .nd-body { flex: 1; min-width: 0; }
.next-due .nd-title { font-weight: 700; }

/* لیست قسط (کارت موبایل) */
.inst-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.inst-list[aria-busy] { background: none; border: 0; gap: 8px; }
.inst {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 14px 16px;
  border: 0 !important; border-radius: 0 !important; background: transparent !important;
}
.inst + .inst { border-top: 1px solid var(--border) !important; }
.inst-date { width: 40px; text-align: center; line-height: 1.15; }
.inst-date b { display: block; font-size: 18px; font-weight: 600; }
.inst-date span { font-size: 11px; color: var(--text-3); }
button.inst-edit-hit {
  border: 0; background: transparent; color: inherit; font: inherit; padding: 0; cursor: pointer;
  border-radius: 8px; text-align: inherit;
}
button.inst-date.inst-edit-hit { min-height: 44px; }
button.inst-amount.inst-edit-hit {
  display: block; font-weight: 700; color: var(--text); margin-bottom: 6px; text-decoration: underline;
  text-decoration-color: var(--border-strong); text-underline-offset: 3px;
}
.inst-foot .btn-sm { flex: 0 0 auto; }
.inst.s-paid .inst-title, .inst.s-paid .inst-amount { color: var(--text-3); }
.inst-main { min-width: 0; }
.inst-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inst-meta { font-size: 12.5px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.inst-amount { font-weight: 600; font-size: 15px; white-space: nowrap; }
.inst-side { display: flex; align-items: center; gap: 12px; }
.inst-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: -6px; font-size: 12.5px; color: var(--text-3); }
.inst-foot .note { flex: 1; min-width: 120px; }
.link-btn { border: 0; background: transparent; color: var(--primary); font-weight: 600; padding: 0 6px; min-height: 36px; border-radius: 8px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.link-btn:hover { background: var(--primary-soft); }
.link-btn svg { width: 15px; height: 15px; }

/* دکمهٔ تیک پرداخت */
.pay-toggle {
  width: var(--tap); height: var(--tap); padding: 0; flex: none;
  display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%;
  font-size: 0; color: transparent;   /* متن فقط برای صفحه‌خوان (aria-label) */
}
.pay-toggle .box { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: #fff; transition: background .15s, border-color .15s; }
.pay-toggle .box svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.pay-toggle:hover .box { border-color: var(--paid); }
.pay-toggle:hover .box svg { opacity: .35; color: var(--paid); }
.pay-toggle[aria-pressed="true"] .box { background: var(--paid); border-color: var(--paid); }
.pay-toggle[aria-pressed="true"] .box svg { opacity: 1; color: #fff; }
.pay-toggle.busy { opacity: .6; pointer-events: none; }

/* جدول دسکتاپ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-size: 12px; color: var(--text-3); font-weight: 500; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child { border-start-start-radius: var(--radius); }
.table th:last-child { border-start-end-radius: var(--radius); }
.table td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.amount { font-weight: 600; white-space: nowrap; }
.table .row-mark { width: 0; padding: 0 !important; }
.table .row-mark span { display: none; }
.table tr.s-paid td { color: var(--text-3); }
.table .note-cell { max-width: 200px; color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* انتخاب‌گر ماه */
.month-bar { display: flex; align-items: center; gap: 6px; padding: 4px; background: none !important; border: 0 !important; }
.month-bar .m-title { flex: 1; text-align: center; font-weight: 700; font-size: 17px; }
.month-bar .m-title small { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; }
.month-bar .m-title button { border: 0; background: transparent; font-weight: 700; font-size: 17px; min-height: var(--tap); padding: 0 12px; border-radius: 10px; }
.month-bar .m-title button:hover { background: var(--surface-2); }
.month-sum, .debt-sum { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.month-sum .ms, .debt-sum .ms { padding: 12px; text-align: center; border: 0 !important; border-radius: 0; background: none; }
.month-sum .ms + .ms, .debt-sum .ms + .ms { border-inline-start: 1px solid var(--border) !important; }
.month-sum .skel { border-radius: 0; }
.month-sum .ms span { font-size: 12px; color: var(--text-3); font-weight: 600; display: block; }
.month-sum .ms b { font-size: 15px; font-weight: 600; white-space: nowrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.toolbar .search { flex: 1 1 220px; position: relative; }
.toolbar .search svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.toolbar .search .input { padding-inline-start: 44px; }
.toolbar .select { width: auto; flex: 1 1 140px; }
.status-tabs { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; scrollbar-width: none; }
.status-tabs .chip { flex: none; }

/* وام‌ها */
.loan-grid { display: grid; gap: 12px; }
.loan-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; color: inherit; transition: border-color .15s, transform .15s; }
.loan-card:hover { border-color: var(--border-strong); }
.loan-top { display: flex; align-items: flex-start; gap: 12px; }
.loan-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; flex: none; }
.loan-top .lt-body { flex: 1; min-width: 0; }
.loan-top h3 { font-size: 15.5px; }
.loan-top .vendor { font-size: 13px; color: var(--text-3); }
.loan-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12.5px; }
.loan-figs span { color: var(--text-3); display: block; }
.loan-figs b { font-size: 14px; white-space: nowrap; }
.progress-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-3); }
.progress-row .progress { flex: 1; }
.page-actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }

/* ویزارد */
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.steps .step { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.steps .step i { font-style: normal; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); font-weight: 800; flex: none; }
.steps .step.on { color: var(--primary); }
.steps .step.on i { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.steps .bar { flex: 1; height: 2px; background: var(--border); align-self: center; }
.preview-sum { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.preview-sum .card { padding: 12px; }
.preview-sum span { font-size: 12px; color: var(--text-3); display: block; }
.preview-sum b { font-size: 15px; }
.sticky-actions { position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); padding: 16px 0 8px; display: flex; gap: 10px; }
.sticky-actions .btn { flex: 1; }

/* جزئیات وام */
.detail-hero { padding: 18px; display: grid; gap: 14px; }
.detail-hero .dh-figs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.detail-hero .dh-figs span { font-size: 12.5px; color: var(--text-3); display: block; }
.detail-hero .dh-figs b { font-size: 16px; }

/* تنظیمات */
.settings-group { padding: 4px 16px; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .sr-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; flex: none; }
.setting-row .sr-body { flex: 1; min-width: 0; }
.setting-row .sr-title { font-weight: 600; }
.setting-row .sr-desc { font-size: 12.5px; color: var(--text-3); }
.setting-block { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.setting-block:last-child { border-bottom: 0; }
.sms-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px 14px 4px 14px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap; }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.var-chips button { border: 1px dashed var(--border-strong); background: transparent; border-radius: 8px; min-height: 34px; padding: 0 10px; font-size: 12.5px; color: var(--text-2); direction: ltr; }
.var-chips button:hover { border-color: var(--primary); color: var(--primary); }

/* تاریخچه */
.log-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; }
.log-ch { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }

/* بدهی و طلب */
.debt-sum .ms span { font-size: 12px; color: var(--text-3); font-weight: 600; display: block; }
.debt-sum .ms b { font-size: 15px; font-weight: 600; white-space: nowrap; }
.debt-sum .ms svg { display: none; }
.people { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.person-chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 6px 12px 6px 14px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface); text-align: start;
}
.person-chip[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.person-chip b { display: block; font-size: 13.5px; line-height: 1.3; }
.person-chip small { font-size: 12px; font-weight: 700; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; flex: none; background: var(--surface-2); color: var(--text-2); }
.avatar.recv { background: var(--recv-soft); color: var(--recv); }
.avatar.pay { background: var(--pay-soft); color: var(--pay); }
.person-chip .avatar { width: 34px; height: 34px; font-size: 14px; }
.c-recv { color: var(--recv) !important; }
.c-pay { color: var(--pay) !important; }
.dir-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.dir-tag svg { width: 15px; height: 15px; stroke-width: 2.2; }
.inst.debt .inst-amount small { display: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; }
.seg label { position: relative; min-height: 48px; border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--text-2); cursor: pointer; text-align: center; line-height: 1.3; }
.seg label small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-3); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--surface); box-shadow: var(--shadow); }
.seg label.recv:has(input:checked) { color: var(--recv); }
.seg label.pay:has(input:checked) { color: var(--pay); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 1px; }
.sheet-actions { display: grid; gap: 10px; }
.sheet-actions a { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.sheet-actions a:hover { border-color: var(--primary); }
.sheet-actions a span.ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.sheet-actions a b { display: block; }
.sheet-actions a small { color: var(--text-3); font-size: 12.5px; }

/* ---------- ۶) ریسپانسیو ---------- */
.only-desktop { display: none; }
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat.hero { grid-column: span 2; }
  .stat.next-due { grid-column: span 1; flex-direction: column; align-items: flex-start; }
  .loan-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-lg); padding-bottom: 20px; }
  .modal::before { display: none; }
  .preview-sum { grid-template-columns: repeat(4, 1fr); }
  .toasts { inset-inline: auto; inset-inline-start: 50%; transform: translateX(50%); width: 460px; }
}
@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .bottomnav { display: none; }
  .main { margin-inline-start: var(--sidebar-w); padding-bottom: 32px; }
  .topbar { padding: 18px 32px 10px; }
  .topbar h1 { font-size: 22px; }
  .view { padding: 4px 32px 32px; }
  .only-mobile { display: none !important; }
  .only-desktop { display: block; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat.hero { grid-column: span 2; grid-row: span 2; justify-content: center; }
  .stat.next-due { grid-column: span 2; flex-direction: row; align-items: center; }
  .dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .loan-grid { grid-template-columns: repeat(3, 1fr); }

  .toasts { bottom: 24px; }
  .sticky-actions { bottom: 0; }
  .detail-hero .dh-figs { grid-template-columns: repeat(4, 1fr); }
  .settings-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  .settings-cols .section:first-child { margin-top: 22px; }
}
