/* Reset & Base ----------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}
.hidden { display: none !important; }

/* ------------------------- Login --------------------------------------- */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.login-header {
  text-align: center;
  margin-bottom: 30px;
}
.login-icon {
  width: 80px;
  height: 80px;
  background: #667eea;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 32px;
  color: #fff;
}
.login-header h1 {
  color: #2d3748;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-header p {
  color: #718096;
  font-size: 1rem;
}
.error-message {
  background: #fed7d7;
  color: #c53030;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.login-form { margin-bottom: 30px; }
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #4a5568;
}
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group i {
  position: absolute;
  left: 16px;
  color: #a0aec0;
  z-index: 1;
}
.input-group input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 16px;
  transition: .3s;
  background: #fff;
}
.input-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, .1);
}
.password-toggle {
  position: absolute;
  right: 16px;
  background: none;
  border: none;
  color: #a0aec0;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: .2s;
}
.password-toggle:hover { color: #667eea; }
.login-btn {
  width: 100%;
  padding: 16px;
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: .3s;
  position: relative;
}
.login-btn:hover:not(:disabled) {
  background: #5a67d8;
  transform: translateY(-2px);
}
.login-btn:disabled {
  opacity: .7;
  cursor: not-allowed;
  transform: none;
}
.btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ------------------------- Dashboard ----------------------------------- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 20px 30px;
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.header h1 {
  color: #2d3748;
  font-size: 2rem;
  font-weight: 700;
}
.header h1 i {
  color: #667eea;
  margin-right: 10px;
}
.header-info {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
#current-date { color: #718096; font-weight: 500; }
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #4a5568;
  font-weight: 500;
}
.user-role {
  padding: 4px 8px;
  background: #667eea;
  color: #fff;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: .3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.btn-primary {
  background: #667eea;
  color: #fff;
}
.btn-primary:hover {
  background: #5a67d8;
  transform: translateY(-2px);
}
.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}
.btn-secondary:hover {
  background: #cbd5e0;
}

/* Loading / Error */
.loading {
  text-align: center;
  padding: 60px 20px;
  background: rgba(255, 255, 255, .95);
  border-radius: 15px;
  margin-bottom: 30px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: #fed7d7;
  color: #c53030;
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.stat-card {
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 25px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
  transition: .3s;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
}
.stat-card:nth-child(1) .stat-icon { background: #667eea; }
.stat-card:nth-child(2) .stat-icon { background: #48bb78; }
.stat-card:nth-child(3) .stat-icon { background: #ed8936; }
.stat-card:nth-child(4) .stat-icon { background: #f56565; }
.stat-content h3 {
  font-size: 2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 5px;
}
.stat-content p {
  color: #718096;
  font-weight: 500;
}

/* Tabs */
.tabs {
  display: flex;
  background: rgba(255, 255, 255, .95);
  border-radius: 15px;
  padding: 8px;
  margin-bottom: 20px;
  gap: 8px;
  overflow-x: auto;
}
.tab-btn {
  padding: 12px 20px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  color: #718096;
  transition: .3s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-btn.active {
  background: #667eea;
  color: #fff;
}
.tab-btn:hover:not(.active) {
  background: #e2e8f0;
  color: #4a5568;
}

/* ------------------------- Calendar UI ------------------------- */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  background: #edf2f7;
  padding: 15px;
  border-radius: 12px;
  margin-top: 10px;
}
.calendar-header {
  text-align: center;
  font-weight: bold;
  padding: 10px 0;
  color: #4a5568;
  background: #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
}
.calendar-day {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px;
  min-height: 70px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  color: #2d3748;
  transition: 0.2s ease-in-out;
  cursor: pointer;
}
.calendar-day:hover {
  background: #f0f4f8;
  transform: scale(1.02);
}
.calendar-day .day-number {
  font-weight: bold;
  margin-bottom: 5px;
}
.calendar-day .day-info {
  font-size: 12px;
  text-align: center;
  color: #718096;
}
.calendar-day.today {
  border: 2px solid #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}
.calendar-day.other-month { opacity: 0.4; }
.calendar-day.has-payments {
  border-left: 4px solid #48bb78;
}
.calendar-day.has-insufficient {
  border-left: 4px solid #f56565;
}
.calendar-legend {
  margin-top: 15px;
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: #4a5568;
  align-items: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}
.legend-color.success { background: #48bb78; }
.legend-color.danger { background: #f56565; }
.legend-color.today { background: #667eea; }

/* ----------- Status Badges ----------------------------- */
.status-active,
.status-success { background: #c6f6d5; color: #22543d; }
.status-insufficient_funds { background: #fed7d7; color: #c53030; }
.status-suspended { background: #fbb6ce; color: #97266d; }
.status-failed { background: #fed7d7; color: #c53030; }

/* Add more custom components as needed… */

/* ------------------------ Media Queries ---------------------------- */
@media (max-width: 768px) {
  .header-content { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .login-card { padding: 25px; }
  .stat-content h3 { font-size: 1.5rem; }
}
/* ------------------------- Tab Content / Card Layout ------------------------- */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 15px;
  padding: 25px;
  margin-bottom: 30px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.card-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2d3748;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-body {
  overflow-x: auto;
}

/* ------------------------- Table Styles ------------------------- */
.table-container {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead {
  background: #edf2f7;
}
.data-table th,
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  text-align: left;
}
.data-table th {
  font-weight: 600;
  color: #4a5568;
}
.data-table td {
  color: #2d3748;
}
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

/* ------------------------- Filters ------------------------- */
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.filter-controls select,
.filter-controls input[type="date"] {
  padding: 8px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  font-size: 14px;
}

/* ------------------------- Visualization ------------------------- */
.visualization-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.account-projection {
  background: #fff;
  border-radius: 10px;
  border-left: 6px solid #cbd5e0;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.account-projection.healthy { border-left-color: #48bb78; }
.account-projection.warning { border-left-color: #ed8936; }
.account-projection.danger  { border-left-color: #f56565; }

.projection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.months-badge {
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 8px;
  font-weight: 600;
}
.months-badge.healthy { background: #c6f6d5; color: #22543d; }
.months-badge.warning { background: #fefcbf; color: #744210; }
.months-badge.danger  { background: #fed7d7; color: #822727; }

.projection-details {
  font-size: 13px;
  color: #4a5568;
  margin-bottom: 10px;
}
.projection-months {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.month-projection {
  background: #f7fafc;
  border-radius: 8px;
  padding: 10px;
  flex: 1 1 100px;
  text-align: center;
}
.month-title {
  font-weight: bold;
  font-size: 13px;
}
.month-balance {
  font-size: 13px;
  color: #2d3748;
}
.month-status.success { color: #48bb78; }
.month-status.danger { color: #f56565; }

/* ------------------------- Modal ------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  padding: 20px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2d3748;
}
.modal-close {
  font-size: 1.5rem;
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  transition: .2s;
}
.modal-close:hover {
  color: #f56565;
}
