/* ============ TOKENS ============ */
:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --surface: #ffffff;
  --surface-2: #f7f4ed;
  --surface-3: #efeae0;
  --border: #e4ddd0;
  --border-strong: #cfc6b5;
  --text: #1c2720;
  --text-2: #4e5a53;
  --muted: #69736c;
  --brand: #1f3d2b;
  --brand-2: #2c5a3f;
  --brand-ink: #f4f1ea;
  --primary-bg: #1f3d2b;
  --primary-hover: #2c5a3f;
  --primary-ink: #f4f1ea;
  --accent: #3f7d58;
  --accent-soft: #e5eee3;
  --sage: #90a889;
  --focus: #3f7d58;
  --income: #1d7a5c;
  --expense: #b3601c;
  --chart-income: #12876a;
  --chart-expense: #d2772a;
  --danger: #b5443a;
  --danger-soft: #f8e7e4;
  --warning: #9a6a12;
  --warning-soft: #f7eed8;
  --good: #2d6e4b;
  --good-soft: #e3f0e7;
  --overlay: rgba(20, 28, 23, 0.45);
  --shadow-sm: 0 1px 2px rgba(31, 61, 43, 0.06);
  --shadow: 0 1px 2px rgba(31, 61, 43, 0.05), 0 8px 24px rgba(31, 61, 43, 0.07);
  --shadow-lg: 0 24px 60px rgba(20, 35, 26, 0.25);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111713;
    --surface: #1c2420;
    --surface-2: #222c27;
    --surface-3: #29342e;
    --border: #303c35;
    --border-strong: #435148;
    --text: #e9eee9;
    --text-2: #b4c0b8;
    --muted: #93a098;
    --brand: #0f2016;
    --brand-2: #1d3a28;
    --primary-bg: #5fb38a;
    --primary-hover: #74c49c;
    --primary-ink: #0d1c13;
    --accent: #5fb38a;
    --accent-soft: #23372b;
    --focus: #7cc8a0;
    --income: #5cc39c;
    --expense: #e79a5a;
    --chart-income: #2fa383;
    --chart-expense: #d27832;
    --danger: #e0766b;
    --danger-soft: #3a2220;
    --warning: #e0b057;
    --warning-soft: #3a3020;
    --good: #6cc494;
    --good-soft: #1f3528;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111713;
  --surface: #1c2420;
  --surface-2: #222c27;
  --surface-3: #29342e;
  --border: #303c35;
  --border-strong: #435148;
  --text: #e9eee9;
  --text-2: #b4c0b8;
  --muted: #93a098;
  --brand: #0f2016;
  --brand-2: #1d3a28;
  --primary-bg: #5fb38a;
  --primary-hover: #74c49c;
  --primary-ink: #0d1c13;
  --accent: #5fb38a;
  --accent-soft: #23372b;
  --focus: #7cc8a0;
  --income: #5cc39c;
  --expense: #e79a5a;
  --chart-income: #2fa383;
  --chart-expense: #d27832;
  --danger: #e0766b;
  --danger-soft: #3a2220;
  --warning: #e0b057;
  --warning-soft: #3a3020;
  --good: #6cc494;
  --good-soft: #1f3528;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* ============ BASE ============ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

#app {
  min-height: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.neg {
  color: var(--danger) !important;
}

.order-last {
  order: 10;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease), box-shadow 0.18s var(--ease),
    transform 0.12s var(--ease);
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-bg);
  color: var(--primary-ink);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(31, 61, 43, 0.25);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.btn-soft:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-danger-outline {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-soft);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn .icon {
  width: 18px;
  height: 18px;
}

.link {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 6px 2px;
  border-radius: 6px;
}

.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============ SHELL ============ */
.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  background: var(--brand);
  color: var(--brand-ink);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 16px 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(244, 241, 234, 0.12);
  color: #cfe3c9;
}

.brand-mark .icon {
  width: 24px;
  height: 24px;
}

.brand-mark.lg {
  width: 64px;
  height: 64px;
  border-radius: 20px;
}

.brand-mark.lg .icon {
  width: 34px;
  height: 34px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 12px;
  opacity: 0.7;
}

