:root {
  --bg: #f3f4ee;
  --paper: #ffffff;
  --ink: #27302a;
  --muted: #6c766e;
  --line: #e0e4da;
  --soft: #f7f8f3;
  --brand: #5f7f66;
  --brand-dark: #4a6651;
  --brand-soft: #e5ede3;
  --sage-side: #dde6d7;
  --sage-side-line: #cbd7c4;
  --rose: #c2525f;
  --rose-soft: #f8e6e7;
  --amber: #b5852c;
  --amber-soft: #f6eedc;
  --sky: #2563a8;
  --sky-soft: #e4eefa;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30,40,35,.04), 0 4px 16px rgba(30,40,35,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--brand); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::before, .login-art::after { content: ''; position: absolute; border-radius: 50%; border: 60px solid rgba(255,255,255,.06); }
.login-art::before { width: 520px; height: 520px; right: -200px; top: -160px; }
.login-art::after { width: 360px; height: 360px; left: -140px; bottom: -120px; }
.login-art h2 { font-size: 40px; line-height: 1.15; margin: 0 0 16px; font-weight: 800; letter-spacing: -.02em; max-width: 460px; }
.login-art p { opacity: .85; max-width: 420px; margin: 0; }
.login-points { display: grid; gap: 14px; margin-top: 36px; position: relative; z-index: 1; }
.login-points div { display: flex; gap: 12px; align-items: center; font-weight: 600; }
.login-points span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14); display: grid; place-items: center; }
.login-form-wrap { display: grid; place-items: center; padding: 32px; }
.login-form { width: 100%; max-width: 360px; }
.login-form h1 { font-size: 26px; margin: 0 0 4px; font-weight: 800; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; position: relative; z-index: 1; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: #fff; color: var(--brand); display: grid; place-items: center; }
.brand-mark.dark { background: var(--brand); color: #fff; }
.brand small { display: block; font-size: 11px; font-weight: 600; opacity: .7; letter-spacing: .02em; }

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; background: var(--sage-side); border-right: 1px solid var(--sage-side-line); display: flex; flex-direction: column; z-index: 40; transition: transform .22s ease; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; font-weight: 800; font-size: 18px; }
.sb-brand small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.sb-brand .sb-close { margin-left: auto; display: none; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #7f8c80; padding: 16px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #445047; text-decoration: none; font-weight: 600; transition: .15s; }
.nav a:hover { background: rgba(255,255,255,.5); color: var(--ink); }
.nav a.active { background: var(--paper); color: var(--brand-dark); box-shadow: 0 1px 3px rgba(60,80,65,.12); }
.nav a.active svg { color: var(--brand); }
.user-menu { position: relative; padding: 12px; border-top: 1px solid var(--sage-side-line); }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: rgba(255,255,255,.55); border: 1px solid var(--sage-side-line); border-radius: 12px; padding: 8px 10px; }
.user-btn:hover { background: var(--paper); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.user-btn .meta { text-align: left; line-height: 1.2; flex: 1; min-width: 0; }
.user-btn .meta b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-btn .meta small { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.user-btn > svg { color: var(--muted); }
.dropdown { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.dropdown button { display: flex; width: 100%; gap: 10px; align-items: center; background: none; border: 0; padding: 9px 10px; border-radius: 8px; text-align: left; }
.dropdown button:hover { background: var(--soft); }
.dropdown .danger { color: var(--rose); }
.main { margin-left: 252px; min-height: 100vh; }
.mobile-bar { display: none; }
.sb-backdrop { display: none; }

/* ---------- Layout ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 30px 28px 60px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; } /* izinkan kolom menyusut, cegah scroll horizontal */
.main { overflow-x: clip; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g-kp { grid-template-columns: 1fr 120px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.box-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.box-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.box-body { padding: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* hero */
.hero { background: linear-gradient(120deg, var(--brand-dark) 0%, #86a08a 100%); color: #fff; border-radius: 18px; padding: 26px 28px; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255,255,255,.08); }
.hero h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.hero p { margin: 0; opacity: .85; }
.hero .btn { position: relative; z-index: 1; }

/* KPI */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 600; font-size: 13px; }
.kpi-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.t-brand { background: var(--brand-soft); color: var(--brand); }
.t-rose { background: var(--rose-soft); color: var(--rose); }
.t-amber { background: var(--amber-soft); color: var(--amber); }
.t-sky { background: var(--sky-soft); color: var(--sky); }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.chart .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 5px; }
.chart .bar { width: 38%; max-width: 22px; border-radius: 6px 6px 2px 2px; min-height: 3px; position: relative; }
.chart .bar.p { background: var(--rose); }
.chart .bar.a { background: var(--amber); }
.chart .bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--muted); }
.chart .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* list */
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list-item:last-child { border-bottom: 0; }
.rank { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px; background: var(--soft); border: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* timeline */
.timeline { position: relative; }
.tl-item { display: grid; grid-template-columns: 56px 18px minmax(0, 1fr); gap: 10px; padding: 8px 0; cursor: pointer; }
.tl-date { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding-top: 2px; }
.tl-dot { position: relative; }
.tl-dot::before { content: ''; position: absolute; left: 8px; top: 0; bottom: -16px; width: 2px; background: var(--line); }
.tl-item:last-child .tl-dot::before { display: none; }
.tl-dot span { position: absolute; left: 3px; top: 5px; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--line); }
.tl-body { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; transition: .15s; min-width: 0; overflow: hidden; }
.box { min-width: 0; }
.tl-item:hover .tl-body { border-color: var(--brand); }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: 13.5px; transition: .15s; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-brand { background: var(--brand); color: #fff; } .btn-brand:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: var(--paper); border-color: var(--line); } .btn-ghost:hover { background: var(--soft); }
.btn-white { background: #fff; color: var(--brand-dark); } .btn-white:hover { background: #f0fbf8; }
.btn-rose { background: var(--rose); color: #fff; } .btn-rose:hover { filter: brightness(.93); }
.btn-lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--soft); border-color: var(--line); color: var(--ink); }
.icon-btn.del:hover { color: var(--rose); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: 12.5px; }
.input { width: 100%; background: var(--paper); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 70px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.input-icon .input { padding-left: 36px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 5px; }
.segmented label { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); }
.segmented input { display: none; }
.segmented input:checked + label.pel { background: var(--rose); color: #fff; }
.segmented input:checked + label.pres { background: var(--amber); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .input { width: auto; padding-top: 8px; padding-bottom: 8px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--soft); }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf8; }
td.act { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px !important; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.tag-p { background: var(--rose-soft); color: var(--rose); }
.tag-a { background: var(--amber-soft); color: var(--amber); }
.tag-n { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.tag-b { background: var(--brand-soft); color: var(--brand-dark); }
.foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.link { color: var(--ink); font-weight: 700; background: none; border: 0; padding: 0; text-align: left; }
.link:hover { color: var(--brand); text-decoration: underline; }

/* kelas cards */
.kelas-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.kelas-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.kelas-card h4 { margin: 0; font-size: 18px; font-weight: 800; }
.kelas-stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.kelas-stats b { color: var(--ink); }
.tingkat-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 10px; }

/* signature */
.sig-wrap { border: 1.5px dashed #c9c6bb; border-radius: 12px; background: repeating-linear-gradient(0deg, transparent 0 34px, #f1efe8 34px 35px), #fff; position: relative; }
.sig-wrap canvas { width: 100%; height: 160px; display: block; touch-action: none; cursor: crosshair; }
.sig-wrap .hint { position: absolute; left: 12px; bottom: 8px; font-size: 11px; color: #a8a497; pointer-events: none; }
.sig-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sig-head button { background: none; border: 0; color: var(--rose); font-weight: 700; font-size: 12px; }

/* student card */
.student-card { position: sticky; top: 90px; }
.student-id { display: flex; gap: 14px; align-items: center; }
.student-id .avatar { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.poin-meter { height: 8px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.poin-meter div { height: 100%; background: linear-gradient(90deg, var(--amber), var(--rose)); }
.mini-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stat div { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.mini-stat b { display: block; font-size: 20px; }
.mini-stat small { color: var(--muted); font-size: 11px; }

/* import */
.steps { display: grid; gap: 12px; margin-bottom: 16px; }
.steps > div { display: flex; gap: 12px; align-items: flex-start; }
.steps > div > span { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 800; font-size: 12px; flex-shrink: 0; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; border: 2px dashed var(--sage-side-line); background: var(--soft); border-radius: 14px; padding: 26px 16px; cursor: pointer; color: var(--brand-dark); transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.err-list { background: var(--rose-soft); color: #8a2f3a; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; max-height: 130px; overflow: auto; }

/* ---------- Modal / toast / loader ---------- */
.modal { position: fixed; inset: 0; background: rgba(25,30,27,.45); backdrop-filter: blur(2px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--paper); border-radius: 18px; width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-box.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-body { padding: 22px; overflow-y: auto; }
.form-grid { display: grid; gap: 14px; }
.toasts { position: fixed; top: 80px; right: 20px; z-index: 70; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; font-weight: 600; max-width: 380px; animation: slide .2s ease-out; }
.toast.err { background: var(--rose); }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }
.loader { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 80; overflow: hidden; }
.loader::after { content: ''; position: absolute; height: 100%; width: 40%; background: var(--brand); animation: load 1s infinite ease-in-out; }
@keyframes load { from { left: -40%; } to { left: 100%; } }
.detail-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.detail-row div:first-child { color: var(--muted); }
.paraf-img { border: 1px solid var(--line); border-radius: 10px; width: 100%; background: #fff; }
.notice { background: var(--amber-soft); color: #7a4d06; border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.code { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 32px 24px; }
  .login-art h2 { font-size: 28px; }
  .login-points { display: none; }
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.18); width: 270px; }
  .sb-open .sidebar { transform: none; }
  .sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(30,40,32,.4); z-index: 30; }
  .sb-brand .sb-close { display: inline-grid; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; background: var(--sage-side); border-bottom: 1px solid var(--sage-side-line); padding: 10px 14px; }
  .mobile-bar .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .page { padding: 20px 16px 48px; }
  .g-4, .g-3, .g-2 { grid-template-columns: 1fr; }
  .g-4.kpis { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: auto; }
  .hero { flex-direction: column; align-items: flex-start; }
  .student-card { position: static; }
  .detail-row { grid-template-columns: 1fr; gap: 2px; }
  .toolbar .input { width: 100%; }
}
