/**
 * AUTO GRADE — App layer on DIR//LISTER design system
 * Layout: sidebar shell, spreadsheet grading table, master murid
 * Version: 2.2.0
 */

/* ===== Token aliases (map old AG names → DIRLISTER) ===== */
:root {
  --bg-deep: var(--bg);
  --bg-panel: var(--bg2);
  --bg-elevated: var(--panel);
  --bg-card: var(--panel);
  --bg-input: var(--panel2);
  --border: var(--line);
  --line2: var(--line2);
  --neon-cyan: var(--cyan);
  --neon-magenta: var(--mag);
  --neon-green: var(--green);
  --neon-orange: var(--amber);
  --neon-yellow: var(--neon);
  --neon-red: var(--mag);
  --neon-purple: var(--violet);
  --text: var(--txt);
  --text-dim: var(--dim);
  --text-muted: var(--dim2);
  --white: var(--heading);
  --primary: var(--cyan);
  --success: var(--green);
  --success-bg: var(--ok-soft);
  --danger: var(--mag);
  --danger-bg: var(--danger-soft);
  --warning: var(--amber);
  --warning-bg: var(--warn-soft);
  --sidebar-w: 240px;
  --font-mono: var(--font);
  --glow-cyan: 0 0 12px rgba(0, 240, 255, 0.3);
}

/* ===== Overflow: never scroll the browser window horizontally ===== */
html, body {
  overflow-x: hidden !important;
  max-width: 100%;
  width: 100%;
}
body {
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
}