.sidebar-x {
  display: none;
  margin-left: auto;
  color: var(--brand-ink);
}

.sidebar-x:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  color: rgba(244, 241, 234, 0.82);
  font-weight: 500;
  text-align: left;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: var(--brand-ink);
  color: #1f3d2b;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.side-accounts {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
}

.side-head h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.side-add {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--brand-ink);
  transition: background-color 0.15s var(--ease);
}

.side-add:hover {
  background: rgba(255, 255, 255, 0.22);
}

.side-add .icon {
  width: 18px;
  height: 18px;
}

.side-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.side-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 8px;
  border-radius: 12px;
  color: var(--brand-ink);
  text-align: left;
  transition: background-color 0.15s var(--ease);
}

.side-account:hover {
  background: rgba(255, 255, 255, 0.07);
}

.side-account.active {
  background: rgba(255, 255, 255, 0.13);
}

.side-acc-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.side-acc-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-acc-bal {
  font-size: 12px;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.side-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px dashed rgba(244, 241, 234, 0.35);
  border-radius: 12px;
  color: var(--brand-ink);
  font-size: 14px;
  text-align: left;
}

.side-empty:hover {
  background: rgba(255, 255, 255, 0.07);
}

.acc-chip,
.cat-chip {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: color-mix(in srgb, var(--chip) 80%, var(--text));
  background: color-mix(in srgb, var(--chip) 20%, transparent);
}

