:root {
  --navy: #0f2c4e;
  --navy-dark: #0a1d33;
  --navy-light: #1e4a7a;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #2dd4bf;
  --gold: #d4a017;
  --gold-dark: #92720d;
  --violet: #7c3aed;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --border: #e5e7eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15,44,78,0.06), 0 1px 3px rgba(15,44,78,0.08);
  --shadow-md: 0 4px 14px rgba(15,44,78,0.12), 0 2px 4px rgba(15,44,78,0.06);
  --shadow-lg: 0 16px 32px rgba(15,44,78,0.18), 0 4px 10px rgba(15,44,78,0.08);
}

* { box-sizing: border-box; }

/* Must win over any class below that sets its own `display` (e.g. .btn, .bottom-nav a) —
   otherwise the [hidden] attribute silently stops hiding those elements. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  /* Backup for the viewport meta's user-scalable=no — blocks double-tap-to-zoom on
     browsers that ignore that meta tag (notably iOS Safari in some versions). */
  touch-action: manipulation;
  /* Stops the rubber-band bounce that lets a drag reveal blank space beyond the
     top/bottom edge, and blocks the browser from chaining that scroll to a parent
     (e.g. pull-to-refresh) — keeps the drag gesture inside the app frame. */
  overscroll-behavior: none;
  overflow-x: hidden;
}

body {
  padding-bottom: 96px; /* space for the floating bottom nav */
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(10,29,51,0.25);
}
.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}
.topbar-logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.35));
}
.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}
.topbar button.logout {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.topbar .back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  flex-shrink: 0;
}
.topbar .back-btn svg { width: 18px; height: 18px; }

/* ---------- Layout ---------- */
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(15,44,78,0.06);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  /* min-width:0 overrides the grid item's default min-width:auto, which otherwise
     sizes the column to fit unbreakable text (e.g. "Rp1.250.000") even past 1fr,
     pushing later cards outside the viewport. */
  min-width: 0;
  background: var(--card);
  border: 1px solid rgba(15,44,78,0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 10px;
  text-align: center;
}
.stat .value {
  font-size: clamp(13px, 5.4vw, 22px);
  font-weight: 800;
  color: var(--navy);
  line-height: 1.15;
  overflow-wrap: break-word;
}
.stat .label {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-icon.icon-teal { background: rgba(13,148,136,0.12); color: var(--teal-dark); }
.stat-icon.icon-gold { background: rgba(212,160,23,0.15); color: var(--gold-dark); }
.stat-icon.icon-navy { background: rgba(15,44,78,0.08); color: var(--navy); }

/* Highlights the single most important number on a screen (e.g. today's revenue,
   total profit) with the brand gradient instead of the flat white card. */
.stat.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  border: none;
  box-shadow: var(--shadow-md);
}
.stat.hero .value { color: #fff; }
.stat.hero .label { color: rgba(255,255,255,0.65); }
.stat.hero .stat-icon { background: rgba(255,255,255,0.16); color: #fff; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 12px 0 6px;
}
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  margin-top: 14px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 14px rgba(13,148,136,0.3);
}
.btn-primary:active { box-shadow: 0 2px 6px rgba(13,148,136,0.3); }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--navy); box-shadow: var(--shadow-sm); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; margin-top: 0; }

/* ---------- Alerts ---------- */
.alert {
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 14px;
  font-weight: 500;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ---------- Lists / tables ---------- */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.list-row:last-child { border-bottom: none; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.list-row .title { font-weight: 600; font-size: 14px; }
.list-row .subtitle { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.list-row .amount { font-weight: 700; color: var(--navy); font-size: 14px; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-low { background: #fef3c7; color: #92400e; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-void { background: #fee2e2; color: #991b1b; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(15,44,78,0.05);
  padding: 8px 6px;
  max-width: 616px;
  margin: 0 auto;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 13px;
  transition: color 0.15s ease, background 0.15s ease;
}
.bottom-nav a.active { color: var(--teal-dark); background: rgba(13,148,136,0.12); }
.bottom-nav a svg { width: 20px; height: 20px; }
.bottom-nav a.active svg { stroke-width: 2.5; }
.bottom-nav a[hidden] { display: none; }

/* ---------- Misc ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qty-stepper button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.qty-stepper input {
  text-align: center;
  width: 56px;
}

.item-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.item-line:last-child { border-bottom: none; }

.install-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  margin-bottom: 14px;
  display: none;
}
.install-banner.show { display: block; }
