/* =====================================================================
   Premiere Dental Care — Sistem Laporan Klinik
   Tema: flat clean corporate, dominan ungu-biru, dengan mode gelap.
   ===================================================================== */

:root {
  --bg: #F4F5FB;
  --bg-soft: #EDEFF9;
  --card: #FFFFFF;
  --card-2: #FAFAFE;
  --border: #E4E7F1;
  --border-strong: #D2D7E8;
  --ink: #171A2B;
  --ink-2: #2C3149;
  --muted: #6B7189;
  --primary: #5849E0;
  --primary-ink: #FFFFFF;
  --primary-soft: #EEECFE;
  --indigo: #4F46E5;
  --blue: #2563EB;
  --blue-soft: #E8F0FE;
  --green: #16A34A;
  --green-soft: #E6F6EC;
  --amber: #C2740A;
  --amber-soft: #FDF3E3;
  --red: #DC2626;
  --red-soft: #FDECEC;
  --orange: #EA580C;
  --violet: #7C3AED;
  --grad: linear-gradient(135deg, #5849E0 0%, #3B82F6 100%);
  --shadow-sm: 0 1px 2px rgba(23, 26, 43, .06);
  --shadow: 0 4px 14px rgba(23, 26, 43, .07);
  --shadow-lg: 0 14px 40px rgba(23, 26, 43, .12);
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 264px;
}

html[data-theme="dark"] {
  --bg: #0E1020;
  --bg-soft: #14172A;
  --card: #171A2E;
  --card-2: #1C2036;
  --border: #282D48;
  --border-strong: #363C5C;
  --ink: #ECEEF8;
  --ink-2: #D6DAF0;
  --muted: #9AA1BD;
  --primary: #7C6CF0;
  --primary-ink: #FFFFFF;
  --primary-soft: #232046;
  --indigo: #8B7BF3;
  --blue: #5B94F7;
  --blue-soft: #1B2440;
  --green: #34D399;
  --green-soft: #132A22;
  --amber: #F0B357;
  --amber-soft: #2B2313;
  --red: #F87171;
  --red-soft: #2E1618;
  --orange: #FB923C;
  --violet: #A78BFA;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; color: var(--ink); font-weight: 650; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.muted-sm { color: var(--muted); font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
/* baris fleksibel: selalu boleh membungkus agar tidak meluber di layar sempit */
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.flex-wrap { flex-wrap: wrap; }
.flex > .grow { min-width: 0; }
.grow { flex: 1; }

/* --------------------------------------------------------------- shell --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; letter-spacing: .5px;
}
/* Lambang berupa GAMBAR logo klinik (bila sudah diunggah). Kotak putih tipis dipakai
   agar logo berlatar putih tetap terlihat rapi pada mode gelap. */
.brand-logo {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 11px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 3px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 13.5px; overflow-wrap: anywhere; }
.brand-text strong { font-size: 13.5px; }
.brand-text small { color: var(--muted); font-size: 11.5px; }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
}
.nav-link:hover { background: var(--bg-soft); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-group { margin: 2px 0; }
.nav-group > summary { list-style: none; position: relative; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group .caret {
  margin-left: auto; width: 8px; height: 8px;
  border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: .55;
  transition: transform .15s ease;
}
.nav-group[open] .caret { transform: rotate(-135deg) translateY(-3px); }
.submenu { padding: 3px 0 3px 10px; margin-left: 12px; border-left: 1.5px solid var(--border); }
.nav-sub {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px; text-decoration: none;
}
.nav-sub:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.nav-sub.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; display: grid; gap: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.su-text { display: flex; flex-direction: column; }
.su-text strong { font-size: 13px; }
.su-text small { color: var(--muted); font-size: 11.5px; }
/* ------------------------------------------------- role badge & profil --- */
.badge-lg { font-size: 12.5px; padding: 5px 12px; }
.role-switch {
  margin: 0 14px 14px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card-2);
  display: flex; flex-direction: column; gap: 4px;
}
.role-switch-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 650; }
.role-switch select { font-size: 13px; padding: 7px 9px; }
.avatar-lg { width: 72px; height: 72px; font-size: 26px; }
.avatar img, img.avatar { object-fit: cover; }
.account-photo { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.account-photo > img, .account-photo > .avatar-lg { flex: 0 0 auto; }
.account-photo > img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-strong); }
.account-photo > .grow { flex: 1 1 240px; min-width: 0; }

