*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F8FC;
  --surface: #FFFFFF;
  --primary: #5C6BC0;
  --primary-dark: #4A5AB0;
  --primary-light: #EEEEFF;
  --text: #0F172A;
  --fg: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06);
  --shadow: 0 4px 16px rgba(15,23,42,0.08);
  --shadow-lg: 0 16px 48px rgba(15,23,42,0.15);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Header ─────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.logo { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #5C6BC0, #7986CB);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 15px; font-weight: 700;
}
.logo-text { font-size: 17px; font-weight: 700; color: var(--primary); letter-spacing: -0.3px; }

.header-info { display: flex; align-items: center; gap: 12px; }
.btn-back { color: var(--muted); }
.btn-back:hover { color: var(--text); }
.txn-pill {
  background: var(--primary-light); color: var(--primary);
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
}
.btn-ghost {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 1.5px solid var(--border);
  color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 6px 12px; border-radius: var(--radius-sm);
  transition: all 0.15s; font-weight: 500;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: #C7D2FE; }

/* ── Navbar tabs ───────────────────────────────── */
.main-nav {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 3px;
}
.nav-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  background: transparent; color: var(--muted);
  transition: all 0.15s;
}
.nav-tab:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.nav-tab.active {
  background: var(--surface); color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Main ─────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 36px 24px 64px; }

/* ── Documents section (home) ──────────────────────── */
#documents-section { padding-top: 36px; padding-bottom: 80px; min-height: calc(100vh - 58px); }
.docs-page { max-width: 680px; margin: 0 auto; }
.docs-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.docs-title { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 2px; letter-spacing: -0.3px; }
.docs-sub { font-size: 13px; color: var(--muted); }
.docs-upload-btn {
  margin-top: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; font-size: 13px; font-weight: 600;
}
.docs-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 60px 24px 80px;
}
.docs-empty-icon { margin-bottom: 24px; }
.docs-empty-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.docs-empty-sub { font-size: 14px; color: var(--muted); margin-bottom: 32px; max-width: 300px; line-height: 1.65; }

/* ── Upload modal ─────────────────────────────────── */
.upload-modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.upload-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.upload-modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.upload-modal-box .drop-zone {
  border-radius: 0; border: none;
  border-bottom: 1px solid var(--border);
  padding: 40px;
}
.upload-modal-features { padding: 14px 20px; border: none; }

/* ── Upload (shared styles) ─────────────────────────── */
.upload-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; max-width: 460px; }

