/* Global Styles */
:root {
  --primary-color: #4361ee;
  --secondary-color: #3f37c9;
  --success-color: #4bb543;
  --danger-color: #ff4444;
  --warning-color: #f57c00; /* For excused absences */
  --light-color: #f8f9fa;
  --dark-color: #212529;
  --gray-color: #6c757d;
  --border-radius: 12px;
  --small-border-radius: 8px;
  --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --light-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s ease;
  --header-height: 60px;
  --bottom-nav-height: 70px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
  position: relative;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* App Container */
#mainApp {
  background-color: #f8f9fa;
  min-height: 100vh;
}

.app-container {
  max-width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  background-color: #fff;
}

/* Header - Mobile First */
.app-header {
  background: var(--light-color);
  color: var(--dark-color);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  height: var(--header-height);
  min-height: var(--header-height);
  border-bottom: 1px solid #e8ecf4;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.desktop-nav {
    display: none; /* Hidden on mobile by default */
    gap: 0.5rem;
}

#menu-btn {
  color: var(--dark-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#notification-btn {
    position: relative;
    color: var(--dark-color);
}

.notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    border: 2px solid var(--light-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
}

#userEmail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
  font-weight: 500;
}

.logout-btn {
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: var(--small-border-radius);
  transition: var(--transition);
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.logout-btn:hover, .logout-btn:active {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Auth Section Styles */
#authSection {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  background-color: var(--light-color);
  z-index: 10;
}

#authSection.active {
  display: flex;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  backdrop-filter: blur(10px);
}

.auth-title {
  text-align: center;
  color: var(--dark-color);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo i {
  font-size: 3.5rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.logo h1 {
  font-size: 2rem;
  color: var(--dark-color);
  font-weight: 700;
}

#loginSection {
  display: block;
}

#registerSection {
  display: none;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 1rem;
  color: var(--gray-color);
}

.auth-switch a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.form-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #aaa;
    margin: 1rem 0;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ddd;
}

.form-divider:not(:empty)::before {
    margin-right: .5em;
}

.form-divider:not(:empty)::after {
    margin-left: .5em;
}

.form-notice {
    font-size: 0.85rem;
    color: var(--gray-color);
    text-align: center;
    margin-top: 1.5rem;
    line-height: 1.4;
}

.form-extra-links {
    text-align: right;
    margin-bottom: 1.5rem;
    margin-top: -0.5rem;
}

.forgot-password-link {
    color: var(--gray-color);
    font-size: 0.9rem;
    text-decoration: none;
    font-weight: 500;
}

.forgot-password-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Main Content */
main {
  padding: calc(var(--header-height) + 1.5rem) 1.5rem calc(var(--bottom-nav-height) + 1.5rem);
  min-height: 100vh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* Forms - Mobile Optimized */
.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark-color);
  font-size: 1rem;
}

.input-group i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-color);
  font-size: 1.1rem;
  z-index: 2;
}

.input-description {
    font-size: 0.85rem;
    color: var(--gray-color);
    margin-top: 0.5rem;
    margin-left: 0.25rem;
    padding: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="month"],
input[type="date"],
select {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 2px solid #e8ecf4;
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  background-color: #fafbfc;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  min-height: 52px;
  font-weight: 500;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
  background-color: white;
}

input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

/* Buttons - Mobile First */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  gap: 0.5rem;
  min-width: 120px;
  min-height: 48px;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  box-shadow: var(--light-shadow);
}

.primary-btn:hover, .primary-btn:active {
  transform: translateY(-2px);
  box-shadow: var(--box-shadow);
}

.secondary-btn {
  background-color: #f1f3f4;
  color: var(--dark-color);
  border: 2px solid #e8ecf4;
}

.secondary-btn:hover, .secondary-btn:active {
  background-color: #e8ecf4;
  border-color: #d1d5db;
}

.danger-btn {
  background: linear-gradient(135deg, var(--danger-color), #e63939);
  color: white;
  box-shadow: var(--light-shadow);
}

.danger-btn:hover, .danger-btn:active {
  transform: translateY(-2px);
  box-shadow: var(--box-shadow);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 50%;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover, .icon-btn:active {
  background-color: rgba(67, 97, 238, 0.1);
}

.icon-btn.danger {
  color: var(--danger-color);
}

/* Receipt Modal Styles */
.receipt-content {
    border: 1px solid #eee;
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    color: #333;
    background-color: #fdfdfd;
}

.receipt-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px dashed #ccc;
    padding-bottom: 10px;
}

.receipt-header h4 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.receipt-header p {
    margin: 5px 0 0;
    font-size: 0.9rem;
}

.receipt-body p {
    margin: 10px 0;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
}

.receipt-body p strong {
    font-weight: bold;
    margin-right: 10px;
}

.receipt-body hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 15px 0;
}

