/* =====================================================================
   Sistem Manajemen Stok dan Distribusi Barang
   Tema: pastel soft blue + putih, bersih dan ramah untuk input harian.
   ===================================================================== */

:root {
  /* Warna utama */
  --biru:        #6C9BD1;
  --biru-tua:    #4E7FB5;
  --biru-muda:   #EAF2FB;
  --mint:        #7FC9BC;
  --mint-muda:   #E7F5F2;

  /* Status */
  --sukses:      #86C7A0;  --sukses-bg: #E8F5EE;
  --tunda:       #F2C879;  --tunda-bg:  #FDF4E3;
  --gagal:       #E39A9A;  --gagal-bg:  #FBEDED;

  /* Netral */
  --putih:       #FFFFFF;
  --latar:       #F7F9FC;
  --teks:        #3D4759;
  --teks-lembut: #7A869A;
  --garis:       #E3E8EF;

  --radius:      12px;
  --radius-sm:   9px;
  --bayang:      0 1px 2px rgba(61,71,89,.04), 0 4px 16px rgba(61,71,89,.05);
  --bayang-kuat: 0 8px 28px rgba(61,71,89,.12);
  --sidebar-w:   248px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--latar);
  color: var(--teks);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--biru-tua); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Angka selalu rata rapi di kolom uang */
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .92em; }

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

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

.sidebar-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--garis);
}
.sidebar-brand .logo {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--biru), var(--mint));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.sidebar-brand .nama { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.sidebar-brand .sub  { font-size: 11px; color: var(--teks-lembut); }

.nav { padding: 12px 10px 24px; flex: 1; }
.nav-group { margin-bottom: 6px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--teks-lembut); font-weight: 700; padding: 12px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--teks); font-weight: 500; font-size: 13.5px;
  position: relative; margin-bottom: 2px;
}
.nav a:hover { background: var(--latar); text-decoration: none; }
.nav a.active { background: var(--biru-muda); color: var(--biru-tua); font-weight: 700; }
.nav a.active::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--biru);
}
.nav .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav a.active .ico { opacity: 1; }

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

.topbar {
  background: var(--putih); border-bottom: 1px solid var(--garis);
  padding: 12px 22px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .user { display: flex; align-items: center; gap: 9px; }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--biru-muda);
  color: var(--biru-tua); display: grid; place-items: center; font-weight: 700; font-size: 12.5px;
}
.topbar .uinfo { line-height: 1.2; }
.topbar .uinfo b { font-size: 13px; display: block; }
.topbar .uinfo span { font-size: 11px; color: var(--teks-lembut); }

.burger {
  display: none; background: none; border: 1px solid var(--garis);
  border-radius: 8px; padding: 6px 9px; cursor: pointer; color: var(--teks);
}

.content { padding: 22px; flex: 1; }
.content > .page-head { margin-bottom: 16px; display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-head h2 { margin: 0 0 3px; font-size: 19px; font-weight: 700; }
.page-head p  { margin: 0; color: var(--teks-lembut); font-size: 13px; }

/* ---------------------------------------------------------------
   Kartu
   --------------------------------------------------------------- */
.card {
  background: var(--putih); border: 1px solid var(--garis);
  border-radius: var(--radius); box-shadow: var(--bayang); margin-bottom: 18px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--garis);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; flex: 1; min-width: 160px; }
.card-head .hint { font-size: 12px; color: var(--teks-lembut); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------------------------------------------------------------
   Grid & statistik
   --------------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }

