/* ============================================
   PURO — Design System
   Konsep: "buku rekening digital" — ledger klasik
   bertemu mobile app modern. Hangat, jujur, tegas.
   ============================================ */

:root {
  /* Warna */
  --ink: #1B2A4A;
  --ink-soft: #3D4A6B;
  --paper: #FAF7F0;
  --paper-raised: #FFFFFF;
  --line: #E3DDD0;
  --wax: #C44536;       /* expense / alert */
  --wax-soft: #F5E2DE;
  --moss: #5B8266;      /* income / positive */
  --moss-soft: #E3EBE2;
  --brass: #B8954A;     /* highlight / badge */
  --brass-soft: #F2E9D5;
  --muted: #8A8473;

  /* Tipografi */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing & radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(27, 42, 74, 0.06), 0 4px 16px rgba(27, 42, 74, 0.06);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  /* Cegah auto-zoom di iOS saat fokus input */
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 16px; /* wajib >=16px biar nggak auto-zoom di iOS */
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

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

::selection {
  background: var(--brass-soft);
  color: var(--ink);
}

/* ===== Layout shell ===== */

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--paper);
}

.app-main {
  flex: 1;
  padding: 20px 20px calc(96px + var(--safe-bottom));
  padding-top: calc(20px + var(--safe-top));
}

/* ===== Typography ===== */

.h-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.amount {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.amount-sm {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ===== Ledger card — elemen signature PURO ===== */

.ledger-card {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.ledger-card::before {
  /* garis halus ala kertas buku rekening */
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 27px,
    rgba(250, 247, 240, 0.045) 28px
  );
  pointer-events: none;
}

.ledger-card .eyebrow {
  color: rgba(250, 247, 240, 0.6);
  position: relative;
}

.ledger-card .amount {
  font-size: 36px;
  color: var(--paper);
  position: relative;
  margin-top: 4px;
  line-height: 1.1;
}

.ledger-stamp {
  position: absolute;
  top: 22px;
  right: 22px;
  border: 1.5px solid rgba(184, 149, 74, 0.7);
  color: var(--brass);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 100px;
  transform: rotate(3deg);
  font-weight: 600;
}

/* ===== Cards ===== */

.card {
  background: var(--paper-raised);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  padding: 16px;
}

.card-flat {
  background: var(--paper-raised);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

/* ===== Buttons ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.12s ease, opacity 0.12s ease;
  width: 100%;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-secondary {
  background: var(--paper-raised);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-wax {
  background: var(--wax);
  color: var(--paper);
}

.btn-moss {
  background: var(--moss);
  color: var(--paper);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  width: auto;
  padding: 8px 12px;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  padding: 0;
}

/* ===== Inputs ===== */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.field-amount input {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ===== Pills / badges ===== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-wax { background: var(--wax-soft); color: var(--wax); }
.pill-moss { background: var(--moss-soft); color: var(--moss); }
.pill-brass { background: var(--brass-soft); color: var(--brass); }
.pill-neutral { background: var(--line); color: var(--ink-soft); }

/* ===== Transaction row ===== */

.trx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.trx-row:last-child {
  border-bottom: none;
}

.trx-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.trx-info {
  flex: 1;
  min-width: 0;
}

.trx-title {
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trx-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.trx-amount {
  font-family: var(--font-body);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14.5px;
  flex-shrink: 0;
}

.trx-amount.income { color: var(--moss); }
.trx-amount.expense { color: var(--wax); }

/* ===== Bottom nav ===== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 8px calc(10px + var(--safe-bottom));
  z-index: 50;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.nav-item i {
  font-size: 18px;
}

.nav-item.active {
  color: var(--ink);
}

.nav-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-top: -28px;
  box-shadow: 0 4px 14px rgba(27, 42, 74, 0.3);
}

/* ===== Empty state ===== */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state i {
  font-size: 32px;
  color: var(--line);
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  margin-top: 6px;
}

/* ===== Section headers ===== */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}

/* ===== Top bar ===== */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.top-bar .greeting {
  font-size: 13px;
  color: var(--muted);
}

.top-bar .brand {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ===== Modal / sheet ===== */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 74, 0.4);
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  background: var(--paper);
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(24px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 100px;
  margin: 10px auto 16px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 18px;
}

/* ===== Toast ===== */

.toast {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toast.error { background: var(--wax); }
.toast.success { background: var(--moss); }

/* ===== Loader ===== */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, #ECE6D8 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Tabs ===== */

.tabs {
  display: flex;
  gap: 6px;
  background: var(--line);
  padding: 4px;
  border-radius: 100px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 9px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.tab.active {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ===== Utility ===== */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ===== Responsive guard ===== */

@media (min-width: 481px) {
  body {
    background: #EFE9DC;
  }
  .app-shell {
    box-shadow: 0 0 40px rgba(27, 42, 74, 0.08);
    min-height: 100vh;
  }
}