/* ===== App shell with sidebar ===== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  overflow-x: hidden;
  max-width: 100vw;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  min-height: var(--header-h);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 28px; height: 28px;
  border: 1px solid var(--cyan);
  display: grid; place-items: center;
  color: var(--cyan);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0;
}
.brand-text strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--heading);
}
.brand-text small {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--neon);
}
.sidebar-toggle {
  display: none;
  background: none; border: none; color: var(--cyan); cursor: pointer;
  flex-direction: column; gap: 4px;
}
.sidebar-toggle span {
  display: block; width: 18px; height: 2px; background: var(--cyan);
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: var(--ls-ui);
  text-transform: uppercase;
  border-left: 2px solid transparent;
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-item:hover {
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.04);
  text-decoration: none;
  border-color: transparent;
}
.nav-item.active {
  color: var(--cyan);
  background: var(--accent2-soft);
  border-left-color: var(--neon);
}
.nav-icon { width: 18px; text-align: center; opacity: 0.85; }
.nav-section { margin-top: 14px; }
.nav-section-title {
  display: block;
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--neon);
  opacity: 0.75;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
  width: 28px; height: 28px;
  border: 1px solid var(--mag);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: var(--mag);
  flex-shrink: 0;
}
.user-name {
  font-size: 12px;
  color: var(--dim2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.btn-logout:hover { color: var(--mag); }
.app-version-badge {
  margin: 0 16px 14px;
  padding: 6px 8px;
  border: 1px solid rgba(252, 238, 10, 0.3);
  color: var(--neon);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* Navbar (top bar) */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad-x);
  background: rgba(6, 8, 10, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.navbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-title::before {
  content: "DIR// ";
  color: var(--neon);
}
.mobile-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  flex-direction: column; gap: 4px;
}
.mobile-menu-btn span {
  display: block; width: 20px; height: 2px; background: var(--cyan);
}
.navbar-right { display: flex; align-items: center; gap: 12px; }
.exam-badge {
  border: 1px solid rgba(0, 240, 255, 0.3);
  background: var(--accent2-soft);
  color: var(--cyan);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.navbar-user {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-content {
  flex: 1;
  padding: var(--gap-lg) var(--pad-x) 32px;
  min-width: 0;
  overflow-x: hidden;
  max-width: 100%;
}
.page-footer {
  border-top: 1px solid var(--line);
  padding: 12px var(--pad-x);
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  background: var(--bg2);
}

/* ===== Login ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(0, 240, 255, 0.06), transparent 50%),
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: auto, 40px 40px, 40px 40px;
}
.login-container { width: 100%; max-width: 400px; padding: 20px; position: relative; z-index: 1; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--neon), transparent);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-logo {
  width: 48px; height: 48px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  display: inline-grid; place-items: center;
  font-weight: 700; font-size: 16px;
  margin-bottom: 12px;
  box-shadow: var(--glow-cyan);
}
.login-header h1 {
  font-size: 1.35rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 6px;
}
.login-header p {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}
.login-form .form-group { margin-bottom: 14px; }
.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.login-footer strong { color: var(--neon); }

/* ===== Map AG components → DIRLISTER look ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-radius: 0;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 240, 255, 0.02);
}
.card-header h2, .card-header h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--heading);
}
.card-body { padding: 16px; }
.card-body.p-0 { padding: 0; overflow: hidden; max-width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--dim2);
  font: 600 12px/1 var(--font);
  letter-spacing: var(--ls-ui);
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover {
  color: var(--neon);
  border-color: rgba(252, 238, 10, 0.55);
  background: var(--accent-soft);
  text-decoration: none;
  box-shadow: 0 0 12px rgba(252, 238, 10, 0.12);
}
.btn-primary {
  color: var(--neon);
  border-color: rgba(252, 238, 10, 0.55);
  background: var(--accent-soft);
}
.btn-primary:hover {
  color: var(--heading);
  border-color: var(--neon);
  background: rgba(252, 238, 10, 0.16);
}
.btn-secondary {
  color: var(--dim2);
  border-color: var(--line2);
  background: transparent;
}
.btn-outline {
  color: var(--cyan);
  border-color: rgba(0, 240, 255, 0.35);
  background: transparent;
}
.btn-outline:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--accent2-soft);
}
.btn-danger {
  color: var(--mag);
  border-color: rgba(255, 42, 109, 0.45);
  background: transparent;
}
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--mag);
  color: var(--mag);
  box-shadow: none;
}
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 11px; }
.btn-block { width: 100%; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 4px; font-size: 14px; color: var(--dim); opacity: 0.8;
}
.btn-icon:hover { color: var(--cyan); opacity: 1; }
.btn-link {
  background: none; border: none; color: var(--cyan);
  cursor: pointer; font: inherit; padding: 0;
}
.btn-link:hover { color: var(--heading); }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--txt);
  font: 500 13px/1.4 var(--font);
  border-radius: 0;
  letter-spacing: 0.02em;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(252, 238, 10, 0.55);
  box-shadow: var(--ui-focus);
}
.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-row .flex-2 { flex: 2; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.form-hint { font-size: 11px; color: var(--dim); margin-top: 4px; }
.required { color: var(--mag); }

.alert {
  padding: 12px 14px;
  border: 1px solid var(--line2);
  border-left-width: 3px;
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(10, 14, 19, 0.7);
  border-radius: 0;
}
.alert-success, .alert-ok {
  border-left-color: var(--green);
  background: var(--ok-soft);
  color: var(--green);
}
.alert-error, .alert-danger {
  border-left-color: var(--mag);
  background: var(--danger-soft);
  color: var(--mag);
}
.alert-warning, .alert-warn {
  border-left-color: var(--amber);
  background: var(--warn-soft);
  color: var(--amber);
}
.alert-close {
  background: none; border: none; color: inherit;
  font-size: 18px; cursor: pointer; opacity: 0.6; line-height: 1;
}
.alert-close:hover { opacity: 1; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  background: var(--accent2-soft);
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--dim);
}
.empty-state p { margin-bottom: 14px; }

/* Stats / KPI */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.stat-card.compact {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
}
.stat-card.compact::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--neon);
  box-shadow: 0 0 8px rgba(252, 238, 10, 0.4);
}
.stat-icon {
  width: 40px; height: 40px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: var(--accent2-soft) !important;
  color: var(--cyan) !important;
  display: grid; place-items: center;
  font-size: 16px;
}
.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}
.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

/* Tables */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(10, 14, 19, 0.9);
  white-space: nowrap;
}
.table td { color: var(--txt); }
.table tbody tr:hover { background: rgba(0, 240, 255, 0.03); }
.table .actions { white-space: nowrap; }
.table .actions .btn { margin-right: 4px; }
.table-sm th, .table-sm td { padding: 6px 8px; font-size: 12px; }

/* ===== Spreadsheet (grading) — no overlap sticky ===== */
.spreadsheet-scroll-hint {
  display: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--accent2-soft);
}
@media (max-width: 900px) {
  .spreadsheet-scroll-hint { display: block; }
}

.spreadsheet-wrapper,
#spreadsheetWrapper {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  max-height: calc(100vh - 260px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  background: #0a0e13;
  box-sizing: border-box;
  position: relative;
}

