* { box-sizing: border-box; }
:root {
  --bg: #0f1419;
  --panel: #1a2230;
  --panel2: #222c3c;
  --line: #2c3848;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #2f81f7;
  --green: #2ea043;
  --amber: #d29922;
  --red: #da3633;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.error { color: var(--red); margin-top: 8px; font-size: 13px; min-height: 16px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--panel); padding: 28px; border-radius: 12px; width: 100%; max-width: 360px; border: 1px solid var(--line); }
.login-card h1 { font-size: 18px; margin: 0 0 6px; }
.login-card input { width: 100%; padding: 10px; margin: 12px 0; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
button { cursor: pointer; background: var(--accent); color: #fff; border: none; padding: 9px 14px; border-radius: 8px; font-size: 14px; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.small { padding: 5px 10px; font-size: 12px; }
button.danger { background: var(--red); }
.code-badge { margin-top: 8px; padding: 8px 10px; background: var(--panel2); border: 1px dashed var(--accent); border-radius: 8px; font-size: 14px; font-weight: 700; letter-spacing: 1px; text-align: center; }
.code-badge:empty { display: none; }
button:hover { opacity: .9; }

/* Layout */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; padding: 14px; height: calc(100vh - 53px); }
.col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.grow-panel { flex: 1; min-height: 0; overflow: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel h2 { font-size: 14px; margin: 0 0 8px; }
.panel-head h2 { margin: 0; }
select { width: 100%; padding: 8px; border-radius: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); }

/* Student list */
.student-list { list-style: none; margin: 0; padding: 0; }
.student-list li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.student-list li:hover { background: var(--panel2); }
.student-list li.active { background: var(--panel2); outline: 1px solid var(--accent); }
.student-list .name { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.online { background: var(--green); }
.dot.offline { background: var(--muted); }
.score { font-size: 12px; color: var(--amber); font-variant-numeric: tabular-nums; }

/* Detail */
.placeholder { color: var(--muted); padding: 40px; text-align: center; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); }
.badge.online { color: var(--green); border-color: var(--green); }
.badge.offline { color: var(--muted); }

/* Toggles */
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--panel2); border-radius: 8px; }
.toggle label { font-size: 13px; }
.switch { position: relative; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #3a4658; border-radius: 999px; transition: .2s; }
.slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.numbers { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.num { background: var(--panel2); padding: 8px 10px; border-radius: 8px; }
.num label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.num input { width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 8px; }
.evt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; background: var(--panel2); border-radius: 8px; }
.evt .lvl { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 6px; color: #fff; white-space: nowrap; }
.lvl.LOW { background: var(--green); }
.lvl.MED { background: var(--amber); }
.lvl.HIGH { background: var(--red); }
.evt .body { flex: 1; }
.evt .type { font-weight: 600; font-size: 13px; }
.evt .note { font-size: 12px; color: var(--muted); }
.evt .time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.evt .evmark { font-size: 11px; color: var(--accent); margin-top: 2px; }
.evt img { max-width: 120px; border-radius: 6px; margin-top: 6px; display: block; }
.evt audio { margin-top: 6px; width: 220px; }

/* Galeri bukti */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 280px; overflow: auto; }
.gitem { position: relative; border: 2px solid var(--line); border-radius: 8px; padding: 4px; background: var(--panel2); }
.gdel { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; line-height: 18px; font-size: 12px; border-radius: 50%; background: rgba(218,54,51,.92); color: #fff; border: none; cursor: pointer; }
.gdel:hover { background: var(--red); }
.gitem.LOW { border-color: var(--green); }
.gitem.MED { border-color: var(--amber); }
.gitem.HIGH { border-color: var(--red); }
.gitem img { width: 100%; height: 72px; object-fit: cover; border-radius: 4px; cursor: pointer; display: block; }
.gitem audio { width: 100%; }
.gcap { font-size: 10px; color: var(--muted); margin-top: 3px; text-align: center; }
#lightbox { align-items: center; }
#lightbox img { max-width: 92%; max-height: 92%; border-radius: 8px; }

/* Laporan (Tahap 6) */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; justify-content: center; align-items: flex-start; padding: 24px; overflow: auto; z-index: 50; }
.report-card { background: #fff; color: #111; width: 100%; max-width: 800px; border-radius: 10px; padding: 22px; }
.report-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.report-card h1 { font-size: 20px; margin: 0 0 12px; }
.report-card h2 { font-size: 15px; margin: 18px 0 8px; }
.rep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; background: #f2f4f7; border-radius: 8px; font-size: 14px; }
.rep-score { font-size: 22px; font-weight: 700; color: #b9770e; }
.rep-section { margin-top: 8px; }
.rep-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.rep-table th, .rep-table td { border: 1px solid #ddd; padding: 6px 10px; text-align: left; }
.report-card .evt { background: #f7f8fa; color: #111; }
.report-card .note, .report-card .time { color: #555; }

@media print {
  body * { visibility: hidden; }
  #reportOverlay, #reportOverlay * { visibility: visible; }
  #reportOverlay { position: absolute; inset: 0; background: #fff; padding: 0; display: block; }
  .report-card { max-width: 100%; box-shadow: none; }
  .no-print { display: none !important; }
}
