/* =========================================================
   Kas UMKM — gaya tampilan bersih & profesional
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #F4F5F7;
  --surface: #ffffff;
  --line: #E4E7EC;
  --line-strong: #D0D5DD;
  --ink: #101828;
  --ink-2: #475467;
  --muted: #667085;
  --primary: #101828;
  --primary-hover: #1D2939;
  --accent: #2563EB;
  --in: #0E9F6E;
  --in-soft: #E7F7F0;
  --out: #E02424;
  --out-soft: #FDEEEE;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-20 { margin-bottom: 20px; }
.tone-in { color: var(--in); }
.tone-out { color: var(--out); }
.tone-ink { color: var(--ink); }

/* ---------------- Top bar ---------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-in {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding-top: 8px;
  padding-bottom: 8px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }
.mainnav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
}
.mainnav a:hover { background: #F2F4F7; text-decoration: none; }
.mainnav a.active { background: #EEF2F6; color: var(--ink); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.who em { font-style: normal; }

/* ---------------- Layout ---------------- */
.page { padding: 32px 0 64px; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-title { font-size: 24px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 20px; }
.grid-2 .card + .card { margin-top: 0; }
.card-title { font-size: 16px; margin-bottom: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.card-head .card-title { margin-bottom: 0; }
.card-head.mt-24 { margin-top: 26px; }

/* ---------------- Stat cards ---------------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 680; letter-spacing: -.02em; }
.stat-note { font-size: 12px; color: var(--muted); }
.mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink-2); }
.btn-ghost:hover { background: #F9FAFB; }
.btn-danger { background: var(--surface); border-color: #FDA29B; color: #B42318; }
.btn-danger:hover { background: #FEF3F2; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.is-disabled { opacity: .45; pointer-events: none; }

/* ---------------- Forms ---------------- */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
input:disabled { background: #F9FAFB; color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.inline input[type="text"] { width: 140px; padding: 6px 9px; font-size: 13px; }
.inline-add { display: flex; gap: 8px; margin-bottom: 14px; }

.segmented { display: flex; gap: 10px; }
.seg { flex: 1; position: relative; }.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  text-align: center;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  background: #fff;
}
.seg-in input:checked + span { border-color: #6CD9AE; background: var(--in-soft); color: #05603A; }
.seg-out input:checked + span { border-color: #F6A9A9; background: var(--out-soft); color: #912018; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
  background: #FAFBFC;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.field-btn { justify-content: flex-end; }
.field[hidden] { display: none; }

/* ---------------- Pemilih periode ---------------- */
.period-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.period-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.period-modes .seg { flex: 0 0 auto; min-width: 96px; }
.period-modes .seg span { padding: 9px 14px; font-size: 13px; }
.seg-plain input:checked + span { border-color: #98A2B3; background: #EEF2F6; color: var(--ink); }
.period-extra { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.period-field { display: flex; flex-direction: column; gap: 5px; }
.period-field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.period-field select, .period-field input[type="date"] { padding: 8px 10px; font-size: 13px; }
.period-field[hidden] { display: none; }
.period-info { display: flex; flex-direction: column; gap: 2px; padding-bottom: 2px; }
.period-info span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.period-info strong { font-size: 14px; white-space: nowrap; }

/* ---------------- Tab di area Laporan ---------------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.tabs a {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------- Laporan per kategori ---------------- */
.filters-kat { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
.table-kat .cek-col { width: 58px; text-align: center; }
.table-kat .cek-col input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.table-kat .ck-label { display: inline-flex; align-items: baseline; gap: 8px; cursor: pointer; }
.table-kat .row-kat td { border-top: 1px solid var(--line-strong); background: #FCFCFD; }
.table-kat .row-sub td:first-child { padding-left: 12px; }
.table-kat .row-sub .ck-label { color: var(--ink-2); }
.table-kat tr:hover td { background: #F9FBFF; }

.pilih-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #F5F8FF;
  border: 1px solid #D6E2FF;
  border-radius: var(--radius-sm);
}
.chip-pilih { background: #fff; }
.chip-pilih .tag { margin-right: 6px; }
.chip-x { text-decoration: none; }

/* ---------------- Table ---------------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 1px solid var(--line); }
.table tbody tr:hover td { background: #FCFCFD; }
.table tfoot th { padding: 12px; border-bottom: 0; border-top: 1px solid var(--line-strong); font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.table .amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.row-active td { background: #F5F8FF; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 6px;
}
.tag-in { background: var(--in-soft); color: #05603A; }
.tag-out { background: var(--out-soft); color: #912018; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #F2F4F7;
  color: var(--ink-2);
}
.badge-owner { background: #EEF4FF; color: #175CD3; }

/* ---------------- Chart ---------------- */
.chart { display: flex; align-items: flex-end; gap: 16px; height: 232px; padding-top: 8px; }
.chart-group { flex: 1; display: flex; flex-direction: column; gap: 8px; height: 100%; min-width: 0; }
.chart-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 5px; min-height: 0; }
.chart-bar { width: 100%; max-width: 26px; border-radius: 6px 6px 0 0; min-height: 2px; }
.chart-bar.in { background: #12B76A; }
.chart-bar.out { background: #F04438; }
.chart-x { text-align: center; font-size: 12px; color: var(--muted); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot.x-in { background: #12B76A; }
.dot.x-out { background: #F04438; margin-left: 8px; }

.catlist { display: flex; flex-direction: column; gap: 14px; }
.catrow { display: flex; flex-direction: column; gap: 6px; }
.cat-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.track { height: 6px; border-radius: 999px; background: #F2F4F7; overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 999px; }
.fill-in { background: #12B76A; }
.fill-out { background: #F04438; }

.katlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.katlist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.katlist li:last-child { border-bottom: 0; }
.kat-name { flex: 1; font-weight: 550; }

/* ---- Kategori + sub-kategori (Pengaturan) ---- */
.katlist { display: block; }
.kategori-blok { padding: 14px 0; border-bottom: 1px solid var(--line); }
.kategori-blok:first-child { padding-top: 0; }
.kategori-blok:last-child { border-bottom: 0; padding-bottom: 0; }
.kat-head { display: flex; align-items: center; gap: 12px; }
.sub-area { margin: 10px 0 0 0; padding-left: 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #FAFBFC;
  font-size: 13px;
  line-height: 1.5;
}
.chip-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 50%;
}
.chip-x:hover { background: var(--out-soft); color: var(--out); }
.chip-ubah { font-size: 13px; }
.chip-ubah:hover { background: #EEF4FF; color: #175CD3; }

/* Ubah nama kategori / sub-kategori (form tersembunyi dibuka tombol "Ubah") */
.edit-row { display: none; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.edit-row.is-editing { display: flex; }
.edit-row input[type="text"] { flex: 1 1 180px; min-width: 0; padding: 6px 9px; font-size: 13px; }
.chip-rename { display: none; align-items: center; gap: 4px; }
.chip.is-editing > :not(.chip-rename) { display: none; }
.chip.is-editing > .chip-rename { display: inline-flex; }
.chip-rename input[type="text"] { width: 150px; max-width: 45vw; padding: 3px 9px; font-size: 12.5px; border-radius: 999px; }
.chip-rename .btn-sm { padding: 4px 10px; font-size: 12px; }
.sub-add { display: flex; gap: 8px; }
.sub-add input[type="text"] { padding: 6px 9px; font-size: 13px; }

.subkat { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---- Rincian kategori & sub-kategori (Laporan) ---- */
.rincian { display: flex; flex-direction: column; gap: 18px; }
.rincian-kat { display: flex; flex-direction: column; gap: 7px; }
.rincian-head { display: flex; align-items: baseline; gap: 10px; font-size: 14px; }
.rincian-head .kat-name { flex: 1; }
.rincian-head strong { font-variant-numeric: tabular-nums; }
.rincian-sub { list-style: none; margin: 2px 0 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.rincian-sub li { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--ink-2); }
.rincian-sub li > span:first-child { flex: 1; }
.rincian-sub li > .num { font-variant-numeric: tabular-nums; }

.plainlist { margin: 0; padding-left: 18px; color: var(--ink-2); }
.plainlist li { margin-bottom: 10px; font-size: 14px; }

/* ---------------- Misc ---------------- */
.saldo-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.saldo-chip span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.saldo-chip strong { font-size: 18px; }

.month-nav { display: flex; align-items: center; gap: 8px; }
.month-now { font-weight: 650; min-width: 130px; text-align: center; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 18px;
  font-size: 14px;
}
.alert-success { background: #ECFDF3; border-color: #A6F4C5; color: #05603A; }
.alert-error { background: #FEF3F2; border-color: #FDA29B; color: #912018; }
.alert-info { background: #EFF8FF; border-color: #B2DDFF; color: #175CD3; }

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: #FAFBFC;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.pager a {
  min-width: 34px;
  padding: 6px 10px;
  text-align: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.pager a:hover { background: #F9FAFB; text-decoration: none; }
.pager a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------------- Auth ---------------- */
.auth-shell { display: flex; justify-content: center; padding: 40px 0 60px; }
.auth-card { width: 100%; max-width: 430px; padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand small { display: block; color: var(--muted); font-size: 12px; }
.auth-title { font-size: 20px; margin-bottom: 6px; }
.auth-foot { margin-top: 20px; font-size: 13px; }

.footer { padding: 20px 0 32px; color: var(--muted); font-size: 12px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-btn { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .wrap { padding: 0 16px; }
  .page { padding: 24px 0 48px; }
  .topbar-in { gap: 12px; }
  .brand-text small { display: none; }
  .mainnav { order: 3; width: 100%; flex-wrap: wrap; overflow: visible; gap: 2px; }
  .mainnav a { padding: 7px 10px; font-size: 13px; }
  .userbox { margin-left: auto; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .chart { gap: 8px; height: 190px; }
  .chart-bar { max-width: 14px; }
  .page-head { align-items: flex-start; }
  .card { padding: 18px; }
  .mini-stats { grid-template-columns: minmax(0, 1fr); }
  .month-now { min-width: auto; }
  .row-actions { justify-content: flex-start; }
  .period-bar { padding: 12px; }
  .period-modes { width: 100%; }
  .period-modes .seg { flex: 1; min-width: 0; }
  .period-modes .seg span { padding: 8px 6px; min-width: 0; }
  .period-extra { width: 100%; }
  .period-field, .period-field select, .period-field input[type="date"] { width: 100%; }
  .period-info { width: 100%; }
  .filters-kat { grid-template-columns: minmax(0, 1fr); }
  .tabs { overflow-x: auto; }
  .table-kat .cek-col { width: 44px; }
  .chart { gap: 5px; }
  .chart-bar { max-width: 10px; }
  .chart-x { font-size: 10px; }
}
