/* ============================================================
   ArusKu — styles.css
   Dark mode (default) dengan warna dasar biru + mode terang.
   Mobile-first, ringan, tanpa framework.
   ============================================================ */

:root {
  --bg: #0a1830;
  --bg-soft: #0d1f3d;
  --card: #10244a;
  --card-2: #0c1c38;
  --border: rgba(120, 170, 255, 0.14);
  --text: #e9f1ff;
  --muted: #8fa8cf;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --accent: #38bdf8;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --amber: #fbbf24;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(2, 8, 30, 0.45);
  --tabbar-h: 64px;
}

[data-theme="light"] {
  --bg: #eaf1fd;
  --bg-soft: #dfe9fb;
  --card: #ffffff;
  --card-2: #f3f7ff;
  --border: rgba(30, 64, 175, 0.12);
  --text: #10254d;
  --muted: #5b7299;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --primary-soft: rgba(29, 78, 216, 0.1);
  --accent: #0284c7;
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.1);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.08);
  --shadow: 0 8px 24px rgba(30, 64, 175, 0.12);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--primary) transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #123064 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

[data-theme="light"] body {
  background: linear-gradient(180deg, #dbe7fd 0%, var(--bg) 320px) fixed, var(--bg);
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; box-shadow: var(--shadow); }
.brand div { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 1.15rem; letter-spacing: 0.2px; }
.brand span { font-size: 0.75rem; color: var(--muted); }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Month bar ---------- */
.monthbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px 2px;
  max-width: 980px;
  margin: 0 auto;
}

.monthbar input[type="month"] {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 1rem;
  color-scheme: dark;
}
[data-theme="light"] .monthbar input[type="month"] { color-scheme: light; }

/* ---------- Layout ---------- */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--tabbar-h) + 96px);
}

