:root {
  --teal: #0D9488;
  --teal-d: #0b7a70;
  --teal-l: #e6f6f4;
  --amber: #FCD34D;
  --amber-l: #FFFBEB;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --muted: #9ca3af;
  --line: #e5e7eb;
  --bg: #f7f8fa;
  --white: #fff;
  --red: #dc2626;
  --red-l: #fef2f2;
  --green: #059669;
  --green-l: #ecfdf5;
  --blue: #2563eb;
  --blue-l: #eff6ff;
  --violet: #7c3aed;
  --violet-l: #f5f3ff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 2px 10px rgba(0,0,0,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: Arial, Helvetica, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 17px; margin-bottom: 10px; }
h3 { font-size: 15px; margin-bottom: 8px; }
p { margin-bottom: 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- Topbar ---------- */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--teal); font-size: 18px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { height: 32px; width: auto; }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.mainnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.mainnav a { padding: 8px 11px; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: 13.5px; }
.mainnav a:hover { background: var(--bg); text-decoration: none; }
.mainnav a.active { background: var(--teal-l); color: var(--teal-d); }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }
.userbox em { font-style: normal; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 18px; cursor: pointer; margin-left: auto; }
@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; padding: 8px 16px; }
  .nav-toggle { display: block; }
  .mainnav, .userbox { display: none; width: 100%; }
  .nav-open .mainnav { display: flex; flex-direction: column; }
  .nav-open .userbox { display: flex; padding: 8px 0; border-top: 1px solid var(--line); }
}

