/* =========================================================================
   ntlerp — sistem desain
   Satu berkas, disusun berlapis: token -> dasar -> layout -> komponen.
   ========================================================================= */

/* ---------- 1. Token ---------- */
:root {
  /* Netral */
  --c-bg:        #f4f6f8;
  --c-surface:   #ffffff;
  --c-surface-2: #fafbfc;
  --c-border:    #e3e7ec;
  --c-border-2:  #d3d9e0;
  --c-text:      #16202c;
  --c-text-2:    #5a6675;
  --c-text-3:    #8894a3;

  /* Aksen — biru teknikal, cocok untuk konteks manufaktur */
  --c-brand:      #1257b8;
  --c-brand-dark: #0e4695;
  --c-brand-soft: #e8f0fc;

  /* Status */
  --c-success: #0f7a4d;  --c-success-soft: #e4f5ec;
  --c-warning: #97600b;  --c-warning-soft: #fcf1de;
  --c-danger:  #b3261e;  --c-danger-soft:  #fdeceb;
  --c-info:    #1257b8;  --c-info-soft:    #e8f0fc;

  /* Sidebar gelap */
  --c-nav-bg:     #101b2b;
  --c-nav-bg-2:   #18263a;
  --c-nav-text:   #a9b6c6;
  --c-nav-active: #ffffff;

  /* Bentuk & bayangan */
  --r-sm: 6px;  --r-md: 8px;  --r-lg: 12px;  --r-full: 999px;
  --sh-1: 0 1px 2px rgba(16, 27, 43, .06);
  --sh-2: 0 2px 8px rgba(16, 27, 43, .08);
  --sh-3: 0 8px 24px rgba(16, 27, 43, .14);

  /* Ukuran */
  --sidebar-w: 250px;
  --topbar-h: 58px;
  --content-max: 1320px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

/* ---------- 2. Dasar ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 21px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }

a { color: var(--c-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--font-mono); font-size: .92em; }
code { background: var(--c-surface-2); border: 1px solid var(--c-border); padding: 1px 5px; border-radius: var(--r-sm); }

.muted { color: var(--c-text-2); }
.help { color: var(--c-text-3); font-size: 12px; line-height: 1.45; }
/* Django kadang mengeluarkan teks bantuan sebagai <ul>; samakan gayanya. */
.help ul, .field ul.helptext { margin: 2px 0 0; padding-left: 16px; }
.help li { margin-top: 1px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.spacer { margin-left: auto; }
.stack { display: grid; gap: 16px; }

:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------- 3. Kerangka aplikasi ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--c-nav-bg);
  color: var(--c-nav-text);
  display: flex;
  flex-direction: column;
  /* Dipatok ke layar supaya kolom gelapnya tidak terpotong di halaman panjang. */
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: #fff; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  background: var(--c-brand); color: #fff;
  border-radius: var(--r-md);
  font-weight: 700; font-size: 13px; letter-spacing: -0.03em;
}
/* Logo bebas rasio: tinggi dikunci, lebar mengikuti bentuk aslinya.
   Alas putih hanya dipasang untuk logo gelap; logo terang dibiarkan
   tampil langsung di atas sidebar gelap. */