.drop-zone {
  width: 100%;
  background: linear-gradient(180deg, #FAFBFF 0%, var(--surface) 100%);
  border: 2px dashed #C7D2FE;
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.drop-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(92,107,192,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.drop-body { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; }

.upload-icon-ring {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, #EEF0FB, #DDE3FA);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 4px 14px rgba(92,107,192,0.15);
}
.drop-zone h2 { font-size: 18px; font-weight: 700; color: var(--text); }
.drop-zone p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn-primary {
  margin-top: 10px;
  background: linear-gradient(135deg, #5C6BC0, #7986CB);
  color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 12px 32px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(92,107,192,0.4);
  letter-spacing: 0.1px;
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.upload-error {
  display: flex; align-items: flex-start; gap: 10px;
  background: #FEF2F2; border: 1px solid #FECACA;
  color: #B91C1C; border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px; line-height: 1.5;
  width: 100%; text-align: left; margin-top: 4px;
}
.upload-error::before { content: "⚠️"; flex-shrink: 0; }

.features-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.feat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 5px 13px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}

/* ── History ─────────────────────────────────────── */
.history-section {
  width: 100%; max-width: 680px; margin: 0 auto;
}
.history-heading {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 10px;
}
.history-heading span:last-child { color: var(--muted); font-weight: 400; font-size: 12px; }
.history-grid { display: flex; flex-direction: column; gap: 10px; }
.history-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
  cursor: pointer; transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
  position: relative;
}
.history-card:hover {
  box-shadow: 0 4px 20px rgba(92,107,192,0.12);
  border-color: #C7D2FE;
  transform: translateY(-1px);
}
.history-icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.history-info { flex: 1; min-width: 0; }
.history-filename { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.history-amount { font-size: 15px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.history-del {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; cursor: pointer; font-size: 13px;
  color: #D1D5DB; padding: 2px 5px; border-radius: 6px; line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.history-del:hover { color: #EF4444; background: #FEE2E2; }

/* ── Loading ─────────────────────────────────────── */
.centered {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px;
  min-height: calc(100vh - 58px - 72px);
}
.spinner-ring {
  width: 44px; height: 44px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
.loading-text { color: var(--muted); font-size: 14px; font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Top row (hero + debt side by side) ──────────── */
.top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
  align-items: start;
}
@media (max-width: 700px) { .top-row { grid-template-columns: 1fr; } }

/* ── Hero (gasto) ───────────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, #3B4DBF 0%, #5C6BC0 55%, #7986CB 100%);
  border-radius: var(--radius);
  padding: 26px 28px;
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  box-shadow: 0 8px 30px rgba(59,77,191,0.28);
  position: relative; overflow: hidden;
  height: 100%;
}
.hero-card::before {
  content: '';
  position: absolute; top: -50px; right: -30px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,0.07);
  pointer-events: none;
}
.hero-card::after {
  content: '';
  position: absolute; bottom: -70px; left: -20px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}
.hero-left { display: flex; align-items: flex-start; gap: 16px; }
.hero-emoji { font-size: 36px; margin-top: 2px; }
.hero-label { color: rgba(255,255,255,0.82); font-size: 12px; font-weight: 600; letter-spacing: 0.1px; margin-bottom: 4px; }
.hero-amount { color: #fff; font-size: 30px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; }
.hero-sub { color: rgba(255,255,255,0.68); font-size: 12px; margin-top: 6px; }
.btn-white {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.35);
  color: #fff; border-radius: var(--radius-sm); padding: 8px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s; backdrop-filter: blur(4px);
}
.btn-white:hover { background: rgba(255,255,255,0.3); }

/* ── Debt card ──────────────────────────────────── */
/* ── Debt stat cards ────────────────────────────── */
.debt-stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-bottom: 20px;
}
.ds-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  border-top: 3px solid transparent;
  display: flex; flex-direction: column; gap: 4px;
}
.ds-owed         { border-top-color: #EF4444; }
.ds-paid         { border-top-color: #10B981; }
.ds-installments { border-top-color: #F59E0B; }
.ds-icon-wrap { font-size: 20px; margin-bottom: 4px; }
.ds-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.ds-val {
  font-size: 22px; font-weight: 800; color: var(--text);
  letter-spacing: -0.5px; line-height: 1.15; margin: 2px 0;
}
.ds-sub { font-size: 11px; color: var(--muted); }
.ds-minimo {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border);
}
.ds-minimo span { font-size: 11px; color: var(--muted); }
.ds-minimo strong { font-size: 12px; font-weight: 700; color: #D97706; }

/* Detail lists inside each stat card */
.ds-detail {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  max-height: 240px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.ds-detail-row {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 10px;
}
.ds-detail-left { flex: 1; min-width: 0; }
.ds-detail-desc {
  font-size: 11px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.ds-detail-date { font-size: 10px; color: var(--muted); margin-top: 1px; }
.ds-detail-val {
  font-size: 12px; font-weight: 700; color: var(--text);
  white-space: nowrap; flex-shrink: 0; text-align: right;
}
.ds-detail-val.green { color: #059669; }
.ds-detail-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.ds-per-mes { font-size: 10px; font-weight: 400; color: var(--muted); }
.ds-dif-val { font-size: 10px; color: #F59E0B; font-weight: 600; }
.ds-cuota-tag {
  font-size: 9px; font-weight: 700; background: #EEF0FB; color: var(--primary);
  border-radius: 4px; padding: 1px 4px; flex-shrink: 0;
}
.ds-empty { font-size: 11px; color: var(--muted); font-style: italic; text-align: center; padding: 8px 0; }

/* Installment progress bar inside detail */
.ds-inst-row { align-items: flex-start; }
.ds-inst-progress { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.ds-inst-track {
  width: 60px; height: 4px; background: var(--border);
  border-radius: 99px; overflow: hidden; flex-shrink: 0;
}
.ds-inst-fill { height: 100%; background: #F59E0B; border-radius: 99px; }
.ds-inst-progress span { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* ── Breakdown card ─────────────────────────────── */
.debt-breakdown-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.debt-breakdown-title { font-size: 13px; font-weight: 600; color: var(--text); }

@media (max-width: 640px) {
  .debt-stats-row { grid-template-columns: 1fr; }
}

.debt-bars { display: flex; flex-direction: column; gap: 4px; }
.debt-bar-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--muted);
}
.debt-bar-row strong { font-size: 12px; color: var(--text); }
.debt-bar-track {
  height: 6px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.debt-bar-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.debt-bar-fill.blue   { background: #5C6BC0; }
.debt-bar-fill.orange { background: #F59E0B; }

/* Simulator */
.sim-row { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.sim-label { font-size: 11px; color: var(--muted); font-weight: 500; }
.sim-input-row {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px;
}
.sim-prefix { color: var(--muted); font-size: 13px; }
.sim-input-row input {
  border: none; outline: none; background: transparent;
  font-size: 14px; font-weight: 600; width: 100%; color: var(--text);
}
.sim-result {
  font-size: 13px; font-weight: 600; color: #059669;
  background: #D1FAE5; border-radius: 8px; padding: 8px 12px;
  text-align: center;
}

/* ── Accordion ──────────────────────────────────── */
.accordion-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  cursor: pointer; transition: background 0.15s; margin-bottom: 0;
}
.accordion-toggle:hover { background: #FAFBFF; }
.accordion-left { display: flex; align-items: center; gap: 12px; text-align: left; }
.accordion-icon { font-size: 20px; }
.accordion-title { font-size: 14px; font-weight: 600; }
.accordion-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Installments ───────────────────────────────── */
.cuotas-list {
  display: flex; flex-direction: column; gap: 0;
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease, padding 0.2s;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin-bottom: 20px;
}
.cuotas-list.cuotas-open { max-height: 1000px; padding: 8px 0; }
.cuota-row {
  background: var(--surface);
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
}
.cuota-row:last-child { border-bottom: none; }
.cuota-desc  { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.cuota-meta  { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.cuota-track { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.cuota-fill  { height: 100%; border-radius: 99px; background: #5C6BC0; transition: width 0.6s ease; }
.cuota-tag-pending {
  font-size: 10px; font-weight: 700; color: #D97706;
  background: #FEF3C7; padding: 2px 8px; border-radius: 99px;
  white-space: nowrap;
}
.cuota-right { text-align: right; }
.cuota-mes   { font-size: 11px; color: var(--muted); }
.cuota-val   { font-size: 15px; font-weight: 800; color: var(--text); }
.cuota-dif   { font-size: 11px; color: #EF4444; margin-top: 2px; }

/* ── Section heading ─────────────────────────────────────── */
.section-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.section-heading span:first-child { font-size: 16px; font-weight: 700; color: var(--text); }
.section-hint { font-size: 12px; color: var(--muted); }

/* ── Category grid ─────────────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}
.cat-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 1px 4px rgba(15,23,42,0.06);
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.15s;
  position: relative; overflow: hidden;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(15,23,42,0.1); }
.cat-card.active { border-color: var(--cat-accent, var(--primary)); }
.cat-card.add-card {
  border: 2px dashed var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--muted); font-size: 13px;
  box-shadow: none; min-height: 120px;
}
.cat-card.add-card:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.cat-icon { font-size: 26px; margin-bottom: 6px; line-height: 1; }
.cat-name { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cat-amount { font-size: 17px; font-weight: 800; margin-bottom: 2px; }
.cat-count { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.cat-bar { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.cat-pct { font-size: 10px; color: var(--muted); margin-top: 4px; }
.cat-delete {
  position: absolute; top: 6px; right: 6px;
  background: #FEE2E2; color: #DC2626; border: none;
  border-radius: 50%; width: 18px; height: 18px;
  font-size: 10px; cursor: pointer; display: none;
  align-items: center; justify-content: center;
  line-height: 1;
}
.cat-card:hover .cat-delete { display: flex; }

/* ── List controls ─────────────────────────────────────── */
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.list-title { font-size: 15px; font-weight: 600; }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 14px; min-width: 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92,107,192,0.1);
}
.search-wrap input {
  border: none; outline: none; font-size: 13px;
  color: var(--text); background: transparent; width: 100%;
}

/* ── Filters ─────────────────────────────────────── */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 13px; border-radius: 99px; border: 2px solid transparent;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; background: var(--surface); color: var(--muted);
}
.chip:hover { opacity: 0.85; }
.chip.active { border-color: currentColor; }
.chip-icon { font-size: 13px; }

/* ── Table card ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #F8FAFC; padding: 10px 16px;
  text-align: left; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: #94A3B8; border-bottom: 1px solid var(--border);
  font-weight: 700;
}
th.right, td.right { text-align: right; }

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFBFF; }
tbody tr.row-selected { background: #EEF0FB; }
tbody tr.row-selected:hover { background: #E5E8F8; }
tbody td { padding: 10px 16px; vertical-align: middle; }

/* Checkbox column */
.txn-checkbox {
  width: 15px; height: 15px; accent-color: var(--primary);
  cursor: pointer; display: block; margin: 0 auto;
}

/* ── FAB: Nuevo PDF ─────────────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(92, 107, 192, 0.45);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.fab:hover {
  background: #4a5ab0;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(92, 107, 192, 0.55);
}
.fab:active { transform: translateY(0); }

/* Bulk action bar */
.bulk-bar {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-radius: 99px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 50; white-space: nowrap;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.bulk-count { font-size: 13px; font-weight: 500; color: #D1D5DB; }
.btn-bulk {
  display: flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff; border: none;
  border-radius: 99px; padding: 7px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn-bulk:hover { background: #4f5ea8; }
.btn-bulk-cancel {
  background: none; border: none; color: #9CA3AF;
  font-size: 13px; cursor: pointer; padding: 4px 8px;
  border-radius: 99px; transition: color 0.15s;
}
.btn-bulk-cancel:hover { color: #fff; }

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase;
}
td.avatar-cell { width: 52px; }

/* Description two-line */
.desc-name { font-size: 13px; font-weight: 500; color: var(--text); }
.desc-date { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* Multi-badges */
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s; white-space: nowrap;
}
.badge:hover { opacity: 0.75; }
.badge-icon { font-size: 11px; }
.badge-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); color: var(--muted);
  font-size: 14px; cursor: pointer; border: 1px solid var(--border);
  transition: background 0.15s;
}
.badge-add:hover { background: var(--primary-light); color: var(--primary); }

.amount-cell { font-weight: 700; white-space: nowrap; font-size: 14px; }
.amount-cell.credit { color: #10B981; }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 56px; gap: 10px; color: var(--muted);
}
.empty-icon { font-size: 36px; }

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17,24,39,0.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 6px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); }
.modal-desc { font-size: 12px; color: var(--muted); margin-bottom: 16px; }

/* Confirm / password modal */
.confirm-box { max-width: 360px; text-align: center; padding: 36px 32px; }
.confirm-icon { font-size: 32px; margin-bottom: 12px; }
.confirm-msg { font-size: 14px; color: var(--text); line-height: 1.5; margin-bottom: 16px; }

/* Password modal */
.pwd-modal-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(135deg, #EEF0FB, #DDE0F7);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 28px;
}
.pwd-modal-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
}
.pwd-modal-sub {
  font-size: 13px; color: var(--muted); margin-bottom: 24px; line-height: 1.5;
}
.pwd-input-wrap {
  position: relative; margin-bottom: 20px;
}
.pwd-input-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.pwd-input {
  width: 100%; padding: 11px 14px 11px 40px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--bg);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--text);
}
.pwd-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92,107,192,0.12);
}
.pwd-input-error { border-color: #EF4444 !important; }
.pwd-error {
  font-size: 12px; color: #B91C1C; text-align: left;
  margin-top: -14px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 5px;
}
.pwd-error::before { content: "⚠️"; font-size: 11px; }
.pwd-modal-actions { display: flex; gap: 10px; }
.pwd-modal-actions .btn-cancel { flex: 1; }
.pwd-modal-actions .btn-open {
  flex: 2; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s;
}
.pwd-modal-actions .btn-open:hover { opacity: 0.88; }

/* Account type badge */
.account-type-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.btn-danger {
  background: #EF4444; color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 9px 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #DC2626; }

.modal-cat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 16px;
}
.modal-cat-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 2px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: all 0.15s; text-align: left;
}
.modal-cat-btn:hover { opacity: 0.85; }
.modal-cat-btn.selected { border-color: currentColor; }
.modal-cat-check { margin-left: auto; font-size: 14px; }
.modal-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-confirm {
  flex: 1; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-confirm:hover { opacity: 0.88; }
.btn-cancel {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 18px;
  font-size: 14px; cursor: pointer; transition: background 0.15s;
}
.btn-cancel:hover { background: var(--border); }

/* New category form */
.new-cat-divider { display: flex; align-items: center; gap: 8px; margin: 12px 0 10px; }
.new-cat-divider span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.new-cat-divider::before, .new-cat-divider::after {
  content: ''; flex: 1; border-top: 1px solid var(--border);
}
.new-cat-block { display: flex; flex-direction: column; gap: 4px; }
.new-cat-sub { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.new-cat-form { display: flex; gap: 6px; align-items: center; }
.new-cat-name {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; outline: none;
}
.new-cat-name:focus { border-color: var(--primary); }

/* Emoji picker */
.emoji-picker {
  display: flex; flex-wrap: wrap; gap: 4px;
  max-height: 136px; overflow-y: auto;
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 6px; margin-top: 4px;
}
.emoji-btn {
  width: 36px; height: 36px; border: 2px solid transparent;
  border-radius: 8px; background: var(--surface);
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.emoji-btn:hover { background: #EEF0FB; }
.emoji-btn.selected { border-color: var(--primary); background: var(--primary-light); }

.color-dots { display: flex; gap: 6px; margin-top: 4px; }
.color-dot {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color 0.15s;
}
.color-dot.selected { border-color: #374151; }
.btn-add-cat {
  background: var(--primary); color: white; border: none;
  border-radius: var(--radius-sm); padding: 8px 14px;
  font-size: 13px; cursor: pointer; font-weight: 500; white-space: nowrap;
}

/* ── Header right (user menu) ───────────────────── */
.header-right { display: flex; align-items: center; gap: 10px; }
.user-menu    { display: flex; align-items: center; gap: 8px; }
.user-name    { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Admin panel ─────────────────────────────────── */
.admin-box { max-width: 500px; width: 100%; }

.admin-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 10px;
}
.admin-input {
  flex: 1; min-width: 120px;
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
  background: var(--bg); color: var(--text);
  outline: none;
}
.admin-input:focus { border-color: var(--primary); }
.admin-check-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}

.admin-error {
  background: #FEE2E2; color: #DC2626;
  border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px;
  margin-bottom: 12px;
}

.admin-user-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto;
  margin-top: 12px;
}
.admin-user-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.admin-user-info {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.admin-user-name  { font-weight: 600; font-size: 13px; }
.admin-user-email { font-size: 12px; color: var(--muted); }
.admin-badge {
  background: var(--primary-light); color: var(--primary);
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 99px;
}
.admin-google  { font-size: 11px; color: #059669; font-weight: 600; }
.admin-pending { font-size: 11px; color: var(--muted); }

/* ── Utils ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
  /* Header */
  header { padding: 0 14px; height: 52px; }
  .user-name { display: none; }
  .txn-pill { display: none; }
  .btn-back-label { display: none; }
  .btn-ghost { padding: 8px 10px; font-size: 12px; gap: 4px; }
  #admin-btn span { display: none; }
  .lang-btn { padding: 3px 7px; font-size: 10px; }

  /* Main */
  main { padding: 16px 12px 88px; }

  /* Bottom nav bar */
  .main-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    border-radius: 0;
    padding: 4px 0 env(safe-area-inset-bottom, 6px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    z-index: 30;
    background: var(--surface);
    justify-content: stretch;
  }
  .nav-tab {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
    justify-content: center;
  }
  .nav-tab.active {
    background: none;
    box-shadow: none;
    color: var(--primary);
    border-top: 2px solid var(--primary);
  }
  .nav-tab svg { width: 18px; height: 18px; }

  /* Hero */
  .hero-card {
    flex-direction: column; align-items: flex-start;
    padding: 18px 16px; gap: 10px;
  }
  .hero-left { gap: 12px; }
  .hero-emoji { font-size: 28px; }
  .hero-amount { font-size: 24px; }
  .hero-sub { font-size: 11px; }

  /* Category grid: 2 columns */
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cat-card { padding: 12px 10px; }
  .cat-icon { font-size: 22px; margin-bottom: 4px; }
  .cat-amount { font-size: 14px; }
  .cat-card.add-card { min-height: 90px; }

  /* Section heading */
  .section-heading { margin-bottom: 10px; }
  .section-hint { display: none; }

  /* Filters */
  .filters { gap: 5px; }
  .chip { font-size: 11px; padding: 4px 10px; }

  /* List header */
  .list-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .search-wrap { width: 100%; min-width: unset; }

  /* Table */
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #txn-table thead th:nth-child(1),
  #txn-table tbody  td:nth-child(1) { display: none; }
  tbody td { padding: 9px 10px; }
  thead th { padding: 8px 10px; }
  .desc-name { font-size: 12px; }
  .desc-date { font-size: 10px; }
  .amount-cell { font-size: 13px; }
  .badge { font-size: 10px; padding: 2px 6px; }
  td.avatar-cell { width: 40px; }
  .avatar { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }

  /* Modal as bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    border-radius: 20px 20px 0 0;
    padding: 20px 16px 28px;
    max-height: 85vh;
  }
  .modal-cat-grid { grid-template-columns: 1fr; }

  /* Confirm modal stays centered on mobile */
  #confirm-modal { align-items: center; padding: 20px; }
  #confirm-modal .modal-box { border-radius: var(--radius); }

  /* Debt stats */
  .debt-stats-row { grid-template-columns: 1fr; }

  /* Documents section */
  #documents-section { padding-top: 20px; padding-bottom: 100px; }
  .docs-page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .docs-empty { padding: 48px 16px; }
  .docs-empty-icon { font-size: 44px; }

  /* Upload modal as bottom sheet */
  #upload-modal { align-items: flex-end; padding: 0; }
  .upload-modal-box { max-width: 100%; border-radius: 20px 20px 0 0; }
  .upload-modal-box .drop-zone { padding: 28px 20px; }
  .upload-icon-ring { width: 60px; height: 60px; }
  .drop-zone h2 { font-size: 17px; }

  /* History cards */
  .history-card { padding: 11px 12px; gap: 10px; }
  .history-icon { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }
  .history-filename { font-size: 12px; }
  .history-amount { font-size: 13px; }

  /* Bulk action bar */
  .bulk-bar { bottom: 72px; padding: 10px 16px; font-size: 12px; gap: 8px; }
  .bulk-count { font-size: 12px; }
  .btn-bulk { padding: 6px 12px; font-size: 12px; }

  /* Breakdown card */
  .debt-breakdown-card { padding: 16px; }

  /* FAB: positioned above the fixed bottom nav */
  .fab {
    bottom: 72px;
    right: 16px;
    padding: 11px 18px;
    font-size: 13px;
  }
}

/* ── Language toggle ────────────────────────────────────── */
.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid var(--border);
}
.lang-btn {
  padding: 3px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.04em;
}
.lang-btn.active {
  background: var(--primary);
  color: #fff;
}
.lang-btn:hover:not(.active) {
  color: var(--text);
}

/* Slightly larger phones/small tablets */
@media (max-width: 380px) {
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .cat-card { padding: 10px 8px; }
  .cat-amount { font-size: 13px; }
  .hero-amount { font-size: 22px; }
}
