/* ===========================
   ASSETKU — Premium Dark Theme
   Mobile-First Responsive
   =========================== */

:root {
  --bg-base: #0c0e14;
  --bg-surface: #111520;
  --bg-elevated: #161b28;
  --bg-hover: #1c2235;
  --bg-card: #141827;

  --border: rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.04);

  --gold: #c9a84c;
  --gold-light: #e2c06b;
  --gold-dim: rgba(201,168,76,0.15);

  --blue: #4a8fff;
  --blue-dim: rgba(74,143,255,0.12);
  --teal: #2dd4bf;
  --teal-dim: rgba(45,212,191,0.12);
  --green: #4ade80;
  --green-dim: rgba(74,222,128,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --amber: #fb923c;
  --amber-dim: rgba(251,146,60,0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167,139,250,0.12);

  --text-primary: #e8ecf4;
  --text-secondary: #7a839e;
  --text-muted: #4a5168;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-w: 220px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
  --glow-gold: 0 0 20px rgba(201,168,76,0.2);

  --header-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }

/* ============ LOGIN ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 30% 20%, rgba(201,168,76,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(74,143,255,0.05) 0%, transparent 60%),
              var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand .brand-icon {
  width: 52px; height: 52px;
  background: var(--gold-dim);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 22px;
  margin: 0 auto 12px;
}

.login-brand-name {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text-primary);
}

.login-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(248,113,113,0.25);
  color: var(--red);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 12px;
}

.btn-full { width: 100%; justify-content: center; padding: 11px 16px; font-size: 13px; }

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── PASSCODE ─────────────────────────────────── */
.passcode-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 18px;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(201,168,76,0.4);
  background: transparent;
  transition: all 0.15s ease;
}

.dot.filled {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201,168,76,0.5);
  transform: scale(1.1);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}

.passcode-dots.shake {
  animation: shake 0.5s ease;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 auto;
  max-width: 260px;
}

.numpad-btn {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
}

.numpad-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(201,168,76,0.3);
  color: var(--gold-light);
}

.numpad-btn:active {
  background: var(--gold-dim);
  border-color: rgba(201,168,76,0.5);
  transform: scale(0.93);
}

.numpad-empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

.numpad-del {
  font-size: 18px;
  color: var(--text-muted);
}

.numpad-del:hover {
  color: var(--red);
  background: var(--red-dim);
  border-color: rgba(248,113,113,0.2);
}

.login-error {
  text-align: center;
  margin-bottom: 14px;
}

/* ============ MOBILE HEADER ============ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}

.hamburger {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 20px; cursor: pointer;
  font-family: var(--font-body);
  padding: 4px;
}

.mobile-title {
  font-family: var(--font-display);
  font-size: 18px;
}

/* ============ SIDEBAR OVERLAY ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 299;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ============ LAYOUT ============ */
.app { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  transition: transform 0.3s ease;
  z-index: 300;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--gold-dim);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 16px; flex-shrink: 0;
}

.brand-name { font-family: var(--font-display); font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 10px; color: var(--text-muted); letter-spacing: 0.03em; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label { font-size: 9px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); padding: 0 8px 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-md);
  cursor: pointer; color: var(--text-secondary);
  font-size: 13px; transition: all 0.2s ease;
  position: relative; margin-bottom: 2px;
}

.nav-item i { font-size: 17px; flex-shrink: 0; }
.nav-item .nav-indicator {
  width: 3px; height: 0; background: var(--gold);
  border-radius: 2px; position: absolute; right: 0; top: 50%;
  transform: translateY(-50%); transition: height 0.2s ease;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--gold-dim); color: var(--gold-light); font-weight: 500; border: 1px solid rgba(201,168,76,0.15); }
.nav-item.active .nav-indicator { height: 20px; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.sidebar-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); letter-spacing: 0.05em; }

/* ============ MAIN ============ */
.main { flex: 1; min-width: 0; overflow-y: auto; background: var(--bg-base); }

