:root {
  --ungu-utama: #6a2de6;
  --ungu-gelap: #5521c7;
  --ungu-soft: #f1ebff;
  --putih: #ffffff;
  --abu-bg: #f4f5f8;
  --abu-panel: #eceef3;
  --teks-hitam: #1e1e2f;
  --teks-muted: #6b7280;
  --hijau: #2ea56a;
  --merah: #d94b4b;
  --radius-lg: 16px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --shadow-soft: 0 2px 10px rgba(30, 30, 47, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--abu-bg);
  color: var(--teks-hitam);
  font-size: 14px;
  line-height: 1.45;
  opacity: 0;
  transition: opacity .22s ease;
}
body.page-ready { opacity: 1; }
html { scroll-behavior: smooth; }

a { color: inherit; }

.layout-wrap { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--putih);
  border-right: 1px solid #ececf2;
  padding: 24px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 22px;
}
.brand .bi { color: var(--ungu-utama); font-size: 20px; }
.brand span { font-size: 18px; }
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
}
.brand-logo-wrap {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  max-width: 28px;
  max-height: 28px;
  border-radius: 8px;
  overflow: hidden;
  display: inline-flex;
  flex-shrink: 0;
}
.sidebar .brand-logo,
.sidebar .brand > img.brand-logo {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  display: block !important;
  object-fit: cover !important;
  object-position: center !important;
  flex-shrink: 0 !important;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #5f6477;
  text-decoration: none;
  margin-bottom: 6px;
  transition: 0.2s ease;
}
.menu-link:hover { background: rgba(106, 45, 230, 0.1); color: var(--ungu-utama); }
.menu-link.active { background: var(--ungu-utama); color: var(--putih); box-shadow: none; }

.main-content { margin-left: 240px; width: calc(100% - 240px); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 245, 248, 0.96);
  backdrop-filter: blur(8px);
  padding: 14px 20px;
  border-bottom: 1px solid #ebeaf2;
}
.topbar-grid {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.page-title { font-size: 24px; font-weight: 600; margin: 0; }
.page-subtitle { font-size: 14px; color: var(--teks-muted); margin: 4px 0 0; }
.search-wrap {
  width: 320px;
  background: var(--putih);
  border: 1px solid #e8e8f0;
  border-radius: 999px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-wrap input { border: none; outline: none; width: 100%; background: transparent; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--putih);
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar-chip {
  background: var(--putih);
  border-radius: 999px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  max-width: 240px;
}
.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8a57f2, #6a2de6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.avatar-media {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  flex-shrink: 0;
}
.avatar-foto {
  width: 32px;
  height: 32px;
  min-width: 32px;
  max-width: 32px;
  min-height: 32px;
  max-height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  border-radius: 50% !important;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}
.topbar .avatar-chip .avatar-foto {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
}
.topbar .avatar-chip .small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.content-area { padding: 24px 26px; }

.mobile-toggle { display: none; }

.card-modern {
  background: var(--putih);
  border: 1px solid #eeedf5;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  transition: box-shadow 0.2s ease;
}
.card-modern:hover { box-shadow: 0 4px 12px rgba(30, 30, 47, 0.06); }
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }

