/* ── TEMA (operational console) ──────────────────────────────
   Palet netral hangat: kertas krem untuk latar, tinta gelap untuk
   sidebar & tombol utama, amber sebagai aksen fokus/aktif. Token
   shadcn-html (CDN di index.html) tetap dipakai komponen shadcn, tapi
   nilainya di-override ke palet ini. Variabel lama potool dipetakan
   di bawah. */
:root {
  /* Override token shadcn-html */
  --background:            oklch(0.973 0.006 85);
  --foreground:            oklch(0.235 0.016 262);
  --card:                  oklch(1 0 0);
  --card-foreground:       oklch(0.235 0.016 262);
  --popover:               oklch(1 0 0);
  --popover-foreground:    oklch(0.235 0.016 262);
  --primary:               oklch(0.275 0.030 262);
  --primary-foreground:    oklch(0.99 0 0);
  --secondary:             oklch(0.960 0.006 85);
  --secondary-foreground:  oklch(0.315 0.020 262);
  --muted:                 oklch(0.962 0.006 85);
  --muted-foreground:      oklch(0.505 0.014 262);
  --accent:                oklch(0.950 0.038 80);
  --accent-foreground:     oklch(0.315 0.020 262);
  --destructive:           oklch(0.560 0.170 25);
  --destructive-foreground:oklch(0.99 0 0);
  --border:                oklch(0.905 0.007 85);
  --input:                 oklch(0.905 0.007 85);
  --ring:                  oklch(0.78 0.14 75);
  --radius:                14px;
  --radius-sm:             9px;

  /* Elevasi */
  --shadow-xs:  0 1px 2px oklch(0.25 0.02 262 / .05);
  --shadow-sm:  0 1px 3px oklch(0.25 0.02 262 / .06), 0 1px 2px oklch(0.25 0.02 262 / .04);
  --shadow-md:  0 4px 12px oklch(0.25 0.02 262 / .07), 0 2px 4px oklch(0.25 0.02 262 / .04);
  --shadow-lg:  0 18px 48px oklch(0.22 0.02 262 / .14), 0 4px 12px oklch(0.22 0.02 262 / .06);

  /* Variabel potool */
  --bg:          var(--background);
  --bg2:         var(--muted);
  --surface:     var(--card);
  --surface2:    oklch(0.968 0.006 85);
  --text:        var(--foreground);
  --fg-muted:    var(--muted-foreground);
  --border-h:    oklch(0.855 0.010 85);
  --brand:       var(--primary);
  --brand-h:     oklch(0.22 0.03 262);
  --brand-glow:  oklch(0.80 0.15 75 / .20);
  --grad:        var(--primary);
  --grad-soft:   var(--muted);
  --font:        'IBM Plex Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --pixel-font:  var(--font);
  --mono-font:   'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Sidebar */
  --side-bg:      oklch(0.245 0.026 262);
  --side-bg-2:    oklch(0.205 0.022 262);
  --side-fg:      oklch(0.940 0.006 262);
  --side-muted:   oklch(0.715 0.020 262);
  --side-hover:   oklch(0.305 0.024 262);
  --side-active:  oklch(0.800 0.150 75 / .14);
  --amber:        oklch(0.810 0.145 75);
  --amber-soft:   oklch(0.945 0.040 80);

  /* Status & aksen (dipakai terbatas) */
  --green:       oklch(0.55 0.11 160);
  --green-h:     oklch(0.47 0.11 160);
  --green-glow:  oklch(0.55 0.11 160 / .12);
  --orange:      oklch(0.62 0.14 55);
  --orange-h:    oklch(0.54 0.14 55);
  --purple:      oklch(0.50 0.13 290);
  --purple-h:    oklch(0.44 0.13 290);
  --cyan:        oklch(0.58 0.09 215);
  --red:         var(--destructive);
  --ok-bg:       oklch(0.965 0.028 160);
  --ok-text:     oklch(0.44 0.10 160);
  --warn-bg:     oklch(0.965 0.040 75);
  --warn-text:   oklch(0.50 0.11 65);
  --err-bg:      oklch(0.965 0.020 25);
  --err-text:    oklch(0.49 0.16 25);
}