/* ============ PAGE ============ */
.page { display: none; padding: 28px 32px; animation: pageIn 0.3s ease; }
.page.active { display: block; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 12px; }
.page-title { font-family: var(--font-display); font-size: 26px; color: var(--text-primary); line-height: 1.2; }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============ ALERTS ============ */
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 12px; margin-bottom: 8px; animation: slideIn 0.3s ease; line-height: 1.5;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.alert-item.warn { background: var(--amber-dim); border: 1px solid rgba(251,146,60,0.2); color: var(--amber); }
.alert-item.danger { background: var(--red-dim); border: 1px solid rgba(248,113,113,0.25); color: var(--red); }

/* ============ METRICS ============ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 20px;
}

.metric {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  position: relative; overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.metric::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}
.metric:hover { transform: translateY(-2px); border-color: rgba(201,168,76,0.2); }
.metric-label { font-size: 10px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.metric-value { font-family: var(--font-mono); font-size: 16px; font-weight: 500; color: var(--text-primary); letter-spacing: -0.02em; }
.metric-value.green { color: var(--green); }
.metric-value.red { color: var(--red); }
.metric-value.amber { color: var(--amber); }
.metric-value.gold { color: var(--gold); }

/* ============ CHARTS ============ */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.chart-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.chart-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chart-card-title { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.chart-card-title em { font-style: normal; color: var(--text-muted); }
.chart-wrap { height: 160px; position: relative; }
canvas { width: 100% !important; height: 100% !important; }

.pie-layout { display: flex; align-items: center; gap: 20px; }
.pie-canvas-wrap { width: 130px; height: 130px; flex-shrink: 0; }
.pie-legend { flex: 1; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 11px; }
.pie-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.pie-legend-label { flex: 1; color: var(--text-secondary); }
.pie-legend-pct { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

/* Dashboard hutang summary */
.hutang-summary-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.hutang-summary-item:last-of-type { border-bottom: none; }
.hutang-summary-name { font-size: 12px; font-weight: 500; }
.hutang-summary-sub { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.hutang-summary-total { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }

/* ============ CARDS ============ */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 14px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-title { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.card-value { font-family: var(--font-mono); font-size: 12px; color: var(--gold); }

/* ============ TABLE ============ */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { padding: 8px 10px; text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle; color: var(--text-secondary); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.15s ease; }
.tbl tbody tr:hover td { background: var(--bg-hover); }
.tbl td.name-cell { font-weight: 500; color: var(--text-primary); }
.tbl td.mono { font-family: var(--font-mono); font-size: 11px; }
.tbl td.center { text-align: center; }

.line-through { text-decoration: line-through; opacity: 0.4; }

/* ============ HUTANG TABLE ============ */
/* CC source card */
.cc-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0; margin-bottom: 16px; overflow: hidden;
}

.cc-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.cc-name { font-family: var(--font-display); font-size: 15px; }
.cc-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.cc-total { font-family: var(--font-mono); font-size: 16px; font-weight: 500; }

/* Table months header */
.tbl th.month-col { min-width: 90px; text-align: right; }
.tbl td.month-val { text-align: right; font-family: var(--font-mono); font-size: 11px; }
.tbl td.month-val.has-val { color: var(--text-primary); }
.tbl td.month-val.empty-val { color: var(--text-muted); }

/* Bank hutang item */
.bank-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 10px;
}
.bank-item-hdr { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.bank-item-name { font-weight: 500; font-size: 13px; }
.bank-item-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.progress-bar { height: 3px; background: var(--bg-hover); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.5s ease; }

/* ============ TABS ============ */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 18px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 4px; width: fit-content;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px; font-size: 12px; font-weight: 500; cursor: pointer;
  border: none; background: transparent; color: var(--text-secondary);
  border-radius: var(--radius-sm); transition: all 0.2s ease; font-family: var(--font-body);
  white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--gold-dim); color: var(--gold-light); border: 1px solid rgba(201,168,76,0.2); }

/* ============ BADGES ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
.badge-amber { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(251,146,60,0.2); }
.badge-blue { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(74,143,255,0.2); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.badge-teal { background: var(--teal-dim); color: var(--teal); border: 1px solid rgba(45,212,191,0.2); }
.badge-gold { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(201,168,76,0.2); }
.badge-gray { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500; font-family: var(--font-body);
  cursor: pointer; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  transition: all 0.2s ease; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn i { font-size: 14px; }
.btn-primary { background: var(--gold-dim); color: var(--gold-light); border-color: rgba(201,168,76,0.3); }
.btn-primary:hover { background: rgba(201,168,76,0.25); border-color: rgba(201,168,76,0.5); color: var(--gold-light); box-shadow: var(--glow-gold); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-secondary); }
.btn-danger { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,0.2); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-success { background: var(--green-dim); color: var(--green); border-color: rgba(74,222,128,0.2); }
.btn-success:hover { background: rgba(74,222,128,0.2); }
.btn-warn { background: var(--amber-dim); color: var(--amber); border-color: rgba(251,146,60,0.2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; }

/* ============ EMPTY STATE ============ */
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 12px; }
.empty i { display: block; font-size: 28px; margin-bottom: 8px; opacity: 0.4; }

