:root {
  --navy-950: #0b1120;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --navy-600: #475569;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --success: #22c55e;
  --danger: #f87171;
  --warning: #fbbf24;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --card-bg: rgba(30, 41, 59, 0.75);
  --border: rgba(148, 163, 184, 0.15);
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'YekanBakh', Tahoma, sans-serif;
  background: var(--navy-950);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(30, 58, 95, 0.4) 0%, transparent 50%),
    linear-gradient(160deg, var(--navy-950) 0%, #1e3a5f 40%, var(--navy-900) 100%);
  z-index: -1;
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

/* Hero */
.hero {
  padding: 3rem 0 2.5rem;
  text-align: center;
}

.hero-badge {
  display: inline-block;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-light);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.hero-address {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.charter-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.2s, transform 0.2s;
}

.charter-link:hover {
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

.info-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  min-width: 200px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s, border-color 0.2s;
}

.info-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
}

.info-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.info-phone {
  display: block;
  color: var(--accent-light);
  text-decoration: none;
  margin-top: 0.25rem;
  font-weight: 600;
}

.charter-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--accent-light);
  font-weight: 600;
}

.charter-icon {
  font-size: 1.25rem;
}

/* Manager section */
.manager-section {
  margin-bottom: 1rem;
}

.manager-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.card-info .card-holder {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.card-info .card-number-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.card-info .card-number {
  display: inline-block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-light);
  unicode-bidi: isolate;
}

.card-info .card-number.card-copy-target {
  cursor: pointer;
  transition: opacity 0.2s;
}

.card-info .card-number.card-copy-target:hover {
  opacity: 0.85;
}

.card-copy-btn {
  padding: 0.3rem 0.75rem;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  color: var(--accent-light);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.card-copy-btn:hover {
  background: rgba(99, 102, 241, 0.35);
}

.card-number-row.is-copied .card-copy-btn {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.45);
  color: var(--success);
}

/* Section nav */
.section-nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.section-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.section-nav a:hover {
  color: #fff;
  background: rgba(99, 102, 241, 0.2);
}

/* Sections */
.section {
  margin-bottom: 3rem;
}

.section-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.section-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Units grid */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.unit-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.unit-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.unit-card.has-debt {
  border-color: rgba(248, 113, 113, 0.3);
}

.unit-card.no-debt {
  border-color: rgba(34, 197, 94, 0.25);
}

.unit-number {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.unit-top h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0.25rem 0 0.15rem;
}

.unit-resident {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.unit-delay {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

.unit-debt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.debt-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.unit-debt strong {
  font-size: 1rem;
  color: var(--warning);
}

.unit-card.no-debt .unit-debt strong {
  color: var(--success);
}

.unit-debt-detail {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.debt-detail-btn {
  width: 100%;
  padding: 0.55rem 1rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  color: var(--accent-light);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.debt-detail-btn:hover {
  background: rgba(99, 102, 241, 0.28);
  transform: translateY(-1px);
}

.current-charge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.current-charge-pill strong {
  color: var(--accent-light);
  font-size: 0.95rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(11, 17, 32, 0.72);
  backdrop-filter: blur(6px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  position: relative;
  width: min(480px, 100%);
  max-height: min(85vh, 640px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

.modal-header {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  padding-left: 2rem;
}

.modal-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.modal-footer strong {
  color: var(--warning);
  font-size: 1rem;
}

.debt-detail-section + .debt-detail-section {
  margin-top: 1.25rem;
}

.debt-detail-heading {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.65rem;
}

.debt-detail-list {
  list-style: none;
}

.debt-detail-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.debt-detail-list li:last-child {
  border-bottom: none;
}

.debt-detail-list li span:last-child {
  color: var(--warning);
  font-weight: 600;
  white-space: nowrap;
}

.debt-detail-list small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.debt-detail-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.35rem 0;
}

/* Calendar */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.nav-btn,
.page-btn {
  padding: 0.5rem 1.25rem;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 10px;
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.nav-btn:hover,
.page-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.35);
}

.page-btn {
  cursor: pointer;
  font-family: inherit;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.calendar-year-heading {
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
  color: var(--text);
}

.calendar-table th.month-col {
  font-size: 0.72rem;
  font-weight: 500;
}

.month-col .month-name {
  display: block;
}

.month-col .month-rate {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.52rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
}

.legend {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.dot.paid { background: var(--success); }
.dot.overdue { background: var(--danger); }
.dot.future { background: var(--navy-600); }

.calendar-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.calendar-table th,
.calendar-table td {
  padding: 0.75rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.calendar-table th {
  /* background: rgba(0, 0, 0, 0.25); */
  font-weight: 600;
  white-space: nowrap;
}

.sticky-col {
  position: sticky;
  right: 0;
  background: var(--navy-800);
  text-align: right;
  padding-right: 1rem !important;
  width: 20ch;
  min-width: 20ch;
  max-width: 20ch;
  z-index: 2;
  opacity: 1;
}

.cal-unit-num {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cal-unit-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-unit-resident {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#calendar-container,
#bills-container {
  position: relative;
}

#calendar-container.loading,
#bills-container.loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.2s;
}

#calendar-container.loading::after,
#bills-container.loading::after {
  content: 'در حال بارگذاری...';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 17, 32, 0.45);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 5;
  border-radius: var(--radius);
}

.status-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.status-cell.paid {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.status-cell.overdue {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.status-cell.future {
  background: rgba(71, 85, 105, 0.3);
  color: var(--text-muted);
}

/* Bills */
.bills-list {
  display: grid;
  gap: 1rem;
}

.bill-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.bill-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.bill-header time {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.bill-total {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.bill-total strong {
  color: var(--accent-light);
}

.bill-shares {
  list-style: none;
}

.bill-shares li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.bill-shares li:last-child {
  border-bottom: none;
}

.share-status {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.share-paid .share-status {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.share-unpaid .share-status {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.page-info {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Footer */
.footer {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

@media (max-width: 768px) {
  .calendar-table {
    min-width: unset;
  }

  .calendar-table th,
  .calendar-table td {
    padding: 0.3rem 0.2rem;
    font-size: 0.65rem;
  }

  .calendar-table th.month-col {
    min-width: 3.2rem;
    max-width: 3.5rem;
    padding: 0.35rem 0.15rem;
    font-size: 0.6rem;
    line-height: 1.3;
  }

  .month-col .month-rate {
    font-size: 0.48rem;
  }

  .sticky-col {
    width: 20ch;
    min-width: 20ch;
    max-width: 20ch;
    padding-right: 0.4rem !important;
    font-size: 0.65rem;
  }

  .cal-unit-num {
    font-size: 0.55rem;
  }

  .cal-unit-name,
  .cal-unit-resident {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cal-unit-resident {
    font-size: 0.5rem;
  }

  .status-cell {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    font-size: 0.7rem;
  }

  .legend {
    gap: 0.75rem;
    font-size: 0.75rem;
  }

  .dot {
    width: 8px;
    height: 8px;
  }
}

.calendar-nav button {
  font-family: 'YekanBakh';
}

@media (max-width: 600px) {
  .hero {
    padding: 2rem 0 1.5rem;
  }

  .bill-shares li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .section-nav {
    top: 0;
    border-radius: 0;
    margin-left: -4vw;
    margin-right: -4vw;
    width: 100vw;
  }
}