.kartu-ringkas { padding: 16px; }
.kartu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.icon-bulat {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.bg-ungu { background: #6a2de6; }
.bg-hijau { background: #2ea56a; }
.bg-merah { background: #d94b4b; }
.bg-biru { background: #3c6fda; }
.kartu-label { color: var(--teks-muted); font-size: 13px; }
.kartu-nominal { font-size: 28px; font-weight: 700; margin: 0; }
.kartu-tren { font-size: 12px; margin-top: 4px; }
.nilai-hijau { color: var(--hijau); font-weight: 600; }
.nilai-merah { color: var(--merah); font-weight: 600; }

.btn { border-radius: 10px; transition: 0.2s ease; }
.btn:active { transform: scale(0.98); }
.btn-utama {
  color: #fff;
  border: none;
  background: #6a2de6;
}
.btn-utama:hover { color: #fff; background: #5521c7; }
.btn-light {
  background: #fff;
  border: 1px solid #dfe2eb;
  color: #2a2a3f;
}
.btn-light:hover {
  background: #f7f8fc;
  border-color: #d4d9e6;
}

.form-control, .form-select {
  border-radius: 12px;
  border: 1px solid #e4e6f0;
  padding: 10px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: rgba(106, 45, 230, 0.7);
  box-shadow: 0 0 0 3px rgba(106, 45, 230, 0.12);
}

.table-clean thead th {
  border-bottom: none;
  background: #f8f8fc;
  color: #667085;
  font-weight: 500;
  padding: 14px;
}
.table-clean tbody td {
  border-top: 1px solid #f1f1f6;
  padding: 14px;
}
.table-clean tbody tr:hover { background: #fafafe; }

.badge-status { padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-masuk { background: rgba(34, 197, 94, 0.12); color: #169c46; }
.badge-keluar { background: rgba(239, 68, 68, 0.12); color: #dc2626; }

.progress {
  background: #ebe9f6;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.progress-bar {
  background: linear-gradient(90deg, #8c59f2, #6a2de6);
  transition: width 0.6s ease;
}

.ai-insight { background: #f7f4ff; border: 1px solid #e5dcff; }

.chat-card { height: 68vh; display: flex; flex-direction: column; }
.chat-box {
  flex: 1;
  overflow-y: auto;
  border-radius: 14px;
  background: #f9f8ff;
  padding: 14px;
}
.chat-row { display: flex; margin-bottom: 10px; }
.chat-row.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
}
.chat-bubble.user { background: var(--ungu-utama); color: #fff; border-bottom-right-radius: 6px; }
.chat-bubble.ai { background: #fff; color: var(--teks-hitam); border: 1px solid #ececf4; border-bottom-left-radius: 6px; }
.chat-input-wrap { display: flex; gap: 10px; margin-top: 10px; }

.tab-nav { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-nav .btn { border-radius: 999px; padding: 8px 14px; }

.auth-shell {
  min-height: 100vh;
  background: #eef0f6;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
}
.auth-visual {
  padding: 36px;
  color: #fff;
  background:
    radial-gradient(1000px 500px at -10% -10%, rgba(255,255,255,.18), transparent 60%),
    linear-gradient(165deg, #5b22d2 0%, #6a2de6 55%, #4e1eb8 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  overflow: hidden;
}
.auth-visual-copy {
  max-width: 640px;
  position: relative;
  z-index: 2;
}
.auth-kicker {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: rgba(255,255,255,.88);
  border: 1px solid rgba(255,255,255,.32);
  background: rgba(255,255,255,.1);
  padding: 6px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.auth-visual-copy h2 {
  font-size: 42px;
  line-height: 1.15;
  margin-bottom: 12px;
}
.auth-visual-copy p {
  color: rgba(255,255,255,.92);
  max-width: 620px;
}
.auth-points {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.auth-points span {
  font-size: 14px;
  color: rgba(255,255,255,.9);
}
.auth-points i { margin-right: 6px; }
.auth-visual-art {
  flex: 1;
  min-height: 260px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,.11), rgba(255,255,255,.06));
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  backdrop-filter: blur(6px);
}
.auth-visual-image {
  width: 100%;
  height: 100%;
  max-height: 500px;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 16px 30px rgba(25, 18, 68, 0.25));
}
.auth-tagline {
  font-size: 20px;
  font-weight: 500;
  color: rgba(255,255,255,.96);
}
.auth-card {
  margin: auto;
  width: min(520px, 92%);
  background: #fff;
  border-radius: 24px;
  border: 1px solid #e4e7f2;
  box-shadow: 0 18px 48px rgba(30, 30, 47, 0.08);
  padding: 34px;
}
.auth-form .mb-3 { margin-bottom: 18px !important; }
.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: #2f3550;
  margin-bottom: 8px;
}
.auth-control {
  min-height: 52px;
  border-radius: 14px;
  border-color: #dce1ee;
}
.auth-submit {
  min-height: 50px;
  border-radius: 14px;
  font-weight: 600;
}
.auth-link {
  color: #5f2bdb;
  font-weight: 600;
  text-decoration: none;
}
.auth-link:hover {
  color: #4e1eb8;
  text-decoration: underline;
}
.auth-legal {
  font-size: 12px;
  color: #8a90a6;
}
.social-btn { border: 1px solid #e9e8f2; background: #fff; }

/* Desktop >= 1200px */
@media (min-width: 1200px) {
  .content-area { padding: 26px; }
}

/* Tablet 768px - 1199px */
@media (max-width: 1199px) and (min-width: 768px) {
  .sidebar {
    width: 86px;
    flex: 0 0 86px;
    padding: 18px 10px;
  }
  .sidebar .brand {
    justify-content: center;
    margin-bottom: 20px;
  }
  .sidebar .menu-link {
    justify-content: center;
    padding: 12px 10px;
  }
  .sidebar .sidebar-text { display: none; }
  .main-content {
    margin-left: 86px;
    width: calc(100% - 86px);
  }
  .topbar { padding: 14px 18px; }
  .search-wrap { width: 250px; }
  .page-title { font-size: 22px; }
  .content-area { padding: 18px; }
  .kartu-nominal { font-size: 24px; }
  .card-modern { border-radius: 14px; }
}

/* Mobile <= 767px */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    transition: 0.3s ease;
    width: 240px;
    flex: 0 0 240px;
    z-index: 30;
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar .sidebar-text { display: inline; }
  .main-content { margin-left: 0; width: 100%; }
  .mobile-toggle { display: inline-flex; }

  .topbar {
    min-height: 56px;
    padding: 8px 10px;
    border-bottom: 1px solid #ececf4;
  }
  .topbar-grid {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .page-title { font-size: 18px; line-height: 1.4; }
  .page-subtitle { display: none; }
  .search-wrap { display: none; }
  .icon-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }
  .icon-btn i { font-size: 20px; }
  .avatar-chip {
    width: auto;
    min-height: 36px;
    padding: 3px 6px;
  }
  .avatar-circle {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
  .avatar-media {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
  }
  .avatar-foto {
    width: 30px;
    height: 30px;
    min-width: 30px;
    max-width: 30px;
    min-height: 30px;
    max-height: 30px;
  }
  .avatar-chip .small { font-size: 12px; }
  .avatar-chip .small {
    max-width: 90px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .topbar .d-flex.align-items-center.gap-2.flex-wrap.justify-content-end {
    justify-content: flex-end !important;
    gap: 6px !important;
  }

  .content-area { padding: 14px; }
  .content-area > div,
  .content-area > .row {
    margin-bottom: 16px !important;
  }
  .content-area h2 {
    font-size: 18px !important;
    margin-bottom: 6px !important;
    line-height: 1.4;
  }
  .content-area p.text-muted {
    font-size: 13px;
    line-height: 1.45;
  }
  .card-modern { border-radius: 14px; }
  .kartu-ringkas { padding: 14px; }
  .kartu-ringkas .icon-bulat {
    width: 38px;
    height: 38px;
  }
  .kartu-ringkas .icon-bulat i { font-size: 18px; }
  .kartu-nominal { font-size: 22px; line-height: 1.3; }
  .kartu-label { font-size: 12px; }
  .section-title { font-size: 16px; margin-bottom: 8px; line-height: 1.4; }

  .btn,
  .form-control,
  .form-select {
    min-height: 42px;
    font-size: 13px;
  }
  .btn-sm {
    min-height: 40px;
    padding: 7px 10px;
    font-size: 13px;
  }
  .btn { padding: 8px 14px; }
  .form-control, .form-select { padding: 8px 10px; }
  .mb-2, .mb-3 { margin-bottom: 8px !important; }
  .g-2, .gy-2 { --bs-gutter-y: .5rem; }
  .g-2, .gx-2 { --bs-gutter-x: .5rem; }
  .d-flex.gap-2 { flex-wrap: wrap; }
  form.d-flex.gap-2 { width: 100%; }
  form.d-flex.gap-2 .form-control { min-width: 0 !important; flex: 1; }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-clean th, .table-clean td {
    white-space: nowrap;
    padding: 9px 8px;
    font-size: 13px;
  }
  .table-clean thead th { font-size: 12px; }
  .badge-status { font-size: 11px; padding: 5px 8px; }
  .btn-sm i { font-size: 16px; }

  .chat-card, .ai-chat-shell { min-height: 74vh; height: auto; }
  .chat-bubble {
    max-width: 92%;
    font-size: 13px;
    padding: 9px 12px;
  }
  .ai-input-wrap {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: 4px;
  }

  .tab-nav, .settings-tab-nav {
    display: grid;
    grid-template-columns: 1fr;
  }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-card { width: 100%; max-width: 430px; }

  .card-modern canvas {
    width: 100% !important;
    max-height: 220px !important;
  }
  .chartjs-legend li span { width: 10px !important; height: 10px !important; }

  .laporan-filter-wrap {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px !important;
  }
  .laporan-filter-form {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 10px !important;
  }
  .laporan-filter-form .form-select {
    width: 100%;
  }
  .laporan-export-btn {
    width: 100%;
    border: 1px solid #d8d8e6;
    background: #fff;
  }
  .laporan-header-mobile { margin-bottom: 16px !important; }

  .dashboard-summary-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-right: 0;
    margin-left: 0;
  }
  .dashboard-summary-item {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    padding-right: 0;
    padding-left: 0;
  }
  .dashboard-summary-item .kartu-ringkas {
    padding: 12px;
  }
  .dashboard-summary-item .kartu-nominal {
    font-size: 18px;
  }
  .dashboard-summary-item .kartu-tren {
    font-size: 12px;
  }
}
.modal.fade .modal-dialog {
  transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal.show .modal-dialog {
  transform: scale(1);
}
.tabungan-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tabungan-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 14px 30px rgba(30, 30, 47, 0.12);
}
.tabungan-progress {
  height: 8px;
}
.ai-chat-shell { min-height: 72vh; display: flex; flex-direction: column; }
.ai-chat-area { background: #fbfbff; border: 1px solid #ececf4; }
.ai-input-wrap { margin-top: auto; position: sticky; bottom: 0; background: #fff; padding-top: 8px; }
.fade-in-up { animation: fadeInUp .25s ease both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px);} to {opacity:1; transform: translateY(0);} }
.typing-dots span { animation: blink 1.2s infinite; display:inline-block; }
.typing-dots span:nth-child(2){ animation-delay:.2s; }
.typing-dots span:nth-child(3){ animation-delay:.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2;} 40% { opacity: 1;} }
.icon-kategori {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.tabs-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.tabs-scroll::-webkit-scrollbar {
  height: 6px;
}
.tabs-scroll::-webkit-scrollbar-thumb {
  background: #d8d8e6;
  border-radius: 999px;
}
.settings-tab-nav .btn { min-width: 110px; }
.profile-preview-box {
  width: 130px;
  height: 130px;
  border-radius: 20px;
  background: #f4f5fb;
  border: 1px dashed #d8dbe8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.profile-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-preview-fallback {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8a57f2, #6a2de6);
  color: #fff;
  font-weight: 700;
  font-size: 28px;
}
.switch-ungu:checked {
  background-color: #6a2de6;
  border-color: #6a2de6;
}
@media (max-width: 767px) {
  .settings-tab-nav {
    display: grid;
    grid-template-columns: 1fr;
  }
}
.badge-premium { background: rgba(106,45,230,.15); color: #6a2de6; }
.badge-biasa { background: #eceef4; color: #4b5563; }

.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 47, 0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast-area {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-item {
  min-width: 240px;
  max-width: 320px;
  background: #fff;
  border: 1px solid #e8e9f3;
  border-left: 4px solid #6a2de6;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(30, 30, 47, 0.12);
  padding: 10px 12px;
  font-size: 13px;
  animation: fadeInUp .2s ease both;
}
.toast-item.sukses { border-left-color: #2ea56a; }
.toast-item.gagal { border-left-color: #d94b4b; }