/* ============ MODALS ============ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 1000; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 24px;
  width: 100%; max-width: 420px; max-height: 92vh; overflow-y: auto;
  animation: modalIn 0.25s ease; box-shadow: var(--shadow-lg);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-family: var(--font-display); font-size: 18px; }
.modal-close {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: none; background: var(--bg-hover);
  color: var(--text-muted); cursor: pointer; font-size: 15px; font-family: var(--font-body); transition: all 0.2s;
}
.modal-close:hover { background: var(--red-dim); color: var(--red); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ============ FORMS ============ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 9px 12px; font-size: 13px;
  font-family: var(--font-body); color: var(--text-primary); outline: none; transition: border-color 0.2s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: rgba(201,168,76,0.4);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.07);
}
.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a5168' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer;
}
.form-group select option { background: var(--bg-elevated); }
.form-group textarea { height: 72px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cicilan-preview { font-size: 11px; color: var(--gold); font-family: var(--font-mono); margin-bottom: 8px; min-height: 16px; }
.alert-warn { display: flex; align-items: center; gap: 8px; background: var(--amber-dim); border: 1px solid rgba(251,146,60,0.2); border-radius: var(--radius-md); padding: 10px 12px; font-size: 11px; color: var(--amber); margin-bottom: 14px; }

/* Color helpers */
.profit-pos { font-family: var(--font-mono); font-weight: 500; color: var(--green); }
.profit-neg { font-family: var(--font-mono); font-weight: 500; color: var(--red); }
.profit-muted { font-family: var(--font-mono); color: var(--text-muted); }
.color-red { color: var(--red); }
.color-green { color: var(--green); }
.color-amber { color: var(--amber); }
.color-gold { color: var(--gold); }
.color-muted { color: var(--text-muted); }
.fw500 { font-weight: 500; }
.mono { font-family: var(--font-mono); }

/* ============ RESPONSIVE — TABLET ============ */
@media (max-width: 1024px) {
  .charts-row, .bottom-row { grid-template-columns: 1fr; }
}

/* ============ RESPONSIVE — MOBILE ============ */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .mobile-header { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .main { padding-top: var(--header-h); }

  .page { padding: 20px 16px; }

  .page-header { flex-direction: column; gap: 12px; }
  .page-header .btn { align-self: flex-start; }

  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 12px 14px; }
  .metric-value { font-size: 14px; }

  .charts-row, .bottom-row { grid-template-columns: 1fr; gap: 12px; }
  .chart-card { padding: 14px 16px; }
  .chart-wrap { height: 140px; }

  .pie-layout { flex-direction: row; align-items: center; gap: 14px; }
  .pie-canvas-wrap { width: 110px; height: 110px; }

  .form-row { grid-template-columns: 1fr; }

  .tab-bar { width: 100%; }
  .tab { flex: 1; text-align: center; padding: 7px 8px; font-size: 11px; }

  .page-title { font-size: 22px; }

  .modal { padding: 20px 16px; border-radius: var(--radius-lg); }
  .modal-footer { flex-direction: column-reverse; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  .tbl th, .tbl td { padding: 8px 8px; font-size: 11px; }

  .cc-card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 400px) {
  .metric-grid { grid-template-columns: 1fr; }
  .page { padding: 16px 12px; }
}