.receipt-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 2px dashed #ccc;
    font-size: 0.8rem;
}

.icon-btn.danger:hover, .icon-btn.danger:active {
  background-color: rgba(255, 68, 68, 0.1);
}

/* Info Card */
.info-card {
    position: relative;
    background-color: var(--light-color);
    border: 1px solid #e8ecf4;
    margin-bottom: 2rem;
}

.info-card-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gray-color);
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-card-close:hover {
    background-color: rgba(0,0,0,0.1);
}

.info-card p, .info-card li {
    color: var(--gray-color);
    font-size: 0.95rem;
}

.info-card strong {
    color: var(--dark-color);
}

body.dark-mode .info-card {
    background-color: #293548;
    border-color: #334155;
}

body.dark-mode .info-card strong {
    color: #cbd5e1;
}


/* Stats Grid - Mobile Optimized */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--light-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: var(--transition);
  border: 1px solid #f0f2f5;
}

.stat-card-link {
  text-decoration: none;
  color: inherit;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--box-shadow);
  border-color: var(--primary-color);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  margin-bottom: 1rem;
}

.stat-card h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  color: var(--dark-color);
}

.stat-card p {
  font-size: 0.9rem;
  color: var(--gray-color);
  margin: 0;
  font-weight: 500;
}

/* Quick Actions - Mobile Grid */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.action-btn {
  background: white;
  border: 2px solid #f0f2f5;
  padding: 1.5rem;
  border-radius: var(--border-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  box-shadow: var(--light-shadow);
  font-size: 1rem;
  color: var(--dark-color);
  transition: var(--transition);
  min-height: 100px;
  font-weight: 600;
}

.action-btn i {
  font-size: 1.5rem;
  color: var(--primary-color);
}

.action-btn:hover, .action-btn:active {
  background-color: #f8f9fa;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--box-shadow);
}

/* List Container */
.list-container {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--light-shadow);
  overflow: hidden;
  border: 1px solid #f0f2f5;
}

.list-item {
  padding: 1.25rem;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  min-height: 80px;
}

.list-item:hover, .list-item:active {
  background-color: #f8f9fa;
}

.list-item:last-child {
  border-bottom: none;
}

/* Weekday Picker Styles */
.weekday-picker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    border: 1px solid #e8ecf4;
    border-radius: 8px;
    margin-top: 5px;
}

.weekday-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.list-item-info h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark-color);
}

.list-item-info p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--gray-color);
  font-weight: 500;
}

.list-item-actions {
  display: flex;
  gap: 0.5rem;
}

/* Bottom Navigation - Enhanced Mobile */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  justify-content: space-around;
  padding: 0.75rem 0 1rem 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  height: var(--bottom-nav-height);
  border-top: 1px solid #f0f2f5;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--gray-color);
  font-size: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: var(--small-border-radius);
  transition: var(--transition);
  cursor: pointer;
  font-weight: 600;
  min-width: 60px;
}

.nav-item i {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.nav-item.active {
  color: var(--primary-color);
  background-color: rgba(67, 97, 238, 0.1);
}

.nav-item:hover, .nav-item:active {
  color: var(--primary-color);
  background-color: rgba(67, 97, 238, 0.05);
}

/* Page Header - Mobile Optimized */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f2f5;
  position: relative; /* For back button positioning */
  padding-left: 40px; /* Make space for the back button */
}

.page-header h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--dark-color);
  letter-spacing: -0.02em;
  text-align: center;
  flex-grow: 1;
}

.back-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-color);
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.back-btn:hover {
    background-color: rgba(0,0,0,0.05);
}

.page-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Form Container */
.form-container {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
  box-shadow: var(--light-shadow);
  border: 1px solid #f0f2f5;
  max-width: 700px; /* Add max-width for better readability on large screens */
}

@media (min-width: 768px) {
  #addGroupForm {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem; /* 0 for row gap, 1.5rem for column gap */
  }

  #addGroupForm h3,
  #addGroupForm .form-actions {
    grid-column: 1 / -1; /* Span full width */
  }
}

.form-container h3 {
  margin: 0 0 1.5rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark-color);
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* Modal Styles - Mobile First */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background-color: #fff;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--box-shadow);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 2px solid #f0f2f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafbfc;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dark-color);
}

.modal-header .modal-close {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-color);
  padding: 0.5rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header .modal-close:hover, .modal-header .modal-close:active {
  background-color: rgba(0, 0, 0, 0.05);
}

.modal-content p {
  padding: 1.5rem;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--dark-color);
}

.modal-content form {
  padding: 1.5rem;
}

/* Payment Item Styles - Mobile Enhanced */
.payment-item {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: white;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  box-shadow: var(--light-shadow);
  gap: 1rem;
  border: 1px solid #f0f2f5;
  transition: var(--transition);
}

