/* =========================================================
   e-Nota — Gaya UI (mobile-first, monokrom, ultra-minimalis)
   ========================================================= */
:root {
  --ink: #111111;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #f0f0f0;
  --bg: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 12px;
  --header-h: 52px;
  --nav-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: "SF Mono", "Roboto Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button:active { opacity: .7; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------- Header ---------------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h);
  padding: 0 6px;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-btn {
  min-width: 64px; padding: 8px 14px; text-align: left;
  font-size: 15px; color: var(--ink); font-weight: 500;
}
.header-btn.muted { color: var(--muted); }
.header-title {
  font-size: 16px; font-weight: 700; text-align: center; flex: 1;
  text-transform: capitalize;
}
.header-right {
  min-width: 70px; text-align: right; padding-right: 14px;
  font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap;
}

/* ---------------- Main ---------------- */
.main { flex: 1; padding-bottom: var(--nav-h); }
.page { display: none; }
.page.active { display: block; animation: fadeIn .16s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

.page-header { padding: 16px 16px 6px; }
.page-title { font-size: 21px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------------- Bottom nav ---------------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  max-width: 520px; margin: 0 auto;
  display: flex; background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding-top: 8px; color: var(--faint); font-size: 10px; font-weight: 600;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--ink); }
/* ---------------- Nota page ---------------- */
.nota-header-field { padding: 12px 16px 6px; display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.input-field {
  width: 100%; border: none; border-bottom: 1.5px solid var(--line);
  padding: 8px 0; font-size: 16px; background: transparent; border-radius: 0;
}
.input-field:focus { outline: none; border-bottom-color: var(--ink); }
.input-row { display: flex; gap: 10px; }
.input-row .input-field { flex: 1; }

.quick-add { padding: 14px 16px 4px; }
.quick-row { display: flex; gap: 8px; align-items: flex-end; }
.select-field {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: 15px; background: #fff; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23111' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.qty-input { width: 76px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.btn-plus {
  width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: #fff;
  font-size: 21px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.autocomplete-hint { margin-top: 8px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.hint-item { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid var(--line); }
.hint-sub { color: var(--muted); font-size: 12px; }

.cart-section { padding: 12px 16px 4px; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; }
.cart-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-size: 14px; font-weight: 600; }
.cart-line { font-size: 12px; color: var(--muted); }
.cart-right { display: flex; align-items: center; gap: 10px; }
.cart-qty-min, .cart-qty-plus {
  width: 30px; height: 30px; flex: none;
  border: 1.5px solid var(--line); background: #fff;
  color: var(--ink); font-size: 16px; font-weight: 700; line-height: 1;
  border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cart-qty-min:active, .cart-qty-plus:active { background: var(--line); border-color: var(--ink); }
.cart-subtotal { font-size: 14px; font-weight: 700; white-space: nowrap; }
.cart-del { color: var(--faint); font-size: 17px; padding: 4px; }
/* ---------------- Kalkulasi & Pembayaran ---------------- */
.bill { margin: 14px 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.bill-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 14px; }
.bill-row.total { font-size: 19px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.seg {
  display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 10px 0;
}
.seg button { flex: 1; padding: 9px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--ink); color: #fff; }

.cart-actions { display: flex; gap: 8px; padding: 8px 16px 24px; }
.btn {
  flex: 1; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 700; text-align: center;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-outline { border: 1.5px solid var(--ink); color: var(--ink); }
.btn-danger { border: 1.5px solid var(--danger); color: var(--danger); }
.btn-ghost { color: var(--muted); }

.riwayat-title { font-size: 13px; font-weight: 700; color: var(--muted); padding: 16px 16px 4px; }
.nota-card { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.nota-card .kiri b { font-size: 15px; }
.nota-card .kiri span { display: block; font-size: 12px; color: var(--muted); }
.kanan-status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.kanan-status.lunas { background: #dcfce7; color: #166534; }
.kanan-status.belum { background: var(--danger-bg); color: var(--danger); }
/* ---------------- Item page ---------------- */
.list-search { padding: 8px 16px; display: none; }
.list-search.show { display: block; }
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px 10px 38px; font-size: 14px;
}
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }

.list-sub { padding: 10px 16px 4px; font-size: 12px; color: var(--faint); }
.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; text-transform: uppercase; flex-shrink: 0;
}
.item-main { flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 600; }
.badge-danger {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--danger-bg); color: var(--danger);
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.text-muted { color: var(--muted); font-size: 12px; }
.item-price { font-size: 14px; font-weight: 700; white-space: nowrap; }
.footer-note { padding: 14px 16px 30px; font-size: 12px; color: var(--faint); }

.fab {
  position: fixed; right: calc(50% - 240px); bottom: calc(var(--nav-h) + 20px); z-index: 30;
  width: 56px; height: 56px; border-radius: 50%; background: var(--ink); color: #fff;
  font-size: 28px; font-weight: 400; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}
@media (max-width: 520px) { .fab { right: 20px; } }

/* ---------------- Market ---------------- */
.market-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.market-price { font-size: 15px; font-weight: 800; }
.market-harga-jual { font-size: 11px; font-weight: 400; color: var(--faint); margin-left: 2px; }
.market-stok { font-size: 12px; color: var(--faint); }
/* ---------------- Laporan & Setting pages ---------------- */
.row-list { padding: 6px 16px; }
.row-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 500;
}
.row-item .chev { color: var(--faint); font-size: 18px; }

.sub-view { padding: 12px 16px 30px; }
.btn-back { font-size: 14px; color: var(--muted); padding: 6px 0 10px; display: flex; align-items: center; gap: 6px; }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.kpi-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 19px; font-weight: 800; margin-top: 3px; }
.kpi-box.span2 { grid-column: span 2; }

.bar-chart { margin: 14px 0; }
.bar-row { display: flex; flex-direction: column; margin-bottom: 8px; }
.bar-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.bar-track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--ink); border-radius: 99px; }

.table-mini { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0; }
.table-mini th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table-mini td { padding: 8px; border-bottom: 1px solid var(--line); }
.table-mini td:last-child, .table-mini th:last-child { text-align: right; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.form-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px;
}
.form-input:focus { outline: none; border-color: var(--ink); }
textarea.form-input { resize: vertical; min-height: 64px; }

.menu-sub { color: var(--muted); font-size: 12px; margin-top: 14px; padding: 0 16px; font-weight: 600; }
/* ---------------- Modal / Bottom sheet ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 99998;
  background: rgba(17,17,17,.4);
  animation: fadeIn .2s ease;
}
.modal-box {
  position: fixed; left: 50%; bottom: 0; z-index: 99999;
  transform: translateX(-50%);
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.12);
  animation: sheetUp .24s ease;
}
@media (min-width: 521px) {
  .modal-box { bottom: auto; top: 12vh; border-radius: 18px; max-height: 76vh; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
}
@keyframes sheetUp { from { transform: translateX(-50%) translateY(30px); opacity: .6; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px;
}
.modal-title { font-size: 17px; font-weight: 800; }
.modal-close { color: var(--muted); font-size: 22px; padding: 2px 8px; }
.modal-body { padding: 4px 18px 20px; }
.modal-actions { display: flex; gap: 10px; padding: 6px 18px 18px; }
.modal-serif { padding: 16px 18px; }

/* ---------------- Item form ---------------- */
.item-form { padding: 8px 18px 18px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.check-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); margin-top: 6px; }
.check-row label { font-size: 14px; font-weight: 600; }
.switch { position: relative; width: 44px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s;
}
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--ink); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------------- Struk / detil nota ---------------- */
.detil-nota { margin: 8px 16px; border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px 18px; max-width: 380px; margin-left: auto; margin-right: auto; }
.detil-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.detil-row b { font-weight: 700; }
.detil-items { margin: 10px 0; border-top: 1px dashed var(--line); padding-top: 6px; }
.detil-item-line { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 13px; }
.detil-sub { color: var(--muted); font-size: 12px; }
.wa-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }

