/* ===== Design tokens ===== */
:root {
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-border: #e4e8f0;
  --color-border-strong: #d3d9e6;
  --color-text: #1c2333;
  --color-text-muted: #6b7488;
  --color-text-soft: #97a0b3;

  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #eef0ff;

  --color-success: #16a34a;
  --color-success-light: #ecfdf3;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;

  --color-sidebar-bg: #131a2c;
  --color-sidebar-bg-active: #1f2a45;
  --color-sidebar-text: #aab2c5;
  --color-sidebar-text-active: #ffffff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 24, 40, 0.08);
  --sidebar-width: 264px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ===== App shell ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  color: #fff;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 16.5px; letter-spacing: 0.2px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}
.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6c7690;
  padding: 16px 12px 6px;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-sidebar-text);
  margin-bottom: 2px;
}
.nav-link .icon { width: 18px; height: 18px; }
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-link.active { background: var(--color-primary); color: #fff; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 6px 12px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  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; color: #fff; }
.user-email { font-size: 12px; color: #8891a5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--color-sidebar-text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 30, 0.55);
  z-index: 39;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 18px; font-weight: 700; }
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  color: var(--color-text);
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

/* ===== Mobile layout ===== */
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .content { padding: 16px; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #fff; color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: #f8f9fc; }
.btn-danger { background: var(--color-danger-light); color: var(--color-danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: #f1f2f7; color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled, .btn-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.card-title { font-size: 15.5px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 22px; font-weight: 800; }
.page-header p { color: var(--color-text-muted); font-size: 13.5px; margin-top: 4px; }

/* ===== Stat cards ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1023px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon .icon { width: 17px; height: 17px; }
.stat-icon.blue { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon.green { background: var(--color-success-light); color: var(--color-success); }
.stat-icon.red { background: var(--color-danger-light); color: var(--color-danger); }
.stat-icon.amber { background: var(--color-warning-light); color: var(--color-warning); }
.stat-value { font-size: 23px; font-weight: 800; letter-spacing: -0.3px; }
.stat-hint { font-size: 12.5px; color: var(--color-text-soft); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; }
thead th {
  background: #f8f9fc;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12.2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
}
tbody tr { border-bottom: 1px solid var(--color-border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap, th.wrap { white-space: normal; }
.table-empty { padding: 48px 20px; text-align: center; color: var(--color-text-muted); }
tfoot td { font-weight: 700; border-top: 2px solid var(--color-border-strong); background: #fafbfd; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
label.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.form-hint { font-size: 12px; color: var(--color-text-soft); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text);
  background: #fff;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
}
.badge-blue { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-green { background: var(--color-success-light); color: var(--color-success); }
.badge-red { background: var(--color-danger-light); color: var(--color-danger); }
.badge-amber { background: var(--color-warning-light); color: var(--color-warning); }
.badge-gray { background: #f1f2f7; color: var(--color-text-muted); }

/* ===== Alerts / flash ===== */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: 13.8px; margin-bottom: 18px; border: 1px solid transparent;
}
.alert .icon { width: 18px; height: 18px; margin-top: 1px; }
.alert-success { background: var(--color-success-light); color: #166534; border-color: #bbf0cd; }
.alert-error { background: var(--color-danger-light); color: #991b1b; border-color: #fecaca; }

/* ===== Login page ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1c2544 0%, #0c1120 60%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { font-size: 13.5px; color: var(--color-text-muted); margin-bottom: 22px; }

/* ===== Journal entry form ===== */
.entry-row { display: flex; flex-wrap: wrap; gap: 16px; }
.entry-row .form-group { margin-bottom: 0; flex: 1 1 150px; }
.entry-row .form-group.fg-amount { flex: 1 1 140px; }
.entry-row .form-group.fg-desc { flex: 2 1 260px; }
.same-account-warning {
  display: none; align-items: center; gap: 8px; margin-top: 14px;
  color: var(--color-danger); background: var(--color-danger-light);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
}
.same-account-warning.show { display: flex; }
.number-hint { font-size: 12.5px; color: var(--color-text-soft); margin: 12px 0 18px; }

/* ===== Modal bukti ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 18, 30, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--color-border);
}
.modal-title { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-sm); flex-shrink: 0;
  border: 1px solid var(--color-border-strong); background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--color-text-muted);
}
.modal-close:hover { background: #f1f2f7; }
.modal-body {
  padding: 18px; overflow: auto; display: flex; align-items: center; justify-content: center;
  background: #fafbfd; min-height: 220px;
}
.modal-body img { max-width: 100%; max-height: 60vh; border-radius: var(--radius-sm); }
.modal-footer { padding: 14px 18px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; }

.dropzone {
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 22px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13.5px;
  cursor: pointer;
  background: #fafbfd;
}
.dropzone:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 13px;
}
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: #eef0f5; flex-shrink: 0; }

.attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.attachment-card {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden;
  display: flex; flex-direction: column; background: #fff;
}
.attachment-card img { width: 100%; height: 90px; object-fit: cover; background: #eef0f5; }
.attachment-card .doc-icon { width: 100%; height: 90px; display: flex; align-items: center; justify-content: center; background: #eef0f5; color: var(--color-text-muted); }
.attachment-card .meta { padding: 8px; font-size: 11.5px; color: var(--color-text-muted); }
.attachment-card .meta .fname { color: var(--color-text); font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.attachment-card[data-view] { cursor: pointer; }
.attachment-card[data-view]:hover { border-color: var(--color-primary); }

.bukti-thumb-wrap { position: relative; display: inline-flex; }
.bukti-thumb, .bukti-thumb-doc {
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  background: #eef0f5; object-fit: cover; flex-shrink: 0;
}
.bukti-thumb-doc { display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); }
.bukti-thumb:hover, .bukti-thumb-doc:hover { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.bukti-thumb-more {
  position: absolute; bottom: -5px; right: -5px;
  background: var(--color-primary); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 5px; line-height: 1.4; pointer-events: none;
}

/* ===== Misc ===== */
.text-muted { color: var(--color-text-muted); }
.text-soft { color: var(--color-text-soft); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; padding: 16px 20px; align-items: center; }
.pagination .btn-sm { min-width: 36px; }
.empty-state { text-align: center; padding: 56px 24px; color: var(--color-text-muted); }
.empty-state .icon-lg { margin: 0 auto 14px; color: var(--color-text-soft); }
.section-title { font-size: 14.5px; font-weight: 700; margin: 22px 0 10px; }
.divider { height: 1px; background: var(--color-border); margin: 18px 0; border: none; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--color-text-muted); margin-top: 10px; }

.scroll-hint { display: none; margin-bottom: 8px; }
@media (max-width: 720px) { .scroll-hint { display: block; } }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; margin-right: 6px; }
