/* =========================================================
   SIMPEL KEUANGAN — Design tokens
   Palette: putih bersih + aksen biru halus
   ========================================================= */
:root {
  --bg:            #f6f8fb;
  --surface:       #ffffff;
  --surface-soft:  #f0f5fc;
  --border:        #e6ebf2;
  --text:          #1c2536;
  --text-muted:    #7c879b;
  --text-faint:    #a7b1c2;

  --blue-50:  #eef4ff;
  --blue-100: #dbe8ff;
  --blue-400: #5b9bf5;
  --blue-500: #3b7ff0;
  --blue-600: #2f6ce0;
  --blue-700: #2557bd;

  --green:  #12b76a;
  --green-bg: #e7f9f0;
  --red:    #f04438;
  --red-bg: #fdeeed;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(28, 37, 54, 0.04);
  --shadow-md: 0 8px 24px rgba(28, 37, 54, 0.06);
  --shadow-focus: 0 0 0 3px rgba(59, 127, 240, 0.18);

  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-text, .stat-value {
  font-family: var(--font-display);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Auth pages (login/register) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f6f9fe 0%, #eef4ff 100%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
}
.auth-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  margin-bottom: 18px;
}
.auth-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
.auth-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}
.auth-foot {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}
.auth-foot a { color: var(--blue-600); font-weight: 600; }

/* ---------- Form elements ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  transition: box-shadow .15s, border-color .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: var(--shadow-focus);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue-500); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-block { width: 100%; }
.btn-secondary { background: var(--surface-soft); color: var(--blue-700); border-color: var(--blue-100); }
.btn-secondary:hover { background: var(--blue-100); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--blue-400); color: var(--blue-600); }
.btn-danger-ghost { background: #fff; color: var(--red); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--red-bg); border-color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-error { background: var(--red-bg); color: #b42318; border: 1px solid #f6c6c1; }
.alert-success { background: var(--green-bg); color: #067647; border: 1px solid #a9e6c8; }

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 24px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 16px;
}
.brand-text { font-weight: 700; font-size: 15.5px; letter-spacing: -0.01em; }

.nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-soft); color: var(--text); }
.nav-link.active { background: var(--blue-50); color: var(--blue-700); font-weight: 600; }
.nav-link svg { flex-shrink: 0; opacity: 0.9; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue-100); color: var(--blue-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13.5px; font-weight: 600; }
.user-logout { font-size: 12.5px; color: var(--text-muted); }
.user-logout:hover { color: var(--red); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 32px;
}
.page-title { font-size: 21px; margin: 0; letter-spacing: -0.01em; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }
.content { padding: 0 32px 40px; flex: 1; }

/* ---------- Cards / stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 { margin: 0; font-size: 15.5px; }
.card-head .sub { font-size: 12.5px; color: var(--text-muted); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 10px; display:flex; align-items:center; gap:8px;}
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card.income .stat-value { color: var(--green); }
.stat-card.expense .stat-value { color: var(--red); }
.stat-card.balance .stat-value { color: var(--blue-700); }
.stat-icon {
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card.income .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-card.expense .stat-icon { background: var(--red-bg); color: var(--red); }
.stat-card.balance .stat-icon { background: var(--blue-50); color: var(--blue-600); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
}

/* ---------- Month selector ---------- */
.month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.month-nav button {
  background: none; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.month-nav button:hover { background: var(--surface-soft); color: var(--blue-600); }
.month-nav .month-label { font-weight: 600; font-size: 14px; min-width: 132px; text-align: center; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-soft); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-soft);
}
.tag-dot { width: 7px; height: 7px; border-radius: 50%; }
.amount-income { color: var(--green); font-weight: 600; }
.amount-expense { color: var(--red); font-weight: 600; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--blue-400); color: var(--blue-600); background: var(--blue-50); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { color: var(--text-faint); margin-bottom: 12px; }
.empty-state p { margin: 4px 0 0; font-size: 13.5px; }

/* ---------- Filters bar ---------- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters-bar select, .filters-bar input[type=text] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: #fff;
}
.spacer { flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 28, 46, 0.42);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---------- Category chips (settings page) ---------- */
.cat-section { margin-bottom: 26px; }
.cat-section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.cat-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.cat-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 8px 8px 14px;
  font-size: 13.5px; font-weight: 500;
}
.cat-chip .cat-dot { width: 10px; height: 10px; border-radius: 50%; }
.cat-chip button {
  background: var(--surface-soft); border: none; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.cat-chip button:hover { background: var(--red-bg); color: var(--red); }
.add-cat-btn {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px dashed var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600;
  color: var(--blue-600); background: var(--blue-50);
  cursor: pointer;
}
.add-cat-btn:hover { background: var(--blue-100); }

.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
}
.color-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }

/* ---------- Export buttons ---------- */
.export-group { display: flex; gap: 8px; }

/* ---------- Chart legend ---------- */
.legend-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-row .cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-row .legend-name { flex: 1; color: var(--text); }
.legend-row .legend-value { font-weight: 600; }
.legend-row .legend-pct { color: var(--text-faint); width: 38px; text-align: right; }

/* ---------- Wallet balance cards (dashboard) ---------- */
.wallet-balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.wallet-balance-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface);
}
.wallet-balance-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.wallet-balance-head .cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.wallet-balance-name { font-size: 13.5px; font-weight: 600; }
.wallet-balance-type { font-size: 11.5px; color: var(--text-faint); }
.wallet-balance-amount { font-size: 19px; font-weight: 700; font-family: var(--font-display); letter-spacing: -0.01em; }
.wallet-balance-amount.positive { color: var(--blue-700); }
.wallet-balance-amount.negative { color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .stat-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .menu-toggle { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 90;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,0.15); }
  .topbar { padding: 16px 18px; }
  .content { padding: 0 18px 32px; }
  .field-row { flex-direction: column; gap: 0; }
}
