/* ==========================================================================
   KAS TK AR-ROHMANIYAH - Modern & Playful Kindergarten Design System
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-main: #fcf9f2;
  --bg-card: #ffffff;
  --text-main: #2d3748;
  --text-muted: #718096;
  
  /* Primary & Accent Colors */
  --color-orange: #f97316;
  --color-orange-light: #fff7ed;
  --color-teal: #0d9488;
  --color-teal-light: #f0fdfa;
  --color-green: #10b981;
  --color-green-light: #ecfdf5;
  --color-purple: #8b5cf6;
  --color-purple-light: #f5f3ff;
  --color-red: #ef4444;
  --color-red-light: #fef2f2;
  
  /* Paper Card Theme (Matching Uploaded Image) */
  --paper-bg: #fffdfa;
  --paper-border: #333333;
  --paper-title-orange: #e67e22;
  --paper-sub-teal: #16a085;
  
  /* UI Elements */
  --border-radius-sm: 8px;
  --border-radius: 14px;
  --border-radius-lg: 20px;
  --box-shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.05);
  --box-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.1);
  --transition-fast: 0.2s ease;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  background-color: #ffffff;
  border-bottom: 2px solid #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--color-orange), #fb923c);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.brand-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 6px;
  background-color: #f8fafc;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.nav-btn:hover {
  color: var(--color-orange);
  background-color: rgba(249, 115, 22, 0.05);
}

.nav-btn.active {
  background-color: #ffffff;
  color: var(--color-orange);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Role Toggle Badge & Button */
.role-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--color-orange-light);
  border: 1.5px solid var(--color-orange);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-orange);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  z-index: 10;
}

.role-badge:hover {
  transform: scale(1.04);
  box-shadow: 0 3px 12px rgba(249, 115, 22, 0.25);
}

.role-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-orange);
  display: inline-block;
  box-shadow: 0 0 8px var(--color-orange);
}

.btn-outline-role {
  background: white;
  border: 1px solid var(--color-orange);
  color: var(--color-orange);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}

