/* ==========================================================================
   Reports page — scoped styles only
   ========================================================================== */

.vp-mobile .content.reports-content-host {
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0)) !important;
}

.reports-page {
  --rp-navy: #0F172A;
  --rp-gold: #C8A968;
  --rp-bg: #F7F9FC;
  --rp-white: #FFFFFF;
  --rp-border: #E6ECF2;
  --rp-muted: #64748B;
  --rp-radius: 16px;
  --rp-radius-sm: 12px;
  --rp-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  --income: #10b981;
  --expense: #f43f5e;
  --fund: #f59e0b;
  --net: #6366f1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
  font-family: Vazirmatn, inherit;
}

#reports-date-filter {
  margin: 0;
}

.reports-period-filter {
  width: 100%;
  border-radius: 16px;
  background: var(--rp-white);
  padding: 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(230, 236, 242, 0.9);
  overflow: hidden;
}

.reports-period-filter__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: Vazirmatn, inherit;
  text-align: start;
  transition: background 0.15s;
}

.reports-period-filter__toggle:hover,
.reports-period-filter__toggle:focus-visible {
  background: rgba(247, 249, 252, 0.9);
  outline: none;
}

.reports-period-filter__toggle:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.12);
}

.reports-period-filter__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.reports-period-filter__toggle-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.reports-period-filter__title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--rp-navy);
  line-height: 1.25;
  white-space: nowrap;
}

.reports-period-filter__summary {
  font-size: 11px;
  font-weight: 600;
  color: var(--rp-muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.reports-period-filter__summary::before {
  content: "·";
  margin-inline-end: 6px;
  color: #CBD5E1;
}

.reports-period-filter__chev {
  flex-shrink: 0;
  transition: transform 0.22s ease;
}

.reports-period-filter.is-open .reports-period-filter__chev {
  transform: rotate(180deg);
}

.reports-period-filter__panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.reports-period-filter.is-open .reports-period-filter__panel {
  max-height: 88px;
  opacity: 1;
  overflow: visible;
  border-top: 1px solid var(--rp-border);
}

.reports-period-filter__segments {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 8px 10px 10px;
}

.reports-custom-range-overlay {
  z-index: 10050;
}

.reports-custom-range-modal .reports-export-modal__hint {
  line-height: 1.65;
  margin-bottom: 14px;
}

.reports-custom-range-modal__fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reports-custom-range-modal__field {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reports-custom-range-modal__field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--rp-navy);
}

.reports-custom-range-modal__input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid #CBD5E1;
  border-radius: 12px;
  background: var(--rp-white);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  font-family: Vazirmatn, inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--rp-navy);
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.reports-custom-range-modal__input:hover {
  border-color: #94A3B8;
}

.reports-custom-range-modal__input:focus {
  outline: none;
  border-color: var(--rp-navy);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.reports-custom-range-modal .modal-foot {
  gap: 8px;
  justify-content: flex-end;
}

.reports-custom-range-modal .modal-foot .btn {
  min-height: 38px;
  padding: 0 16px;
  font-size: 12px;
  border-radius: 10px;
  font-family: Vazirmatn, inherit;
  flex: 0 0 auto;
}

.reports-custom-range-submit {
  min-width: 72px;
}

.reports-period-filter__seg {
  min-height: 32px;
  padding: 6px 4px;
  border: 1px solid var(--rp-border);
  border-radius: 10px;
  background: var(--rp-bg);
  color: var(--rp-muted);
  font-family: Vazirmatn, inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-align: center;
  line-height: 1.2;
}

.reports-period-filter__seg:hover {
  border-color: rgba(15, 23, 42, 0.2);
  color: var(--rp-navy);
}

.reports-period-filter__seg.is-active {
  background: var(--rp-navy);
  border-color: var(--rp-navy);
  color: var(--rp-white);
}

.reports-period-filter__custom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 0 16px 16px;
}

.reports-period-filter__custom.is-hidden {
  display: none;
}