.sidebar .acc-chip {
  color: #fff;
  background: color-mix(in srgb, var(--chip) 70%, #1f3d2b);
}

.acc-chip .icon,
.cat-chip .icon {
  width: 18px;
  height: 18px;
}

.acc-chip.lg {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

.acc-chip.lg .icon {
  width: 22px;
  height: 22px;
}

.side-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(244, 241, 234, 0.12);
}

.side-data {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.side-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(244, 241, 234, 0.2);
  color: var(--brand-ink);
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.side-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(244, 241, 234, 0.4);
}

.side-btn .icon {
  width: 18px;
  height: 18px;
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #cfe3c9;
  color: #1f3d2b;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.side-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.side-user-name {
  font-weight: 600;
  font-size: 14px;
}

.side-user-mail {
  font-size: 12px;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-logout {
  color: var(--brand-ink);
}

.side-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.side-sync {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 12px;
  opacity: 0.65;
}

.side-sync .icon {
  width: 14px;
  height: 14px;
}

.scrim {
  display: none;
}

/* ============ MAIN ============ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 20px;
  padding: 26px 32px 18px;
}

.menu-btn {
  display: none;
}

.title-block {
  flex: 1;
  min-width: 220px;
}

.title-block h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.title-block p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.boot {
  display: grid;
  place-items: center;
  gap: 18px;
  align-content: center;
  height: 100vh;
  color: var(--accent);
}

.boot .brand-mark {
  background: var(--brand);
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-head h2 .icon {
  color: var(--accent);
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.align-start {
  align-items: start;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 14px;
}

.notice .icon {
  color: var(--accent);
}

.banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--warning-soft);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
}

.banner > .icon {
  color: var(--warning);
}

.banner > div:not(.banner-actions) {
  flex: 1;
  min-width: 220px;
}

.banner p {
  color: var(--text-2);
  font-size: 14px;
}

.banner-actions {
  display: flex;
  gap: 8px;
}

/* ============ STATS ============ */
.stats,
.networth {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.networth {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-feature {
  background: linear-gradient(145deg, #2c5a3f, #1f3d2b 70%);
  border-color: transparent;
  color: #f4f1ea;
}

.stat-feature .stat-label,
.stat-feature .stat-foot {
  color: rgba(244, 241, 234, 0.75);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.stat-ic {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
}

.stat-ic .icon {
  width: 15px;
  height: 15px;
}

.stat-ic.income {
  background: var(--good-soft);
  color: var(--income);
}

.stat-ic.expense {
  background: var(--warning-soft);
  color: var(--expense);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-foot {
  font-size: 12.5px;
  color: var(--muted);
}

/* ============ CHART ============ */
.legend {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--text-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.sw-income {
  background: var(--chart-income);
}

.sw-expense {
  background: var(--chart-expense);
}

.chart {
  position: relative;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.base-line {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: var(--font);
}

.axis-current {
  fill: var(--text);
  font-weight: 700;
}

.bar-income {
  fill: var(--chart-income);
}

.bar-expense {
  fill: var(--chart-expense);
}

.hit {
  fill: transparent;
  cursor: crosshair;
}

.hit.hover {
  fill: var(--text);
  fill-opacity: 0.04;
}

.chart-tip {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: none;
}

.chart-tip span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}

.chart-tip b {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tip-net {
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ============ LISTS ============ */
.spend-list,
.tx-list,
.acc-mini,
.cat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.spend-list {
  gap: 14px;
}

.spend-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.spend-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spend-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.spend-name {
  font-weight: 600;
}

.spend-amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s var(--ease);
}

.bar.near span {
  background: var(--warning);
}

.bar.over span {
  background: var(--danger);
}

.budget-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill .icon {
  width: 13px;
  height: 13px;
}

.pill-ok {
  background: var(--good-soft);
  color: var(--good);
}

.pill-near {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill-over {
  background: var(--danger-soft);
  color: var(--danger);
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
  transition: background-color 0.15s var(--ease);
}

.tx-row + .tx-row {
  border-top: 1px solid var(--border);
}

.tx-row:hover {
  background: var(--surface-2);
}

.tx-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tx-desc {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-meta,
.tx-note {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-note {
  font-style: italic;
}

.tx-amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tx-amt.income,
.income {
  color: var(--income);
}

.tx-amt.expense,
.expense {
  color: var(--text);
}

.tx-summary .expense {
  color: var(--expense);
}

.tx-amt.transfer {
  color: var(--text-2);
}

.row-actions {
  display: flex;
  gap: 2px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.empty > .icon {
  width: 28px;
  height: 28px;
  color: var(--sage);
}

.acc-mini li + li {
  border-top: 1px solid var(--border);
}

.acc-mini-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  border-radius: 12px;
  text-align: left;
}

.acc-mini-row:hover {
  background: var(--surface-2);
}

.acc-mini-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 14.5px;
}

.acc-mini-text small {
  font-weight: 400;
  font-size: 12.5px;
  color: var(--muted);
}

.acc-mini-bal {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 36px;
  max-width: 720px;
}

.welcome-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}

.welcome-mark .icon {
  width: 28px;
  height: 28px;
}

.welcome h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
}

.welcome p {
  color: var(--text-2);
  max-width: 560px;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* ============ TRANSACTIONS VIEW ============ */
.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.tx-summary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 8px;
  box-shadow: var(--shadow-sm);
}

.day + .day {
  margin-top: 12px;
}

.day-head {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 8px;
  letter-spacing: 0.01em;
}

#tx-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============ ACCOUNTS VIEW ============ */
.acc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.acc-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 4px solid var(--chip);
}

.acc-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.acc-card-title {
  flex: 1;
  min-width: 0;
}

.acc-card-title h2 {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-card-title p {
  font-size: 13px;
  color: var(--muted);
}

.acc-balance {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.acc-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.acc-flow span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.acc-flow small {
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
}

.acc-note {
  font-size: 13px;
  color: var(--text-2);
}

.acc-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.acc-card-actions .btn {
  flex: 1;
}

.acc-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 240px;
  padding: 24px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  text-align: center;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.acc-add:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.acc-add span:last-child {
  font-size: 13px;
  color: var(--muted);
}

.acc-add-ic {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
}

/* ============ CATEGORIES VIEW ============ */
.cat-list .cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
}

.cat-list .cat-row + .cat-row {
  border-top: 1px solid var(--border);
}

.cat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cat-name {
  font-weight: 600;
}

.cat-sub {
  font-size: 12.5px;
  color: var(--muted);
}

/* ============ SETTINGS ============ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.card-danger {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.card-danger h2 .icon {
  color: var(--danger);
}

.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.danger-row + .danger-row {
  border-top: 1px solid var(--border);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* ============ FORMS ============ */
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field > label,
.field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}

.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 12.5px;
}

.help {
  font-size: 12.5px;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input:hover:not(:disabled),
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

input:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.search input[type="search"] {
  min-height: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.form-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.pw {
  position: relative;
}

.pw input {
  padding-right: 48px;
}

.pw-toggle {
  position: absolute;
  right: 2px;
  top: 2px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Segmented control */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-3);
}

.seg {
  flex: 1;
  position: relative;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.seg span .icon {
  width: 16px;
  height: 16px;
}

.seg:hover span {
  color: var(--text);
}

.seg input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.seg-expense input:checked + span {
  color: var(--expense);
}

.seg-income input:checked + span {
  color: var(--income);
}

.seg-transfer input:checked + span {
  color: #4f6d8a;
}

.seg input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* Colour + icon pickers */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch-opt {
  position: relative;
}

.swatch-opt input,
.icon-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatch-opt span {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chip);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease);
}

.swatch-opt span:hover {
  transform: scale(1.08);
}

.swatch-opt input:checked + span {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--chip);
}

.swatch-opt input:focus-visible + span,
.icon-opt input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
}

.icon-opt span {
  display: grid;
  place-items: center;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease);
}

.icon-opt span:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-opt input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Radio cards / choices */
.radio-cards {
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-cards legend {
  margin-bottom: 6px;
}

.radio-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.radio-card:hover {
  border-color: var(--border-strong);
}

.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.radio-card input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.radio-card span,
.choice span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-card small,
.choice small,
.import-summary small {
  color: var(--muted);
  font-size: 13px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.choice:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-ic {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.import-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
}

.import-summary div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.import-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 30px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  color: var(--text-2);
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone > .icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.dropzone small {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 6px;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table-wrap th,
.table-wrap td {
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}

.table-wrap th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
}

.table-wrap tr + tr td {
  border-top: 1px solid var(--border);
}

.table-wrap .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ============ DROPDOWN ============ */
.dd {
  position: relative;
  min-width: 0;
}

.dd-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.dd-trigger:hover {
  border-color: var(--border-strong);
}

.dd.open .dd-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.dd-value {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.dd-trigger .dd-hint {
  display: none;
}

.dd-placeholder {
  color: var(--muted);
}

.dd-chevron {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.2s var(--ease);
}

.dd.open .dd-chevron {
  transform: rotate(180deg);
}

.dd-toolbar .dd-trigger {
  min-width: 190px;
  font-weight: 600;
  font-size: 14px;
}

.dd-menu {
  z-index: 3000;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: ddIn 0.14s var(--ease);
}

@keyframes ddIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dd-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.dd-search input {
  flex: 1;
  min-height: 38px;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text);
  box-shadow: none;
  padding: 0;
}

.dd-search input:focus {
  box-shadow: none;
}

.dd-options {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  outline: none;
}

.dd-option:hover,
.dd-option:focus {
  background: var(--surface-2);
}

.dd-option:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.dd-option[aria-selected="true"] {
  background: var(--accent-soft);
  font-weight: 600;
}

.dd-check {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--accent);
  visibility: hidden;
}

.dd-option[aria-selected="true"] .dd-check {
  visibility: visible;
}

.dd-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dd-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.dd-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--chip);
  background: color-mix(in srgb, var(--chip) 16%, transparent);
}

.dd-icon .icon {
  width: 16px;
  height: 16px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dd-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ============ MODALS ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--overlay);
  animation: fadeIn 0.18s var(--ease);
  overflow-y: auto;
}

.overlay-top {
  z-index: 1500;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.22s var(--ease);
}

.modal-sm {
  width: min(440px, 100%);
}

.modal-lg {
  width: min(760px, 100%);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-x {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  flex-shrink: 0;
}

.modal-x:hover {
  background: var(--surface-3);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px 22px;
  overflow-y: auto;
}

.dialog-msg {
  color: var(--text-2);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

/* ============ TOASTS ============ */
#toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 10px 14px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s var(--ease);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--good-soft);
  color: var(--good);
  flex-shrink: 0;
}

.toast-icon .icon {
  width: 17px;
  height: 17px;
}

.toast-error .toast-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.toast-info .toast-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.toast-text {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.toast-text strong {
  display: block;
  font-size: 14px;
}

.toast-text p {
  font-size: 13px;
  color: var(--text-2);
}

.toast-x {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  flex-shrink: 0;
}

.toast-x:hover {
  background: var(--surface-3);
  color: var(--text);
}

.toast-x .icon {
  width: 16px;
  height: 16px;
}

/* ============ AUTH ============ */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 48px clamp(24px, 6vw, 88px);
  background: radial-gradient(circle at 20% 15%, #2c5a3f, #1f3d2b 55%, #16301f);
  color: var(--brand-ink);
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 5vw, 56px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.auth-tag {
  font-size: 18px;
  opacity: 0.85;
}

.auth-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
  max-width: 460px;
}

.auth-points li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  opacity: 0.9;
}

.auth-points .icon {
  color: #cfe3c9;
  margin-top: 2px;
}

.auth-card {
  align-self: center;
  justify-self: center;
  width: min(440px, calc(100% - 32px));
  margin: 32px 0;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border-radius: 14px;
  background: var(--surface-3);
}

.auth-tabs button {
  min-height: 40px;
  border-radius: 10px;
  font-weight: 600;
  color: var(--text-2);
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

/* ============ V3: NAVIGATION ============ */
.side-label {
  padding: 0 14px;
  margin-bottom: -12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}

.nav-count {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e0b057;
  color: #1f2a16;
  font-size: 12px;
  font-weight: 700;
}

.side-bottom {
  margin-top: auto;
}

.sync {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12.5px;
  font-weight: 600;
}

.sync .icon {
  width: 16px;
  height: 16px;
}

.sync-ok .icon {
  color: #a8d5b6;
}

.sync-busy .icon {
  color: #cfe3c9;
  animation: pulse 1.2s ease-in-out infinite;
}

.sync-warn .icon {
  color: #e0b057;
}

.sync-bad {
  background: rgba(224, 118, 107, 0.2);
}

.sync-bad .icon {
  color: #f0a39a;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.bottom-nav {
  display: none;
}

.toolbar-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.title-block h1 em,
.page-header h2 em {
  font-style: italic;
  color: var(--accent);
}

/* ============ V3: PAGE STRUCTURE ============ */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.eyebrow,
.kicker {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead {
  color: var(--text-2);
  font-size: 14px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 8px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
}

.section-head p {
  color: var(--muted);
  font-size: 14px;
}

.card-head > div {
  min-width: 0;
}

.card-head .kicker {
  margin-bottom: 2px;
}

.grid-2.wide-left {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card-grid > .empty {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.list-card {
  padding: 8px 14px;
}

.list-card > .btn-block {
  margin: 6px 0 8px;
}

.span-2 {
  grid-column: 1 / -1;
}

.small {
  font-size: 13px;
}

.pos {
  color: var(--income);
}

.expense-text {
  color: var(--expense);
}

.warn-text {
  color: var(--warning);
  font-weight: 600;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-sm .icon {
  width: 16px;
  height: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill .icon {
  width: 14px;
  height: 14px;
}

/* month navigation */
.month-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.month-nav .icon-btn {
  width: 38px;
  height: 38px;
}

.dd-month .dd-trigger {
  min-width: 170px;
  min-height: 38px;
  border: 0;
  font-weight: 600;
}

/* ============ V3: STATS ============ */
.stat-ic.income {
  background: var(--good-soft);
  color: var(--income);
}

.stat-ic.expense {
  background: var(--warning-soft);
  color: var(--expense);
}

.stat-feature .stat-ic {
  background: rgba(255, 255, 255, 0.14);
  color: #f4f1ea;
}

.chart-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: -6px 0 8px;
}

.chart-meta strong {
  font-size: 24px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.chart-meta span {
  font-size: 13px;
  font-weight: 600;
}

/* ============ V3: CHARTS ============ */
.chart svg {
  max-width: 100%;
}

.line-path {
  fill: none;
  stroke: var(--chart-income);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line-area {
  fill: url(#nwFill);
}

.area-top {
  stop-color: var(--chart-income);
  stop-opacity: 0.22;
}

.area-bottom {
  stop-color: var(--chart-income);
  stop-opacity: 0;
}

.line-dot {
  fill: var(--surface);
  stroke: var(--chart-income);
  stroke-width: 2;
}

.line-dot.current,
.line-dot.hover {
  fill: var(--chart-income);
}

.crosshair {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}

.chart.donut {
  flex: 0 0 180px;
  width: 180px;
}

.donut-track {
  stroke: var(--surface-3);
}

.donut-seg {
  cursor: pointer;
  transition: stroke-width 0.15s var(--ease);
}

.donut-seg.hover {
  stroke-width: 30;
}

.donut-total {
  fill: var(--text);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
}

.donut-sub {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 12px;
}

.legend-list {
  list-style: none;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 4px 8px;
  border-radius: 10px;
  text-align: left;
  font-size: 14px;
}

.legend-row:not(:disabled):hover {
  background: var(--surface-2);
}

.legend-row:disabled {
  cursor: default;
}

.legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.legend-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.legend-pct {
  color: var(--muted);
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============ V3: ROWS ============ */
.rows {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.rows > li + li {
  border-top: 1px solid var(--border);
}

.rows > li.tx-row + li.tx-row {
  border-top: 1px solid var(--border);
}

.tx-row {
  border-radius: 0;
}

.tx-row.compact {
  padding: 9px 4px;
}

.tx-row.as-button {
  width: 100%;
  text-align: left;
  border-radius: 12px;
}

.tx-row.inactive {
  opacity: 0.6;
}

.tx-title {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-meta.overdue {
  color: var(--danger);
  font-weight: 600;
}

.tx-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 3px;
}

.tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.tag:hover {
  text-decoration: underline;
}

.tx-amt.expense {
  color: var(--text);
}

.tx-amt.transfer {
  color: #4f6d8a;
}

:root[data-theme="dark"] .tx-amt.transfer {
  color: #8fb0cf;
}

/* ============ V3: SIGNALS & MINDFUL ============ */
.signals {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.signals li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.signals strong {
  display: block;
  font-size: 14.5px;
}

.signals p {
  color: var(--muted);
  font-size: 13px;
}

.signal-ic {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.signal-ic .icon {
  width: 18px;
  height: 18px;
}

.mindful {
  background: linear-gradient(160deg, var(--accent-soft), var(--surface) 70%);
}

.streak {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.streak strong {
  font-family: var(--font-display);
  font-size: 48px;
  line-height: 1;
  color: var(--accent);
}

.streak span {
  color: var(--text-2);
  font-size: 14px;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.pip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pip > .icon,
.pip > span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pip.good > .icon {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pip.spent > .icon {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: var(--warning);
}

.pip.today > .icon {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent);
}

.pip small {
  font-size: 11px;
  color: var(--muted);
}

/* ============ V3: BUDGETS & GOALS ============ */
.budget-card,
.goal-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-card {
  border-top: 4px solid var(--chip);
}

.budget-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.budget-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.budget-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-name span {
  font-size: 12.5px;
  color: var(--muted);
}

.budget-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--text-2);
}

.budget-foot strong {
  color: var(--text);
}

.bar.goal span {
  background: var(--chip);
}

.goal-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.goal-value small {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

/* ============ V3: REPORTS ============ */
.merchants {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.merchant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  width: 100%;
  padding: 8px;
  border-radius: 12px;
  text-align: left;
}

.merchant-row:hover {
  background: var(--surface-2);
}

.merchant-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merchant-amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.merchant-row .bar {
  grid-column: 1 / -1;
  height: 6px;
}

/* ============ V3: TRANSACTION FILTERS ============ */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-items: end;
  gap: 12px;
  padding: 16px;
}

.filters .search {
  grid-column: 1 / -1;
}

.filters .field-label,
.filters label {
  font-size: 12.5px;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 44px;
}

#tx-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============ V3: SETTINGS ============ */
.rate-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.rate-row > label {
  font-weight: 600;
}

.cat-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px 24px;
}

.group-title {
  margin: 10px 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-head p.muted {
  font-size: 13px;
  margin-top: 2px;
}

/* ============ V3: FORMS ============ */
.modal-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13.5px;
}

.field-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field-row:has(> [data-transfer-only]:not([hidden])) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.split-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 40px;
  align-items: end;
  gap: 10px;
}

.split-row .icon-btn {
  margin-bottom: 2px;
}

.split-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.preview-summary span {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-2);
}

.preview-summary strong {
  color: var(--text);
}

.table-wrap tr.dup td {
  background: var(--warning-soft);
}

.table-wrap td.income {
  color: var(--income);
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
}

.steps code,
.auth-card code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-3);
  font-size: 13px;
}

.auth.single {
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.auth.single .auth-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
  width: min(560px, calc(100% - 32px));
}


/* ============ RESPONSIVE ============ */
@media (max-width: 1180px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters .search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .grid-2,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 900;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: var(--shadow-lg);
  }

  .nav-open .sidebar {
    transform: none;
  }

  .sidebar-x {
    display: inline-grid;
  }

  .nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 800;
    background: var(--overlay);
  }

  .menu-btn {
    display: inline-grid;
    background: var(--surface);
    border: 1px solid var(--border);
  }

  .topbar {
    padding: 16px;
    gap: 12px;
  }

  .title-block {
    min-width: 0;
  }

  .title-block h1 {
    font-size: 24px;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .dd {
    flex: 1 1 160px;
  }

  .dd-toolbar .dd-trigger {
    min-width: 0;
  }

  .toolbar .btn-primary {
    flex: 1 1 100%;
  }

  .content {
    padding: 4px 16px 32px;
    gap: 16px;
  }

  .auth {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-brand {
    padding: 36px 24px 28px;
    gap: 12px;
  }

  .auth-points {
    display: none;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-feature {
    grid-column: 1 / -1;
  }

  .stat {
    padding: 14px;
  }

  .stat-value {
    font-size: 19px;
  }

  .stat-feature .stat-value {
    font-size: 26px;
  }

  .filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .card {
    padding: 18px;
  }

  .tx-row {
    flex-wrap: wrap;
  }

  .tx-row .row-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .danger-row {
    flex-direction: column;
    align-items: stretch;
  }

  .overlay {
    place-items: end center;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
  }

  .modal-head {
    padding: 14px 14px 12px 18px;
  }

  .modal-body {
    padding: 18px;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
  }

  #toast-root {
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ V3: RESPONSIVE ============ */
@media (max-width: 1100px) {
  .grid-2.wide-left {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 700;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
  }

  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 50px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
  }

  .bottom-nav button.active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .content {
    padding-bottom: 96px;
  }

  #toast-root {
    bottom: 84px;
  }

  .field-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-header {
    align-items: stretch;
  }

  .page-header .page-actions,
  .month-nav {
    width: 100%;
  }

  .month-nav .dd {
    flex: 1;
  }

  .dd-month .dd-trigger {
    min-width: 0;
  }

  .toolbar .btn-primary {
    flex: 1 1 auto;
  }
}

@media (max-width: 560px) {
  .hide-sm {
    display: none !important;
  }

  .donut-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .chart.donut {
    align-self: center;
  }

  .field-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .split-row {
    grid-template-columns: minmax(0, 1fr) 100px 40px;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .title-block h1 {
    font-size: 22px;
  }

  .week {
    gap: 2px;
  }

  .pip > .icon,
  .pip > span {
    width: 32px;
    height: 32px;
  }

  .rate-row {
    grid-template-columns: 70px minmax(0, 1fr) auto;
  }
}

/* ============ PRINT (Reports → Print report) ============ */
@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
  }

  body {
    background: #fff;
  }

  .shell {
    display: block;
    height: auto;
  }

  .main {
    height: auto;
    overflow: visible;
  }

  .content {
    overflow: visible;
    padding: 0;
  }

  .sidebar,
  .bottom-nav,
  .scrim,
  .toolbar,
  .menu-btn,
  .page-actions,
  .row-actions,
  .link,
  #toast-root,
  .chart-tip {
    display: none !important;
  }

  .card,
  .stat {
    box-shadow: none;
    break-inside: avoid;
  }

  .stat-feature {
    color: #1c2720;
    background: #fff;
    border: 1px solid #ccc;
  }

  .stat-feature .stat-label,
  .stat-feature .stat-foot {
    color: #555;
  }
}