.view { display: flex; flex-direction: column; gap: 14px; animation: fadeUp 0.25s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hint { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: 0.88rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- Summary cards ---------- */
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sum {
  border-radius: var(--radius);
  padding: 12px 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  box-shadow: var(--shadow);
  min-width: 0;
}
.sum .lbl { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum .val { font-size: clamp(0.85rem, 3.4vw, 1.15rem); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum.in .val { color: var(--green); }
.sum.out .val { color: var(--red); }
.sum.net .val { color: var(--accent); }

/* ---------- Budget bars (dashboard) ---------- */
.budget-row { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.budget-row:last-child { border-bottom: 0; }
.budget-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.budget-top .nm { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pct-badge {
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  background: var(--primary-soft); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.bar { height: 10px; border-radius: 999px; background: rgba(140, 170, 220, 0.16); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.4s ease; }
.bar.over > i { background: linear-gradient(90deg, #ef4444, var(--amber)); }
.budget-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 0.8rem; color: var(--muted); }
.budget-meta .over-t { color: var(--red); font-weight: 700; }
.budget-meta .ok-t { color: var(--green); }

/* ---------- Donut ---------- */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut .center-t { font-size: 15px; font-weight: 800; fill: var(--text); }
.donut .center-s { font-size: 9.5px; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 7px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.legend .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .vl { font-weight: 700; }
.legend .pc { color: var(--muted); font-size: 0.75rem; width: 44px; text-align: right; }

/* ---------- Transaction list ---------- */
.filters { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 8px; }
.chips button, .chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: 0.85rem; cursor: pointer;
}
.chips button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.searchrow { display: flex; gap: 8px; }
.searchrow input, .searchrow select {
  flex: 1; min-width: 0; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; font-size: 0.9rem;
}
.searchrow select { flex: 0 1 170px; }

.txgroup { margin-bottom: 4px; }
.txgroup > h3 { font-size: 0.8rem; color: var(--muted); margin: 14px 2px 6px; font-weight: 600; }
.txrow {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 12px; margin-bottom: 8px; cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.txrow:active { transform: scale(0.985); }
.txic {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800;
}
.txic.out { background: var(--red-soft); color: var(--red); }
.txic.in { background: var(--green-soft); color: var(--green); }
.txmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.txmain strong { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txmain span { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txamt { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.txamt.out { color: var(--red); }
.txamt.in { color: var(--green); }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .big { font-size: 2.2rem; margin-bottom: 8px; }
.empty p { margin: 6px 0 14px; }

/* ---------- Budget editor ---------- */
.brow {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "dot name del" "slider slider slider" "info info info";
  gap: 6px 10px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px dashed var(--border);
}
.brow:last-of-type { border-bottom: 0; }
.brow .dot { grid-area: dot; width: 16px; height: 16px; cursor: pointer; }
.brow .bname {
  grid-area: name; background: transparent; border: 0; border-bottom: 1px dashed transparent;
  color: var(--text); font-size: 0.98rem; font-weight: 700; padding: 4px 2px; min-width: 0; width: 100%;
}
.brow .bname:focus { outline: none; border-bottom-color: var(--primary); }
.brow .bdel { grid-area: del; }
.brow .bslider { grid-area: slider; width: 100%; accent-color: var(--primary); height: 28px; cursor: pointer; }
.brow .binfo { grid-area: info; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.bnum { display: flex; align-items: center; gap: 4px; }
.bnum input {
  width: 64px; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px; font-size: 0.9rem; text-align: right; font-weight: 700;
}
.bamt { font-weight: 700; color: var(--accent); }

.addrow { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.addrow input {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; font-size: 0.9rem;
}
.addrow input[name="newName"] { flex: 2; min-width: 140px; }
.addrow input[name="newPct"] { flex: 0 1 80px; }

.howto { margin: 6px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.88rem; display: flex; flex-direction: column; gap: 6px; }

/* ---------- History ---------- */
.hist-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; color: var(--text); box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.hist-card:active { transform: scale(0.99); }
.hist-card .hm { font-weight: 800; margin-bottom: 8px; font-size: 1rem; }
.hist-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 0.8rem; }
.hist-grid .hl { color: var(--muted); font-size: 0.7rem; }
.hist-grid .hv { font-weight: 700; font-size: 0.92rem; }
.hv.pos { color: var(--green); } .hv.neg { color: var(--red); } .hv.neu { color: var(--accent); }

.setting-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer; color: var(--text);
  background: var(--card); transition: transform 0.1s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--primary-strong), var(--primary)); border-color: transparent; color: #fff; }
.btn.danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 0.8rem; border-radius: 10px; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 0.85rem; font-weight: 600; cursor: pointer; padding: 4px; }

.icon-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.bdel { width: 30px; height: 30px; font-size: 1rem; border-radius: 10px; color: var(--muted); }

/* ---------- Tab bar & FAB ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar button {
  flex: 1; background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 0.68rem; cursor: pointer; font-weight: 600;
}
.tabbar button .ti { font-size: 1.3rem; }
.tabbar button.active { color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 40;
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  font-size: 2rem; line-height: 1; color: #fff;
  background: linear-gradient(135deg, var(--primary-strong), var(--accent));
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease;
}
.fab:active { transform: scale(0.92) rotate(90deg); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 8, 22, 0.65);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 520px;
  max-height: 92vh; overflow-y: auto;
  animation: sheetUp 0.25s ease;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 14px; font-size: 1.1rem; }

.seg { display: flex; background: var(--bg-soft); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button {
  flex: 1; border: 0; background: none; color: var(--muted); border-radius: 9px;
  padding: 9px; font-size: 0.9rem; font-weight: 700; cursor: pointer;
}
.seg button.active[data-type="out"] { background: var(--red-soft); color: var(--red); }
.seg button.active[data-type="in"] { background: var(--green-soft); color: var(--green); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.field input, .field select {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 13px; font-size: 1rem; font-weight: 500; color-scheme: dark;
}
[data-theme="light"] .field input, [data-theme="light"] .field select { color-scheme: light; }
.field input:focus, .field select:focus { outline: 2px solid var(--primary); border-color: transparent; }
#fAmount { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.5px; }

.modal-actions { display: flex; gap: 10px; margin-top: 6px; align-items: center; }
.modal-actions .spacer { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 90px);
  z-index: 80; background: var(--primary-strong); color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap; max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
  animation: fadeUp 0.2s ease;
}
.toast[hidden] { display: none; }

/* ---------- Sync ---------- */
#syncDot { font-size: 1rem; }
#syncDot[data-state="syncing"] { animation: syncPulse 1s ease-in-out infinite; }
@keyframes syncPulse { 50% { transform: scale(1.18); opacity: 0.65; } }

/* ---------- Desktop ---------- */
@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 22px; border-bottom: 1px solid var(--border); }
  .cards3 { gap: 14px; }
  .brow {
    grid-template-columns: auto 200px 1fr 150px 110px auto;
    grid-template-areas: "dot name slider num info del";
  }
  .brow .binfo { flex-direction: column; align-items: flex-end; gap: 2px; }
  .donut-wrap { flex-wrap: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Layar login / setup admin (multi-user) ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 800px at 50% -10%, #12305e 0%, var(--bg) 60%);
}
.login-screen[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.login-card h1 { font-size: 1.25rem; margin: 12px 0 6px; }
.login-card .field { text-align: left; }
.login-err {
  color: var(--red); font-size: 0.82rem; font-weight: 600;
  background: var(--red-soft); border-radius: 10px; padding: 8px 12px;
}
.login-err[hidden] { display: none; }

/* ---------- Panel admin & daftar user ---------- */
.badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(140, 170, 220, 0.16); color: var(--muted);
  vertical-align: middle;
}
.badge.admin { background: rgba(56, 189, 248, 0.18); color: var(--primary); }
.badge.off { background: var(--red-soft); color: var(--red); }
.admin-panel { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.admin-panel h3 { font-size: 0.95rem; margin: 0 0 10px; }
.admin-panel .input, .admin-panel select.input {
  background: var(--bg-soft, rgba(140,170,220,.08));
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 0.85rem; color: var(--text);
}
.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 0.85rem; flex-wrap: wrap;
}
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
