:root {
  /* Palet BerUang: coklat beruang + krem hangat */
  --bg: #fbf6ee;            /* krem terang — background utama */
  --panel: #ffffff;         /* panel putih bersih */
  --ink: #3e2d21;           /* coklat gelap — teks utama */
  --ink-soft: #8b7355;      /* coklat tanah — teks sekunder */
  --line: #ede2cc;          /* krem gelap — border/pemisah */
  --income: #5a8a3a;        /* hijau zaitun hangat — pemasukan */
  --income-bg: #e7efd9;
  --expense: #c0392b;       /* merah bata hangat — pengeluaran */
  --expense-bg: #f6dcd7;
  --balance: #4a7fc1;       /* biru klasik — saldo */
  --balance-bg: #dde7f1;
  --count: #c17c3e;         /* amber — jumlah transaksi */
  --count-bg: #f6e4cf;
  --primary: #8b5a2b;       /* coklat beruang — warna utama */
  --primary-dark: #6f4518;  /* coklat gelap untuk hover */
  --primary-ink: #fff;
  --cream-2: #f5ebd8;       /* krem aksen */
  --shadow: 0 1px 2px rgba(62, 45, 33, .06), 0 4px 12px rgba(62, 45, 33, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 240px; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #8b5a2b, #c89468);
  color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(139, 90, 43, .3);
}
.brand-icon-img {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fbf6ee, #f1e0c6);
  padding: 2px;
  box-shadow: 0 3px 10px rgba(139, 90, 43, .22), 0 0 0 1px rgba(139, 90, 43, .08);
  object-fit: contain;
  flex: 0 0 auto;
}
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--ink-soft); font-size: 12px; }
.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.tab {
  background: transparent; border: none; padding: 8px 14px; border-radius: 999px;
  color: var(--ink-soft); font-weight: 500; cursor: pointer;
}
.tab:hover { background: #eef2fb; color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }
.topbar-actions { display: flex; gap: 8px; }

/* BUTTONS */
.btn {
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 500; font-size: 13px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #f6f8fd; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: #b91c1c; border-color: #fecaca; background: #fff5f5; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: #f6f8fd; }
.btn-small { padding: 5px 10px; font-size: 12px; }

/* MAIN */
main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .15s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* PAGE HEAD */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 16px; margin-bottom: 18px;
}
.page-title { display: flex; align-items: center; gap: 10px; }
.page-title h1 { margin: 0; font-size: 26px; font-weight: 700; }
.page-title .emoji { font-size: 26px; }
.page-filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.page-filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-soft); gap: 4px; }
.page-filters select, .page-filters input[type="search"] {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; min-width: 120px;
}
.seg {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 500;
}
.seg.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* KPI CARDS — premium design untuk kesan mahal */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.card {
  background: var(--panel); border-radius: 18px; padding: 18px 20px;
  box-shadow: 0 2px 4px rgba(62, 45, 33, .04), 0 8px 24px rgba(62, 45, 33, .06);
  border: 1px solid var(--line); position: relative; overflow: hidden;
  display: flex; gap: 14px; align-items: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(62, 45, 33, .06), 0 12px 32px rgba(62, 45, 33, .1);
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px;
}
.card-income::before { background: linear-gradient(90deg, #10B981, #84CC16); }
.card-expense::before { background: linear-gradient(90deg, #EF4444, #F97316); }
.card-balance::before { background: linear-gradient(90deg, #3B82F6, #6366F1); }
.card-count::before { background: linear-gradient(90deg, #F59E0B, #EC4899); }
.card-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 24px;
  flex: 0 0 auto;
}
.card-income .card-icon { background: linear-gradient(135deg, #D1FAE5, #BBF7D0); }
.card-expense .card-icon { background: linear-gradient(135deg, #FEE2E2, #FED7AA); }
.card-balance .card-icon { background: linear-gradient(135deg, #DBEAFE, #E0E7FF); }
.card-count .card-icon { background: linear-gradient(135deg, #FEF3C7, #FCE7F3); }
.card-body { flex: 1; min-width: 0; }
.card-label { font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--ink-soft); }
.card-value { font-size: 22px; font-weight: 800; margin: 2px 0 4px; letter-spacing: -.3px; }
.card-income .card-value { color: #059669; }
.card-expense .card-value { color: #DC2626; }
.card-balance .card-value { color: #2563EB; }
.card-count .card-value { color: #D97706; }
.card-delta { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.card-delta.up { color: #059669; }
.card-delta.down { color: #DC2626; }

/* PANELS — premium card style */
.panel {
  background: var(--panel); border-radius: 16px; padding: 18px;
  box-shadow: 0 1px 2px rgba(62, 45, 33, .03), 0 4px 16px rgba(62, 45, 33, .05);
  border: 1px solid var(--line); margin-bottom: 16px;
  transition: box-shadow .2s ease;
}
.panel:hover {
  box-shadow: 0 2px 4px rgba(62, 45, 33, .04), 0 8px 24px rgba(62, 45, 33, .08);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .2px; color: var(--ink); }
.panel-head small { color: var(--ink-soft); font-size: 12px; }

/* Container chart dengan tinggi tetap supaya canvas tidak grow tanpa batas di iPad/PWA */
.chart-box {
  position: relative;
  width: 100%;
  height: 260px;
  overflow: hidden;
}
.chart-box-lg { height: 300px; }
.chart-box canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}
.legend { font-size: 12px; color: var(--ink-soft); display: flex; gap: 10px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-income { background: var(--income); }
.dot-expense { background: var(--expense); }

/* GRIDS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 0; }
.grid-2 > .panel, .grid-3 > .panel { margin-bottom: 16px; }

@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* WELCOME BANNER */
.welcome-banner {
  background: linear-gradient(135deg, #8b5a2b, #c89468);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px rgba(139, 90, 43, .25);
}
.welcome-banner[hidden] { display: none; }
.welcome-content { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.welcome-bear { font-size: 56px; line-height: 1; flex: 0 0 auto; }
.welcome-bear-img {
  width: 96px; height: 96px; flex: 0 0 auto;
  border-radius: 18px;
  background: rgba(255,255,255,.15);
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  object-fit: contain;
}
.welcome-content h2 { margin: 0 0 4px; font-size: 22px; }
.welcome-content p { margin: 4px 0; opacity: .95; }
.welcome-content .welcome-steps { font-size: 13px; opacity: .9; margin: 8px 0 12px; }
.welcome-content .btn-primary { background: #fff; color: var(--primary); border-color: #fff; font-weight: 600; }
.welcome-content .btn-primary:hover { background: var(--cream-2); color: var(--primary-dark); border-color: var(--cream-2); }

/* MINI REPORTS */
.mini-reports { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.mini-reports li {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px;
}
.mini-reports li.good { border-left: 3px solid var(--income); }
.mini-reports li.bad  { border-left: 3px solid var(--expense); }
.mini-reports li.info { border-left: 3px solid var(--balance); }

/* RANKED LIST */
.ranked { padding-left: 20px; margin: 0; max-height: 320px; overflow: auto; }
.ranked li { margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.ranked li .rank-name { color: var(--ink); }
.ranked li .rank-val  { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

/* CATEGORY LEGEND (lama, fallback) */
.cat-legend { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; }
.cat-legend li { display: flex; align-items: center; gap: 6px; }
.cat-legend .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }

/* PIE + LEGEND KANAN (modern seperti contoh haloziq) */
.pie-with-legend {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 1.2fr;
  gap: 14px;
  align-items: center;
}
.pie-canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}
.pie-canvas-wrap canvas { max-width: 200px; max-height: 200px; }
.pie-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.pie-center small { color: var(--ink-soft); font-size: 10px; letter-spacing: .5px; text-transform: uppercase; display: block; }
.pie-center b { color: var(--ink); font-size: 15px; font-weight: 700; display: block; margin-top: 2px; }
.pie-legend-right {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 12px;
  max-height: 240px;
  overflow-y: auto;
}
.pie-legend-right li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #fcf8f1;
  border: 1px solid #f1e9d9;
  transition: background .15s, transform .1s;
}
.pie-legend-right li:hover {
  background: #fff;
  transform: translateX(2px);
}
.pie-legend-right .sw {
  width: 14px; height: 14px; border-radius: 4px;
  display: inline-block; flex: 0 0 auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.pie-legend-right .cat-name { color: var(--ink); font-weight: 500; }
.pie-legend-right .cat-pct {
  color: #fff;
  font-weight: 700;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  min-width: 40px;
  text-align: center;
}

@media (max-width: 700px) {
  .pie-with-legend { grid-template-columns: 1fr; text-align: center; }
  .pie-legend-right { max-height: none; }
}

/* COMPARE LIST */
.compare-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.compare-list li {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); align-items: center;
}
.compare-list li:last-child { border-bottom: none; }
.compare-list .arr.up { color: var(--income); }
.compare-list .arr.down { color: var(--expense); }

/* ALOKASI */
.alokasi-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.alokasi-item { border-radius: 10px; padding: 12px; border: 1px solid var(--line); }
.alok-keb { background: #fdf0dc; border-color: #f1dab4; }
.alok-kei { background: #fbe8e4; border-color: #f2c9c0; }
.alok-inv { background: #e9efd9; border-color: #d0dcb2; }
.alokasi-title { font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .5px; }
.alokasi-item ol { padding-left: 20px; margin: 0; font-size: 12px; max-height: 220px; overflow: auto; }
.alokasi-item ol li { display: flex; justify-content: space-between; gap: 6px; }
.alokasi-total { margin-top: 10px; font-weight: 700; display: flex; justify-content: space-between; font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; }

/* BUDGET RINGS */
.budget-rings { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.ring-wrap { position: relative; text-align: center; min-height: 150px; display: flex; align-items: center; justify-content: center; }
.ring-wrap canvas { max-width: 150px; max-height: 150px; display: block; }
.ring-label {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none; text-align: center;
}
.ring-label span { font-weight: 800; font-size: 18px; display: block; line-height: 1; }
.ring-label small { color: var(--ink-soft); font-size: 10px; display: block; margin-top: 2px; max-width: 90px; }
.budget-note { margin-top: 10px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit input { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); width: 140px; }

/* SIX MONTH TABLE */
.six-month-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.six-month-table th, .six-month-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: right; }
.six-month-table th:first-child, .six-month-table td:first-child { text-align: left; }
.six-month-table thead th { background: #f8fafc; font-weight: 700; font-size: 12px; color: var(--ink-soft); letter-spacing: .3px; }
.six-month-table tfoot td { font-weight: 700; background: #f0f4ff; }

/* TRANSAKSI */
.trx-table, .rekap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.trx-table th, .trx-table td, .rekap-table th, .rekap-table td {
  padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
.trx-table thead th, .rekap-table thead th { background: #f8fafc; color: var(--ink-soft); font-size: 12px; letter-spacing: .3px; }
.trx-table td.num, .trx-table th.num, .rekap-table td.num, .rekap-table th.num { text-align: right; }
.trx-table tbody tr:hover { background: #fafbff; }
.pill { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill-in  { background: var(--income-bg);  color: var(--income); }
.pill-out { background: var(--expense-bg); color: var(--expense); }
.pill-alok { background: #eef2ff; color: #3730a3; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { border: none; background: transparent; cursor: pointer; color: var(--ink-soft); padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: #eef2fb; color: var(--ink); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--expense); }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* FORM */
.form { display: grid; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); }
.form input, .form select, .form textarea {
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px;
  color: var(--ink); font-family: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* CHAT */
.chat-panel { display: flex; flex-direction: column; }
.chat-box {
  flex: 1; min-height: 280px; max-height: 380px; overflow: auto;
  background: #f8fafc; border-radius: 10px; border: 1px solid var(--line);
  padding: 10px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px;
}
.chat-msg {
  padding: 8px 12px; border-radius: 12px; max-width: 85%; font-size: 13px; line-height: 1.5;
}
.chat-msg.bot  { background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.chat-msg.user { background: var(--primary); color: #fff; align-self: flex-end; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); }

/* STRUK */
#struk-text {
  width: 100%; min-height: 180px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}
.struk-photo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.struk-photo-btn, .struk-gallery-btn {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff !important; border: none; cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,255,255,.25);
}
.struk-photo-btn { background: linear-gradient(135deg, #2563eb, #16a34a); }
.struk-gallery-btn { background: linear-gradient(135deg, #9333ea, #db2777); }
.struk-photo-btn:hover, .struk-gallery-btn:hover,
.struk-photo-btn:active, .struk-gallery-btn:active { filter: brightness(1.08); color: #fff; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
#struk-photo-preview {
  max-width: 220px; max-height: 220px; border-radius: 10px; margin-bottom: 8px;
  border: 1px solid var(--line); display: block; object-fit: contain; background: #fff;
}
.ocr-progress {
  padding: 10px 12px; border-radius: 10px; background: #eff6ff; color: #1e40af;
  font-size: 12px; margin-bottom: 8px; border: 1px solid #bfdbfe;
}
.ocr-progress.ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.ocr-progress.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.ocr-bar { display: block; height: 6px; background: #dbeafe; border-radius: 999px; margin-top: 6px; overflow: hidden; }
.ocr-bar > span { display: block; height: 100%; background: #2563eb; width: 0%; transition: width .2s; }
.struk-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; flex-wrap: wrap; }
.struk-preview { margin-top: 10px; font-size: 12px; }
.struk-preview table { width: 100%; border-collapse: collapse; }
.struk-preview th, .struk-preview td { padding: 4px 6px; border-bottom: 1px solid var(--line); }

/* KATEGORI */
.kat-list { display: grid; gap: 10px; }
.kat-group {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.kat-group h4 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.kat-group ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.kat-group li {
  background: #f8fafc; border: 1px solid var(--line); padding: 4px 8px; border-radius: 999px; font-size: 12px;
  display: inline-flex; gap: 6px; align-items: center;
}
.kat-group li button { border: none; background: transparent; cursor: pointer; color: var(--ink-soft); }
.kat-group li button:hover { color: var(--expense); }
.form-inline { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.form-inline input, .form-inline select { padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; }

/* MODAL */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 50;
  padding: 20px;
}
.modal[hidden] { display: none !important; }
.modal:not([hidden]) { display: grid; place-items: center; }
.toast[hidden] { display: none !important; }
.modal-close {
  position: absolute; top: 8px; right: 10px;
  background: transparent; border: none; font-size: 26px; line-height: 1;
  color: var(--ink-soft); cursor: pointer; padding: 4px 10px; border-radius: 8px;
}
.modal-close:hover { background: #f1f5f9; color: var(--ink); }
.modal-card { position: relative; }
.modal-card {
  background: #fff; border-radius: var(--radius); padding: 20px; width: 100%;
  max-width: 520px; box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-card h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* TOAST */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; z-index: 60; box-shadow: 0 10px 20px rgba(0,0,0,.2);
  animation: toastIn .2s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.footer { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 20px; }

/* ============ LOGIN SCREEN ============ */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, #fbf6ee 0%, #f1e0c6 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.login-screen[hidden] { display: none; }
.login-card {
  background: #fff; border-radius: 22px;
  padding: 30px 26px; max-width: 400px; width: 100%;
  box-shadow: 0 8px 32px rgba(139, 90, 43, .15), 0 2px 8px rgba(139, 90, 43, .08);
  text-align: center;
}
.login-logo {
  width: 90px; height: 90px; margin: 0 auto 10px; display: block;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(139, 90, 43, .2);
}
.login-brand { margin: 0 0 4px; font-size: 28px; font-weight: 800; color: var(--primary); letter-spacing: -.5px; }
.login-tag { color: var(--ink-soft); font-size: 13px; margin: 0 0 24px; }
.login-tabs { display: flex; gap: 4px; background: #fbf6ee; border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.login-tab {
  flex: 1; padding: 10px; border: none; background: transparent; cursor: pointer;
  border-radius: 8px; font-weight: 600; color: var(--ink-soft); font-size: 14px;
}
.login-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.auth-form { display: grid; gap: 14px; text-align: left; }
.auth-form[hidden] { display: none; }
.auth-form label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.auth-form input {
  width: 100%; padding: 12px 14px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fbf6ee;
}
.auth-form input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: #fff; }
.btn-block { width: 100%; padding: 12px; font-size: 14px; font-weight: 600; }
.auth-form a { text-align: center; color: var(--primary); font-size: 13px; text-decoration: none; margin-top: 4px; }
.auth-form a:hover { text-decoration: underline; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 18px 0;
  color: var(--ink-soft); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.btn-google {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-google:hover { background: #fcf8f1; border-color: var(--primary); }
.auth-error, .auth-info {
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-top: 14px; text-align: left;
}
.auth-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.auth-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.login-footer { margin-top: 16px; color: var(--ink-soft); font-size: 12px; text-align: center; }

/* ============ PAYWALL ============ */
.paywall-card { max-width: 460px; }
.paywall-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.price-card {
  border: 2px solid var(--line); border-radius: 14px; padding: 16px 12px;
  background: #fcf8f1; position: relative;
  display: flex; flex-direction: column; gap: 8px;
  transition: all .2s;
}
.price-card:hover { border-color: var(--primary); }
.price-card.selected { border-color: var(--primary); background: #fff4e0; box-shadow: 0 4px 12px rgba(139,90,43,.15); }
.price-card.highlight { background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: #fbbf24; }
.price-card.highlight.selected { box-shadow: 0 4px 16px rgba(251,191,36,.3); }
.price-card b { display: block; font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.price-card .price { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.price-card .price small { display: block; font-size: 11px; font-weight: 500; color: var(--ink-soft); margin-top: 3px; }
.price-card .badge {
  position: absolute; top: -10px; right: 10px;
  background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff; font-size: 10px;
  padding: 3px 10px; border-radius: 999px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(245,158,11,.4);
}
.price-card .btn-buy { padding: 8px; font-size: 13px; margin-top: auto; }

.payment-info {
  background: #fbf6ee; border: 1px solid #ede2cc; border-radius: 12px;
  padding: 12px 14px; margin: 16px 0; text-align: left;
}
.payment-title { font-weight: 700; margin-bottom: 8px; font-size: 13px; color: var(--ink); }
.payment-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.payment-row:last-child { border-bottom: none; }
.payment-row span:first-child { color: var(--ink-soft); }
.payment-row b { color: var(--ink); }
.payment-copy { display: flex; gap: 8px; align-items: center; }
.payment-copy code {
  background: #fff; padding: 4px 10px; border-radius: 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 14px; font-weight: 700;
  color: var(--primary); border: 1px solid var(--line);
}

.paywall-actions { display: grid; gap: 8px; margin-bottom: 12px; }
.btn-wa {
  background: #25d366; color: #fff !important; border-color: #25d366;
  font-weight: 700;
}
.btn-wa:hover { background: #128c7e; border-color: #128c7e; }
.btn-ig {
  background: linear-gradient(135deg, #833AB4, #E1306C, #F77737);
  color: #fff !important; border: none;
  font-weight: 700;
}
.btn-ig:hover { filter: brightness(1.1); }
.paywall-note {
  font-size: 12px; color: var(--ink-soft); text-align: center;
  margin: 14px 0; line-height: 1.6;
}

/* ============ USER MENU ============ */
.user-menu { position: relative; margin-left: 6px; }
.user-menu-btn {
  border: 2px solid var(--primary); background: var(--cream-2);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0; overflow: hidden;
  font-weight: 700; color: var(--primary);
}
.user-menu-btn:hover { background: #fff; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; min-width: 240px;
  box-shadow: 0 8px 24px rgba(62, 45, 33, .12);
}
.user-dropdown[hidden] { display: none; }
.user-info { padding: 6px 8px; }
.user-name { font-weight: 700; font-size: 14px; }
.user-email { color: var(--ink-soft); font-size: 12px; margin: 2px 0; }
.user-plan { font-size: 12px; color: var(--primary); font-weight: 600; margin-top: 6px; }
.user-dropdown hr { border: none; border-top: 1px solid var(--line); margin: 8px 0; }
.user-item {
  width: 100%; text-align: left; padding: 8px 10px; border: none;
  background: transparent; cursor: pointer; border-radius: 8px;
  font-size: 13px; color: var(--ink);
}
.user-item:hover { background: #fee2e2; color: #991b1b; }

/* ============ ADMIN PANEL ============ */
.tab-admin { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e !important; font-weight: 700 !important; }
.tab-admin.active { background: var(--ink) !important; color: #fde68a !important; }

.admin-stats {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.admin-stat {
  background: #fff; border-radius: 12px; padding: 14px;
  text-align: center; border-top: 3px solid var(--line);
  box-shadow: 0 1px 3px rgba(62,45,33,.04);
}
.admin-stat b { display: block; font-size: 22px; font-weight: 800; color: var(--ink); margin-bottom: 2px; line-height: 1; }
.admin-stat small { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.admin-stat.ok { border-color: #10b981; }
.admin-stat.ok b { color: #059669; }
.admin-stat.warn { border-color: #f59e0b; }
.admin-stat.warn b { color: #d97706; }
.admin-stat.star { border-color: var(--primary); }
.admin-stat.star b { color: var(--primary); }
.admin-stat.blue { border-color: #3b82f6; }
.admin-stat.blue b { color: #2563eb; }
.admin-stat.money { border-color: #8b5cf6; }
.admin-stat.money b { color: #7c3aed; font-size: 16px; }

.admin-toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px; padding: 12px; background: #fbf6ee; border-radius: 12px;
}
.admin-toolbar input[type="search"] {
  flex: 1; min-width: 200px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 14px; background: #fff;
}
.admin-filters { display: flex; gap: 6px; flex-wrap: wrap; }

.admin-list { display: grid; gap: 12px; }
.admin-card {
  background: #fff; border-radius: 14px; padding: 16px;
  border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(62,45,33,.05);
  transition: all .15s;
}
.admin-card:hover { box-shadow: 0 4px 12px rgba(62,45,33,.08); border-color: var(--primary-light); }
.admin-card-head {
  display: grid; grid-template-columns: 48px 1fr auto;
  gap: 12px; align-items: center; margin-bottom: 12px;
}
.admin-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  overflow: hidden;
}
.admin-avatar img { width: 100%; height: 100%; object-fit: cover; }
.admin-info b { display: block; font-size: 14px; color: var(--ink); }
.admin-info span { display: block; font-size: 12px; color: var(--ink-soft); margin: 2px 0; }
.admin-info small { font-size: 11px; color: #b5835a; }
.admin-status {
  padding: 6px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-actions .btn { flex: 1; min-width: 120px; }
.btn-life {
  background: linear-gradient(135deg, var(--primary), #c89468);
  color: #fff; border: none;
  box-shadow: 0 2px 8px rgba(139,90,43,.3);
}
.btn-life:hover { filter: brightness(1.1); }

@media (max-width: 900px) {
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-card-head { grid-template-columns: 40px 1fr; }
  .admin-status { grid-column: 1 / -1; text-align: center; }
}

/* Custom confirm modal (in-app browser friendly) */
.admin-confirm-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .55);
  align-items: center; justify-content: center;
  padding: 20px;
}
.admin-confirm-card {
  background: #fff; border-radius: 16px;
  padding: 24px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.admin-confirm-card h3 { margin: 0 0 12px; font-size: 18px; }
.admin-confirm-card p {
  color: var(--ink-soft); margin-bottom: 20px;
  line-height: 1.5; font-size: 14px;
  white-space: pre-line;
}
.admin-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.admin-confirm-actions .btn { padding: 10px 18px; }

/* ============ SYNC STATUS BADGE ============ */
.sync-status {
  font-size: 11px; color: var(--ink-soft);
  padding: 4px 8px; border-radius: 999px;
  transition: all .2s;
}
.sync-status.ok { background: #dcfce7; color: #166534; }
.sync-status.err { background: #fee2e2; color: #991b1b; }
.sync-status.syncing { background: #dbeafe; color: #1e40af; }

/* ================ HUTANG & PIUTANG ================ */
.hutang-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 18px;
}
.hsum-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border-left: 4px solid #94a3b8;
}
.hsum-card.hsum-piutang { border-left-color: #10b981; background: linear-gradient(135deg, #fff, #ecfdf5); }
.hsum-card.hsum-hutang { border-left-color: #ef4444; background: linear-gradient(135deg, #fff, #fef2f2); }
.hsum-card.hsum-net { border-left-color: var(--accent, #c9a352); background: linear-gradient(135deg, #fff, #fefce8); }
.hsum-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.hsum-value { font-size: 22px; font-weight: 800; color: var(--ink); margin-top: 4px; }
.hsum-card.hsum-piutang .hsum-value { color: #10b981; }
.hsum-card.hsum-hutang .hsum-value { color: #ef4444; }
.hsum-meta { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
@media (max-width: 640px) {
  .hutang-summary { grid-template-columns: 1fr; }
  .hsum-value { font-size: 18px; }
}

.hutang-filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.hutang-filters select {
  padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
  font-size: 13px; color: var(--ink);
}

.hutang-list { display: flex; flex-direction: column; gap: 10px; }
.hutang-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.hutang-card.hutang-overdue {
  background: linear-gradient(135deg, #fff, #fef2f2);
  border-color: #fecaca;
  border-left: 4px solid #ef4444;
}
.hutang-card.hutang-lunas { opacity: .65; }

.hutang-card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.hutang-arrow {
  font-size: 32px; font-weight: 800;
  flex-shrink: 0; line-height: 1;
}
.hutang-info { flex: 1; min-width: 0; }
.hutang-nama { font-size: 16px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.hutang-jenis-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hutang-jenis {
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
}
.hutang-nominal {
  font-size: 18px; font-weight: 900; color: var(--ink);
  white-space: nowrap;
}
.hutang-card-body { padding-left: 44px; margin-bottom: 8px; }
.hutang-meta { font-size: 12px; color: var(--ink-soft); padding: 2px 0; }
.hutang-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-left: 44px;
}

.hbadge {
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  white-space: nowrap;
}
.hbadge-success { background: #dcfce7; color: #166534; }
.hbadge-danger { background: #fee2e2; color: #991b1b; }
.hbadge-warn { background: #fef3c7; color: #92400e; }
.hbadge-info { background: #dbeafe; color: #1e40af; }
.hbadge-neutral { background: #f1f5f9; color: #475569; }

@media (max-width: 640px) {
  .hutang-card-head { flex-wrap: wrap; }
  .hutang-arrow { font-size: 24px; }
  .hutang-nominal { font-size: 16px; }
  .hutang-card-body, .hutang-card-actions { padding-left: 0; }
}