/*
 * Column layout (fixed px — must match sticky left offsets)
 * NO=48  NIS=96  NAMA=160  → NAMA sticky left = 144
 * Q=42 each  RESULT=56  STATUS=96  AKSI=76
 */
.spreadsheet-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  width: max-content;
  min-width: 100%;
  /* do NOT use table-layout:fixed here — conflicts with sticky widths */
}

.spreadsheet-table th,
.spreadsheet-table td {
  border-right: 1px solid #1b2530;
  border-bottom: 1px solid #1b2530;
  padding: 0 2px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  height: 36px;
  box-sizing: border-box;
  overflow: hidden;
}

/* ---- Sticky identity columns (opaque so answers never show through) ---- */
.spreadsheet-table .sticky-col,
.spreadsheet-table td.sticky-col,
.spreadsheet-table th.sticky-col {
  position: sticky !important;
  left: 0 !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  z-index: 30 !important;
  background: #0a0e13 !important;
  background-clip: padding-box !important;
}

.spreadsheet-table .sticky-col-nis,
.spreadsheet-table td.sticky-col-nis,
.spreadsheet-table th.sticky-col-nis,
.spreadsheet-table td.col-nis,
.spreadsheet-table th.col-nis {
  position: sticky !important;
  left: 48px !important;
  width: 96px !important;
  min-width: 96px !important;
  max-width: 96px !important;
  z-index: 30 !important;
  background: #0a0e13 !important;
  background-clip: padding-box !important;
}

.spreadsheet-table .sticky-col-2,
.spreadsheet-table td.sticky-col-2,
.spreadsheet-table th.sticky-col-2,
.spreadsheet-table td.col-name,
.spreadsheet-table th.col-name {
  position: sticky !important;
  left: 144px !important; /* 48+96 */
  width: 160px !important;
  min-width: 160px !important;
  max-width: 160px !important;
  z-index: 30 !important;
  background: #0a0e13 !important;
  background-clip: padding-box !important;
  text-align: left !important;
  /* hard edge so answer cells never visually bleed under */
  box-shadow: 6px 0 10px rgba(0, 0, 0, 0.55) !important;
  border-right: 2px solid #00f0ff55 !important;
}

/* Header sticky cells need higher stacking + match header bg */
.spreadsheet-table thead .sticky-col,
.spreadsheet-table thead .sticky-col-nis,
.spreadsheet-table thead .sticky-col-2,
.spreadsheet-table thead th.col-no,
.spreadsheet-table thead th.col-nis,
.spreadsheet-table thead th.col-name {
  z-index: 40 !important;
  background: #0a0e13 !important;
}

.spreadsheet-table thead tr.header-group .sticky-col,
.spreadsheet-table thead tr.header-group .sticky-col-nis,
.spreadsheet-table thead tr.header-group .sticky-col-2 {
  background: #06080a !important;
  z-index: 42 !important;
  top: 0 !important;
}

.spreadsheet-table thead tr.header-cols th {
  top: 30px !important;
  z-index: 35;
  background: #0a0e13 !important;
}
.spreadsheet-table thead tr.header-cols .sticky-col,
.spreadsheet-table thead tr.header-cols .sticky-col-nis,
.spreadsheet-table thead tr.header-cols .sticky-col-2 {
  top: 30px !important;
  z-index: 42 !important;
  background: #0a0e13 !important;
}

/* Key row sticky */
.spreadsheet-table thead tr.key-row td {
  position: sticky;
  top: 60px !important;
  z-index: 34;
  background: #141208 !important;
  color: #fcee0a;
  font-weight: 700;
  height: 36px;
  border-bottom: 1px solid rgba(252, 238, 10, 0.35);
}
.spreadsheet-table thead tr.key-row .sticky-col,
.spreadsheet-table thead tr.key-row .sticky-col-nis,
.spreadsheet-table thead tr.key-row .sticky-col-2 {
  z-index: 42 !important;
  background: #141208 !important;
  top: 60px !important;
}

/* Header band labels */
.spreadsheet-table thead th {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: #00f0ff;
  height: 30px;
  padding: 0 4px;
}
.spreadsheet-table .header-group th {
  background: #06080a;
  color: #fcee0a;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  top: 0;
  position: sticky;
  z-index: 36;
}