.brand-logo {
  height: 34px; width: auto; max-width: 168px; flex: none;
  object-fit: contain; object-position: left center; display: block;
}
.brand-logo.on-plate {
  background: #fff; border-radius: var(--r-md); padding: 3px 5px;
  max-width: 158px;
}
.brand--logo-only { padding-top: 14px; padding-bottom: 14px; }
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 650; font-size: 14px; color: #fff; }
.brand-sub {
  font-size: 10.5px; line-height: 1.35; color: var(--c-nav-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-label {
  padding: 0 10px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: #66748a;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  color: var(--c-nav-text); font-size: 13.5px; font-weight: 500;
  border-radius: var(--r-md); text-decoration: none;
}
.nav a:hover { background: var(--c-nav-bg-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--c-brand); color: var(--c-nav-active); font-weight: 600; }
.nav a .ico {
  width: 18px; height: 18px; flex: none; opacity: .9;
  stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav a.active .ico, .nav a:hover .ico { opacity: 1; }
.nav a .count {
  margin-left: auto; background: rgba(255,255,255,.14); color: #fff;
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: var(--r-full);
}
.nav a.active .count { background: rgba(255,255,255,.25); }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  margin-left: var(--sidebar-w);
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; font-size: 14px; }
.topbar-title .crumb { color: var(--c-text-3); font-weight: 500; }
.topbar-title .crumb::after { content: "/"; margin: 0 7px; color: var(--c-border-2); }

.icon-btn {
  display: none; border: 1px solid var(--c-border); background: var(--c-surface);
  width: 34px; height: 34px; border-radius: var(--r-md); cursor: pointer;
  font-size: 16px; line-height: 1; color: var(--c-text-2);
}

.content { padding: 24px; max-width: var(--content-max); width: 100%; }

/* Menu pengguna */
.usermenu { position: relative; margin-left: auto; }
.usermenu > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 9px;
  padding: 5px 9px 5px 5px; border-radius: var(--r-full); border: 1px solid transparent;
}
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover { background: var(--c-surface-2); border-color: var(--c-border); }
.usermenu[open] > summary { background: var(--c-surface-2); border-color: var(--c-border); }
.avatar {
  width: 30px; height: 30px; border-radius: var(--r-full); flex: none;
  display: grid; place-items: center;
  background: var(--c-brand-soft); color: var(--c-brand);
  font-weight: 700; font-size: 11.5px; letter-spacing: .02em;
}
.usermenu .who { display: grid; line-height: 1.2; text-align: left; }
.usermenu .who strong { font-size: 13px; font-weight: 600; }
.usermenu .who span { font-size: 11px; color: var(--c-text-3); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: 6px; z-index: 40;
}
.menu-panel .menu-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--c-border); margin-bottom: 6px; }
.menu-panel a, .menu-panel button {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border-radius: var(--r-md);
  color: var(--c-text); font-size: 13px; background: none; border: none;
  font-family: inherit; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--c-surface-2); text-decoration: none; }
.menu-panel .danger { color: var(--c-danger); }

/* ---------- 4. Kepala halaman ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head .titles { min-width: 0; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--c-text-2); margin-top: 3px; font-size: 13px; }
.breadcrumbs { font-size: 12px; color: var(--c-text-3); margin-bottom: 8px; }
.breadcrumbs a { color: var(--c-text-2); }
.breadcrumbs .sep { margin: 0 6px; color: var(--c-border-2); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- 5. Tombol ---------- */
.btn {
  --btn-bg: var(--c-surface); --btn-fg: var(--c-text); --btn-bd: var(--c-border-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; min-height: 36px;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  border-radius: var(--r-md); font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover { text-decoration: none; box-shadow: var(--sh-1); border-color: var(--c-text-3); }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary { --btn-bg: var(--c-brand); --btn-fg: #fff; --btn-bd: var(--c-brand); }
.btn-primary:hover { --btn-bg: var(--c-brand-dark); --btn-bd: var(--c-brand-dark); }
.btn-danger { --btn-fg: var(--c-danger); --btn-bd: #f0c4c1; }
.btn-danger:hover { --btn-bg: var(--c-danger-soft); --btn-bd: var(--c-danger); }
.btn-ghost { --btn-bd: transparent; --btn-bg: transparent; --btn-fg: var(--c-text-2); }
.btn-ghost:hover { --btn-bg: var(--c-surface-2); --btn-bd: var(--c-border); }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- 6. Kartu & panel ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 18px 20px;
}
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .card + form, form + .card { margin-top: 16px; }
/* Di dalam grid, jarak diatur gap; margin sibling akan menggeser kartu dan
   membuat barisnya tidak rata. */
.grid > .card, .grid > form, .grid > section, .grid > div { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: -2px 0 14px;
}
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 16px 20px 12px; margin: 0; border-bottom: 1px solid var(--c-border); }
.card-flush > .card-foot { padding: 12px 20px; border-top: 1px solid var(--c-border); background: var(--c-surface-2); }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }
/* Dua kolom pasti, supaya kartu tidak menggantung sendirian di baris terakhir. */
.grid-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-pair { grid-template-columns: 1fr; } }
.grid-sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 900px) { .grid-sidebar { grid-template-columns: 1fr; } }

