/* =========================================================
   Keuangankita — Stylesheet Utama (bagian 1: base & layout)
   ========================================================= */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #0891b2;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,.08);
  --shadow-md: 0 4px 12px rgba(15,23,42,.10);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

/* ---------- Layout app (sidebar + konten) ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.2rem;
  color: #fff; font-weight: 700; font-size: 1.12rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center; color: #fff; font-weight: 800;
  flex-shrink: 0;
}
.nav { padding: .8rem .6rem; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .8rem; margin: 2px 0;
  color: #cbd5e1; border-radius: 9px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ico { width: 20px; text-align: center; opacity: .9; }

.side-foot {
  padding: .8rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem; color: #94a3b8;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: .9rem 1.4rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 1.12rem; font-weight: 700; }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: .6rem;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.content { padding: 1.4rem; flex: 1; }
/* =========================================================
   Keuangankita — Stylesheet (bagian 2: komponen)
   ========================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
}
.card + .card { margin-top: 1.1rem; }
.card-title { font-weight: 700; margin-bottom: .2rem; }
.card-sub { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.45rem; font-weight: 800; margin-top: .25rem; color: #0f172a; }
.stat.pos .value { color: var(--success); }
.stat.neg .value { color: var(--danger); }
.stat .sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

/* Tabel */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
.tbl th {
  text-align: left; padding: .7rem .9rem; background: #f8fafc;
  border-bottom: 1px solid var(--line); font-weight: 700; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap;
}
.tbl td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #f8fafc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .strong { font-weight: 700; }

/* Badge */
.badge {
  display: inline-block; padding: .18rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700;
}
.badge.income { background: var(--success-light); color: var(--success); }
.badge.expense { background: var(--danger-light); color: var(--danger); }
.badge.role-owner { background: #ede9fe; color: #6d28d9; }
.badge.role-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge.role-pencatat { background: #f1f5f9; color: var(--muted); }
.badge.on { background: var(--success-light); color: var(--success); }
.badge.off { background: #f1f5f9; color: var(--muted); }
.badge.type-cash { background: var(--success-light); color: var(--success); }
.badge.type-bank { background: var(--primary-light); color: var(--primary-dark); }
.badge.type-ewallet { background: #ccfbf1; color: #0f766e; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 9px; border: 1px solid transparent;
  font-weight: 600; font-size: .88rem; cursor: pointer;
  transition: filter .15s, background .15s;
  background: var(--primary); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f8fafc; color: var(--ink); }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: .3rem .65rem; font-size: .8rem; border-radius: 7px; }
.btn.block { width: 100%; justify-content: center; }

/* Form */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
input[type=text], input[type=number], input[type=date], input[type=password],
input[type=search], select, textarea {
  width: 100%; padding: .55rem .8rem;
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }

/* Filter bar */
.filterbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.filterbar .field { margin-bottom: 0; min-width: 130px; flex: 1; }
.filterbar .field label { font-size: .74rem; }
.filterbar .actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Flash */
.flash { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; }
.flash.success { background: var(--success-light); color: var(--success); }
.flash.error { background: var(--danger-light); color: var(--danger); }
.flash.info { background: var(--primary-light); color: var(--primary-dark); }

/* Pagination */
.pagination { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: .85rem; background: #fff; color: var(--ink);
}
.pagination span.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
/* =========================================================
   Keuangankita — Stylesheet (bagian 3: login, tabs, responsive)
   ========================================================= */

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; background: #0f172a; }
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px;
  padding: 2rem 1.8rem; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-card .logo {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto .8rem;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center; color: #fff; font-size: 1.4rem; font-weight: 800;
}
.login-card h1 { text-align: center; font-size: 1.25rem; }
.login-card .sub { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 1.4rem; }
.login-card .field label { font-size: .8rem; }
.login-card .foot { text-align: center; margin-top: 1.2rem; font-size: .8rem; color: var(--muted); }

/* ---------- Tabs laporan ---------- */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.tabs a {
  padding: .55rem 1.1rem; font-weight: 600; font-size: .88rem;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Bar progres anggaran ---------- */
.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--success); border-radius: 999px; }
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* ---------- Utilitas ---------- */
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.small { font-size: .8rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; align-items: center; gap: .6rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.empty {
  text-align: center; padding: 2.2rem 1rem; color: var(--muted);
  border: 2px dashed var(--line); border-radius: var(--radius);
}
.empty .big { font-size: 2rem; margin-bottom: .4rem; }
.kbd {
  display: inline-block; padding: .12rem .45rem; background: #f1f5f9;
  border: 1px solid var(--line); border-radius: 6px; font-size: .78rem;
}
.hidden { display: none !important; }
code { background: #f1f5f9; padding: .12rem .35rem; border-radius: 5px; font-size: .85em; }

/* ---------- Print (laporan) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .flash, .filterbar { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  .card + .card { margin-top: 1.4rem; }
  .tbl th, .tbl td { font-size: .8rem; }
  @page { size: A4; margin: 14mm; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { width: 72px; }
  .sidebar .brand span.txt, .sidebar .nav a span.txt, .sidebar .side-foot { display: none; }
  .brand { justify-content: center; padding: 1rem .5rem; }
  .nav a { justify-content: center; padding: .7rem; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .content { padding: 1rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .filterbar .field { min-width: 100%; }
  .topbar { padding: .8rem 1rem; }
  .user-chip .who { display: none; }
}