.reports-period-filter__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reports-period-filter__field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--rp-muted);
}

.reports-period-filter__input {
  width: 100%;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid var(--rp-border);
  border-radius: 16px;
  background: var(--rp-bg);
  font-family: Vazirmatn, inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--rp-navy);
  text-align: center;
}

.reports-period-filter__input:focus {
  outline: none;
  border-color: var(--rp-navy);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.reports-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 16px;
  font-size: 13px;
  color: var(--rp-muted);
  text-align: center;
  line-height: 1.6;
}

.reports-export-modal__range-readonly .field {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reports-export-modal__range-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--rp-navy);
  text-align: end;
}

#reports-dynamic.is-loading {
  pointer-events: none;
}

.reports-skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 50%, #eef2f6 75%);
  background-size: 200% 100%;
  animation: reports-skeleton-shimmer 1.2s ease-in-out infinite;
}

.reports-skeleton-line--sm {
  width: 55%;
  margin-bottom: 10px;
}

.reports-skeleton-line--lg {
  width: 80%;
  height: 18px;
}

.reports-skeleton-line--title {
  width: 40%;
  height: 14px;
  margin-bottom: 14px;
}

.reports-skeleton-line--block {
  width: 100%;
  height: 72px;
  border-radius: 12px;
}

.reports-skeleton-stat {
  min-height: 88px;
  padding: 14px;
}

.reports-skeleton-chart {
  padding: 16px;
  margin-bottom: 12px;
}

.reports-skeleton-bars {
  height: 120px;
  border-radius: 12px;
  background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 50%, #eef2f6 75%);
  background-size: 200% 100%;
  animation: reports-skeleton-shimmer 1.2s ease-in-out infinite;
}

.reports-skeleton-debt {
  padding: 16px;
}

@keyframes reports-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.reports-page .page-head h2 {
  font-size: 20px;
}

.reports-page .toolbar .btn {
  min-height: 38px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 10px;
}

.reports-page__toolbar {
  gap: 8px;
}

.reports-page__action-btn {
  min-height: 34px !important;
  padding: 6px 14px !important;
  font-size: 12px !important;
  font-weight: 600;
  border-radius: 10px !important;
  font-family: Vazirmatn, inherit;
}

.reports-export-overlay {
  z-index: 10050;
}

.reports-export-modal {
  max-width: 440px;
  border: 1px solid rgba(200, 169, 104, 0.25);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
}

.reports-export-modal .modal-head h3 {
  font-size: 15px;
  color: var(--rp-navy);
}

.reports-export-modal__hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--rp-muted);
  line-height: 1.5;
}

.reports-export-modal__period {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--rp-bg);
  border: 1px solid var(--rp-border);
}

.reports-export-modal__period .field {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reports-export-modal__period label {
  font-size: 13px;
  font-weight: 600;
  color: var(--rp-navy);
  white-space: nowrap;
}

.reports-export-modal__period .select {
  flex: 1;
  min-height: 38px;
  max-width: 160px;
  font-size: 13px;
  border-radius: 10px;
}

.reports-export-modal__selection-hint {
  margin: 0 0 8px;
  font-size: 11px;
  color: #dc2626;
  line-height: 1.4;
}

.reports-export-modal__selection-hint.is-hidden {
  display: none;
}

.reports-export-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.reports-export-modal__group {
  margin-bottom: 14px;
}

.reports-export-modal__group-title {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--rp-gold);
  letter-spacing: 0.02em;
}

.reports-export-modal__checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.reports-export-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--rp-bg);
  border: 1px solid var(--rp-border);
  font-size: 12px;
  color: var(--rp-navy);
  cursor: pointer;
  user-select: none;
}

.reports-export-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--rp-gold);
  flex-shrink: 0;
}