/* Reset di layer base agar komponen shadcn (layer components) tetap menang */
@layer base {
  * { box-sizing: border-box; margin: 0; padding: 0; }
}
/* Reset di atas menghapus margin:auto bawaan <dialog> → modal jatuh ke pojok */
dialog[open] { margin: auto; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 640px at 88% -14%, oklch(0.985 0.022 85), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  padding-left: 248px;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1;
}
::selection { background: oklch(0.86 0.09 80 / .40); }
.page, [id^="view-"] { position: relative; z-index: 1; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; bottom: 0; width: 248px; z-index: 100;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-fg);
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
  overflow: hidden;
  border-right: 1px solid oklch(0.34 0.02 262 / .55);
  scrollbar-width: thin; scrollbar-color: oklch(0.40 0.02 262) transparent;
}
.nav-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 2px 10px 22px;
  border-bottom: 1px solid oklch(0.34 0.02 262 / .55);
  margin-bottom: 16px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(140deg, oklch(0.88 0.14 88), oklch(0.75 0.15 68));
  color: oklch(0.24 0.03 262);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono-font); font-size: 12px; font-weight: 700; letter-spacing: .02em;
  flex-shrink: 0;
  box-shadow: 0 4px 14px oklch(0.80 0.15 75 / .28), inset 0 1px 0 oklch(1 0 0 / .45);
}
.brand-name { font-size: 15.5px; font-weight: 700; color: #fff; line-height: 1.2; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--side-muted); margin-top: 2px; letter-spacing: .02em; }

.nav-tools { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 3px; margin-top: 18px; }
.nav-group:first-child { margin-top: 0; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--side-muted); padding: 0 12px 7px;
}
.nav-tool-btn {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 12px;
  border: none; border-radius: 9px; background: transparent; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 500; color: var(--side-muted);
  text-align: left;
  transition: background .16s ease, color .16s ease;
}
.nav-tool-btn:hover { color: var(--side-fg); background: var(--side-hover); }
.nav-tool-btn.active {
  color: #fff; font-weight: 600;
  background: linear-gradient(90deg, oklch(0.80 0.15 75 / .18), oklch(0.80 0.15 75 / .04));
}
.nav-tool-btn.active::before {
  content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--amber);
  box-shadow: 0 0 10px oklch(0.80 0.15 75 / .50);
}
.nav-tool-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.nav-tool-btn .ico { width: 17px; height: 17px; flex-shrink: 0; opacity: .78; transition: opacity .16s ease, color .16s ease; }
.nav-tool-btn:hover .ico { opacity: 1; }
.nav-tool-btn.active .ico { color: var(--amber); opacity: 1; }

