/* ===== فونت محلی ===== */
@font-face {
  font-family: 'Vazirmatn';
  src: url('./assets/fonts/Vazirmatn.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ===== پایه ===== */
html {
  /* رزرو همیشگی فضای اسکرول‌بار عمودی تا با ظاهر/حذف آن در نماهای
     کوتاه و بلند، عرض ویوپورت (و ناو ثابت پایین) جابه‌جا نشود. */
  scrollbar-gutter: stable;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
button,
input,
select,
textarea {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
}

body {
  min-height: 100vh;
  background-color: var(--canvas);
  color: var(--text-primary);
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px calc(100px + env(safe-area-inset-bottom));
}

/* ===== سربرگ ===== */
.app-header {
  position: relative;
  padding: 16px 4px 24px;
  padding-inline-end: 56px;
}

.app-header h1 {
  font-size: 26px;
  font-weight: 800;
}

.app-header p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== انتخاب تقویم شمسی/میلادی ===== */
.calendar-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.calendar-switch-label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.calendar-switch-options {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.cal-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
}

.cal-btn:hover {
  color: var(--text);
}

.cal-btn.active {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.cal-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== راهنمای فیلد تاریخ ===== */
.field-hint {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.8;
}

/* ===== کارت جمع ماهانه (D1: .total-amount زنده است، بقیه بازنشسته) ===== */
.total-amount {
  /* تایپوگرافی واکنش‌گرا: دسکتاپ پررنگ می‌ماند، موبایل باریک سرریز نمی‌کند. */
  font-size: clamp(26px, 9vw, 36px);
  font-weight: 800;
}

.total-amount small {
  font-size: 16px;
  font-weight: 500;
}

.total-count {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== بخش لیست ===== */
.list-section {
  margin-top: 28px;
}

.list-section h2 {
  margin-bottom: 14px;
  font-size: 17px;
  font-weight: 700;
}

/* ===== بخش تاریخچه تمدیدها ===== */
.history-section {
  margin-top: 28px;
}

.history-section h2 {
  margin-bottom: 12px;
  font-size: var(--text-section-title);
  font-weight: 800;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-name {
  overflow: hidden;
  min-width: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-period {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.history-amount {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  line-height: var(--leading-tight);
}

.history-transition,
.history-recorded {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-more {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* ===== حالت خالی ===== */
.empty-state {
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--text-muted);
  line-height: 1;
  text-align: center;
}

.empty-icon svg {
  display: block;
}

.empty-title {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.empty-text {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.8;
}

/* ===== دکمه شناور + ===== */
.fab {
  position: fixed;
  z-index: 5;
  inset-inline-end: 16px;
  bottom: calc(104px + env(safe-area-inset-bottom));

  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;

  padding: 0;
  border: none;
  border-radius: 50%;

  background: var(--accent);
  color: var(--bg);

  cursor: pointer;

  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fab svg {
  display: block;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

.fab[hidden] {
  display: none;
}

/* ===== نماها و ناوبری پایینی (فقط نمایشی؛ منطق و رندر دست نمی‌خورند) ===== */
.view[hidden] {
  display: none;
}

.view-title {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 800;
}

.more-group {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.more-group h3 {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.more-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.more-group .app-version {
  display: block;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 11px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 0 14px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.bottom-nav-inner {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.bottom-nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid rgba(183, 243, 74, 0.19);
  box-shadow:
    inset 0 1px 1px rgba(183, 243, 74, 0.20),
    0 0 8px rgba(183, 243, 74, 0.19),
    0 2px 14px rgba(183, 243, 74, 0.14),
    0 6px 20px rgba(183, 243, 74, 0.10),
    0 10px 28px rgba(183, 243, 74, 0.06);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  will-change: transform, width;
  transition:
    transform 380ms cubic-bezier(0.22, 1.35, 0.36, 1),
    width 380ms cubic-bezier(0.22, 1.35, 0.36, 1);
}

.bottom-nav-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 5px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 2;
  transition: color 200ms ease;
}

.bottom-nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.bottom-nav-btn.active:hover {
  background: transparent;
}

.bottom-nav-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  line-height: 1;
  color: inherit;
  transform: scale(1);
  transition:
    transform 260ms cubic-bezier(0.34, 1.35, 0.64, 1),
    color 200ms ease;
}

.bottom-nav-icon svg {
  display: block;
}

.bottom-nav-label {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: inherit;
  transition:
    color 200ms ease,
    font-weight 200ms ease;
}

.bottom-nav-btn.active {
  color: var(--text);
}

.bottom-nav-btn.active .bottom-nav-icon {
  color: var(--accent);
  transform: scale(1.08);
}

.bottom-nav-btn.active .bottom-nav-label {
  color: var(--text);
  font-weight: 800;
}

.bottom-nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 380px) {
/* superseded by GlassKit pilot — remove after visual approval, see glasskit-theme-override.css */
.bottom-nav {
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  }

  .bottom-nav-inner {
    padding: 4px;
  }

  .bottom-nav-btn {
    min-height: 48px;
    padding: 5px 1px 4px;
    border-radius: var(--radius-pill);
    gap: 2px;
  }

  .bottom-nav-icon {
    width: 24px;
    height: 24px;
  }

  .bottom-nav-icon svg {
    width: 20px;
    height: 20px;
  }

  .bottom-nav-label {
    font-size: 9.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bottom-nav-indicator {
    transition: none !important;
  }
  .bottom-nav-btn,
  .bottom-nav-icon,
  .bottom-nav-label {
    transition: none;
  }
  .bottom-nav-btn.active .bottom-nav-icon {
    transform: none;
  }
}

/* ===== توکن‌های طراحی (D0: لایم روی مشکی نزدیک) ===== */
:root {
  color-scheme: dark;

  /* پایه */
  --bg: #0B0D0C;
  --surface-1: #141816;
  --surface-2: #1B211E;
  --surface-raised: #232B26;

  --text: #F2F5F0;
  --text-secondary: #A9B4AC;
  --text-muted: #7E8A81;

  --border: #2A312D;
  --border-strong: #37413A;

  --accent: #B7F34A;
  --accent-strong: #C9FF63;
  --accent-soft: #CDF38A;
  --accent-dim: rgba(183, 243, 74, 0.12);

  --positive: #4ADE80;
  --warning: #EAB308;
  --danger: #F87171;
  --danger-soft: #FCA5A5;

  --focus-ring: #B7F34A;

  /* تایپوگرافی */
  --text-hero: clamp(34px, 9vw, 40px);
  --text-page-title: 22px;
  --text-section-title: 16px;
  --text-metric: 20px;
  --text-item: 15px;
  --text-body: 14px;
  --text-meta: 12px;
  --text-helper: 11px;
  --text-nav: 10px;
  --leading-tight: 1.2;
  --leading-body: 1.6;

  /* فاصله */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;

  /* شعاع */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* سایه خنثی (بدون درخشش رنگی) */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.45);

  --transition-fast: 160ms ease;

  /* نام‌های قدیمی: نگاشت سازگار به پالت جدید (بدون تعریف تکراری) */
  --canvas: var(--bg);
  --surface: var(--surface-1);
  --surface-hover: var(--surface-2);
  --surface-input: #0F1210;
  --text-primary: var(--text);
  --accent-deep: #4C6B14;
  --accent-text: #0B0D0C;

  /* اجزای مشترک */
  --gradient-primary: linear-gradient(135deg,
      var(--accent-deep),
      var(--accent));

  --shadow-accent: var(--shadow-2);
}

/* ===== بنیان تعامل و سطوح (D0: قابل استفاده در فازهای بعد) ===== */
::selection {
  background: rgba(183, 243, 74, 0.28);
}

/* حلقه فوکوس سراسری؛ قوانین تخصصی‌تر موجود (با ویژگی بالاتر) پابرجا می‌مانند. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}


/* ===== لیست کارت‌ها ===== */
.sub-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

/* ===== کارت اشتراک (D2: فین‌تک فشرده) ===== */
.sub-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
  transition: background var(--transition-fast);
}

.sub-card:hover {
  background: var(--surface-2);
}

/* الگوی مشترک تراز آیکون: grid مرکزی + line-height:1 برای جلوگیری از اعوجاج فونت/ایموجی */
.sub-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  place-items: center;
  background: var(--surface-2);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  text-align: center;
}

.sub-info {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.sub-name {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-meta {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-side {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.sub-badge {
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 999px;
}

.sub-badge-today {
  background: var(--accent);
  color: var(--bg);
}

.sub-badge-soon {
  background: rgba(234, 179, 8, 0.14);
  color: var(--warning);
}

.sub-badge-past {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

.sub-price {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.sub-renewal {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.sub-renewal.soon {
  color: var(--warning);
}

.sub-renewal.past {
  padding: 3px 8px;
  background: rgba(248, 113, 113, 0.14);
  border-radius: 8px;
  color: var(--danger);
}

/* ===== دکمه‌های ویرایش و حذف ===== */
.card-actions {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.edit-btn,
.delete-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.edit-btn svg,
.delete-btn svg {
  display: block;
}

.edit-btn:hover,
.edit-btn:focus-visible {
  background: var(--surface-2);
  color: var(--text);
}

.delete-btn:hover,
.delete-btn:focus-visible {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
}

.edit-btn:focus-visible,
.delete-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== دکمه تمدید اشتراک (کنش مثبت اصلی کارت) ===== */
.renew-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(183, 243, 74, 0.25);
}

.renew-btn svg {
  display: block;
}

.renew-btn:hover {
  box-shadow: 0 6px 18px rgba(183, 243, 74, 0.35);
}

.renew-btn:active {
  transform: scale(0.96);
}

.renew-btn:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* کارت اشتراک: درخشش محدود تا از لبه کارت بیرون نزند.
   عمداً محدود به کارت است تا رفتار دکمه تمدید در تقویم دست نخورد. */
.card-actions .renew-btn {
  max-width: 100%;
  box-shadow: 0 2px 10px rgba(183, 243, 74, 0.22);
}

.card-actions .renew-btn:hover {
  box-shadow: 0 3px 12px rgba(183, 243, 74, 0.28);
}

/* کارت اشتراک در موبایل: اکشن‌ها ردیف تمام‌عرض زیر محتوای اصلی می‌شوند تا
   هیچ عنصری (از جمله دکمه تمدید) از لبه محتوای کارت بیرون نزند.
   محدود به کارت اشتراک است؛ اکشن تقویم دست نمی‌خورد. */
@media (max-width: 480px) {
  .sub-card {
    flex-wrap: wrap;
  }

  .card-actions {
    flex-direction: row;
    flex-basis: 100%;
    align-items: center;
  }

  .card-actions .renew-btn {
    flex: 1;
  }
}

/* ===== مودال افزودن و ویرایش ===== */
.modal-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: 20px 20px 0 0;
  transform: translateY(40px);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: var(--text-section-title);
  font-weight: 800;
  color: var(--text);
}

/* بدنه اسکرول‌شونده مودال: هدر همیشه در دید می‌ماند، فرم داخل مودال اسکرول می‌شود */
.modal form {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close svg {
  display: block;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: var(--surface-raised);
  color: var(--text);
}

.modal-close:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== فیلدهای فرم ===== */
.field {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  outline: none;
  background: var(--surface-input);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--border-strong);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(183, 243, 74, 0.15);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.date-segments {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface-input);
  border-radius: var(--radius-md);
  direction: ltr;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.date-segments:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(183, 243, 74, 0.15);
}

.date-segments.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12);
}

.date-segments input {
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: center;
  letter-spacing: 0.04em;
}

.date-segments input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

#f-date-year,
#renew-date-year {
  flex: 1.4;
}

.date-sep {
  color: var(--text-muted);
  font-size: 14px;
  user-select: none;
  padding: 0 2px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.submit-btn {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--bg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(183, 243, 74, 0.25);
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== پنجره تأیید حذف ===== */
.confirm-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.confirm-overlay.open {
  opacity: 1;
  visibility: visible;
}

.confirm-dialog {
  width: 100%;
  max-width: 340px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 20px 20px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.2s ease;
}

.confirm-overlay.open .confirm-dialog {
  transform: scale(1);
}

.confirm-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 16px;
  line-height: 1;
  text-align: center;
}

.confirm-icon svg {
  display: block;
}

.confirm-icon.tone-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

.confirm-icon.tone-lime {
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.confirm-dialog h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.confirm-dialog p {
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.9;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions button {
  flex: 1;
  padding: 12px 10px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.confirm-actions button:hover {
  transform: translateY(-2px);
}

.confirm-cancel-btn {
  background: var(--surface-2);
  color: var(--text);
}

.confirm-delete-btn {
  background: var(--danger);
  color: var(--bg);
}

#renew-confirm {
  background: var(--accent);
  color: var(--bg);
}

.renew-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.renew-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.renew-option-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.renew-option-label {
  font-size: 13px;
  font-weight: 700;
}

.renew-option-date {
  font-size: 11px;
  color: var(--text-muted);
}

.renew-custom-date {
  margin-bottom: 16px;
}

#renew-confirm-subname {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== نمایش بهتر در موبایل کوچک ===== */
@media (max-width: 380px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .sub-card {
    gap: 9px;
    padding: 12px;
  }

  .renew-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}

/* ===== جست‌وجوی اشتراک‌ها ===== */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.list-header h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.search-box {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  color: var(--text-muted);
  transition: border-color 0.15s ease;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box .search-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
}

.search-box .search-icon svg {
  display: block;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

@media (max-width: 380px) {
  .list-header {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ===== فیلترهای سریع ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, transform 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-btn:active {
  transform: scale(0.96);
}

.filter-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}

/* ===== کارت‌های خلاصه تمدید (بازنشسته در D1؛ فقط hintها زنده‌اند) ===== */
.insight-hint {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.6;
}

.insight-mode-hint {
  opacity: 0.85;
  font-size: 9px;
}

/* ===== خانه D1: داشبورد فین‌تک (توکن‌های D0) ===== */
.home-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 4px 0 var(--space-4);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  background: var(--accent);
  color: var(--bg);
}

.brand-mark svg {
  display: block;
}

.brand-text h1 {
  font-size: var(--text-page-title);
  font-weight: 800;
  line-height: var(--leading-tight);
}

.brand-text p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--text-meta);
}

.home-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(175px, 1fr) auto;
  grid-template-areas:
    "top top"
    "icon middle"
    "hint hint";
  align-items: center;
  column-gap: var(--space-3);
  min-height: 210px;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(183, 243, 74, 0.09), transparent 60%),
    var(--surface-1);
}

/* متن‌ها، برچسب‌ها و ارقام همیشه روی لایه آیکون قرار می‌گیرند */
.home-hero-top,
.home-hero-amount,
.home-hero-hint {
  position: relative;
  z-index: 1;
}

/* کارت ۱ (معادل هزینه ماهانه):
   مبالغ تومان و ارزهای ثانویه ($/€) همگی به سمت چپ فیزیکی تراز می‌شوند
   تا فضای سمت راست کارت به طور کامل برای نمایش آیکون آزاد شود. */
.home-hero .total-amount,
.home-hero .total-amount .money-row {
  text-align: left;
}

/* فاصله مشخصاً بزرگ‌تر بین مبلغ اصلی تومان و گروه ارزهای فرعی $/€ */
.home-hero .total-amount .money-primary {
  margin-bottom: 10px;
}

/* پایه مشترک آیکون‌های تزئینی کارت‌های هیرو: ستون ساختاری گرید، بدون هم‌پوشانی با متن. */
.home-hero-icon {
  grid-area: icon;
  justify-self: center;
  align-self: center;
  object-fit: contain;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

/* آیکون کارت معادل هزینه ماهانه: ستون گرید سمت راست منطقی (ترک icon در "icon top/middle/hint"). */
.home-cost-icon,
.home-hero:not(.home-trend-card) .home-hero-icon {
  width: 175px;
  height: 175px;
}

/* کارت ۲ (روند این ماه) */
.home-trend-card {
  margin-top: var(--space-3);
  min-height: 165px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(170px, 1fr) auto;
  grid-template-areas:
    "top top"
    "middle icon"
    "hint hint";
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(183, 243, 74, 0.06), transparent 60%),
    var(--surface-1);
}

/* آیکون کارت روند این ماه: ستون ساختاری گرید، بدون هم‌پوشانی با متن. */
.home-trend-icon,
.home-trend-card .home-hero-icon {
  width: 170px;
  height: 170px;
}

.home-hero-top { grid-area: top; }
.home-hero-amount { grid-area: middle; }
.home-hero-hint { grid-area: hint; }

.home-trend-amount {
  transition: color 0.15s ease;
}

.home-trend-amount.trend-decrease {
  color: var(--accent);
}

.home-trend-amount.trend-increase {
  color: var(--warning);
}

.home-trend-amount.trend-neutral {
  font-size: clamp(20px, 6vw, 26px);
  color: var(--text-muted);
}


.home-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.home-hero-title {
  color: var(--text-secondary);
  font-size: var(--text-meta);
  font-weight: 700;
}

.home-hero-count {
  color: var(--text-muted);
  font-size: var(--text-helper);
  white-space: nowrap;
}

.home-hero-amount {
  margin-top: var(--space-2);
  min-width: 0;
  color: var(--text);
  font-size: var(--text-hero);
  font-weight: 800;
  line-height: var(--leading-tight);
}

.home-hero-amount small {
  font-size: 0.42em;
  font-weight: 600;
  color: var(--text-secondary);
}

.home-hero-hint {
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-helper);
  line-height: var(--leading-body);
}

.home-primary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.metric-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
}

.metric-icon svg {
  display: block;
}

.metric-icon.tone-lime {
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.metric-icon.tone-neutral {
  background: var(--surface-2);
  color: var(--text-secondary);
}

.metric-title {
  color: var(--text-muted);
  font-size: var(--text-meta);
  font-weight: 700;
}

.metric-value {
  color: var(--text);
  font-size: var(--text-metric);
  font-weight: 800;
  line-height: var(--leading-tight);
}

.metric-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-muted);
  font-size: var(--text-helper);
  line-height: var(--leading-body);
}

.metric-meta strong {
  color: var(--text-secondary);
}

.home-status-row {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.status-chip {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.status-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.status-icon svg {
  display: block;
}

.tone-warning .status-icon {
  color: var(--warning);
}

.tone-danger .status-icon {
  color: var(--danger);
}

.status-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: var(--leading-tight);
}

.status-text strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.status-text span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-helper);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-secondary {
  margin-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.secondary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 2px;
  border-bottom: 1px solid var(--border);
}

.secondary-label {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: var(--text-meta);
  font-weight: 700;
}

.secondary-value {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: var(--leading-tight);
  text-align: end;
}

.secondary-value #top-sub-name {
  font-size: 14px;
}

.secondary-value #top-sub-detail {
  color: var(--text-secondary);
  font-size: var(--text-meta);
  font-weight: 600;
}

@media (max-width: 380px) {
  .home-primary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .home-cost-icon,
  .home-hero:not(.home-trend-card) .home-hero-icon {
    width: 130px;
    height: 130px;
  }
  .home-trend-icon,
  .home-trend-card .home-hero-icon {
    width: 125px;
    height: 125px;
  }
  .home-hero-amount {
    font-size: clamp(24px, 7vw, 32px);
  }
}

/* ===== تقویم تمدیدها ===== */
.calendar-section {
  margin-top: 20px;
}

.calendar-section h2 {
  margin-bottom: 12px;
  font-size: var(--text-section-title);
  font-weight: 800;
}

.calendar-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.calendar-tab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.calendar-tab:hover {
  color: var(--text);
}

.calendar-tab.active {
  background: var(--accent);
  color: var(--bg);
}

.calendar-tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-month-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-nav-btn,
.calendar-today-btn {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.calendar-nav-btn svg {
  display: block;
}

.calendar-today-btn {
  min-height: 40px;
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
}

.calendar-nav-btn:hover,
.calendar-today-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.calendar-nav-btn:focus-visible,
.calendar-today-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 6px 2px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface-1);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.calendar-day:hover {
  background: var(--surface-2);
}

.calendar-day:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.calendar-day.outside {
  opacity: 0.38;
}

.calendar-day.today {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.calendar-day.today .calendar-day-num {
  color: var(--accent-strong);
}

.calendar-day.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.calendar-day.selected.today {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.calendar-day-markers {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  align-items: center;
}

.calendar-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.calendar-dot.due {
  background: var(--accent);
}

.calendar-dot.overdue {
  background: var(--danger);
}

.calendar-dot.completed {
  background: var(--positive);
}

.calendar-badge {
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}

.calendar-detail {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-detail-empty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.calendar-detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.calendar-detail-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-detail-meta {
  color: var(--text-muted);
  font-size: 11px;
}

.calendar-detail-meta.calendar-detail-amount {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.calendar-detail-actions {
  margin-top: 8px;
}

@media (max-width: 380px) {
  .calendar-grid {
    gap: 4px;
  }

  .calendar-day {
    min-height: 38px;
    font-size: 12px;
    padding-bottom: 16px;
  }
}

/* ===== گزارش ماهانه واقعی ===== */
.report-section {
  margin-top: 28px;
}

.report-section h2 {
  margin-bottom: 12px;
  font-size: var(--text-section-title);
  font-weight: 800;
}

.report-comparison-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.report-compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.report-stat {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.report-stat-label {
  color: var(--text-secondary);
  font-size: 11px;
}

.report-stat-value {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.report-stat + .report-stat .report-stat-value {
  color: var(--text-secondary);
  font-size: 15px;
}

.report-stat-count {
  color: var(--text-muted);
  font-size: 11px;
}

.report-change {
  margin-top: 12px;
  text-align: center;
}

.report-change-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.report-change-increase {
  background: rgba(74, 222, 128, 0.14);
  color: var(--positive);
}

.report-change-decrease {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

.report-change-nochange {
  background: var(--surface-2);
  color: var(--text-muted);
}

.report-change-start {
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.report-mode-hint {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}

.report-month-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  list-style: none;
  padding: 0;
}

.report-month-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.report-month-row.report-month-current {
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.report-month-label {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-month-total {
  color: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.report-month-count {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

/* سطرهای مبالغ چندارزی: هر ارز در سطر جدا تا اعداد مخلوط نشوند. */
.money-line {
  display: block;
}

/* گروه مبالغ چندارزی (قابل استفاده مجدد): ریتم عمودی یکسان،
   سطر اول پررنگ‌تر، سطرهای بعدی کمی کوچک‌تر ولی خوانا. */
.money-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.money-group .money-row {
  line-height: 1.5;
}

.money-group .money-primary {
  font-weight: 800;
}

.money-group .money-secondary {
  font-size: 0.85em;
  font-weight: 600;
  opacity: 0.92;
}

.report-chart {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.report-chart-title {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
}

.report-chart-subtitle {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.report-chart-bars {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-top: 10px;
}

.report-chart-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* خط مبنای مشترک: تفاوت تعداد سطرهای برچسب به سمت بالا رشد می‌کند،
     پس همه ترک‌ها (با ارتفاع ثابت) و همه لیبل‌های ماه در یک راستا می‌مانند. */
  justify-content: flex-end;
  gap: 6px;
  border-radius: 8px;
}

.report-chart-col:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.report-chart-value {
  min-height: 15px;
  color: var(--text-primary);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.report-chart-track {
  position: relative;
  width: 100%;
  max-width: 34px;
  height: 110px;
  border-radius: 6px;
  background: var(--surface-2);
}

.report-chart-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 6px;
  background: rgba(183, 243, 74, 0.55);
}

.report-chart-col.report-chart-current .report-chart-bar {
  background: var(--accent);
}

.report-chart-col.report-chart-current .report-chart-track {
  outline: 1px solid var(--accent);
}

/* ماه صفر: بدون پس‌زمینه پررنگ تا با داده اشتباه نشود؛ فقط خط مبنای محو.
   چیدمان ستون و تأکید ماه جاری (outline) دست‌نخورده می‌ماند. */
.report-chart-col.report-chart-zero .report-chart-track {
  background: transparent;
  border-bottom: 1px dashed var(--border);
}

.report-chart-month {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

.report-chart-col.report-chart-current .report-chart-month {
  color: var(--accent-soft);
  font-weight: 700;
}

.report-chart-empty {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* ===== کارت دونات تفکیک دسته‌بندی در گزارش‌ها ===== */
.report-category-card {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.report-category-currencies {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 6px;
}

.report-cur-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.report-cur-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.report-cur-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.report-donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

.report-donut-ring {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.report-donut-hole {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #141816;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  padding: 6px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.report-donut-total-label {
  font-size: 10px;
  color: var(--text-muted);
}

.report-donut-total-value {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.report-category-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.report-legend-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.report-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.report-legend-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.report-legend-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-legend-amount {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.report-legend-pct {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 32px;
  text-align: left;
  direction: ltr;
}

/* مقایسه «این ماه / ماه قبل»: تا 480px عمداً تک‌ستونه می‌ماند تا متن
   راست‌به‌چپ و مبالغ بلند در همه گوشی‌ها (360 تا 440px) یکدست خوانا
   بمانند؛ چیدمان دوستونه فقط برای نماهای عریض‌تر است. نقطه 480px
   همان شکست‌خط مصرف‌شده در بقیه فایل است، نه محاسبه پدینگ. */
@media (max-width: 480px) {
  .report-compare-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .report-month-row {
    grid-template-columns: 1fr auto;
  }

  .report-month-row .report-month-count {
    grid-column: 1 / -1;
    text-align: end;
  }

  .report-chart-bars {
    gap: 4px;
  }

  .report-chart-track {
    height: 92px;
  }

  .report-chart-value,
  .report-chart-month {
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 24px 16px calc(100px + env(safe-area-inset-bottom));
  }
}

.fab:focus-visible {
  outline: 3px solid rgba(183, 243, 74, 0.5);
  outline-offset: 3px;
}

/* ===== راهنمای شروع اشتراک‌بان ===== */
.onboarding-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;

  display: grid;
  place-items: center;

  padding: 24px;
  background: rgba(5, 5, 12, 0.74);
  backdrop-filter: blur(10px);

  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.onboarding-overlay.open {
  opacity: 1;
  visibility: visible;
}

.onboarding-card {
  width: min(100%, 680px);
  overflow: hidden;

  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.onboarding-viewport {
  overflow: hidden;
}

.onboarding-track {
  display: flex;
  width: 100%;
  direction: ltr;

  transform: translateX(0);
  transition: transform 0.35s ease;
}

.onboarding-slide {
  width: 100%;
  min-width: 100%;
  flex: 0 0 100%;
  direction: rtl;

  padding: 48px;
  text-align: center;
}

.onboarding-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;

  margin: 0 auto 20px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent-strong);
  line-height: 1;
  text-align: center;
}

.onboarding-icon svg {
  display: block;
}

.onboarding-step {
  display: inline-block;

  margin-bottom: 12px;
  color: var(--accent-soft);
  font-size: 13px;
}

.onboarding-slide h2 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 24px;
}

.onboarding-slide p {
  max-width: 440px;

  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 2;
}

.onboarding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.onboarding-skip-btn,
.onboarding-next-btn {
  min-width: 92px;
  min-height: 42px;

  padding: 10px 16px;
  border: none;
  border-radius: 12px;

  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.onboarding-skip-btn {
  background: transparent;
  color: var(--text-secondary);
}

.onboarding-skip-btn:hover {
  color: var(--text-primary);
}

.onboarding-next-btn {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.onboarding-next-btn:hover {
  transform: translateY(-1px);
}

.onboarding-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.onboarding-dot {
  width: 7px;
  height: 7px;

  border-radius: 50%;
  background: var(--border-strong);
  transition: width 0.2s ease, background 0.2s ease;
}

.onboarding-dot.active {
  width: 22px;
  border-radius: 8px;
  background: var(--accent);
}

@media (max-width: 480px) {
  .onboarding-overlay {
    align-items: end;
    padding: 0;
  }

  .onboarding-card {
    border-right: none;
    border-bottom: none;
    border-left: none;
    border-radius: 24px 24px 0 0;
  }

  .onboarding-slide {
    padding: 36px 24px;
  }

  .onboarding-slide h2 {
    font-size: 21px;
  }

  .onboarding-footer {
    padding: 16px;
  }

  .onboarding-skip-btn,
  .onboarding-next-btn {
    min-width: 82px;
  }
}

/* ===== اعلان‌های موفقیت ===== */
.toast-container {
  position: fixed;
  z-index: 200;
  top: 20px;
  left: 50%;

  width: min(calc(100% - 32px), 360px);

  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 14px 16px;
  border: 1px solid rgba(114, 188, 143, 0.35);
  border-radius: 14px;

  background: #173426;
  color: #dcfce7;

  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);

  animation: toast-enter 0.25s ease;
}

.toast::before {
  content: "✓";

  display: grid;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  place-items: center;

  border-radius: 50%;
  background: rgba(114, 188, 143, 0.22);
  color: #bbf7d0;
}

.toast-error {
  border-color: rgba(248, 113, 113, 0.45);
  background: #3a1a1a;
  color: #fecaca;
}

.toast-error::before {
  content: "!";
  background: rgba(248, 113, 113, 0.22);
  color: #fecaca;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== جلوگیری از اسکرول پس‌زمینه در مودال ===== */
body.is-dialog-open {
  overflow: hidden;
}

/* ===== ابزار داده و نسخهٔ اپ (دکمه‌ها در نمای «بیشتر» استفاده می‌شوند) ===== */
.footer-tool-btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  background: var(--surface-2);
  color: var(--text);

  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.footer-tool-btn svg {
  display: block;
  flex-shrink: 0;
}

.footer-tool-btn:hover,
.footer-tool-btn:focus-visible {
  border-color: var(--border-strong);
  color: var(--accent-strong);
}

.footer-tool-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.footer-tool-btn input {
  display: none;
}

.app-version {
  direction: ltr;

  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
}

/* ===== ابزارهای لیست اشتراک‌ها ===== */
.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  margin-bottom: 16px;
}

.sort-control {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;

  color: var(--text-secondary);
  font-size: 12px;
}

.sort-control select {
  min-height: 40px;

  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;

  background: var(--surface);
  color: var(--text-primary);

  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.sort-control select:focus {
  border-color: var(--accent);
}

.clear-filters-btn {
  min-height: 40px;

  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;

  background: transparent;
  color: var(--text-secondary);

  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.clear-filters-btn:hover {
  border-color: var(--accent);
  color: var(--accent-soft);
}

@media (max-width: 380px) {
  .list-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .sort-control {
    justify-content: space-between;
  }

  .sort-control select {
    flex: 1;
  }
}