.reports-export-modal__filters {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reports-export-filter-field.is-hidden {
  display: none;
}

.reports-export-filter-field .input,
.reports-export-filter-field .select {
  min-height: 38px;
  font-size: 13px;
  border-radius: 10px;
}

.reports-export-modal .modal-foot {
  gap: 8px;
}

.reports-export-modal .modal-foot .btn.details {
  min-height: 38px;
  padding: 0 16px;
  font-size: 12px;
  border-radius: 10px;
}

.reports-export-submit {
  flex: 1;
}

.reports-page__export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.reports-page__export-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--rp-muted);
}

.reports-page__export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reports-page__export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  font-weight: 600;
  border-radius: 10px !important;
  font-family: Vazirmatn, inherit;
}

.reports-page__kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.reports-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--rp-radius);
  border: 1px solid #F3F4F6;
  box-shadow: var(--rp-shadow);
  background: var(--rp-white);
}

.reports-kpi__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.reports-kpi__icon .icon {
  width: 18px;
  height: 18px;
}

.reports-kpi--income .reports-kpi__icon {
  color: var(--income);
  background: rgba(16, 185, 129, 0.12);
}

.reports-kpi--expense .reports-kpi__icon {
  color: var(--expense);
  background: rgba(244, 63, 94, 0.12);
}

.reports-kpi--fund .reports-kpi__icon {
  color: var(--fund);
  background: rgba(245, 158, 11, 0.14);
}

.reports-kpi--net .reports-kpi__icon {
  color: var(--net);
  background: rgba(99, 102, 241, 0.12);
}

.reports-kpi__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--rp-muted);
  line-height: 1.3;
}

.reports-kpi__amount {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}

.reports-kpi__value {
  font-family: "Vazirmatn FD", "Vazirmatn", Tahoma, sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: var(--rp-navy);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.reports-kpi__unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--rp-muted);
}

.reports-debt-progress {
  margin-bottom: 12px;
}

.reports-debt-progress__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.reports-debt-progress__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--rp-muted);
}

.reports-debt-progress__pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--rp-navy);
  font-variant-numeric: tabular-nums;
}

.reports-debt-progress__track {
  height: 8px;
  border-radius: 999px;
  background: var(--rp-bg);
  border: 1px solid var(--rp-border);
  overflow: hidden;
}

.reports-debt-progress__bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e 0%, #10b981 100%);
  transition: width 0.35s ease;
}

.reports-debt-top-list {
  margin-bottom: 12px;
}

.reports-debt-top-list__title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--rp-navy);
}

.reports-debt-top-list__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reports-debt-top-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--rp-bg);
  border: 1px solid var(--rp-border);
  font-size: 12px;
}

.reports-debt-top-list__unit {
  color: var(--rp-muted);
  font-weight: 600;
}

.reports-debt-top-list__amount {
  font-family: "Vazirmatn FD", "Vazirmatn", Tahoma, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #ef4444;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.reports-debt-view-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
  color: var(--rp-navy);
  text-decoration: none;
  border-radius: var(--rp-radius-sm);
  background: var(--rp-bg);
  border: 1px solid var(--rp-border);
  transition: background 0.15s, border-color 0.15s;
}

.reports-debt-view-all:hover {
  background: var(--rp-white);
  border-color: rgba(15, 23, 42, 0.15);
}

.reports-page__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.reports-page__stats .card.stat {
  padding: 12px 14px;
  border-radius: var(--rp-radius-sm);
  border: 1px solid rgba(210, 220, 235, 0.55);
  box-shadow: var(--rp-shadow);
}

.reports-page__stats .stat .ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  margin-bottom: 2px;
}

.reports-page__stats .stat .ico .icon {
  width: 18px;
  height: 18px;
}

.reports-page__stats .stat .label {
  font-size: 11px;
  line-height: 1.3;
}

.reports-page__stats .stat .value {
  font-size: 16px;
  line-height: 1.2;
  word-break: break-word;
}

.reports-page__chart-card {
  padding: 14px 16px 16px;
  border-radius: var(--rp-radius);
  border: 1px solid #F3F4F6;
  box-shadow: var(--rp-shadow);
}

