/* Ujian Sekolah - tampilan bersama untuk semua halaman.
   Mau ganti warna utama? Ubah --navy di bawah ini. */
:root {
  --navy: #1e3a8a;
  --navy-dark: #152a66;
  --graphite: #2b2d36;      /* warna pensil 2B untuk bulatan jawaban */
  --paper: #f4f6fb;
  --sheet: #ffffff;
  --line: #dde3ee;
  --text: #0f172a;
  --muted: #5b6678;
  --ok: #1f7a4d;   --ok-bg: #e3f3ea;
  --warn: #8a5300; --warn-bg: #fff1d0;
  --bad: #b42318;  --bad-bg: #fde7e4;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", "Droid Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 760px; padding: 0 16px 48px;
  background: var(--paper); color: var(--text); font: 16px/1.5 var(--sans);
}
h1, h2, h3 { font-family: var(--serif); color: var(--navy); font-weight: 600; line-height: 1.3; }
h3 { font-size: 18px; margin: 24px 0 8px; }
p { margin: 8px 0; }
small { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Kop halaman (garis ganda seperti kop surat) ---------- */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 18px 0 12px; margin-bottom: 20px; border-bottom: 5px double var(--navy);
}
.top h2 { margin: 0; font-size: 20px; }
.top button { width: auto; min-height: 40px; padding: 8px 16px; }