.nav-right {
  margin-top: 16px; padding-top: 16px; flex: none;
  border-top: 1px solid oklch(0.34 0.02 262 / .55);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.nav-right .badge {
  font-size: 11px; padding: 4px 10px; border-radius: 99px;
  background: oklch(1 0 0 / .06); color: var(--side-fg);
  border: 1px solid oklch(1 0 0 / .10);
  font-family: var(--font); font-weight: 500; white-space: nowrap;
}
#navLogout { color: var(--side-muted); padding: 6px 9px; width: auto; border-radius: 8px; }
#navLogout:hover { background: var(--side-hover); }
#navLogout .ico { width: 15px; height: 15px; }

/* Layar sempit: sidebar jadi bar atas yang bisa digeser */
@media (max-width: 900px) {
  body { padding-left: 0; }
  .nav {
    position: sticky; top: 0; width: auto; bottom: auto; padding: 11px 16px;
    flex-direction: row; align-items: center; gap: 10px;
    overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid oklch(0.34 0.02 262 / .55);
    box-shadow: 0 8px 24px oklch(0.20 0.02 262 / .14);
    scrollbar-width: none;
  }
  .nav-tools { overflow: visible; padding-right: 0; min-height: auto; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-brand { border: none; margin: 0; padding: 0 12px 0 0; white-space: nowrap; gap: 10px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: 11px; }
  .brand-name { font-size: 14px; }
  .brand-sub { display: none; }
  .nav-tools { flex-direction: row; flex: none; gap: 4px; }
  .nav-group { flex-direction: row; margin: 0; gap: 3px; }
  .nav-label { display: none; }
  .nav-tool-btn { width: auto; white-space: nowrap; padding: 8px 12px; min-height: 38px; }
  .nav-tool-btn.active::before { display: none; }
  .nav-right { margin: 0 0 0 auto; padding: 0; border: none; }
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.page { max-width: 1320px; margin: 0 auto; padding: 34px 40px 56px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 20px; }
.panel-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: linear-gradient(180deg, oklch(1 0 0), oklch(0.986 0.004 85));
}
.panel-title {
  font-family: var(--font); font-size: 15px; color: var(--text);
  font-weight: 650; letter-spacing: -.015em; display: flex; align-items: center; gap: 9px;
  white-space: nowrap;
}
.panel-body { padding: 24px; }
.panel-body + .panel-body { border-top: 1px solid var(--border); }

/* ── UPLOAD ZONE ─────────────────────────────────────────── */
.upload-zone {
  border: 1.5px dashed var(--border-h);
  background: radial-gradient(120% 130% at 50% 0%, oklch(0.985 0.012 85), oklch(0.965 0.006 85));
  text-align: center; padding: 34px 22px;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
  position: relative; border-radius: var(--radius);
  max-width: 720px; margin-left: auto; margin-right: auto;
}
.upload-zone:hover { border-color: oklch(0.78 0.06 80); box-shadow: inset 0 0 0 3px oklch(0.93 0.03 80 / .30); }
.upload-zone.dragover {
  border-color: var(--amber);
  background: oklch(0.955 0.045 80);
  box-shadow: inset 0 0 0 3px oklch(0.85 0.10 80 / .18);
}
.upload-zone p { color: var(--fg-muted); font-size: 13px; line-height: 1.65; margin: 0 auto 16px; max-width: 54ch; }
.upload-zone input[type=file] { display: none; }
.upload-zone .file-info { font-size: 12.5px; color: var(--ok-text); margin-top: 12px; font-weight: 600; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px;
  padding: 9px 15px; border: 1px solid transparent;
  font-family: var(--font); font-size: 13.5px; font-weight: 550;
  cursor: pointer; letter-spacing: -.005em;
  transition: background .16s ease, border-color .16s ease, color .16s ease,
              box-shadow .16s ease, transform .12s ease;
  white-space: nowrap; line-height: 1.2;
  border-radius: var(--radius-sm);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / .12), 0 1px 2px oklch(0.25 0.02 262 / .18);
}
.btn-primary:hover { background: oklch(0.235 0.03 262); box-shadow: inset 0 1px 0 oklch(1 0 0 / .14), 0 2px 6px oklch(0.25 0.02 262 / .22); }
/* Aksi sekunder: putih berbingkai, aksen warna hanya di teks */
.btn-green, .btn-orange, .btn-purple, .btn-cyan, .btn-ghost {
  background: var(--surface); color: var(--text); border-color: var(--border-h);
  box-shadow: var(--shadow-xs);
}
.btn-green:hover, .btn-orange:hover, .btn-purple:hover, .btn-cyan:hover, .btn-ghost:hover {
  background: var(--surface2); border-color: oklch(0.80 0.012 85);
}
.btn-green  { color: var(--green-h); }
.btn-orange { color: var(--orange-h); }
.btn-purple { color: var(--purple-h); }
.btn-cyan   { color: oklch(0.45 0.08 215); }
.btn-green:hover  { background: oklch(0.972 0.02 160); }
.btn-orange:hover { background: oklch(0.972 0.025 65); }
.btn-purple:hover { background: oklch(0.972 0.02 290); }
.btn-cyan:hover   { background: oklch(0.972 0.02 215); }
.btn-danger  { background: var(--red); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ── INPUTS ──────────────────────────────────────────────── */
.input {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--border-h); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 14px; outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.input:hover { border-color: oklch(0.80 0.012 85); }
.input:focus { border-color: oklch(0.72 0.10 75); box-shadow: 0 0 0 3px var(--brand-glow); }
.input::placeholder { color: oklch(0.60 0.012 262); }
select.input option { background: #fff; color: var(--text); }
.input-wrap { position: relative; }
.input-wrap .search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--fg-muted); pointer-events: none; font-size: 12px; }
.input-wrap .input { padding-left: 36px; }

/* ── TABLE ───────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-xs); }
table:not(.table) { width: 100%; border-collapse: collapse; font-size: 13px; }
th:not(.table-head) {
  background: oklch(0.971 0.006 85);
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: oklch(0.47 0.015 262);
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
td:not(.table-cell) {
  padding: 11px 16px; border-bottom: 1px solid oklch(0.945 0.005 85);
  white-space: nowrap; font-size: 13px; color: var(--text);
  font-family: var(--font); font-variant-numeric: tabular-nums;
}
th:not(.table-head) { font-variant-numeric: tabular-nums; }
tr:last-child td:not(.table-cell) { border-bottom: none; }
tbody tr:not(.table-row) { transition: background .12s ease; }
tbody tr:nth-child(even):not(.table-row) td:not(.table-cell) { background: oklch(0.988 0.004 85); }
tr:not(.table-row):hover td:not(.table-cell) { background: oklch(0.968 0.022 80); }
tr.hl td { background: oklch(0.965 0.045 85) !important; }
tfoot td:not(.table-cell) { font-weight: 600; background: oklch(0.965 0.008 85); border-top: 1px solid var(--border-h); border-bottom: none; color: var(--text); }
.flag-multi { color: var(--orange-h); font-weight: 600; }
.flag-none  { color: var(--red);      font-weight: 600; }
.mono { font-family: var(--mono-font); font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.number-input {
  width: 112px; padding: 7px 9px;
  border: 1px solid var(--border-h); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: var(--mono-font); font-size: 12.5px; text-align: right; outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.number-input:hover { border-color: oklch(0.80 0.012 85); }
.number-input:focus { border-color: oklch(0.72 0.10 75); box-shadow: 0 0 0 3px var(--brand-glow); }

/* ── STATUS / TAGS ───────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 10px; border: 1px solid; border-radius: 99px; font-weight: 550; }
.chip-ok   { background: var(--ok-bg);   color: var(--ok-text);   border-color: oklch(0.88 0.05 160); }
.chip-warn { background: var(--warn-bg); color: var(--warn-text); border-color: oklch(0.88 0.07 75); }
.chip-err  { background: var(--err-bg);  color: var(--err-text);  border-color: oklch(0.88 0.05 25); }
.stat-bar { display: flex; gap: 12px 20px; flex-wrap: wrap; font-size: 13px; color: var(--fg-muted); align-items: center; font-family: var(--font); }
.stat-bar b { color: var(--text); font-weight: 600; font-family: var(--mono-font); font-variant-numeric: tabular-nums; }
.stat-ok   { color: var(--green-h); font-weight: 600; }
.stat-warn { color: var(--orange-h); font-weight: 600; }
.stat-err  { color: var(--red); font-weight: 600; }
.alert { padding: 12px 16px; font-size: 12.5px; margin-bottom: 12px; border-left: 3px solid; border-radius: 10px; }
.alert-err  { background: var(--err-bg); color: var(--err-text); border-color: var(--red); display: none; }
.alert-info { background: var(--surface2); color: var(--text); border-color: var(--primary); }

/* ── SECTION DIVIDER ─────────────────────────────────────── */
.step-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 10.5px; font-weight: 650; color: var(--fg-muted);
  letter-spacing: .09em; margin-bottom: 12px; text-transform: uppercase;
}
.step-label::before { content: ''; width: 14px; height: 2px; border-radius: 2px; background: var(--amber); flex: none; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── VIEWS ───────────────────────────────────────────────── */
#view-home, #view-pl, #view-main, #view-editharga, #view-pdf, #view-cek, #view-label, #view-report, #view-onhand, #view-sisastok { display: none; }
#view-home.active, #view-pl.active, #view-main.active, #view-editharga.active,
#view-pdf.active, #view-cek.active, #view-label.active, #view-report.active,
#view-onhand.active, #view-sisastok.active { display: block; }

/* ── BERANDA (ringkasan alur kerja) ──────────────────────── */
.home-head { margin-bottom: 32px; max-width: 720px; }
.home-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; color: var(--text); }
.home-head p { font-size: 14.5px; color: var(--fg-muted); margin-top: 6px; }
.home-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.home-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.home-col-head {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: oklch(0.972 0.006 85);
  font-size: 10.5px; font-weight: 650; letter-spacing: .10em; text-transform: uppercase; color: var(--fg-muted);
}
.home-row {
  display: grid; grid-template-columns: 34px 1fr 18px; align-items: center; gap: 14px;
  width: 100%; padding: 16px 20px; border: none; border-bottom: 1px solid oklch(0.945 0.005 85);
  background: var(--surface); cursor: pointer; text-align: left; font-family: var(--font);
  transition: background .16s ease, box-shadow .16s ease;
  box-shadow: inset 2px 0 0 transparent;
}
.home-row:last-child { border-bottom: none; }
.home-row:hover { background: oklch(0.982 0.012 85); box-shadow: inset 2px 0 0 var(--amber); }
.home-row:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.home-row .hr-num {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; background: oklch(0.945 0.022 85); color: oklch(0.45 0.02 262);
  font-family: var(--mono-font); font-size: 11.5px; font-weight: 600;
  transition: background .16s ease, color .16s ease;
}
.home-row:hover .hr-num { background: oklch(0.92 0.05 80); color: oklch(0.36 0.03 262); }
.home-row .hr-title, .home-row .hr-desc { display: block; }
.home-row .hr-title { font-size: 14.5px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.home-row .hr-desc { font-size: 12.5px; color: var(--fg-muted); margin-top: 2px; }
.home-row .hr-arrow { width: 17px; height: 17px; color: var(--fg-muted); transition: transform .16s ease, color .16s ease; }
.home-row:hover .hr-arrow { transform: translateX(3px); color: var(--text); }

@media (max-width: 1000px) {
  .home-cols { grid-template-columns: 1fr; }
}

/* Heading khusus view upload packing list (markup memakai inline style) */
#view-pl .page > div:first-child h1 { font-size: 26px !important; letter-spacing: -.03em; }
#view-pl .page > div:first-child p { max-width: 54ch; margin-left: auto; margin-right: auto; }

/* Sisa On Hand: ratakan kartu bertingkat agar tidak kotak-di-dalam-kotak */
#view-sisastok .panel-body > div[style*="grid-template-columns:1fr 1fr"] > div {
  border-color: transparent !important;
  background: oklch(0.978 0.006 85);
  border-radius: 12px;
}