.reports-page__chart-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--rp-navy);
}

.reports-page__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
}

.reports-page .chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  padding-top: 8px;
  overflow-x: hidden;
  width: 100%;
}

.reports-page .chart-col {
  flex: 1 1 0;
  min-width: 0;
}

.reports-page .chart-col .lbl {
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reports-page .chart-bars--dense .chart-col .lbl {
  font-size: 9px;
}

.reports-page .chart-col .bar {
  width: 100%;
  max-width: 18px;
  margin-inline: auto;
  min-height: 3px;
}

.reports-page__debt-summary {
  padding: 14px 16px 16px;
  border-radius: var(--rp-radius);
  border: 1px solid #F3F4F6;
  box-shadow: var(--rp-shadow);
  background: linear-gradient(180deg, var(--rp-white) 0%, rgba(247, 249, 252, 0.92) 100%);
}

.reports-page__debt-summary-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--rp-navy);
}

.reports-page__debt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.reports-page__debt-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  padding: 8px 4px;
  border-radius: var(--rp-radius-sm);
  background: var(--rp-bg);
  border: 1px solid var(--rp-border);
  text-align: center;
}

.reports-page__debt-stat-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--rp-muted);
  line-height: 1.25;
  max-width: 100%;
}

.reports-page__debt-stat-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--rp-navy);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.reports-page__debt-stat--paid .reports-page__debt-stat-value {
  color: #22c55e;
}

.reports-page__debt-stat--debtors .reports-page__debt-stat-value {
  font-size: 14px;
  color: #ef4444;
}

.reports-page__debt-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--rp-radius-sm);
  background: var(--rp-white);
  border: 1px solid var(--rp-border);
}

.reports-page__debt-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--rp-muted);
}

.reports-page__debt-row strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--rp-navy);
  text-align: end;
}

.reports-page__debt-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  border-radius: var(--rp-radius-sm);
  font-family: Vazirmatn, inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--rp-navy);
  border-color: var(--rp-navy);
}

.reports-page__debt-link:hover {
  filter: brightness(1.05);
}

@media (max-width: 720px) {
  .reports-period-filter.is-open .reports-period-filter__panel {
    max-height: 120px;
  }

  .reports-period-filter__segments {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 8px 10px 10px;
  }

  .reports-period-filter__seg:nth-child(4) {
    grid-column: 1;
  }

  .reports-period-filter__seg:nth-child(5) {
    grid-column: 2 / span 2;
  }

  .reports-period-filter__seg {
    min-height: 30px;
    font-size: 10px;
    padding: 5px 4px;
  }

  .reports-period-filter__custom {
    grid-template-columns: 1fr;
  }

  .reports-page__kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .reports-kpi__value {
    font-size: 14px;
  }

  .reports-page__export-row {
    flex-direction: column;
    align-items: stretch;
  }

  .reports-page__export-actions {
    width: 100%;
  }

  .reports-page__export-btn {
    flex: 1;
    justify-content: center;
  }

  .reports-page__stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .reports-page__stats .stat .value {
    font-size: 14px;
  }

  .reports-page .chart-bars {
    height: 150px;
  }

  .reports-page .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .reports-page .toolbar {
    width: 100%;
  }

  .reports-page .toolbar .btn {
    flex: 1;
    justify-content: center;
  }

  .reports-export-modal__checks {
    grid-template-columns: 1fr;
  }

  .reports-page__debt-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .reports-page__debt-stat {
    min-height: 64px;
    padding: 6px 4px;
    flex-direction: column;
    justify-content: center;
  }

  .reports-page__debt-stat-label {
    font-size: 9px;
    line-height: 1.2;
  }

  .reports-page__debt-stat-value {
    font-size: 15px;
  }

  .reports-page__debt-stat--debtors .reports-page__debt-stat-value {
    font-size: 12px;
  }
}

@media print {
  .reports-page__export-row {
    display: none !important;
  }
}
