:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --line: #dde3ea;
  --text: #17202b;
  --muted: #5d6b7c;
  --primary: #1d5fbf;
  --primary-ink: #ffffff;
  --primary-soft: #e3edfb;
  --ok: #1a7f4b;      --ok-soft: #dff3e8;
  --warn: #a15c00;    --warn-soft: #fdf0d9;
  --bad: #b3261e;     --bad-soft: #fbe3e1;
  --idle: #6b7785;    --idle-soft: #eceff3;
  --info: #1d5fbf;    --info-soft: #e3edfb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e27;
    --surface-2: #1f2833;
    --line: #2c3744;
    --text: #e6ebf1;
    --muted: #9aa7b6;
    --primary: #6aa5ff;
    --primary-ink: #0b1522;
    --primary-soft: #1b2b44;
    --ok: #5fd197;      --ok-soft: #143325;
    --warn: #f0b659;    --warn-soft: #3a2a10;
    --bad: #ff8a80;     --bad-soft: #3d1a18;
    --idle: #9aa7b6;    --idle-soft: #242e3a;
    --info: #6aa5ff;    --info-soft: #1b2b44;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- tata letak ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 800; font-size: .8rem;
}
.brand-text { min-width: 0; }
.brand-text b { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { display: block; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-name { text-align: right; min-width: 0; }
.user-name b { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.user-name span { display: block; font-size: .72rem; color: var(--muted); }
.nav {
  max-width: 1200px; margin: 0 auto; padding: 0 12px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 10px 12px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .9rem; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav a.aktif { color: var(--primary); border-bottom-color: var(--primary); }
main { max-width: 1200px; margin: 0 auto; padding: 16px 16px 96px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; margin: 4px 0 14px; }
.page-head h1 { font-size: 1.35rem; }
.page-head .aksi { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; min-width: 0;
}
.card > h2, .card > h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .aksi { margin-left: auto; }
.stat b { display: block; font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--muted); }

/* ---------- tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.utama { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.utama:hover { filter: brightness(1.07); }
.btn.sukses { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bahaya { color: var(--bad); border-color: var(--bad); }
.btn.kecil { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
.btn.polos { border-color: transparent; background: transparent; }
input[type=text], input[type=email], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); min-height: 40px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--text); opacity: 1; }
label.fld { display: block; margin-bottom: 12px; }
label.fld > span { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 180px; gap: 10px; }
.filters { display: grid; grid-template-columns: 220px 180px 1fr; gap: 10px; margin-bottom: 12px; }

/* ---------- lencana ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-selesai  { background: var(--ok-soft);   color: var(--ok); }
.st-draf     { background: var(--warn-soft); color: var(--warn); }
.st-belum    { background: var(--idle-soft); color: var(--idle); }
.st-terlewat { background: var(--bad-soft);  color: var(--bad); }
.kat { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.kat-sb { background: var(--ok-soft); color: var(--ok); }
.kat-b  { background: var(--info-soft); color: var(--info); }
.kat-c  { background: var(--warn-soft); color: var(--warn); }
.kat-k  { background: var(--bad-soft); color: var(--bad); }

/* ---------- tabel ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; white-space: nowrap; }
.tbl th.urut { cursor: pointer; user-select: none; }
.tbl th.urut:hover { color: var(--text); }
.tbl tbody tr.klik { cursor: pointer; }
.tbl tbody tr.klik:hover { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- kalender ---------- */
.kal { display: grid; grid-template-columns: 70px repeat(5, minmax(0, 1fr)); gap: 6px; }
.kal-h { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 0 4px; }
.kal-w { font-size: .75rem; color: var(--muted); font-weight: 700; padding-top: 6px; }
.kal-d { background: var(--surface-2); border-radius: 10px; padding: 6px; min-height: 84px; min-width: 0; }
.kal-d.hari-ini { outline: 2px solid var(--primary); }
.kal-d .tg { font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.chip {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer;
  border-radius: 7px; padding: 4px 6px; margin-bottom: 4px; font-size: .74rem; line-height: 1.3;
  border-left: 3px solid currentColor;
}
.chip b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip span { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- batang ---------- */
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; margin-bottom: 10px; font-size: .88rem; }
.bar { grid-column: 1 / -1; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .b-ok { background: var(--ok); }
.bar .b-warn { background: var(--warn); }

/* ---------- daftar ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.kosong { color: var(--muted); font-size: .9rem; padding: 6px 0; }

/* ---------- form instrumen ---------- */
.form-head { display: grid; gap: 4px 16px; grid-template-columns: 1fr auto; align-items: start; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .86rem; color: var(--muted); }
.meta b { color: var(--text); font-weight: 600; }
.steps {
  position: sticky; top: 97px; z-index: 10; background: var(--bg);
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; margin: 8px 0 4px; scrollbar-width: none;
}
.steps::-webkit-scrollbar { display: none; }
.steps a {
  flex: none; text-decoration: none; font-size: .82rem; font-weight: 700;
  padding: 6px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.steps a.lengkap { color: var(--ok); border-color: var(--ok); }
.sec { scroll-margin-top: 150px; margin-top: 14px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sec-head .ringkas { margin-left: auto; font-size: .85rem; color: var(--muted); }
.sec-head .ringkas b { color: var(--text); }
.rubrik { font-size: .8rem; color: var(--muted); margin: -4px 0 10px; }
.butir { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.butir .kd { font-weight: 800; font-size: .82rem; color: var(--muted); }
.butir .tx { font-size: .92rem; }
.skor { display: flex; gap: 6px; }
.skor label { position: relative; }
.skor input { position: absolute; opacity: 0; pointer-events: none; }
.skor span {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 800; cursor: pointer; user-select: none;
}
.skor input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.skor input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.skor input:disabled + span { cursor: default; }
.skor input:disabled:not(:checked) + span { opacity: .45; }
.butir.kosong-skor .kd { color: var(--bad); }
.cek { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; cursor: pointer; }
.cek input { width: 22px; height: 22px; flex: none; margin: 0; }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert .btn { margin-left: auto; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.dock-in { max-width: 1200px; margin: 0 auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dock .nilai { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dock .nilai b { font-size: 1.35rem; font-weight: 800; }
.dock .simpan { font-size: .8rem; color: var(--muted); }
.dock .aksi { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.nilai-tbl td { padding: 6px 8px; }

/* ---------- layar tengah ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.box { width: 100%; max-width: 420px; }
.box .card { padding: 24px; }
.box h1 { font-size: 1.3rem; margin-bottom: 6px; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 16px 0; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: putar .8s linear infinite; }
@keyframes putar { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: .88rem; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}

/* ---------- ponsel ---------- */
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .brand-text span, .user-name { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .cari { grid-column: 1 / -1; }
  .row2 { grid-template-columns: 1fr; }
  .form-head { grid-template-columns: 1fr; }
  .butir { grid-template-columns: 30px minmax(0, 1fr); }
  .butir .skor { grid-column: 1 / -1; justify-content: space-between; }
  .skor label { flex: 1; }
  .skor span { width: 100%; }
  .kal { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .kal-h:first-child, .kal-w { display: none; }
  .kal-d { padding: 4px; min-height: 64px; }
  .chip { padding: 3px 4px; font-size: .68rem; }
  .chip span { display: none; }
  .tbl.kartu thead { display: none; }
  .tbl.kartu, .tbl.kartu tbody, .tbl.kartu tr, .tbl.kartu td { display: block; }
  .tbl.kartu tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl.kartu td { border: 0; padding: 2px 0; }
  .tbl.kartu td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .8rem; }
  .dock .aksi { margin-left: 0; width: 100%; }
  .dock .aksi .btn { flex: 1; white-space: normal; padding: 8px; line-height: 1.2; }
  .steps { top: 93px; }
}

/* ---------- cetak ---------- */
@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }
  body { background: #fff; color: #000; font-size: 10pt; }
}
.lembar { color: #000; font-size: 10pt; line-height: 1.35; }
.lembar h1 { font-size: 13pt; text-align: center; margin: 0; }
.lembar .sub { text-align: center; margin: 2px 0 10px; }
.lembar table { width: 100%; border-collapse: collapse; margin: 6px 0 8px; }
.lembar th, .lembar td { border: 1px solid #000; padding: 3px 5px; vertical-align: top; text-align: left; }
.lembar th { background: #eee; }
.lembar table.ident td { border: 0; padding: 1px 4px; }
.lembar table.ident td:first-child { width: 36%; }
.lembar .c { text-align: center; }
.lembar h2 { font-size: 10.5pt; margin: 10px 0 2px; }
.lembar .kotak { border: 1px solid #000; padding: 4px 6px; min-height: 22px; white-space: pre-wrap; margin-bottom: 6px; }
.lembar .ttd { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; page-break-inside: avoid; }
.lembar .ttd div { text-align: center; }
.lembar .ttd .ruang { height: 60px; }
.lembar .ttd b { text-decoration: underline; }
.lembar .draf { border: 2px solid #b3261e; color: #b3261e; text-align: center; font-weight: 700; padding: 4px; margin-bottom: 8px; }
.lembar .blok { page-break-inside: avoid; }

/* ---------- tambahan versi CodeIgniter ---------- */
.filters form, form.filters { margin: 0; }
.kal-d a.chip { text-decoration: none; }
.tbl th.urut a { color: inherit; text-decoration: none; }
.tbl th.urut a:hover { color: var(--text); }
.tbl tr.sorot td { background: var(--primary-soft); }
.pembaruan { position: fixed; left: 50%; top: 110px; transform: translateX(-50%); z-index: 40; box-shadow: var(--shadow); }
form.inline { display: inline; margin: 0; }
.lembar-aksi { max-width: 794px; margin: 16px auto; display: flex; gap: 8px; padding: 0 16px; }
@media print { .lembar-aksi { display: none !important; } }


/* ---------- logo ---------- */
.brand-logo { height: 40px; width: auto; flex: none; display: block; }
.brand-logo.besar { height: 64px; }
.lembar .kop { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
.lembar .kop img { height: 58px; width: auto; }
.lembar .kop > div { flex: 1; }
.lembar .kop h1, .lembar .kop .sub { text-align: left; }
.lembar .kop .sub { margin-bottom: 0; }
@media (max-width: 720px) { .brand-logo { height: 34px; } }
