:root {
  --navy: #0A2463;
  --navy-dark: #061640;
  --gold: #D4AF37;
  --gold-light: #F0D77B;
  --paper: #F7F5F0;
  --white: #FFFFFF;
  --text: #1A1A2E;
  --muted: #6B7280;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --border: #E5E7EB;
  --shadow: 0 2px 12px rgba(10, 36, 99, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ========== LAYOUT ========== */
.app { display: flex; flex-direction: column; min-height: 100vh; max-width: 480px; margin: 0 auto; background: var(--paper); position: relative; }
.page { display: none; flex: 1; overflow-y: auto; padding-bottom: 72px; }
.page.active { display: block; }

/* Header */
.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: white;
  padding: 12px 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-row { display: flex; align-items: center; gap: 10px; }
.header .logo {
  width: 44px; height: 44px; border-radius: 10px;
  object-fit: cover; border: 1.5px solid var(--gold);
  background: var(--navy); flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(212,175,55,0.35);
}
.header h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; flex: 1; }
.header h1 span { display: block; font-size: 11px; font-weight: 400; opacity: 0.85; color: var(--gold-light); }
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,0.12); border: none; color: white;
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
}
.icon-btn:active { background: rgba(255,255,255,0.25); }

/* Search */
.search-wrap { padding: 10px 16px 0; }
.search-box {
  display: flex; align-items: center; background: white; border-radius: 10px;
  padding: 10px 14px; box-shadow: var(--shadow); gap: 8px;
}
.search-box input {
  border: none; outline: none; flex: 1; font-size: 14px; background: transparent;
}
.search-box input::placeholder { color: var(--muted); }

/* Category pills */
.cats {
  display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.cats::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0; padding: 7px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: white; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer;
  transition: all 0.15s;
}
.cat-pill.active {
  background: var(--navy); color: white; border-color: var(--navy);
}

