/* === BILLETÍN — DASHBOARD STYLES === */

/* ── Layout base ── */
.dash-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Top bar ── */
.dash-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.dash-topbar-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  max-width: 100%;
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); padding: 7px; border-radius: var(--radius-sm);
  transition: background var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg); }

.dash-topbar .logo { font-size: 1.1rem; }

.topbar-right {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}
.topbar-btn {
  background: none; border: none; cursor: pointer;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--bg); }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444; position: absolute; top: 6px; right: 6px;
  border: 2px solid white;
}

.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: var(--radius-full);
  cursor: pointer; transition: background var(--transition);
}
.topbar-user:hover { background: var(--bg); }
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: var(--primary-dark); font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-name { font-size: 0.85rem; font-weight: 700; line-height: 1.2; }
.topbar-stars { font-size: 0.72rem; color: #f59e0b; }
.topbar-user-info { display: flex; flex-direction: column; }

/* Notif dropdown */
.notif-dropdown {
  position: absolute; top: 100%; right: 60px;
  width: 300px; background: white;
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); z-index: 300;
  overflow: hidden;
}
.notif-dropdown.hidden { display: none; }
.notif-header {
  padding: 14px 18px; font-weight: 700; font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f0fdf4; }
.notif-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-icon.green { background: var(--primary-light); color: var(--primary-dark); }
.notif-icon.orange { background: var(--orange-light); color: var(--orange); }
.notif-icon.blue { background: var(--blue-light); color: var(--blue); }
.notif-title { font-size: 0.83rem; font-weight: 600; }
.notif-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* ── Layout grid ── */
.dash-layout {
  display: flex;
  padding-top: 61px; /* topbar height */
  min-height: 100vh;
}

/* ── Sidebar ── */
.dash-sidebar {
  width: 248px; flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 61px; bottom: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
}

.sidebar-profile {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: var(--primary-dark); font-weight: 800; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.profile-status-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2.5px solid white;
  position: absolute; bottom: 1px; right: 1px;
}
.profile-name { font-size: 0.9rem; font-weight: 700; line-height: 1.2; }
.profile-tier { margin-top: 4px; }
.tier-badge {
  font-size: 0.73rem; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
  background: #f1f5f9; color: var(--text-2);
}