/* -------------------------------------------------------- kamera/absensi --- */
.camera-box {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-soft); overflow: hidden; position: relative; min-height: 200px;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.camera-box video, .camera-box img.shot { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.camera-box .camera-hint { padding: 22px; color: var(--muted); font-size: 13px; }
.selfie-thumb { width: 100%; max-width: 210px; border-radius: 12px; border: 1px solid var(--border-strong); display: block; }
.geo-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.photo-grid figure { margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card-2); }
.photo-grid img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo-grid figcaption { padding: 6px 8px; font-size: 11.5px; color: var(--muted); }
.file-slot { display: grid; gap: 8px; }
.att-status { display: flex; flex-wrap: wrap; gap: 12px; }
.att-status .att-item {
  flex: 1 1 200px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; background: var(--card-2); min-width: 0;
}
.att-status .att-item b { display: block; font-size: 13px; margin-bottom: 2px; }

.avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700;
}

.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title h1 { font-size: 17px; margin: 0; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { padding: 22px 20px 40px; display: block; }
.foot {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); }
.ic { width: 18px; height: 18px; flex: 0 0 18px; }
.ic-sm { width: 15px; height: 15px; flex: 0 0 15px; }
.ic-lg { width: 30px; height: 30px; }
.theme-dark { display: none; }
html[data-theme="dark"] .theme-dark { display: block; }
html[data-theme="dark"] .theme-light { display: none; }

/* ------------------------------------------------------------- section --- */
.page-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .ph-text h2 { margin: 0 0 4px; }
.page-head .ph-text p { margin: 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section { margin-bottom: 32px; }
.section > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--ink); }
.section > h3 .ic { color: var(--primary); }

/* ---------------------------------------------------------------- card --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head h3 .ic { color: var(--primary); }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

/**
 * Blok kontrol di dalam kepala kartu (mis. catatan verifikasi + tombolnya).
 * Jarak nyaman 14px; pada ponsel tombol otomatis selebar baris agar mudah disentuh.
 */
.inline-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; width: 100%; min-width: 0; }
.inline-filter > input, .inline-filter > select { flex: 1 1 220px; min-width: 0; max-width: 100%; }
.inline-filter > .btn { flex: 0 0 auto; }
@media (max-width: 720px) {
  .inline-filter > .btn, .inline-filter > button.btn, .inline-filter > input, .inline-filter > select { flex: 1 1 100%; }
}

/* Penjaga lebar: anak kartu / kolom tidak boleh melebihi kotak induknya. */
.card > *, .field > *, .card-head > *, .ci-body > *, .grid > *, .section > * { min-width: 0; }
.card > *, .table-wrap { max-width: 100%; }

@media (max-width: 720px) {
  /* 16px mencegah iOS Safari memperbesar (zoom) halaman saat kolom disentuh. */
  input[type="text"], input[type="password"], input[type="number"], input[type="date"],
  input[type="time"], input[type="email"], select, textarea { font-size: 16px; }
}
/* ---------------------------------------------------- form yang dibuka --- */
/* Form yang dibuka lewat tombol (?new=1 / ?act=new / ?edit=N) diberi sorotan sesaat
   + digulir otomatis oleh assets/js/app.js. Tanpa ini, di HP halaman tampak "tidak
   bereaksi" karena form berada di bawah kartu statistik (di luar layar). */
.form-buka.form-sorot {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 24%, transparent), var(--shadow-lg);
}
details.form-buka > summary { list-style: none; }
details.form-buka > summary::-webkit-details-marker { display: none; }
details.form-buka > summary::after {
  content: "▾"; margin-left: 8px; color: var(--muted); font-size: 12px;
}
details.form-buka[open] > summary::after { content: "▴"; }

.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 18px 20px 0; margin-bottom: 12px; }
/* Kartu di dalam grid: jarak diatur oleh `gap` grid, jadi margin antar-kartu dimatikan.
   Tanpa ini kartu kedua (dan seterusnya) turun 20px dan jadi 20px lebih pendek dari
   kartu pertama — terlihat seperti kotak yang tidak sejajar. */
.grid > .card + .card { margin-top: 0; }
/* Kartu di dalam kartu (mis. daftar hak akses): lebih ringan, tanpa bayangan. */
.card-flat {
  background: var(--bg-soft);
  box-shadow: none;
  padding: 16px;
  border-color: var(--border);
}
.card-flat + .card-flat { margin-top: 0; }
.card-flat h4.mt-0 { margin-top: 0; }
/* Kotak tampilan (bukan isian) agar sejajar tinggi dengan kontrol form di sebelahnya. */
.readonly-box {
  display: flex; align-items: center;
  min-height: 42px; padding: 9px 11px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--ink-2); font-size: 13.5px;
}