/* Answer columns — never sticky, sit under identity */
.spreadsheet-table .col-q,
.spreadsheet-table td.col-q,
.spreadsheet-table th.col-q {
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  position: static !important;
  left: auto !important;
  z-index: 1 !important;
}

.spreadsheet-table .col-benar,
.spreadsheet-table .col-salah,
.spreadsheet-table .col-kosong,
.spreadsheet-table .col-nilai {
  width: 56px !important;
  min-width: 56px !important;
  max-width: 56px !important;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  position: static !important;
  z-index: 1 !important;
}
.col-benar { color: #00ff9f; }
.col-salah { color: #ff2a6d; }
.col-kosong { color: #7a8b9c; }
.col-nilai { color: #00f0ff; }

.spreadsheet-table .col-status {
  width: 96px !important;
  min-width: 96px !important;
  max-width: 96px !important;
  position: static !important;
  z-index: 1 !important;
}
.spreadsheet-table .col-aksi {
  width: 76px !important;
  min-width: 76px !important;
  max-width: 76px !important;
  position: static !important;
  z-index: 1 !important;
}

.col-no { color: #7a8b9c; font-variant-numeric: tabular-nums; font-size: 11px; }

/* Answer colors — only on non-sticky cells */
.spreadsheet-table td.ans-correct {
  background: rgba(0, 255, 159, 0.16) !important;
  color: #00ff9f;
}
.spreadsheet-table td.ans-correct select { color: #00ff9f; background: transparent; }
.spreadsheet-table td.ans-wrong {
  background: rgba(255, 42, 109, 0.16) !important;
  color: #ff2a6d;
}
.spreadsheet-table td.ans-wrong select { color: #ff2a6d; background: transparent; }
.spreadsheet-table td.ans-empty {
  background: transparent !important;
  color: #7a8b9c;
}

/* Inputs fill sticky cells fully (opaque) */
.cell-name,
.cell-nis {
  display: block;
  width: 100%;
  height: 36px;
  border: 0;
  background: #0a0e13 !important;
  padding: 0 8px;
  margin: 0;
  font: 500 12px/36px var(--font);
  color: #cfd8e0;
  border-radius: 0;
  box-sizing: border-box;
}
.cell-nis {
  text-align: center;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.cell-name:focus,
.cell-nis:focus {
  outline: none;
  background: #0e151c !important;
  box-shadow: inset 0 0 0 1px rgba(252, 238, 10, 0.5);
}

.cell-answer,
.key-select {
  display: block;
  width: 100%;
  height: 36px;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: 700 12px/36px var(--font);
  text-align: center;
  text-align-last: center;
  color: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.cell-answer:focus,
.key-select:focus {
  outline: none;
  background: #0e151c !important;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(252, 238, 10, 0.55);
}

.key-val {
  display: inline-block;
  min-width: 1em;
  font-size: 12px;
  color: #fcee0a;
}

.val-benar, .val-salah, .val-kosong, .val-nilai {
  display: block;
  line-height: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.val-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.status-lulus {
  background: rgba(0, 255, 159, 0.1);
  color: #00ff9f;
  border-color: rgba(0, 255, 159, 0.35);
}
.status-belum-lulus {
  background: rgba(255, 42, 109, 0.1);
  color: #ff2a6d;
  border-color: rgba(255, 42, 109, 0.35);
}

.col-aksi .btn-icon {
  padding: 4px;
  font-size: 13px;
  line-height: 1;
  opacity: 0.75;
}
.col-aksi .btn-icon:hover { opacity: 1; }

/* Row hover — sticky stays opaque */
.spreadsheet-table tbody tr:hover td.col-q {
  filter: brightness(1.08);
}
.spreadsheet-table tbody tr:hover .sticky-col,
.spreadsheet-table tbody tr:hover .sticky-col-nis,
.spreadsheet-table tbody tr:hover .sticky-col-2 {
  background: #0c1218 !important;
}
.spreadsheet-table tbody tr:hover .cell-name,
.spreadsheet-table tbody tr:hover .cell-nis {
  background: #0c1218 !important;
}

.key-table-wrapper { width: 100%; overflow-x: auto; }
.key-table { border-collapse: collapse; font-size: 13px; }
.key-table th, .key-table td {
  border: 1px solid var(--line);
  padding: 6px;
  text-align: center;
  min-width: 48px;
}
.key-table th {
  background: rgba(0, 240, 255, 0.05);
  color: var(--cyan);
  font-size: 10px;
}

/* Toolbar / filter */
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  max-width: 100%;
}
.toolbar-left h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.toolbar-left h2::before {
  content: ">_ ";
  color: var(--green);
}
.exam-info {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.03em;
}
.toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  cursor: pointer;
}
.checkbox-label input { accent-color: var(--neon); width: auto; min-height: auto; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  max-width: 100%;
}
.search-box input {
  min-width: 200px;
  min-height: 36px;
}
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-group select {
  min-height: 36px;
  width: auto;
  min-width: 120px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}
.modal-dialog {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  z-index: 1;
}
.modal-dialog.modal-lg { max-width: 640px; }
.modal-dialog::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--neon));
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
}
.modal-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--dim); line-height: 1;
}
.modal-close:hover { color: var(--mag); }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.text-danger { color: var(--mag); font-size: 13px; margin-top: 6px; }
.text-muted { color: var(--dim); font-size: 13px; }

.detail-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.detail-stats div {
  background: var(--accent2-soft);
  border: 1px solid var(--line);
  padding: 10px;
  text-align: center;
}
.detail-stats span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.detail-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
  color: var(--cyan);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border: 1px solid var(--line2);
  background: rgba(10, 14, 19, 0.95);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--mag); color: var(--mag); }
.toast-warning { border-color: var(--amber); color: var(--amber); }

/* Master murid */
.master-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.master-table { min-width: 1100px; }
.master-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}
.mono { letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }

code {
  background: var(--accent2-soft);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 1px 6px;
  color: var(--cyan);
  font-size: 12px;
}
select option { background: var(--panel2); color: var(--txt); }

/* Print */
@media print {
  @page { size: landscape; margin: 0.8cm; }
  body {
    background: #fff !important;
    color: #111 !important;
    background-image: none !important;
  }
  body::before, body::after { display: none !important; }
  .sidebar, .navbar, .page-footer, .no-print,
  .filter-bar, .page-toolbar, .sidebar-overlay,
  .toast-container, .modal, .app-version-badge,
  .spreadsheet-scroll-hint { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .print-header { display: block !important; color: #111; margin-bottom: 12px; }
  .spreadsheet-wrapper {
    overflow: visible !important;
    max-height: none !important;
    border: 1px solid #ccc !important;
    background: #fff !important;
  }
  .spreadsheet-table th, .spreadsheet-table td {
    border: 1px solid #ccc !important;
    color: #111 !important;
    background: #fff !important;
    font-size: 10px !important;
  }
  .sticky-col, .sticky-col-nis, .sticky-col-2 {
    position: static !important;
    background: #fff !important;
  }
  .ans-correct {
    background: #d4edda !important;
    color: #155724 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .ans-wrong {
    background: #f8d7da !important;
    color: #721c24 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .card { box-shadow: none; border: none; background: #fff; }
  .stats-grid { display: none; }
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .sidebar-toggle { display: flex; }
}
@media (max-width: 768px) {
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-box input { min-width: 0; width: 100%; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .dashboard-actions { flex-direction: column; }
  .dashboard-actions .btn { width: 100%; }
  .exam-badge { display: none; }
  .spreadsheet-wrapper { max-height: 55vh; }
}
@media (max-width: 480px) {
  .login-card { padding: 20px 16px; }
  .brand-text small { display: none; }
}
@media (hover: none) {
  .btn, .nav-item { min-height: 40px; }
  .cell-answer { font-size: 14px; min-height: 36px; }
}

/* ===== DIR//LISTER PRO — chamfer buttons & neon hover ===== */
.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-danger {
  clip-path: var(--clip-btn, none);
  -webkit-clip-path: var(--clip-btn, none);
}
.btn-sm {
  clip-path: var(--clip-sm, none);
  -webkit-clip-path: var(--clip-sm, none);
}
/* Primary = neon yellow (PRO / index.php style) */
.btn-primary {
  border-color: color-mix(in srgb, var(--neon) 50%, var(--line2)) !important;
  background: var(--accent-soft) !important;
  color: var(--neon) !important;
  box-shadow: 0 0 12px color-mix(in srgb, var(--neon) 20%, transparent) !important;
  font-weight: 700 !important;
}
.btn-primary:hover {
  border-color: var(--neon) !important;
  background: #fff !important;
  color: #000 !important;
  box-shadow: 0 0 16px rgba(252, 238, 10, 0.35) !important;
}
.btn:hover {
  border-color: rgba(252, 238, 10, 0.55) !important;
  color: var(--neon) !important;
  background: var(--accent-soft) !important;
}
.btn-danger:hover {
  color: var(--mag) !important;
  border-color: var(--mag) !important;
  background: var(--danger-soft) !important;
  box-shadow: none !important;
}

/* Search / input focus = neon edge (PRO) */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.search-box input:focus,
input:focus, select:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--neon) 55%, transparent) !important;
  box-shadow: var(--ui-focus, 0 0 0 1px rgba(252, 238, 10, 0.45)) !important;
}

/* Card / KPI slight PRO elevation */
.card, .stat-card {
  box-shadow: var(--shadow, 0 8px 28px rgba(0, 0, 0, 0.45)) !important;
}
.stat-card.compact::before {
  background: var(--neon) !important;
}

/* Brand mark PRO */
.brand-icon, .login-logo {
  clip-path: var(--clip-sm, none);
}

/* Version */
.app-version-badge {
  border-color: rgba(252, 238, 10, 0.4) !important;
  color: var(--neon) !important;
}


/* ==========================================================================
   INPUT TABLE (#studentTable) — professional fixed grid, no sticky overlap
   Matches Rekap alignment; inputs/selects cannot expand columns
   ========================================================================== */
#studentTable.spreadsheet-input,
.spreadsheet-input {
  table-layout: fixed !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

#studentTable col.c-no { width: 48px; }
#studentTable col.c-name { width: 180px; }
#studentTable col.c-q { width: 40px; }
#studentTable col.c-stat { width: 52px; }
#studentTable col.c-status { width: 92px; }
#studentTable col.c-aksi { width: 72px; }

#studentTable th,
#studentTable td {
  box-sizing: border-box !important;
  overflow: hidden !important;
  height: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  vertical-align: middle !important;
  border-right: 1px solid #1b2530 !important;
  border-bottom: 1px solid #1b2530 !important;
}


/* Identity sticky — NO + NAMA only (NIS column removed from Input) */
#studentTable .sticky-col,
#studentTable th.col-no,
#studentTable td.col-no {
  position: sticky !important;
  left: 0 !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  z-index: 20 !important;
  background: #0a0e13 !important;
}