/* Star rating in sidebar */
.sidebar-rating {
  padding: 16px; border-bottom: 1px solid var(--border);
  text-align: center;
}
.rating-label { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.star-display { display: flex; justify-content: center; gap: 3px; }
.star { font-size: 1.4rem; color: var(--border-2); cursor: pointer; transition: all 0.15s; line-height: 1; }
.star.filled { color: #f59e0b; text-shadow: 0 0 8px rgba(245,158,11,0.3); }
.star:hover, .star.hover { color: #fcd34d; transform: scale(1.15); }
.rating-score { font-size: 0.8rem; font-weight: 700; color: var(--text-2); margin-top: 6px; }

/* Nav items */
.sidebar-nav {
  flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px; border-radius: var(--radius-md);
  color: var(--text-2); font-size: 0.88rem; font-weight: 500;
  transition: all var(--transition); cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark); font-weight: 700;
}
.nav-item svg { flex-shrink: 0; }

.sidebar-bottom { padding: 12px 10px; border-top: 1px solid var(--border); }
.nav-item-logout { color: var(--muted); }
.nav-item-logout:hover { color: #ef4444; background: #fef2f2; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  z-index: 99; backdrop-filter: blur(2px);
}
.sidebar-overlay.hidden { display: none; }

/* ── Main content ── */
.dash-main {
  flex: 1;
  margin-left: 248px;
  padding: 28px 28px 60px;
  min-width: 0;
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* Section visibility */
.dash-section { display: none; animation: sect-in 0.3s ease; }
.dash-section.active { display: block; }
@keyframes sect-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-heading { margin-bottom: 24px; }
.section-heading h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.section-heading p { color: var(--muted); margin-top: 6px; font-size: 0.9rem; }
.section-date { font-size: 0.83rem; color: var(--muted); margin-top: 4px; }

/* ── KPI Cards ── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 20px;
}
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi-card {
  background: white; border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  padding: 20px; display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 46px; height: 46px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon.green  { background: var(--primary-light); color: var(--primary-dark); }
.kpi-icon.blue   { background: var(--blue-light);    color: var(--blue); }
.kpi-icon.orange { background: var(--orange-light);  color: var(--orange); }
.kpi-icon.purple { background: var(--purple-light);  color: var(--purple); }

.kpi-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.kpi-of { font-size: 1rem; font-weight: 500; color: var(--muted); }
.kpi-sub { font-size: 0.73rem; color: var(--muted); margin-top: 4px; }
.stars-kpi { color: #f59e0b; letter-spacing: 1px; }

/* ── Generic dash card ── */
.dash-card {
  background: white; border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  padding: 22px; box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; font-weight: 700; color: var(--text-2);
  margin-bottom: 18px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title svg { color: var(--primary); }

.card-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 240px; margin-bottom: 0; }
.flex-2 { flex: 2; min-width: 300px; margin-bottom: 0; }

/* Loan progress */
.loan-progress-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.loan-prog-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.loan-prog-count { font-size: 1.2rem; font-weight: 800; }
.loan-prog-pct { font-size: 1.5rem; font-weight: 900; color: var(--primary); }
.loan-prog-bar-wrap {
  height: 10px; background: var(--bg);
  border-radius: var(--radius-full); overflow: hidden; margin-bottom: 18px;
}
.loan-prog-bar {
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), #4ade80);
  transition: width 1s ease;
}

.cuotas-timeline { display: flex; flex-wrap: wrap; gap: 6px; }
.cuota-dot {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; cursor: default;
  transition: all var(--transition);
  position: relative;
}
.cuota-dot.paid { background: var(--primary-light); color: var(--primary-dark); border: 1.5px solid var(--primary); }
.cuota-dot.current {
  background: var(--orange-light); color: var(--orange);
  border: 2px solid var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}
.cuota-dot.pending { background: var(--bg); color: var(--muted); border: 1.5px solid var(--border); }
.cuota-dot:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: white;
  font-size: 0.68rem; padding: 4px 8px; border-radius: 5px; white-space: nowrap; z-index: 10;
}

/* Next payment block */
.next-payment-block { text-align: center; }
.next-pay-amount { font-size: 2rem; font-weight: 900; color: var(--primary-dark); margin-bottom: 6px; }
.next-pay-date { font-size: 0.83rem; color: var(--muted); margin-bottom: 10px; }
.next-pay-badge {
  display: inline-block; padding: 4px 12px; border-radius: var(--radius-full);
  background: var(--orange-light); color: var(--orange);
  font-size: 0.78rem; font-weight: 700; margin-bottom: 18px;
}
.pay-note { font-size: 0.72rem; color: var(--muted); margin-top: 10px; }

/* Quick actions */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.quick-btn {
  flex: 1; min-width: 100px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 12px; border-radius: var(--radius-lg);
  border: 1.5px solid var(--border); background: var(--surface-2);
  cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--text-2);
  transition: all var(--transition); font-family: var(--font);
}
.quick-btn:hover { background: white; border-color: var(--primary); color: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.quick-icon {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.quick-icon.green  { background: var(--primary-light); color: var(--primary-dark); }
.quick-icon.blue   { background: var(--blue-light);    color: var(--blue); }
.quick-icon.orange { background: var(--orange-light);  color: var(--orange); }
.quick-icon.purple { background: var(--purple-light);  color: var(--purple); }

/* Loan status badge */
.loan-status-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: var(--radius-full);
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 0.82rem; font-weight: 700; margin-top: 6px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse-dot 2s infinite; }

/* Loan detail card */
.loan-detail-card .loan-meta-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
.lmi-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 5px; }
.lmi-value { font-size: 1.1rem; font-weight: 800; }
.lmi-value.green { color: var(--primary-dark); }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.data-table th {
  text-align: left; padding: 10px 14px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.td-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 700; }
.td-status.paid    { background: var(--primary-light); color: var(--primary-dark); }
.td-status.current { background: var(--orange-light);  color: var(--orange); }
.td-status.pending { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.td-status.done    { background: var(--primary-light); color: var(--primary-dark); }
.td-status.active  { background: var(--orange-light);  color: var(--orange); }

/* Payments list */
.payments-list { display: flex; flex-direction: column; gap: 10px; }
.payment-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface-2);
}
.payment-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.payment-title { font-size: 0.88rem; font-weight: 600; }
.payment-date  { font-size: 0.75rem; color: var(--muted); }
.payment-amount { margin-left: auto; font-size: 0.95rem; font-weight: 800; color: var(--primary-dark); }

