/* UangKu - Premium Dark Banking PWA */
/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e17;
  --surface: #141b2d;
  --card: #1a2236;
  --elevated: #1f2940;
  --accent: #00d4aa;
  --accent-dim: rgba(0,212,170,.15);
  --danger: #ff4757;
  --blue: #3742fa;
  --warning: #ffa502;
  --text: #ffffff;
  --text2: #8892b0;
  --muted: #495670;
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-pill: 24px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

html {
  height: 100vh;
  height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
button, a, input, select, textarea, label { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }

.hidden { display: none !important; }

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .5s ease;
}
.loading-screen.hide { opacity: 0; pointer-events: none; }

.loading-logo { font-size: 64px; margin-bottom: 16px; animation: pulse 2s infinite; }
.loading-text { font-size: 28px; font-weight: 700; letter-spacing: 2px; margin-bottom: 32px; }
.loading-spinner {
  width: 36px; height: 36px; border: 3px solid var(--muted);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ===== AUTH SCREEN ===== */
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-container {
  width: 100%; max-width: 400px;
  background: var(--card); border-radius: var(--radius-card);
  padding: 32px 24px; text-align: center;
}
.auth-logo { font-size: 56px; margin-bottom: 8px; }
.auth-title { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.auth-form { text-align: left; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text2); }
.auth-switch a { font-weight: 600; }

/* ===== INPUTS ===== */
.input-group { margin-bottom: 16px; }
.input-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text2); margin-bottom: 6px;
}
.input-group input,
.input-group textarea,
.input-group select {
  width: 100%; font-size: 16px; padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--muted); border-radius: var(--radius-input);
  outline: none; transition: border-color .2s;
  -webkit-appearance: none; appearance: none;
}
.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus { border-color: var(--accent); }

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.textarea {
  width: 100%; min-height: 120px; resize: vertical;
  font-size: 16px; padding: 12px 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--muted); border-radius: var(--radius-input);
  outline: none;
}
.textarea:focus { border-color: var(--accent); }

.select-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}

.file-input {
  font-size: 14px !important;
  padding: 10px 14px !important;
  cursor: pointer;
}
.file-input::file-selector-button {
  background: var(--accent); color: #000; border: none;
  padding: 6px 14px; border-radius: 8px; font-weight: 600;
  font-size: 13px; margin-right: 10px; cursor: pointer;
}

.amount-input { font-size: 28px !important; font-weight: 700; text-align: center; }
.amount-group { text-align: center; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  padding: 13px 24px; border-radius: var(--radius-input);
  border: none; cursor: pointer; transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:active { background: #00b894; transform: scale(.97); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { opacity: .85; transform: scale(.97); }
.btn-outline {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:active { background: var(--accent-dim); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; margin-top: 16px; }
.btn-row .btn { flex: 1; }

.btn-icon {
  background: var(--surface); color: var(--text); border: none;
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:active { background: var(--elevated); }

.btn-close {
  background: none; border: none; color: var(--text2);
  font-size: 22px; cursor: pointer; padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

/* ===== APP CONTAINER ===== */
.app-container {
  max-width: 480px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  position: relative;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 48px);
}

/* ===== TOP BAR ===== */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-t));
  background: rgba(10,14,23,.85);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(73,86,112,.2);
}
.top-bar-left { display: flex; flex-direction: column; }
.greeting { font-size: 13px; color: var(--text2); }
.greeting-name { font-size: 17px; font-weight: 700; }
.top-bar-right { display: flex; align-items: center; gap: 8px; }
#btn-month-selector {
  width: auto; padding: 8px 14px; border-radius: var(--radius-pill);
  display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
}
.icon-chevron { font-size: 12px; color: var(--text2); }