#studentTable .sticky-col-2,
#studentTable th.col-name,
#studentTable td.col-name {
  position: sticky !important;
  left: 48px !important;
  width: 180px !important;
  min-width: 180px !important;
  max-width: 180px !important;
  z-index: 20 !important;
  background: #0a0e13 !important;
  text-align: left !important;
  box-shadow: 4px 0 8px rgba(0,0,0,.5) !important;
  border-right: 2px solid rgba(0,240,255,.35) !important;
}

/* hide any leftover NIS cells if present */
#studentTable .col-nis,
#studentTable .sticky-col-nis {
  display: none !important;
}

#studentTable thead th.sticky-col,
#studentTable thead th.sticky-col-nis,
#studentTable thead th.sticky-col-2,
#studentTable thead th.col-no,
#studentTable thead th.col-nis,
#studentTable thead th.col-name {
  z-index: 30 !important;
  background: #06080a !important;
}

#studentTable thead .header-group th {
  position: sticky !important;
  top: 0 !important;
  z-index: 25 !important;
  height: 28px !important;
  background: #06080a !important;
  color: #fcee0a !important;
  font-size: 10px !important;
  letter-spacing: .08em !important;
  text-transform: uppercase !important;
}
#studentTable thead .header-group .sticky-col,
#studentTable thead .header-group .sticky-col-nis,
#studentTable thead .header-group .sticky-col-2 {
  z-index: 32 !important;
  top: 0 !important;
}

#studentTable thead .header-cols th {
  position: sticky !important;
  top: 28px !important;
  z-index: 24 !important;
  height: 28px !important;
  background: #0a0e13 !important;
  color: #00f0ff !important;
  font-size: 10px !important;
}
#studentTable thead .header-cols .sticky-col,
#studentTable thead .header-cols .sticky-col-nis,
#studentTable thead .header-cols .sticky-col-2 {
  z-index: 32 !important;
  top: 28px !important;
  background: #0a0e13 !important;
}

