/* ==========================================================================
   MATERIAL 3 EXPRESSIVE DESIGN TOKENS (UNIFIED BPIBS IDENTITY)
   ========================================================================== */
:root {
  --md-sys-color-primary: #274FE8;
  --md-sys-color-primary-hover: #1E40C8;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #DEE1FF;
  --md-sys-color-on-primary-container: #001159;

  --md-sys-color-secondary: #4B5D78;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #D3E4FF;
  --md-sys-color-on-secondary-container: #041C35;

  --md-sys-color-tertiary: #845400;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #FFDEA7;
  --md-sys-color-on-tertiary-container: #2A1700;

  --md-sys-color-error: #BA1A1A;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #410002;

  --badge-sabtu-bg: #D5F5E3;
  --badge-sabtu-fg: #0B532C;
  --badge-ahad-bg: #EDE2FF;
  --badge-ahad-fg: #3B1278;

  --md-sys-color-background: #F4F6FC;
  --md-sys-color-on-background: #141824;
  --md-sys-color-surface: #F4F6FC;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #EEF1FA;
  --md-sys-color-surface-container: #E5EAF6;
  --md-sys-color-surface-container-high: #DCE3F2;
  --md-sys-color-on-surface: #141824;
  --md-sys-color-on-surface-variant: #44495A;
  --md-sys-color-outline: #73778A;
  --md-sys-color-outline-variant: #CFD3E4;

  --md-sys-shape-extra-large: 24px;
  --md-sys-shape-large: 16px;
  --md-sys-shape-medium: 12px;
  --md-sys-shape-full: 9999px;

  /* Kurva gerak profesional: halus tanpa pantulan */
  --smooth-decelerate: cubic-bezier(0.22, 1, 0.36, 1);
  --standard-easing: cubic-bezier(0.2, 0, 0, 1);

  --card-shadow: 0 1px 3px rgba(20, 24, 36, 0.04), 0 4px 12px rgba(20, 24, 36, 0.03);
  --card-shadow-hover: 0 6px 18px rgba(39, 79, 232, 0.09), 0 2px 4px rgba(20, 24, 36, 0.04);
  --menu-shadow: 0 16px 40px rgba(15, 19, 29, 0.22), 0 4px 12px rgba(15, 19, 29, 0.08);
  --sheet-shadow: 0 -10px 32px rgba(15, 19, 29, 0.26);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  line-height: 1.5;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-display {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

button, input, textarea {
  touch-action: manipulation;
}

/* Accessible Keyboard Focus Ring */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.svg-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ==========================================================================
   EXPRESSIVE HERO HEADER
   ========================================================================== */
.hero-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #274FE8 0%, #3E48E5 52%, #1B3687 100%);
  color: #FFFFFF;
  border-radius: var(--md-sys-shape-extra-large);
  padding: 20px 22px;
  box-shadow: 0 12px 28px rgba(39, 79, 232, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

@media (max-width: 640px) {
  .hero-card {
    padding: 16px 16px 18px;
    border-radius: 22px;
  }
}

.hero-card::before,
.hero-card::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.12;
}
.hero-card::before {
  width: 240px;
  height: 240px;
  background: #FFDEA7;
  top: -90px;
  right: -45px;
}
.hero-card::after {
  width: 160px;
  height: 160px;
  background: #98F5BE;
  bottom: -65px;
  right: 120px;
}

.school-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 5px 11px;
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.25;
  color: #FFFFFF;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 19, 29, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 5px 12px;
  border-radius: var(--md-sys-shape-full);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.95);
}

/* ==========================================================================
   CONCENTRIC SURFACE HIERARCHY
   ========================================================================== */
.m3-card-xl {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-extra-large);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--card-shadow);
}

.m3-tonal-box {
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-large);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3-tertiary-box {
  background-color: #EEF3FE;
  border-radius: var(--md-sys-shape-large);
  border: 1px solid #C6D5FA;
}

/* ==========================================================================
   STICKY TABLE STYLING
   ========================================================================== */
.table-wrapper {
  max-height: calc(100vh - 280px);
  min-height: 420px;
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.table-wrapper::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: var(--md-sys-color-surface-container-low);
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: #B9C0D4;
  border-radius: 9999px;
  border: 2px solid var(--md-sys-color-surface-container-low);
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #929BB5;
}

table.rapor-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

table.rapor-table thead tr.header-row-1 th {
  position: sticky;
  top: 0;
  height: 46px;
  z-index: 30;
}

table.rapor-table thead tr.header-row-2 th {
  position: sticky;
  top: 46px;
  height: 34px;
  z-index: 30;
}

.sticky-col-1 {
  position: sticky;
  left: 0;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  z-index: 20;
}

.sticky-col-2 {
  position: sticky;
  left: 48px;
  width: 278px;
  min-width: 278px;
  max-width: 278px;
  z-index: 20;
  box-shadow: 6px 0 14px -6px rgba(20, 24, 36, 0.12);
}

table.rapor-table thead th.sticky-col-1,
table.rapor-table thead th.sticky-col-2 {
  z-index: 45 !important;
}