.grid { display: grid; gap: 20px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-tight { gap: 14px; }
.span-2 { grid-column: span 2; }

/* --------------------------------------------------------------- stats --- */
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--grad); opacity: .9;
}
.stat .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 550; text-transform: uppercase; letter-spacing: .3px; }
.stat .stat-value { font-size: 23px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .stat-sub { color: var(--muted); font-size: 12.5px; }
.stat.is-green::after { background: var(--green); }
.stat.is-red::after { background: var(--red); }
.stat.is-amber::after { background: var(--amber); }
.stat.is-blue::after { background: var(--blue); }
.stat.is-violet::after { background: var(--violet); }
.stat-row { display: flex; align-items: center; gap: 8px; }

.delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

/* -------------------------------------------------------------- format --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent;
}
.b-green { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.b-amber { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.b-red { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.b-blue { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.b-indigo, .b-violet { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.b-gray, .b-orange { background: var(--bg-soft); color: var(--muted); border-color: var(--border); }
.b-orange { color: var(--orange); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--bg-soft); color: var(--ink-2);
  font-size: 12.5px; border: 1px solid var(--border);
}
.chip-muted { color: var(--muted); }
.chip-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 600; }

.progress { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }
.progress.is-warn > span { background: linear-gradient(135deg, #F59E0B, #EA580C); }
.progress.is-bad > span { background: linear-gradient(135deg, #F87171, #DC2626); }

/* -------------------------------------------------------------- tables --- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data thead th {
  background: var(--card-2);
  color: var(--muted);
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--card-2); }
table.data tfoot td { font-weight: 650; background: var(--card-2); border-top: 2px solid var(--border-strong); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data.compact th, table.data.compact td { padding: 7px 10px; }
.table-scroll { max-height: 460px; overflow-y: auto; }

/**
 * Kelompok tombol aksi di dalam sel tabel (edit / nonaktifkan / hapus).
 * Dipakai supaya tombol selalu sejajar secara vertikal dan berjarak sama
 * di layar sempit maupun lebar — <form> di dalamnya dibuat "display: contents"
 * agar tombolnya menjadi item flex langsung dari .row-actions.
 */
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions > form { display: contents; }
.row-actions > * { margin: 0; }
/* Tombol di dalam <form> cenderung inline-level (tingginya berbeda karena line-box),
   jadi dipaksa block-level + tinggi seragam agar semua tombol sejajar rapi. */
.row-actions .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  white-space: nowrap;
}
table.data td .btn, table.data td form { vertical-align: middle; }
@media (max-width: 720px) {
  .row-actions { gap: 10px; }
}

/* --------------------------------------------------------------- forms --- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid > * { min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="time"], input[type="email"], select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 9px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
}

/**
 * Kolom tanggal/jam: sebagian browser (iOS Safari, Samsung Internet, Firefox)
 * memberi lebar intrinsik pada kontrol ini sehingga melebihi kotak induknya.
 * Reset berikut memaksa kontrol mengikuti lebar kolom, bukan lebar bawaan browser.
 */