.stat {
  background: var(--putih); border: 1px solid var(--garis); border-radius: var(--radius);
  padding: 16px 17px; box-shadow: var(--bayang); position: relative; overflow: hidden;
}
.stat .label { font-size: 12px; color: var(--teks-lembut); font-weight: 600; margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .sub   { font-size: 11.5px; color: var(--teks-lembut); margin-top: 4px; }
.stat::after {
  content: ''; position: absolute; right: -18px; top: -18px;
  width: 66px; height: 66px; border-radius: 50%; background: var(--biru-muda); opacity: .55;
}
.stat.mint::after   { background: var(--mint-muda); }
.stat.sukses::after { background: var(--sukses-bg); }
.stat.tunda::after  { background: var(--tunda-bg); }
.stat.gagal::after  { background: var(--gagal-bg); }
.stat > * { position: relative; z-index: 1; }

/* ---------------------------------------------------------------
   Tabel
   --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.2px; }
table.tbl th, table.tbl td { padding: 10px 14px; text-align: left; vertical-align: middle; }
table.tbl thead th {
  background: var(--biru-muda); color: var(--teks); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
  border-bottom: 1px solid var(--garis);
}
table.tbl tbody tr { border-bottom: 1px solid var(--garis); }
table.tbl tbody tr:last-child { border-bottom: 0; }
table.tbl tbody tr:hover { background: #FBFCFE; }
table.tbl tfoot td { background: var(--latar); font-weight: 700; border-top: 2px solid var(--garis); }
table.tbl .aksi { white-space: nowrap; text-align: right; }
table.tbl.rapat th, table.tbl.rapat td { padding: 7px 10px; }

.empty { padding: 40px 20px; text-align: center; color: var(--teks-lembut); }
.empty .big { font-size: 15px; font-weight: 600; color: var(--teks); margin-bottom: 5px; }

/* ---------------------------------------------------------------
   Tombol
   --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--biru); color: #fff; font-weight: 600; font-size: 13.2px;
  cursor: pointer; font-family: inherit; line-height: 1.3; white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--biru-tua); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--putih); color: var(--teks); border-color: var(--garis); }
.btn-ghost:hover { background: var(--latar); color: var(--teks); }
.btn-mint { background: var(--mint); }
.btn-mint:hover { background: #66B5A7; }
.btn-danger { background: var(--gagal); }
.btn-danger:hover { background: #D28282; }
.btn-sm { padding: 6px 11px; font-size: 12.3px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 9px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------
   Form
   --------------------------------------------------------------- */
.form-grid { display: grid; gap: 14px; }
.fg { display: flex; flex-direction: column; gap: 5px; }
.fg label { font-size: 12.5px; font-weight: 600; color: var(--teks); }
.fg .req { color: var(--gagal); }
.fg .note { font-size: 11.5px; color: var(--teks-lembut); line-height: 1.45; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--garis);
  border-radius: var(--radius-sm); background: var(--putih); color: var(--teks);
  font-family: inherit; font-size: 13.5px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--biru); box-shadow: 0 0 0 3px rgba(108,155,209,.18);
}
input:disabled, select:disabled, textarea:disabled { background: var(--latar); color: var(--teks-lembut); }
textarea { resize: vertical; min-height: 76px; }
select { appearance: none; background-image:
  url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237A869A' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* aksesibilitas: fokus keyboard selalu terlihat */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--biru-tua); outline-offset: 2px;
}

.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.filter-bar .fg { min-width: 145px; flex: 0 1 auto; }
.filter-bar .grow { flex: 1 1 200px; }

/* ---------------------------------------------------------------
   Badge & label
   --------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.5;
}
.b-sukses { background: var(--sukses-bg); color: #35785A; }
.b-tunda  { background: var(--tunda-bg);  color: #96660E; }
.b-gagal  { background: var(--gagal-bg);  color: #A94F4F; }
.b-netral { background: var(--latar);     color: var(--teks-lembut); border: 1px solid var(--garis); }
.b-pkp    { background: var(--biru-muda); color: var(--biru-tua); }
.b-nonpkp { background: var(--mint-muda); color: #3E8377; }
.b-info   { background: var(--biru-muda); color: var(--biru-tua); }

/* ---------------------------------------------------------------
   Pemberitahuan
   --------------------------------------------------------------- */
