:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #eef3ff;
  --text: #111827;
  --muted: #5e687b;
  --primary: #0e2a66;
  --primary-2: #194bb6;
  --success: #1f7a45;
  --danger: #ba1a1a;
  --border: #d6dfef;
  --shadow: 0 10px 24px rgba(11, 29, 76, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 95% 0%, #dfe9ff, transparent 40%), var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 14px 90px;
}
.tab { display: none; }
.tab.active { display: block; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.section-head.compact {
  margin-bottom: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.section-head h2, .section-head h3 { margin: 0; }
.section-head.compact .btn { margin-left: auto; }
.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}
.btn-ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.auth-gate {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 14px 0;
}
.auth-card {
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.step-badge {
  display: inline-block;
  background: var(--surface-2);
  color: var(--primary);
  border: 1px solid #c8d8ff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}
.inline-banner {
  margin: 10px 0;
  border: 1px solid var(--border);
  background: #f9fbff;
  color: var(--muted);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 13px;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.status-item {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 9px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
label { display: grid; gap: 6px; font-size: 14px; margin-bottom: 10px; }
input, select {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.row { display: flex; gap: 8px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.home-context {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.kpi.kpi-income { border-left: 4px solid #1f7a45; }
.kpi.kpi-expense { border-left: 4px solid #ba1a1a; }
.kpi.kpi-balance { border-left: 4px solid #194bb6; }
.kpi.kpi-neutral { border-left: 4px solid #6b7280; }
.kpi h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi p { margin: 0; font-size: 20px; font-weight: 700; }
.home-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.home-trend-card {
  min-height: 180px;
}
.home-trend-card canvas {
  height: 120px !important;
}
.card-stack { display: grid; gap: 8px; }
.item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.item:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(11, 29, 76, 0.12);
}
.tx-empty {
  text-align: center;
  color: var(--muted);
  padding: 16px;
}
.item .row { justify-content: space-between; align-items: center; }
.item .meta { margin-top: 6px; color: var(--muted); font-size: 12px; }
.item .actions { display: flex; gap: 6px; margin-top: 8px; }
.tx-card {
  border-left: 4px solid #d6dfef;
}
.tx-card.expense { border-left-color: #efc1be; }
.tx-card.income { border-left-color: #bfe7cf; }
.tx-card .tx-card-amount {
  font-size: 18px;
}
.tx-card.expense .tx-card-amount { color: var(--danger); }
.tx-card.income .tx-card-amount { color: var(--success); }
.home-tx {
  border-left: 4px solid #d6dfef;
}
.home-tx.expense { border-left-color: #efc1be; }
.home-tx.income { border-left-color: #bfe7cf; }
.home-tx-top {
  margin-bottom: 2px;
}
.home-tx-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.home-tx-amount {
  font-size: 18px;
}
.home-tx-note {
  font-style: italic;
}
.type-chip {
  display: inline-block;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border: 1px solid transparent;
}
.type-chip.income { background: #e8f7ef; color: var(--success); border-color: #bfe7cf; }
.type-chip.expense { background: #fbe9e8; color: var(--danger); border-color: #efc1be; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chips.mini { margin: 0; }
.chips button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.chips button.active { background: var(--surface-2); color: var(--primary); border-color: #b8cdfb; }
.reports-filters {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
}
.reports-filters.sticky {
  position: sticky;
  top: 74px;
  z-index: 9;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}
.tx-quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.tx-stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}
.tx-stat span {
  font-size: 12px;
  color: var(--muted);
}
.tx-stat strong {
  font-size: 18px;
  line-height: 1.1;
}
.tx-stat small {
  font-size: 11px;
  color: var(--muted);
}
.tx-filters {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px;
  margin-bottom: 10px;
}
.tx-filters label {
  margin: 0;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.tx-filters input {
  background: #fcfdff;
}

.tx-filter-actions {
  display: flex;
  align-items: end;
}
.tx-filter-actions .btn {
  width: 100%;
}
.chart-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
  min-height: 250px;
}
.chart-card h3 { margin: 0 0 8px; }
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}
.settings-block {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
}
.categories-card {
  position: relative;
}
.settings-status-strip {
  position: sticky;
  top: 74px;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.settings-status-strip span {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
}
.help-text {
  color: var(--muted);
  font-size: 12px;
}
.connection-card .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.muted-badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
}
.sticky-tools {
  position: static;
  background: var(--surface);
  padding-bottom: 8px;
  padding-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.categories-card #categoryList {
  position: relative;
  z-index: 1;
  max-height: 52vh;
  overflow: auto;
  padding-right: 2px;
}
.category-inline {
  display: grid;
  grid-template-columns: 1fr 180px;
  margin-top: 0;
}
.filters-inline {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 8px;
  margin-bottom: 10px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox input { width: auto; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 4px;
}
.switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #c7d2e7;
  border: 1px solid #b2c1df;
  border-radius: 999px;
  transition: 0.2s ease;
}
.switch .slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: 0.2s ease;
}
.switch input:checked + .slider {
  background: #cfe0ff;
  border-color: #8fb2f8;
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: var(--primary);
}
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0 12px;
}
.preview-box {
  border: 1px dashed #b9c8e8;
  background: #f7faff;
  border-radius: 12px;
  padding: 9px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 2px;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 10px 14px;
  border-top: 1px solid var(--border);
  background: #ffffffec;
  backdrop-filter: blur(6px);
}
.bottom-nav button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  padding: 9px 6px;
  font: inherit;
  cursor: pointer;
}
.bottom-nav button.active {
  background: var(--surface-2);
  color: var(--primary);
  border-color: #b8cdfb;
}
.fab {
  position: fixed;
  right: 14px;
  bottom: 76px;
  z-index: 40;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 10px 24px rgba(13, 41, 104, 0.34);
  cursor: pointer;
}
menu { display: flex; justify-content: flex-end; gap: 8px; margin: 0; padding: 0; }
dialog {
  border: none;
  border-radius: 16px;
  width: min(94vw, 420px);
  box-shadow: var(--shadow);
  max-height: 88vh;
  overflow: auto;
}
dialog::backdrop { background: rgba(10, 21, 50, 0.5); }
#toast {
  position: fixed;
  right: 14px;
  bottom: 146px;
  z-index: 50;
  background: #1f2937;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  display: none;
}
@media (max-width: 700px) {
  .topbar { align-items: flex-start; }
  .settings-status-strip { grid-template-columns: 1fr; top: 66px; }
  .filters-inline { grid-template-columns: 1fr; }
  .categories-card #categoryList { max-height: 48vh; }
  .category-inline { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .tx-quick-stats { grid-template-columns: 1fr; }
  .home-actions { grid-template-columns: 1fr; }
}
