/* =====================================================================
   KAWAL DATA — gaya tampilan
   Warna diambil dari logo SMA MTA: biru langit, hijau, kuning
   ===================================================================== */
:root {
  --navy: #0b3a66;
  --navy-2: #0e4a80;
  --blue: #1b8fd8;
  --blue-soft: #e6f3fc;
  --green: #23964a;
  --green-soft: #e3f5e9;
  --yellow: #f4d21f;
  --red: #c8372d;
  --red-soft: #fdecea;
  --amber: #b7791f;
  --amber-soft: #fff5db;

  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #e2e8f0;
  --line-2: #cfd8e3;
  --text: #172235;
  --text-2: #4a5a70;
  --muted: #7a889b;
  --focus: rgba(27, 143, 216, .28);
  --shadow: 0 1px 2px rgba(16, 32, 60, .05), 0 6px 20px rgba(16, 32, 60, .06);
  --radius: 14px;
  --side: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1520; --surface: #142030; --surface-2: #1a283b; --line: #24364d; --line-2: #31465f;
    --text: #e7eef7; --text-2: #b2c0d2; --muted: #8394aa; --blue-soft: #12324d; --green-soft: #133a24;
    --red-soft: #3c1a18; --amber-soft: #3a2e12; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1520; --surface: #142030; --surface-2: #1a283b; --line: #24364d; --line-2: #31465f;
  --text: #e7eef7; --text-2: #b2c0d2; --muted: #8394aa; --blue-soft: #12324d; --green-soft: #133a24;
  --red-soft: #3c1a18; --amber-soft: #3a2e12; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
svg { width: 18px; height: 18px; flex: none; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.req { color: var(--red); }
.mb { margin: 0 0 12px; }
.mb2 { margin: 0 0 16px; max-width: none; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }

/* ---------- tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text); transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: var(--surface); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-t:hover { color: var(--red); border-color: var(--red); }
.btn.block { width: 100%; height: 44px; }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue); }
.icon-btn.del:hover:not(:disabled) { background: var(--red-soft); color: var(--red); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 11px; min-height: 38px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
input:disabled { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; accent-color: var(--navy); }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }
.hint.warn { color: var(--amber); }
.cb { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; }
.row input { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.badge.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.off { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.lulus { background: var(--blue-soft); color: var(--navy); border-color: transparent; }
:root[data-theme="dark"] .badge.lulus { color: var(--text); }
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.role-superadmin { background: var(--navy); color: #fff; border-color: transparent; }
.badge.role-admin { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

.alert { padding: 10px 13px; border-radius: 10px; font-size: 13.5px; }
.alert.err { background: var(--red-soft); color: var(--red); }

/* ---------- splash ---------- */
.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.splash img { width: 74px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.fatal { max-width: 560px; margin: 12vh auto; padding: 24px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login { position: relative; min-height: 100vh; display: grid; grid-template-columns: 1.15fr minmax(340px, 440px); align-items: center; gap: 40px; padding: 40px 6vw; overflow: hidden; }
.login-bg { position: fixed; inset: 0; background-size: cover; background-position: center 40%; transform: scale(1.03); }
.login-shade { position: fixed; inset: 0; background: linear-gradient(105deg, rgba(8, 40, 74, .88) 0%, rgba(11, 58, 102, .62) 45%, rgba(11, 58, 102, .25) 100%); }
.login-side { position: relative; color: #fff; max-width: 520px; }
.brand-big img { width: 92px; filter: drop-shadow(0 8px 20px rgba(0,0,0,.35)); }
.login-side h1 { font-size: clamp(40px, 6vw, 68px); font-weight: 800; line-height: 1; margin: 22px 0 14px; letter-spacing: -.03em; }
.login-side h1 span { color: var(--yellow); }
.login-side p { font-size: 18px; opacity: .92; margin: 0; }
.login-card {
  position: relative; background: var(--surface); border-radius: 20px; padding: 30px 30px 22px;
  box-shadow: 0 24px 60px rgba(4, 22, 44, .45); display: flex; flex-direction: column; gap: 14px;
  border-top: 5px solid var(--green);
}
.login-logo { display: none; width: 54px; }
.login-card h2 { font-size: 22px; }
.login-card .muted { margin: -8px 0 4px; font-size: 13.5px; }
.pw { position: relative; }
.pw input { padding-right: 42px; }
.pw .icon-btn { position: absolute; right: 4px; top: 3px; }
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.demo-box { background: var(--amber-soft); border-radius: 12px; padding: 11px 12px; font-size: 12.5px; color: var(--text-2); }
.demo-acc { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.demo-acc button { font: inherit; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); cursor: pointer; }
.demo-acc button:hover { border-color: var(--blue); color: var(--blue); }

/* =====================================================================
   SHELL
   ===================================================================== */
.shell { display: flex; min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy); color: #cfe0f1;
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand img { width: 38px; }
.side-brand b { display: block; color: #fff; font-size: 17px; letter-spacing: -.01em; }
.side-brand small { font-size: 11.5px; opacity: .7; }
.side nav { flex: 1; overflow-y: auto; padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.side nav a, .nav-out {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: #cfe0f1;
  font-weight: 500; font-size: 14px; position: relative;
}
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.side nav a.on::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--yellow); }
.nav-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; opacity: .5; padding: 14px 12px 4px; }
.nav-out { margin: 10px; border: 0; background: rgba(255,255,255,.06); font: inherit; cursor: pointer; }
.nav-out:hover { background: rgba(200, 55, 45, .35); color: #fff; }
.side-dim { display: none; }
.main { flex: 1; margin-left: var(--side); min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 26px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.crumb { display: flex; flex-direction: column; min-width: 0; }
.crumb b { font-size: 17px; display: flex; align-items: center; gap: 4px; }
.crumb small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-back { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; color: var(--text-2); }
.crumb-back:hover { background: var(--blue-soft); color: var(--blue); }
.who { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.who-txt { text-align: right; line-height: 1.25; }
.who-txt b { display: block; font-size: 13.5px; }
.who-txt small { color: var(--muted); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 700; }
.only-m { display: none; }
.view { padding: 24px 26px 60px; max-width: 1400px; width: 100%; }

/* ---------- kartu & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 760px; }
.card h3 { font-size: 15px; margin-bottom: 14px; }
.card h4 { font-size: 13.5px; margin: 18px 0 8px; }
.h3row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.h3row h3 { margin: 0; }
.h3row .row { margin: 0 0 0 auto; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; }

.hero {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 22px 24px; margin-bottom: 18px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--navy) 0%, #11619f 60%, var(--blue) 100%); color: #fff; position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgba(244, 210, 31, .18); }
.hero h1 { font-size: 23px; }
.hero p { margin: 4px 0 0; opacity: .9; }
.hero-act { margin-left: auto; display: flex; gap: 10px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero .btn.primary { background: var(--yellow); color: var(--navy); }
.hero .btn.ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats.mini { grid-template-columns: repeat(4, 1fr); margin: 4px 0 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); border-left: 4px solid var(--blue); }
.stat.good { border-left-color: var(--green); }
.stat.bad { border-left-color: var(--red); }
.stat.lulus { border-left-color: var(--yellow); }
.stat small { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.stat b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat b.sm { font-size: 16px; }
.stat b i { font-style: normal; color: var(--muted); font-weight: 500; }
.stat span { font-size: 12px; color: var(--muted); }

.ring-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; font-weight: 800; }
.bar { display: grid; grid-template-columns: 120px 1fr 56px; align-items: center; gap: 10px; font-size: 13px; margin-top: 7px; }
.bar div { height: 8px; background: var(--line); border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 9px; }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }
.kv-list { list-style: none; padding: 0; margin: 0 0 10px; }
.kv-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }

/* ---------- toolbar & tabel ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 140px; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search svg { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search input { padding-left: 36px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 11px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr.sel { background: var(--blue-soft); }
.tbl tr.dim td { opacity: .55; }
.tbl .c { text-align: center; }
.tbl .r { text-align: right; }
.tbl td small { display: block; color: var(--muted); font-size: 12px; }
.tbl.compact td, .tbl.compact th { padding: 7px 10px; }
.tbl a.name { color: var(--text); font-weight: 600; }
.tbl a.name:hover { color: var(--blue); }
.tbl td.act { white-space: nowrap; }
.tbl td.act > * { vertical-align: middle; }
.empty-row { text-align: center; color: var(--muted); padding: 34px !important; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.pager div { display: flex; gap: 8px; align-items: center; }
.dots3 { display: inline-flex; gap: 4px; }
.dots3 i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); }
.dots3 i.y { background: var(--green); }
.sel-count { font-size: 13px; color: var(--muted); font-weight: 600; }
.info-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); background: var(--blue-soft); padding: 9px 12px; border-radius: 10px; max-width: 760px; }
.info-note svg { color: var(--blue); margin-top: 1px; }

/* ---------- detail ---------- */
.profile { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.pf-avatar { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 28px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--blue), var(--navy)); flex: none; }
.pf-avatar.p { background: linear-gradient(135deg, #2bb36a, var(--green)); }
.pf-main { flex: 1; min-width: 240px; }
.pf-main h2 { font-size: 21px; }
.pf-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 6px; font-size: 13.5px; color: var(--text-2); }
.pf-lulus { display: flex; gap: 6px; align-items: center; margin: 10px 0 0; color: var(--navy); font-size: 13.5px; }
.pf-non { display: flex; gap: 6px; align-items: center; margin: 10px 0 0; color: var(--red); font-size: 13.5px; }
.pf-act { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin: 0; }
.dl > div { min-width: 0; }
.dl .w2 { grid-column: span 2; }
.dl .w3 { grid-column: 1 / -1; }
.dl dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.dl dd { margin: 2px 0 0; font-weight: 500; word-break: break-word; }
.berkas-card .chk-row { display: flex; gap: 10px; flex-wrap: wrap; }
.chk-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1.5px solid var(--line-2); border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13.5px; user-select: none; }
.chk-pill input { display: none; }
.chk-pill svg { width: 16px; height: 16px; color: transparent; border: 1.5px solid var(--line-2); border-radius: 50%; padding: 1px; }
.chk-pill.on { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.chk-pill.on svg { color: #fff; background: var(--green); border-color: var(--green); }

/* ---------- form ---------- */
.form-top { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.form-top .fld { width: 340px; max-width: 100%; }
.form-top > div { flex: 1; min-width: 220px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs button { flex: none; font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.fgroup { display: none; }
.fgroup.on { display: block; }
.fgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.fgrid .w2 { grid-column: span 2; }
.fgrid .w3 { grid-column: 1 / -1; }
.preview-addr { padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line-2); min-height: 38px; }
.form-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); flex-wrap: wrap; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(8, 20, 38, .5); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal-wrap.out { opacity: 0; transition: opacity .18s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); width: 100%; max-width: 500px; border-radius: 16px; box-shadow: 0 30px 70px rgba(0,0,0,.35); display: flex; flex-direction: column; max-height: calc(100vh - 32px); animation: pop .18s; }
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; }
.modal-body .fld { margin-bottom: 12px; }
.modal-body .fgrid .fld { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.confirm-msg { margin: 4px 0; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg label { cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; padding: 7px 18px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.seg input:checked + span { background: var(--surface); color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.sm { margin: 0; }
.seg.sm span { padding: 5px 12px; font-size: 13px; }
.non-box { display: none; }
.non-box.show { display: block; }
.non-box .row { margin: 0; }
.non-box .row select { flex: 1; }
.non-box > .row { margin-bottom: 12px; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--navy); color: #fff; padding: 11px 15px; border-radius: 11px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13.5px; font-weight: 500; animation: pop .2s; border-left: 4px solid var(--green); }
.toast.err { border-left-color: #ff7b72; background: #5c1b17; }
.toast.warn { border-left-color: var(--yellow); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }

/* ---------- berkas ---------- */
.bsum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.bs { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.bs.hl { border-color: var(--green); background: var(--green-soft); }
.bs small { color: var(--muted); font-weight: 600; font-size: 12px; }
.bs b { display: block; font-size: 21px; font-weight: 800; }
.bs b i { font-style: normal; font-size: 14px; color: var(--muted); font-weight: 500; }
.minibar { height: 5px; background: var(--line); border-radius: 5px; overflow: hidden; margin-top: 4px; }
.minibar span { display: block; height: 100%; background: var(--green); }
.tick { display: inline-grid; cursor: pointer; }
.tick input { position: absolute; opacity: 0; pointer-events: none; }
.tick span { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-2); display: grid; place-items: center; color: transparent; transition: .12s; background: var(--surface); }
.tick span svg { width: 16px; height: 16px; stroke-width: 2.6; }
.tick input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.tick input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus); }
.tick:hover span { border-color: var(--green); }

/* ---------- cetak (pemilihan) ---------- */
.print-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.ptype { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; box-shadow: var(--shadow); }
.ptype input { position: absolute; opacity: 0; }
.ptype b { font-size: 13.5px; line-height: 1.3; }
.ptype small { font-size: 12px; color: var(--muted); }
.ptype .pt-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); margin-bottom: 4px; }
.ptype.on { border-color: var(--navy); background: var(--blue-soft); }
.ptype.on .pt-ic { background: var(--navy); color: #fff; }

.ttd-opt { border-left: 4px solid var(--blue); }
.ttd-opt h3 { margin-bottom: 8px; }
.ttd-row { margin-top: 0; }
.ttd-opt p { margin: 10px 0 0; }

/* ---------- ekspor ---------- */
.colgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.colgroups fieldset { border: 1px solid var(--line); border-radius: 11px; padding: 6px 12px 10px; margin: 0; }
.colgroups legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
.colgroups legend label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.colgroups .cb { font-size: 13px; padding: 2px 0; }
.order { margin-top: 14px; }
#eOrder { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--navy); padding: 3px 4px 3px 10px; border-radius: 99px; }
:root[data-theme="dark"] .chip { color: var(--text); }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 15px; line-height: 1; width: 20px; height: 20px; border-radius: 50%; }
.chip button:hover { background: rgba(0,0,0,.1); }
.prev { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; max-height: 300px; }
.prev td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

.als { list-style: none; margin: 0; padding: 0; }
.als li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.als li span { flex: 1; font-weight: 500; }
.rights { list-style: none; padding: 0; margin: 0; }
.rights li { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 13.5px; }
.rights svg { color: var(--green); }

/* ---------- responsif ---------- */
@media (max-width: 1180px) {
  .print-types { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .side { transform: translateX(-100%); box-shadow: 10px 0 40px rgba(0,0,0,.3); }
  .side.open { transform: none; }
  .side.open + .side-dim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); }
  .main { margin-left: 0; }
  .only-m { display: inline-grid; }
  .grid2 { grid-template-columns: 1fr; }
  .stats, .bsum, .stats.mini { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; justify-items: center; padding: 24px 16px; }
  .login-side { display: none; }
  .login-card { width: 100%; max-width: 440px; }
  .login-logo { display: block; }
}
@media (max-width: 640px) {
  .view { padding: 16px 16px 60px; }
  .top { padding: 0 12px; }
  .who-txt { display: none; }
  .fgrid, .dl { grid-template-columns: 1fr 1fr; }
  .fgrid .w2, .dl .w2 { grid-column: 1 / -1; }
  .print-types { grid-template-columns: 1fr 1fr; }
  .toolbar select { flex: 1 1 140px; }
  .search { max-width: none; }
  .hero-act { margin-left: 0; }
  .bar { grid-template-columns: 96px 1fr 50px; }
  .tbl td, .tbl th { padding: 8px 9px; }
}

/* =====================================================================
   PRATINJAU & CETAK DOKUMEN
   ===================================================================== */
body.printing .shell, body.printing #toasts { display: none; }
#print-root { position: fixed; inset: 0; z-index: 150; background: #5b6675; overflow: auto; color: #000; }
.print-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--navy); color: #fff; flex-wrap: wrap; }
.print-bar span { opacity: .75; font-size: 13px; }
.print-bar .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.print-bar .btn.primary { background: var(--yellow); color: var(--navy); }
.pages { padding: 24px 0 60px; display: flex; flex-direction: column; align-items: center; gap: 22px; }

.page {
  --pw: 210mm; --ph: 297mm;
  width: var(--pw); height: var(--ph); background: #fff; color: #000; box-shadow: 0 6px 24px rgba(0,0,0,.35);
  font-family: Arial, "Liberation Sans", Helvetica, sans-serif; font-size: 11pt; line-height: 1.35;
  padding: 16mm 18mm 14mm; position: relative; overflow: hidden; flex: none;
}
.paper-F4 .page { --ph: 330mm; --pw: 215mm; }

/* Haldep 1 */
.p-haldep1 { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 26mm; padding-bottom: 22mm; }
.hd-t1 { font-size: 20pt; font-weight: 700; letter-spacing: .02em; }
.hd-t2 { font-size: 20pt; font-weight: 700; margin-top: 4mm; }
.hd-t3 { font-size: 16pt; font-weight: 700; margin-top: 4mm; }
.hd-logo { width: 58mm; margin: 18mm 0 0; }
.hd-nama { margin-top: auto; margin-bottom: auto; padding-top: 10mm; }
.hd-lbl { font-size: 16pt; }
.hd-nm { font-size: 22pt; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; margin-top: 7mm; line-height: 1.3; padding: 0 6mm; }
.hd-nis { font-size: 16pt; margin-top: 3mm; }
.hd-foot { font-size: 16pt; font-weight: 700; line-height: 1.8; }
.paper-F4 .hd-logo { width: 64mm; margin-top: 24mm; }

/* Haldep 2 */
.p-haldep2 { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 26mm; }
.hd2-logo { width: 42mm; }
.hd2-title { margin-top: 14mm; }
.hd2-title .hd-t1, .hd2-title .hd-t2 { font-size: 18pt; margin-top: 2mm; }
.hd2-title .hd-t3 { font-size: 15pt; margin-top: 2mm; font-weight: 400; }
.hd2-title .hd-t3:last-child { font-weight: 700; }
.kv { border-collapse: collapse; text-align: left; }
.hd2-tbl { margin-top: 14mm; width: 155mm; font-size: 13pt; }
.hd2-tbl td { padding: 2.1mm 0; vertical-align: top; }
.hd2-tbl td:first-child { width: 52mm; }
.hd2-tbl td:nth-child(2) { width: 7mm; }

/* Identitas rapor */
.p-identitas { padding: 14mm 18mm 18mm 20mm; font-size: 10.5pt; }
.p-identitas .idt td { padding-top: 1mm; padding-bottom: 1mm; }
.id-title { text-align: center; font-size: 12.5pt; font-weight: 700; margin: 0 0 7mm; }
.idt { border-collapse: collapse; width: 100%; }
.idt td { vertical-align: top; padding: 1.15mm 0; }
.idt .no { width: 10mm; text-align: right; padding-right: 3mm; }
.idt .lbl { width: 62mm; }
.idt .sep { width: 5mm; }
.idt tr.sub .lbl { padding-left: 5mm; }
.id-sign { display: flex; justify-content: flex-end; align-items: flex-end; gap: 14mm; margin-top: 6mm; }
.foto34 { width: 30mm; height: 40mm; border: 1px solid #000; display: grid; place-content: center; text-align: center; font-size: 7.5pt; }
.ttd { width: 70mm; line-height: 1.55; }
.ttd-space { height: 18mm; }
.ttd-nm { font-weight: 700; text-decoration: underline; }
.paper-F4 .p-identitas .idt td { padding-top: 1.6mm; padding-bottom: 1.6mm; }
.pg-no { position: absolute; left: 0; right: 0; bottom: 7mm; text-align: center; font-size: 11pt; }
.paper-F4 .hd2-tbl td { padding: 2.8mm 0; }

/* Buku induk & cek data */
.p-induk { padding: 10mm 12mm 10mm 14mm; font-size: 9.6pt; display: flex; flex-direction: column; }
.ind-head { display: flex; align-items: flex-start; gap: 6mm; }
.ind-no { font-size: 7pt; color: #2a7fc0; width: 6mm; }
.boxes { border-collapse: collapse; }
.boxes td { border: 1px solid #000; height: 7mm; min-width: 15mm; padding: 0 2mm; font-size: 8.5pt; vertical-align: middle; }
.boxes td.sm { font-size: 7.5pt; min-width: 0; }
.boxes td.big { font-weight: 700; font-size: 11pt; }
.ind-right { margin-left: auto; display: flex; align-items: center; gap: 4mm; }
.ind-title { text-align: center; font-weight: 700; font-size: 12.5pt; margin-top: 7mm; }
.ind-sub { text-align: center; font-size: 9.5pt; margin-top: 1mm; }
.ind-body { display: flex; gap: 4mm; margin-top: 5mm; flex: 1; }
.ind-body .idt { flex: 1; }
.idt.ind td { padding: .9mm 0; }
.idt.ind .no { width: 9mm; }
.idt.ind .lbl { width: 46mm; }
.idt.ind .sep { width: 4mm; }
.idt.ind .val { position: relative; }
.rk { float: right; display: inline-flex; gap: 3mm; margin-right: 6mm; }
.rk span { font-size: 8.5pt; }
.rk b { font-weight: 400; min-width: 8mm; }
.idt .small { font-size: 8pt; }
.ind-photos { width: 34mm; display: flex; flex-direction: column; justify-content: space-between; padding: 2mm 0 8mm; }
.ind-photos .ph { height: 46mm; border: 1px dashed #777; position: relative; }
.ind-photos .ph span { position: absolute; top: -1.5mm; left: 1mm; right: 1mm; background: #fff; border: 1px solid #000; font-size: 5.6pt; text-align: center; padding: .3mm; }
.ind-foot { display: flex; justify-content: space-between; font-size: 8pt; margin-top: 3mm; }
.dots { display: inline-block; width: 70mm; border-bottom: 1px dotted #555; height: 1em; }
.paper-F4 .idt.ind td { padding-top: 1.35mm; padding-bottom: 1.35mm; }
.paper-F4 .ind-photos .ph { height: 52mm; }

@media print {
  html, body { background: #fff !important; }
  body.printing .shell, .no-print, #toasts { display: none !important; }
  #print-root { position: static; background: none; overflow: visible; }
  .pages { padding: 0; gap: 0; display: block; }
  .page { box-shadow: none; margin: 0; page-break-after: always; break-after: page; }
  .page:last-child { page-break-after: auto; break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media screen and (max-width: 860px) {
  .pages { align-items: flex-start; padding-left: 12px; padding-right: 12px; }
  .pages .page { zoom: .45; }
}