/* ---------- 7. Statistik ---------- */
.stat {
  display: block; padding: 16px 18px; text-decoration: none; color: inherit;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
a.stat:hover { border-color: var(--c-brand); box-shadow: var(--sh-2); text-decoration: none; }
.stat-label { display: block; font-size: 12px; color: var(--c-text-2); font-weight: 550; }
.stat-value { display: block; font-size: 25px; font-weight: 680; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value.sm { font-size: 17px; }
.stat-foot { display: block; margin-top: 2px; font-size: 12px; color: var(--c-text-3); }
.stat.danger .stat-value { color: var(--c-danger); }
.stat.success .stat-value { color: var(--c-success); }

/* ---------- 8. Tabel ---------- */
.table-wrap {
  max-width: 100%;
  overflow-x: auto; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card .table-wrap, .card-flush .table-wrap { border: none; border-radius: 0; box-shadow: none; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; vertical-align: top; }
table.data thead th {
  background: var(--c-surface-2); border-bottom: 1px solid var(--c-border);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--c-text-2); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data tbody td { border-bottom: 1px solid var(--c-border); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--c-surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td { padding: 12px 14px; font-weight: 650; background: var(--c-surface-2); border-top: 1px solid var(--c-border-2); }
table.data .primary-cell { font-weight: 600; }
table.data td.code, table.data th.code { white-space: nowrap; }
table.data .sub { display: block; color: var(--c-text-3); font-size: 12px; font-weight: 400; margin-top: 1px; }
.empty { padding: 40px 20px; text-align: center; color: var(--c-text-3); }
.empty strong { display: block; color: var(--c-text-2); font-size: 14px; margin-bottom: 4px; }

/* ---------- 9. Badge & chip ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: #eef1f5; color: var(--c-text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.plain::before { display: none; }
.badge.success { background: var(--c-success-soft); color: var(--c-success); }
.badge.warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge.danger  { background: var(--c-danger-soft);  color: var(--c-danger); }
.badge.info    { background: var(--c-info-soft);    color: var(--c-info); }
.badge.muted   { background: #eef1f5; color: var(--c-text-2); }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-sm);
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  font-size: 11.5px; color: var(--c-text-2); font-weight: 550;
}

/* ---------- 10. Daftar kunci–nilai ---------- */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 22px; }
.meta > div { min-width: 0; font-size: 13.5px; }
.meta .full { grid-column: 1 / -1; }
.meta .sub, .field .sub, .stat .sub {
  display: block; margin-top: 2px;
  font-size: 12px; color: var(--c-text-3); line-height: 1.4;
}
.meta .label {
  display: block; font-size: 11px; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--c-text-3); margin-bottom: 3px;
}

/* ---------- 11. Form ---------- */
/* align-content: start mencegah kolom isian ikut melar ketika field di
   sebelahnya lebih tinggi karena punya teks bantuan atau pesan error. */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > .label-text { font-size: 12.5px; font-weight: 600; color: var(--c-text); }
.field .req { color: var(--c-danger); font-style: normal; margin-left: 2px; }

.input {
  width: 100%; padding: 8px 11px; min-height: 38px;
  border: 1px solid var(--c-border-2); border-radius: var(--r-md);
  background: var(--c-surface); color: var(--c-text);
  font: inherit; font-size: 13.5px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder { color: var(--c-text-3); }
.input:hover { border-color: var(--c-text-3); }
.input:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-soft); }
.input:disabled, .input[readonly] { background: var(--c-surface-2); color: var(--c-text-2); cursor: not-allowed; }
/* Penanda error digerakkan CSS agar tidak perlu memvalidasi form saat dibangun. */
.input.has-error,
.field:has(.errorlist li) .input { border-color: var(--c-danger); }
.input.has-error:focus,
.field:has(.errorlist li) .input:focus { box-shadow: 0 0 0 3px var(--c-danger-soft); }
.field:has(.errorlist li) > .label-text { color: var(--c-danger); }
select.input {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6675' d='M6 8.2 2.3 4.5l.9-.9L6 6.4l2.8-2.8.9.9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 12px;
}
textarea.input { min-height: 74px; resize: vertical; line-height: 1.5; }
.input.file { padding: 7px 11px; }
.input.file::file-selector-button {
  margin-right: 10px; padding: 4px 10px; border: 1px solid var(--c-border-2);
  background: var(--c-surface-2); border-radius: var(--r-sm); font: inherit; font-size: 12.5px; cursor: pointer;
}
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--c-danger); font-size: 12px; font-weight: 550; }