/* ===== BACKUP/RESTORE SIDEBAR BUTTONS ===== */
.sidebar-backup-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.sidebar-backup-row .btn {
  flex: 1;
  justify-content: center;
  font-size: 11px;
  padding: 6px 8px;
}
.btn-outline-green {
  background: transparent;
  border: 1px solid #4ade80;
  color: #4ade80;
}
.btn-outline-green:hover {
  background: rgba(74,222,128,0.12);
}
.btn-outline-amber {
  background: transparent;
  border: 1px solid var(--amber);
  color: var(--amber);
}
.btn-outline-amber:hover {
  background: rgba(201,168,76,0.12);
}

/* ===== CATEGORY FILTER BUTTONS (replaces dropdown) ===== */
.cat-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.cat-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.cat-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}
.cat-btn.active {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
  font-weight: 600;
}

/* ===== SORTABLE TABLE HEADERS ===== */
.tbl th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tbl th.sortable:hover {
  color: var(--amber);
}
.tbl th.sortable::after {
  content: ' ⇅';
  font-size: 9px;
  opacity: 0.4;
  margin-left: 2px;
}
.tbl th.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--amber); }
.tbl th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--amber); }

/* ===== SEARCH ===== */
.sidebar-search-wrap {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.search-bar-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-input, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 7px 30px 7px 32px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.search-input:focus { border-color: var(--amber); }
.search-input::placeholder { color: var(--text-muted); }

.search-clear {
  position: absolute;
  right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px; padding: 2px;
  line-height: 1;
}
.search-clear:hover { color: var(--text-primary); }

/* Mobile header search */
.mobile-header .search-bar-wrap {
  flex: 1;
  margin: 0 8px;
}

/* Results panel */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 420px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.search-results.active { display: block; }

.search-group-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px 5px;
  border-top: 1px solid var(--border);
}
.search-group-label:first-child { border-top: none; }

.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  cursor: pointer;
  gap: 8px;
  transition: background .12s;
}
.search-item:hover { background: var(--bg-hover); }
.search-item-left { flex: 1; min-width: 0; }
.search-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-name mark {
  background: rgba(201,168,76,0.35);
  color: var(--gold-light);
  border-radius: 2px;
  padding: 0 1px;
}
.search-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-right {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.search-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ─── ROW HIGHLIGHT (search scroll) ─────────────────── */
@keyframes rowGlow {
  0%   { background: rgba(245,185,0,0.35); box-shadow: inset 0 0 0 2px rgba(245,185,0,0.6); }
  70%  { background: rgba(245,185,0,0.18); box-shadow: inset 0 0 0 1px rgba(245,185,0,0.3); }
  100% { background: transparent; box-shadow: none; }
}
.tbl tbody tr.row-highlight td {
  animation: rowGlow 2.8s ease forwards;
}

/* ─── TABLE LOCAL SEARCH ─────────────────────────────── */
.tbl-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}
.tbl-search-wrap:focus-within {
  border-color: var(--amber, #f5b900);
}
.tbl-search-wrap .ti-search {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.tbl-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans, inherit);
  min-width: 0;
}
.tbl-search-input::placeholder { color: var(--text-muted); }
.tbl-search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  font-size: 13px;
  display: flex;
  align-items: center;
}
.tbl-search-clear:hover { color: var(--text-primary); }
.tbl-search-count {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-mono, monospace);
}
.tbl-no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 12px;
}

