*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --success: #34a853;
  --warning: #fbbc04;
  --danger: #ea4335;
  --grey-50: #f8f9fa;
  --grey-100: #f1f3f4;
  --grey-200: #e8eaed;
  --grey-400: #bdc1c6;
  --grey-600: #80868b;
  --grey-800: #3c4043;
  --grey-900: #202124;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--grey-50);
  color: var(--grey-900);
  min-height: 100dvh;
  padding-bottom: 80px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.app-header-row { display: flex; align-items: center; justify-content: space-between; }
.app-header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: .01em; }
.app-header small { font-size: .75rem; opacity: .8; }
.key-toggle-btn {
  background: rgba(255,255,255,.18);
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 1.1rem;
  cursor: pointer;
  color: #fff;
  line-height: 1;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.key-toggle-btn:active { background: rgba(255,255,255,.3); }

/* ── Access Key Panel ────────────────────────────────────────────────────────── */
.key-panel {
  background: #fff;
  border-bottom: 2px solid var(--grey-200);
  position: sticky;
  top: 57px;
  z-index: 99;
}
.key-panel-inner { padding: 12px 16px 14px; }
.key-panel-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--grey-600);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.key-input-row { display: flex; gap: 8px; }
.key-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  outline: none;
}
.key-input-row input:focus { border-color: var(--primary); }
.key-hint {
  font-size: .73rem;
  color: var(--grey-600);
  margin-top: 8px;
  line-height: 1.4;
}

/* ── Bottom nav ─────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--grey-200);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  color: var(--grey-600);
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn .icon { font-size: 1.4rem; line-height: 1; }
.nav-btn.active { color: var(--primary); }
.nav-btn.active .icon { transform: scale(1.1); }

/* ── Tabs/Pages ─────────────────────────────────────────────────────────────── */
.page { display: none; padding: 12px 12px 16px; }
.page.active { display: block; }

/* ── Search bar ─────────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: 12px;
}
.search-wrap input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 1rem;
  background: #fff;
  color: var(--grey-900);
  outline: none;
  transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--primary); }
.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--grey-600);
  pointer-events: none;
}
.search-hint { font-size: .78rem; color: var(--grey-600); margin-bottom: 8px; padding-left: 4px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--grey-100); color: var(--grey-800); border: 1.5px solid var(--grey-200); }
.btn-sm { padding: 6px 14px; font-size: .82rem; font-weight: 500; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--grey-200);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--grey-900); line-height: 1.3; }
.card-sub { font-size: .82rem; color: var(--grey-600); margin-top: 2px; }
.card-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.card-label { font-size: .78rem; color: var(--grey-600); }
.card-value { font-size: .88rem; color: var(--grey-800); font-weight: 500; }
.card-amount { font-size: 1.05rem; font-weight: 700; color: var(--grey-900); }
.card-meta { font-size: .78rem; color: var(--grey-600); margin-top: 4px; }
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--grey-100);
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-green { background: #e6f4ea; color: #1e7e34; }
.badge-blue { background: #e8f0fe; color: #1a73e8; }
.badge-yellow { background: #fef7e0; color: #b06000; }
.badge-grey { background: var(--grey-100); color: var(--grey-600); }
.badge-red { background: #fce8e6; color: #c5221f; }

/* ── States ─────────────────────────────────────────────────────────────────── */
.state-box {
  text-align: center;
  padding: 48px 16px;
  color: var(--grey-600);
}
.state-box .state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.state-box p { font-size: .95rem; line-height: 1.5; }
.state-box .state-action { margin-top: 16px; }

.loading-bar {
  display: none;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, #8ab4f8 50%, var(--primary) 100%);
  background-size: 200% 100%;
  animation: loading 1.2s infinite;
  border-radius: 2px;
  margin-bottom: 12px;
}
.loading-bar.active { display: block; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Section heading ─────────────────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h2 { font-size: .9rem; font-weight: 600; color: var(--grey-600); text-transform: uppercase; letter-spacing: .04em; }
.section-count { font-size: .8rem; color: var(--grey-600); }

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slide-up .22s ease-out;
}
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--grey-200);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: .85rem; color: var(--grey-600); margin-bottom: 16px; }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--grey-100);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-sheet { position: relative; }

/* ── Line items table ───────────────────────────────────────────────────────── */
.line-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 12px; }
.line-table th { text-align: left; color: var(--grey-600); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--grey-200); font-size: .78rem; }
.line-table td { padding: 8px 4px; vertical-align: top; border-bottom: 1px solid var(--grey-100); }
.line-table tr:last-child td { border-bottom: none; }
.line-table .amount-col { text-align: right; font-weight: 600; white-space: nowrap; }

/* ── Info rows ───────────────────────────────────────────────────────────────── */
.info-row { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--grey-100); }
.info-row:last-child { border-bottom: none; }
.info-key { font-size: .8rem; color: var(--grey-600); flex: 0 0 120px; padding-top: 1px; }
.info-val { font-size: .88rem; color: var(--grey-900); font-weight: 500; flex: 1; }

/* ── Divider ─────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--grey-200); margin: 14px 0; }

/* ── Rupiah ─────────────────────────────────────────────────────────────────── */
.rupiah { font-variant-numeric: tabular-nums; }

@media (min-width: 480px) {
  .page { max-width: 520px; margin: 0 auto; }
  .modal-sheet { max-width: 520px; margin: 0 auto; border-radius: 20px; }
  .modal-overlay { align-items: center; }
}