/* ---------- Form & tombol ---------- */
input, select, textarea, button {
  font: inherit; font-size: 16px; width: 100%; min-height: 46px;
  padding: 10px 12px; margin: 4px 0; border-radius: 8px;
}
input, select, textarea { background: #fff; border: 1px solid #aeb8c8; color: var(--text); }
textarea { min-height: 0; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(27, 47, 91, .28); border-color: var(--navy);
}
button {
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  font-weight: 600; cursor: pointer; transition: background .12s;
}
button:hover { background: var(--navy-dark); }
button:active { transform: translateY(1px); }
button:focus-visible, a.btn:focus-visible { outline: 3px solid rgba(27, 47, 91, .4); outline-offset: 2px; }
button.gray { background: #fff; color: var(--navy); border-color: #aeb8c8; }
button.gray:hover { background: #eef2f8; }
button.red { background: #fff; color: var(--bad); border-color: #e0a7a0; }
button.red:hover { background: var(--bad-bg); }
button.green { background: var(--ok); border-color: var(--ok); }
button.green:hover { background: #17623d; }

a.btn {
  display: flex; align-items: center; justify-content: center; min-height: 46px;
  margin: 4px 0; padding: 10px 12px; border-radius: 8px;
  background: var(--navy); color: #fff; font-weight: 600; text-decoration: none;
}
a.btn.green { background: var(--ok); }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row button { flex: 1 1 140px; width: auto; }

/* ---------- Kartu, label, teks ---------- */
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 12px 0; }
.card h3 { margin-top: 0; }
.card { overflow-wrap: anywhere; }
.card ul { margin: 8px 0; padding-left: 20px; }

.tag {
  display: inline-block; padding: 4px 9px; border-radius: 999px; vertical-align: middle;
  background: #e8ecf3; color: #3a475c; font: 600 12px/1 var(--sans);
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

.ans {
  background: #f6f8fb; border-left: 3px solid var(--navy); border-radius: 4px;
  padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; font: 16px/1.6 var(--serif);
}
.good { color: var(--ok); font-weight: 600; }
.mine { color: var(--navy); font-weight: 600; }
.msg { white-space: pre-wrap; font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--bad); }

details { margin: 8px 0; }
summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.card > a:not(.btn) { color: var(--navy); font-weight: 600; }

/* ---------- Rumus ---------- */
sup, sub { font-size: .75em; line-height: 0; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; line-height: 1.25; }
.frac .fn { border-bottom: 1.5px solid currentColor; padding: 0 4px; }
.frac .fd { padding: 0 4px; }
.sqrt { white-space: nowrap; }
.sqrt .rb { border-top: 1.5px solid currentColor; padding: 0 2px; margin-left: 1px; }

/* ---------- Gambar soal ---------- */
.qimg { display: block; max-width: 100%; height: auto; margin: 10px 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.card .qimg { max-width: min(100%, 440px); }
.qimg.zoomable { cursor: zoom-in; }
#lightbox { position: fixed; inset: 0; z-index: 25; padding: 12px; background: rgba(0, 0, 0, .9);
            display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }

/* ---------- Pilihan jawaban bergambar ---------- */
.optimg { display: block; max-width: 100%; max-height: 220px; width: auto; height: auto; object-fit: contain;
          background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.card .optimg { max-height: 120px; }
.opt .optimg { max-height: 220px; margin-bottom: 4px; }
.optcap { margin-top: 4px; }
button.zoombtn { width: auto; min-height: 34px; margin: 6px 0 0; padding: 4px 10px; font-size: 14px; }

.optrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.optrow input[type=text] { flex: 1 1 180px; width: auto; margin: 0; }
.optrow input[type=radio] { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; }
.optrow button { width: auto; min-height: 40px; margin: 0; padding: 6px 12px; }
.optletter { flex: none; width: 20px; color: var(--navy); }
.optthumb { max-height: 44px; max-width: 80px; background: #fff; border: 1px solid var(--line); border-radius: 4px; }

/* ---------- Alat bantu rumus (guru) ---------- */
.mathbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
button.mkey { width: auto; min-height: 36px; margin: 0; padding: 4px 10px; background: #fff; color: var(--navy);
              border: 1px solid #aeb8c8; font-weight: 600; }
button.mkey:hover { background: #eef2f8; }
#qPreview { margin: 8px 0; padding: 10px 12px; background: #fafbfd; border: 1px dashed #aeb8c8; border-radius: 8px; }
.popt { margin: 4px 0 0 4px; }

/* ---------- Identitas sekolah ---------- */
.brandbar { display: flex; align-items: center; gap: 10px; padding: 14px 0 0; font: 600 14px var(--sans); color: var(--navy); }
.brandbar img { height: 34px; width: auto; max-width: 90px; object-fit: contain; }
.brandbar + .top { padding-top: 10px; }
.login-logo { display: block; margin: 0 auto 14px; height: 108px; width: auto; max-width: 70%; object-fit: contain; }
.logo-preview-img { display: block; max-height: 96px; max-width: 200px; object-fit: contain; margin: 8px 0; padding: 6px;
                    background: #fff; border: 1px dashed #aeb8c8; border-radius: 8px; }

/* ---------- Filter daftar ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 8px; }
.filters .wide { grid-column: 1 / -1; }

/* ---------- Kelas ---------- */
.classrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.classrow b { flex: 1 1 140px; }
.classrow button { width: auto; min-height: 36px; margin: 0; padding: 4px 12px; }
.chk { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-weight: 600; cursor: pointer; }
.chk input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; }

/* ---------- Kartu ujian (pratinjau di layar dan cetak) ---------- */
#printArea { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.kartu { background: #fff; color: #000; border: 1.5px solid var(--navy); border-radius: 6px; padding: 10px 12px; break-inside: avoid; page-break-inside: avoid; }
.kartu-head { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 3px double var(--navy); }
.kartu-head img { height: 34px; width: auto; max-width: 52px; object-fit: contain; }
.kartu-head b { font: 700 12px/1.25 var(--sans); color: var(--navy); }
.kartu-title { margin: 0 0 6px; text-align: center; font: 700 13px var(--serif); letter-spacing: .12em; }
.kartu table { width: 100%; border-collapse: collapse; font: 12px/1.5 var(--sans); }
.kartu td { padding: 1px 0; vertical-align: top; }
.kartu td:first-child { width: 58px; color: #444; }
.kartu .pw { font: 700 15px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .1em; }
.kartu-url { margin-top: 6px; padding-top: 4px; border-top: 1px dashed #888; font: 10px/1.3 var(--sans); color: #444; word-break: break-all; }
@media (max-width: 560px) { #printArea { grid-template-columns: 1fr; } }
@media print {
  @page { size: A4; margin: 10mm; }
  body > *:not(#cardSection) { display: none !important; }
  #cardSection > *:not(#printArea) { display: none !important; }
  body { max-width: none; margin: 0; padding: 0; background: #fff; }
  #printArea { grid-template-columns: repeat(2, 1fr); gap: 0; margin: 0; }
  .kartu { height: 66mm; margin: 0; padding: 4mm 5mm; border: 1px dashed #666; border-radius: 0;
           -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Halaman masuk ---------- */
body.login-page { max-width: 420px; padding-top: 8vh; }
.login-head { text-align: center; padding-bottom: 16px; margin-bottom: 20px; border-bottom: 5px double var(--navy); }
.login-head h1 { margin: 0 0 6px; font-size: 30px; }
.login-head p { margin: 0; color: var(--muted); }
label.field { display: block; margin-top: 12px; font-size: 14px; font-weight: 600; }
#error { min-height: 1.4em; margin: 10px 0 0; color: var(--bad); }

/* ---------- Siswa: lembar ujian ---------- */
.noselect { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

#bar { position: sticky; top: 0; z-index: 5; margin-bottom: 8px; padding: 10px 0 8px;
       background: var(--paper); border-bottom: 1px solid var(--line); }
#bar .top { padding: 0; margin: 0; border: 0; }
#examTitle { font: 600 17px/1.3 var(--serif); color: var(--navy); }
#timer { padding: 6px 12px; border: 1.5px solid var(--navy); border-radius: 8px;
         font: 700 22px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--navy); }
.barline { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 13px; color: var(--muted); }

.qhead { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.qnum { flex: none; min-width: 26px; font: 600 20px/1.5 var(--serif); color: var(--navy); }
.qnum::after { content: "."; }
.qtext { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 18px/1.6 var(--serif); }
.pts { display: block; margin-top: 2px; font: 13px var(--sans); color: var(--muted); }

.opt { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px;
       margin: 8px 0; padding: 8px 12px; background: #fff; border: 1px solid var(--line);
       border-radius: 10px; cursor: pointer; }
.opt:hover { border-color: #8e9bb3; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; }
.bub { flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
       border: 2px solid var(--graphite); border-radius: 50%; color: var(--graphite);
       font: 600 14px var(--sans); transition: background .12s, color .12s; }
.opt input:checked + .bub { background: var(--graphite); color: #fff; }
.opt input:focus-visible + .bub { outline: 3px solid rgba(27, 47, 91, .4); outline-offset: 2px; }
.opt:has(input:checked) { border-color: var(--graphite); background: #f3f4f7; }
.otxt { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 17px/1.4 var(--serif); }

#warning { position: fixed; inset: 0; z-index: 30; padding: 24px; background: rgba(122, 20, 14, .97); color: #fff;
           display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
#warning h1 { margin: 0 0 12px; color: #fff; font-size: 30px; }
#warning p { max-width: 420px; }
#warning button { max-width: 320px; background: #fff; color: var(--bad); border-color: #fff; }

.check { position: relative; width: 56px; height: 56px; margin: 4px 0 16px; border-radius: 50%; background: var(--ok); }
.check::after { content: ""; position: absolute; left: 20px; top: 10px; width: 13px; height: 26px;
                border: solid #fff; border-width: 0 4px 4px 0; transform: rotate(45deg); }
#doneView .card h2 { margin: 0 0 8px; font-size: 24px; }
#doneView { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; }
#doneView .card { width: 100%; max-width: 520px; padding: 28px 20px; text-align: center; }
#doneView .check { margin: 4px auto 16px; }
#doneView .card button { display: block; width: 100%; max-width: 320px; margin: 16px auto 0; }

@media (max-width: 480px) {
  .top h2 { font-size: 18px; }
  .login-head h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* =====================================================================
   TAMPILAN MODERN (hanya layar; cetak kartu tidak terpengaruh)
   - Dasar: warna, bentuk, bayangan
   - HP / tablet kecil (di bawah 900px): satu kolom, tombol besar, bilah atas lengket
   - Komputer (900px ke atas): halaman lebar, kartu dua kolom, daftar berbentuk grid
   ===================================================================== */
@media screen {
  :root { --radius: 14px; --shadow-sm: 0 1px 2px rgba(15,23,42,.08);
          --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06); }
  body { font-family: var(--sans); -webkit-font-smoothing: antialiased; }
  h1, h2, h3 { font-family: var(--sans); font-weight: 700; letter-spacing: -.015em; }
  h3 { font-size: 17px; }

  .top { border-bottom: 1px solid var(--line); padding: 14px 0; margin-bottom: 18px; }
  .top h2 { font-size: 19px; }
  .brandbar { padding-top: 16px; }

  .card { border: 1px solid rgba(15,23,42,.07); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
  input, select, textarea, button, a.btn { border-radius: 10px; }
  input, select, textarea { border: 1px solid #c9d1e0; transition: border-color .12s, box-shadow .12s; }
  input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--navy); box-shadow: 0 0 0 4px rgba(30,58,138,.15); }
  button, a.btn { box-shadow: var(--shadow-sm); transition: background .12s, box-shadow .12s, transform .05s; }
  button.gray { border-color: var(--line); }
  button.red { border-color: #f0c4be; }
  .tag { padding: 5px 10px; }
  label.field { color: var(--muted); font-size: 13px; letter-spacing: .01em; }
  details { background: #f8fafd; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }

  /* Halaman masuk */
  body.login-page { background: linear-gradient(180deg, #e3eafb 0, var(--paper) 340px) no-repeat, var(--paper); }
  .login-head { border-bottom: 0; }
  .login-head h1 { font-size: 28px; }
  body.login-page .card { padding: 24px; box-shadow: 0 12px 40px rgba(30,58,138,.12); }

  /* Lembar ujian siswa */
  .qtext, .otxt, .qnum, .ans { font-family: var(--sans); }
  .qtext { font-size: 17px; line-height: 1.65; }
  .otxt { font-size: 16px; }
  .opt { border: 1.5px solid var(--line); border-radius: 12px; transition: border-color .12s, background .12s; }
  .opt:hover { border-color: #93a4c9; background: #fafbfe; }
  .opt:has(input:checked) { border-color: var(--navy); background: #eef3ff; }
  .opt input:checked + .bub { background: var(--navy); border-color: var(--navy); }
  #bar { background: rgba(244,246,251,.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  #examTitle { font-family: var(--sans); }
  #timer { border: 0; background: var(--navy); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 20px; }

  /* Kotak dialog dari ui.js */
  body #uiModal { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  body #uiModal .uibox { border-radius: 18px; padding: 24px; font-family: var(--sans); box-shadow: 0 24px 60px rgba(15,23,42,.3); }
  body #uiModal button { border-radius: 10px; min-height: 46px; background: var(--navy); font-weight: 600; }
  body #uiModal button.uigray { background: #fff; color: var(--navy); border: 1px solid var(--line); }
  body #uiModal input { border-radius: 10px; border: 1px solid #c9d1e0; }

  /* ---------- HP dan tablet kecil ---------- */
  @media (max-width: 899px) {
    body { padding: 0 12px calc(32px + env(safe-area-inset-bottom, 0px)); }
    body > .top { position: sticky; top: 0; z-index: 6; margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px;
                  background: rgba(244,246,251,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
    .card { padding: 16px; border-radius: 16px; }
    input, select, textarea, button, a.btn { min-height: 50px; }
    textarea { min-height: 0; }
    .opt { min-height: 60px; padding: 10px 14px; }
    .bub { width: 36px; height: 36px; }
    .mathbar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    button.mkey { flex: none; min-height: 40px; }
    .student-page #examView > button.green { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 4;
                                              box-shadow: 0 10px 28px rgba(31,122,77,.4); }
    #lightbox { padding: 8px; }
  }
  @media (max-width: 480px) {
    .row button { flex-basis: 100%; }
    #timer { font-size: 18px; padding: 6px 12px; }
  }

  /* ---------- Komputer ---------- */
  @media (min-width: 900px) {
    body { max-width: 1120px; padding: 0 32px 64px; }
    body.student-page { max-width: 860px; }
    body.login-page { max-width: 440px; }
    .top h2 { font-size: 22px; }
    .card { padding: 22px; }
    .qtext { font-size: 18px; }
    .opt { min-height: 56px; }

    /* daftar berbentuk grid kartu */
    #examList, #resList, #userList { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
    #examList > .card, #resList > .card, #userList > .card { margin: 0; }
    .student-page #examList { grid-template-columns: repeat(2, 1fr); }

    /* guru: halaman ujian berkolom dua */
    .teacher-page #examView { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-start; }
    .teacher-page #examView > button { flex: 0 0 auto; width: auto; margin: 0; padding-left: 22px; padding-right: 22px; }
    .teacher-page #examView > h3, .teacher-page #examView > #questionList { flex: 1 1 100%; margin: 8px 0 0; }
    .teacher-page #examView > .card { flex: 1 1 calc(50% - 8px); min-width: 0; margin: 0; }
    .teacher-page #resultsView > button, .teacher-page #gradeView > button,
    .teacher-page #listView > .card > button { width: auto; padding-left: 22px; padding-right: 22px; }
    .teacher-page a.btn { display: inline-flex; width: auto; padding-left: 22px; padding-right: 22px; }
    .teacher-page #gQuestions .card input[type=number] { max-width: 220px; }

    .admin-page .card a.btn { display: inline-flex; width: auto; padding-left: 22px; padding-right: 22px; }
  }
}


/* ---------- Perapian: filter ujian dan kartu ujian seragam ---------- */
@media screen {
  .filters { display: flex; flex-wrap: wrap; gap: 10px; }
  .filters > select { flex: 1 1 180px; min-width: 0; margin: 0; }
  .filters > input.wide { flex: 1 1 100%; margin: 0; }
  .filters-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
  .filters-foot button { flex: none; width: auto; min-height: 40px; margin: 0; padding: 6px 18px; }

  /* semua kartu dalam satu baris sama tinggi; tombol selalu rata di bagian bawah */
  #examList, #resList, #userList { align-items: stretch; }
  .teacher-page #examList > .card { display: flex; flex-direction: column; margin: 0; }
  .teacher-page #examList > .card .exam-info { flex: 1; }
  .teacher-page #examList > .card .row { margin-top: 14px; flex-wrap: nowrap; }
  .teacher-page #examList > .card .row button { flex: 1 1 0; min-width: 0; margin: 0; }
  .exam-info > * { margin-bottom: 8px; }
  .exam-info small { display: block; line-height: 1.45; }
  .exam-title { font-size: 16px; font-weight: 700; line-height: 1.35; color: var(--text); }
  .exam-meta { color: var(--muted); font-size: 14px; }
}


/* ---------- Perapian halaman admin ---------- */
@media screen {
  .admin-col { min-width: 0; }
  .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 8px; }
  .section-head h3 { margin: 0; font-size: 19px; }
  .section-head p { margin: 0; color: var(--muted); font-size: 14px; }
  .admin-page .card > h3 { margin-bottom: 6px; }
  .admin-page .card > h3 + small { display: block; margin-bottom: 12px; line-height: 1.55; }
  .admin-page .card > button, .admin-page .card > a.btn { margin-top: 10px; }
  .admin-page .card > .row { margin-top: 12px; }
  .admin-page .card > select + input, .admin-page .card > select + select { margin-top: 8px; }

  input[type=file] { min-height: 0; padding: 8px; background: #f8fafd; border-style: dashed; color: var(--muted); font-size: 14px; }
  input[type=file]::file-selector-button { margin-right: 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
                                           background: #fff; color: var(--navy); font: 600 14px var(--sans); cursor: pointer; }
  input[type=file]::file-selector-button:hover { background: #eef2f8; }

  #userList .row button { flex: 1 1 auto; min-height: 40px; padding: 6px 12px; font-size: 14px; margin: 0; }
  #userList .card select { margin: 10px 0 0; }
  #userList .row { margin-top: 12px; }
  .classrow:first-child { border-top: 0; }
  .classrow { border-top: 1px solid var(--line); }
  #classList { margin-top: 10px; }

  @media (min-width: 900px) {
    .admin-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
    .admin-col > .card:first-child { margin-top: 0; }
  }
}


/* ---------- Perapian halaman hasil ujian ---------- */
@media screen {
  .res-head { align-items: flex-end; margin: 20px 0 14px; flex-wrap: wrap; }
  .teacher-page #resultsView .res-head a.btn { flex: none; width: auto; margin: 0; }
  #resSummary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .stat { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: 13px; }
  .stat b { color: var(--text); font-size: 14px; }

  #resList { display: block; padding: 0; background: #fff; border: 1px solid rgba(15,23,42,.07);
             border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  #resList:not(:has(.res-row)) { padding: 20px; color: var(--muted); }
  .res-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.4fr) 96px auto; gap: 8px 16px; align-items: center; padding: 14px 18px; }
  .res-row + .res-row { border-top: 1px solid var(--line); }
  .res-who b, .res-who small, .res-score small, .res-score b { display: block; }
  .res-who small, .res-score small { color: var(--muted); font-size: 13px; }
  .res-tags { display: flex; flex-wrap: wrap; gap: 6px; }
  .res-score { text-align: right; }
  .res-score b { font-size: 16px; }
  .res-row > .row { margin: 0; flex-wrap: nowrap; justify-content: flex-end; }
  .res-row > .row button { flex: none; width: auto; min-height: 38px; margin: 0; padding: 6px 14px; font-size: 14px; white-space: nowrap; }

  @media (max-width: 899px) {
    .res-row { grid-template-columns: minmax(0, 1fr) auto; }
    .res-who { order: 1; } .res-score { order: 2; } .res-tags { order: 3; grid-column: 1 / -1; }
    .res-row > .row { order: 4; grid-column: 1 / -1; flex-wrap: wrap; justify-content: stretch; }
    .res-row > .row button { flex: 1 1 auto; }
  }
}


/* ---------- Perapian dashboard siswa ---------- */
@media screen {
  .exam-card { display: flex; flex-direction: column; border-left: 4px solid var(--navy); }
  .exam-card.ok { border-left-color: var(--ok); }
  .exam-card.warn { border-left-color: #d98a00; }
  .exam-card.bad { border-left-color: var(--bad); }
  .exam-card.neutral { border-left-color: #9aa8c4; }
  .exam-card .exam-info { flex: 1; }
  .exam-actions { margin-top: 14px; }
  .exam-actions button { margin: 0; }
  .student-page .exam-title { font-size: 17px; }
  .student-page #examList:not(:has(.card)) { display: block; padding: 32px 20px; text-align: center; color: var(--muted);
                                              background: #fff; border: 1px dashed #c9d1e0; border-radius: var(--radius); }
}

/* ---------- Perapian halaman ujian guru ---------- */
@media screen and (min-width: 900px) {
  .teacher-page #examView > .card { align-self: stretch; }   /* kartu sebaris sama tinggi */
  #classBoxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 16px; }
}


/* ---------- Kotak aturan ujian ---------- */
@media screen {
  body #uiModal .uibox { max-height: calc(100vh - 32px); overflow-y: auto; }
  body #uiModal.uiwide .uibox { max-width: 520px; }
  body #uiModal h3 { font-size: 20px; margin-bottom: 6px; }
  body #uiModal p { color: var(--muted); }
  body #uiModal ul { margin: 4px 0 16px; padding: 0; list-style: none; counter-reset: rule; }
  body #uiModal li { counter-increment: rule; display: flex; gap: 12px; align-items: flex-start; margin: 0 0 8px; padding: 11px 14px;
                     background: #f4f7fd; border: 1px solid #e3e9f5; border-radius: 12px; font-size: 14.5px; line-height: 1.5; color: var(--text); }
  body #uiModal li::before { content: counter(rule); flex: none; display: grid; place-items: center; width: 24px; height: 24px;
                             border-radius: 50%; background: var(--navy); color: #fff; font: 700 12px/1 var(--sans); margin-top: 1px; }
}


/* ---------- Teks pembuka halaman masuk ---------- */
@media screen {
  .login-intro { margin-bottom: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
  .login-intro h2 { margin: 0 0 4px; font-size: 22px; }
  .login-intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
  #error { min-height: 0; }
  #error:empty { display: none; }
  #error:not(:empty) { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); font-size: 14px; }
}

/* ---------- Teks pembuka halaman masuk: rata tengah ---------- */
@media screen {
  .login-intro { text-align: center; }
}


/* ---------- Footer hak cipta ---------- */
.site-footer { margin-top: 48px; padding: 18px 0 8px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 13px; }
@media print { .site-footer { display: none !important; } }


/* ---------- Tombol unduh template impor ---------- */
a.btn.gray { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.row a.btn { flex: 1 1 200px; width: auto; margin: 0; text-align: center; }

/* ---------- Kartu ujian: logo dan nama sekolah rata tengah ---------- */
.kartu-head { justify-content: center; text-align: center; }


/* ---------- Daftar pilihan jawaban di tampilan guru (A. B. C. ...) ---------- */
.optlist { margin: 10px 0 6px; }
.optlist .popt { margin: 3px 0; padding: 4px 8px; border-radius: 8px; }
.optlist .popt.key { background: var(--ok-bg); }
.optlist .popt b { display: inline-block; min-width: 1.4em; color: var(--navy); }


/* ---------- Pemeriksaan sebelum impor ---------- */
#importCheck { margin-top: 14px; }
.chk-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chk-box { margin: 10px 0; padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.chk-box.err { background: var(--bad-bg); color: var(--bad); }
.chk-box.warn { background: var(--warn-bg); color: var(--warn); }
.chk-box.ok { background: var(--ok-bg); color: var(--ok); }
.chk-box ul { margin: 6px 0 0; padding-left: 20px; }
.chk-list { max-height: 380px; overflow: auto; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.chk-q { display: flex; gap: 12px; align-items: flex-start; padding: 9px 14px; font-size: 14px; line-height: 1.45; }
.chk-q + .chk-q { border-top: 1px solid var(--line); }
.chk-q.warn { background: #fffaf0; }
.chk-no { flex: none; min-width: 28px; font-weight: 700; color: var(--navy); }
.chk-q small { display: block; color: var(--muted); }
.chk-q small.chk-warn { color: var(--warn); }


/* ---------- Layar hasil pemeriksaan impor (komputer) ---------- */
#importModal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px;
               background: rgba(15,23,42,.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#importModal .imbox { display: flex; flex-direction: column; width: 100%; max-width: 960px; max-height: calc(100vh - 48px);
                      background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(15,23,42,.35); }
.imhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.imhead h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.imhead .imclose { flex: none; width: 40px; min-height: 40px; margin: 0; padding: 0; font-size: 22px; line-height: 1; }
.imbody { flex: 1; padding: 18px 24px; overflow-y: auto; }
.imfoot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: #f8fafd; }
.imfoot button { width: auto; min-height: 44px; margin: 0; padding: 8px 26px; }
.chk-hint { margin-right: auto; color: var(--muted); }
#importModal .chk-list { max-height: none; overflow: visible; margin: 0; }
.chk-q { align-items: baseline; }
.chk-txt { flex: 1; min-width: 0; }
.chk-info { flex: none; white-space: nowrap; text-align: right; }

/* =====================================================================
   KERANGKA ADMIN & GURU: menu samping, dashboard, tab
   Layar lebar (1100px ke atas): menu samping tetap di kiri.
   Layar lebih sempit: menu menjadi bilah di atas.
   ===================================================================== */
@media screen {
  body.admin-page, body.teacher-page { max-width: none; margin: 0; padding: 0; }
  .shell { display: block; }
  .side { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
  .side-brand { display: flex; align-items: center; gap: 10px; font: 700 15px/1.3 var(--sans); color: var(--navy); }
  .side-brand img { height: 38px; width: auto; max-width: 56px; object-fit: contain; }
  .side-nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
  .side-nav a { display: block; padding: 10px 14px; border-radius: 10px; color: #334155; font-size: 15px; font-weight: 600; text-decoration: none; }
  .side-nav a:hover { background: #eef2fb; }
  .side-nav a.active { background: var(--navy); color: #fff; }
  .side-user { display: flex; align-items: center; gap: 12px; }
  .side-user small { display: block; color: var(--muted); font-size: 12px; }
  .side-user b { display: block; font-size: 14px; overflow-wrap: anywhere; }
  .side-user button { width: auto; min-height: 38px; margin: 0; padding: 6px 16px; }
  .main { padding: 20px 16px 8px; }

  .page-head { margin-bottom: 20px; }
  .page-head h2 { margin: 0 0 4px; font-size: 26px; }
  .page-head p { margin: 0; color: var(--muted); font-size: 15px; }

  /* kartu berpasangan dan susunan dua kolom */
  .two { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
  .two > .card, .stack > .card { margin: 0; }
  .stack { display: flex; flex-direction: column; gap: 18px; }

  /* statistik dashboard */
  .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
  .stat-card { padding: 16px 18px; background: #fff; border: 1px solid rgba(15,23,42,.07); border-top: 4px solid var(--navy);
               border-radius: 14px; box-shadow: var(--shadow); }
  .stat-card.live { border-top-color: var(--ok); }
  .stat-card.warn { border-top-color: #d98a00; }
  .stat-card small { display: block; color: var(--muted); font-size: 13px; }
  .stat-card b { display: block; margin-top: 4px; font-size: 30px; line-height: 1.2; font-variant-numeric: tabular-nums; }
  .stat-card .of { color: var(--muted); font-size: 13px; font-weight: 500; }
  .dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .dash-grid .card { margin: 0 0 18px; }
  .tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
  .tbl th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; }
  .tbl td { padding: 10px; border-bottom: 1px solid #eef1f7; vertical-align: middle; }
  .tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
  .tbl small { color: var(--muted); }
  .bar { height: 6px; margin-top: 8px; overflow: hidden; background: #e8ecf3; border-radius: 99px; }
  .bar i { display: block; height: 100%; background: var(--ok); }
  .alert-list { margin: 0; padding: 0; list-style: none; }
  .alert-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef1f7; font-size: 14px; }
  .alert-list li:last-child { border-bottom: 0; }
  .alert-list a { flex: none; font-weight: 600; color: var(--navy); }
  .empty { margin: 4px 0; color: var(--muted); font-size: 14px; }

  /* halaman satu ujian: kepala dan tab */
  .teacher-page #examView { display: block; }
  .back { width: auto; min-height: 38px; margin: 0; padding: 6px 16px; }
  .exam-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
  .exam-titlebar h3 { margin: 0; font-size: 24px; }
  .exam-btns { display: flex; flex-wrap: wrap; gap: 8px; }
  .exam-btns button { width: auto; min-height: 42px; margin: 0; padding: 8px 18px; }
  .tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 20px 0 22px; border-bottom: 1px solid var(--line); }
  .tabs button { width: auto; min-height: 46px; margin: 0 0 -1px; padding: 8px 20px; background: transparent; color: #475569; font-weight: 600;
                 border: 0; border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0; box-shadow: none; }
  .tabs button:hover { background: #eef2fb; }
  .tabs button.active { color: var(--navy); border-bottom-color: var(--navy); }
  .tab-count { margin-left: 6px; padding: 2px 9px; background: #e8ecf3; border-radius: 99px; font-size: 12px; }
  .grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: stretch; }
  .grid3 > .card { margin: 0; }

  /* pratinjau kartu ujian: layar tersendiri di atas halaman */
  #cardSection { position: fixed; z-index: 40; top: 24px; bottom: 24px; left: 50%; transform: translateX(-50%);
                 width: min(1000px, calc(100% - 48px)); padding: 24px; overflow: auto; background: #fff; border-radius: 18px;
                 box-shadow: 0 0 0 100vmax rgba(15,23,42,.55), 0 24px 60px rgba(15,23,42,.35); }
  #cardSection h3 { margin-top: 0; }

  @media (min-width: 1100px) {
    .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
    .side { position: sticky; top: 0; height: 100vh; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 20px;
            padding: 22px 14px; border-bottom: 0; border-right: 1px solid var(--line); }
    .side-brand { padding: 0 10px 18px; border-bottom: 1px solid var(--line); }
    .side-nav { flex: 1; flex-direction: column; flex-wrap: nowrap; }
    .side-user { flex-direction: column; align-items: stretch; padding: 14px 10px 0; border-top: 1px solid var(--line); }
    .side-user button { width: 100%; }
    .main { width: 100%; max-width: 1500px; padding: 32px 40px 16px; }
  }
  @media (max-width: 1099px) { .dash-grid { grid-template-columns: 1fr; } }
}

/* ---------- Halaman masuk: muat dalam satu layar (komputer dan HP) ---------- */
@media screen {
  body.login-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
                    padding: 16px; }
  body.login-page .login-head { margin-bottom: clamp(8px, 2vh, 20px); padding-bottom: 0; }
  body.login-page .login-logo { height: clamp(52px, 12vh, 96px); margin-bottom: clamp(6px, 1.6vh, 14px); }
  body.login-page .login-head h1 { margin-bottom: 4px; font-size: clamp(22px, 4.4vh, 28px); }
  body.login-page .card { margin: 0; padding: clamp(16px, 3vh, 24px); }
  body.login-page .login-intro { margin-bottom: 4px; padding-bottom: clamp(8px, 1.8vh, 14px); }
  body.login-page label.field { margin-top: clamp(8px, 1.6vh, 12px); }
  body.login-page .site-footer { margin-top: 16px; padding: 4px 0 0; border-top: 0; }
}
/* layar sangat pendek (mis. HP mendatar): ringkas lebih jauh */
@media screen and (max-height: 600px) {
  body.login-page .login-logo { height: 44px; }
  body.login-page .login-head p, body.login-page .login-intro p, body.login-page .site-footer { display: none; }
}


/* ---------- Statistik dengan ikon dan daftar siswa per ujian ---------- */
@media screen {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  @media (min-width: 1500px) { .stat-grid { grid-template-columns: repeat(6, 1fr); } }
  .stat-card { display: flex; align-items: center; gap: 14px; border-top: 1px solid rgba(15,23,42,.07); }
  .stat-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #eaf0ff; color: var(--navy); }
  .stat-card.live .stat-ico { background: var(--ok-bg); color: var(--ok); }
  .stat-card.warn .stat-ico { background: var(--warn-bg); color: var(--warn); }
  .stat-text { min-width: 0; }
  .stat-card b { margin-top: 2px; }

  .tbl tr.clickable { cursor: pointer; }
  .tbl tr.clickable:hover td { background: #f6f8fd; }
  .lnk { color: var(--navy); font-weight: 600; }

  #pesertaModal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px;
                  background: rgba(15,23,42,.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
  #pesertaModal .imbox { display: flex; flex-direction: column; width: 100%; max-width: 1000px; max-height: calc(100vh - 48px);
                         background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(15,23,42,.35); }
  .imhead small { color: var(--muted); }
  .pfilter { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
  .pfilter input { flex: 1 1 220px; max-width: 320px; margin: 0; }
  .pchips { display: flex; flex-wrap: wrap; gap: 8px; }
  .pchip { width: auto; min-height: 36px; margin: 0; padding: 6px 14px; background: #fff; color: #334155; font-size: 14px; font-weight: 600;
           border: 1px solid var(--line); border-radius: 99px; box-shadow: none; }
  .pchip:hover { background: #eef2fb; }
  .pchip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
  .pchip b { margin-left: 4px; opacity: .85; }
}


/* ---------- Ujian siswa: satu soal per layar dengan navigasi nomor ---------- */
@media screen {
  button:disabled { opacity: .45; cursor: not-allowed; }
  .exam-layout { display: block; }
  .qtools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .qpos { font-weight: 700; color: var(--navy); }
  .qtools-btns { display: flex; gap: 8px; }
  .qtools-btns button { width: auto; min-height: 38px; margin: 0; padding: 6px 14px; font-size: 14px; }
  #flagBtn.flagged { background: #fff1d0; color: #8a5300; border-color: #e8c26b; }
  .qnav-bar { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 10px; margin-top: 14px;
              padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); background: rgba(244,246,251,.92);
              -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .qnav-bar button { flex: 1; width: auto; min-height: 52px; margin: 0; }

  .qgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 10px 0; }
  .qn { width: 100%; min-height: 42px; margin: 0; padding: 0; background: #fff; color: #334155; font-weight: 700;
        border: 1.5px solid #c9d1e0; border-radius: 10px; box-shadow: none; }
  .qn:hover { background: #eef2fb; }
  .qn.done { background: var(--navy); border-color: var(--navy); color: #fff; }
  .qn.flag { background: #f5b942; border-color: #d98a00; color: #4a3000; }
  .qn.current { outline: 3px solid rgba(30,58,138,.35); outline-offset: 1px; border-color: var(--navy); }
  .qpanel { background: #fff; border: 1px solid rgba(15,23,42,.07); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
  .qpanel-head { display: flex; align-items: center; justify-content: space-between; }
  .qpanel-close { width: 38px; min-height: 38px; margin: 0; padding: 0; font-size: 22px; line-height: 1; }
  .qpanel-count { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
  .qlegend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 14px; color: var(--muted); font-size: 12px; }
  .qlegend .lg { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; border: 1.5px solid #c9d1e0; border-radius: 4px; background: #fff; }
  .qlegend .lg.done { background: var(--navy); border-color: var(--navy); }
  .qlegend .lg.flag { background: #f5b942; border-color: #d98a00; }

  #summary h3 { margin-top: 0; font-size: 20px; }
  .sum-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
  .sum-stats > div { padding: 12px; background: #f4f7fd; border: 1px solid #e3e9f5; border-radius: 12px; text-align: center; }
  .sum-stats b { display: block; font-size: 26px; line-height: 1.2; }
  .sum-stats small { color: var(--muted); }
  .sum-h { margin: 14px 0 0; font-weight: 600; }
  .sum-ok { margin: 14px 0; color: var(--ok); font-weight: 600; }
  #summary .row { margin-top: 18px; }

  @media (min-width: 900px) {
    body.student-page.exam-mode { max-width: 1120px; }
    .exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
    .qpanel { position: sticky; top: 96px; }
    .qpanel-close, .qlist-btn { display: none; }
    .qnav-bar button { flex: 0 1 220px; }
    .qnav-bar { justify-content: space-between; }
  }
  @media (max-width: 899px) {
    .qpanel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-height: 75vh; overflow-y: auto;
              border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
              transform: translateY(105%); transition: transform .2s; }
    .qpanel.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15,23,42,.45), 0 -10px 40px rgba(15,23,42,.2); }
    .student-page #examView > button.green { position: static; }
  }
}
