:root {
  --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card: #ffffff;
  --text: #1a202c;
  --muted: #718096;
  --border: #e2e8f0;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  --sidebar-text: #e2e8f0;
  --sidebar-active: rgba(99, 102, 241, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.3s ease;
}

.container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.sidebar-footer {
  margin-top: auto;
  padding: 8px 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.powered-by {
  display: block;
  text-decoration: none;
  transition: opacity 0.2s;
}

.powered-by:hover {
  opacity: 0.8;
}

.powered-text {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.powered-by img {
  height: 24px;
  width: auto;
  display: block;
}

.powered-logo-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.powered-company {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  white-space: nowrap;
}

/* Footer Contact */
.footer-contact {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-name {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
  font-weight: 600;
}

.contact-phone {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-block;
}

.contact-phone:hover {
  color: #10b981;
  transform: scale(1.05);
}

.wa-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-right: 4px;
}

.brand {
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  display: block;
  cursor: pointer;
  transition: all 0.3s ease;
}

.brand:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.branch {
  color: var(--sidebar-text);
  font-size: 13px;
  margin-bottom: 24px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav a {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--sidebar-text);
  margin-bottom: 8px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.nav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(4px);
}

.nav a.active {
  background: var(--sidebar-active);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.nav a.active::before {
  transform: scaleY(1);
}

/* Sidebar User Info */
.sidebar-user {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.user-name {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}

.user-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: capitalize;
}

/* Branch Selector */
.branch-selector {
  margin-bottom: 24px;
  position: relative;
}

.branch-button {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.branch-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dropdown-arrow {
  font-size: 10px;
  transition: transform 0.3s ease;
}

.branch-button.active .dropdown-arrow {
  transform: rotate(180deg);
}

.branch-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.branch-dropdown.show {
  display: block;
}

.branch-dropdown form {
  display: flex;
  flex-direction: column;
}

.branch-option {
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}

.branch-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.branch-option.active {
  background: rgba(99, 102, 241, 0.15);
  color: #ffffff;
}

/* Sidebar Logout Button */
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #fca5a5;
  border-radius: 12px;
  color: #dc2626;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.3s ease;
  justify-content: center;
}

.sidebar-logout:hover {
  background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.content {
  padding: 24px;
  flex: 1;
}

/* Card Styles */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* Form Styles */
.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
  flex: 1;
}

.field label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

input,
select,
textarea {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  background: #fff;
  outline: none;
  font-size: 14px;
  transition: all 0.3s ease;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 12px 20px;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn.primary:hover {
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn.danger {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border-color: #fca5a5;
  color: #dc2626;
}

.btn.danger:hover {
  background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn.small {
  padding: 8px 16px;
  font-size: 13px;
}

/* Table Styles */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.table thead {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.table th {
  padding: 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background: #f8fafc;
  transform: scale(1.01);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  color: #4f46e5;
  font-size: 12px;
  font-weight: 600;
}

/* Alert */
.alert {
  padding: 16px 20px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  margin-bottom: 16px;
  color: #166534;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

/* Small Text */
.small {
  font-size: 13px;
  color: var(--muted);
}

/* Modal Styles */
.modal-dialog {
  border: none;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 0;
  min-width: 400px;
  max-width: 500px;
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin: auto;
  inset: 0;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  animation: backdropFadeIn 0.3s ease;
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Error Dialog - Always on top */
#errorDialog {
  z-index: 999999 !important;
}

#errorDialog::backdrop {
  z-index: 999998 !important;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.modal-content {
  padding: 0;
  font-family: inherit;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border-radius: 20px 20px 0 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.modal-header button {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  cursor: pointer;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--muted);
}

.modal-header button:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
  transform: rotate(90deg);
}

.modal-body {
  padding: 28px;
}

.modal-body p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
}

.modal-footer {
  padding: 20px 28px;
  text-align: right;
  background: #f8fafc;
  border-radius: 0 0 20px 20px;
  border-top: 1px solid var(--border);
}

/* Fieldset Styles */
fieldset {
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

fieldset legend {
  font-weight: 700;
  color: var(--text);
  padding: 0 12px;
  font-size: 16px;
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

/* Payment Filters */
.payment-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 10px 16px;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f1f5f9;
  color: #475569;
  font-family: inherit;
}

.filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.filter-btn.active {
  border-color: currentColor;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.filter-all.active {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border-color: #3b82f6;
}

.filter-overdue.active {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
  border-color: #dc2626;
}

.filter-today.active {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border-color: #f59e0b;
}

.filter-upcoming.active {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: #166534;
  border-color: #10b981;
}

/* Payment Status Badges */
.badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

/* --- MODERN UI COMPONENTS --- */

/* Modern Card */
.card-modern {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-modern:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Avatar Initials */
.avatar-initials {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.avatar-initials.large {
  width: 80px;
  height: 80px;
  font-size: 32px;
}

/* Status Tabs (Pill Shape) */
.status-tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.status-tab-item {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  border: none;
  background: transparent;
  display: inline-block;
}

.status-tab-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.5);
}

.status-tab-item.active {
  background: white;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Profile Header */
.profile-header {
  background: linear-gradient(135deg, var(--accent) 0%, #a855f7 100%);
  color: white;
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
  position: relative;
  overflow: hidden;
}

.profile-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.profile-info {
  position: relative;
  z-index: 1;
}

.profile-info h1 {
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 4px 0;
  letter-spacing: -0.5px;
}

.profile-stat-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Modern Input Group */
.input-group-modern {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  transition: all 0.2s;
  width: 100%;
}

.input-group-modern:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-group-modern input,
.input-group-modern select {
  border: none;
  background: transparent;
  padding: 8px;
  width: 100%;
  outline: none;
  font-size: 14px;
  color: var(--text);
}

/* Stats Grid used in Student Card */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.stat-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

/* Detail Sections */
.detail-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px;
}

/* Clean Table */
.table-clean {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-clean th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
}

.table-clean td {
  padding: 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table-clean tr:last-child td {
  border-bottom: none;
}

.table-clean tr:hover td {
  background: #f8fafc;
}

/* Tab Navigation */
.app-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 24px;
  gap: 24px;
}

.app-tab {
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.app-tab:hover {
  color: var(--text);
}

.app-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}