.btn-outline-role:hover {
  background: var(--color-orange);
  color: white;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */

.main-content {
  max-width: 1200px;
  width: 100%;
  margin: 24px auto;
  padding: 0 24px;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .app-header {
    backdrop-filter: none;
  }

  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 15px;
  }

  .brand {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    width: 100%;
    gap: 4px;
  }

  .brand-title {
    font-size: 1.15rem;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
  }
  
  .brand-subtitle {
    white-space: normal;
    word-wrap: break-word;
    font-size: 0.75rem;
  }

  .mobile-menu-btn {
    display: block !important;
    width: 100%;
    padding: 10px;
    background: white;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-weight: 700;
    color: var(--color-orange);
    margin-bottom: 4px;
    cursor: pointer;
  }

  .nav-tabs {
    display: none; /* hidden by default, toggled by JS */
    flex-direction: column;
    width: 100%;
    white-space: normal;
    padding: 8px;
    gap: 8px;
  }
  
  .nav-tabs.show {
    display: flex;
  }

  .nav-btn {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  .role-badge {
    align-self: center;
    width: auto;
    justify-content: center;
    padding: 4px 12px;
    font-size: 0.78rem;
  }

  .card-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .student-select-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .student-select-group .form-select,
  .student-select-group .btn {
    width: 100% !important;
    box-sizing: border-box;
  }

  .action-buttons {
    flex-direction: column;
    width: 100%;
  }

  .action-buttons .btn {
    width: 100% !important;
  }

  .digital-card {
    padding: 16px 12px;
    border-radius: 16px;
  }

  .card-head {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .card-titles h2 {
    font-size: 1.1rem;
  }

  .card-titles h3 {
    font-size: 0.95rem;
  }

  .student-meta {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bca-info-banner {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .card-table th, .card-table td {
    padding: 8px 6px;
    font-size: 0.78rem;
  }

  .modal-box {
    width: 92% !important;
    padding: 18px 15px !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  .card-paper-wrapper {
    padding: 0;
    margin: 0 -15px; /* Pull out of section padding */
  }

  .card-paper {
    padding: 12px 4px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    width: 100vw;
  }
  
  .card-decor {
    display: none; /* Hide background decorative images on mobile to avoid covering content */
  }

  .card-header-art {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  .avatar-img-art {
    width: 65px;
    height: 65px;
  }

  .card-main-title {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .card-school-name {
    font-size: 0.85rem;
  }

  .sub-header-tag {
    font-size: 0.8rem;
  }

  .card-meta-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  .meta-value {
    min-width: 0;
    flex: 1;
    text-align: right;
  }

  .kas-table th, .kas-table td {
    padding: 8px 6px;
    font-size: 0.78rem;
    border-width: 1px;
    white-space: nowrap;
  }
  
  .kas-table th {
    font-size: 0.78rem;
    letter-spacing: -0.5px;
  }
  
  .month-cell {
    padding-left: 6px !important;
  }

  .status-badge, .paraf-stamp {
    font-size: 0.7rem;
    padding: 4px 8px;
    white-space: nowrap;
    display: inline-block;
  }

  /* Force table to expand inside table-responsive so it can be swiped */
  .kas-table {
    min-width: 500px;
    table-layout: auto !important;
  }

  .card-footer-info {
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    margin-top: 16px;
    padding-top: 12px;
  }

  .footer-note {
    max-width: 100%;
    font-size: 0.7rem;
  }

  .matrix-table th, .matrix-table td {
    padding: 6px 4px;
    font-size: 0.75rem;
  }

  .sticky-col {
    min-width: 110px;
    font-size: 0.7rem;
    padding: 6px 4px !important;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
}

/* ==========================================================================
   Card Toolbar Controls
   ========================================================================== */

.card-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.student-select-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.student-select-group label {
  font-weight: 700;
  color: #334155;
  font-size: 0.95rem;
}

.form-select, .form-control {
  padding: 9px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
  background-color: white;
}

.form-select:focus, .form-control:focus {
  border-color: var(--color-orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.action-buttons {
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.btn-primary {
  background-color: var(--color-orange);
  color: white;
}

.btn-primary:hover {
  background-color: #ea580c;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}

.btn-secondary {
  background-color: #475569;
  color: white;
}

.btn-secondary:hover {
  background-color: #334155;
}

.btn-success {
  background-color: #16a34a;
  color: white;
}

.btn-success:hover {
  background-color: #15803d;
}

.btn-outline {
  background-color: white;
  border: 1.5px solid #cbd5e1;
  color: #475569;
}

.btn-outline:hover {
  border-color: var(--color-orange);
  color: var(--color-orange);
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* ==========================================================================
   DIGITAL KARTU PEMBAYARAN (EXACT MATCH FOR UPLOADED IMAGE DESIGN)
   ========================================================================== */

.card-paper-wrapper {
  display: flex;
  justify-content: center;
}

.card-paper {
  background-color: #fffbf4;
  background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
  background-size: 16px 16px;
  width: 100%;
  max-width: 680px;
  border: 3px solid #2d2d2d;
  border-radius: 18px;
  padding: 32px;
  position: relative;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* Decorative background elements */
.card-decor {
  position: absolute;
  pointer-events: none;
  opacity: 0.35;
}

.star-top-left {
  top: 15px;
  left: 20px;
  font-size: 1.8rem;
  color: #f59e0b;
}

.star-top-right {
  top: 12px;
  right: 180px;
  font-size: 2rem;
  color: #eab308;
}

.number-123 {
  right: 15px;
  top: 180px;
  font-family: 'Fredoka', cursive;
  font-size: 2.2rem;
  font-weight: 700;
  color: #ec4899;
}

.magnifying {
  left: 15px;
  bottom: 120px;
  font-size: 2.5rem;
  color: #fb923c;
  transform: rotate(-15deg);
}

/* Card Header Artwork */
.card-header-art {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  text-align: center;
}

.avatar-img-art {
  width: 90px;
  height: 90px;
  object-fit: contain;
}

.card-title-block {
  flex: 1;
  padding: 0 10px;
}

.sub-header-tag {
  font-family: 'Fredoka', cursive;
  font-size: 1.4rem;
  color: #e67e22;
  font-weight: 600;
  display: block;
}

.card-main-title {
  font-family: 'Fredoka', cursive;
  font-size: 2.3rem;
  font-weight: 700;
  color: #d97706;
  line-height: 1.1;
  letter-spacing: 1px;
}

.card-school-name {
  font-family: 'Fredoka', cursive;
  font-size: 1.5rem;
  color: #ea580c;
  font-weight: 600;
  margin-top: 4px;
}

/* Metadata Row */
.card-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 10px 16px;
  background-color: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  border: 1.5px solid #2d2d2d;
  font-size: 1.05rem;
  font-weight: 700;
}

.meta-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-label {
  color: #1e293b;
}

.meta-value {
  color: #0f172a;
  border-bottom: 2px solid #0f172a;
  padding: 0 12px;
  min-width: 140px;
  display: inline-block;
}

/* Progress bar inside card */
.card-progress-bar-container {
  margin-bottom: 16px;
  background: white;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: #475569;
}

.progress-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f97316, #10b981);
  transition: width 0.4s ease;
}

/* Table Style matching printed paper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
}

.kas-table {
  width: 100%;
  border-collapse: collapse;
  background-color: white;
  border: 2px solid #2d2d2d;
  table-layout: fixed; /* Ensures columns respect width */
}

.kas-table th, .kas-table td {
  border: 1.5px solid #2d2d2d;
  padding: 9px 10px;
  text-align: center;
  font-size: 0.95rem;
}

.kas-table th {
  background-color: #f8fafc;
  font-weight: 700;
  color: #0f172a;
  font-size: 0.9rem;
}

.kas-table tr:nth-child(even) {
  background-color: #fafafa;
}

.month-cell {
  font-weight: 600;
  text-align: left !important;
  padding-left: 16px !important;
}

.amount-cell {
  font-weight: 700;
  color: #334155;
}

/* Payment Status Badges & Paraf */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.status-badge:hover {
  transform: scale(1.05);
}

.status-lunas {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.status-belum {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.paraf-stamp {
  font-family: 'Fredoka', cursive;
  color: #0284c7;
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Card Footer */
.card-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1.5px dashed #cbd5e1;
}

.footer-note {
  max-width: 60%;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
}

.footer-signature {
  text-align: center;
}

.sig-stamp {
  margin-bottom: 6px;
}

.stamp-circle {
  border: 2px dashed #0284c7;
  color: #0284c7;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-block;
  transform: rotate(-4deg);
}

.sig-label {
  font-size: 0.8rem;
  color: #475569;
  font-weight: 600;
}

.sig-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 28px;
}

/* ==========================================================================
   REKAP KELAS (SUMMARY & MATRIX)
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--box-shadow-subtle);
  border: 1px solid #f1f5f9;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.bg-orange .stat-icon { background: var(--color-orange-light); color: var(--color-orange); }
.bg-teal .stat-icon { background: var(--color-teal-light); color: var(--color-teal); }
.bg-green .stat-icon { background: var(--color-green-light); color: var(--color-green); }
.bg-purple .stat-icon { background: var(--color-purple-light); color: var(--color-purple); }

.stat-content h3 {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;

}

.stat-number {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  margin: 2px 0;
}

.stat-sub {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Section Cards */
.section-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--box-shadow-subtle);
  border: 1px solid #f1f5f9;
  margin-bottom: 24px;
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input-group {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-input-group .form-control {
  padding-left: 36px;
  width: 100%;
}

.filter-status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* Matrix Table */
.matrix-table-container {
  max-height: 520px;
  overflow-y: auto;
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.matrix-table th, .matrix-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f8fafc;
}

.matrix-table th {
  background-color: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
  font-weight: 700;
  color: #475569;
}

.sticky-col {
  position: sticky;
  left: 0;
  background-color: white !important;
  z-index: 11;
  text-align: left !important;
  font-weight: 700;
  min-width: 160px;
  box-shadow: 2px 0 5px rgba(0,0,0,0.03);
}

.matrix-table th.sticky-col {
  z-index: 12;
  background-color: #f8fafc !important;
}

.dot-status {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
}

.dot-lunas { background-color: #10b981; color: white; }
.dot-belum { background-color: #cbd5e1; color: #64748b; }

/* ==========================================================================
   PENGELUARAN & WA TOOLS
   ========================================================================== */

.two-column-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
}

@media (max-width: 850px) {
  .two-column-layout {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #334155;
}

.form-control, .form-select {
  width: 100%;
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-warning { background: #fef3c7; color: #b45309; }

.wa-generator-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .wa-generator-grid { grid-template-columns: 1fr; }
}

.wa-preset-select {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wa-textarea {
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  background-color: #f8fafc;
  resize: vertical;
}

.wa-action-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.color-whatsapp { color: #25d366; }

/* ==========================================================================
   MODAL WINDOWS & TOASTS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: white;
  width: 90%;
  max-width: 480px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-hover);
  overflow: hidden;
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.05rem;
  color: #1e293b;
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.modal-info-box {
  background: var(--color-orange-light);
  border-left: 4px solid var(--color-orange);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--box-shadow-hover);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Photo Thumbnails in Tables & Cards */
.photo-preview-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.thumb-img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thumb-img:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-color: var(--color-orange);
}

.btn-view-all-photos {
  background: var(--color-orange-light);
  color: var(--color-orange);
  border: 1px dashed var(--color-orange);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-view-all-photos:hover {
  background: var(--color-orange);
  color: white;
}

/* Modal Large & Gallery Grid */
.modal-box.modal-lg {
  max-width: 720px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  max-height: 520px;
  overflow-y: auto;
  padding: 4px;
}

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  background: #f8fafc;
}

.gallery-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.gallery-img:hover {
  transform: scale(1.05);
}

.gallery-caption {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  background: white;
  text-align: center;
  border-top: 1px solid #f1f5f9;
}

/* ==========================================================================
   VISUAL REFRESH V14
   Harmonized layout for the current dashboard markup.
   ========================================================================== */

:root {
  --bg-main: #fffaf4;
  --bg-soft: #fff7ed;
  --bg-card: #ffffff;
  --text-main: #243044;
  --text-muted: #6b7280;
  --line-soft: #e8edf3;
  --color-orange: #ed6c1d;
  --color-orange-dark: #c94f0c;
  --color-orange-light: #fff3e8;
  --color-teal: #0f8f83;
  --color-teal-light: #eafaf7;
  --color-green: #159a68;
  --color-green-light: #ecfdf5;
  --color-purple: #7c5ce7;
  --color-purple-light: #f2efff;
  --color-red: #dc4c4c;
  --color-red-light: #fff0f0;
  --border-radius-sm: 10px;
  --border-radius: 16px;
  --border-radius-lg: 24px;
  --box-shadow-subtle: 0 8px 28px rgba(62, 42, 24, 0.07);
  --box-shadow-hover: 0 18px 48px rgba(62, 42, 24, 0.12);
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at 8% 4%, rgba(249, 115, 22, 0.08), transparent 26rem),
    radial-gradient(circle at 92% 18%, rgba(13, 148, 136, 0.07), transparent 24rem),
    var(--bg-main);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(237, 108, 29, 0.22);
  outline-offset: 2px;
}

.app-header {
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 24px rgba(62, 42, 24, 0.055);
  backdrop-filter: blur(14px);
}

.header-container {
  max-width: 1320px;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto;
  grid-template-areas:
    "brand role"
    "nav nav";
  gap: 12px 20px;
}

.brand {
  grid-area: brand;
  min-width: 0;
}

.brand-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 15px;
  box-shadow: 0 8px 20px rgba(237, 108, 29, 0.22);
}

.brand-title {
  font-size: clamp(1.16rem, 2vw, 1.42rem);
  letter-spacing: 0.02em;
}

.brand-subtitle {
  margin-top: 1px;
  line-height: 1.45;
}

.nav-tabs {
  grid-area: nav;
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  background: #f8fafc;
  border-color: #e5eaf0;
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  min-height: 40px;
  justify-content: center;
  white-space: nowrap;
}

.nav-btn.active {
  color: var(--color-orange-dark);
  box-shadow: 0 3px 12px rgba(31, 41, 55, 0.09);
}

.role-badge {
  grid-area: role;
  align-self: center;
  max-width: 100%;
  border-color: rgba(237, 108, 29, 0.35);
  background: #fff8f1;
  box-shadow: 0 5px 18px rgba(237, 108, 29, 0.08);
}

.btn-outline-role {
  min-height: 30px;
}

.main-content {
  max-width: 1320px;
  margin: 28px auto 44px;
}

.card-toolbar {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--box-shadow-subtle);
}

.student-select-group,
.action-buttons {
  gap: 9px;
}

.student-select-group {
  flex: 1 1 680px;
}

.student-select-group label {
  white-space: nowrap;
}

.student-select-group .form-select {
  min-width: 190px;
  flex: 1 1 230px;
}

.action-buttons {
  flex: 0 1 auto;
}

.form-select,
.form-control {
  min-height: 44px;
  border: 1px solid #d9e0e8;
  border-radius: 11px;
  background-color: #fff;
  color: var(--text-main);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.form-select:hover,
.form-control:hover {
  border-color: #bdc8d5;
}

.form-select:focus,
.form-control:focus {
  border-color: var(--color-orange);
  box-shadow: 0 0 0 4px rgba(237, 108, 29, 0.11);
}

textarea.form-control {
  padding-block: 11px;
}

.btn {
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 11px;
  line-height: 1.2;
  text-decoration: none;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(31, 41, 55, 0.04);
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-orange), #f58b43);
  box-shadow: 0 7px 16px rgba(237, 108, 29, 0.18);
}

.btn-secondary {
  background: #334155;
}

.btn-secondary:hover {
  background: #1e293b;
}

.btn-success {
  background: #128c61;
}

.btn-success:hover {
  background: #0d7751;
}

.btn-danger {
  color: #fff;
  background: var(--color-red);
  border-color: var(--color-red);
}

.btn-danger:hover {
  background: #c43d3d;
}

.btn-lg {
  min-height: 48px;
  padding: 12px 18px;
}

.digital-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid #eadfce;
  border-top: 5px solid var(--color-orange);
  border-radius: var(--border-radius-lg);
  background:
    radial-gradient(circle at 0 0, rgba(249, 115, 22, 0.09), transparent 21rem),
    radial-gradient(circle at 100% 100%, rgba(13, 148, 136, 0.08), transparent 24rem),
    #fffefb;
  box-shadow: 0 22px 54px rgba(79, 52, 24, 0.11);
}

.card-head {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px dashed #dccdb9;
}

.school-logo {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.header-avatar {
  width: 82px;
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(48, 35, 24, 0.12));
}

.header-avatar + .header-avatar {
  margin-left: -26px;
}

.card-titles h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.15;
  color: #283548;
}

.card-titles h3 {
  margin-top: 4px;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: var(--color-teal);
}

.card-titles p {
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.student-meta {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(120px, 0.5fr) minmax(250px, 1fr);
  gap: 10px;
  padding: 18px 0;
}

.student-meta .meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #ece6de;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.student-meta .meta-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.student-meta .meta-value,
.meta-valueHighlight {
  overflow: hidden;
  color: #263449;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-valueHighlight {
  color: var(--color-orange-dark);
}

.bca-info-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid #bfe5e1;
  border-radius: 13px;
  background: #effbf9;
}

.bca-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 9px;
  color: #fff;
  background: var(--color-teal);
  font-size: 0.8rem;
  font-weight: 800;
}

.bca-details {
  color: #27514c;
  font-size: 0.88rem;
}

.bca-details small {
  display: block;
  margin-top: 2px;
  color: #5c7773;
}

.table-responsive {
  border-radius: 13px;
  scrollbar-color: #cbd5e1 transparent;
  scrollbar-width: thin;
}

.card-table,
.expense-table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  font-size: 0.86rem;
}

.card-table th,
.card-table td,
.expense-table th,
.expense-table td {
  padding: 11px 10px;
  border-right: 1px solid #edf0f3;
  border-bottom: 1px solid #e6ebf0;
  text-align: center;
  vertical-align: middle;
}

.card-table th,
.expense-table th {
  color: #425066;
  background: #f5f7fa;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.card-table tbody tr:nth-child(even),
.expense-table tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.72);
}

.card-table tbody tr:hover,
.expense-table tbody tr:hover,
.matrix-table tbody tr:hover td {
  background: #fff8f1;
}

.card-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 28px;
  align-items: end;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed #dccdb9;
}

.foot-notes {
  color: #5d6776;
  font-size: 0.8rem;
}

.foot-notes ul {
  margin: 6px 0 0 18px;
}

.signature-box {
  text-align: center;
  color: #475569;
  font-size: 0.8rem;
}

.sig-space {
  min-height: 56px;
  display: grid;
  place-items: center;
}

.stamp-approved {
  display: inline-block;
  padding: 5px 8px;
  border: 2px solid rgba(15, 143, 131, 0.55);
  border-radius: 8px;
  color: var(--color-teal);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  transform: rotate(-4deg);
}

.card-progress-container {
  margin-top: 16px;
  padding: 15px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--box-shadow-subtle);
}

.card-progress-container .progress-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
  color: #5f6b7b;
  font-size: 0.82rem;
}

.card-progress-container .progress-info strong {
  color: #263449;
}

.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef3;
}

.progress-bar .progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-orange), #f6a04f);
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-width: 0;
  min-height: 126px;
  padding: 18px;
  border-color: var(--line-soft);
  box-shadow: var(--box-shadow-subtle);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-primary .stat-icon {
  color: var(--color-orange);
  background: var(--color-orange-light);
}

.stat-danger .stat-icon {
  color: var(--color-red);
  background: var(--color-red-light);
}

.stat-success .stat-icon {
  color: var(--color-green);
  background: var(--color-green-light);
}

.stat-info .stat-icon {
  color: var(--color-purple);
  background: var(--color-purple-light);
}

.stat-details {
  min-width: 0;
}

.stat-title {
  display: block;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.stat-details h3 {
  overflow: hidden;
  margin: 3px 0 2px;
  color: #1f2d42;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-card,
.expense-form-card,
.expense-list-card,
.wa-tools-card {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--border-radius);
  background: #fff;
  box-shadow: var(--box-shadow-subtle);
}

.matrix-header,
.card-header-styled {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(135deg, #fff, #fafbfc);
}

.matrix-header h2,
.card-header-styled h2,
.card-header-styled h3 {
  color: #263449;
  font-size: 1.08rem;
}

.matrix-header p,
.card-header-styled p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.matrix-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  color: #94a3b8;
  transform: translateY(-50%);
}

.search-box .form-control {
  width: 230px;
  padding-left: 38px;
}

.matrix-card > .table-responsive {
  max-height: 580px;
  border-radius: 0;
}

.matrix-table {
  min-width: 1050px;
}

.expense-container {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(520px, 1.45fr);
  gap: 18px;
  align-items: start;
}

.expense-form-card form {
  padding: 20px;
}

.expense-list-card .table-responsive {
  border-radius: 0;
}

.form-row {
  display: flex;
  gap: 12px;
}

.col-6 {
  flex: 1 1 0;
  min-width: 0;
}

.card-header-styled .badge {
  flex: 0 0 auto;
}

.wa-tools-card {
  padding-bottom: 20px;
}

.wa-presets,
.wa-preview-box,
.wa-actions {
  margin-inline: 20px;
}

.wa-presets {
  display: flex;
  gap: 9px;
  padding: 18px 0 14px;
  flex-wrap: wrap;
}

.wa-preset-btn.active {
  color: var(--color-orange-dark);
  border-color: rgba(237, 108, 29, 0.5);
  background: var(--color-orange-light);
}

.wa-preview-box label {
  display: block;
  margin-bottom: 7px;
  color: #344258;
  font-size: 0.84rem;
  font-weight: 700;
}

.wa-textarea {
  min-height: 260px;
  border-radius: 13px;
  background: #f8fafc;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.wa-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.modal-overlay {
  padding: 18px;
  background: rgba(20, 28, 39, 0.64);
  backdrop-filter: blur(5px);
}

.modal-box {
  width: min(100%, 520px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.25);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 17px 20px;
  background: rgba(248, 250, 252, 0.97);
  backdrop-filter: blur(12px);
}

.close-modal-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  line-height: 1;
}

.close-modal-btn:hover {
  color: #334155;
  background: #e9eef4;
}

.text-success {
  color: var(--color-green) !important;
}

.text-danger {
  color: var(--color-red) !important;
}

.text-muted {
  color: var(--text-muted);
}

@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .matrix-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .matrix-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .expense-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-header {
    backdrop-filter: none;
  }

  .header-container {
    padding: 11px 15px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "role";
    gap: 10px;
  }

  .brand {
    width: auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 13px;
  }

  .brand-title {
    font-size: 1.02rem;
    line-height: 1.15;
  }

  .brand-subtitle {
    font-size: 0.69rem;
  }

  .mobile-menu-btn {
    display: none !important;
  }

  .nav-tabs {
    position: fixed;
    right: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 900;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-self: auto;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    padding: 6px 5px calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
    overflow: visible;
    border-color: rgba(226, 232, 240, 0.95);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 30px rgba(31, 41, 55, 0.13);
    backdrop-filter: blur(16px);
  }

  .nav-tabs.show {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-btn {
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    min-height: 50px;
    padding: 5px 2px;
    gap: 3px;
    overflow: hidden;
    font-size: 0.62rem;
    line-height: 1.1;
    text-align: center;
    text-overflow: ellipsis;
  }

  .nav-btn i {
    font-size: 1rem;
  }

  .nav-btn.active {
    background: var(--color-orange-light);
    box-shadow: none;
  }

  .role-badge {
    justify-self: stretch;
    justify-content: flex-start;
    width: 100%;
    padding: 7px 10px;
    border-radius: 12px;
  }

  .role-badge #roleLabel {
    flex: 1 1 auto;
  }

  .main-content {
    margin: 16px auto calc(92px + env(safe-area-inset-bottom));
    padding: 0 12px;
  }

  .card-toolbar {
    gap: 9px;
    padding: 10px;
  }

  .student-select-group {
    display: grid;
    flex: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: min-content;
    align-content: start;
    gap: 7px;
    width: 100%;
  }

  .student-select-group label,
  .student-select-group .form-select {
    grid-column: 1 / -1;
  }

  .student-select-group label {
    margin-bottom: -1px;
    font-size: 0.76rem;
  }

  .student-select-group .form-select {
    min-height: 40px;
    padding-block: 7px;
  }

  .student-select-group .btn,
  .action-buttons .btn {
    width: 100% !important;
    min-width: 0;
    min-height: 38px;
    padding: 7px 6px;
    gap: 5px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .action-buttons {
    display: grid;
    flex: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: min-content;
    align-content: start;
    gap: 7px;
    width: 100%;
  }

  .digital-card {
    padding: 16px 12px;
    border-radius: 18px;
  }

  .card-head {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-bottom: 14px;
    text-align: center;
  }

  .school-logo {
    order: 2;
  }

  .header-avatar {
    width: 62px;
    height: 62px;
  }

  .card-titles {
    order: 1;
  }

  .student-meta {
    grid-template-columns: 1fr;
    padding: 13px 0;
  }

  .student-meta .meta-item {
    padding: 10px 12px;
  }

  .bca-info-banner {
    align-items: flex-start;
    text-align: left;
  }

  .card-foot {
    grid-template-columns: 1fr;
    gap: 18px;
    text-align: left;
  }

  .card-progress-container {
    padding: 13px;
  }

  .card-progress-container .progress-info {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

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

  .stat-card {
    min-height: 104px;
  }

  .matrix-header,
  .card-header-styled {
    align-items: flex-start;
    padding: 16px;
  }

  .matrix-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box .form-control,
  .matrix-actions .form-select,
  .matrix-actions .btn {
    width: 100% !important;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .wa-presets {
    flex-direction: column;
  }

  .wa-presets .btn {
    width: 100%;
  }

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

  .wa-actions .btn {
    width: 100%;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 10px;
  }

  .modal-box {
    width: 100% !important;
    max-height: 92vh;
    padding: 0 !important;
    border-radius: 20px 20px 14px 14px;
  }

  .toast-container {
    right: 12px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    left: 12px;
  }
}

@media (max-width: 430px) {
  .nav-tabs.show {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .role-badge {
    flex-wrap: wrap;
  }

  .role-badge #roleLabel {
    min-width: calc(100% - 24px);
  }

  .btn-outline-role {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   PRINT STYLESHEET (FOR CLEAN PHYSICAL PAPER PRINTING)
   ========================================================================== */

@media print {
  @page {
    size: 4in 6in; /* 4R Size (102mm x 152mm) Portrait */
    margin: 0.4cm; /* Small margin to maximize space */
  }

  body {
    background: white;
    color: black;
  }

  .app-header, .card-toolbar, .nav-tabs, .modal-overlay, .toast-container,
  .card-progress-container {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }

  .tab-pane {
    display: block !important;
  }

  #tab-rekap, #tab-pengeluaran, #tab-wa-tools {
    display: none !important;
  }

  .card-paper-wrapper {
    margin: 0;
    padding: 0;
  }

  .card-paper,
  .digital-card {
    box-shadow: none !important;
    border: 2px solid black !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px !important;
    page-break-inside: avoid;
  }

  .digital-card {
    border-top-width: 2px !important;
    border-radius: 0 !important;
    background: white !important;
  }

  .card-head {
    grid-template-columns: 80px 1fr !important;
    gap: 8px !important;
    padding-bottom: 7px !important;
  }

  .header-avatar {
    width: 48px !important;
    height: 48px !important;
  }

  .student-meta {
    grid-template-columns: 1.2fr 0.45fr 1fr !important;
    gap: 4px !important;
    padding: 7px 0 !important;
  }

  .student-meta .meta-item,
  .bca-info-banner {
    padding: 5px 7px !important;
    border-radius: 4px !important;
  }

  .bca-info-banner {
    margin-bottom: 7px !important;
  }

  .card-table {
    min-width: 0 !important;
    font-size: 0.62rem !important;
  }

  .card-table th,
  .card-table td {
    padding: 3px !important;
  }

  .card-foot {
    grid-template-columns: 1fr 140px !important;
    gap: 8px !important;
    margin-top: 7px !important;
    padding-top: 6px !important;
  }

  /* Shrink text/elements to fit the small 4R size */
  .card-main-title {
    font-size: 1.2rem !important;
  }
  
  .card-school-name {
    font-size: 0.9rem !important;
  }

  .avatar-img-art {
    width: 50px !important;
    height: 50px !important;
  }

  .card-meta-bar {
    font-size: 0.75rem !important;
    padding: 6px !important;
    margin-bottom: 8px !important;
  }

  .kas-table th, .kas-table td {
    padding: 4px !important;
    font-size: 0.65rem !important;
  }

  .card-progress-bar-container {
    display: none !important;
  }
}