/* ---------------- Toast ---------------- */
.toast-wrap { position: fixed; top: calc(var(--header-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 500;
  border-radius: 99px; padding: 10px 18px; max-width: 92vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: fadeIn .2s ease;
}
.toast.error { background: var(--danger); }

/* ---------------- Halaman pemasukan/bayar ---------------- */
.detail-note-line, .input-line { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--faint); font-size: 14px; }
.center-text { text-align: center; }

/* ---------------- Percetakan struk thermal ---------------- */
.print-area { position: absolute; left: -9999px; top: 0; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  #app { display: none; }
  .print-area {
    position: static !important; left: 0; top: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px; color: #000; width: 100%;
  }
  .print-area .struk, .struk { width: 78mm; margin: 0 auto; white-space: pre-wrap; }
  .struk-center { text-align: center; }
  .struk-divider { letter-spacing: 0; }
}
.struk-line { white-space: pre; }

/* ---------------- Layar Form Item Baru (Sesuai Desain) ---------------- */
.item-form-screen {
  position: fixed !important;
  top: 0 !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 100% !important;
  max-width: 520px !important;
  height: 100% !important;
  height: 100dvh !important;
  background: #ffffff !important;
  z-index: 9999 !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  box-shadow: 0 0 30px rgba(0,0,0,.25) !important;
  box-sizing: border-box !important;
}
.item-form-screen[hidden] {
  display: none !important;
}

.item-form-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  height: 56px !important;
  background: #000000 !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0 16px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15) !important;
}
.form-header-left {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
}
.item-form-header .btn-back-header {
  background: none !important;
  border: none !important;
  padding: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  color: #ffffff !important;
}
.item-form-header .form-header-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  letter-spacing: 0.3px !important;
}
.item-form-header .btn-save-header {
  width: 32px !important;
  height: 32px !important;
  background: #ffffff !important;
  border-radius: 50% !important;
  border: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  box-shadow: 0 2px 6px rgba(0,0,0,.25) !important;
  transition: transform .15s !important;
}
.item-form-header .btn-save-header:active {
  transform: scale(0.92) !important;
}

