/**
 * FBC Printing POS — Styles
 * @version 4.2.0
 * @updated 2026-08-31
 * @sprint Sprint UI/UX + Bahan_Baku Redesign
 * @changelog See GAS/Code.gs for full history
 */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --primary: #0f3d6b;
  --primary-2: #1e5a99;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
}
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Header ---------- */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  color: white;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-short { display: none; }
@media (max-width: 640px) {
  #topbar { padding: 8px 12px; gap: 8px; }
  .brand-long { display: none; }
  .brand-short { display: inline; }
  #shift-badge { display: none; } /* info shift sudah ada di tab Shift */
}
.topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }
.topbar-right button {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}
#user-badge, #shift-badge { font-size: 12px; opacity: 0.9; }
#sync-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.15);
}
#sync-badge.sync-ok { color: #4ade80; background: rgba(74,222,128,0.15); }
#sync-badge.sync-pending { color: #422006; background: #fbbf24; }

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: block; }

/* ---------- Login ---------- */
#view-login.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface);
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  text-align: center;
  width: 340px;
}
.login-card h1 { color: var(--primary); margin-bottom: 6px; }
.login-card .subtitle { color: var(--muted); margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 14px;
  font-size: 22px; text-align: center; letter-spacing: 10px;
  border: 1px solid var(--border); border-radius: 4px; margin-bottom: 12px;
}
.login-card button {
  width: 100%; padding: 12px;
  background: var(--primary); color: white;
  border: none; border-radius: 4px;
  font-size: 16px; cursor: pointer;
}
.login-card button:hover { background: var(--primary-2); }
.hint { color: var(--muted); font-size: 11px; margin-top: 12px; }
.error { color: var(--danger); margin-top: 8px; min-height: 18px; font-size: 13px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 8px;
  overflow-x: auto;
}
.tab {
  padding: 12px 18px;
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; font-size: 14px; color: var(--muted);
  white-space: nowrap;
}
.tab.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; padding: 16px; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}

.riwayat-summary {
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.riwayat-summary .rs-item { display: flex; gap: 6px; align-items: baseline; }
.riwayat-summary .rs-label { color: var(--muted); font-size: 12px; }
.riwayat-summary .rs-value { font-weight: 700; color: var(--primary); font-size: 15px; }

/* ---------- POS grid ---------- */
.pos-grid { display: grid; grid-template-columns: 1fr 400px; gap: 16px; }
@media (max-width: 900px) { .pos-grid { grid-template-columns: 1fr; } }
.item-panel, .cart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
#item-search {
  width: 100%; padding: 10px;
  border: 1px solid var(--border); border-radius: 4px;
  margin-bottom: 10px; font-size: 14px;
}
.item-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  max-height: 65vh; overflow-y: auto;
}
.item-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 10px;
  cursor: pointer; text-align: left; font-size: 13px;
  transition: border-color 0.1s;
}
.item-card:hover { border-color: var(--primary); }
.item-card .name { font-weight: 600; margin-bottom: 4px; }
.item-card .kategori { color: var(--muted); font-size: 11px; }
.item-card .price { color: var(--primary); font-weight: 600; margin-top: 4px; }

/* ---------- Cart ---------- */
.cart-panel h2 { margin-bottom: 10px; font-size: 16px; }
.cart-list {
  max-height: 45vh; overflow-y: auto; margin-bottom: 10px;
  min-height: 60px;
}
/* v4.2 Cart item restructure — header (name + total + delete) + controls di bawah.
   Delete button SELALU inline dengan nama supaya visual anchor jelas.
   Tidak ada .ci-main wrapper, tidak ada grid 1fr auto (dulu bikin overflow di mobile). */