/* ===== PAGES ===== */
.page { flex: 1; }
.page-content { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.page-title { font-size: 22px; font-weight: 700; }

/* ===== BALANCE CARD ===== */
.balance-card {
  background: linear-gradient(135deg, var(--accent), #00b894);
  border-radius: var(--radius-card); padding: 24px;
  text-align: center; color: #000;
}
.balance-label { font-size: 13px; opacity: .7; margin-bottom: 4px; font-weight: 600; }
.balance-amount { font-size: 32px; font-weight: 800; letter-spacing: -1px; }

/* ===== SUMMARY ROW ===== */
.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-card {
  background: var(--card); border-radius: var(--radius-card);
  padding: 16px; display: flex; align-items: center; gap: 12px;
}
.summary-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.summary-income .summary-icon { background: rgba(0,212,170,.15); color: var(--accent); }
.summary-expense .summary-icon { background: rgba(255,71,87,.15); color: var(--danger); }
.summary-label { font-size: 11px; color: var(--text2); margin-bottom: 2px; }
.summary-amount { font-size: 15px; font-weight: 700; }

/* ===== CARDS ===== */
.card {
  background: var(--card); border-radius: var(--radius-card);
  padding: 20px; overflow: hidden;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.card-header .card-title { margin-bottom: 0; }
.card-link { font-size: 13px; color: var(--accent); font-weight: 600; }
.card-desc { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

/* ===== CHART ===== */
.chart-container { position: relative; width: 100%; margin-bottom: 12px; }
.chart-container canvas { width: 100% !important; max-height: 220px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ===== TRANSACTION LIST ===== */
.tx-list, .tx-list-grouped { display: flex; flex-direction: column; gap: 2px; }
.tx-date-group { margin-bottom: 8px; }
.tx-date-label {
  font-size: 12px; font-weight: 600; color: var(--text2);
  padding: 8px 0 6px; position: sticky; top: 0;
  background: var(--bg);
}
.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid rgba(73,86,112,.15);
  cursor: pointer; transition: background .15s;
}
.tx-item:last-child { border-bottom: none; }
.tx-item:active { background: var(--surface); border-radius: 12px; }
.tx-icon {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); display: flex; align-items: center;
  justify-content: center; font-size: 20px; flex-shrink: 0;
}
.tx-details { flex: 1; min-width: 0; }
.tx-desc { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text2); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tx-wallet-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--elevated); padding: 2px 8px; border-radius: 6px;
  font-size: 10px; color: var(--text2);
}
.tx-amount { font-size: 14px; font-weight: 700; text-align: right; white-space: nowrap; flex-shrink: 0; }
.tx-amount.income { color: var(--accent); }
.tx-amount.expense { color: var(--danger); }

/* ===== MONTH NAV ===== */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: var(--radius-card); padding: 8px 12px;
}
#tx-month-label { font-size: 15px; font-weight: 700; }

/* ===== FILTER TABS ===== */
.filter-tabs { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 8px 18px; border-radius: var(--radius-pill);
  background: var(--card); color: var(--text2); border: none;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  cursor: pointer; transition: all .2s; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.filter-tab.active { background: var(--accent); color: #000; }

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius-input);
  padding: 10px 14px;
}
.search-icon { font-size: 16px; flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 16px; font-family: inherit;
}
.search-input::placeholder { color: var(--muted); }