/* Product grid */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 0 16px 20px;
}
.card {
  background: white; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.card-img {
  height: 100px; background: linear-gradient(145deg, #e8eef8, #f0f4fa);
  display: flex; align-items: center; justify-content: center; font-size: 36px;
  position: relative;
}
.card-body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; }
.card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-price { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.card-stock { font-size: 11px; margin-bottom: 8px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.badge-ok { background: #D1FAE5; color: #065F46; }
.badge-low { background: #FEF3C7; color: #92400E; }
.badge-out { background: #FEE2E2; color: #991B1B; }
.btn-add {
  margin-top: auto; width: 100%; padding: 8px; border: none; border-radius: 8px;
  background: var(--gold); color: var(--navy-dark); font-weight: 700; font-size: 13px;
  cursor: pointer;
}
.btn-add:active { opacity: 0.85; }
.btn-add:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: white;
  border-top: 1px solid var(--border); display: flex; z-index: 60;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 4px 10px; gap: 2px; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 11px; font-weight: 500;
}
.nav-item .nav-icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--navy); font-weight: 700; }
.nav-item .badge-count {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: var(--danger); color: white; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.nav-item { position: relative; }

/* ========== CART ========== */
.cart-list { padding: 12px 16px; }
.cart-item {
  background: white; border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
  box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 600; font-size: 14px; }
.cart-item-price { font-size: 13px; color: var(--navy); font-weight: 600; }
.qty-ctrl { display: flex; align-items: center; gap: 8px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1.5px solid var(--border);
  background: white; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.qty-val { font-weight: 700; min-width: 20px; text-align: center; }

.form-group { padding: 0 16px 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; background: white;
}
.form-group input:focus, .form-group select:focus { border-color: var(--navy); }

.pay-methods { display: flex; gap: 8px; padding: 0 16px 12px; }
.pay-opt {
  flex: 1; padding: 12px 8px; border: 1.5px solid var(--border); border-radius: 10px;
  background: white; text-align: center; cursor: pointer; font-size: 12px; font-weight: 600;
}
.pay-opt.active { border-color: var(--navy); background: #EEF2FF; color: var(--navy); }

.cart-footer {
  position: sticky; bottom: 72px; background: white; padding: 14px 16px;
  border-top: 1px solid var(--border); box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}
.cart-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 10px;
  background: var(--gold); color: var(--navy-dark); font-weight: 700; font-size: 15px;
  cursor: pointer;
}
.btn-primary:active { opacity: 0.9; }
.btn-primary:disabled { background: #e5e7eb; color: #9ca3af; }

.btn-secondary {
  width: 100%; padding: 12px; border: 1.5px solid var(--navy); border-radius: 10px;
  background: white; color: var(--navy); font-weight: 600; font-size: 14px; cursor: pointer;
  margin-top: 8px;
}

/* ========== SUCCESS / NOTA ========== */
.success-box {
  text-align: center; padding: 32px 20px;
}
.success-box .check { font-size: 56px; color: var(--success); margin-bottom: 12px; }
.success-box h2 { font-size: 20px; margin-bottom: 4px; }
.success-box .nota-code { font-size: 18px; font-weight: 700; color: var(--navy); letter-spacing: 1px; margin: 12px 0; }
.qr-wrap {
  display: inline-block; padding: 16px; background: white; border-radius: 12px;
  box-shadow: var(--shadow); margin: 12px 0;
}
.qr-wrap canvas, .qr-wrap img { display: block; }

/* ========== MEJA ========== */
.meja-filters { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; }
.filter-btn {
  flex-shrink: 0; padding: 7px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: white; font-size: 13px; font-weight: 500; cursor: pointer;
}
.filter-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

.order-card {
  background: white; border-radius: var(--radius); margin: 0 16px 12px; padding: 14px;
  box-shadow: var(--shadow);
}
.order-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.order-code { font-weight: 700; font-size: 14px; color: var(--navy); }
.order-time { font-size: 12px; color: var(--muted); }
.order-customer { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.order-items { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.order-total { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700;
}
.status-baru { background: #FEF3C7; color: #92400E; }
.status-disiapkan { background: #DBEAFE; color: #1E40AF; }
.status-selesai { background: #D1FAE5; color: #065F46; }
.order-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-sm {
  flex: 1; padding: 9px; border: none; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn-sm.primary { background: var(--navy); color: white; }
.btn-sm.success { background: var(--success); color: white; }
.btn-sm.outline { background: white; border: 1.5px solid var(--border); color: var(--text); }

/* ========== ADMIN ========== */
.admin-menu { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-tile {
  background: white; border-radius: var(--radius); padding: 20px 12px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer; border: none;
}
.admin-tile .tile-icon { font-size: 28px; margin-bottom: 8px; }
.admin-tile .tile-label { font-size: 13px; font-weight: 600; }

.section-title {
  padding: 16px 16px 8px; font-size: 16px; font-weight: 700; color: var(--navy);
}

.table-wrap { padding: 0 16px 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: white; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
th { background: var(--navy); color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

.login-box {
  max-width: 340px; margin: 40px auto; background: white; border-radius: 16px;
  padding: 28px 24px; box-shadow: var(--shadow);
}
.login-box h2 { text-align: center; margin-bottom: 20px; color: var(--navy); }
.pin-input {
  letter-spacing: 8px; font-size: 24px; text-align: center; font-weight: 700;
}

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; padding: 12px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 500; z-index: 100; opacity: 0; transition: opacity 0.25s;
  pointer-events: none; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: white; width: 100%; max-width: 480px; border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px; max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; color: var(--navy); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }

.hidden { display: none !important; }

/* Finance cards */
.fin-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px; }
.fin-card {
  background: white; border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
}
.fin-card .label { font-size: 12px; color: var(--muted); }
.fin-card .value { font-size: 16px; font-weight: 700; margin-top: 4px; }
.fin-card .value.green { color: var(--success); }
.fin-card .value.red { color: var(--danger); }
.fin-card .value.navy { color: var(--navy); }

/* Utility */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); font-size: 13px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.p-16 { padding: 16px; }
