/**
 * Sistem Informasi Administrasi Sekolah Modern
 * Theme: Pastel Soft UI + Glassmorphism
 */

:root {
  --bg-page: #F8F6EF;
  --bg-sidebar: #D9E6DD;
  --card-mint: #E0F0EB;
  --card-peach: #F6D2C5;
  --card-yellow: #F9E8B6;
  --card-blue: #D5E3F6;
  --btn-primary: #E98167;
  --btn-primary-hover: #dc7258;
  --text-main: #342C28;
  --text-secondary: #77736D;
  --card-white: #FFFFFF;
  --border-subtle: rgba(52, 44, 40, 0.08);
  --shadow-soft: 0 4px 20px rgba(52, 44, 40, 0.04);
  --shadow-hover: 0 8px 24px rgba(52, 44, 40, 0.08);
  --radius-card: 24px;
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

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

/* Layout Grid */
.app-container {
  display: flex;
  min-height: 100vh;
  padding: 16px;
  gap: 20px;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-radius: var(--radius-card);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  color: #342C28;
  text-transform: uppercase;
}

.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
}

.avatar-wrapper {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.online-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background-color: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.user-role {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.5);
  transform: translateX(3px);
}

.nav-item.active {
  background-color: var(--card-white);
  box-shadow: 0 4px 12px rgba(52, 44, 40, 0.05);
  color: var(--text-main);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-promo {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  margin-bottom: 12px;
}

.promo-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.promo-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.btn-quick-journal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background-color: var(--btn-primary);
  color: #ffffff;
  border: none;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(233, 129, 103, 0.3);
}

