/* Akuntan Ikan — tema biru laut, mobile-friendly */
:root {
  --blue: #0e4a6e;
  --blue-dark: #08324a;
  --blue-soft: #e3f0f7;
  --cream: #fdf3d8;
  --gold: #c98a2d;
  --ink: #1c2b33;
  --muted: #6b7d88;
  --line: #d9e4ea;
  --bg: #f2f7fa;
  --card: #ffffff;
  --red: #c0392b;
  --green: #1e7d4f;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 12px; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--blue-dark), var(--blue));
}
.login-card {
  background: #fff;
  width: 100%;
  max-width: 380px;
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 6px 0 4px; color: var(--blue-dark); }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-card form { text-align: left; }
.setup-note {
  background: var(--blue-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--blue-dark);
}

/* ---- Form ---- */
label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
input, select {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* ---- Tombol ---- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.ghost { background: #eef3f6; color: var(--ink); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: #fdecea; color: var(--red); }
.btn.wa { background: #1faa53; color: #fff; text-decoration: none; }
.btn.block { width: 100%; }

/* ---- App shell ---- */
.topbar {
  background: var(--blue-dark);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip {
  background: rgba(255, 255, 255, .15);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
  overflow-x: auto;
  background: var(--bg);
  position: sticky;
  top: 52px;
  z-index: 9;
}
.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.container { max-width: 720px; margin: 0 auto; padding: 6px 14px 40px; }

/* ---- Dashboard ---- */
.hero {
  background: linear-gradient(150deg, var(--blue), var(--blue-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
}
.hero-label { font-size: 13px; opacity: .85; }
.hero-value { font-size: 34px; font-weight: 800; margin: 4px 0 10px; }
.hero-row { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.quick-btn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 4px 10px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.quick-btn span { font-size: 11px; font-weight: 700; color: var(--ink); }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-card span { font-size: 12px; color: var(--muted); }
.stat-card b { font-size: 17px; }
.stat-card.warn b { color: var(--red); }
.stock-list, .op-top { display: flex; flex-direction: column; gap: 8px; }
.stock-row, .op-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stock-row b { font-size: 16px; }

/* ---- Daftar ---- */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.section-head h2 { margin: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.tx-list, .cust-list { display: flex; flex-direction: column; gap: 10px; }
.tx-item, .cust-card, .card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.tx-item .tx-top { display: flex; justify-content: space-between; gap: 10px; }
.tx-item .tx-amount { font-weight: 800; font-size: 16px; }
.tx-item .tx-amount.out { color: var(--red); }
.tx-item .tx-amount.in { color: var(--green); }
.tx-item .tx-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tx-item .tx-actions, .cust-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
}
.badge.warn { background: #fdecea; color: var(--red); }
.badge.ok { background: #e6f4ec; color: var(--green); }
.badge.mid { background: #fdf3d8; color: #8a6d1a; }
.cust-card h3 { margin-bottom: 4px; }
.cust-card .cust-meta { font-size: 13px; color: var(--muted); }
.cust-card .cust-meta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cust-card .cust-meta a:hover { color: var(--primary); }
.cust-card .cust-nums { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; flex-wrap: wrap; }
.card { margin-top: 14px; }
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.user-row:last-child { border-bottom: none; }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 30, 45, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-box {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 16px;
  padding: 20px;
  margin: auto 0;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.op-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.op-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.op-chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--blue-dark);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
/* ---- Ekspor ---- */
.export-card { margin-top: 14px; }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.print-only { display: none; }

/* ---- Nota ---- */
.nota-box { max-width: 560px; }
.nota-sheet h2 { text-align: center; margin: 0 0 4px; }
.nota-head { text-align: center; margin-bottom: 12px; }
.nota-logo { width: 72px; height: auto; display: block; margin: 0 auto 8px; }
.nota-head p { margin: 0; font-size: 13px; color: var(--muted); }
.nota-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.nota-meta-row { display: flex; gap: 8px; align-items: center; }
.nota-meta-row span { min-width: 84px; color: var(--muted); font-size: 13px; }
.nota-meta-row input { margin: 0; padding: 7px 10px; flex: 1; }
.nota-items { width: 100%; border-collapse: collapse; }
.nota-items th, .nota-items td { border: 1px solid var(--line); padding: 6px; text-align: left; font-size: 13px; }
.nota-items td.num { text-align: right; }
.nota-items input, .nota-items select { margin: 0; padding: 6px 8px; font-size: 13px; }
.nota-items .nota-qty { width: 72px; }
.nota-items .nota-price { width: 108px; }
.nota-items .nota-fish { width: 108px; }
.nota-pay { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: flex-end; }
.nota-pay label { margin: 0; }
.nota-remain { font-size: 14px; padding-bottom: 10px; }
.nota-total { text-align: right; font-size: 18px; font-weight: 800; margin-top: 12px; }
.nota-sign { display: flex; justify-content: space-between; margin-top: 26px; font-size: 13px; }
.nota-sign div { text-align: center; min-width: 140px; }
.nota-thanks { text-align: center; margin-top: 16px; font-size: 13px; }
.nota-note { text-align: center; font-size: 12px; color: var(--muted); }

/* ---- Pilihan ukuran kertas nota ---- */
.nota-paper-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.nota-paper-row label { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.nota-paper-row select { margin: 0; padding: 6px 8px; font-size: 13px; width: auto; }
.nota-copies input { margin: 0; }
/* Pratinjau Thermal 80mm di layar: nota ramping selebar kertas thermal */
.nota-sheet.thermal { width: 80mm; max-width: 100%; margin: 0 auto; font-size: 12px; }
.nota-sheet.thermal .nota-logo { width: 40mm; }
.nota-sheet.thermal .nota-items th, .nota-sheet.thermal .nota-items td { padding: 4px; font-size: 12px; }
.nota-sheet.thermal .nota-total { font-size: 15px; }
.nota-sheet.thermal .nota-sign { margin-top: 18px; }
.nota-sheet.thermal .nota-sign div { min-width: 100px; }

/* ---- Cetak / PDF ---- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  #login-view, #app-view, .modal, #toast { display: none !important; }
  .print-only { display: block !important; }
  #print-report h1 { font-size: 20px; margin: 0 0 4px; }
  #print-report h2 { font-size: 14px; margin: 16px 0 6px; }
  #print-report p { margin: 0 0 8px; }
  #print-report table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
  #print-report th, #print-report td { border: 1px solid #999; padding: 5px 7px; text-align: left; }
  #print-report td.num, #print-report th.num { text-align: right; }
  .nota-print h1 { font-size: 20px; }
  .nota-print .nota-logo { width: 72px; height: auto; display: block; margin: 0 auto 6px; }
  .nota-print .nota-total-print { font-size: 15px; margin: 10px 0; }
  .nota-sign-print { display: flex; justify-content: space-between; margin-top: 34px; }
  .nota-sign-print div { text-align: center; min-width: 160px; }
  /* Cetak 2 rangkap: label lembar + page break antar lembar. */
  .nota-copy-label { font-size: 12px; font-weight: 700; text-align: center; margin-bottom: 8px; }
  .nota-page-break { break-after: page; page-break-after: always; }
  /* Nota Thermal 80mm: layout ramping selebar kertas thermal.
     Data sama dengan A4 (nomor, tanggal, pelanggan, item, total, bayar),
     hanya rapat + font lebih kecil. Pilih kertas 80mm di dialog print. */
  .nota-print.thermal80 { width: 80mm; margin: 0 auto; font-size: 11px; }
  .nota-print.thermal80 .nota-logo { width: 40mm; }
  .nota-print.thermal80 h1 { font-size: 14px; }
  .nota-print.thermal80 p { font-size: 11px; margin: 0 0 5px; }
  .nota-print.thermal80 table th, .nota-print.thermal80 table td { padding: 2px 3px; font-size: 11px; word-break: break-word; overflow-wrap: anywhere; }
  .nota-print.thermal80 .nota-total-print { font-size: 13px; margin: 8px 0; }
  .nota-print.thermal80 .nota-sign-print { margin-top: 20px; }
  .nota-print.thermal80 .nota-sign-print div { min-width: 110px; font-size: 11px; }
}

@media (max-width: 520px) {
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-value { font-size: 28px; }
}