.cart-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item .ci-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cart-item .ci-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cart-item .ci-total {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.cart-item .ci-controls {
  display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.cart-item input {
  padding: 4px;
  border: 1px solid var(--border); border-radius: 3px;
  text-align: right;
}
.cart-item .ci-remove {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.cart-item .ci-remove:hover, .cart-item .ci-remove:focus-visible {
  background: #fef2f2;
  border-color: #fca5a5;
  outline: none;
}
.cart-empty { color: var(--muted); padding: 20px; text-align: center; font-size: 13px; }

.cart-summary {
  margin: 12px 0; padding: 12px;
  background: var(--bg); border-radius: 4px;
}
.cart-summary .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0;
}
.cart-summary .row.total {
  font-size: 18px; font-weight: 700;
  border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px;
}
.cart-summary input {
  width: 110px; padding: 4px;
  border: 1px solid var(--border); border-radius: 3px;
  text-align: right;
}

/* ---------- Buttons ---------- */
button {
  cursor: pointer; padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px; font-size: 14px;
}
button:hover { background: var(--bg); }
button.primary {
  background: var(--primary); color: white;
  border-color: var(--primary);
}
button.primary:hover { background: var(--primary-2); }
button.big { padding: 12px 16px; font-size: 16px; width: 100%; margin-top: 8px; }

/* Cart action row: Bersihkan (secondary outline) + Checkout (primary dominan) */
.cart-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.cart-actions .btn-clear {
  flex: 0 0 auto;
  padding: 12px 14px;
  color: var(--danger);
  background: white;
  border: 1px solid var(--danger);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.cart-actions .btn-clear:hover {
  background: #fef2f2;
}
.cart-actions .btn-checkout {
  flex: 1;
  margin-top: 0 !important;
}
@media (max-width: 480px) {
  .cart-actions .btn-clear-text { display: none; } /* mobile: ikon saja */
  .cart-actions .btn-clear { padding: 12px; }
}

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
.data-table {
  width: 100%; border-collapse: collapse;
  min-width: 640px; /* trigger horizontal scroll di mobile */
}
.data-table th, .data-table td {
  padding: 10px 8px; border-bottom: 1px solid var(--border);
  text-align: left; font-size: 13px;
  white-space: nowrap;
}
.data-table th { background: var(--bg); font-weight: 600; }
.data-table .status-lunas { color: var(--success); font-weight: 600; }
.data-table .status-void { color: var(--danger); font-weight: 600; }

/* ---------- Dashboard ---------- */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; margin: 16px 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 16px;
}
.card h3 {
  color: var(--muted); font-size: 13px;
  margin-bottom: 8px; font-weight: 500;
}
.card > div {
  font-size: 22px; font-weight: 700; color: var(--primary);
}

/* ---------- Shift status ---------- */
#shift-status {
  background: var(--surface); padding: 16px;
  border-radius: 6px; border: 1px solid var(--border);
  margin-bottom: 12px; line-height: 1.6;
}

/* ---------- Form pengeluaran ---------- */
#form-pengeluaran {
  max-width: 420px;
  background: var(--surface); padding: 16px;
  border-radius: 6px; border: 1px solid var(--border);
}
#form-pengeluaran label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
#form-pengeluaran input, #form-pengeluaran select {
  display: block; width: 100%; padding: 8px;
  border: 1px solid var(--border); border-radius: 4px;
  margin-top: 4px; font-size: 14px; color: var(--text);
}