.payment-item:hover {
  box-shadow: var(--box-shadow);
  border-color: var(--primary-color);
}

.payment-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.payment-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--small-border-radius);
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.payment-info {
  flex: 1;
  min-width: 0;
}

.payment-info h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark-color);
  word-wrap: break-word;
}

.payment-date {
  color: var(--gray-color);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.payment-amount-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.payment-amount {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary-color);
}

.payment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.payment-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(67, 97, 238, 0.1);
  color: var(--primary-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--small-border-radius);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.payment-actions {
  display: flex;
  gap: 0.75rem;
}

.payment-action-btn {
  background: none;
  border: 2px solid #f0f2f5;
  color: var(--gray-color);
  width: 44px;
  height: 44px;
  border-radius: var(--small-border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.1rem;
}

.payment-action-btn:hover, .payment-action-btn:active {
  background: #f8f9fa;
  border-color: #d1d5db;
}

.payment-action-btn.delete:hover, .payment-action-btn.delete:active {
  color: var(--danger-color);
  background: rgba(255, 68, 68, 0.1);
  border-color: var(--danger-color);
}

/* Toast Notifications - Mobile Enhanced */
.verification-banner {
    background-color: #ffc107;
    color: #333;
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.verification-banner .btn-small {
    padding: 4px 8px;
    font-size: 0.8rem;
    background-color: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 1rem);
  left: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
    background-color: #6c757d; /* Default to offline */
}

.status-indicator.online {
    background-color: #28a745; /* green */
}

.status-indicator.offline {
    background-color: #6c757d; /* grey */
}

.status-text-online {
    color: #28a745;
    font-weight: 600;
}

.status-text-offline {
    color: #6c757d;
}

.status-text-disabled {
    color: #dc3545;
    font-weight: 600;
}

.toast {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  pointer-events: none;
  border: 1px solid #f0f2f5;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast-icon {
  margin-right: 0.75rem;
  font-size: 1.25rem;
}

.toast.success {
  border-left: 4px solid var(--success-color);
}

.toast.success .toast-icon {
  color: var(--success-color);
}

.toast.error {
  border-left: 4px solid var(--danger-color);
}

.toast.error .toast-icon {
  color: var(--danger-color);
}

.toast.info {
  border-left: 4px solid var(--primary-color);
}

.toast.info .toast-icon {
  color: var(--primary-color);
}

.toast-message {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
  color: var(--dark-color);
}

/* Attendance Styles - Mobile Enhanced */
.attendance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  background: white;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  box-shadow: var(--light-shadow);
  gap: 1rem;
  border: 1px solid #f0f2f5;
  transition: var(--transition);
}

.attendance-item:hover {
  box-shadow: var(--box-shadow);
  border-color: var(--primary-color);
}

.attendance-info {
  flex: 1;
  min-width: 0;
}

.attendance-info h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark-color);
  word-wrap: break-word;
}

.attendance-info p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--gray-color);
  font-weight: 500;
}

