/* ============ Lapak App — mobile first ============ */
:root {
  --green: #10b981;
  --green-d: #059669;
  --green-l: #d1fae5;
  --green-light: #ecfdf5;
  --teal: #0ea5a4;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --danger: #ef4444;
  --amber: #f59e0b;
  --radius: 16px;
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
a { color: var(--green-d); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform .05s, background .15s; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-d); }
.btn-outline { background: #fff; color: var(--green-d); border: 1.5px solid var(--green); }
.btn-ghost { background: #f1f5f9; color: var(--ink); }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1.5px solid #fecaca; }
.btn-block { display: flex; width: 100%; margin-top: 10px; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 16px; font-size: 17px; }

/* ---------- Inputs ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.input, input[type=text], input[type=tel], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--ink); outline: none;
}
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-l); }
.input-lg { font-size: 20px; font-weight: 700; padding: 14px; }
textarea { resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--green); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, var(--green) 0%, var(--teal) 100%); }
.auth-card { background: #fff; border-radius: 24px; padding: 28px 22px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 { margin: 8px 0 2px; font-size: 26px; }
.alert { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }

/* Kontak WhatsApp admin */
.wa-contact { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.wa-info { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 10px; line-height: 1.5; }
.btn-wa { background: #25d366; color: #fff; }
.btn-wa:active { background: #1da851; }

/* Panduan pasang aplikasi */
.ins { margin: 8px 0 4px; padding-left: 22px; }
.ins li { padding: 6px 0; line-height: 1.5; }

/* ---------- App layout ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; box-shadow: var(--shadow); padding-top: env(safe-area-inset-top, 0); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.topbar-title { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 800; color: var(--ink); }
.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; }

/* Install bar (indah & informatif, paling atas) */
.install-bar {
  display: flex; align-items: center; gap: 12px; width: 100%; border: none; cursor: pointer;
  background: linear-gradient(100deg, var(--green) 0%, var(--teal) 100%); color: #fff;
  padding: 12px 16px; text-align: left;
}
.install-icon { font-size: 24px; }
.install-text { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.install-text small { opacity: .9; font-size: 12px; }
.install-cta { background: #fff; color: var(--green-d); font-weight: 800; padding: 8px 16px; border-radius: 20px; font-size: 14px; }
.installed-hint { background: var(--green-light); color: var(--green-d); text-align: center; padding: 8px; font-size: 13px; font-weight: 600; }

.content { flex: 1; padding: 16px; padding-bottom: 96px; }
.page { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h4 { margin: 0 0 6px; font-size: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 12px; }
.section-head h3 { margin: 0; font-size: 18px; }

/* Hero */
.hero-card { background: linear-gradient(135deg, var(--green) 0%, var(--teal) 100%); color: #fff; border-radius: 20px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.hero-label { font-size: 13px; opacity: .9; }
.hero-value { font-size: 32px; font-weight: 800; margin-top: 2px; }
.hero-sub { display: flex; gap: 8px; margin-top: 16px; }
.hero-sub > div { flex: 1; background: rgba(255,255,255,.15); border-radius: 12px; padding: 10px; text-align: center; }
.hero-sub span { display: block; font-size: 20px; font-weight: 800; }
.hero-sub small { font-size: 11px; opacity: .9; }

/* Quick actions */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.quick { background: #fff; border: none; border-radius: 14px; padding: 16px 10px; box-shadow: var(--shadow); font-weight: 700; font-size: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink); }
.quick span { font-size: 26px; }
.quick:active { transform: scale(.97); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.li-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.li-title { font-weight: 700; font-size: 16px; }
.li-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 700; }
.badge-on { background: var(--green-l); color: var(--green-d); }
.badge-off { background: #f1f5f9; color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--green-light); color: var(--green-d); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chip b { color: var(--ink); }

/* qty stepper */
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: none; background: #f8fafc; width: 34px; height: 34px; font-size: 18px; font-weight: 700; cursor: pointer; color: var(--green-d); }
.stepper button:active { background: var(--green-l); }
.stepper .val { min-width: 40px; text-align: center; font-weight: 700; }

.link-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mini-btn { font-size: 12px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.mini-btn.danger { color: var(--danger); border-color: #fecaca; }

/* Stok adder rows */
.stok-row { display: flex; gap: 8px; margin-top: 8px; }
.stok-row .name { flex: 2; }
.stok-row .qty, .stok-row .price { flex: 1; }
.stok-row .rm { flex: 0 0 auto; background: #fef2f2; color: var(--danger); border: none; border-radius: 10px; width: 42px; font-size: 18px; cursor: pointer; }

/* Sales */
.sale-line { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sale-line .sl-name { flex: 1; font-weight: 600; }
.sale-line .sl-match { font-size: 12px; margin-top: 2px; }
.match-ok { color: var(--green-d); }
.match-warn { color: var(--amber); }
.match-none { color: var(--danger); }
.sale-line select { flex: 1.2; padding: 8px; font-size: 13px; }
.sale-line .sl-price { width: 90px; font-size: 14px; padding: 8px; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 6px; font-size: 18px; }
.total-row b { font-size: 22px; color: var(--green-d); }
.change-box { display: flex; justify-content: space-between; align-items: center; background: var(--green-light); border: 2px solid var(--green-l); color: var(--green-d); border-radius: 14px; padding: 14px 16px; margin: 10px 0; font-size: 17px; font-weight: 600; }
.change-box b { font-size: 26px; font-weight: 800; }
.change-neg { background: #fef2f2 !important; border-color: #fecaca !important; color: var(--danger) !important; }

/* Bot */
.bot-status { padding: 10px 12px; background: #f8fafc; border-radius: 12px; margin-bottom: 10px; }
.bot-status.open { background: var(--green-light); color: var(--green-d); }
.qr-wrap { text-align: center; margin: 10px 0; }
.qr-wrap img { width: 220px; max-width: 100%; border: 6px solid #fff; border-radius: 12px; box-shadow: var(--shadow); }
.pair-wrap { background: var(--green-light); border-radius: 12px; padding: 14px; text-align: center; font-size: 18px; margin: 10px 0; }
.pair-wrap b { font-size: 26px; letter-spacing: 3px; color: var(--green-d); }
.log { max-height: 240px; overflow-y: auto; font-size: 13px; }
.log-line { padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* Bottom nav */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto;
  background: #fff; box-shadow: 0 -4px 16px rgba(15,23,42,.08); display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b)); z-index: 40; }
.bottomnav button { flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; padding: 6px 2px; font-weight: 600; }
.bottomnav button span { font-size: 20px; }
.bottomnav button.active { color: var(--green-d); }
.bottomnav .nav-sell span { background: var(--green); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-top: -18px; box-shadow: var(--shadow); }
.bottomnav .nav-sell.active span { background: var(--green-d); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 60; }
.modal-card { background: #fff; border-radius: 24px 24px 0 0; padding: 22px; width: 100%; max-width: 560px; animation: slideup .25s ease; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.modal-card h3 { margin: 0 0 8px; }

/* Toast */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 30px; font-size: 14px; font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90%; text-align: center; }
.toast.ok { background: var(--green-d); }
.toast.err { background: var(--danger); }

@media (min-width: 600px) { body { font-size: 16px; } }