#studentTable thead .key-row td {
  position: sticky !important;
  top: 56px !important;
  z-index: 23 !important;
  height: 30px !important;
  background: #161208 !important;
  color: #fcee0a !important;
  font-weight: 700 !important;
  border-bottom: 1px solid rgba(252,238,10,.3) !important;
}
#studentTable thead .key-row .sticky-col,
#studentTable thead .key-row .sticky-col-nis,
#studentTable thead .key-row .sticky-col-2 {
  z-index: 32 !important;
  top: 56px !important;
  background: #161208 !important;
}

/* Answer + result cols never sticky */
#studentTable td.col-q,
#studentTable th.col-q {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  position: relative !important;
  left: auto !important;
  z-index: 1 !important;
}

#studentTable .col-benar,
#studentTable .col-salah,
#studentTable .col-kosong,
#studentTable .col-nilai {
  width: 52px !important;
  min-width: 52px !important;
  max-width: 52px !important;
  position: relative !important;
  z-index: 1 !important;
  font-weight: 700;
}
#studentTable .col-status {
  width: 92px !important;
  min-width: 92px !important;
  max-width: 92px !important;
  position: relative !important;
  z-index: 1 !important;
}
#studentTable .col-aksi {
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Kill browser min-size on form controls inside grid */
#studentTable input,
#studentTable select {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  height: 34px !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  font-size: 12px !important;
  line-height: 34px !important;
  padding: 0 4px !important;
  box-sizing: border-box !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
#studentTable .cell-nis {
  text-align: center !important;
  background: #0a0e13 !important;
  color: #cfd8e0 !important;
}
#studentTable .cell-name {
  text-align: left !important;
  background: #0a0e13 !important;
  color: #cfd8e0 !important;
  padding-left: 8px !important;
}
#studentTable .cell-nis:focus,
#studentTable .cell-name:focus {
  background: #0e151c !important;
  box-shadow: inset 0 0 0 1px rgba(252,238,10,.45) !important;
}
#studentTable .cell-answer {
  text-align: center !important;
  text-align-last: center !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  color: inherit !important;
}
#studentTable .cell-answer:focus {
  background: #0e151c !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(252,238,10,.5) !important;
}

#studentTable td.ans-correct {
  background: rgba(0,255,159,.15) !important;
  color: #00ff9f !important;
}
#studentTable td.ans-wrong {
  background: rgba(255,42,109,.15) !important;
  color: #ff2a6d !important;
}
#studentTable td.ans-empty {
  background: transparent !important;
  color: #6b7c8c !important;
}

#studentTable tbody tr:hover .sticky-col,
#studentTable tbody tr:hover .sticky-col-nis,
#studentTable tbody tr:hover .sticky-col-2 {
  background: #0c1218 !important;
}
#studentTable tbody tr:hover .cell-name,
#studentTable tbody tr:hover .cell-nis {
  background: #0c1218 !important;
}

/* Result values centered */
#studentTable .val-benar,
#studentTable .val-salah,
#studentTable .val-kosong,
#studentTable .val-nilai {
  display: block;
  line-height: 34px;
  font-weight: 700;
}
#studentTable .val-status,
#studentTable .status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Wrapper polish */
#spreadsheetWrapper {
  background: #0a0e13;
  border: 1px solid #1b2530;
}

/* Class picker (exam create/edit) */
.class-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.class-picker .class-select {
  width: 100%;
  min-height: var(--control-h, 40px);
  background: var(--panel2, #0e151c);
  border: 1px solid var(--line, #1b2530);
  color: var(--cyan, #00f0ff);
  font: 600 12px var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 12px;
  border-radius: 0;
}
.class-picker .class-select:focus {
  outline: none;
  border-color: rgba(252, 238, 10, 0.55);
  box-shadow: var(--ui-focus, 0 0 0 1px rgba(252,238,10,.4));
}


/* ===== MODAL FIX (students + global) — override PRO kit conflict ===== */
.modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2000 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  width: auto !important;
  max-height: none !important;
  overflow: visible !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
.modal.is-open,
.modal:not([hidden]) {
  display: flex !important;
}
.modal[hidden] {
  display: none !important;
}
.modal .modal-backdrop {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.78) !important;
  z-index: 0;
}
.modal .modal-dialog {
  position: relative !important;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  background: #0b1015 !important;
  border: 1px solid #1b2530 !important;
  box-shadow: 0 16px 48px rgba(0,0,0,.55) !important;
}
.modal .modal-dialog.modal-lg {
  max-width: 640px;
}