.check-row { display: flex; align-items: flex-start; gap: 9px; }
.check-row input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--c-brand); flex: none; }
.check-row .label-text { font-weight: 550; font-size: 13.5px; }

.checkbox-cards { display: grid; gap: 8px; }
.checkbox-cards label {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--c-border); border-radius: var(--r-md); cursor: pointer; background: var(--c-surface);
}
.checkbox-cards label:hover { border-color: var(--c-brand); background: var(--c-brand-soft); }
.checkbox-cards input { margin-top: 2px; accent-color: var(--c-brand); }

.form-section { padding-bottom: 4px; }
.form-section + .form-section { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--c-border); }
.form-section-head { margin-bottom: 14px; }
.form-section-head h3 { font-size: 13.5px; }
.form-section-head p { font-size: 12.5px; color: var(--c-text-2); margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr; } }

.form-actions {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding: 14px 20px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-2);
}
.form-actions .hint { color: var(--c-text-3); font-size: 12.5px; }

/* Tabel baris item pada form */
.line-table td { padding: 7px 8px; vertical-align: top; }
.line-table th { padding: 10px 8px; }
.line-table .input { min-height: 34px; padding: 6px 9px; font-size: 13px; }
.line-table td.w-item { width: 20%; min-width: 170px; }
.line-table td.w-desc { min-width: 200px; }
.line-table td.w-note { min-width: 180px; }
/* min-width, bukan width: pada tabel yang menggulir menyamping, `width` pada sel
   hanya usulan dan tetap diciutkan peramban sampai kolom isian tak terpakai. */
.line-table td.w-qty  { min-width: 104px; }
.line-table td.w-unit { min-width: 100px; }
.line-table td.w-price{ min-width: 140px; }
.line-table td.w-total{ min-width: 120px; }
.line-table td.w-del  { min-width: 64px; text-align: center; }
.line-table tr.row-deleted { opacity: .45; }
.line-table tr.row-deleted .input { text-decoration: line-through; }
.row-total { font-variant-numeric: tabular-nums; font-weight: 600; padding-top: 15px !important; }
/* `position: relative` wajib: tanpa itu checkbox absolut di dalamnya memakai
   viewport sebagai acuan, keluar dari kotak gulir tabel, dan membuat seluruh
   halaman bisa digeser ke samping di layar kecil. */
.del-toggle { position: relative; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.del-toggle input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.del-toggle span {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--c-border-2); border-radius: var(--r-md);
  color: var(--c-text-3); font-size: 14px; line-height: 1;
}
.del-toggle:hover span { border-color: var(--c-danger); color: var(--c-danger); background: var(--c-danger-soft); }
.del-toggle input:checked + span { border-color: var(--c-danger); color: #fff; background: var(--c-danger); }

/* ---------- 12. Toolbar filter ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.toolbar .input { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1 1 240px; min-width: 0; }
.toolbar .search { position: relative; flex: 1 1 260px; display: flex; }
.toolbar .search .input { padding-left: 34px; width: 100%; }
.toolbar .search::before {
  content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%);
  color: var(--c-text-3); font-size: 16px; pointer-events: none;
}
.toolbar .toggle {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  border: 1px solid var(--c-border-2); border-radius: var(--r-md);
  font-size: 13px; cursor: pointer; user-select: none; white-space: nowrap;
}
.toolbar .toggle input { accent-color: var(--c-brand); }
.toolbar .toggle:has(input:checked) { border-color: var(--c-brand); background: var(--c-brand-soft); color: var(--c-brand); font-weight: 600; }

/* ---------- 13. Total & progres ---------- */
.totals { margin-left: auto; width: 100%; max-width: 360px; display: grid; gap: 7px; font-size: 13.5px; }
.totals > div { display: flex; justify-content: space-between; gap: 20px; }
.totals .grand {
  border-top: 1px solid var(--c-border-2); margin-top: 4px; padding-top: 10px;
  font-size: 17px; font-weight: 700;
}
.totals span:last-child { font-variant-numeric: tabular-nums; }

.progress { height: 6px; background: #e7ebf0; border-radius: var(--r-full); overflow: hidden; min-width: 84px; }
.progress span { display: block; height: 100%; background: var(--c-brand); border-radius: var(--r-full); }
.progress.done span { background: var(--c-success); }

/* ---------- 14. Lampiran ---------- */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
@media (max-width: 640px) { .attach-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); } }

