/* ============================================================
   ZR Kasir POS — Tema (PRD §7)
   Utama: Indigo #3B4CCA | Sukses: Emerald #10B981
   Peringatan: Amber #F59E0B | Bahaya: Rose #EF4444
   ============================================================ */

:root {
  --primary: #3B4CCA;
  --primary-dark: #2F3DA8;
  --primary-soft: #EEF1FE;
  --success: #10B981;
  --success-soft: #E7F8F1;
  --warning: #F59E0B;
  --warning-soft: #FEF4E2;
  --danger: #EF4444;
  --danger-soft: #FDEAEA;

  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, .12);

  --sidebar-w: 240px;
  --font: 'Inter', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

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

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

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform .2s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  font-weight: 700; font-size: 18px;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .bi { font-size: 24px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.nav-section {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 12px 10px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s ease, color .15s ease;
}
.nav-link .bi { font-size: 18px; width: 22px; text-align: center; color: var(--text-muted); }
.nav-link:hover { background: var(--primary-soft); text-decoration: none; color: var(--primary); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link.active .bi { color: var(--primary); }

.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
  background: var(--bg);
}
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-chip .meta { min-width: 0; }
.user-chip .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ---------- Navigasi mobile ---------- */
/* Area gelap di belakang sidebar yang terbuka */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 35;
}
.nav-backdrop.show { opacity: 1; pointer-events: auto; }

/* Sheet akun: profil + logout untuk layar kecil */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 1040;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.account-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 520px;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .22s ease;
  z-index: 1050;
}
.account-sheet.show { transform: none; }

.sheet-grip {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 4px auto 14px;
}
.sheet-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.sheet-user .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}
.sheet-user .meta { min-width: 0; }
.sheet-user .name { font-weight: 700; font-size: 15px; }
.sheet-user .role { font-size: 12px; color: var(--text-muted); }

.sheet-links { display: flex; flex-direction: column; }
.sheet-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
}
.sheet-link:hover { background: var(--bg); text-decoration: none; color: var(--primary); }
.sheet-link .bi { font-size: 18px; width: 22px; text-align: center; color: var(--text-muted); }
/* Tombol pintasan di sheet tampil sama seperti tautan. */
button.sheet-link {
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
button.sheet-link:hover { color: var(--primary); }
button.sheet-link[aria-pressed="true"] { color: var(--primary); }
button.sheet-link[aria-pressed="true"] .bi { color: var(--primary); }
.sheet-link:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
  display: flex; align-items: center; gap: 14px;
}
.topbar-title { font-size: 18px; font-weight: 700; margin: 0; }
.topbar-spacer { flex: 1; }

.content { padding: 22px; flex: 1; }

/* ---------- Komponen ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
}
.card-body { padding: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: filter .15s ease, background .15s ease, transform .05s ease;
  font-family: var(--font);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0C9E6B; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 15px; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }

.table-responsive { overflow-x: auto; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.table tbody tr:hover { background: #FAFBFD; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-success { background: var(--success-soft); color: #0B7A55; }
.badge-warning { background: var(--warning-soft); color: #92600A; }
.badge-danger  { background: var(--danger-soft); color: #B91C1C; }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge-secondary { background: #EEF2F7; color: var(--text-muted); }
.badge-dapur   { background: #EFE6DD; color: #8B5E34; }

.form-control, .form-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  min-height: 40px;
}
.form-control:focus, .form-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 5px; display: block; }
.form-text { font-size: 12px; color: var(--text-muted); }

.input-group { display: flex; gap: 8px; }
.input-group .form-control { flex: 1; }

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); border-color: #BEEAD9; color: #0B5D43; }
.alert-danger  { background: var(--danger-soft); border-color: #F6C9C9; color: #8F1D1D; }
.alert-warning { background: var(--warning-soft); border-color: #F6E3BC; color: #7A4E08; }
.alert-info    { background: var(--primary-soft); border-color: #D5DCFA; color: var(--primary-dark); }

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
}
.empty-state .bi { font-size: 44px; margin-bottom: 10px; opacity: .5; }
.empty-state p { margin: 6px 0 0; }

.text-muted { color: var(--text-muted); }
.text-success { color: #0B7A55; }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* Stat cards (dashboard) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card { padding: 16px 18px; display: flex; align-items: flex-start; gap: 14px; }
.stat-card .icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-card .value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); }

/* ---------- POS ---------- */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  align-items: start;
}

