/* Tabungan Bersama — mobile-first, dark default */
:root, [data-theme="dark"] {
  --bg: #0b1220;
  --bg2: #0f172a;
  --card: #16213a;
  --card2: #1b2745;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --teal: #14b8a6;
  --teal-dark: #0f766e;
  --teal-soft: rgba(20, 184, 166, 0.14);
  --border: rgba(148, 163, 184, 0.16);
  --danger: #f87171;
  --warn: #fbbf24;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}
[data-theme="light"] {
  --bg: #eef2f7;
  --bg2: #f8fafc;
  --card: #ffffff;
  --card2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --teal: #0f766e;
  --teal-dark: #0d5f58;
  --teal-soft: rgba(15, 118, 110, 0.1);
  --border: #e2e8f0;
  --danger: #dc2626;
  --warn: #d97706;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  transition: background 0.25s, color 0.25s;
}
h1, h2, h3 { margin: 0; }
button { font-family: inherit; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: radial-gradient(120% 60% at 50% 0%, rgba(20,184,166,0.16), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo { width: 72px; height: 72px; border-radius: 20px; }
.auth-card h1 { font-size: 22px; margin: 14px 0 6px; }
.auth-card .muted { font-size: 13.5px; margin: 0 0 22px; }
.auth-card form { text-align: left; }

/* ---------- Layout ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header .logo { width: 40px; height: 40px; border-radius: 12px; }
.app-header .who { flex: 1; min-width: 0; }
.app-header .who b { display: block; font-size: 15px; }
.app-header .who span { font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 110px;
}
.tab { display: none; }
.tab.active { display: block; animation: tabIn 0.28s ease; }
@keyframes tabIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.hero {
  background: linear-gradient(135deg, var(--teal-dark), #115e59 60%, #134e4a);
  color: #fff;
  border: none;
  overflow: hidden;
  position: relative;
}
.hero .total-label { font-size: 13px; opacity: 0.85; }
.hero .total { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.progress { height: 12px; border-radius: 99px; background: rgba(255,255,255,0.22); overflow: hidden; }
.progress > i {
  display: block; height: 100%;
  background: repeating-linear-gradient(45deg, #fff, #fff 10px, #e6fffa 10px, #e6fffa 20px);
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
  animation: stripes 1.2s linear infinite;
  background-size: 28px 100%;
}
@keyframes stripes { to { background-position: 28px 0; } }
.hero .target-line { font-size: 12.5px; opacity: 0.9; margin-top: 8px; }

.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; padding-bottom: 0; }
.member-row:first-of-type { padding-top: 0; }
.avatar {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--teal-soft); color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; flex-shrink: 0;
}
.member-row .info { flex: 1; min-width: 0; }
.member-row .info b { display: block; font-size: 14.5px; }
.member-row .info span { font-size: 12px; color: var(--muted); }
.member-row .amt { text-align: right; }
.member-row .amt b { display: block; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.member-row .amt span {
  font-size: 11px; color: var(--teal); font-weight: 700;
  background: var(--teal-soft); padding: 2px 8px; border-radius: 99px;
}
.mbar { height: 6px; border-radius: 99px; background: var(--card2); margin-top: 10px; overflow: hidden; }
.mbar > i { display: block; height: 100%; background: var(--teal); border-radius: 99px; transition: width 1s ease; }

.acct-grid { display: grid; gap: 8px; font-size: 14px; }
.acct-grid .rowline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acct-grid .num { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: 0.5px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px; /* cegah auto-zoom iOS Safari (<16px memicu zoom) */
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--teal); }
textarea.input { resize: vertical; min-height: 74px; }
input[type="date"].input {
  min-height: 50px;
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
input[type="date"].input::-webkit-datetime-edit {
  padding: 0;
  min-width: 0;
  overflow: hidden;
}
input[type="date"].input::-webkit-datetime-edit-fields-wrapper {
  max-width: 100%;
}
/* Pembungkus anti-overflow: potong apapun yang dirender di luar batas */
.date-clip {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.date-clip .input {
  border: none;
  border-radius: 0;
  background: transparent;
}
.btn {
  display: block; width: 100%;
  border: none; border-radius: 16px;
  padding: 15px;
  font-size: 15.5px; font-weight: 700;
  background: var(--teal); color: #fff;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 10px; font-size: 13.5px; }
.btn.small { width: auto; padding: 9px 16px; font-size: 13.5px; border-radius: 12px; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  border-radius: 99px;
  padding: 9px 15px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.chip.on { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }

/* ---------- History ---------- */
.hist-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.hist-item .grow { flex: 1; min-width: 0; }
.hist-item .grow b { font-size: 14px; }
.hist-item .grow .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hist-item .grow .note { font-size: 12.5px; color: var(--muted); margin-top: 5px; font-style: italic; }
.hist-item .right { text-align: right; flex-shrink: 0; }
.hist-item .right b { color: var(--teal); font-variant-numeric: tabular-nums; }
.linklike {
  background: none; border: none; padding: 0; margin-top: 8px;
  color: var(--teal); font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.del-btn {
  background: none; border: none; color: var(--danger);
  font-size: 12px; cursor: pointer; margin-top: 8px; padding: 0; opacity: 0.85;
}

/* ---------- OCR / proof ---------- */
.drop {
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.drop:hover, .drop.over { border-color: var(--teal); }
.drop input { display: none; }
.ocr-status { font-size: 12.5px; color: var(--warn); margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.ocr-ok { color: var(--teal); }
.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--warn);
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.proof-thumb { max-width: 100%; border-radius: 12px; margin-top: 10px; border: 1px solid var(--border); }

/* ---------- Modal / toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: tabIn 0.2s ease;
}
.modal .box {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  max-width: 480px; width: 100%;
  max-height: 88dvh; overflow: auto;
}
.modal img { width: 100%; border-radius: 12px; }
#toast-wrap {
  position: fixed; bottom: 96px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none; padding: 0 20px;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 99px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: tabIn 0.25s ease;
  max-width: 100%;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  font-size: 10.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0;
  cursor: pointer;
  border-radius: 12px;
}
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button.on { color: var(--teal); }
.tabbar button.on svg { filter: drop-shadow(0 0 6px rgba(20,184,166,0.5)); }

.section-title { font-size: 17px; font-weight: 800; margin: 4px 2px 14px; }
.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 28px 10px; }
.kv { display: flex; justify-content: space-between; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border: none; }
.kv span { color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.warnbox {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warn);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
@media (min-width: 640px) {
  .hero .total { font-size: 40px; }
}