.attendance-status {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.attendance-status-text {
  font-size: 0.9rem;
  color: var(--gray-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  min-width: 70px;
}

.attendance-status-text i {
  font-size: 1rem;
}

/* Switch - Enhanced for Mobile */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--success-color);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Filters - Mobile Optimized */
.filters {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.filters .input-group {
  margin-bottom: 0;
}

.filters select {
  padding: 1rem;
  font-size: 1.1rem;
}

/* Loading State */
.loading {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--gray-color);
  font-size: 1.1rem;
  font-weight: 500;
}

.loading i {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

/* Error State */
.error {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--danger-color);
  font-size: 1.1rem;
  font-weight: 500;
}

.error i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
  :root {
    --header-height: 56px;
    --bottom-nav-height: 65px;
  }

  .app-header {
    padding: 0.75rem 1rem;
    height: var(--header-height);
  }

  .app-header h1 {
    font-size: 1.25rem;
  }

  .user-info {
    font-size: 0.9rem;
    gap: 0.5rem;
  }

  #userEmail {
    max-width: 100px;
    font-size: 0.85rem;
  }

  .logout-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  main {
    padding: calc(var(--header-height) + 1rem) 1rem calc(var(--bottom-nav-height) + 1rem);
  }

  .auth-container {
    padding: 2rem 1.5rem;
  }

  .auth-title {
    font-size: 1.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .stat-card h3 {
    font-size: 1.25rem;
  }

  .stat-card p {
    font-size: 0.8rem;
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .action-btn {
    padding: 1rem;
    font-size: 0.9rem;
    min-height: 80px;
  }

  .action-btn i {
    font-size: 1.25rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-header h2 {
    font-size: 1.5rem;
  }

  .form-container {
    padding: 1.5rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .input-group i {
    left: 0.75rem;
  }

  input, select {
    padding: 0.875rem 0.875rem 0.875rem 2.75rem;
    font-size: 1rem;
    min-height: 48px;
  }

  .btn {
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    min-height: 44px;
  }

  .attendance-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .attendance-status {
    width: 100%;
    justify-content: space-between;
  }

  .payment-item {
    padding: 1rem;
  }

  .payment-header {
    gap: 0.75rem;
  }

  .payment-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .payment-info h4 {
    font-size: 1rem;
  }

  .payment-amount {
    font-size: 1rem;
  }

  .payment-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .payment-tag {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }

  .modal-content {
    border-radius: 16px 16px 0 0;
  }

  .modal-header {
    padding: 1.25rem;
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }

  .modal-content p {
    padding: 1.25rem;
    font-size: 1rem;
  }

  .modal-content form {
    padding: 1.25rem;
  }

  .bottom-nav {
    padding: 0.5rem 0 0.75rem 0;
    height: var(--bottom-nav-height);
  }

  .nav-item {
    font-size: 0.7rem;
    padding: 0.4rem 0.75rem;
  }

  .nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
  }

  .toast-container {
    top: calc(var(--header-height) + 0.75rem);
    left: 0.75rem;
    right: 0.75rem;
  }

  .toast {
    padding: 0.875rem 1rem;
  }

  .toast-message {
    font-size: 0.9rem;
  }

  .filters {
    gap: 0.75rem;
  }
}

/* Medium Mobile Devices (481px - 600px) */
@media (min-width: 481px) and (max-width: 600px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .filters {
    flex-direction: row;
    gap: 1rem;
  }

  .filters .input-group {
    flex: 1;
  }

  .filters select {
    flex: 0 0 140px;
  }

  .attendance-item {
    flex-direction: row;
    align-items: center;
  }

  .attendance-status {
    width: auto;
  }

  .payment-meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* Tablet and Desktop (601px+) */
@media (min-width: 601px) {
  .app-container {
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--box-shadow);
  }

  main {
    padding: calc(var(--header-height) + 2rem) 2rem calc(var(--bottom-nav-height) + 2rem);
  }

  .auth-container {
    max-width: 450px;
    padding: 3rem 2.5rem;
  }

  .auth-title {
    font-size: 2.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .stat-card {
    padding: 2rem;
  }

  .stat-icon {
    width: 56px;
    height: 56px;
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
  }

  .stat-card h3 {
    font-size: 1.75rem;
  }

  .stat-card p {
    font-size: 1rem;
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }

  .action-btn {
    padding: 2rem;
    min-height: 120px;
    font-size: 1.1rem;
  }

  .action-btn i {
    font-size: 1.75rem;
  }

  .page-header {
    flex-direction: row;
    align-items: center;
  }

  .page-header h2 {
    font-size: 2rem;
  }

  .form-container {
    padding: 2.5rem;
  }

  .form-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .form-actions .btn {
    width: auto;
    min-width: 140px;
  }

  .filters {
    flex-direction: row;
    gap: 1.5rem;
  }

  .filters .input-group {
    flex: 1;
    max-width: 300px;
  }

  .filters select {
    flex: 0 0 160px;
  }

  .modal {
    align-items: center;
    justify-content: center;
  }

  .modal-content {
    width: 90%;
    max-width: 500px;
    border-radius: var(--border-radius);
    transform: scale(0.9);
  }

  .modal.show .modal-content {
    transform: scale(1);
  }

  .modal-header {
    padding: 2rem;
  }

  .modal-header h3 {
    font-size: 1.5rem;
  }

  .modal-content p {
    padding: 2rem;
    font-size: 1.1rem;
  }

  .modal-content form {
    padding: 2rem;
  }

  .payment-item {
    padding: 2rem;
  }

  .payment-header {
    gap: 1.25rem;
  }

  .payment-avatar {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }

  .payment-info h4 {
    font-size: 1.3rem;
  }

  .payment-amount {
    font-size: 1.3rem;
  }

  .payment-meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .attendance-item {
    padding: 1.75rem;
  }

  .attendance-info h4 {
    font-size: 1.2rem;
  }

  .attendance-info p {
    font-size: 1rem;
  }

  .bottom-nav {
    max-width: 800px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    bottom: 0;
    padding: 1rem 0;
  }

  .nav-item {
    font-size: 0.9rem;
    padding: 0.75rem 1.25rem;
  }

  .nav-item i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .toast-container {
    right: calc(50% - 400px + 2rem);
    left: auto;
    width: 350px;
  }

  .toast {
    padding: 1.25rem 1.5rem;
  }

  .toast-message {
    font-size: 1rem;
  }
}

/* Tablet and Desktop (768px+) */
@media (min-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  /* Hide mobile-only controls */
  #menu-btn,
  .bottom-nav:not(#admin-bottom-nav), /* Keep admin bottom nav separate */
  .sidebar-header,
  #sidebar-overlay,
  #close-sidebar-btn {
    display: none !important;
  }

  .desktop-nav {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 0.5rem; /* Add gap between nav items */
  }

  .desktop-nav .nav-item {
    flex-direction: row;
    padding: 0.75rem 1.25rem; /* Increase padding for a better look */
    font-size: 0.95rem; /* Slightly smaller font for balance */
    height: auto; /* Auto height based on content */
    border-radius: var(--small-border-radius); /* Add border radius */
    background-color: transparent;
    color: var(--gray-color);
    border: 2px solid transparent; /* Add transparent border for hover effect */
    gap: 0.75rem; /* Space between icon and text */
    align-items: center;
  }

  .desktop-nav .nav-item:hover {
    background-color: rgba(67, 97, 238, 0.05);
    color: var(--primary-color);
  }

  .desktop-nav .nav-item.active {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    font-weight: 600;
  }

  .desktop-nav .nav-item i {
    display: inline-block; /* Make icons visible */
    font-size: 1.1rem; /* Adjust icon size */
  }

  .app-header {
    justify-content: space-between;
  }

  /* .back-btn is intentionally not hidden on desktop per user request */

  /* --- Layout --- */
  .sidebar {
    left: 0 !important; /* This is the definitive fix */
    transform: none !important;
    width: var(--sidebar-width);
    transition: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    border-right: 1px solid #e8ecf4;
    padding-top: 1.5rem;
  }

  body.dark-mode .sidebar {
      background-color: #1e293b; /* Explicitly set dark background to avoid confusion */
      border-right: 1px solid #334155;
  }

  .app-header {
    position: fixed;
    width: calc(100% - var(--sidebar-width));
    left: var(--sidebar-width);
    border-bottom: 1px solid #e8ecf4;
  }

  body.dark-mode .app-header {
      border-bottom: 1px solid #334155;
  }

  main {
    margin-left: var(--sidebar-width);
    padding: calc(var(--header-height) + 2rem) 2.5rem 2rem;
    width: calc(100% - var(--sidebar-width));
    height: 100vh;
    overflow-y: auto;
  }

  /* --- Component Adjustments --- */
  .page-header {
    padding-left: 0;
  }

  /* .back-btn is intentionally not hidden on desktop per user request */

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem; /* Increased gap */
  }

  .quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  #toastContainer {
      left: auto;
      right: 2.5rem;
      width: 400px;
      bottom: 2.5rem;
      top: auto;
  }

  .modal-content {
      max-width: 600px;
  }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

.rounded { border-radius: var(--small-border-radius); }
.rounded-lg { border-radius: var(--border-radius); }
.rounded-full { border-radius: 50%; }

.shadow { box-shadow: var(--light-shadow); }
.shadow-lg { box-shadow: var(--box-shadow); }

.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-gray { color: var(--gray-color); }
.text-dark { color: var(--dark-color); }

.warning-text {
    color: #ff9800; /* A nice amber/orange color for warnings */
    font-weight: 600;
}

.warning-text .fas {
    margin-right: 0.5rem;
}

.bg-primary { background-color: var(--primary-color); }
.bg-success { background-color: var(--success-color); }
.bg-danger { background-color: var(--danger-color); }
.bg-light { background-color: var(--light-color); }
.bg-white { background-color: white; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Focus Styles for Accessibility */
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
.nav-item:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Animation Classes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* Tailwind-like utility classes for new components */
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.bg-gray-600 { background-color: #4a5568; }
.bg-opacity-50 { background-color: rgba(74, 85, 104, 0.5); }
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.z-50 { z-index: 50; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.p-6 { padding: 1.5rem; }
.justify-between { justify-content: space-between; }
.text-xl { font-size: 1.25rem; }
.font-semibold { font-weight: 600; }
.text-gray-800 { color: #2d3748; }
.text-gray-400 { color: #a0aec0; }
.hover\:text-gray-600:hover { color: #718096; }
.text-gray-600 { color: #718096; }
.block { display: block; }
.text-sm { font-size: 0.875rem; }
.font-medium { font-weight: 500; }
.mb-1 { margin-bottom: 0.25rem; }
.mt-1 { margin-top: 0.25rem; }
.border { border-width: 1px; }
.border-gray-300 { border-color: #d2d6dc; }
.rounded-md { border-radius: 0.375rem; }
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }
.focus\:ring-indigo-500:focus { --tw-ring-opacity: 1; ring-color: rgba(99, 102, 241, var(--tw-ring-opacity)); box-shadow: 0 0 0 3px var(--tw-ring-color); }
.focus\:border-indigo-500:focus { border-color: #6366f1; }
.justify-end { justify-content: flex-end; }
.bg-gray-300 { background-color: #d2d6dc; }
.hover\:bg-gray-400:hover { background-color: #b0b6bf; }
.bg-indigo-600 { background-color: #4f46e5; }
.hover\:bg-indigo-700:hover { background-color: #4338ca; }
.text-white { color: #fff; }

/*
--- Dark Mode Styles ---
*/

/* Add transitions for smooth theme switching */
body, .app-header, .stat-card, .action-btn, .list-item, .modal-content, .sidebar, .auth-container, input, select, .btn, .payment-item, .toast {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode {
  --light-color: #1e293b; /* slate-800 */
  --dark-color: #f1f5f9; /* slate-100 */
  --gray-color: #94a3b8; /* slate-400 */

  background-color: #0f172a; /* slate-900 */
  color: var(--dark-color);
}

body.dark-mode .app-header {
  background: var(--light-color);
  border-bottom: 1px solid #334155; /* slate-700 */
}

body.dark-mode .sidebar {
  background: var(--light-color);
}

body.dark-mode .bottom-nav {
  background: var(--light-color);
  border-top: 1px solid #334155; /* slate-700 */
}

body.dark-mode .auth-container,
body.dark-mode .stat-card,
body.dark-mode .form-container,
body.dark-mode .list-item,
body.dark-mode .payment-item,
body.dark-mode .card,
body.dark-mode .modal-content {
  background-color: #293548; /* A bit lighter than main bg */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: #334155; /* slate-700 */
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 {
  color: var(--dark-color);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background-color: #334155; /* slate-700 */
  color: var(--dark-color);
  border-color: #475569; /* slate-600 */
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  background-color: #3b4a5f;
  border-color: var(--primary-color);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #94a3b8; /* slate-400 */
}

body.dark-mode .secondary-btn {
  background-color: #475569;
  color: var(--dark-color);
  border-color: #64748b;
}

body.dark-mode .secondary-btn:hover {
  background-color: #64748b;
  border-color: #94a3b8;
}

body.dark-mode .list-item:hover {
  background-color: #334155;
}

body.dark-mode .nav-item {
  color: var(--gray-color);
}

body.dark-mode .nav-item.active {
  color: var(--primary-color);
  background-color: rgba(67, 97, 238, 0.15);
}

body.dark-mode .toast {
  background-color: #334155;
  border-color: #475569;
}

/* --- Ledger Table Styles --- */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--light-shadow);
}

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.ledger-table th, .ledger-table td {
    padding: 0.8rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.ledger-table th:last-child, .ledger-table td:last-child {
    border-right: none;
}
.ledger-table tbody tr:last-child td {
    border-bottom: none;
}


.ledger-table th {
    background-color: #fafbfc;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ledger-table td:first-child, .ledger-table th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background-color: #fafbfc;
    z-index: 20;
    border-right: 2px solid #e0e0e0;
}

.ledger-table td div:last-child {
    font-size: 0.8rem;
    color: var(--gray-color);
    border-top: 1px solid rgba(0,0,0,0.05);
    margin-top: 0.25rem;
    padding-top: 0.25rem;
}

.ledger-table .status-paid { background-color: #e8f5e9; }
.ledger-table .status-unpaid { background-color: #ffebee; }
.ledger-table .status-partial { background-color: #fff3e0; }
.ledger-table .status-zero { background-color: #f5f5f5; color: #9e9e9e; }

body.dark-mode .table-container {
    border-color: #334155;
}
body.dark-mode .ledger-table th,
body.dark-mode .ledger-table td:first-child,
body.dark-mode .ledger-table th:first-child {
    background-color: #293548;
    border-color: #334155;
}
body.dark-mode .ledger-table td {
    border-color: #334155;
}
body.dark-mode .ledger-table .status-paid { background-color: rgba(40, 167, 69, 0.2); }
body.dark-mode .ledger-table .status-unpaid { background-color: rgba(220, 53, 69, 0.2); }
body.dark-mode .ledger-table .status-partial { background-color: rgba(255, 193, 7, 0.2); }
body.dark-mode .ledger-table .status-zero { background-color: rgba(75, 85, 99, 0.2); }

/* New Attendance Status Styles */
.attendance-status-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.attendance-status-tag {
    padding: 0.4rem 0.8rem;
    border-radius: var(--small-border-radius);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease-in-out;
    user-select: none;
}

.attendance-status-tag:not(.active):hover {
    transform: translateY(-2px);
}

.attendance-status-tag.status-present {
    background-color: #e8f5e9;
    color: var(--success-color);
}
.attendance-status-tag.status-present.active {
    background-color: var(--success-color);
    color: white;
    box-shadow: 0 2px 5px rgba(75, 181, 67, 0.4);
}

.attendance-status-tag.status-absent {
    background-color: #ffebee;
    color: var(--danger-color);
}
.attendance-status-tag.status-absent.active {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 2px 5px rgba(255, 68, 68, 0.4);
}

.attendance-status-tag.status-excused {
    background-color: #fff3e0;
    color: var(--warning-color);
}
.attendance-status-tag.status-excused.active {
    background-color: var(--warning-color);
    color: white;
    box-shadow: 0 2px 5px rgba(245, 124, 0, 0.4);
}

.attendance-status-tag.status-unknown {
    background-color: #f5f5f5;
    color: var(--gray-color);
    cursor: default;
}

.attendance-reason {
    font-size: 0.85rem;
    color: var(--gray-color);
    margin-top: 0.5rem;
    padding-left: 0.25rem;
    display: block;
    font-style: italic;
}

.attendance-reason i {
    margin-right: 0.25rem;
}

/* --- Debt Filter Logic for Group Details --- */
.student-table.filter-debtors-active tbody tr {
    display: none;
}

.student-table.filter-debtors-active tbody tr[data-has-debt="true"] {
    display: table-row;
}

/* --- Student Table Styles --- */
.student-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.student-table th,
.student-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f0f2f5;
    border-right: 1px solid #f0f2f5;
}

.student-table th:last-child,
.student-table td:last-child {
    border-right: none;
}

.student-table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: #fafbfc;
    color: var(--gray-color);
}

.student-table tbody tr:hover {
    background-color: #f8f9fa;
}

.student-table .list-item-actions {
    justify-content: flex-end;
}

body.dark-mode .student-table th {
    background-color: #293548;
    border-bottom-color: #334155;
}

body.dark-mode .student-table td {
    border-bottom-color: #334155;
}

body.dark-mode .student-table tbody tr:hover {
    background-color: #334155;
}

/* Text-based status styles for tables */
.status-present {
    color: var(--success-color);
    font-weight: 600;
}
.status-absent {
    color: var(--danger-color);
    font-weight: 600;
}
.status-unknown {
    color: var(--gray-color);
}


/* Responsive Table for Mobile */
@media (max-width: 767px) {
    #studentsList {
        background-color: transparent;
        box-shadow: none;
        border: none;
    }

    .student-table,
    .student-table thead,
    .student-table tbody,
    .student-table th,
    .student-table td,
    .student-table tr {
        display: block;
    }

    .student-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .student-table tr {
        background: white;
        border-radius: var(--border-radius);
        margin-bottom: 1rem;
        box-shadow: var(--light-shadow);
        border: 1px solid #f0f2f5;
    }

    .student-table td {
        border: none;
        border-bottom: 1px solid #f0f2f5;
        position: relative;
        padding-left: 50%;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .student-table td:last-child {
        border-bottom: none;
    }

    .student-table td:before {
        position: absolute;
        top: 50%;
        left: 1rem;
        transform: translateY(-50%);
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        content: attr(data-label);
        font-weight: 600;
        color: var(--dark-color);
    }

    .student-table td .list-item-actions {
        justify-content: flex-start;
        margin-left: auto;
    }

    body.dark-mode .student-table tr {
        background-color: #293548;
        border-color: #334155;
    }

    body.dark-mode .student-table td {
        border-bottom-color: #334155;
    }

    body.dark-mode .student-table td:before {
        color: var(--dark-color);
    }
}

body.dark-mode .toast-message {
  color: var(--dark-color);
}

body.dark-mode #mainApp {
  background-color: #0f172a; /* slate-900 */
}


/* Sidebar Menu */
.sidebar {
  position: fixed;
  top: 0;
  left: -300px; /* Hidden by default */
  width: 300px;
  max-width: 90%;
  height: 100vh;
  background-color: var(--light-color);
  z-index: 1050;
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  transition: left 0.3s ease-in-out;
  transform: none;
}

.sidebar.show {
  left: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f0f2f5;
  min-height: var(--header-height);
  /* The background is inherited from .sidebar, which is theme-aware */
  color: var(--dark-color);
}

.sidebar-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  color: var(--dark-color);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  border-bottom: none;
  transition: background-color 0.2s ease;
}

.sidebar-item:hover {
  background-color: rgba(67, 97, 238, 0.1);
  color: var(--primary-color);
}

.sidebar-item.active {
  background-color: rgba(67, 97, 238, 0.15);
  border-left: 4px solid var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
}

.permissions-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.permission-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--small-border-radius);
    background-color: #f8f9fa;
}

.permission-item label:first-child {
    font-weight: 500;
}

/* Specific styles for the user list in the admin panel */
.user-list-item {
    gap: 1rem;
}

.user-list-item .list-item-info {
    flex-grow: 1;
    min-width: 0; /* Prevents long emails from breaking layout */
}

.user-list-item .list-item-info h4 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-list-item .list-item-actions .btn {
    width: 150px;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .list-item .list-item-actions {
        width: 100%;
        margin-top: 1rem;
    }

    .list-item .list-item-actions .btn {
        flex-grow: 1; /* Make buttons take equal width */
        justify-content: center;
    }

    .user-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-list-item .list-item-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .user-list-item .list-item-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (min-width: 768px) {
    .user-list-item .list-item-info {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem 1.5rem;
        align-items: center;
    }

    .user-list-item .list-item-info h4 {
        grid-column: 1 / -1; /* Title spans both columns */
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 600px) {
    .user-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-list-item .list-item-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .user-list-item .list-item-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

.sidebar-item i {
  width: 24px;
  text-align: center;
  color: var(--gray-color);
  font-size: 1.2rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* Verification Page Styles */
.verification-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100vh;
    padding: 2rem;
    background-color: #f0f2f5;
}

.verification-box {
    background: #fff;
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 450px;
    width: 100%;
}

.verification-box i {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 1.5rem;
}

.verification-box h2 {
    margin-bottom: 1rem;
    font-size: 2rem;
}

.verification-box p {
    font-size: 1.1rem;
    color: var(--gray-color);
}

/* --- Report Filtering --- */
.stat-card-link {
    text-decoration: none;
}

.stat-card-link .stat-card {
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent;
}

.stat-card-link.active-filter .stat-card {
    border: 2px solid var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.verification-box .btn {
    margin-top: 2rem;
}

/* Pull to Refresh Styles */
.ptr-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transform: translateY(-60px);
    transition: transform 0.3s ease;
}

.ptr-spinner {
    width: 30px;
    height: 30px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--dark-color);
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.ptr-container.refreshing .ptr-spinner {
    animation: ptr-spin 1s infinite linear;
}

@keyframes ptr-spin {
    to {
        transform: rotate(360deg);
    }
}



/* This override is no longer needed with the new theme-color meta tag and body background logic. */

/* Styles for Roles Page */
.roles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}
@media (min-width: 768px) {
    .roles-grid {
        grid-template-columns: 1fr 2fr;
        align-items: flex-start;
    }
}
.role-item.active {
    background-color: var(--primary-color) !important;
    color: white;
    border-left: 4px solid var(--secondary-color);
}
.role-item.active h4 {
    color: white;
}
.permissions-form .permission-category {
    margin-bottom: 1.5rem;
}
.permissions-form .permission-category h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f0f2f5;
}
body.dark-mode .permissions-form .permission-category h3 {
    border-bottom-color: #334155;
}
body.dark-mode .role-item.active h4 {
    color: white;
}
.permission-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
}
.permission-item label:first-of-type {
    font-weight: 500;
}
.card-header .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: auto;
}

/* Collapsible Info Card Styles */
.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-top: none;
}

.collapsible-content.show {
    max-height: 1000px; /* Large enough to fit any content */
    transition: max-height 0.5s ease-in, padding 0.3s ease-in;
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
    border-top: 1px solid var(--border-color);
}

/* Invoice and Status Styles */
.status-badge {
  padding: 0.4rem 0.8rem;
  border-radius: var(--small-border-radius);
  font-weight: 600;
  font-size: 0.9rem;
  color: white;
  text-align: center;
  white-space: nowrap;
}

.status-paid {
  background-color: var(--success-color);
}

.status-unpaid {
  background-color: var(--danger-color);
}

.status-overdue {
  background-color: #f57c00; /* Darker Orange */
}

.status-void {
  background-color: var(--gray-color);
}

/* Row-level status coloring */
.list-item.status-paid {
    background-color: #e8f5e9; /* Light Green */
    border-left: 5px solid var(--success-color);
}
.list-item.status-unpaid {
    background-color: #ffebee; /* Light Red */
    border-left: 5px solid var(--danger-color);
}
.list-item.status-overdue {
    background-color: #fff3e0; /* Light Orange */
    border-left: 5px solid #f57c00;
}
.list-item.status-void {
    background-color: #f5f5f5; /* Light Gray */
    border-left: 5px solid var(--gray-color);
}

.input-group-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 2px solid #e8ecf4;
  border-radius: var(--border-radius);
  background-color: #fafbfc;
}

.input-group-checkbox input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 0.25rem;
  width: 18px;
  height: 18px;
}

.input-group-checkbox label {
  font-weight: 600;
  color: var(--dark-color);
}

.input-group-checkbox .input-description {
  margin-top: 0.25rem;
}

body.dark-mode .input-group-checkbox {
  background-color: #334155;
  border-color: #475569;
}