input[type="date"], input[type="time"], input[type="datetime-local"],
input[type="month"], input[type="week"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  inline-size: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
/* Penjaga umum: kontrol form tidak boleh lebih lebar dari tempatnya. */
input, select, textarea, button, fieldset, .btn, .badge, .chip { max-width: 100%; }
fieldset { min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { min-height: 76px; resize: vertical; }
input[readonly] { background: var(--bg-soft); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); }

/**
 * Baris filter. Mobile-first: SATU item per baris di layar ponsel, melebar
 * otomatis jadi beberapa kolom pada layar besar. Memakai CSS Grid (bukan flex)
 * supaya kolom tanggal / tombol tidak mungkin saling menempel atau bertumpuk
 * pada lebar layar berapa pun.
 */
.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  min-width: 0;
  max-width: 100%;
}
.filters > * { min-width: 0; max-width: 100%; }
.filters > .field { min-width: 0; }
.filters .btn { height: 42px; }
.filters > .flex, .filters > .flex-wrap, .filters > .tabs { grid-column: 1 / -1; }
@media (min-width: 721px) {
  .filters { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}
@media (min-width: 1100px) {
  .filters { grid-template-columns: repeat(auto-fit, minmax(190px, 240px)); }
  .filters .btn { justify-self: start; width: auto; min-width: 160px; }
}

.checklist { display: grid; gap: 20px; }
.check-group { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.check-group > header {
  background: var(--card-2); padding: 10px 14px; font-weight: 650; font-size: 13px;
  border-bottom: 1px solid var(--border); color: var(--ink-2);
}
.check-item {
  display: grid; grid-template-columns: 22px 1fr;
  gap: 12px; align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.check-item:last-child { border-bottom: none; }
.check-item > input[type="checkbox"] { width: 18px; height: 18px; margin: 2px 0 0; }
.check-item > .ci-bullet {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); margin-top: 1px;
}
.check-item > .ci-body { display: grid; gap: 8px; min-width: 0; }
.check-item .ci-text { font-size: 13.5px; }
.check-item.is-done { background: color-mix(in srgb, var(--green) 6%, transparent); }
.ci-inputs { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ci-inputs input[type="number"] { max-width: 170px; }
.ci-inputs input[type="text"] { max-width: 100%; }
.ci-metric { font-size: 12px; color: var(--muted); }
.verify-note { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(1.06); background: var(--grad); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 16%, transparent); }
.btn-success { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.alert { padding: 11px 14px; border-radius: 11px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.a-success { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.a-error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.a-warning { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.a-info { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty-state h2, .empty-state h3 { color: var(--ink); }

/* ---------------------------------------------------------------- tabs --- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a, .tabs button {
  padding: 9px 13px; border-radius: 10px 10px 0 0; font-size: 13.5px; font-weight: 600;
  color: var(--muted); background: transparent; border: 1px solid transparent; border-bottom: none; cursor: pointer;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); background: var(--bg-soft); text-decoration: none; }
.tabs a.active, .tabs button.active { color: var(--primary); background: var(--card); border-color: var(--border); border-bottom: 1px solid var(--card); margin-bottom: -1px; }

/* -------------------------------------------------------------- charts --- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------------------------------------------------------------- misc --- */
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.list-clean { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; max-width: 100%; }
/* min-width:0 pada li & isinya wajib: tanpa itu teks panjang memaksa item lebih
   lebar dari kartunya (menyebabkan halaman bisa digeser ke samping). */
.list-clean li {
  display: flex; gap: 10px; align-items: flex-start;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  min-width: 0; max-width: 100%; overflow-wrap: anywhere;
}
.list-clean li > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.list-clean li:last-child { border-bottom: none; padding-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); display: grid; gap: 14px; }
.timeline { min-width: 0; max-width: 100%; }
.timeline li { position: relative; min-width: 0; overflow-wrap: anywhere; }
.timeline .tl-title, .timeline .tl-meta { overflow-wrap: anywhere; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.timeline .tl-title { font-weight: 600; font-size: 13.5px; }
.timeline .tl-meta { color: var(--muted); font-size: 12px; }

.bar-inline { display: flex; align-items: center; gap: 8px; }
.bar-inline .progress { flex: 1; min-width: 60px; }

details.help > summary { cursor: pointer; color: var(--primary); font-size: 12.5px; font-weight: 600; }
details.help[open] > summary { margin-bottom: 8px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }

.hr { height: 1px; background: var(--border); margin: 18px 0; border: 0; }

/* ---------------------------------------------------------------- login --- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 12% 10%, color-mix(in srgb, #5849E0 22%, transparent), transparent 60%),
    radial-gradient(800px 600px at 88% 88%, color-mix(in srgb, #3B82F6 22%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 30px;
}
.login-brand { display: grid; justify-items: center; gap: 10px; text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { width: 54px; height: 54px; flex: none; border-radius: 15px; font-size: 16px; }
.login-brand .brand-logo { width: 84px; height: 84px; flex: none; border-radius: 18px; padding: 5px; }
.brand-logo-lg { width: 84px; height: 84px; flex: 0 0 84px; border-radius: 16px; padding: 5px; }
.brand-mark-lg { width: 84px; height: 84px; flex: 0 0 84px; border-radius: 18px; font-size: 20px; }
.login-brand h1 { font-size: 19px; margin: 0; }
.login-brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
.login-card form { display: grid; gap: 16px; }
.login-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 14px; font-size: 13px; }
.login-links a { color: var(--primary); font-weight: 600; text-decoration: none; }
.login-links a:hover { text-decoration: underline; }
.login-links .dot { color: var(--muted); }
.login-card-wide { max-width: 560px; }
.reset-temp { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 12px 0 6px; }
.reset-temp-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 700; letter-spacing: 1px; color: var(--ink);
  background: var(--bg-soft); border: 1px dashed var(--border-strong);
  border-radius: 12px; padding: 10px 16px; user-select: all;
}
@media (max-width: 560px) { .reset-temp-value { font-size: 18px; width: 100%; text-align: center; } }
.login-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-104%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(14, 16, 32, .5); z-index: 35; }
  .content { padding: 18px 14px 32px; }
  .topbar { padding: 10px 14px; }
  .d-none-mobile { display: none !important; }
}
@media (max-width: 720px) {
  .cols-2, .cols-3, .cols-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .span-2 { grid-column: span 1; }
  .stat .stat-value { font-size: 20px; }
  /* Tabel data dipadatkan agar lebih banyak kolom terlihat tanpa menggeser */
  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 9px 10px; }
  table.data.compact th, table.data.compact td { padding: 7px 8px; }
  table.data thead th { font-size: 11px; }
}

/* ------------------------------------------------- media slip gaji --- */
/* Pratinjau logo kop & tanda tangan pada Pengaturan Gaji.
   WAJIB height:auto — atribut width/height di HTML menimpa aspect-ratio. */
.kop-preview {
  display: block; max-width: 100%; max-height: 110px; height: auto;
  margin-top: 12px; padding: 8px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border);
}
.ttd-preview {
  display: block; max-width: 230px; max-height: 110px; height: auto;
  margin-top: 12px; padding: 8px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border);
}
.list-plain {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px; font-size: 13.5px; color: var(--muted);
}

/* ------------------------------------------------- slip gaji (cetak) --- */
.slip-sheet { max-width: 920px; }
.slip-kop { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.slip-logo {
  width: 84px; height: 84px; flex: none;
  object-fit: contain; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--border); padding: 6px;
}
.slip-kop-teks { min-width: 0; }
.slip-kop-teks h3 { margin: 0; font-size: 20px; }
.slip-kop-teks p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.slip-garis { height: 3px; border-radius: 2px; background: var(--grad); margin: 16px 0 20px; }
.slip-judul { text-align: center; margin: 0 0 4px; letter-spacing: .08em; }
.slip-periode { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.slip-info {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px;
}
.slip-info > div { display: grid; gap: 2px; min-width: 0; }
.slip-info span { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.slip-info b { font-size: 14px; }
.slip-tabel tfoot td { font-weight: 700; }
.slip-potongan td { color: var(--red); }
.slip-netto td { background: var(--bg-soft); font-size: 15px; }
.slip-terbilang {
  margin-top: 16px; padding: 14px 18px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft);
}
.slip-catatan { margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.slip-ttd { display: flex; justify-content: space-between; gap: 24px; margin-top: 32px; text-align: center; }
.slip-ttd-kiri, .slip-ttd-kanan { flex: 1 1 0; min-width: 0; }
.slip-ttd p { margin: 4px 0 0; }
.slip-ttd-ruang {
  height: 78px; display: flex; align-items: flex-end; justify-content: center;
  border-bottom: 1px dashed var(--border-strong); padding-bottom: 4px;
}
.slip-ttd-ruang img { max-height: 70px; max-width: 170px; height: auto; }
.slip-kaki { margin-top: 24px; text-align: center; font-size: 11.5px; }

@media (max-width: 720px) {
  .slip-info { grid-template-columns: minmax(0, 1fr); }
  .slip-ttd { flex-direction: column; gap: 28px; }
  .slip-kop { gap: 12px; }
  .slip-logo { width: 64px; height: 64px; }
}

/* ---------------------------------------------------------------- print --- */
@media print {
  .sidebar, .topbar, .foot, .page-actions, .no-print, .filters .btn { display: none !important; }
  body, .content { background: #fff; padding: 0; }
  .card { box-shadow: none; border-color: #ccc; }
  a { color: #000; }
  /* Slip gaji: bersihkan bingkai kartu & warna latar agar hemat tinta */
  .slip-sheet { max-width: none; padding: 0; border: none; }
  .slip-info, .slip-terbilang, .slip-netto td { background: #fff; }
  .tabs { display: none !important; }
}