/* Active Row Focus & Hover Ergonomics */
table.rapor-table tbody tr.santri-item:hover td {
  filter: brightness(0.985);
}
table.rapor-table tbody tr.santri-item:focus-within td {
  background-color: #EEF2FF !important;
}
table.rapor-table tbody tr.santri-item:focus-within td.col-tonal-blue {
  background-color: #E3EBFF !important;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ==========================================================================
   M3 EXPRESSIVE INPUTS
   ========================================================================== */
.cell-input {
  width: 100%;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
  transition: border-color 0.2s var(--standard-easing), box-shadow 0.2s var(--standard-easing), background-color 0.2s;
}
.cell-input:hover {
  border-color: var(--md-sys-color-outline);
}
.cell-input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  background-color: #FAFBFD;
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

.cell-num {
  width: 100%;
  min-width: 56px;
  min-height: 36px;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  border-radius: 10px;
  padding: 6px 4px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
  transition: border-color 0.2s var(--standard-easing), box-shadow 0.2s var(--standard-easing);
}
.cell-num:hover {
  border-color: var(--md-sys-color-outline);
}
.cell-num:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

.card-input {
  width: 100%;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
  transition: border-color 0.2s var(--standard-easing), box-shadow 0.2s var(--standard-easing);
}
.card-input:hover {
  border-color: var(--md-sys-color-outline);
}
.card-input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

.card-num {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-medium);
  padding: 9px 4px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
  transition: border-color 0.2s var(--standard-easing), box-shadow 0.2s var(--standard-easing);
}
.card-num:hover {
  border-color: var(--md-sys-color-outline);
}
.card-num:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

/* ==========================================================================
   GOOGLE FORM STYLE DROPDOWN TRIGGER & BOTTOM SHEET / POPOVER
   ========================================================================== */
.dd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  text-align: left;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s var(--standard-easing), box-shadow 0.2s var(--standard-easing), background-color 0.2s;
}
.dd-trigger:hover {
  border-color: var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface-container-low);
}
.dd-trigger.is-open {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  background-color: var(--md-sys-color-surface-container-lowest);
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}
.dd-trigger.dd-control {
  min-height: 48px;
  border-radius: 14px;
  padding: 9px 14px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
}
.dd-trigger.dd-cell {
  min-height: 36px;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  box-shadow: none;
}
.dd-trigger.dd-card {
  min-height: 44px;
  border-radius: var(--md-sys-shape-medium);
  padding: 9px 13px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  box-shadow: none;
}
.dd-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.dd-chevron {
  width: 18px;
  height: 18px;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
  transition: transform 0.25s var(--smooth-decelerate), color 0.2s;
}
.dd-trigger.is-open .dd-chevron {
  transform: rotate(180deg);
  color: var(--md-sys-color-primary);
}

/* Backdrop untuk Mobile Bottom Sheet */
.gf-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.56);
  backdrop-filter: blur(2px);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--smooth-decelerate);
}
.gf-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Floating M3 Menu & Bottom Sheet */
.gf-shared-menu {
  position: fixed;
  z-index: 300;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-large);
  box-shadow: var(--menu-shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
  max-height: 340px;
  color: var(--md-sys-color-on-surface);
  animation: menuPop 0.22s var(--smooth-decelerate) both;
}
.gf-shared-menu.open {
  display: flex;
}

@keyframes menuPop {
  from {
    opacity: 0;
    transform: translate3d(0, -6px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.gf-menu-header {
  padding: 10px 14px 10px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.gf-sheet-handle {
  display: none;
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: var(--md-sys-color-outline-variant);
  margin: 2px auto 0;
}

.gf-sheet-title {
  display: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.01em;
}

.gf-menu-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-full);
  padding: 0 13px;
  height: 40px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gf-menu-search:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}
.gf-menu-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  min-width: 0;
}
.gf-menu-search input::placeholder {
  color: var(--md-sys-color-outline);
}

.gf-options-list {
  overflow-y: auto;
  padding: 4px 0 calc(6px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.gf-option {
  width: 100%;
  min-height: 46px;
  padding: 10px 15px;
  border: none;
  border-bottom: 1px solid rgba(128, 134, 155, 0.1);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.15s var(--standard-easing);
}
.gf-option:last-child {
  border-bottom: none;
}
.gf-option:hover {
  background: var(--md-sys-color-surface-container-low);
}
.gf-option.selected {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
}

@media (max-width: 640px) {
  .gf-shared-menu {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 82vh;
    max-height: 82dvh;
    border-radius: 24px 24px 0 0;
    border: none;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: var(--sheet-shadow);
    will-change: transform;
    animation: sheetSlideUp 0.32s var(--smooth-decelerate) both;
  }
  .gf-sheet-handle,
  .gf-sheet-title {
    display: block;
  }
  .gf-option {
    min-height: 52px;
    padding: 12px 16px;
  }
}

@keyframes sheetSlideUp {
  from {
    transform: translate3d(0, 100%, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes m3DialogSlide {
  from {
    opacity: 0;
    transform: translate3d(0, 12px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}
.m3-dialog-animate {
  animation: m3DialogSlide 0.26s var(--smooth-decelerate) both;
}

/* ==========================================================================
   BUTTONS & SEGMENTED SWITCHER
   ========================================================================== */
.m3-fab {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: var(--md-sys-shape-full);
  font-family: 'Plus Jakarta Sans', sans-serif;
  box-shadow: 0 3px 10px rgba(39, 79, 232, 0.24);
  transition: filter 0.18s var(--standard-easing), transform 0.18s var(--smooth-decelerate);
}
.m3-fab:hover:not(:disabled) {
  filter: brightness(1.08);
}
.m3-fab:active:not(:disabled) {
  transform: scale(0.97);
}
.m3-fab:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.m3-btn-tertiary {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: 1px solid #B6CEF8;
  border-radius: var(--md-sys-shape-full);
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: filter 0.18s var(--standard-easing), transform 0.18s var(--smooth-decelerate);
}
.m3-btn-tertiary:hover:not(:disabled) {
  filter: brightness(0.96);
}
.m3-btn-tertiary:active:not(:disabled) {
  transform: scale(0.97);
}
.m3-btn-tertiary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}