.pos-search-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.pos-search-bar .form-control { flex: 1; min-width: 180px; font-size: 15px; }

.category-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: all .15s ease;
  position: relative;
  min-height: 132px;
  display: flex;
  flex-direction: column;
}
.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.product-card .p-name { font-weight: 600; font-size: 13.5px; margin-top: 6px; line-height: 1.3; }
.product-card .p-price { font-weight: 700; color: var(--primary); margin-top: auto; padding-top: 8px; font-size: 14.5px; }
.product-card .p-stock { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.product-card.out-of-stock { opacity: .5; cursor: not-allowed; }
.product-card .p-thumb {
  width: 46px; height: 46px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.product-card .p-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }

/* Keranjang */
.cart-panel { position: sticky; top: 76px; }
.cart-items { max-height: 46vh; overflow-y: auto; }
.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item .ci-info { flex: 1; min-width: 0; }
.cart-item .ci-name { font-weight: 600; font-size: 13.5px; }
.cart-item .ci-price { font-size: 12px; color: var(--text-muted); }
/* Ukuran input diskon dicatat di sini, bukan sebagai inline style, supaya bisa
   disesuaikan per ukuran layar. */
.cart-item .ci-disc-wrap { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cart-item .ci-disc {
  display: inline-block;
  width: 86px;
  padding: 2px 6px;
  min-height: 26px;
  font-size: 12px;
  text-align: right;
}
.cart-item .qty-ctrl { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.cart-item .ci-subtotal { width: 82px; text-align: right; font-weight: 600; font-size: 13.5px; }

/* Kepala & aksi keranjang */
.cart-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
}
.cart-head .form-control { flex: 1; min-width: 0; padding: 7px 10px; min-height: 36px; font-size: 13px; }
.cart-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  flex-wrap: wrap;
}
.cart-actions .btn-pay { flex: 1 1 160px; }

/* Floating action button keranjang & backdrop (mobile) — default tersembunyi */
.cart-fab,
.cart-backdrop { display: none; }
.cart-handle { display: none; }

.cart-totals { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.cart-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13.5px; }
.cart-row.grand { font-size: 17px; font-weight: 700; padding-top: 8px; }

.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.pay-method {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 9px 4px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all .15s ease;
}
.pay-method .bi { display: block; font-size: 18px; margin-bottom: 3px; }
.pay-method.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-cash button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.quick-cash button:hover { border-color: var(--primary); color: var(--primary); }

/* Kartu produk (pc-* dipakai view POS & render JS) */
.product-card .pc-img {
  width: 100%; height: 64px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; overflow: hidden;
}
.product-card .pc-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card .pc-name {
  font-weight: 600; font-size: 13.5px; line-height: 1.3;
  margin-top: 8px; min-height: 35px;
  display: flex; align-items: center; justify-content: center;
}
.product-card .pc-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.product-card .pc-price { font-weight: 700; color: var(--primary); font-size: 14px; }
.product-card .pc-stock { font-size: 11px; color: var(--text-muted); }

/* Baris total keranjang (ct-* dipakai view POS) */
.ct-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13.5px; gap: 10px; }
.ct-row.ct-total { font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.ct-discount { display: flex; align-items: center; gap: 8px; }
.ct-discount a { font-size: 12px; font-weight: 600; }

/* ---------- Status online/offline ---------- */
.net-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.net-indicator .dot { width: 8px; height: 8px; border-radius: 50%; }
.net-indicator.online { background: var(--success-soft); color: #0B7A55; }
.net-indicator.online .dot { background: var(--success); }
.net-indicator.offline { background: var(--warning-soft); color: #92600A; }
.net-indicator.offline .dot { background: var(--warning); }

/* ---------- Tombol install PWA ---------- */
.install-btn { display: none; }

/* ---------- Mode tampilan (HP / Desktop) ---------- */
@media (max-width: 767.98px) {
  .view-toggle-btn .btn-label { display: none; }
  .view-toggle-btn .bi { margin-right: 0; }
}

/* ---------- Receipt (thermal) ---------- */
.receipt-wrap {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  padding: 22px 18px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.45;
}
.receipt-wrap h2 { font-size: 16px; text-align: center; margin: 0 0 2px; }
.receipt-wrap .r-center { text-align: center; }
.receipt-wrap hr { border: none; border-top: 1px dashed #94A3B8; margin: 10px 0; }
.receipt-wrap table { width: 100%; border-collapse: collapse; }
.receipt-wrap td { padding: 2px 0; vertical-align: top; }
.receipt-wrap .r-right { text-align: right; }

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav { display: none; }

/* ---------- Modal PIN ---------- */
.pin-modal .pin-dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
.pin-modal .pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border);
}
.pin-modal .pin-dot.filled { background: var(--primary); border-color: var(--primary); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 18px; right: 18px;
  z-index: 1050;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1E293B; color: #fff;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s ease;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
  .pos-layout { grid-template-columns: 1fr 340px; }
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }

  /* Sidebar terbuka harus menutupi navigasi bawah & tombol keranjang,
     kalau tidak footer sidebar (tombol "Keluar") tidak bisa diketuk. */
  body.nav-open .sidebar { z-index: 1060; }
  body.nav-open .bottom-nav,
  body.nav-open .cart-fab { display: none !important; }
}

/* Tablet: keranjang tetap inline tapi lebih sempit */
@media (min-width: 768px) and (max-width: 991.98px) {
  .pos-layout { grid-template-columns: 1fr 330px; gap: 14px; }
  .cart-items { max-height: 44vh; }
}

@media (max-width: 767.98px) {
  .content { padding: 14px; padding-bottom: 86px; }
  .topbar { padding: 10px 14px; gap: 8px; }
  /* Judul dipotong dengan elipsis, bukan mendorong baris keluar layar. */
  .topbar-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
  }
  .topbar .net-indicator { display: none; }
  .topbar .badge { font-size: 11px; white-space: nowrap; }

  /* Tabel menjadi kartu bertumpuk (dikendalikan app.js: kelas .table-cards
     + atribut data-label yang diisi otomatis dari judul kolom). */
  .table-wrap, .table-responsive { overflow-x: visible; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { display: none; }
  .table-cards tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    margin-bottom: 10px;
    padding: 4px 0;
  }
  .table-cards tr:last-child { margin-bottom: 0; }
  .table-cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 14px;
    border-bottom: 1px dashed var(--border);
    white-space: normal;
    text-align: right;
    word-break: break-word;
  }
  .table-cards td:last-child { border-bottom: 0; }
  .table-cards td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 46%;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .table-cards td:empty, .table-cards td[data-label='']::before { display: none; }
  .table-cards td .btn { min-height: 34px; }
  .table-cards .text-end { text-align: right; }

  .pos-layout { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  .product-card { min-height: 118px; }

  /* Keranjang: pop-up modal (centered) */
  body.cart-open { overflow: hidden; }
  .cart-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    z-index: 1060;
    width: min(94vw, 460px);
    max-height: 86vh;
    transform: translate(-50%, -46%) scale(.96);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .2s ease;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
    overflow: hidden;
  }
  .cart-panel.cart-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  .cart-panel .cart-head {
    padding: 12px 14px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  .cart-panel .cart-items { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; padding: 0 14px; }

  /* Item keranjang (HP): tiga baris yang lurus. Sebelumnya subtotal melayang
     di tengah kolom kanan, input diskon dijeploskan sebaris dengan harga, dan
     tombol hapus menempel di tombol “+”, jadi satu item 103px dan 4 item saja
     sudah tidak muat di popup selebar 367px. */
  .cart-panel .cart-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name  total"
      "price qty";
    gap: 4px 10px;
    align-items: center;
    padding: 8px 0;
  }
  .cart-panel .cart-item .ci-info { display: contents; }
  .cart-panel .cart-item .ci-name {
    grid-area: name;
    font-size: 13.5px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .cart-panel .cart-item .ci-price {
    grid-area: price;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 12px;
    min-width: 0;
  }
  .cart-panel .cart-item .ci-disc { width: 62px; min-height: 26px; font-size: 11.5px; padding: 2px 5px; }
  /* Di popup HP kolom kiri sempit, teks “· diskon” disembunyikan agar input
     tetap satu baris bersama harga; labelnya pindah ke atribut title. */
  .cart-panel .cart-item .ci-disc-label { display: none; }
  .cart-panel .cart-item .qty-ctrl { grid-area: qty; gap: 7px; }
  .cart-panel .cart-item .qty-btn { width: 30px; height: 30px; }
  .cart-panel .cart-item .ci-subtotal {
    grid-area: total;
    width: auto;
    align-self: start;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
  }

  /* Kartu stok (HP): lima kolom diringkas jadi tiga baris. Sebelumnya tiap
     kolom jadi satu baris penuh, jadi satu produk 208px — hanya tiga produk
     yang muat satu layar. */
  .table-cards.table-stock tr,
  .table-cards.table-stock-log tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 12px;
    align-items: center;
    padding: 10px 0;
  }
  .table-cards.table-stock td,
  .table-cards.table-stock-log td {
    padding: 0 14px;
    border-bottom: 0;
    align-items: center;
    gap: 6px;
  }
  /* Label kolom tidak boleh terlipat: kolom Stok/Min hanya ~96px sehingga
     “STOK” dengan max-width 46% membungkus dua baris dan membuat kartu 12px
     lebih tinggi dari yang perlu. */
  .table-cards.table-stock td::before,
  .table-cards.table-stock-log td::before { max-width: none; white-space: nowrap; }
  .table-cards.table-stock td[data-label='Produk'] { grid-area: 1 / 1; display: block; font-weight: 600; }
  .table-cards.table-stock td[data-label='Stok'] { grid-area: 1 / 2; justify-content: flex-end; }
  .table-cards.table-stock td[data-label='SKU'] { grid-area: 2 / 1; justify-content: flex-start; font-size: 12.5px; }
  .table-cards.table-stock td[data-label='Min'] { grid-area: 2 / 2; justify-content: flex-end; font-size: 12.5px; }
  .table-cards.table-stock td[data-label='Aksi'] { grid-area: 3 / 1 / 4 / 3; justify-content: flex-start; padding-top: 4px; }
  .table-cards.table-stock td[data-label='Aksi']::before { content: none; }

  .table-cards.table-stock-log td[data-label='Waktu'] { grid-area: 1 / 1; justify-content: flex-start; font-size: 12.5px; }
  .table-cards.table-stock-log td[data-label='Jenis'] { grid-area: 1 / 2; justify-content: flex-end; }
  .table-cards.table-stock-log td[data-label='Produk'] { grid-area: 2 / 1 / 3 / 3; display: block; font-weight: 600; }
  .table-cards.table-stock-log td[data-label='Qty'] { grid-area: 3 / 1; justify-content: flex-start; }
  .table-cards.table-stock-log td[data-label='Oleh'] { grid-area: 3 / 2; justify-content: flex-end; }
  .table-cards.table-stock-log td[data-label='Catatan'] { grid-area: 4 / 1 / 5 / 3; display: block; font-size: 12.5px; }
  .cart-panel .cart-totals { padding: 10px 16px 0; flex-shrink: 0; }
  .cart-panel .cart-actions { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); flex-shrink: 0; }

  /* FAB keranjang */
  .cart-fab {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 60;
    align-items: center;
    gap: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 13px 16px;
    box-shadow: var(--shadow-lg);
    font-family: var(--font);
    font-size: 15px;
    cursor: pointer;
    transition: transform .15s ease, opacity .2s ease;
  }
  .cart-fab:active { transform: scale(.98); }
  .cart-fab.open { opacity: 0; pointer-events: none; }
  .cart-fab .cf-badge { position: relative; display: inline-flex; font-size: 20px; line-height: 1; }
  .cart-fab .cf-count {
    position: absolute;
    top: -8px;
    right: -10px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .cart-fab .cf-total { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
  .cart-fab .cf-toggle { font-size: 18px; transition: transform .2s ease; }

  /* Backdrop pop-up keranjang */
  .cart-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 1055;
  }
  .cart-backdrop.show { opacity: 1; pointer-events: auto; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1;
    text-align: center;
    font-size: 10.5px;
    color: var(--text-muted);
    padding: 4px 0;
  }
  .bottom-nav button {
    background: none;
    border: 0;
    font: inherit;
    font-size: 10.5px;
    color: var(--text-muted);
    cursor: pointer;
  }
  .bottom-nav a .bi, .bottom-nav button .bi { display: block; font-size: 19px; margin-bottom: 1px; }
  .bottom-nav a.active, .bottom-nav button.active { color: var(--primary); font-weight: 600; }
  .bottom-nav button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 6px; }

  /* Cegah halaman ikut ter-scroll saat menu/sheet terbuka */
  body.nav-open, body.sheet-open { overflow: hidden; }
}