.attach {
  border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden;
  background: var(--c-surface); display: flex; flex-direction: column;
}
.attach:hover { border-color: var(--c-border-2); box-shadow: var(--sh-1); }

.attach .thumb {
  position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--c-surface-2); border-bottom: 1px solid var(--c-border);
  cursor: zoom-in;
}
/* Gambar dipatok absolut: `height: 100%` pada kotak ber-aspect-ratio menciptakan
   ketergantungan melingkar, dan peramban memakai tinggi asli gambar — bukti tegak
   jadi melar dan merusak tinggi barisnya.
   `contain`, bukan `cover`: bukti transaksi harus terbaca utuh, bukan terpotong. */
.attach .thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; display: block;
}
.attach .thumb.is-file { cursor: pointer; }
.attach .file-icon {
  display: grid; place-items: center; height: 100%; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--c-text-3);
}
.attach .file-icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.6; }
/* Jenis lampiran ditempel di sudut gambar supaya keterangan tetap jadi teks utama. */
.attach .kind {
  position: absolute; top: 7px; left: 7px; z-index: 1;
  padding: 2px 7px; border-radius: var(--r-full);
  font-size: 10.5px; font-weight: 650; letter-spacing: .01em;
  background: rgba(255, 255, 255, .93); color: var(--c-text-2);
  box-shadow: 0 1px 3px rgba(16, 27, 43, .18);
}
.attach .kind.invoice { color: var(--c-info); }
.attach .kind.proof { color: var(--c-success); }

.attach-body { padding: 9px 11px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.attach-body strong { font-size: 12.5px; font-weight: 600; word-break: break-word; line-height: 1.35; }
.attach-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  margin-top: auto; color: var(--c-text-3); font-size: 11px; white-space: nowrap;
}
.attach-foot .meta { overflow: hidden; text-overflow: ellipsis; }
.attach-del {
  flex: none; width: 26px; height: 26px; padding: 0; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-sm); background: none;
  color: var(--c-text-3); font-size: 13px; line-height: 1; cursor: pointer;
}
.attach-del:hover { background: var(--c-danger-soft); border-color: #f0c4c1; color: var(--c-danger); }

.upload-form {
  display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) minmax(0,1.2fr) auto;
  gap: 12px 14px; align-items: start;
  margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--c-border-2);
}
.upload-form .btn { margin-top: 21px; }   /* sejajar dengan baris kolom isian, bukan labelnya */
@media (max-width: 820px) {
  .upload-form { grid-template-columns: 1fr; }
  .upload-form .btn { margin-top: 4px; }
}

/* Bukti kecil di dalam tabel (mis. bukti transfer pada riwayat pembayaran) */
.proof-thumb {
  display: inline-block; width: 46px; height: 34px; overflow: hidden;
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  background: var(--c-surface-2); cursor: zoom-in; vertical-align: middle;
}
.proof-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.proof-file {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  font-size: 11.5px; color: var(--c-text-2); background: var(--c-surface-2);
}