/* ─── UNDO BUTTON ─────────────────────────────────── */
.btn-undo {
  background: rgba(167, 139, 250, 0.12);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-undo:hover {
  background: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
}

/* ── NEW V12 FEATURES ──────────────────────────── */

/* Dark/Light mode toggle */
body.light-mode {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card2: #f8f9fa;
  --bg-hover: #f0f2f5;
  --text-primary: #1a1d2e;
  --text-secondary: #4a5168;
  --text-muted: #7a819a;
  --border: #e2e5ef;
  --border-light: #eceef5;
  --sidebar-bg: #1a1d2e;
}
body.light-mode .tbl tbody tr:hover { background: rgba(0,0,0,0.03); }
body.light-mode .metric { background: #ffffff; }
body.light-mode .chart-card { background: #ffffff; }
body.light-mode .cc-card { background: #ffffff; border-color: #e2e5ef; }
body.light-mode .bank-item { background: #f8f9fa; border-color: #e2e5ef; }
body.light-mode .login-card { background: #ffffff; }
body.light-mode input, body.light-mode select, body.light-mode textarea {
  background: #f8f9fa;
  border-color: #dde1ee;
  color: #1a1d2e;
}

/* Alert info (biru) */
.alert-item.info { background: rgba(74,143,255,0.08); border: 1px solid rgba(74,143,255,0.2); color: #4a8fff; }

/* Back to Top button */
#backToTopBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: #000;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0.85;
}
#backToTopBtn:hover { opacity: 1; transform: translateY(-2px); }

/* Riwayat filter bar */
.riwayat-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--bg-card2);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.riwayat-filter-bar select {
  height: 30px;
  font-size: 12px;
  padding: 0 6px;
  border-radius: 6px;
}

/* btn-outline for edit button */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

/* btn-outline-green */
.btn-outline-green {
  background: transparent;
  border: 1px solid rgba(74,222,128,0.4);
  color: #4ade80;
}
.btn-outline-green:hover { background: rgba(74,222,128,0.1); }

/* Terjual row subtle bg */
tr[data-row-id].terjual-row { opacity: 0.7; }

/* ── CSV DROPDOWN STYLED ──────────────────────── */
.csv-dropdown-wrap {
  position: relative;
  display: inline-flex;
}
.btn-csv-styled {
  background: linear-gradient(135deg, #1a6b3a 0%, #1e8449 100%);
  color: #fff;
  border: 1px solid rgba(74,222,128,0.35);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: .02em;
}
.btn-csv-styled:hover {
  background: linear-gradient(135deg, #21863f 0%, #25a35a 100%);
  border-color: rgba(74,222,128,0.6);
  box-shadow: 0 2px 8px rgba(30,132,73,0.35);
}
.csv-dropdown-wrap.open .btn-csv-styled {
  background: linear-gradient(135deg, #21863f 0%, #25a35a 100%);
  border-color: rgba(74,222,128,0.7);
}
.csv-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
  min-width: 220px;
  overflow: hidden;
  animation: csvDropIn .15s ease;
}
@keyframes csvDropIn {
  from { opacity:0; transform: translateY(-6px) scale(.97); }
  to   { opacity:1; transform: none; }
}
.csv-dropdown-menu.open { display: block; }
.csv-dropdown-title {
  padding: 10px 14px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-light);
}
.csv-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  text-align: left;
  color: var(--text-primary);
}
.csv-dropdown-item:hover { background: var(--bg-card2); }
.csv-dropdown-item .ti {
  font-size: 18px;
  color: #4ade80;
  flex-shrink: 0;
}
.csv-item-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1px;
}
.csv-item-desc {
  font-size: 10px;
  color: var(--text-muted);
}
.csv-dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 2px 0;
}
.csv-dropdown-info {
  padding: 7px 14px;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.csv-dropdown-info .ti { font-size: 12px; }

/* ── HUTANG TOTAL BADGE ──────────────────────── */
.hutang-total-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  background: linear-gradient(135deg, rgba(248,113,113,.1) 0%, rgba(248,113,113,.06) 100%);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: 8px;
  padding: 5px 10px;
}
.hutang-total-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.hutang-total-val {
  font-size: 15px;
  font-weight: 700;
  color: #f87171;
  font-family: 'JetBrains Mono', monospace;
}

/* ── HUTANG BANK TOTAL BAR ──────────────────── */
.hutang-bank-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(248,113,113,.08) 0%, rgba(248,113,113,.04) 100%);
  border: 1px solid rgba(248,113,113,.25);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