/* ── LABEL BOX ───────────────────────────────────────────── */
.shipping-label {
  border: 2px solid #222;
  width: 100%; max-width: 420px;
  font-family: Arial, sans-serif;
  background: #fff; margin-bottom: 16px; overflow: hidden; page-break-inside: avoid;
}
.label-section { padding: 12px 16px; }
.label-section + .label-section { border-top: 1px solid #bbb; }
.label-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #666; margin-bottom: 3px; }
.label-name { font-size: 15px; font-weight: 700; color: #111; line-height: 1.3; }
.label-addr { font-size: 12.5px; color: #333; line-height: 1.6; margin-top: 1px; }
.label-phone { font-size: 11.5px; color: #666; margin-top: 2px; }
.label-box { background: #111; color: #fff; padding: 14px 16px; text-align: center; }
.label-box-num { font-size: 28px; font-weight: 900; letter-spacing: .04em; }
.label-box-sub { font-size: 11px; opacity: .7; margin-top: 1px; }

/* Edit harga panel */
.ehp-section { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.ehp-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.ehp-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ehp-summary { margin-top: 10px; font-size: 12px; color: var(--fg-muted); }
.ehp-error { color: var(--err-text); font-size: 12px; margin-top: 8px; }
.db-badge { font-family: var(--mono-font); }

/* Modal */
dialog::backdrop { background: oklch(0.20 0.02 262 / .45); backdrop-filter: blur(3px); }
#addrDbModal > div {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  box-shadow: var(--shadow-lg) !important;
}

/* ── PRINT ───────────────────────────────────────────────── */
.print-header { display: none; }
.print-sheet  { display: none; }
@media print {
  /* Sembunyikan semua elemen navigasi & kontrol */
  .nav, .toolbar, .meta-bar, .alert-err,
  #mainToolbar, #summaryBox, #metaInfo { display: none !important; }
  body { padding-left: 0; }

  /* Default: sembunyikan semua view */
  #view-home, #view-pl, #view-main, #view-editharga, #view-pdf,
  #view-cek, #view-label, #view-report, #view-onhand, #view-sisastok { display: none !important; }

  /* ── Print Packing List ── */
  body.print-packlist #view-main { display: block !important; }
  body.print-packlist .page { padding: 0; max-width: 100%; }

  body.print-packlist .print-header { display: block; margin: 0 0 18px; }
  body.print-packlist .ph-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #8b5cf6);
    color: #fff; print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  body.print-packlist .ph-brand { font-weight: 800; font-size: 16px; letter-spacing: .02em; }
  body.print-packlist .ph-doc { font-size: 13px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; opacity: .92; }
  body.print-packlist .ph-meta {
    display: flex; flex-wrap: wrap; margin-top: 12px;
    border: 1px solid #e4e8f0; border-radius: 10px; overflow: hidden;
  }
  body.print-packlist .ph-meta-item { flex: 1 1 25%; min-width: 140px; padding: 9px 14px; border-right: 1px solid #e4e8f0; }
  body.print-packlist .ph-meta-item:last-child { border-right: none; }
  body.print-packlist .ph-label { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: #7a819a; margin-bottom: 3px; }
  body.print-packlist .ph-value { display: block; font-size: 13px; font-weight: 700; color: #11152a; }

  body.print-packlist .panel { box-shadow: none !important; border: none !important; }
  body.print-packlist .panel-header { display: none !important; }
  body.print-packlist .tbl-wrap { border: 1px solid #e4e8f0; border-radius: 10px; overflow: hidden; }
  body.print-packlist table { width: 100%; font-size: 10.5px; }
  body.print-packlist thead th {
    background: linear-gradient(180deg, #f8fafc, #eef2ff) !important;
    color: #1e293b !important; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; font-size: 9.5px;
    border-bottom: 2px solid #c7d2fe !important;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  body.print-packlist th, body.print-packlist td { padding: 6px 9px !important; }
  body.print-packlist tbody tr:nth-child(even) td {
    background: #fafbff !important; print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  body.print-packlist tfoot td {
    background: #eef2ff !important; border-top: 2px solid #c7d2fe !important; font-weight: 700;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }

  /* ── Print Packing List: lembar modern (No PO · Optik · Total Qty) ── */
  body.print-packlist .print-header { display: none !important; }
  body.print-packlist .tbl-wrap { display: none !important; }
  body.print-packlist .print-sheet { display: block; }
  /* Hanya lembar cetak yang tampil — sembunyikan panel/input lain */
  body.print-packlist #view-main .page > :not(#plPrintSheet) { display: none !important; }
  body.print-packlist .print-sheet {
    background: #fff; border: 1px solid #e8ecf3; border-radius: 12px;
    overflow: hidden; box-shadow: 0 2px 14px rgba(30,41,59,.06);
  }
  body.print-packlist .ps-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 8px; padding: 10px 16px; flex-wrap: wrap;
    background: linear-gradient(135deg, #4f46e5, #8b5cf6);
    color: #fff; print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  body.print-packlist .ps-brand { font-weight: 800; font-size: 11px; letter-spacing: .02em; opacity: .95; }
  body.print-packlist .ps-title { font-size: 16px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; line-height: 1.1; }
  body.print-packlist .ps-date { font-size: 11px; opacity: .92; }
  body.print-packlist .ps-body { padding: 12px 16px; }
  body.print-packlist .ps-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
  body.print-packlist .ps-mi {
    flex: 1 1 120px; min-width: 110px; padding: 7px 10px;
    background: linear-gradient(180deg, #f8fafc, #eef2ff);
    border: 1px solid #e0e7ff; border-radius: 8px;
  }
  body.print-packlist .ps-lb { display: block; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; color: #7a819a; margin-bottom: 3px; }
  body.print-packlist .ps-val { display: block; font-size: 13px; font-weight: 800; color: #11152a; }
  body.print-packlist .ps-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 10.5px; }
  body.print-packlist .ps-table thead th {
    background: linear-gradient(180deg, #f8fafc, #eef2ff); color: #1e293b;
    font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    font-size: 8.5px; padding: 6px 8px; border-bottom: 1.5px solid #c7d2fe; text-align: left;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  body.print-packlist .ps-table tbody td { padding: 5px 8px; border-bottom: 1px solid #eef1f7; word-break: break-word; }
  body.print-packlist .ps-table tbody tr:nth-child(even) td { background: #fafbff; }
  body.print-packlist .ps-table .ps-po { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #4f46e5; font-weight: 600; }
  body.print-packlist .ps-table td.ps-qty { text-align: right; font-weight: 700; }
  body.print-packlist .ps-table tbody tr:last-child td { border-bottom: none; }
  body.print-packlist .ps-table tfoot td {
    padding: 7px 8px; border-top: 1.5px solid #c7d2fe; background: #eef2ff; font-weight: 800; font-size: 11px;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  body.print-packlist .ps-total-lb { text-align: right; text-transform: uppercase; letter-spacing: .06em; }
  body.print-packlist .ps-total { text-align: right; }
  @page { size: auto; margin: 8mm; }

  /* ── Print Label Box ── */
  body.print-label #view-label { display: block !important; }
  body.print-label #view-label .page > div { display: block !important; }
  body.print-label #view-label > .page > div > div:first-child { display: none !important; }
  body.print-label #view-label .panel { border: none; box-shadow: none; }
  body.print-label #view-label .panel-header { display: none; }
  body.print-label #lblPreviewArea { background: transparent !important; padding: 0 !important; }
  body.print-label .shipping-label { page-break-after: always; max-width: 100%; }
  body.print-label .shipping-label:last-child { page-break-after: avoid; }

  body { background: #fff; }
}

/* ── GATE (login) ────────────────────────────────────────── */
.gate-overlay{
  position:fixed; inset:0; z-index:2000;
  display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(900px 520px at 50% -10%, oklch(0.86 0.10 80 / .35), transparent 65%),
    linear-gradient(180deg, oklch(0.25 0.026 262), oklch(0.19 0.02 262));
}
.gate-card{
  background: var(--surface);
  border: 1px solid oklch(1 0 0 / .10);
  border-radius: 18px;
  padding: 36px 32px 32px;
  width: 356px; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow-lg);
}
.gate-logo{
  width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 12px;
  background: linear-gradient(140deg, oklch(0.88 0.14 88), oklch(0.75 0.15 68));
  color: oklch(0.24 0.03 262);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono-font); font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 18px oklch(0.80 0.15 75 / .35), inset 0 1px 0 oklch(1 0 0 / .45);
}
.gate-card h2{ font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; color: var(--text); }
.gate-sub{ font-size: 13px; color: var(--fg-muted); margin: 0 0 20px; }
.gate-input{
  width: 100%; padding: 11px 13px; margin-bottom: 10px;
  border: 1px solid var(--border-h); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 15px; font-family: var(--font); box-sizing: border-box;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.gate-input:hover{ border-color: oklch(0.80 0.012 85); }
.gate-input:focus{ outline:none; border-color: oklch(0.72 0.10 75); box-shadow: 0 0 0 3px var(--brand-glow); }
.gate-btn{ width:100%; margin-top:8px; justify-content:center; min-height:42px; }
.gate-error{ color:var(--err-text); font-size:12.5px; margin:4px 0 8px; min-height:14px; }

/* ── DETAIL INTERAKSI & MOTION ───────────────────────────── */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
[id^="view-"].active { animation: viewIn .22s cubic-bezier(.22,.61,.36,1); }

/* Scrollbar halus */
* { scrollbar-width: thin; scrollbar-color: oklch(0.85 0.01 85) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: oklch(0.86 0.008 85);
  border: 2px solid transparent; border-radius: 99px; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: oklch(0.78 0.01 85); background-clip: padding-box; }

/* Fokus keyboard yang konsisten */
:where(button, [role="button"], a, select, summary):focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}

/* ── RESPONSIF ───────────────────────────────────────────── */
@media (max-width: 980px) {
  #view-label .page > div { grid-template-columns: 1fr !important; }
}
@media (max-width: 780px) {
  .page { padding: 22px 16px 44px; }
  .panel-header { padding: 14px 16px; flex-wrap: wrap; }
  .panel-body { padding: 16px; }
  .home-head { margin-bottom: 24px; }
  .home-head h1 { font-size: 26px; }
  .home-row { padding: 14px 16px; }
  .upload-zone { padding: 26px 16px; }
  #view-cek .panel-body > div[style*="grid-template-columns:1fr 1fr"],
  #view-sisastok .panel-body > div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  #addrDbModal [style*="grid-template-columns:120px 1fr 1fr"],
  #addrDbModal [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .input, .number-input, .gate-input, select.input { font-size: 16px; }
  .btn { min-height: 44px; }
  .action-row .btn { flex: 1 1 auto; }
  #mainToolbar div[style*="width:1px"] { display: none !important; }
  .toast, .table-container { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