/* Pratinjau gambar layar penuh */
.lightbox {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(16, 27, 43, .82); padding: 32px; cursor: zoom-out;
}
.lightbox img {
  max-width: min(1100px, 92vw); max-height: 82vh; object-fit: contain;
  background: #fff; border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.lightbox .lightbox-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; color: #fff; font-size: 13px; background: rgba(0, 0, 0, .35);
}
.lightbox .lightbox-bar a { color: #fff; text-decoration: underline; }
.lightbox .lightbox-close {
  position: absolute; top: 16px; right: 20px; width: 36px; height: 36px;
  border-radius: 50%; border: none; background: rgba(255, 255, 255, .15);
  color: #fff; font-size: 18px; cursor: pointer;
}
.lightbox .lightbox-close:hover { background: rgba(255, 255, 255, .28); }

/* ---------- 15. Pesan ---------- */
.messages { display: grid; gap: 10px; margin-bottom: 18px; }
.msg {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--r-md); font-size: 13.5px;
  border: 1px solid; background: var(--c-info-soft); border-color: #c9dcf8; color: #0f3f88;
}
.msg .close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 15px; line-height: 1; }
.msg .close:hover { opacity: 1; }
.msg.success { background: var(--c-success-soft); border-color: #bfe4d1; color: var(--c-success); }
.msg.warning { background: var(--c-warning-soft); border-color: #f0dcb8; color: var(--c-warning); }
.msg.error   { background: var(--c-danger-soft);  border-color: #f2c8c5; color: var(--c-danger); }

.callout {
  display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--r-md);
  border: 1px solid var(--c-border); background: var(--c-surface-2); font-size: 13.5px;
}
.callout.warning { background: var(--c-warning-soft); border-color: #f0dcb8; color: var(--c-warning); }
.callout.danger  { background: var(--c-danger-soft);  border-color: #f2c8c5; color: var(--c-danger); }
.callout strong { font-weight: 650; }

/* ---------- 16. Paginasi ---------- */
.pagination {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 16px; color: var(--c-text-2); font-size: 12.5px; flex-wrap: wrap;
  border-top: 1px solid var(--c-border); background: var(--c-surface-2);
}
.pagination .pages { display: flex; gap: 8px; }

/* ---------- 16b. Wizard ---------- */
.wizard-head { margin-bottom: 20px; }
.wizard-steps {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px;
  margin-top: 16px;
}
.wizard-step {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--c-border); background: var(--c-surface);
  text-decoration: none; color: inherit; min-width: 0;
}
.wizard-step .num {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: #eef1f5; color: var(--c-text-2);
}
.wizard-step .label { min-width: 0; }
.wizard-step .label b { display: block; font-size: 13px; font-weight: 650; }
.wizard-step .label span { display: block; font-size: 11.5px; color: var(--c-text-3); line-height: 1.35; }
.wizard-step.is-current { border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-soft); }
.wizard-step.is-current .num { background: var(--c-brand); color: #fff; }
.wizard-step.is-done .num { background: var(--c-success-soft); color: var(--c-success); }
.wizard-step.is-done { border-color: #bfe4d1; }
.wizard-step.is-next { opacity: .72; }
a.wizard-step:hover { text-decoration: none; border-color: var(--c-text-3); }
@media (max-width: 860px) {
  .wizard-steps { grid-auto-flow: row; }
  .wizard-step .label span { display: none; }
}

.wizard-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding: 14px 18px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-2);
  position: sticky; bottom: 0; z-index: 10;
}
.wizard-actions .hint { color: var(--c-text-3); font-size: 12.5px; }
.wizard-actions .spacer { margin-left: auto; }

/* Kartu aksi "apa yang ingin Anda lakukan" */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(226px, 1fr)); gap: 12px; }
.action-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 15px 16px; border-radius: var(--r-lg);
  border: 1px solid var(--c-border); background: var(--c-surface);
  box-shadow: var(--sh-1); text-decoration: none; color: inherit;
}
.action-card:hover { border-color: var(--c-brand); box-shadow: var(--sh-2); text-decoration: none; }
.action-card .ico-box {
  flex: none; width: 34px; height: 34px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--c-brand-soft); color: var(--c-brand);
}
.action-card .ico-box svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.action-card b { display: block; font-size: 13.5px; font-weight: 650; }
.action-card span { display: block; font-size: 12px; color: var(--c-text-2); margin-top: 2px; line-height: 1.4; }
.action-card .count {
  margin-left: auto; flex: none; align-self: center;
  background: var(--c-brand); color: #fff; font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--r-full);
}
.action-card.primary { border-color: var(--c-brand); background: linear-gradient(180deg, var(--c-brand-soft), var(--c-surface) 70%); }