.btn-quick-journal:hover {
  background-color: var(--btn-primary-hover);
  transform: translateY(-1px);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

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

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.preview-badge {
  font-size: 10px;
  font-weight: 700;
  background-color: #fee2e2;
  color: #dc2626;
  padding: 4px 8px;
  border-radius: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-search {
  flex: 1;
  max-width: 380px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 38px;
  background-color: var(--card-white);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--btn-primary);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

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

.btn-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background-color: var(--card-white);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-icon:hover {
  background-color: #f1f0e8;
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--card-white);
  padding: 6px 14px 6px 6px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.header-user-info {
  display: flex;
  flex-direction: column;
}

.header-user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.header-user-role {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Banner Sambutan */
.welcome-banner {
  background: linear-gradient(135deg, #F6D2C5 0%, #FCECE4 45%, #F9E8B6 100%);
  border-radius: var(--radius-card);
  padding: 28px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 190px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 30px -10px rgba(233, 129, 103, 0.22);
  border: 1px solid rgba(233, 129, 103, 0.35);
  animation: bannerFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.banner-content {
  max-width: 65%;
  z-index: 2;
}

.banner-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  color: #a84730;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 6px rgba(178, 88, 65, 0.08);
}

.banner-title {
  font-size: 27px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.banner-desc {
  font-size: 13.5px;
  color: #5c4e48;
  line-height: 1.55;
  margin-bottom: 20px;
}

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

.btn-primary-action {
  padding: 10px 22px;
  background: linear-gradient(135deg, #E98167 0%, #db6c50 100%);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(233, 129, 103, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary-action:hover {
  background: linear-gradient(135deg, #f08d74 0%, #e06e53 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 22px rgba(233, 129, 103, 0.5);
}

.btn-secondary-action {
  padding: 10px 22px;
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(52, 44, 40, 0.05);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary-action:hover {
  background-color: #ffffff;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 20px rgba(52, 44, 40, 0.1);
}

.banner-graphic {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.banner-graphic svg {
  animation: bannerGraphicFloat 5s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(233, 129, 103, 0.2));
}

@keyframes bannerGraphicFloat {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(1.5deg);
  }
}

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

/* Stat Cards (4 in a row) with Staggered Animations & Vibrant Colors */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.stat-card {
  padding: 22px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 135px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  animation: statCardEntrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

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

.stat-card:hover {
  transform: translateY(-6px) scale(1.015);
}

.stat-card.mint {
  background: linear-gradient(145deg, #E0F0EB 0%, #ECF7F3 100%);
  border-color: rgba(46, 107, 86, 0.2);
}
.stat-card.mint:hover {
  box-shadow: 0 16px 32px -8px rgba(46, 107, 86, 0.25);
  border-color: rgba(46, 107, 86, 0.45);
}

.stat-card.peach {
  background: linear-gradient(145deg, #F6D2C5 0%, #FAECE6 100%);
  border-color: rgba(178, 88, 65, 0.2);
}
.stat-card.peach:hover {
  box-shadow: 0 16px 32px -8px rgba(178, 88, 65, 0.25);
  border-color: rgba(178, 88, 65, 0.45);
}

.stat-card.yellow {
  background: linear-gradient(145deg, #F9E8B6 0%, #FCF5DC 100%);
  border-color: rgba(146, 111, 26, 0.2);
}
.stat-card.yellow:hover {
  box-shadow: 0 16px 32px -8px rgba(146, 111, 26, 0.25);
  border-color: rgba(146, 111, 26, 0.45);
}

.stat-card.blue {
  background: linear-gradient(145deg, #D5E3F6 0%, #EBF2FA 100%);
  border-color: rgba(59, 110, 168, 0.2);
}
.stat-card.blue:hover {
  box-shadow: 0 16px 32px -8px rgba(59, 110, 168, 0.25);
  border-color: rgba(59, 110, 168, 0.45);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(3deg);
}

.stat-value {
  font-size: 34px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-top: 10px;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.card-box {
  background-color: var(--card-white);
  border-radius: var(--radius-card);
  padding: 24px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

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

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.select-filter {
  padding: 6px 12px;
  background-color: #f7f6f0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

/* Tables & Forms */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  background-color: #faf9f5;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #faf9f3;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--btn-primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--btn-primary-hover);
}

.btn-secondary {
  background-color: #f1f0e8;
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: #e5e3d7;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    padding: 10px;
  }
  .sidebar {
    width: 100%;
    margin-bottom: 16px;
  }
  .welcome-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .banner-content {
    max-width: 100%;
  }
  .banner-graphic {
    display: none;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* Cetak: sembunyikan elemen non-laporan */
@media print {
    .no-print, .sidebar, .navbar, .top-navbar, .top-header { display: none !important; }
    .main-wrapper { margin: 0 !important; padding: 0 !important; }
    .card-box { box-shadow: none !important; }
}


/* =====================================================================
   MOBILE SUPPORT + BOTTOM NAVIGATION
   ===================================================================== */

html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }

/* Pembungkus tabel: scroll horizontal (diterapkan otomatis oleh app.js) */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Komponen mobile disembunyikan di desktop */
.bottom-nav,
.more-sheet,
.more-backdrop { display: none; }

@media (hover: none) {
  .nav-item:hover,
  .stat-card:hover,
  .btn-primary-action:hover,
  .btn-secondary-action:hover { transform: none; }
}

@media (max-width: 768px) {
  :root { --radius-card: 20px; }

  /* ---------- Layout dasar ---------- */
  .app-container {
    padding: 10px 10px 0;
    gap: 0;
  }
  .sidebar { display: none; }          /* diganti bottom navigation */
  .main-wrapper {
    gap: 14px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  /* ---------- Header atas (sticky) ---------- */
  .top-header {
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
    gap: 10px;
    margin: -10px -10px 0;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    background: rgba(248, 246, 239, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .header-left { flex: 1; min-width: 0; }
  .page-title {
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .preview-badge,
  .header-user,
  .header-logout { display: none; }
  .header-search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
  .header-actions { gap: 8px; }

  /* ---------- Bottom navigation ---------- */
  .bottom-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    height: 64px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    box-shadow: 0 8px 28px rgba(52, 44, 40, 0.14);
    z-index: 900;                       /* di bawah modal (999) */
  }

  .bn-item,
  .bn-fab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    border: 0;
    background: none;
    font: inherit;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .bn-item svg { width: 22px; height: 22px; position: relative; z-index: 1; }
  .bn-item::before {                    /* pil highlight untuk menu aktif */
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    width: 54px;
    height: 30px;
    margin-left: -27px;
    border-radius: 999px;
    background: var(--card-mint);
    transform: scale(0.6);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  }
  .bn-item.active { color: #2e6b56; font-weight: 700; }
  .bn-item.active::before { transform: scale(1); opacity: 1; }
  .bn-item:active svg { transform: scale(0.9); }

  /* Tombol tengah (Isi Jurnal Cepat) */
  .bn-fab {
    justify-content: flex-end;
    color: var(--text-main);
    font-weight: 700;
  }
  .bn-fab-circle {
    position: absolute;
    top: -20px;
    left: 50%;
    margin-left: -27px;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--btn-primary);
    color: #fff;
    border: 4px solid var(--bg-page);
    box-shadow: 0 6px 16px rgba(233, 129, 103, 0.45);
    transition: transform 0.2s, background-color 0.2s;
  }
  .bn-fab-circle svg { width: 24px; height: 24px; stroke-width: 2.6; }
  .bn-fab:active .bn-fab-circle { transform: scale(0.93); }
  .bn-fab.active .bn-fab-circle { background: var(--btn-primary-hover); }
  .bn-fab-label { margin-bottom: 12px; }

  /* ---------- Bottom sheet "Lainnya" ---------- */
  .more-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(52, 44, 40, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1000;
  }
  .more-backdrop.open { opacity: 1; pointer-events: auto; }

  .more-sheet {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -10px 40px rgba(52, 44, 40, 0.18);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.3s;
  }
  .more-sheet.open {
    transform: translateY(0);
    visibility: visible;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
  }
  body.sheet-open { overflow: hidden; }

  .more-handle {
    width: 40px;
    height: 4px;
    margin: 0 auto 14px;
    border-radius: 999px;
    background: rgba(52, 44, 40, 0.16);
  }
  .more-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .more-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card-mint);
    flex-shrink: 0;
  }
  .more-user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .more-user-text strong {
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .more-user-text span { font-size: 12px; color: var(--text-secondary); }
  .more-close {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: #f1f0e8;
    color: var(--text-main);
    cursor: pointer;
  }
  .more-close svg { width: 18px; height: 18px; }

  .more-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .more-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 6px 12px;
    border-radius: 18px;
    background: var(--card-mint);
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s;
  }
  .more-tile:nth-child(4n+2) { background: var(--card-peach); }
  .more-tile:nth-child(4n+3) { background: var(--card-yellow); }
  .more-tile:nth-child(4n+4) { background: var(--card-blue); }
  .more-tile:active { transform: scale(0.96); }
  .more-tile.active { outline: 2px solid var(--btn-primary); outline-offset: -2px; }
  .more-tile-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.75);
  }
  .more-tile-icon svg { width: 20px; height: 20px; }
  .more-tile-label { font-size: 12px; font-weight: 600; line-height: 1.25; }

  .more-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    margin-top: 14px;
    border-radius: 16px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 14px;
    font-weight: 700;
  }
  .more-logout svg { width: 18px; height: 18px; }

  /* ---------- Konten ---------- */
  .card-box { padding: 16px; }
  .card-header { flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
  .card-title { font-size: 15px; }

  .welcome-banner { padding: 20px; min-height: 0; }
  .banner-title { font-size: 20px; }
  .banner-desc { font-size: 13px; margin-bottom: 16px; }
  .banner-buttons { flex-wrap: wrap; width: 100%; }
  .banner-buttons > a { flex: 1 1 auto; text-align: center; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; min-height: 112px; }
  .stat-icon { width: 34px; height: 34px; }
  .stat-value { font-size: 24px; margin-top: 8px; }
  .stat-label { font-size: 12px; }

  .donut-row {
    flex-direction: column;
    height: auto !important;
    gap: 16px;
  }
  .donut-legend { width: 100%; padding-left: 0 !important; }

  /* Semua grid inline (form 2/3 kolom, dsb.) menjadi 1 kolom */
  [style*="grid-template-columns"]:not([style*="auto-fit"]) {
    grid-template-columns: 1fr !important;
  }

  /* Form filter (GET): isi memenuhi lebar layar */
  form[method="GET"] > div { width: 100%; }
  form[method="GET"] > div > div { flex: 1 1 150px; min-width: 0; }
  form[method="GET"] select,
  form[method="GET"] .search-input { width: 100% !important; max-width: 100%; }

  /* Kontrol form: 16px agar iOS tidak auto-zoom, tinggi nyaman disentuh */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]),
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
  }
  select { max-width: 100%; text-overflow: ellipsis; }
  form[method="GET"] button.btn-secondary-action { width: 100%; }
  .btn-primary-action,
  .btn-secondary-action { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-icon { width: 42px; height: 42px; }

  /* Tabel: scroll horizontal di dalam kartu */
  .table-scroll > .data-table:not(.att-table) { min-width: 620px; }
  .data-table th,
  .data-table td { padding: 10px 12px; }
  td[style*="width: 200px"] { width: 120px !important; }

  /* Modal: muat di layar kecil & bisa di-scroll */
  [style*="position: fixed"][style*="inset: 0"] { padding: 12px !important; align-items: flex-end !important; }
  [style*="position: fixed"][style*="inset: 0"] > div {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 20px !important;
    border-radius: 22px !important;
  }

  /* Footer */
  .app-footer {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 6px;
    margin-top: 20px !important;
  }

  /* ---------- Absensi: tabel -> kartu per siswa ---------- */
  .att-table thead { display: none; }
  .att-table,
  .att-table tbody { display: block; width: 100%; }
  .att-table tbody tr {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    column-gap: 10px;
    row-gap: 8px;
    align-items: center;
    padding: 12px;
    margin-bottom: 10px;
    background: #faf9f5;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
  }
  .att-table tbody tr:hover { background: #faf9f5; }
  .att-table td { display: block; padding: 0; border: 0; }
  .att-table td[colspan] { grid-column: 1 / -1; }
  .att-table td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; font-size: 12px; color: var(--text-secondary); font-weight: 700; align-self: start; padding-top: 2px; }
  .att-table td:nth-child(3) { grid-column: 2; grid-row: 1; font-size: 14px; line-height: 1.3; }
  .att-table td:nth-child(2) { grid-column: 2; grid-row: 2; font-size: 11px; color: var(--text-secondary); }
  .att-table td:nth-child(4) { grid-column: 3; grid-row: 1; font-size: 12px; font-weight: 700; color: var(--text-secondary); }
  .att-table td:nth-child(5) { grid-column: 1 / -1; grid-row: 3; }
  .att-table td:nth-child(6) { grid-column: 1 / -1; grid-row: 4; }
  .att-table td:nth-child(5) > div { display: flex !important; width: 100%; }
  .att-table td:nth-child(5) .radio-label {
    flex: 1;
    text-align: center;
    padding: 10px 0 !important;
    font-size: 14px !important;
  }
}

@media (max-width: 380px) {
  .stat-value { font-size: 21px; }
  .more-tile-label { font-size: 11px; }
  .bn-item, .bn-fab { font-size: 10px; }
}

@media print {
  .bottom-nav, .more-sheet, .more-backdrop { display: none !important; }
  .table-scroll { overflow: visible !important; }
}