/* ===== DEBT LIST ===== */
.debt-list { display: flex; flex-direction: column; gap: 12px; }
.debt-card {
  background: var(--card); border-radius: var(--radius-card);
  padding: 16px; cursor: pointer;
}
.debt-card:active { background: var(--elevated); }
.debt-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.debt-creditor { font-size: 15px; font-weight: 700; }
.debt-type-badge {
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.debt-type-badge.hutang { background: rgba(255,71,87,.15); color: var(--danger); }
.debt-type-badge.piutang { background: rgba(0,212,170,.15); color: var(--accent); }
.debt-amounts { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.debt-progress { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.debt-progress-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; }
.debt-actions { display: flex; gap: 8px; }
.debt-actions .btn { padding: 8px 14px; font-size: 12px; }

/* ===== WALLET LIST ===== */
.wallet-list { display: flex; flex-direction: column; gap: 12px; }
.wallet-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: var(--radius-card);
  padding: 16px; border-left: 4px solid var(--accent);
  cursor: pointer; transition: background .15s;
}
.wallet-card:active { background: var(--elevated); }
.w-icon { font-size: 28px; flex-shrink: 0; }
.w-info { flex: 1; min-width: 0; }
.w-name { font-size: 15px; font-weight: 700; }
.w-type { font-size: 12px; color: var(--text2); }
.w-balance { font-size: 15px; font-weight: 700; text-align: right; white-space: nowrap; }

/* ===== WISHLIST ===== */
.wishlist-list { display: flex; flex-direction: column; gap: 12px; }
.wishlist-card {
  background: var(--card); border-radius: var(--radius-card);
  padding: 16px; cursor: pointer;
}
.wishlist-card:active { background: var(--elevated); }
.wishlist-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.wishlist-amounts { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.wishlist-progress { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.wishlist-progress-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; }
.wishlist-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.wishlist-actions { display: flex; gap: 8px; }
.wishlist-actions .btn { padding: 8px 14px; font-size: 12px; }

/* ===== PROFILE ===== */
.profile-card { text-align: center; padding: 28px 20px; }
.profile-avatar { font-size: 56px; margin-bottom: 12px; display: block; }
.profile-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.profile-email { font-size: 14px; color: var(--text2); }

/* ===== BUDGET ===== */
.budget-list { display: flex; flex-direction: column; gap: 14px; }
.budget-bar-wrap { }
.budget-bar-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.budget-bar { height: 8px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.budget-bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.budget-bar-fill.ok { background: var(--accent); }
.budget-bar-fill.warning { background: var(--warning); }
.budget-bar-fill.over { background: var(--danger); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid rgba(73,86,112,.2);
  display: flex; align-items: center; justify-content: space-around;
  max-width: 480px; margin: 0 auto;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; color: var(--muted);
  font-size: 10px; font-family: inherit; cursor: pointer;
  padding: 6px 0; flex: 1; transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; display: block; line-height: 1; }
.nav-label { font-weight: 600; }
.nav-item-center { position: relative; }
.nav-icon-fab {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-top: -18px;
  box-shadow: 0 4px 16px rgba(0,212,170,.3);
}

/* ===== MODALS ===== */
.modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal-sheet {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px;
  max-height: 90vh; max-height: 90dvh;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  animation: slideUp .3s ease;
  padding-bottom: var(--safe-b);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-handle {
  width: 40px; height: 4px; background: var(--muted);
  border-radius: 2px; margin: 10px auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 20px 12px; border-bottom: 1px solid rgba(73,86,112,.2);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body {
  padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* ===== TYPE TOGGLE ===== */
.type-toggle {
  display: flex; gap: 8px; margin-bottom: 20px;
  background: var(--surface); border-radius: var(--radius-input); padding: 4px;
}
.type-btn {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: none; color: var(--text2); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all .2s;
  font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.type-btn.active { background: var(--accent); color: #000; }

/* ===== CATEGORY GRID ===== */
.category-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: var(--radius-input);
  background: var(--surface); border: 2px solid transparent;
  cursor: pointer; font-size: 11px; color: var(--text2);
  text-align: center; transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-item:active, .cat-item.active { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }
.cat-icon { font-size: 24px; }

/* ===== COLOR & ICON PICKER ===== */
.color-picker, .icon-picker { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.color-swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.color-swatch.active { border-color: var(--text); }
.icon-option {
  width: 44px; height: 44px; border-radius: var(--radius-input);
  background: var(--surface); border: 2px solid transparent;
  font-size: 22px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-option.active { border-color: var(--accent); background: var(--accent-dim); }

/* ===== TRANSFER ARROW ===== */
.transfer-arrow {
  text-align: center; font-size: 24px; color: var(--text2);
  padding: 8px 0;
}

/* ===== PARSED ITEMS (BULK) ===== */
.parsed-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(73,86,112,.15);
  font-size: 13px;
}
.p-amount { font-weight: 700; min-width: 80px; }
.p-desc { flex: 1; color: var(--text2); }
.p-cat { color: var(--muted); font-size: 12px; }

.bulk-summary-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 12px;
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text2); }
.empty-icon { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
  left: 50%; transform: translateX(-50%) translateY(100px);
  z-index: 9000; padding: 12px 24px; border-radius: var(--radius-input);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  max-width: calc(100% - 32px); text-align: center;
  transition: transform .3s ease, opacity .3s ease;
  opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.toast.success { background: var(--accent); color: #000; }
.toast.error { background: var(--danger); color: #fff; }
.toast.hidden { display: none; }

/* ===== SMALL PHONES (320px) ===== */
@media (max-width: 359px) {
  .balance-amount { font-size: 26px; }
  .summary-card { padding: 12px 10px; gap: 8px; }
  .summary-amount { font-size: 13px; }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .nav-icon-fab { width: 42px; height: 42px; margin-top: -14px; }
  .page-content { padding: 12px; gap: 12px; }
  .modal-body { padding: 16px; }
}

/* ===== LANDSCAPE ===== */
@media (orientation: landscape) and (max-height: 500px) {
  .modal-sheet { max-height: 95vh; max-height: 95dvh; }
  .balance-card { padding: 16px; }
  .balance-amount { font-size: 26px; }
  .top-bar { padding-top: 8px; }
}

/* ===== DESKTOP CENTERING ===== */
@media (min-width: 481px) {
  .auth-screen { background: var(--bg); }
  .bottom-nav { left: 50%; transform: translateX(-50%); }
}