/* ── TIERS ── */
.tiers-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 14px; margin-bottom: 20px;
}
.tier-card {
  background: white; border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  padding: 20px 16px; text-align: center;
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.tier-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tier-card.tier-current {
  border-color: var(--primary); border-width: 2px;
  background: linear-gradient(160deg, #f0fdf4, white);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-md);
}
.tier-card.tier-locked { opacity: 0.55; }
.tier-card.tier-active { border-color: #92400e44; }

.tier-badge-label {
  position: absolute; top: 10px; left: 0; right: 0;
  font-size: 0.64rem; font-weight: 800; color: var(--primary-dark);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.tier-emoji { font-size: 2rem; margin-bottom: 8px; margin-top: 8px; }
.tier-name { font-size: 1rem; font-weight: 800; margin-bottom: 4px; }
.tier-req { font-size: 0.7rem; color: var(--muted); margin-bottom: 12px; line-height: 1.4; }
.tier-perks { list-style: none; text-align: left; display: flex; flex-direction: column; gap: 7px; }
.tier-perks li {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 0.77rem; color: var(--text-2);
}
.tier-perks li svg { color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.perk-locked { opacity: 0.4; }
.perk-locked svg { color: var(--muted); }

/* Current tier highlight */
.current-tier-card .current-tier-inner {
  display: flex; align-items: center; gap: 20px; margin-bottom: 20px;
}
.tier-medal { font-size: 2.5rem; }
.tier-current-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.tier-current-name { font-size: 1.4rem; font-weight: 900; }
.tier-current-sub { font-size: 0.83rem; color: var(--text-2); margin-top: 4px; }
.tier-progress-row { display: flex; align-items: center; gap: 14px; }
.tier-prog-label { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.tier-prog-bar-wrap { flex: 1; height: 8px; background: var(--bg); border-radius: var(--radius-full); overflow: hidden; }
.tier-prog-bar { height: 100%; background: linear-gradient(90deg, #f59e0b, #fcd34d); border-radius: var(--radius-full); transition: width 1.2s ease; }
.tier-prog-pct { font-size: 0.83rem; font-weight: 700; color: #b45309; }

/* Rating breakdown */
.rating-breakdown { display: flex; flex-direction: column; gap: 14px; }
.rating-factor { display: flex; align-items: center; gap: 14px; }
.rf-label { font-size: 0.83rem; color: var(--text-2); width: 220px; flex-shrink: 0; }
.rf-bar-wrap { flex: 1; height: 8px; background: var(--bg); border-radius: var(--radius-full); overflow: hidden; }
.rf-bar { height: 100%; border-radius: var(--radius-full); }
.rf-bar.green { background: linear-gradient(90deg, var(--primary), #4ade80); }
.rf-bar.blue  { background: linear-gradient(90deg, var(--blue), #93c5fd); }
.rf-bar.orange{ background: linear-gradient(90deg, var(--orange), #fed7aa); }
.rf-val { font-size: 0.83rem; font-weight: 700; color: var(--text-2); width: 45px; text-align: right; }
.rating-total {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 0.88rem; font-weight: 700;
}
.stars-highlight { color: #f59e0b; font-size: 1.1rem; letter-spacing: 1px; }

/* ── Profile section ── */
.profile-form { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.profile-avatar-lg {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: var(--primary-dark); font-weight: 800; font-size: 1.8rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(34,197,94,0.2);
}
.pf-fields { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.pf-row { display: flex; gap: 16px; }
.pf-item { flex: 1; background: var(--surface-2); border-radius: var(--radius-md); padding: 12px 14px; border: 1px solid var(--border); }
.pf-label { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.pf-value { font-size: 0.92rem; font-weight: 600; }
.geo-pf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-geo-badge { font-size: 0.72rem; background: var(--primary-light); color: var(--primary-dark); padding: 2px 8px; border-radius: var(--radius-full); font-weight: 600; }

.account-status-list { display: flex; flex-direction: column; gap: 12px; }
.ast-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.ast-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ast-icon.green  { background: var(--primary-light); color: var(--primary-dark); }
.ast-icon.orange { background: var(--orange-light);  color: var(--orange); }
.ast-label { font-size: 0.72rem; color: var(--muted); }
.ast-val { font-size: 0.88rem; font-weight: 700; }
.ast-pending { color: var(--orange); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 500; display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: white; border-radius: var(--radius-xl);
  padding: 36px; max-width: 380px; width: 90%;
  text-align: center; box-shadow: var(--shadow-xl);
  animation: pop-in 0.3s cubic-bezier(0.17,0.67,0.38,1.35);
}
.modal-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: #dbeafe; color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.modal-box h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.modal-box p  { font-size: 0.88rem; color: var(--muted); margin-bottom: 16px; }
.modal-amount { font-size: 2rem; font-weight: 900; color: var(--primary-dark); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .tiers-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .dash-main { margin-left: 0; padding: 20px; }
  .dash-sidebar {
    transform: translateX(-100%);
  }
  .dash-sidebar.open { transform: translateX(0); }
  .loan-detail-card .loan-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .tiers-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid-3 { grid-template-columns: 1fr; }
  .topbar-user-info { display: none; }
  .card-row { flex-direction: column; }
  .tiers-grid { grid-template-columns: 1fr; }
  .rf-label { width: 140px; }
  .pf-row { flex-direction: column; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); flex-wrap: wrap; }
}