.next-steps { counter-reset: step; list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.next-steps li { counter-increment: step; display: flex; gap: 10px; align-items: flex-start; }
.next-steps li::before {
  counter-content: ""; content: counter(step);
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  background: #eef1f5; color: var(--c-text-2);
}
.next-steps b { display: block; font-size: 13px; font-weight: 600; }
.next-steps span { display: block; font-size: 12px; color: var(--c-text-3); line-height: 1.4; }

/* Lembar keputusan persetujuan */
.decision-row.is-rejected { opacity: .55; }
.decision-row.is-rejected .primary-cell { text-decoration: line-through; }
.decision-row .toggle { border-color: var(--c-border); }
.decision-row .toggle:has(input:checked) { border-color: var(--c-success); background: var(--c-success-soft); color: var(--c-success); }
.decision-row .decision-label { font-weight: 600; font-size: 12.5px; }

/* ---------- 17. Timeline alur dokumen ---------- */
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.flow .step {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border: 1px solid var(--c-border); border-radius: var(--r-full);
  background: var(--c-surface); color: var(--c-text-3);
}
.flow .step.done { border-color: var(--c-success); background: var(--c-success-soft); color: var(--c-success); font-weight: 600; }
.flow .step.current { border-color: var(--c-brand); background: var(--c-brand-soft); color: var(--c-brand); font-weight: 650; }
.flow .arrow { color: var(--c-border-2); }

/* ---------- 18. HTMX ---------- */
.htmx-indicator {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px; border-radius: var(--r-full);
  background: var(--c-text); color: #fff; font-size: 12.5px; font-weight: 550;
  opacity: 0; transform: translateY(6px); transition: opacity .15s ease, transform .15s ease;
  pointer-events: none; box-shadow: var(--sh-3);
}
.htmx-indicator.htmx-request { opacity: 1; transform: none; }
.htmx-indicator .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.htmx-request.opacity-target { opacity: .5; transition: opacity .1s ease; }

/* ---------- 19. Halaman login ---------- */
.auth-page { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-side {
  background: linear-gradient(160deg, #101b2b 0%, #16304f 55%, #1257b8 140%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side .brand-mark { width: 40px; height: 40px; font-size: 15px; }
.auth-side h2 { font-size: 27px; font-weight: 680; line-height: 1.25; max-width: 15ch; }
.auth-side p { color: #b6c4d6; margin-top: 12px; max-width: 42ch; font-size: 14px; }
.auth-side .points { display: grid; gap: 12px; margin-top: 26px; }
.auth-side .points div { display: flex; gap: 10px; align-items: flex-start; color: #cfdaea; font-size: 13.5px; }
.auth-side .points b { color: #fff; font-weight: 600; }
.auth-side .foot { color: #7f8ea4; font-size: 12px; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--c-surface); }
.auth-card { width: min(390px, 100%); }
.auth-card h1 { font-size: 22px; }
.auth-card .sub { color: var(--c-text-2); margin: 6px 0 26px; font-size: 13.5px; }
.auth-form { display: grid; gap: 16px; }
/* Di ponsel panel identitas tidak dibuang, melainkan dijadikan pita ringkas di
   atas formulir. Menyembunyikannya sama sekali membuat halaman masuk kehilangan
   logo, nama sistem, dan penanda tahapnya — persis hal yang paling perlu terlihat
   lebih dulu. Yang ditanggalkan hanya daftar poin dan catatan kaki, sebab layar
   sesempit itu lebih baik langsung sampai ke formulirnya. */
@media (max-width: 880px) {
  /* Baris kedua memanjang mengisi sisa layar; tanpa itu latar halaman
     menyembul di bawah formulir sebagai pita kosong. */
  .auth-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; min-height: 100dvh; }
  .auth-side {
    padding: 26px 22px 24px;
    display: grid;
    gap: 14px;
    justify-content: start;
  }
  .auth-side h2 { font-size: 21px; max-width: none; }
  .auth-side p { margin-top: 6px; font-size: 13px; max-width: none; }
  .auth-side .points,
  .auth-side .foot,
  .auth-side .next { display: none; }
  .auth-side .stage { margin-top: 10px; font-size: 12.5px; padding: 6px 11px; }
  .auth-logo { height: 38px; }

  .auth-main { padding: 28px 22px 40px; place-items: start center; }
  .auth-card { width: min(420px, 100%); }
}

/* ---------- 20. Responsif ---------- */
@media (max-width: 1020px) {
  .icon-btn { display: grid; place-items: center; }
  .main { margin-left: 0; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--sh-3);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(16,27,43,.45); z-index: 25;
  }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 600px) {
  .usermenu .who { display: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { justify-content: flex-start; }
  .form-actions { padding: 12px 14px; }
}

.print-logo { height: 50px; width: auto; max-width: 220px; object-fit: contain; }
.print-logo.on-plate {
  background: var(--c-nav-bg); border-radius: var(--r-md); padding: 6px 10px;
}

/* ---------- 20b. Batang gulir ---------- */
/* Properti standar (Chrome 121+, Firefox, Safari 18.2+). Bila ini didukung,
   peramban mengabaikan aturan ::-webkit-scrollbar di bawahnya. */
html,
.table-wrap,
.content,
.menu-panel,
textarea.input {
  scrollbar-width: thin;
  scrollbar-color: var(--c-border-2) transparent;
}
/* Sidebar berlatar gelap butuh gagang terang, bukan abu-abu bawaan peramban. */
.sidebar .nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .22) transparent;
}

/* Cadangan untuk peramban WebKit yang belum mendukung properti standar. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--c-border-2);
  border: 3px solid transparent;
  border-radius: var(--r-full);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--c-text-3); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

.sidebar .nav::-webkit-scrollbar { width: 8px; }
.sidebar .nav::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, .2);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.sidebar .nav:hover::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, .34); }

/* Penanda bahwa menu masih bisa digulir: gradasi tipis di tepi bawah sidebar.
   Ditempel pada .sidebar, bukan .nav, supaya tidak ikut bergulir bersama isinya. */
.sidebar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: linear-gradient(to bottom, transparent, var(--c-nav-bg) 85%);
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.sidebar.has-more::after { opacity: 1; }

/* ---------- 21. Cetak ---------- */
@media print {
  .sidebar, .topbar, .no-print, .htmx-indicator, .form-actions, .actions { display: none !important; }
  body { background: #fff; }
  .app { display: block; }
  /* Sidebar dipatok ke layar; marginnya harus dilepas agar kertas tidak menyisakan
     kolom kosong selebar 250px di kiri. */
  .main { margin-left: 0; }
  .content { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; padding: 0; }
  .print-logo.on-plate { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.data thead th { position: static; }
  .print-doc { padding: 0; }
}

/* --- Bingkai QR WhatsApp --------------------------------------------------- */
.qr-frame {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.qr-code { width: 260px; height: 260px; image-rendering: pixelated; }
.qr-note { margin-top: 10px; text-align: center; }

/* --- Bilah kemajuan ------------------------------------------------------- */
.progress {
  height: 6px;
  margin-top: 10px;
  background: var(--c-surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--c-brand);
  border-radius: 999px;
  transition: width .4s ease;
}

/* --- Logo pada halaman masuk ---------------------------------------------
   Panel kirinya gelap, jadi logo terang tampil apa adanya; yang gelap perlu
   alas putih agar tetap terbaca. Tingginya lebih besar daripada di sidebar
   karena di sini logo itu satu-satunya penanda identitas. */
.auth-logo {
  height: 46px; width: auto; max-width: 240px;
  object-fit: contain; object-position: left center; display: block;
}
.auth-logo.on-plate {
  background: #fff; border-radius: var(--r-md); padding: 6px 10px;
}

/* --- Penanda tahap pada halaman masuk -------------------------------------
   Menyebut cakupan yang sudah jalan tanpa menenggelamkan judulnya: sedikit
   lebih terang dari teks pendukung, tetapi tetap di bawah judul. */
.auth-side .stage {
  margin-top: 14px;
  padding: 7px 12px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  font-size: 13px;
  color: rgba(255,255,255,.82);
}
.auth-side .stage strong { color: #fff; font-weight: 650; }
.auth-side .next {
  margin-top: 14px;
  font-size: 12.5px;
  color: rgba(255,255,255,.55);
}
