@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* Gaya aplikasi (login, admin, dashboard): neobrutalism versi tenang agar angka mudah dibaca */
:root {
  --ink: #111;
  --ink-2: #3d3d3d;
  --muted: #6b6b6b;
  --paper: #fff8ec;
  --white: #fff;
  --grid: #e6e1d6;
  --grid-2: #f6f2e9;
  --yellow: #ffd23f;
  --yellow-50: #fff4c2;
  --accent: var(--yellow);
  --accent-50: var(--yellow-50);
  --on-accent: #111;
  --zoom: 1;
  --green: #2ee59d;
  --green-ink: #0a7d4c;
  --green-50: #dcfbeb;
  --red-ink: #c92a5a;
  --red-50: #ffe3ec;
  --pink: #ff6b9d;
  --blue: #74b9ff;
  --blue-50: #e3f0ff;
  --purple: #b892ff;
  --b: 2px solid var(--ink);
  --sh: 4px 4px 0 var(--ink);
  --sh-sm: 3px 3px 0 var(--ink);
  --r: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: clip; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
.display { font-family: 'Archivo Black', sans-serif; font-weight: 400; text-transform: uppercase; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.pos { color: var(--green-ink); } .neg { color: var(--red-ink); }

/* ---------- Tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: var(--b); border-radius: 10px; padding: 11px 18px; font: 700 15px/1.1 'Space Grotesk', sans-serif;
  cursor: pointer; background: var(--white); color: var(--ink); box-shadow: var(--sh-sm); text-decoration: none;
  transition: transform .1s ease, box-shadow .1s ease; white-space: nowrap;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-primary { background: var(--green); }
.btn-yellow { background: var(--accent); }
.btn-ghost { background: var(--white); }
.btn-danger { background: var(--red-50); color: var(--red-ink); }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

label { display: block; font-weight: 700; font-size: 14px; margin: 0 0 6px; }
.input {
  width: 100%; padding: 11px 13px; border: var(--b); border-radius: 10px; font: 500 15px 'Space Grotesk', sans-serif;
  background: var(--white); color: var(--ink); outline: none;
}
.input:focus { box-shadow: 3px 3px 0 var(--green); }
.field { margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.error { color: var(--red-ink); font-size: 14px; font-weight: 600; margin-top: 8px; min-height: 1em; }

.card { background: var(--white); border: var(--b); border-radius: var(--r); box-shadow: var(--sh); }

/* ---------- Navbar (login/admin) ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: var(--b); }
.nav .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Archivo Black'; font-size: 20px; text-decoration: none; }
.brand-logo {
  width: 36px; height: 36px; display: grid; place-items: center; background: var(--green); border: var(--b);
  border-radius: 9px; box-shadow: 2px 2px 0 var(--ink); font-family: 'Archivo Black'; font-size: 18px; transform: rotate(-6deg);
}
.brand small { display: block; font: 600 11px 'Space Grotesk'; color: var(--muted); margin-top: -2px; text-transform: none; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 32px 16px;
  background-image: radial-gradient(rgba(17,17,17,.12) 1.2px, transparent 1.2px); background-size: 22px 22px; }
.auth-card { width: 100%; max-width: 420px; padding: 30px; }
.auth-card h1 { font-family: 'Archivo Black'; text-transform: uppercase; font-weight: 400; font-size: 26px; }
.otp-input { letter-spacing: 12px; text-align: center; font-size: 26px; font-weight: 700; }
.phone-input { display: flex; }
.phone-input span { padding: 11px 13px; border: var(--b); border-right: 0; border-radius: 10px 0 0 10px; background: var(--accent); font-weight: 700; }
.phone-input .input { border-radius: 0 10px 10px 0; }

/* =====================================================================
   DASHBOARD
   ===================================================================== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* Sidebar */
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--white); border-right: var(--b); display: flex; flex-direction: column;
  padding: 18px 14px; gap: 6px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--grid) transparent;
}
.side > * { flex: none; }

.side .brand { padding: 4px 6px 18px; }
.menu-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 2px solid transparent;
  font: 600 15px 'Space Grotesk'; color: var(--ink-2); background: none; cursor: pointer; text-align: left; width: 100%; text-decoration: none;
}
.menu-item .ic { width: 22px; text-align: center; font-size: 17px; }
.menu-item:hover { background: var(--grid-2); }
.menu-item.active { background: var(--accent); border-color: var(--ink); color: var(--ink); box-shadow: var(--sh-sm); }
.menu-item .badge { margin-left: auto; font-size: 11px; background: var(--pink); border: 1.5px solid var(--ink); border-radius: 99px; padding: 0 7px; }
.side-foot { margin-top: auto; border-top: 2px dashed var(--grid); padding-top: 12px; }
.user-chip { display: flex; gap: 10px; align-items: center; padding: 8px; }
.user-chip .ava { width: 36px; height: 36px; flex: none; border: var(--b); border-radius: 50%; background: var(--blue); display: grid; place-items: center; font-weight: 700; }
.user-chip b { display: block; font-size: 14px; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: 12px; }