/* ---------- Modal ---------- */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-body {
  background: var(--surface);
  border-radius: 8px; padding: 24px;
  width: min(400px, 92vw);
  max-height: 90vh; overflow-y: auto;
}
.modal-body h2 { margin-bottom: 16px; }
.modal-body label {
  display: block; margin-bottom: 12px;
  font-size: 13px; color: var(--muted);
}
.modal-body input, .modal-body select {
  display: block; width: 100%; padding: 8px;
  border: 1px solid var(--border); border-radius: 4px;
  margin-top: 4px; font-size: 14px; color: var(--text);
}
.modal-body .row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
}
.modal-actions {
  display: flex; gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
/* Pattern: [Batal outline kiri kecil] [Konfirmasi primary dominan kanan] */
.modal-actions .primary {
  flex: 1;
  margin-top: 0 !important;
}
.modal-actions button:not(.primary) {
  flex: 0 0 auto;
  padding: 12px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Payment method panels (QRIS / Transfer) */
.payment-panel {
  background: var(--bg);
  padding: 14px;
  border-radius: 6px;
  margin-top: 8px;
  border: 1px solid var(--border);
}
.payment-title {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 14px;
}
.payment-note {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.bank-info {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  padding: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 8px 0;
  word-break: break-all;
  white-space: pre-line;
  text-align: center;
}
.btn-copy {
  width: 100%;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.btn-copy:hover { background: var(--bg); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: white;
  padding: 12px 20px; border-radius: 6px;
  z-index: 200; font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- Struk 58mm ---------- */
.struk-58mm {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 11px; line-height: 1.3;
  width: 58mm; padding: 4mm;
  background: white; color: black;
  margin: 0 auto;
}
.struk-58mm h3 { text-align: center; font-size: 13px; margin-bottom: 4px; }
.struk-58mm .center { text-align: center; }
.struk-58mm .sep {
  border-top: 1px dashed #000;
  margin: 4px 0;
}
.struk-58mm table { width: 100%; border-collapse: collapse; font-size: 11px; }
.struk-58mm td { padding: 1px 0; vertical-align: top; }
.struk-58mm td.right { text-align: right; }
.struk-58mm .total-row td { font-weight: bold; border-top: 1px solid #000; padding-top: 2px; }

/* ---------- Setup View (boot) ---------- */
#view-setup.active {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.setup-card {
  background: var(--surface);
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  width: 100%; max-width: 520px;
}
.setup-card h1 {
  color: var(--primary);
  margin-bottom: 6px;
  text-align: center;
  font-size: 24px;
}
.setup-card .subtitle {
  color: var(--muted);
  text-align: center;
  margin-bottom: 20px;
}
.setup-card p { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.setup-card label {
  display: block;
  margin: 16px 0 4px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.setup-card input[type="url"], .setup-card input[type="text"] {
  width: 100%; padding: 10px;
  border: 1px solid var(--border); border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: 12px;
  background: var(--bg);
}
.setup-actions {
  display: flex; gap: 8px; margin-top: 16px;
}
.setup-actions button { flex: 1; padding: 10px; }
.setup-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  min-height: 20px;
  background: var(--bg);
  color: var(--muted);
}
.setup-status.ok {
  background: #dcfce7; color: #14532d;
  border: 1px solid #86efac;
}
.setup-status.err {
  background: #fef2f2; color: #7f1d1d;
  border: 1px solid #fca5a5;
}
.setup-card .hint { font-size: 11px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ---------- Setup Tab (Owner) ---------- */
.setup-owner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.setup-owner-grid .card h3 {
  margin-bottom: 12px; font-size: 14px;
}
.setup-owner-grid .card input[type="url"] {
  width: 100%; padding: 8px;
  border: 1px solid var(--border); border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: 12px;
  margin-bottom: 10px;
}
.setup-owner-grid .card p.info-line {
  font-size: 12px; color: var(--muted);
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.setup-owner-grid .btn-danger {
  background: var(--danger) !important;
  color: white !important;
  border-color: var(--danger) !important;
}

/* ---------- Print (58mm thermal) ---------- */
@media print {
  body * { visibility: hidden; }
  #modal-struk, #modal-struk * { visibility: visible; }
  #modal-struk {
    position: static;
    background: none;
    display: block;
    height: auto;
  }
  #modal-struk .modal-body {
    box-shadow: none; padding: 0;
    max-height: none; overflow: visible;
    min-width: 0;
  }
  #modal-struk .modal-actions { display: none; }
  .struk-58mm { width: 58mm; padding: 0; margin: 0; }
  @page { size: 58mm auto; margin: 0; }
}


/* Sprint 2 — Reorder alert + stok status */
.reorder-alert {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.reorder-alert b { color: #dc2626; }
.status-order { color: #dc2626; font-weight: 700; }
.status-kritis { color: #d97706; font-weight: 600; }
.status-aman { color: #16a34a; }
tr.row-order td { background: #fef2f2; }
tr.row-kritis td { background: #fefce8; }



/* ============ Sprint 3 UX ============ */

/* Cart qty +/- group (tap-friendly 44px). ci-main removed di v4.2 restructure. */
.cart-item .ci-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qty-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.qty-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: #f1f5f9;
  color: var(--primary, #0f3d6b);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.1s;
}
.qty-btn:hover, .qty-btn:focus-visible { background: #e2e8f0; outline: none; }
.qty-btn:active { background: #cbd5e1; }
.qty-input {
  width: 52px;
  min-height: 36px;
  border: 0;
  border-left: 1px solid var(--border, #cbd5e1);
  border-right: 1px solid var(--border, #cbd5e1);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  padding: 0 4px;
  background: transparent;
}
.qty-input:focus { outline: 2px solid var(--primary, #0f3d6b); outline-offset: -2px; }
.ci-price, .ci-disc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
}
.ci-price input, .ci-disc input {
  width: 72px;
  min-height: 32px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 4px;
  padding: 4px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.ci-disc input { width: 56px; }
.ci-remove {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #dc2626;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}
.ci-remove:hover, .ci-remove:focus-visible {
  background: #fef2f2; border-color: #fca5a5; outline: none;
}
.cart-warn {
  color: #dc2626;
  font-size: 12px;
  padding: 4px 8px;
  background: #fef2f2;
  border-radius: 4px;
  margin: 4px 0;
}

/* Quick-cash pills */
.cash-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}
.cash-pill {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border, #cbd5e1);
  background: #f8fafc;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary, #0f3d6b);
  cursor: pointer;
  transition: all 0.1s;
  touch-action: manipulation;
}
.cash-pill:hover, .cash-pill:focus-visible {
  background: var(--primary, #0f3d6b);
  color: white;
  border-color: var(--primary, #0f3d6b);
  outline: none;
}

/* Chip filter kategori */
.kategori-wrap {
  position: relative;
  margin-bottom: 6px;
}
.kategori-wrap::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 10px;
  width: 28px;
  background: linear-gradient(to right, rgba(255,255,255,0), var(--surface, #ffffff));
  pointer-events: none;
  border-radius: 0 6px 6px 0;
}
.kategori-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 24px 10px 2px;
  scrollbar-width: thin;
  margin-bottom: 6px;
  scroll-behavior: smooth;
}
.kategori-strip::-webkit-scrollbar { height: 4px; }
.kategori-strip::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.kat-chip {
  padding: 6px 12px;
  border: 1px solid var(--border, #cbd5e1);
  background: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s;
  touch-action: manipulation;
  min-height: 32px;
}
.kat-chip:hover { border-color: var(--primary, #0f3d6b); color: var(--primary, #0f3d6b); }
.kat-chip.active {
  background: var(--primary, #0f3d6b);
  color: white;
  border-color: var(--primary, #0f3d6b);
}

/* Top hari ini section */
.top-today {
  margin: 12px 0;
  padding: 10px 12px;
  background: #fef3c7;
  border-left: 3px solid #d97706;
  border-radius: 0 4px 4px 0;
}
.top-today .tt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #92400e;
  margin-bottom: 6px;
}
.top-today .tt-items {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.top-today .tt-item {
  padding: 4px 10px;
  background: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  cursor: pointer;
  border: 1px solid #fde68a;
}
.top-today .tt-item:hover { background: #fbbf24; color: white; }
.top-today .tt-count { font-weight: 500; opacity: 0.7; margin-left: 4px; }

/* Filter bar generic (Riwayat, Pengeluaran) */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  margin-bottom: 12px;
  align-items: center;
}
.filter-bar label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
}
.filter-bar input, .filter-bar select {
  padding: 5px 8px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 4px;
  font-size: 13px;
  min-height: 32px;
}
.filter-bar .btn-mini {
  padding: 6px 12px;
  min-height: 32px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 4px;
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.filter-bar .btn-mini.primary {
  background: var(--primary, #0f3d6b);
  color: white;
  border-color: var(--primary, #0f3d6b);
}
.summary-bar {
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #065f46;
  line-height: 1.6;
}
.summary-bar b { color: #047857; }

/* Chart canvas */
.chart-card {
  padding: 12px;
  background: white;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  margin: 12px 0;
  overflow-x: auto;
}
.chart-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 8px;
}
#chart-hourly {
  display: block;
  max-width: 100%;
  height: auto;
}

/* SW update banner */
.update-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--primary, #0f3d6b);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 10px;
}
.update-banner button {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: white;
  color: var(--primary, #0f3d6b);
  font-weight: 700;
  cursor: pointer;
  font-size: 12px;
}

/* Pengeluaran history table */
.expense-history {
  margin-top: 20px;
}
.expense-history .edit-btn {
  padding: 4px 10px;
  border: 1px solid var(--border, #cbd5e1);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.expense-history .edit-btn:hover { background: #f1f5f9; }

/* Restok tab dropdown fix (existing) */
.form-help {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

/* v4.2 Diskon toggle group Rp/% */
.discount-input-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}
.discount-mode-btn {
  padding: 4px 10px;
  border: 0;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-width: 36px;
  min-height: 32px;
  transition: background 0.1s, color 0.1s;
  touch-action: manipulation;
}
.discount-mode-btn:hover { background: #e2e8f0; }
.discount-mode-btn.active {
  background: var(--primary);
  color: white;
}
.discount-mode-btn.active:hover { background: var(--primary-2); }
.discount-input-group input {
  border: 0;
  border-left: 1px solid var(--border);
  padding: 4px 8px;
  width: 90px;
  min-height: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: transparent;
}
.discount-input-group input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* ============ Sprint UI/UX Fix 2026-08-31 ============ */

/* Restok form 2-col grid + Opsi C button hierarchy */
#form-restok .form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
#form-restok label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 0;
}
#form-restok input,
#form-restok select {
  display: block;
  width: 100%;
  padding: 10px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
}
#form-restok .restok-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
#form-restok .restok-actions .primary {
  flex: 1;
  padding: 12px 16px;
  min-height: 44px;
  font-weight: 600;
}
#form-restok .restok-actions .btn-secondary {
  flex: 0 0 auto;
  padding: 12px 14px;
  min-height: 44px;
  color: var(--primary);
  background: white;
  border: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
#form-restok .restok-actions .btn-secondary:hover {
  background: var(--bg);
  border-color: var(--primary);
}

/* Kolom Nota table: allow wrap, jangan force nowrap */
.data-table td.col-nota,
.data-table th.col-nota {
  white-space: normal;
  max-width: 260px;
  line-height: 1.4;
}

/* ============ Mobile/Tablet Optimization ============ */

/* Tablet: 768px — tap targets besar + grid density.
   NOTE: .pos-grid stacking dihandle oleh @media 900px (grid-template-columns:1fr).
   Kalau override pos-grid di sini, cart panel akan overflow di viewport ≤768px. */
@media (max-width: 768px) {
  .item-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .dash-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .dash-cards .card { padding: 12px; }
  .dash-cards .card > div { font-size: 18px; }

  /* Tap targets 44px+ untuk touch */
  .qty-btn { min-width: 44px; min-height: 44px; font-size: 20px; }
  .qty-input { min-height: 44px; font-size: 16px; width: 56px; }
  .ci-remove { min-width: 44px; min-height: 44px; font-size: 22px; }
  .cash-pill { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .kat-chip { min-height: 40px; padding: 10px 14px; font-size: 13px; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .btn-mini { min-height: 40px; font-size: 14px; }
  .modal-body input,
  .modal-body select,
  .modal-body button { min-height: 44px; font-size: 15px; padding: 10px 12px; }
  #form-pengeluaran input,
  #form-pengeluaran select { min-height: 44px; padding: 10px; font-size: 15px; }
  .tab { min-height: 48px; padding: 12px 14px; }
  .topbar-right button { min-height: 40px; padding: 8px 14px; }
}

/* Mobile ≤640px: convert 4 tabel ke card list layout */
@media (max-width: 640px) {
  /* Untuk .table-wrap yang punya class card-toggle: hide tabel, show row-cards */
  .table-wrap.card-toggle {
    border: none;
    background: transparent;
    overflow-x: visible;
    padding: 0;
    margin-top: 8px;
  }
  .table-wrap.card-toggle > .data-table {
    display: none;
  }
  .table-wrap.card-toggle > .row-cards {
    display: block;
  }

  /* Restok form 1-col di mobile */
  #form-restok .form-grid-2col {
    grid-template-columns: 1fr;
  }
  #form-restok .restok-actions .btn-secondary {
    flex: 0 0 40%;
  }

  /* Modal action stack vertical di mobile sangat kecil */
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions button {
    width: 100%;
  }

  /* Dashboard cards single col */
  .dash-cards {
    grid-template-columns: 1fr;
  }

  /* Setup owner grid single col */
  .setup-owner-grid {
    grid-template-columns: 1fr;
  }

  /* Chart canvas fit width */
  .chart-card { padding: 8px; }
  #chart-hourly { width: 100%; }

  /* Filter bar labels lebih compact */
  .filter-bar {
    padding: 8px;
    gap: 6px;
  }

  /* v4.2 Cart item mobile: ci-header (name+total+delete) sudah inline, tidak perlu block-below.
     Compact input widths supaya ci-controls muat tanpa wrap paksa. */
  .ci-price input { width: 56px; }
  .ci-disc input { width: 44px; }
  .qty-input { width: 44px; }
  .qty-btn { min-width: 40px; min-height: 40px; }
  /* Cart panel proper width — jangan overflow viewport */
  .cart-panel { min-width: 0; padding: 10px; }
  .cart-summary { min-width: 0; padding: 10px; }
  .cart-summary input { max-width: 100px; }
  /* Reduce panel padding di mobile supaya konten dapat ruang lebih */
  .tab-panel { padding: 12px; }
  .item-panel { padding: 10px; min-width: 0; }
  .filter-bar label {
    flex: 1 1 auto;
    min-width: 45%;
  }

  /* POS grid: sudah stack via 900px breakpoint. Cart di bawah item. */
  .cart-panel {
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  }

  /* Login card padding lebih rapat */
  .login-card { padding: 24px 20px; width: 100%; max-width: 340px; }
}

/* Row-card layout (mobile alternative to data-table) */
.row-cards { display: none; }
.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.row-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.row-card-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  word-break: break-word;
}
.row-card-total {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
}
.row-card-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.row-card-body dt {
  color: var(--muted);
  font-size: 12px;
}
.row-card-body dd {
  color: var(--text);
  word-break: break-word;
}
.row-card-body dd.status-lunas { color: var(--success); font-weight: 600; }
.row-card-body dd.status-void { color: var(--danger); font-weight: 600; }
.row-card-body dd.status-order { color: var(--danger); font-weight: 700; }
.row-card-body dd.status-kritis { color: var(--warning); font-weight: 600; }
.row-card-action {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.row-card-action button {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 13px;
}
.row-card-empty {
  text-align: center;
  padding: 30px 12px;
  color: var(--muted);
  font-size: 13px;
}