.alert {
  padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 14px;
  font-size: 13.3px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: var(--sukses-bg); border-color: #BFE3CD; color: #2F6B50; }
.alert-danger  { background: var(--gagal-bg);  border-color: #F0C9C9; color: #9E4646; }
.alert-warning { background: var(--tunda-bg);  border-color: #F5DFB0; color: #8A5D0C; }
.alert-info    { background: var(--biru-muda); border-color: #C9DDF2; color: var(--biru-tua); }

.hint-box {
  background: var(--biru-muda); border: 1px solid #C9DDF2; color: var(--biru-tua);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12.3px; line-height: 1.5;
}
.hint-box b { color: var(--biru-tua); }

/* ---------------------------------------------------------------
   Paginasi
   --------------------------------------------------------------- */
.pagination { display: flex; gap: 5px; padding: 14px 18px; flex-wrap: wrap; align-items: center; }
.pg {
  min-width: 33px; height: 33px; padding: 0 9px; border-radius: 8px;
  border: 1px solid var(--garis); background: var(--putih); color: var(--teks);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.pg:hover { background: var(--latar); text-decoration: none; }
.pg.active { background: var(--biru); border-color: var(--biru); color: #fff; }
.pg.disabled { opacity: .4; pointer-events: none; }
.pg.dots { border: 0; background: none; }

/* ---------------------------------------------------------------
   Baris item transaksi (combobox barang)
   --------------------------------------------------------------- */
.item-rows { width: 100%; border-collapse: collapse; }
.item-rows th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--teks-lembut); font-weight: 700; padding: 0 8px 7px; white-space: nowrap;
}
.item-rows td { padding: 4px 8px 4px 0; vertical-align: top; }
.item-rows td:first-child { padding-left: 0; }
.item-rows input { font-size: 13.2px; }

.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 60;
  background: var(--putih); border: 1px solid var(--garis); border-radius: var(--radius-sm);
  box-shadow: var(--bayang-kuat); max-height: 246px; overflow-y: auto; display: none;
}
.combo-list.open { display: block; }
.combo-list .opt { padding: 8px 11px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--garis); }
.combo-list .opt:last-child { border-bottom: 0; }
.combo-list .opt:hover, .combo-list .opt.sel { background: var(--biru-muda); }
.combo-list .opt .n { font-weight: 600; }
.combo-list .opt .m { font-size: 11.5px; color: var(--teks-lembut); }
.combo-list .opt.baru { color: var(--biru-tua); font-weight: 700; }
.combo-list .kosong { padding: 10px 11px; color: var(--teks-lembut); font-size: 12.5px; }

.warn-mirip {
  font-size: 11.5px; color: #96660E; background: var(--tunda-bg);
  border: 1px solid #F5DFB0; border-radius: 7px; padding: 5px 8px; margin-top: 4px; display: none;
}
.warn-mirip.show { display: block; }

/* ---------------------------------------------------------------
   Modal
   --------------------------------------------------------------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(61,71,89,.42);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--putih); border-radius: var(--radius); width: 100%; max-width: 470px;
  box-shadow: var(--bayang-kuat); max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 16px 19px; border-bottom: 1px solid var(--garis); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 15.5px; flex: 1; }
.modal-body { padding: 19px; }
.modal-foot { padding: 14px 19px; border-top: 1px solid var(--garis); display: flex; gap: 9px; justify-content: flex-end; }
.x-close { background: none; border: 0; font-size: 21px; line-height: 1; cursor: pointer; color: var(--teks-lembut); padding: 0 4px; }

/* daftar tukang print di modal cetak */
.print-list { display: flex; flex-direction: column; gap: 8px; }
.print-opt {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  border: 1px solid var(--garis); border-radius: var(--radius-sm); cursor: pointer;
  background: var(--putih); text-align: left; width: 100%; font-family: inherit; color: var(--teks);
}
.print-opt:hover { border-color: var(--biru); background: var(--biru-muda); text-decoration: none; }
.print-opt .pn { font-weight: 700; font-size: 13.4px; }
.print-opt .pw { font-size: 12px; color: var(--teks-lembut); }
.print-opt .wa {
  margin-left: auto; background: var(--mint-muda); color: #3E8377;
  padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
}

/* ---------------------------------------------------------------
   Halaman login
   --------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 22px;
  background: linear-gradient(160deg, var(--biru-muda) 0%, var(--latar) 55%, var(--mint-muda) 100%);
}
.login-card {
  background: var(--putih); border: 1px solid var(--garis); border-radius: 16px;
  padding: 32px 30px; width: 100%; max-width: 396px; box-shadow: var(--bayang-kuat);
}
.login-card .mark {
  width: 46px; height: 46px; border-radius: 13px; margin-bottom: 15px;
  background: linear-gradient(135deg, var(--biru), var(--mint));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 19px;
}
.login-card h1 { font-size: 19px; margin: 0 0 5px; }
.login-card .sub { color: var(--teks-lembut); font-size: 13px; margin: 0 0 22px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 11.5px; color: var(--teks-lembut); }

/* ---------------------------------------------------------------
   Kartu stok / dashboard tambahan
   --------------------------------------------------------------- */
.chart-box { position: relative; height: 260px; }
.chart-box.pendek { height: 210px; }

.list-ringkas { display: flex; flex-direction: column; }
.list-ringkas .row {
  display: flex; align-items: center; gap: 11px; padding: 9px 0;
  border-bottom: 1px solid var(--garis); font-size: 13px;
}
.list-ringkas .row:last-child { border-bottom: 0; }
.list-ringkas .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-ringkas .vl { font-weight: 700; font-variant-numeric: tabular-nums; }

.rail { display: flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }

/* ringkasan dampak sebelum simpan (retur) */
.dampak {
  background: var(--mint-muda); border: 1px solid #C4E6DE; border-radius: var(--radius-sm);
  padding: 13px 15px; font-size: 13px;
}
.dampak h4 { margin: 0 0 8px; font-size: 13.5px; color: #3E8377; }
.dampak .baris { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.dampak .baris b { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------
   Responsif
   --------------------------------------------------------------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .g3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--bayang-kuat); }
  .burger { display: inline-flex; }
  .backdrop { position: fixed; inset: 0; background: rgba(61,71,89,.35); z-index: 35; display: none; }
  .backdrop.open { display: block; }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .content { padding: 15px; }
  .topbar { padding: 10px 14px; }
  .topbar .uinfo { display: none; }
  .card-body { padding: 14px; }
  table.tbl th, table.tbl td { padding: 9px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------
   Cetak (preview invoice di layar)
   --------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .no-print, .backdrop { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