.container { max-width: 1200px; margin: 0 auto; padding: 22px 16px 40px; }
.container.narrow, .narrow { max-width: 720px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--ink-2); margin: 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; color: var(--teal); line-height: 1.2; }
.stat span { color: var(--ink-2); font-size: 12.5px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--white); color: var(--ink); font-weight: 600; font-size: 13.5px; cursor: pointer; line-height: 1.3; font-family: inherit; white-space: nowrap; }
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-l); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #78350f; }
.btn-violet { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn-violet:hover { background: #6d28d9; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--teal); cursor: pointer; font: inherit; padding: 0; }
.linkbtn.danger { color: var(--red); }
form.inline { display: inline; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; color: var(--ink); background: var(--white);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13,148,136,.25); border-color: var(--teal); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--teal); vertical-align: middle; }
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; cursor: pointer; margin-right: 14px; color: var(--ink); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input { width: auto; min-width: 140px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: #f9fafb; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-2); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fcfcfd; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .center { text-align: center; }
.tbl .nowrap { white-space: nowrap; }
.tbl tr.muted td { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px !important; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: #f3f4f6; color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--green-l); color: var(--green); }
.badge-warn { background: var(--amber-l); color: #92400e; }
.badge-err { background: var(--red-l); color: var(--red); }
.badge-dark { background: #374151; color: #fff; }
.badge-muted { background: #f3f4f6; color: var(--ink-2); }
.badge-info { background: var(--blue-l); color: var(--blue); }
.badge-ai { background: var(--violet-l); color: var(--violet); }
.badge-pg { background: var(--blue-l); color: var(--blue); }
.badge-pgk { background: var(--violet-l); color: var(--violet); }
.badge-bs { background: var(--amber-l); color: #92400e; }
.badge-uraian { background: var(--teal-l); color: var(--teal-d); }
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: 13.5px; }
.alert-success { background: var(--green-l); border-color: #a7f3d0; color: #065f46; }
.alert-error { background: var(--red-l); border-color: #fecaca; color: #991b1b; }
.alert-warn { background: var(--amber-l); border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--blue-l); border-color: #bfdbfe; color: #1e40af; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal-back.open { display: flex; }
.modal { background: var(--white); border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h3 { margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Landing / center pages ---------- */
.center-page { display: flex; align-items: center; justify-content: center; padding: 30px 16px; background: #fff;
  background-image: radial-gradient(circle at 15% 10%, rgba(13,148,136,.07), transparent 40%), radial-gradient(circle at 85% 90%, rgba(252,211,77,.15), transparent 40%); }
.center-page .card { width: 100%; }
.brand-title { color: var(--teal); text-align: center; }
.landing { max-width: 640px; width: 100%; text-align: center; }
.landing .logo { height: 64px; margin-bottom: 10px; }
.top-line { width: 60px; height: 4px; background: var(--teal); border-radius: 2px; margin: 0 auto 20px; }
.landing h1 { font-size: 30px; color: var(--teal); }
.landing .sub { color: #6b7280; margin-bottom: 30px; }
.mapel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.mapel-card { display: block; background: #fff; border: 1px solid #ececec; border-radius: 14px; padding: 26px 18px; box-shadow: 0 2px 10px rgba(0,0,0,.05); color: inherit; transition: transform .15s, box-shadow .15s; }
.mapel-card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.08); text-decoration: none; }
.mapel-card .ic { width: 52px; height: 52px; border-radius: 12px; background: var(--teal-l); color: var(--teal); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; margin: 0 auto 12px; }
.mapel-card h2 { font-size: 18px; margin: 0; }
.mapel-card p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.landing-links { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Soal rendering ---------- */
.soal-html { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.soal-html p { margin: 0 0 6px; }
.soal-html img { max-height: 380px; display: block; margin: 8px 0; border-radius: 4px; }
.soal-html table { border-collapse: collapse; margin: 8px 0; }
.soal-html td, .soal-html th { border: 1px solid #cbd5e1; padding: 4px 8px; }
.soal-html ol, .soal-html ul { padding-left: 22px; margin: 4px 0; }
.soal-html .ql-align-center { text-align: center; }
.soal-html .ql-align-right { text-align: right; }
.soal-html .ql-align-justify { text-align: justify; }
.soal-html .ql-formula { display: inline-block; }
.soal-preview { max-height: 3.2em; overflow: hidden; color: var(--ink-2); }
.soal-preview img { display: none; }
.soal-preview p { display: inline; }
.opsi-list { list-style: none; margin-top: 8px; }
.opsi-list li { display: flex; gap: 8px; padding: 3px 0; }
.opsi-list .key { font-weight: 700; min-width: 22px; }
.opsi-list li.benar .key { color: var(--green); }
.opsi-list li.benar { background: var(--green-l); border-radius: 6px; padding: 3px 6px; }

/* ---------- Editor ---------- */
.ed-wrap { background: #fff; border-radius: 8px; }
.ed-wrap .ql-toolbar { border-radius: 8px 8px 0 0; background: #fafafa; }
.ed-wrap .ql-container { border-radius: 0 0 8px 8px; font-size: 15px; font-family: inherit; }
.ed-wrap .ql-editor { min-height: 120px; }
.ed-wrap.small .ql-editor { min-height: 44px; }
.ql-snow .ql-toolbar button.ql-symbol, .ql-snow .ql-toolbar button.ql-mathx { width: auto; padding: 3px 7px; font-weight: 700; font-size: 13px; color: var(--teal); }
.opsi-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.opsi-row .opsi-key { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; width: 46px; }
.opsi-row .opsi-key b { font-size: 16px; }
.opsi-row .ed-wrap { flex: 1; min-width: 0; }
.opsi-row .opsi-del { padding-top: 8px; }
.bs-key { display: flex; gap: 4px; }
.bs-key label { margin: 0; display: inline-flex; gap: 3px; align-items: center; font-size: 12px; cursor: pointer; }
.math-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.math-tabs button { flex: 1; }
.math-tabs button.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.sym-grid button { padding: 8px 0; font-size: 17px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-family: "Times New Roman", serif; }
.sym-grid button:hover { background: var(--teal-l); border-color: var(--teal); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-bottom: 10px; }
.tpl-grid button { padding: 6px 4px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; min-height: 52px; }
.tpl-grid button:hover { background: var(--teal-l); border-color: var(--teal); }
.math-preview { min-height: 54px; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px; text-align: center; font-size: 20px; margin-top: 8px; background: #fafafa; overflow-x: auto; }

/* ---------- Ujian siswa ---------- */
.exam-body { background: #eef2f5; }
.exam-top { background: var(--teal); color: #fff; position: sticky; top: 0; z-index: 40; }
.exam-top-inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.exam-top .who { flex: 1; min-width: 180px; line-height: 1.3; }
.exam-top .who b { display: block; font-size: 15px; }
.exam-top .who span { font-size: 12px; opacity: .85; }
.timer { background: rgba(255,255,255,.15); border-radius: 8px; padding: 6px 12px; font-family: "Courier New", monospace; font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.timer.warn { background: var(--amber); color: #78350f; }
.save-state { font-size: 12px; opacity: .9; min-width: 90px; text-align: right; }
.fontsize button { background: rgba(255,255,255,.15); border: 0; color: #fff; padding: 5px 9px; border-radius: 6px; cursor: pointer; font-weight: 700; }
.exam-wrap { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .exam-wrap { grid-template-columns: 1fr; } .exam-side { order: -1; } }
.q-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.q-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.q-no { font-weight: 700; font-size: 16px; }
.q-body { font-size: var(--qfs, 16px); }
.q-body .soal-html { font-size: inherit; }
.ans-opt { display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-top: 10px; cursor: pointer; font-weight: 400; color: var(--ink); font-size: inherit; }
.ans-opt:hover { border-color: #99d5cf; }
.ans-opt.on { border-color: var(--teal); background: var(--teal-l); }
.ans-opt input { margin-top: 4px; flex: 0 0 auto; }
.ans-opt .k { font-weight: 700; min-width: 20px; }
.ans-opt .soal-html { flex: 1; min-width: 0; font-size: inherit; }
.bs-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: inherit; }
.bs-table th, .bs-table td { border: 1px solid var(--line); padding: 9px 10px; vertical-align: middle; }
.bs-table th { background: #f9fafb; font-size: 13px; }
.bs-table td.c { text-align: center; width: 76px; }
.bs-table input { width: 20px; height: 20px; }
.uraian-box textarea { min-height: 180px; font-size: inherit; margin-top: 10px; }
.sym-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.sym-bar button { min-width: 34px; padding: 5px 6px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 15px; font-family: "Times New Roman", serif; }
.sym-bar button:hover { background: var(--teal-l); }
.q-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.ragu-btn.on { background: var(--amber); border-color: var(--amber); color: #78350f; }
.exam-side .card { padding: 14px; }
.nomor-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nomor-grid button { aspect-ratio: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 14px; position: relative; }
.nomor-grid button.done { background: var(--teal); color: #fff; border-color: var(--teal); }
.nomor-grid button.ragu { background: var(--amber); color: #78350f; border-color: var(--amber); }
.nomor-grid button.cur { outline: 3px solid rgba(13,148,136,.35); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--ink-2); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }

/* ---------- Penilaian ---------- */
.jw-item { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.jw-item .jw-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.jw-answer { background: #f9fafb; border-left: 3px solid var(--teal); padding: 8px 12px; border-radius: 4px; margin: 8px 0; white-space: pre-wrap; }
.jw-key { background: var(--green-l); border-left: 3px solid var(--green); padding: 8px 12px; border-radius: 4px; margin: 8px 0; }
.poin-input { width: 90px !important; display: inline-block; }
.progress { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--violet); width: 0; transition: width .2s; }

/* ---------- Import preview ---------- */
.imp-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.imp-item.has-warn { border-color: #fde68a; background: #fffdf5; }
.imp-item .imp-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.warn-text { color: #b45309; font-size: 12.5px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .container { padding: 0; max-width: none; }
}

/* ---------- Tabs ujian ---------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: -6px 0 18px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: 13.5px; }
.tabs a:hover { background: #fff; text-decoration: none; }
.tabs a.active { background: var(--teal-l); color: var(--teal-d); }
.token-big { font-family: "Courier New", monospace; font-size: 34px; font-weight: 700; letter-spacing: 6px; color: var(--teal-d); }
.opsi-list .soal-html p:last-child, .ans-opt .soal-html p:last-child, .bs-table .soal-html p:last-child, .jw-key .soal-html p:last-child { margin-bottom: 0; }
@media (max-width: 860px) { .nomor-grid { grid-template-columns: repeat(8, 1fr); } .nomor-grid button { font-size: 13px; } }
