:root {
  --brand: #43a047;
  --brand-dark: #2e7d32;
  --brand-light: #e8f5e9;
  --gold: #f9a825;
  --bg: #f1f5f0;
  --card: #ffffff;
  --text: #263238;
  --muted: #607d8b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar { background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; padding: 12px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.brand { font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.brand .gas-logo { width: 26px; height: auto; flex-shrink: 0; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { color: #c8e6c9; text-decoration: none; font-size: 0.85rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a.logout { color: #ffcdd2; margin-left: auto; }

.container { max-width: 760px; margin: 16px auto; padding: 0 12px; }

.hero { text-align: center; margin: 12px 0 20px; }
.btn-scan {
  display: inline-block; background: var(--brand); color: #fff;
  font-size: 1.25rem; font-weight: 700; padding: 20px 32px;
  border-radius: 16px; text-decoration: none;
  box-shadow: 0 4px 14px rgba(67, 160, 71, 0.35);
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.stat { background: var(--card); border-radius: 14px; padding: 18px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--brand); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.card { background: var(--card); border-radius: 14px; padding: 18px; margin: 16px 0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.hint { color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); font-size: 0.9rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #eceff1; }
.list li:last-child { border-bottom: none; }
.nama { font-weight: 600; }
.meta { color: var(--muted); font-size: 0.85rem; }

#reader { width: 100%; max-width: 340px; margin: 12px auto; border-radius: 12px; overflow: hidden; }
.last-scan { text-align: center; font-size: 0.9rem; color: var(--muted); margin: 4px 0 10px; min-height: 20px; }
.last-scan b { color: var(--text); }
.result { min-height: 26px; margin: 12px 0; padding: 10px 14px; border-radius: 10px; font-size: 0.95rem; }
.result.ok { background: #e8f5e9; color: #1b5e20; }
.result.err { background: #ffebee; color: #b71c1c; }

.sale-form { border: 2px solid var(--brand); border-radius: 14px; padding: 16px; margin: 12px 0; background: var(--brand-light); }
.cust-info { text-align: center; margin-bottom: 12px; }
.cust-name { font-size: 1.3rem; font-weight: 700; color: var(--brand-dark); }
.cust-nik { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.form-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
.form-row label { font-weight: 600; font-size: 0.9rem; }
.form-row input { width: 140px; padding: 10px; border: 1px solid #cfd8dc; border-radius: 10px; font-size: 1rem; text-align: right; }
.total-box { text-align: center; font-size: 1.2rem; font-weight: 700; margin: 12px 0; color: var(--brand-dark); }
.sale-actions { display: flex; gap: 8px; justify-content: center; }

.btn-primary { background: var(--brand); color: #fff; border: none; padding: 12px 18px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.btn-secondary { background: #eceff1; color: var(--text); border: none; padding: 12px 18px; border-radius: 10px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-del { background: #ffebee; border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.btn-edit { background: #e3f2fd; border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.row-actions { white-space: nowrap; }

.form { display: grid; gap: 10px; margin: 14px 0; }
.form input, .form select, .form-inline input { padding: 12px; border: 1px solid #cfd8dc; border-radius: 10px; font-size: 1rem; }
.form select { background: #fff; }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.88rem; }
.table th, .table td { text-align: left; padding: 9px 6px; border-bottom: 1px solid #eceff1; }
.table th { color: var(--muted); font-weight: 600; }
.table code { background: var(--brand-light); padding: 2px 6px; border-radius: 6px; font-size: 0.76rem; }

.hidden { display: none; }
.manual { margin-top: 10px; display: grid; gap: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 420px; display: grid; gap: 10px; }
.modal-box h3 { margin: 0 0 4px; }
.modal-box input { padding: 12px; border: 1px solid #cfd8dc; border-radius: 10px; font-size: 1rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 16px; }
.id-card { border: 2px solid var(--brand); border-radius: 14px; text-align: center; padding: 14px; }
.id-head { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 6px; }
.id-logo .gas-logo { width: 44px; height: auto; flex-shrink: 0; }
.id-toko { font-weight: 700; color: var(--brand-dark); font-size: 0.85rem; line-height: 1.15; }
.id-qr svg { width: 130px; height: 130px; }
.id-name { font-weight: 700; font-size: 1.05rem; margin-top: 6px; }
.id-jenis { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.id-kelas { color: var(--muted); font-size: 0.85rem; }
.id-code { font-family: monospace; font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

/* login */
.login-body { background: linear-gradient(160deg, var(--brand-dark), var(--brand)); }
.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login-card { text-align: center; padding: 30px 22px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.login-logo { margin-bottom: 8px; }
.login-logo .gas-logo { width: 120px; height: auto; }
.login-card h1 { margin: 4px 0; font-size: 1.3rem; color: var(--brand-dark); }
.login-card form { display: grid; gap: 12px; margin-top: 18px; }
.login-card input { padding: 14px; font-size: 1rem; border: 1px solid #cfd8dc; border-radius: 10px; text-align: center; }
.login-error { color: #b71c1c; font-size: 0.9rem; }

/* badge jenis pelanggan */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.badge-rt { background: #e8f5e9; color: #1b5e20; }
.badge-mikro { background: #e3f2fd; color: #0d47a1; }

/* tabel bisa scroll di HP */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.td-nama { font-weight: 600; white-space: nowrap; }

@media print {
  .topbar, .hero, .btn-primary, .btn-secondary, .nav { display: none !important; }
  body { background: #fff; }
  .cards-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .id-card { break-inside: avoid; }
}