/* =====================================================================
   Tampilan HP: cegah zoom (cubit-zoom & ketuk-ganda)
   ===================================================================== */
html, body {
  /* `manipulation` mematikan zoom ketuk-ganda tanpa mematikan scroll satu jari. */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, a, input, select, textarea, label, .btn, .product-card, .nav-link, td, th {
  touch-action: manipulation;
}
/* Saat aktif, app.js mengunci gesture pinch-zoom (diperlukan untuk iOS Safari
   yang mengabaikan user-scalable=no). */
html.no-zoom, html.no-zoom body {
  touch-action: manipulation;
}

/* =====================================================================
   Mode Desktop di HP — shortcut ke tampilan penuh untuk PWA
   ===================================================================== */
.view-toggle-btn { white-space: nowrap; }
.view-toggle-btn .bi { margin-right: 4px; }

/* Layar kecil + mode desktop: tata letak penuh seperti di laptop
   (tabel kembali ke bentuk tabel penuh) TANPA membuat halaman melebar —
   sidebar jadi laci yang bisa dibuka, tabel lebar digulir di dalam wadahnya. */
@media (max-width: 991.98px) {
  html[data-view="desktop"] .sidebar {
    transform: none;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1060;
    width: min(78vw, var(--sidebar-w));
    box-shadow: var(--shadow-lg);
  }
  html[data-view="desktop"] .main { margin-left: 0; }
  html[data-view="desktop"] .bottom-nav { display: none !important; }
  /* Di mode desktop laci sidebar bisa ditutup lewat tombol hamburger. */
  html[data-view="desktop"] body.nav-open .sidebar { transform: translateX(-100%); }
  html[data-view="desktop"] body.nav-open .main { margin-left: 0; }
  html[data-view="desktop"] .content { padding-bottom: 20px; }
  /* Tabel kembali menjadi tabel penuh dengan gulir mendatar. */
  html[data-view="desktop"] .table-wrap,
  html[data-view="desktop"] .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  html[data-view="desktop"] .table-cards { display: table; }
  html[data-view="desktop"] .table-cards tbody { display: table-row-group; }
  html[data-view="desktop"] .table-cards tr { display: table-row; width: auto; }
  html[data-view="desktop"] .table-cards td { display: table-cell; width: auto; }
  html[data-view="desktop"] .table-cards thead { display: table-header-group; }
  html[data-view="desktop"] .table-cards tr {
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    margin: 0;
    padding: 0;
  }
  html[data-view="desktop"] .table-cards td {
    display: table-cell;
    text-align: inherit;
    padding: 10px 12px;
    border-bottom: 0;
    white-space: nowrap;
  }
  html[data-view="desktop"] .table-cards td.text-right { text-align: right; }
  html[data-view="desktop"] .table-cards td::before { content: none; }

  /* Jaring pengaman: kartu stok diringkas lewat grid, jadi harus dikembalikan
     penuh bila kelas .table-cards sempat aktif di Mode Desktop. */
  html[data-view="desktop"] .table-cards.table-stock tr,
  html[data-view="desktop"] .table-cards.table-stock-log tr { display: table-row; padding: 0; gap: normal; }
  html[data-view="desktop"] .table-cards.table-stock td,
  html[data-view="desktop"] .table-cards.table-stock-log td { display: table-cell; padding: 0; grid-area: auto; border-bottom: 1px solid var(--border); }
  /* Tabel lebar tetap bisa dibuka lewat gulir mendatar. */
  html[data-view="desktop"] .pos-layout { grid-template-columns: 1fr 300px; }
}

/* BilahMODE desktop tetap terlihat saat sidebar Nutup di HP */
html[data-view="desktop"] .topbar {
  position: sticky;
  z-index: 1030;
}

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print,
  .nav-backdrop, .sheet-backdrop, .account-sheet { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff; }
}
