:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --border: #e4e8ee;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1d6ef2;
  --primary-dark: #1557c7;
  --danger: #dc2626;
  --success-bg: #ecfdf3;
  --success-text: #027a48;
  --error-bg: #fef3f2;
  --error-text: #b42318;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 34px;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 24px;
}

.login-status {
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}

/* APP LAYOUT DESKTOP */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  overflow: hidden;
  z-index: 30;
}

.main-content {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px;
}

/* SIDEBAR */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
}

.brand h2 {
  margin: 0;
  font-size: 22px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.nav-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-item:hover {
  background: #f3f6fb;
}

.nav-item.active {
  background: #eaf2ff;
  color: var(--primary);
  font-weight: 700;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.user-mini p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.logout-btn {
  width: 100%;
  border: 0;
  background: #fee2e2;
  color: #b91c1c;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}

.logout-btn:hover {
  background: #fecaca;
}

/* AVATAR */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dbeafe;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* TOPBAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 34px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 16px;
}

.topbar-user-text {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.topbar-user-text span {
  color: var(--muted);
  font-size: 13px;
}

.menu-toggle-btn {
  display: none;
  border: 0;
  background: #fff;
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

/* STATUS */
.status-box {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 14px;
}

.status-box.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-box.error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* PAGE */
.page-section {
  display: none;
}

.page-section.active {
  display: block;
}

.content-card {
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.card-header h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.card-header p {
  margin: 0;
  color: var(--muted);
}

.badge {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

/* FORM */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px 26px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-group label {
  font-size: 15px;
  font-weight: 600;
  color: #4b5563;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid #d7dde5;
  border-radius: 18px;
  padding: 18px 20px;
  font-size: 16px;
  outline: none;
  background: #fff;
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 180px;
}

.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: #fff;
}

.full-width {
  grid-column: 1 / -1;
}

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

.primary-btn {
  border: 0;
  background: var(--primary);
  color: #fff;
  padding: 14px 22px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

/* JURNAL */
.form-jurnal {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.jurnal-section {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  background: #fcfdff;
}

.jurnal-section h3 {
  margin: 0 0 18px;
  font-size: 20px;
}

.field-hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: -4px;
}

#tilawahDetailSection {
  margin-top: 4px;
}

/* LEGACY CHOICE GROUP - optional */
.choice-group {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
}

.choice-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.choice-group input[type="radio"] {
  transform: scale(1.1);
}

/* MOBILE SIDEBAR */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: 0.25s ease;
  z-index: 20;
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* RESPONSIVE */
@media (max-width: 980px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    height: 100vh;
  }

  .menu-toggle-btn {
    display: inline-grid;
    place-items: center;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    height: 100vh;
    overflow-y: auto;
    padding: 20px;
  }

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

  .topbar-user {
    justify-content: space-between;
  }

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

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

  .topbar h1 {
    font-size: 28px;
  }

  .jurnal-section {
    padding: 18px;
  }

  .content-card {
    padding: 20px;
  }
}

/* CHECKLIST TABLE */
.checklist-table {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.checklist-header,
.checklist-row {
  display: grid;
  grid-template-columns: minmax(340px, 2.4fr) repeat(3, minmax(90px, 110px));
  gap: 16px;
  align-items: center;
}

.checklist-header {
  padding: 0 12px 4px;
  font-weight: 700;
  color: var(--text);
}

.checklist-col-label {
  font-size: 15px;
}

.checklist-col-option {
  text-align: center;
  font-size: 15px;
}

.checklist-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px;
}

.checklist-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checklist-label strong {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

.checklist-label small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.checklist-option {
  display: flex;
  justify-content: center;
  align-items: center;
}

.checklist-option input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}

@media (max-width: 980px) {
  .checklist-header,
  .checklist-row {
    grid-template-columns: 1fr 64px 64px 90px;
    gap: 10px;
  }

  .checklist-header {
    padding: 0 4px 4px;
  }

  .checklist-col-option {
    font-size: 12px;
  }

  .checklist-label strong {
    font-size: 14px;
  }

  .checklist-label small {
    font-size: 11px;
  }
}

/* ERROR HIGHLIGHT */
.input-error {
  border: 1px solid #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.checklist-row-error {
  border: 2px solid #dc2626 !important;
  background: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.checklist-row-error .checklist-label strong,
.checklist-row-error .checklist-label small {
  color: #b42318 !important;
}

.checklist-row-error:hover {
  background: #fee2e2 !important;
  border-color: #dc2626 !important;
}

.checklist-row:hover {
  background: #f1f5f9;
}

.checklist-row-error:hover {
  background: #fee2e2 !important;
}

/* SUCCESS MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}

.modal-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.modal-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #ecfdf3;
  color: #16a34a;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
}

.modal-box h3 {
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--text);
}

.modal-box p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}

.modal-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.modal-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #ecfdf3;
  color: #16a34a;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
}

.modal-box h3 {
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--text);
}

.modal-box p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.modal-loading .modal-box,
.modal-loading {
  text-align: center;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border: 5px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* KBM MODULE */
.kbm-shell {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.kbm-topbar {
  background: linear-gradient(135deg, #1da1f2, #3f6ed1);
  color: #fff;
  border-radius: 26px;
  padding: 34px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.kbm-topbar-left h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: #fff;
}

.kbm-topbar-left p {
  margin: 0;
  color: rgba(255, 255, 255, 0.95);
  font-size: 16px;
  font-weight: 500;
}

.kbm-topbar-right {
  width: 100%;
  max-width: 420px;
}

.kbm-topbar-right label {
  display: none;
}

.kbm-topbar-right select {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #178fe4;
  background: #fff;
  outline: none;
}

.kbm-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px;
}

.kbm-left-card,
.kbm-right-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.kbm-form-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 22px 30px;
}

.kbm-jp-group select {
  min-width: 120px;
}

.kbm-student-header {
  background: linear-gradient(135deg, #1da1f2, #3f6ed1);
  color: #fff;
  border-radius: 18px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 140px;
  font-weight: 700;
  margin-bottom: 16px;
}

.kbm-student-list {
  border: 1px solid var(--border);
  border-radius: 20px;
  max-height: 660px;
  overflow-y: auto;
  padding: 8px 0;
}

.kbm-student-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid #eef2f7;
}

.kbm-student-row:last-child {
  border-bottom: 0;
}

.kbm-student-name {
  font-weight: 600;
  line-height: 1.5;
}

.kbm-student-result select {
  width: 100%;
  border: 0;
  background: transparent;
  font-weight: 700;
  color: #2563eb;
  text-align: right;
}

.kbm-student-empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
}

.kbm-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .kbm-topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 24px 20px;
  }

  .kbm-topbar-right {
    max-width: 100%;
  }

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

  .kbm-form-grid {
    grid-template-columns: 1fr;
  }

  .kbm-student-header,
  .kbm-student-row {
    grid-template-columns: 1fr 110px;
  }
}

.locked-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.locked-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text);
}