/* Area konten */
.main { min-width: 0; padding: 22px 28px 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar h1 { font-family: 'Archivo Black'; font-weight: 400; text-transform: uppercase; font-size: 28px; margin: 0; }
.topbar .sub { color: var(--muted); font-weight: 500; margin: 2px 0 0; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Periode */
.period { display: flex; align-items: center; gap: 0; border: var(--b); border-radius: 10px; background: var(--white); box-shadow: var(--sh-sm); overflow: hidden; }
.period button { border: 0; border-right: 2px solid var(--ink); background: none; padding: 8px 13px; font: 600 14px 'Space Grotesk'; cursor: pointer; }
.period button:last-child { border-right: 0; }
.period button.active { background: var(--ink); color: var(--white); }
.period-custom { display: flex; gap: 6px; align-items: center; }
.period-custom .input { width: auto; padding: 6px 8px; font-size: 14px; }

/* Dropdown ekspor */
.dd { position: relative; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 230px; background: var(--white); border: var(--b); border-radius: 10px; box-shadow: var(--sh); padding: 6px; }
.dd-menu a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.dd-menu a small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.dd-menu a:hover { background: var(--accent-50); }

/* Kartu statistik */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat .label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.stat .label i { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 3px; }
.stat .value { font-size: 25px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; }
.stat .foot { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.hl { background: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 18px; }
.panel { padding: 18px 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.chart-box { position: relative; height: 270px; }
.seg { display: inline-flex; border: var(--b); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--white); padding: 6px 12px; font: 600 13px 'Space Grotesk'; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.active { background: var(--ink); color: var(--white); }

.cat-row { margin-bottom: 12px; }
.cat-row .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.bar { height: 12px; border: 2px solid var(--ink); border-radius: 99px; background: var(--grid-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-right: 2px solid var(--ink); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 38px; }

/* ---------- Spreadsheet ---------- */
.sheet-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.sheet-tools .input { width: auto; padding: 8px 12px; font-size: 14px; }
.sheet-tools .search { flex: 1; min-width: 180px; }
.sheet {
  border: var(--b); border-radius: var(--r); background: var(--white); box-shadow: var(--sh); overflow: hidden;
}
.sheet-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 260px; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
table.grid th, table.grid td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); padding: 0; white-space: nowrap; }
table.grid th:last-child, table.grid td:last-child { border-right: 0; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--ink); color: var(--white); text-align: left;
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-right-color: #333; border-bottom: 0;
  cursor: pointer; user-select: none;
}
table.grid thead th.r { text-align: right; }
table.grid thead th .sort { opacity: .5; margin-left: 4px; }
table.grid thead th.sorted .sort { opacity: 1; color: var(--accent); }
table.grid .colnum { position: sticky; left: 0; z-index: 1; width: 46px; min-width: 46px; text-align: center; color: var(--muted); font-size: 12px; background: var(--grid-2); font-weight: 600; }
table.grid thead .colnum { z-index: 3; background: #222; color: #999; cursor: default; }
table.grid tbody tr:nth-child(even) td:not(.colnum) { background: #fcfbf8; }
table.grid tbody tr:hover td:not(.colnum) { background: var(--accent-50); }
table.grid tbody tr.flash td:not(.colnum) { animation: flash 1.2s ease; }
@keyframes flash { from { background: var(--green-50); } }

.cell { display: block; padding: 9px 12px; min-height: 38px; cursor: text; overflow: hidden; text-overflow: ellipsis; }
td.money .cell, td.r .cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
td.note { min-width: 220px; max-width: 360px; }
td.note .cell { white-space: nowrap; }
td.editing { box-shadow: inset 0 0 0 2px var(--green-ink); }
td .cell-input {
  width: 100%; border: 0; outline: none; padding: 9px 12px; min-height: 38px; font: inherit; background: var(--green-50);
}
td.money .cell-input { text-align: right; }
.cat-pill { display: inline-block; font-size: 12.5px; font-weight: 600; border: 1.5px solid var(--ink); border-radius: 99px; padding: 1px 9px; background: var(--white); }
.src { font-size: 12px; color: var(--muted); }
.row-act { display: flex; gap: 2px; padding: 0 6px; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 6px 7px; border-radius: 6px; font-size: 14px; }
.icon-btn:hover { background: var(--red-50); }

/* Baris input baru (seperti baris kosong Excel) */
tr.new-row td { background: var(--blue-50) !important; border-top: 2px solid var(--ink); }
tr.new-row input, tr.new-row select {
  width: 100%; border: 0; background: transparent; padding: 9px 12px; font: 500 14.5px 'Space Grotesk'; outline: none; min-height: 38px;
}
tr.new-row input:focus, tr.new-row select:focus { background: var(--white); box-shadow: inset 0 0 0 2px var(--ink); }
tr.new-row .money input { text-align: right; }
tr.new-row .colnum { background: var(--blue) !important; color: var(--ink); font-size: 16px; }

tfoot td { position: sticky; bottom: 0; background: var(--accent) !important; border-top: 2px solid var(--ink); font-weight: 700; z-index: 1; }
tfoot td .cell { cursor: default; }

/* Tab sheet di bawah tabel (seperti Excel) */
.sheet-tabs { display: flex; gap: 0; border-top: var(--b); background: var(--grid-2); overflow-x: auto; }
.sheet-tabs button {
  border: 0; border-right: 2px solid var(--ink); background: none; padding: 10px 18px; font: 600 14px 'Space Grotesk'; cursor: pointer; white-space: nowrap;
}
.sheet-tabs button.active { background: var(--white); box-shadow: inset 0 -4px 0 var(--green); }
.sheet-tabs .info { margin-left: auto; padding: 10px 14px; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Pivot tahunan */
table.pivot td .cell { cursor: default; }
table.pivot td.section { background: var(--ink-2) !important; color: var(--white); font-weight: 700; padding: 6px 12px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
table.pivot tr.sum td { font-weight: 700; background: var(--grid-2) !important; border-top: 2px solid var(--ink); }
table.pivot tr.net td { background: var(--accent) !important; font-weight: 700; border-top: 2px solid var(--ink); }
table.pivot td.zero .cell { color: #c4bfb3; font-weight: 400; }
table.pivot td.total-col { background: var(--accent-50) !important; border-left: 2px solid var(--ink); }

/* Scan struk */
.scan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.drop {
  border: 2.5px dashed var(--ink); border-radius: var(--r); background: var(--white); min-height: 320px; display: grid; place-items: center;
  text-align: center; padding: 24px; cursor: pointer; transition: background .15s;
}
.drop:hover, .drop.over { background: var(--accent-50); }
.drop .big { font-size: 46px; }
.drop img { max-width: 100%; max-height: 420px; border: var(--b); border-radius: 8px; }
.tips { margin: 14px 0 0; padding-left: 18px; color: var(--ink-2); }
.tips li { margin-bottom: 4px; }
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; border: var(--b); border-radius: 10px; overflow: hidden; }
.type-toggle button { border: 0; padding: 10px; font: 700 14px 'Space Grotesk'; cursor: pointer; background: var(--white); }
.type-toggle button + button { border-left: 2px solid var(--ink); }
.type-toggle button.active[data-v="pemasukan"] { background: var(--green); }
.type-toggle button.active[data-v="pengeluaran"] { background: var(--pink); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--grid); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.cmd-list { display: grid; gap: 0; border: var(--b); border-radius: 10px; overflow: hidden; }
.cmd-list div { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--grid); align-items: center; }
.cmd-list div:last-child { border-bottom: 0; }
.cmd-list code { font: 700 13px 'Space Grotesk'; background: var(--green-50); border: 1.5px solid var(--ink); border-radius: 6px; padding: 2px 8px; min-width: 130px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 60; box-shadow: 4px 4px 0 var(--green); max-width: calc(100vw - 32px); }
.toast button { margin-left: 10px; background: none; border: 0; color: var(--accent); font: 700 14px 'Space Grotesk'; cursor: pointer; text-decoration: underline; }

/* Navigasi bawah (HP) */
.tabbar { display: none; }
.imp-grid { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); }
.imp-grid > * { min-width: 0; }

/* ---------- Responsif ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .scan-grid, .imp-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--white); border-top: var(--b);
  }
  .tabbar button { border: 0; background: none; padding: 8px 2px 10px; font: 600 11px 'Space Grotesk'; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: var(--ink-2); }
  .tabbar button .ic { font-size: 19px; }
  .tabbar button.active { background: var(--accent); color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }
  .topbar h1 { font-size: 22px; }
  .sheet-scroll { max-height: none; }
}
@media (max-width: 560px) {
  .stat .value { font-size: 19px; }
  .stats { gap: 10px; }
  .row-2 { grid-template-columns: 1fr; }
  .auth-card { padding: 22px; }
  .period button { padding: 8px 9px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .spinner { transition: none; animation: none; }
  table.grid tbody tr.flash td { animation: none; }
}

/* ---------- Ikon (Lucide) ---------- */
.lucide { width: 1.15em; height: 1.15em; stroke-width: 2.2; flex: none; vertical-align: -.2em; }
.menu-item .ic { display: grid; place-items: center; }
.menu-item .ic .lucide { width: 19px; height: 19px; }
.tabbar .ic .lucide { width: 21px; height: 21px; }
.empty .big .lucide { width: 42px; height: 42px; stroke-width: 1.8; color: var(--ink-2); }
.ic-box { width: 30px; height: 30px; flex: none; display: inline-grid; place-items: center; border: 2px solid var(--ink); border-radius: 8px; }
.ic-box .lucide { width: 16px; height: 16px; }
.ic-in { background: var(--green-50); color: var(--green-ink); }
.ic-out { background: var(--red-50); color: var(--red-ink); }
.cat-pill .lucide { width: 13px; height: 13px; margin-right: 3px; vertical-align: -.15em; }
.stat .label .ic-box { width: 26px; height: 26px; border-radius: 7px; }
.src { display: inline-flex; align-items: center; gap: 4px; }
.src .lucide { width: 14px; height: 14px; }
.toast { display: flex; align-items: center; gap: 8px; }
.toast .lucide { color: var(--green); }
.dd-menu a .ic-box { background: var(--grid-2); }

/* ---------- Pengaturan: saluran & notifikasi ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings .panel h3 { display: flex; align-items: center; gap: 10px; }
.channel { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--grid); }
.channel:first-of-type { border-top: 0; }
.channel .ic-box { width: 40px; height: 40px; border-radius: 10px; }
.channel .ic-box .lucide { width: 20px; height: 20px; }
.channel b { display: block; }
.channel small { color: var(--muted); }
.channel .btn { margin-left: auto; }
.pill-ok { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; background: var(--green-50); color: var(--green-ink); border: 1.5px solid var(--ink); border-radius: 99px; padding: 1px 8px; margin-left: auto; white-space: nowrap; }
.pill-off { background: var(--grid-2); color: var(--muted); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--grid); cursor: pointer; }
.switch-row:first-child { border-top: 0; }
.switch-row span { flex: 1; font-weight: 600; }
.switch-row small { display: block; font-weight: 500; color: var(--muted); }
.switch { appearance: none; width: 46px; height: 26px; border: 2px solid var(--ink); border-radius: 99px; background: var(--grid-2); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); border: 2px solid var(--ink); transition: transform .15s ease; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
@media (max-width: 1080px) { .settings { grid-template-columns: 1fr; } }

/* =====================================================================
   PREFERENSI TAMPILAN (tema, aksen, ukuran teks, kepadatan, kolom, sidebar)
   ===================================================================== */
:root[data-accent="green"] { --accent: #2ee59d; --accent-50: #dcfbeb; }
:root[data-accent="blue"] { --accent: #74b9ff; --accent-50: #e3f0ff; }
:root[data-accent="pink"] { --accent: #ff8fb1; --accent-50: #ffe3ec; }
:root[data-accent="purple"] { --accent: #c3a6ff; --accent-50: #efe6ff; }

/* Tema gelap */
:root[data-theme="dark"] {
  --ink: #f2ede2; --ink-2: #d9d3c6; --muted: #a8a294;
  --paper: #13120f; --white: #1e1c17; --grid: #3a362d; --grid-2: #27241e;
  --green-50: #133829; --green-ink: #5ff0b4; --red-50: #3d1a25; --red-ink: #ff86aa;
  --blue-50: #172a40; --yellow-50: #3a3213;
  --accent-50: color-mix(in srgb, var(--accent) 22%, #1e1c17);
  color-scheme: dark;
}
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-yellow, :root[data-theme="dark"] .menu-item.active,
:root[data-theme="dark"] .stat.hl, :root[data-theme="dark"] tfoot td, :root[data-theme="dark"] .tabbar button.active,
:root[data-theme="dark"] .type-toggle button.active, :root[data-theme="dark"] .phone-input span, :root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .switch:checked, :root[data-theme="dark"] .menu-item .badge, :root[data-theme="dark"] tr.new-row .colnum,
:root[data-theme="dark"] table.pivot tr.net td, :root[data-theme="dark"] .seg-pick button.active { color: var(--on-accent); }
:root[data-theme="dark"] .stat.hl .foot, :root[data-theme="dark"] tfoot td .pos, :root[data-theme="dark"] tfoot td .neg { color: #3b3320; }
:root[data-theme="dark"] .stat.hl .value { color: #111 !important; }
:root[data-theme="dark"] table.grid thead th { background: #000; color: var(--ink); border-right-color: #2b2822; }
:root[data-theme="dark"] table.grid thead .colnum { background: #000; color: var(--muted); }
:root[data-theme="dark"] table.grid tbody tr:nth-child(even) td:not(.colnum) { background: #221f1a; }
:root[data-theme="dark"] table.pivot td.section { background: #000 !important; }
:root[data-theme="dark"] table.pivot td.zero .cell { color: #4d483d; }
:root[data-theme="dark"] .toast { background: #000; border: 2px solid var(--ink); }
:root[data-theme="dark"] .bar > i, :root[data-theme="dark"] .switch::after { border-color: #111; }
:root[data-theme="dark"] .auth-wrap { background-image: radial-gradient(rgba(255,255,255,.08) 1.2px, transparent 1.2px); }

/* Ukuran teks (memperbesar seluruh isi) */
.app, .tabbar, .auth-card { zoom: var(--zoom); }

/* Kepadatan ringkas */
:root[data-density="compact"] .cell, :root[data-density="compact"] td .cell-input,
:root[data-density="compact"] tr.new-row input, :root[data-density="compact"] tr.new-row select { padding: 5px 10px; min-height: 30px; }
:root[data-density="compact"] table.grid { font-size: 13.5px; }
:root[data-density="compact"] .stat { padding: 12px 14px; }
:root[data-density="compact"] .stat .value { font-size: 21px; }
:root[data-density="compact"] .panel { padding: 14px 16px; }
:root[data-density="compact"] .stats, :root[data-density="compact"] .grid-2 { gap: 12px; margin-bottom: 12px; }
:root[data-density="compact"] .main { padding-top: 16px; }

/* Kolom tersembunyi di Buku Kas */
#sheet.hide-category [data-col="category"], #sheet.hide-saldo [data-col="saldo"], #sheet.hide-source [data-col="source"] { display: none; }

/* Sidebar ciut */
.app.collapsed { grid-template-columns: 76px 1fr; }
.app.collapsed .side { padding: 18px 10px; align-items: center; }
.app.collapsed .side .brand > span:last-child, .app.collapsed .menu-label, .app.collapsed .menu-item .lbl,
.app.collapsed .menu-item .badge, .app.collapsed .user-chip > div:last-child { display: none; }
.app.collapsed .menu-item { justify-content: center; padding: 10px; width: 48px; }
.app.collapsed .side .brand { padding: 4px 0 18px; }
.collapse-btn { margin-top: 0; width: auto; flex: none; padding: 9px; }
.collapse-btn .lbl { display: none; }
.side-foot { display: flex; align-items: center; gap: 4px; }
.side-foot .user-chip { flex: 1; min-width: 0; }
.user-chip > div:last-child { min-width: 0; }
.user-chip b, .user-chip small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app.collapsed .side-foot { flex-direction: column; }
.app.collapsed .collapse-btn .lucide { transform: scaleX(-1); }

/* layar pendek (laptop 13"): menu lebih rapat agar semua item muat tanpa menggulir */
@media (max-height: 900px) {
  .side { gap: 2px; padding-top: 14px; }
  .side .brand { padding-bottom: 10px; }
  .menu-item { padding: 7px 12px; font-size: 14.5px; }
  .menu-label { padding: 8px 10px 2px; }
  .side-foot { padding-top: 6px; }
  .user-chip { padding: 4px 8px; }
  .app.collapsed .menu-item { padding: 7px; }
}
@media (max-height: 780px) {
  .side { gap: 1px; padding-top: 10px; padding-bottom: 8px; }
  .side .brand { padding-bottom: 4px; }
  .menu-item { padding: 6px 12px; }
  .app.collapsed .menu-item { padding: 6px; }
  .menu-label { padding: 6px 10px 1px; }
}
/* Panel tampilan */
.disp { display: grid; gap: 14px; }
.disp-row > label { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.seg-pick { display: flex; border: var(--b); border-radius: 10px; overflow: hidden; }
.seg-pick button { flex: 1; border: 0; background: var(--white); color: var(--ink); padding: 8px 6px; font: 600 13px 'Space Grotesk'; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; justify-content: center; }
.seg-pick button + button { border-left: 2px solid var(--ink); }
.seg-pick button.active { background: var(--accent); }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: var(--b); cursor: pointer; }
.swatches button.active { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.col-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.col-checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; border: 2px solid var(--ink); border-radius: 99px; padding: 4px 12px; cursor: pointer; margin: 0; text-transform: none; letter-spacing: 0; color: var(--ink); }
.col-checks input { accent-color: var(--ink); }
#display-menu { width: 320px; padding: 16px; }

/* ---------- Buku Kas jadi kartu di layar kecil ---------- */
@media (max-width: 820px) {
  #view-buku .sheet-scroll { overflow: visible; }
  .sheet-scroll { min-height: 0; }
  #sheet thead { display: none; }
  #sheet, #sheet tbody, #sheet tfoot { display: block; }
  #sheet tr { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 10px 12px; border-bottom: 2px solid var(--grid); position: relative; }
  #sheet td { display: block; border: 0 !important; background: none !important; }
  #sheet td .cell, #sheet td .cell-input { padding: 2px 0; min-height: 0; }
  #sheet td.colnum { display: none; }
  #sheet #rows td[data-f="note"] { grid-column: 1; grid-row: 1; font-weight: 700; font-size: 15.5px; max-width: none; min-width: 0; }
  #sheet #rows td[data-f="in"], #sheet #rows td[data-f="out"] { grid-column: 2; grid-row: 1; }
  #sheet #rows td[data-f="in"]:has(.cell:empty), #sheet #rows td[data-f="out"]:has(.cell:empty) { display: none; }
  #sheet #rows td[data-f="date"] { grid-column: 1; grid-row: 2; font-size: 13px; color: var(--muted); }
  #sheet #rows td[data-col="category"] { grid-column: 1; grid-row: 3; }
  #sheet #rows td[data-col="saldo"] { grid-column: 2; grid-row: 2; font-size: 12.5px; color: var(--muted); }
  #sheet #rows td[data-col="saldo"] .cell { font-weight: 500; }
  #sheet #rows td[data-col="source"] { grid-column: 2; grid-row: 3; text-align: right; }
  #sheet #rows td:last-child { position: absolute; right: 2px; bottom: 2px; }
  #sheet #rows td[data-col="source"] { padding-right: 34px; }
  #sheet #rows tr:hover td { background: none !important; }
  #sheet tbody tr:nth-child(even) { background: var(--grid-2); }
  #sheet tr.new-row { grid-template-columns: 1fr 1fr; gap: 8px; background: var(--blue-50); }
  #sheet tr.new-row td { grid-column: span 2; }
  #sheet tr.new-row td.money { grid-column: span 1; }
  #sheet tr.new-row input, #sheet tr.new-row select { border: 2px solid var(--ink); border-radius: 8px; background: var(--white); }
  #sheet tr.new-row td.money { display: flex; flex-direction: column; min-width: 0; }
  #sheet tr.new-row td.money::before { content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--muted); }
  #sheet tfoot tr { grid-template-columns: 1fr 1fr 1fr; background: var(--accent); }
  #sheet tfoot td[data-col="tf-label"] { grid-column: 1 / -1; }
  #sheet tfoot td:empty { display: none; }
  .sheet-tabs .info { display: none; }
}
:root[data-theme="dark"] .stat.hl .ic-box { background: #fff !important; color: #111; border-color: #111; }
:root[data-theme="dark"] .stat.hl { border-color: #111; }

/* =====================================================================
   PERENCANAAN: anggaran, utang/piutang, invoice, target, pengingat, analisis
   ===================================================================== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.bcard { padding: 16px 18px; display: grid; gap: 8px; }
.bcard .top { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.bcard .top .icon-btn { margin-left: auto; }
.bcard .big { font-size: 22px; font-weight: 700; }
.bcard .bar { height: 14px; }
.bcard.warn { background: var(--accent-50); }
.bcard.over { background: var(--red-50); }

.insight .ins-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.insight .ins-grid div { border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; }
.insight .ins-grid small { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.insight .ins-grid b { font-size: 18px; }
.insight .ins-grid em { font-style: normal; font-size: 12.5px; font-weight: 700; }
.ins-tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.ins-tips li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; background: var(--grid-2); border-radius: 8px; }
.ins-tips li .lucide { margin-top: 3px; color: var(--green-ink); }

.due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; border: 1.5px solid var(--ink); border-radius: 99px; padding: 1px 8px; white-space: nowrap; }
.due.late { background: var(--red-50); color: var(--red-ink); }
.due.soon { background: var(--accent-50); }
.due.ok { background: var(--green-50); color: var(--green-ink); }
.due.none { color: var(--muted); border-style: dashed; }
.row-btns { display: flex; gap: 6px; padding: 0 8px; align-items: center; }
.pay-inline { display: flex; gap: 6px; padding: 4px 8px; }
.pay-inline .input { padding: 6px 10px; width: 130px; font-size: 14px; }

.iv-row { display: grid; grid-template-columns: 1fr 64px 120px 32px; gap: 6px; margin-bottom: 6px; }
.iv-row .input { padding: 8px 10px; font-size: 14px; }

.goal { border: 2px solid var(--ink); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; display: grid; gap: 6px; }
.goal .top { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.goal .top span { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 600; }
.goal .bar { height: 14px; }
.goal .act { display: flex; gap: 6px; flex-wrap: wrap; }
.goal .act .input { width: 130px; padding: 6px 10px; font-size: 14px; }
.goal.done { background: var(--green-50); }
.rem { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--grid); }
.rem:first-child { border-top: 0; }
.rem .day { width: 46px; height: 46px; flex: none; border: 2px solid var(--ink); border-radius: 10px; display: grid; place-items: center; text-align: center; line-height: 1; background: var(--accent); color: var(--on-accent); }
.rem .day small { display: block; font-size: 10px; font-weight: 700; }
.rem .day b { font-size: 18px; }
.rem > div:nth-child(2) { flex: 1; }
.rem small.muted { display: block; }

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: grid; gap: 4px; justify-items: start; text-align: left; padding: 16px; font: inherit; color: inherit; cursor: pointer; }
.tile .ic-box { width: 40px; height: 40px; margin-bottom: 6px; }
.tile small { color: var(--muted); }

@media (max-width: 1080px) {
  .insight .ins-grid { grid-template-columns: 1fr 1fr; }
  #view-anggaran .grid-2, #debt-pane, #invoice-pane, #view-target .grid-2 { grid-template-columns: 1fr !important; }
}
@media (max-width: 820px) {
  #view-utang .stats { grid-template-columns: 1fr !important; }
  #debt-table, #invoice-table { font-size: 13.5px; }
}

/* ---------- Laba rugi, dompet, produk ---------- */
.pl-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.pl-table td { padding: 8px 4px; border-bottom: 1px solid var(--grid); }
.pl-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-table .pl-head td { font-weight: 700; padding-top: 14px; }
.pl-table .pl-item td { color: var(--ink-2); padding-left: 22px; font-size: 14px; }
.pl-table .pl-item td.num { padding-left: 4px; }
.pl-table .pl-item .lucide { width: 14px; height: 14px; margin-right: 4px; color: var(--muted); }
.pl-table .pl-sum td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: var(--grid-2); }
.pl-table .pl-net td { font-size: 17px; background: var(--accent); color: var(--on-accent); }
.pl-table .pl-net td.pos, .pl-table .pl-net td.neg { color: var(--on-accent); }
#sheet.hide-wallet [data-col="wallet"] { display: none; }
tr.new-row select#n-wallet { min-width: 110px; }
@media (max-width: 820px) {
  #sheet #rows td[data-col="wallet"] { grid-column: 1; grid-row: 4; font-size: 12.5px; color: var(--muted); }
  #sheet tr.new-row td[data-col="wallet"] { grid-column: span 2; }
  #view-labarugi .grid-2, #view-dompet .grid-2, #view-produk .grid-2 { grid-template-columns: 1fr !important; }
  #view-produk .stats { grid-template-columns: 1fr !important; }
}

/* ---------- Langganan ---------- */
.plan-banner { margin: -4px 0 16px; }
.plan-banner .pb { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: var(--b); border-radius: 10px; background: var(--accent-50); box-shadow: var(--sh-sm); flex-wrap: wrap; }
.plan-banner .pb span { flex: 1; min-width: 200px; }
.plan-banner .pb-off { background: var(--red-50); }
.lock-ic { margin-left: auto; color: var(--muted); display: inline-flex; }
.lock-ic .lucide { width: 14px; height: 14px; }
.app.collapsed .lock-ic, .tabbar .lock-ic { display: none; }
.sub-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.sub-ic { width: 52px; height: 52px; border-radius: 14px; background: var(--accent); color: var(--on-accent); }
.sub-ic .lucide { width: 26px; height: 26px; }
.sub-name { font-family: 'Archivo Black'; text-transform: uppercase; font-size: 26px; line-height: 1.1; }
.sub-quota { min-width: 220px; display: grid; gap: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.plan-card { padding: 22px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.plan-card h3 { font-family: 'Archivo Black'; text-transform: uppercase; font-weight: 400; font-size: 22px; margin: 0; }
.plan-card.popular { background: var(--accent-50); box-shadow: 6px 6px 0 var(--ink); }
.plan-flag { position: absolute; top: -13px; right: 14px; background: var(--pink); border: 2px solid var(--ink); border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 700; color: #111; }
.plan-price { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.plan-price small { font-size: 14px; color: var(--muted); font-weight: 600; }
.plan-card ul { list-style: none; padding: 0; margin: 8px 0 14px; display: grid; gap: 7px; flex: 1; }
.plan-card li { display: flex; gap: 8px; align-items: flex-start; font-size: 14.5px; }
.plan-card li .lucide { color: var(--green-ink); margin-top: 3px; }
@media (max-width: 1280px) { .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .plan-grid { grid-template-columns: 1fr; } }
.locked-card { max-width: 620px; margin: 10px auto; text-align: center; display: grid; justify-items: center; gap: 10px; padding: 34px 26px; }
.locked-card .ic-box .lucide { width: 30px; height: 30px; }
.locked-card h2 { font-size: 28px; margin: 6px 0 0; }
.locked-card p { color: var(--ink-2); margin: 0; }
.locked-list { list-style: none; padding: 0; margin: 8px 0 14px; display: grid; gap: 8px; text-align: left; }
.locked-list li { display: flex; gap: 10px; align-items: center; font-weight: 600; }

/* QRIS */
.qris-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start; }
.qris-img { width: 100%; border: var(--b); border-radius: 12px; background: #fff; box-shadow: var(--sh-sm); }
.qris-amount { font-size: 30px; font-weight: 800; margin: 4px 0 8px; }
.qris-wrap .btn { margin: 4px 6px 4px 0; }
@media (max-width: 560px) { .qris-wrap { grid-template-columns: 1fr; } .qris-img { max-width: 280px; margin: 0 auto; display: block; } }


/* =====================================================================
   Ramah semua perangkat (HP kecil 320px s.d. tablet)
   ===================================================================== */
.input { max-width: 100%; box-sizing: border-box; }
.main, .view, .card, .panel { min-width: 0; }
.grid-2 > *, .settings > *, .scan-grid > *, .imp-grid > *, .stats > *, .cards-grid > * { min-width: 0; }
.rc-sub { display: none; }
.rc-text { min-width: 0; }

/* Layar sentuh: font isian 16px agar iPhone tidak memperbesar layar saat mengetik; tombol mudah ditekan */
@media (max-width: 820px) {
  .input, select.input, textarea.input { font-size: 16px; }
  .sheet-tools .input, .period-custom .input, .pay-inline .input, .iv-row .input, .goal .act .input { font-size: 16px; }
  .btn-sm { min-height: 36px; }
  .icon-btn { min-width: 36px; min-height: 36px; }
  .tabbar { padding-bottom: env(safe-area-inset-bottom); }
  .tabbar button { min-height: 52px; }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
  .stat .value { white-space: nowrap; }
}

@media (max-width: 560px) {
  .main { padding-top: 12px; }
  .topbar { gap: 10px; }
  .topbar h1 { font-size: 20px; }
  .card.panel, .panel { padding: 14px; }

  /* Form sebaris (target, pengingat, tim, kategori) jadi bertumpuk penuh */
  .inline-form { flex-wrap: wrap; }
  .inline-form > .input, .inline-form > select, .inline-form > input {
    flex: 1 1 100% !important; max-width: none !important; min-width: 0 !important; width: 100% !important;
  }
  .inline-form > .btn { flex: 1 1 100%; justify-content: center; }

  /* Kartu angka */
  .stat { padding: 12px 14px; }
  .stat .value { font-size: clamp(16px, 5.2vw, 20px); }

  /* Transaksi terbaru: satu baris per transaksi, nominal selalu terlihat */
  #recent .rc-date, #recent .rc-cat { display: none; }
  #recent .rc-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
  #recent td.note { width: 100%; }
  #recent .rc-text { overflow: hidden; text-overflow: ellipsis; }
  #recent td.money { white-space: nowrap; }

  /* Utang & piutang: tabel jadi kartu */
  #debt-table thead { display: none; }
  #debt-table, #debt-table tbody { display: block; }
  #debt-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 2px solid var(--grid); }
  #debt-table td { display: block; border: 0 !important; padding: 0 !important; min-width: 0; }
  #debt-table td.colnum { display: none; }
  #debt-table td.d-name { grid-column: 1; }
  #debt-table td.money:nth-of-type(3) { grid-column: 2; grid-row: 1; text-align: right; }
  #debt-table td.money:nth-of-type(4) { display: none; }
  #debt-table td.note { grid-column: 1 / -1; }
  #debt-table td:last-child { grid-column: 1 / -1; margin-top: 6px; }
  #debt-table .row-btns { justify-content: flex-start; flex-wrap: wrap; }
  #debt-table .empty, .empty { white-space: normal; }
  #debt-table td[colspan] { grid-column: 1 / -1; }

  .recent-table { table-layout: fixed; width: 100%; }
  #recent td.money { width: 112px; }
  #sheet tr.new-row td { min-width: 0; }
  #sheet tr.new-row input, #sheet tr.new-row select { width: 100%; min-width: 0; box-sizing: border-box; }
  .btn-wrap { white-space: normal; max-width: 100%; text-align: left; }

  /* Pilihan segmen (tab utang, durasi paket, tampilan) tidak melebar */
  .seg-pick button { min-width: 0; padding: 8px 4px; font-size: 13px; white-space: normal; line-height: 1.2; flex: 1 1 0; }
  .seg-pick button .lucide { width: 14px; height: 14px; flex: none; }
  .period { flex-wrap: wrap; }
  .top-actions { flex-wrap: wrap; gap: 8px; }
  #display-menu { width: min(320px, calc(100vw - 32px)); right: 0; left: auto; }

  /* Langganan & QRIS */
  .plan-cycle { max-width: none !important; }
  .qris-amount { font-size: 26px; }
}

/* HP sangat kecil (iPhone SE 1st gen, Android 320px) */
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr !important; }
  .main { padding-left: 12px; padding-right: 12px; }
  .tabbar button { font-size: 10px; padding-left: 0; padding-right: 0; }
  .period button { padding: 7px 7px; font-size: 12px; }
  .tile-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .seg-pick button { font-size: 12px; padding: 8px 2px; gap: 3px; }
  .insight .ins-grid b { font-size: 15px; }
  .insight .ins-grid div { padding: 8px 9px; }
}
.insight .ins-grid > div { min-width: 0; }
.insight .ins-grid b { display: block; overflow-wrap: anywhere; }

/* Tablet (portrait & landscape) */
@media (min-width: 821px) and (max-width: 1080px) {
  .main { padding: 20px; }
  .side { padding: 14px 10px; }
}