.item-type-selector {
  display: flex !important;
  align-items: center !important;
  justify-content: space-around !important;
  padding: 20px 24px 12px !important;
  background: #ffffff !important;
}
.type-radio-label {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  font-size: 15.5px !important;
  font-weight: 600 !important;
  color: #111111 !important;
  cursor: pointer !important;
  user-select: none !important;
  position: relative !important;
}
.type-radio-label input[type="radio"] {
  position: absolute !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}
.type-radio-label .custom-radio {
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  border: 2px solid #555555 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all .15s ease !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}
.type-radio-label .custom-radio::after {
  content: "" !important;
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: #000000 !important;
  transform: scale(0) !important;
  transition: transform .15s ease !important;
}
.type-radio-label input[type="radio"]:checked + .custom-radio {
  border-color: #000000 !important;
  border-width: 2.5px !important;
}
.type-radio-label input[type="radio"]:checked + .custom-radio::after {
  transform: scale(1) !important;
}

.item-form-body {
  padding: 12px 22px 60px !important;
  flex: 1 !important;
  background: #ffffff !important;
}

.input-underline-group {
  margin-bottom: 22px !important;
}
.input-underline-group .input-label {
  display: block !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  color: #737373 !important;
  margin-bottom: 3px !important;
}
.input-with-icon-wrap {
  position: relative !important;
  width: 100% !important;
}
.input-with-icon-wrap .input-icon-btn {
  position: absolute !important;
  right: 0 !important;
  bottom: 6px !important;
  background: none !important;
  border: none !important;
  padding: 4px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #777777 !important;
}
.input-with-icon-wrap .input-icon-btn:hover {
  color: #000000 !important;
}
.input-underline {
  width: 100% !important;
  border: none !important;
  border-bottom: 1.5px solid #d4d4d8 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  font-size: 16px !important;
  color: #111111 !important;
  padding: 6px 0 8px !important;
  font-family: inherit !important;
  box-sizing: border-box !important;
  transition: border-color .2s ease !important;
}
.input-with-icon-wrap .input-underline {
  padding-right: 36px !important;
}
.input-underline:focus {
  border-bottom-color: #000000 !important;
  border-bottom-width: 2px !important;
}
.input-underline::placeholder {
  color: #bbbbbb !important;
  font-size: 14.5px !important;
}

.section-divider-bar {
  height: 12px !important;
  background: #ececec !important;
  margin: 16px -22px 24px -22px !important;
  border: none !important;
}

.input-row-flex {
  display: flex !important;
  gap: 20px !important;
  align-items: flex-start !important;
}
.input-row-flex .col-left {
  flex: 1.6 !important;
}
.input-row-flex .col-right {
  flex: 1 !important;
}

.grosir-toggle-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-bottom: 1.5px solid #d4d4d8 !important;
  padding: 8px 0 10px !important;
  margin-bottom: 22px !important;
  cursor: pointer !important;
  transition: border-color .2s !important;
}
.grosir-toggle-row:hover {
  border-bottom-color: #000000 !important;
}
.grosir-toggle-title {
  font-size: 14.5px !important;
  font-weight: 500 !important;
  color: #737373 !important;
}
.grosir-chevron {
  color: #888888 !important;
  font-size: 20px !important;
  line-height: 1 !important;
  transition: transform .2s !important;
}
.grosir-chevron.open {
  transform: rotate(90deg) !important;
}
.grosir-drawer {
  background: #f9fafb !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  padding: 12px 14px !important;
  margin-top: -12px !important;
  margin-bottom: 22px !important;
}

.image-preview-box {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  margin-top: 8px !important;
  padding: 8px 12px !important;
  background: #f9fafb !important;
  border-radius: 8px !important;
}
.image-preview-box img {
  width: 48px !important;
  height: 48px !important;
  object-fit: cover !important;
  border-radius: 6px !important;
  border: 1px solid #e5e7eb !important;
}
.image-preview-box .btn-remove-img {
  font-size: 12px !important;
  color: var(--danger) !important;
  cursor: pointer !important;
}