/* ═══════════════════════════════════════════════════════════
   FINFLOW — Minimal Design System
   Light-first · Inter + DM Mono · #16A34A accent
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ──────────────────────────────────────
   TOKENS — Light (default)
────────────────────────────────────── */
:root {
  --bg:           #F8FAFC;
  --surface:      #FFFFFF;
  --surface-2:    #F1F5F9;
  --border:       #E2E8F0;
  --text:         #0F172A;
  --t2:           #475569;
  --t3:           #94A3B8;

  --accent:        #16A34A;
  --accent-bg:     #F0FDF4;
  --accent-border: #BBF7D0;

  --red:      #DC2626;
  --red-bg:   #FEF2F2;
  --green:    #16A34A;
  --green-bg: #F0FDF4;
  --amber:    #D97706;
  --amber-bg: #FFFBEB;
  --violet:   #7C3AED;
  --violet-bg:#F5F3FF;

  /* Radii */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-full: 999px;

  /* Shadows — very light */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);

  /* Typography */
  --font-body: 'Inter', -apple-system, system-ui, sans-serif;
  --font-num:  'DM Mono', 'Courier New', monospace;

  /* Motion */
  --transition:    150ms ease;
  --transition-md: 200ms ease;
  --transition-lg: 300ms ease;

  /* Layout */
  --sidebar-w: 240px;

  /* Legacy compatibility aliases */
  --s1: var(--surface);
  --s2: var(--surface);
  --s3: var(--surface-2);
  --s4: var(--border);
  --s5: #CBD5E1;
  --green-s:      var(--green-bg);
  --red-s:        var(--red-bg);
  --amber-s:      var(--amber-bg);
  --violet-s:     var(--violet-bg);
  --accent-subtle:var(--accent-bg);
  --accent-text:  #ffffff;
  --accent-on:    #ffffff;
  --err:          var(--red);
  --font-display: var(--font-body);
}

/* ──────────────────────────────────────
   TOKENS — Dark
────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0F172A;
  --surface:      #1E293B;
  --surface-2:    #293548;
  --border:       rgba(255,255,255,0.08);
  --text:         #F1F5F9;
  --t2:           #94A3B8;
  --t3:           #64748B;

  --accent:        #22C55E;
  --accent-bg:     rgba(34,197,94,0.1);
  --accent-border: rgba(34,197,94,0.2);

  --red:      #F87171;
  --red-bg:   rgba(248,113,113,0.1);
  --green:    #4ADE80;
  --green-bg: rgba(74,222,128,0.1);
  --amber:    #FBBF24;
  --amber-bg: rgba(251,191,36,0.1);
  --violet:   #A78BFA;
  --violet-bg:rgba(167,139,250,0.1);

  /* No shadows in dark — only borders */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;

  --s5: #324060;
  --accent-subtle: rgba(34,197,94,0.1);
}

/* ──────────────────────────────────────
   RESET
────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; font-size:14px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition-lg), color var(--transition-lg);
}

/* ──────────────────────────────────────
   LAYOUT
────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ──────────────────────────────────────
   SIDEBAR
────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  transition: background var(--transition-lg);
}

.sidebar-inner {
  display: flex; flex-direction: column;
  padding: 16px 12px;
  height: 100%;
}

/* Logo */
.logo {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 20px;
}
.logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}
.logo-mark:hover { transform: scale(1.06); }
.logo-mark svg { width: 18px; height: 18px; color: #fff; }
.logo-text { display: flex; flex-direction: column; }
.logo-name {
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1;
  color: var(--text);
}
.logo-sub {
  font-size: 10px; font-weight: 500;
  color: var(--t3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Nav groups */
.nav-group { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; }
.nav-label {
  font-size: 10px; font-weight: 600;
  color: var(--t3);
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 12px 10px 4px;
}

/* Nav button */
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0 10px;
  height: 40px;
  border: none;
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--t2);
  font-family: var(--font-body);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  text-align: left;
  position: relative; overflow: hidden;
  letter-spacing: 0;
}
.nav-btn svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-btn:not(.active):hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-btn.active svg { color: inherit; stroke: currentColor; }

/* Sidebar footer */
.sidebar-foot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}

/* Theme toggle row */
.theme-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; height: 40px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
  color: var(--t2);
}
.theme-row:hover { background: var(--surface-2); color: var(--text); }
.theme-row-label { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.theme-row-label svg { width: 18px; height: 18px; }

/* Toggle switch */
.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: var(--r-full);
  border: none;
  position: relative;
  transition: background var(--transition-md);
  flex-shrink: 0;
}
[data-theme="dark"] .toggle { background: var(--accent); }
.toggle-dot {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--t3);
  transition: transform var(--transition-md), background var(--transition-md);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .toggle-dot {
  transform: translateX(18px);
  background: #fff;
}

.version-tag {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px;
  font-size: 11px; color: var(--t3);
}
.v-badge {
  font-size: 10px; font-weight: 700;
  background: var(--accent-bg); color: var(--accent);
  padding: 2px 8px; border-radius: var(--r-full);
}

/* ──────────────────────────────────────
   MAIN CONTENT
────────────────────────────────────── */
.main {
  padding: 32px 36px 60px;
  overflow-y: auto; max-height: 100vh;
  background: var(--bg);
}
.page { display: none; }
.page.active { display: block; }

/* ──────────────────────────────────────
   PAGE HEADER
────────────────────────────────────── */
.ph {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.pt {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1;
  color: var(--text);
}
.pt em { color: var(--accent); font-style: normal; }
.ps { font-size: 13px; color: var(--t2); margin-top: 4px; }

/* ──────────────────────────────────────
   BUTTONS
────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-accent { background: var(--accent); color: #ffffff; }
.btn-accent:hover { background: #15803D; }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-bg);
}
.btn-danger:hover { filter: brightness(0.95); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
  padding: 8px; width: 36px; height: 36px;
  justify-content: center;
  border-radius: var(--r-sm);
}
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 6px; }

/* ──────────────────────────────────────
   GRID
────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 28px; }

/* ──────────────────────────────────────
   CARDS
────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  transition: background var(--transition-lg);
}
.card-sm { padding: 14px 16px; }
.card-xs { padding: 10px 14px; }
.card-elevated { box-shadow: var(--shadow-lg); }

/* ──────────────────────────────────────
   STAT CARDS
────────────────────────────────────── */
.sc {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-md);
  padding: 18px 20px;
  transition: all var(--transition);
  cursor: default;
}
.sc:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.sc-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.sc-icon svg { width: 16px; height: 16px; color: var(--accent); }
.sc-label {
  font-size: 11px; font-weight: 600;
  color: var(--t3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sc-val {
  font-family: var(--font-num);
  font-size: 24px; font-weight: 600;
  letter-spacing: -0.04em;
  margin-top: 6px; line-height: 1;
  font-feature-settings: 'tnum';
  color: var(--text);
}
.sc-sub { font-size: 12px; color: var(--t2); margin-top: 6px; }
.sc-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: var(--r-full);
  margin-top: 6px;
}
.sc-trend.up  { background: var(--red-bg);    color: var(--red);   }
.sc-trend.down { background: var(--green-bg); color: var(--green); }
.sc-trend.neu  { background: var(--surface-2); color: var(--t2);   }

/* Colour utilities */
.c-accent { color: var(--accent); }
.c-red    { color: var(--red);    }
.c-green  { color: var(--green);  }
.c-amber  { color: var(--amber);  }
.c-violet { color: var(--violet); }

/* ──────────────────────────────────────
   SECTION TITLE
────────────────────────────────────── */
.stitle {
  font-size: 11px; font-weight: 600;
  color: var(--t3);
  text-transform: uppercase; letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.stitle::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ──────────────────────────────────────
   ACCOUNT CARDS
────────────────────────────────────── */
.acc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative; overflow: hidden;
  transition: all var(--transition);
}
.acc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.acc-stripe {
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.acc-glow { display: none; }
.acc-emoji { font-size: 24px; margin-bottom: 8px; display: block; }
.acc-name { font-size: 14px; font-weight: 600; color: var(--text); }
.acc-txcount { font-size: 11px; color: var(--t3); margin-top: 2px; }
.acc-bal {
  font-family: var(--font-num);
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.04em;
  margin-top: 14px;
  font-feature-settings: 'tnum';
  color: var(--text);
}
.acc-actions { display: flex; gap: 6px; margin-top: 14px; }

/* ──────────────────────────────────────
   TRANSACTION LIST (dashboard)
────────────────────────────────────── */
.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  transition: background var(--transition);
  cursor: default;
}
.tx-item:hover { background: var(--surface-2); }
.tx-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--t2); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.tx-inc { color: var(--green); font-weight: 600; }
.tx-exp { color: var(--text); font-weight: 600; }

/* ──────────────────────────────────────
   TRANSACTION TABLE
────────────────────────────────────── */
.tbl-head {
  display: grid;
  grid-template-columns: 150px 1fr 140px 74px 124px 64px;
  padding: 10px 20px 8px;
  border-bottom: 1px solid var(--border);
  align-items: end;
}
.tbl-head > div {
  font-size: 10px; font-weight: 700;
  color: var(--t3); text-transform: uppercase; letter-spacing: 0.1em;
}
.tbl-head .tbl-cat { display: block; }
.tbl-head .tbl-amt { text-align: right; justify-content: flex-end; display: flex; }
.tbl-head .tbl-acts { display: block; }
.tbl-body { display: flex; flex-direction: column; }

.tbl-date-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 6px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface-2); z-index: 1;
}
.tbl-date-label { font-size: 11px; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: 0.08em; }
.tbl-date-total { display: flex; align-items: center; gap: 12px; }
.tbl-dsum-exp { font-size: 12px; font-weight: 700; color: var(--red); font-feature-settings: 'tnum'; }
.tbl-dsum-inc { font-size: 12px; font-weight: 700; color: var(--green); font-feature-settings: 'tnum'; }

.tbl-row {
  display: grid;
  grid-template-columns: 150px 1fr 140px 74px 124px 64px;
  align-items: center; padding: 0 20px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  border-radius: 0;
}
.tbl-row:last-child { border-bottom: none; }
.tbl-row:hover { background: var(--surface-2); }
.tbl-row:hover .tbl-acts { opacity: 1; }

.tbl-cat { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl-cat-ico {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.tbl-cat-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl-desc {
  font-size: 12px; color: var(--t2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 14px; display: flex; align-items: center; gap: 6px;
}
.tbl-desc-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-desc-tags { display: flex; gap: 4px; flex-shrink: 0; }
.tbl-acc { font-size: 12px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl-date { font-size: 12px; color: var(--t3); font-weight: 400; white-space: nowrap; }
.tbl-amt {
  display: flex; align-items: baseline; justify-content: flex-end;
  gap: 1px; white-space: nowrap; font-feature-settings: 'tnum';
}
.tbl-amt-sign { font-size: 11px; font-weight: 500; opacity: 0.5; margin-right: 1px; }
.tbl-amt-cur  { font-size: 10px; font-weight: 500; opacity: 0.5; margin-right: 2px; }
.tbl-amt-num  { font-family: var(--font-num); font-size: 13px; font-weight: 500; letter-spacing: -0.03em; }
.tbl-amt-exp  { color: var(--text); }
.tbl-amt-inc  { color: var(--green); }
.tbl-acts {
  display: flex; gap: 2px; justify-content: flex-end;
  opacity: 0; transition: opacity var(--transition);
}
.tbl-row[data-type="expense"]:hover .tbl-amt-num { color: var(--red); }
.tbl-row[data-type="income"]:hover  .tbl-amt-num { color: var(--green); }

.dg-header {
  font-size: 10px; font-weight: 700;
  color: var(--t3); text-transform: uppercase; letter-spacing: 0.1em;
  padding: 14px 12px 6px;
}

/* ──────────────────────────────────────
   TAGS
────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-xs);
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
}
.tag-a { background: var(--accent-bg); color: var(--accent); }
.tag-v { background: var(--violet-bg); color: var(--violet); }
.tag-r { background: var(--red-bg);    color: var(--red);    }

.tag-picker { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0 0; }
.tag-picker .tag-chip {
  display: inline-flex; align-items: center;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 11px; user-select: none;
}
.tag-picker .tag-chip span {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 8px; border-radius: var(--r-xs); font-size: 11px;
}
.tag-picker .tag-chip input { display: none; }
.tag-picker .tag-chip input:checked + span { background: var(--accent-bg); color: var(--accent); }
.tag-picker .tag-chip:hover { background: var(--border); }

.tag-chip-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: none; background: transparent; color: var(--t3);
  font-size: 14px; line-height: 1; cursor: pointer;
  padding: 0; margin-left: -2px;
  transition: color var(--transition), background var(--transition);
}
.tag-chip-del:hover { color: var(--red); background: var(--red-bg); }

.tag-add-row {
  display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 8px; margin-top: 6px;
}
.tag-add-row input { flex: 1 1 180px; min-width: 0; width: 100%; }
.tag-add-row .btn-add-tag {
  flex-shrink: 0; padding: 4px 10px;
  border: none; border-radius: var(--r-full);
  background: var(--accent-bg); color: var(--accent);
  font-size: 12px; font-weight: 600;
  font-family: var(--font-body); cursor: pointer;
  white-space: nowrap; transition: background var(--transition);
}
.tag-add-row .btn-add-tag:hover { background: var(--accent); color: #fff; }

/* ──────────────────────────────────────
   FORMS
────────────────────────────────────── */
.fg { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; min-width: 0; }
.mo-tx-grid > .fg { min-width: 0; }
.mo-tx-toggle { margin-bottom: 10px; }
.tx-toprow { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.tx-toprow > .fg:first-child { flex: 1; min-width: 0; }
.tx-toprow .tx-date-fg { width: 100%; }
.mo-tx-grid { margin-top: 8px; gap: 10px 12px; }
.tx-tags { margin-top: 10px; }
.tx-field-savings-hidden { display: none; }
.tx-field-savings-only  { display: none; }
.btn-create-goal { width: fit-content; margin-top: 6px; padding: 10px 14px; }
.fg-full { grid-column: 1/-1; }
.modal .fg { gap: 6px; }
.field-note { font-size: 12px; color: var(--t2); margin-top: 2px; line-height: 1.3; }
.field-error { font-size: 12px; min-height: 0; line-height: 1.3; color: var(--red); display: none; }
.field-error:not(:empty) { display: block; min-height: 14px; }

label {
  font-size: 10px; font-weight: 700;
  color: var(--t2);
  text-transform: uppercase; letter-spacing: 0.1em;
}
label.btn { text-transform: none; letter-spacing: 0.01em; font-size: 13px; font-weight: 600; color: var(--text); }

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px; font-weight: 400;
  outline: none; width: 100%;
  transition: border-color var(--transition), border-bottom-width var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: none;
}
input:focus, select:focus, textarea:focus {
  border-bottom-width: 2px;
  border-bottom-color: var(--accent);
  outline: none;
}
input::placeholder { color: var(--t3); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
select option { background: var(--surface); }
textarea { resize: vertical; min-height: 64px; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--red); }
.fg > .field-error + div { margin-top: 2px; }

/* Amount input */
.input-amount {
  font-family: var(--font-num);
  font-size: 18px; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--text); width: 100%;
  font-feature-settings: 'tnum';
  transition: border-color var(--transition), border-bottom-width var(--transition);
  outline: none; letter-spacing: 0;
}
.input-amount:focus { border-bottom-width: 2px; border-bottom-color: var(--accent); }
.input-amount::placeholder { color: var(--t3); font-weight: 400; font-size: 14px; }

/* ──────────────────────────────────────
   SEGMENTED BUTTON (tabs)
────────────────────────────────────── */
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-head .stitle { margin-bottom: 0; }
.card-head .stitle::after { display: none; }

.tabs {
  display: flex; gap: 2px;
}
.tb {
  padding: 5px 12px;
  border-radius: var(--r-sm);
  border: none; background: transparent;
  color: var(--t2);
  font-family: var(--font-body);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tb:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.tb.active { background: var(--accent-bg); color: var(--accent); }

.type-toggle {
  display: flex; gap: 1px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
}
.type-btn {
  flex: 1; padding: 6px 8px;
  border: none; border-radius: var(--r-sm);
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  background: transparent; color: var(--t2);
}
.type-btn.active.expense  { background: var(--red-bg);    color: var(--red);    }
.type-btn.active.income   { background: var(--green-bg);  color: var(--green);  }
.type-btn.active.transfer { background: var(--violet-bg); color: var(--violet); }
.type-btn.active.savings  { background: var(--accent-bg); color: var(--accent); }

/* ──────────────────────────────────────
   SEARCH
────────────────────────────────────── */
.search-wrap { position: relative; flex: 1; }
.search-wrap input { padding-left: 40px; border-radius: var(--r-full) !important; }
.search-ico {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--t2); pointer-events: none; width: 15px; height: 15px;
}

/* ──────────────────────────────────────
   PERIOD BAR
────────────────────────────────────── */
.period-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.custom-dates { display: flex; gap: 7px; align-items: center; }
.custom-dates input[type=date] { width: 148px; }

/* ──────────────────────────────────────
   MODAL
────────────────────────────────────── */
.mo {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition-lg);
}
.mo.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px 24px;
  width: min(560px, calc(100vw - 32px));
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition-lg);
  box-shadow: var(--shadow-lg);
}
.mo.show .modal { transform: translateY(0) scale(1); }
.modal-sm { width: min(400px, calc(100vw - 32px)); }
#mo-tx .modal { max-height: 90vh; overflow-y: auto; }
#mo-tx .mo-tx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#mo-tx .mo-tx-grid > .fg { min-width: 0; }
#mo-tx .tag-add-row { flex-wrap: wrap; }
#mo-tx .tag-add-row input { min-width: 0; width: 100%; }
#mo-tx .field-note { margin-top: 2px; }
#mo-tx .field-error { min-height: 14px; }

.mh {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.mh-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.mf { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ──────────────────────────────────────
   PROGRESS
────────────────────────────────────── */
.pbar { background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.pbar-sm  { height: 4px; }
.pbar-md  { height: 6px; }
.pbar-lg  { height: 10px; }
.pfill { height: 100%; border-radius: var(--r-full); transition: width var(--transition-lg); }

/* ──────────────────────────────────────
   CHARTS
────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }
.card-stretch { display: flex; flex-direction: column; }
.card-stretch .chart-wrap { flex: 1; height: auto; min-height: 200px; }
.chart-md   { height: 200px; }
.chart-sm   { height: 160px; }

/* ──────────────────────────────────────
   DONUT LEGEND
────────────────────────────────────── */
.dl { display: flex; flex-direction: column; gap: 4px; }

.an-donut-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
}
.an-donut-chart {
  position: relative; width: 200px; height: 200px; flex-shrink: 0;
}
.an-donut-chart canvas { width: 100% !important; height: 100% !important; }
.an-donut-leg {
  width: 100%;
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
}
.an-dl-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-md);
  background: var(--surface-2);
  transition: background var(--transition);
  min-width: 0; cursor: default;
}
.an-dl-item:hover { background: var(--border); }
.an-dl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.an-dl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.an-dl-name { font-size: 11px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-dl-val  { font-family: var(--font-num); font-size: 12px; font-weight: 600; color: var(--text); }
.an-dl-pct  { font-size: 10px; color: var(--t3); flex-shrink: 0; }

@media (max-width: 400px) {
  .an-donut-leg { grid-template-columns: 1fr; }
  .an-donut-chart { width: 170px; height: 170px; }
}

.dl-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; padding: 2px 8px;
  border-radius: var(--r-md);
  transition: background var(--transition);
}
.dl-item:hover { background: var(--surface-2); }
.dl-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dl-name { flex: 1; color: var(--t2); font-size: 12px; }
.dl-val  { font-family: var(--font-num); font-size: 12px; font-weight: 500; }

#dashDonutLeg { grid-template-columns: 1fr; min-width: 0; }
#card-dash-donut .an-donut-wrap { width: 100%; min-width: 0; overflow: hidden; }

.chart-leg-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--surface-2);
}
.chart-leg-item:last-child { border-bottom: none; }
.chart-leg-box   { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-leg-label { flex: 1; font-size: 13px; color: var(--t2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-leg-val   { font-family: var(--font-num); font-size: 13px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.chart-leg-pct   { font-size: 11px; color: var(--t3); margin-left: 4px; }

/* ──────────────────────────────────────
   GOAL CARDS
────────────────────────────────────── */
.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-lg); padding: 20px;
  transition: all var(--transition);
}
.goal-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.goal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.goal-emoji { font-size: 28px; margin-bottom: 6px; }
.goal-name { font-size: 15px; font-weight: 700; }
.goal-deadline { font-size: 11px; color: var(--t3); margin-top: 2px; }
.goal-pct { font-family: var(--font-num); font-size: 28px; font-weight: 600; letter-spacing: -0.04em; }
.goal-amounts { display: flex; justify-content: space-between; font-size: 12px; color: var(--t2); margin: 10px 0 8px; }

/* ──────────────────────────────────────
   COMPARE BARS
────────────────────────────────────── */
.cmp-item { margin-bottom: 16px; }
.cmp-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; margin-bottom: 6px; }
.cmp-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cmp-bar-label { font-size: 10px; font-weight: 700; color: var(--t3); width: 44px; text-align: right; letter-spacing: 0.04em; text-transform: uppercase; }
.cmp-bar-wrap { flex: 1; background: var(--surface-2); border-radius: var(--r-full); height: 6px; overflow: hidden; }
.cmp-bar-fill { height: 100%; border-radius: var(--r-full); transition: width var(--transition-lg); }

/* ──────────────────────────────────────
   HEATMAP
────────────────────────────────────── */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.hm-days { display: flex; flex-direction: column; gap: 3px; margin-right: 6px; }
.hm-day { font-size: 9px; color: var(--t3); height: 13px; display: flex; align-items: center; font-weight: 500; }
.hm-week { display: flex; flex-direction: column; gap: 3px; }
.hm-cell {
  width: 13px; height: 13px; border-radius: 3px;
  background: var(--surface-2); cursor: pointer;
  transition: transform 0.1s; position: relative;
}
.hm-cell:hover { transform: scale(1.6); z-index: 10; }
.hm-cell[title]:hover::after { display: none; }

#hm-tooltip {
  position: fixed; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 11px; font-weight: 500;
  font-family: var(--font-body);
  padding: 6px 12px; border-radius: var(--r-full);
  white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity 0.1s;
}

/* ──────────────────────────────────────
   MONTH MINI BARS
────────────────────────────────────── */
.mc-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 8px; }
.mc-col { text-align: center; }
.mc-bar-wrap { height: 80px; display: flex; flex-direction: column-reverse; align-items: center; margin-bottom: 6px; }
.mc-bar { width: 22px; border-radius: var(--r-sm) var(--r-sm) 0 0; transition: height var(--transition-lg); min-height: 2px; }
.mc-lbl { font-size: 10px; color: var(--t3); font-weight: 500; }
.mc-val { font-size: 10px; font-weight: 700; color: var(--t2); margin-top: 2px; }

/* ──────────────────────────────────────
   SWATCHES
────────────────────────────────────── */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform var(--transition);
}
.swatch:hover { transform: scale(1.25); }
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }

/* ──────────────────────────────────────
   EMPTY STATE
────────────────────────────────────── */
.empty { text-align: center; padding: 56px 24px; color: var(--t2); }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty p { font-size: 14px; line-height: 1.7; }

/* ──────────────────────────────────────
   SNACKBAR
────────────────────────────────────── */
.notif {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 40px));
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 12px 22px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  transition: transform var(--transition-lg);
  min-width: 180px; max-width: 420px;
  color: var(--text);
}
.notif.show { transform: translateX(-50%) translateY(0); }
.notif-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.notif.ok  .notif-dot { background: var(--green); }
.notif.err .notif-dot { background: var(--red); }

/* ──────────────────────────────────────
   SCROLLBAR
────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--t3); }

/* ──────────────────────────────────────
   ANIMATIONS
────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page.active > * {
  animation: fade-up var(--transition-md) ease both;
}
.page.active > *:nth-child(2) { animation-delay: 30ms; }
.page.active > *:nth-child(3) { animation-delay: 60ms; }
.page.active > *:nth-child(4) { animation-delay: 90ms; }
.page.active > *:nth-child(5) { animation-delay: 120ms; }

/* ──────────────────────────────────────
   CATEGORY ROWS
────────────────────────────────────── */
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  border-radius: 0;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--surface-2); }
.cat-ico { width: 36px; height: 36px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.cat-info { flex: 1; }
.cat-name  { font-size: 13px; font-weight: 500; }
.cat-count { font-size: 11px; color: var(--t3); margin-top: 1px; }

/* ══════════════════════════════════════
   RESPONSIVE — Tablet
══════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .main { padding: 24px 24px 48px; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .tbl-head { grid-template-columns: 130px 1fr 110px 68px 110px 56px; }
  .tbl-row  { grid-template-columns: 130px 1fr 110px 68px 110px 56px; }
}

/* ══════════════════════════════════════
   MOBILE TAB BAR
══════════════════════════════════════ */
.mob-nav { display: none; }

@media (max-width: 680px) {
  .sidebar { display: none !important; }

  .mob-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 64px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    align-items: stretch;
  }

  .mob-tab {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    border: none; background: transparent;
    color: var(--t2);
    font-family: var(--font-body);
    font-size: 10px; font-weight: 600;
    cursor: pointer; padding: 8px 4px;
    position: relative;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
  }
  .mob-tab svg { width: 22px; height: 22px; stroke-width: 1.8; transition: transform var(--transition-md); }
  .mob-tab span { font-size: 10px; line-height: 1; letter-spacing: 0.02em; }
  .mob-tab.active { color: var(--accent); }
  .mob-tab.active svg { transform: translateY(-1px); }
  .mob-tab.active::before {
    content: '';
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 24px; height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
  }

  /* Layout */
  .app { grid-template-columns: 1fr; min-height: 100dvh; }
  .main { padding: 16px 14px 90px; max-height: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* Page header */
  .ph { margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
  .ph-left { flex: 1 1 100%; margin-bottom: 8px; }
  .ph-actions { flex-shrink: 0; }
  .pt { font-size: 22px; }
  .ps { font-size: 12px; }
  .ph .btn { padding: 9px 16px; font-size: 13px; }

  /* Grid */
  .g4, .g3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .g2 { grid-template-columns: 1fr; gap: 10px; }

  /* Stat cards */
  .sc { padding: 14px 14px 12px; }
  .sc-val { font-size: 20px; }
  .sc-icon { width: 32px; height: 32px; margin-bottom: 10px; }
  .sc-icon svg { width: 14px; height: 14px; }
  .sc-label { font-size: 9px; }

  /* Cards */
  .card { padding: 14px 16px; border-radius: var(--r-md); }
  .card-sm { padding: 12px 14px; }
  .mb-5, .mb-6 { margin-bottom: 12px; }

  /* Accounts horizontal scroll */
  #dash-accounts {
    display: flex !important;
    gap: 12px; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px; scrollbar-width: none;
    grid-template-columns: none !important;
  }
  #dash-accounts::-webkit-scrollbar { display: none; }
  #dash-accounts .acc-card { min-width: 190px; flex-shrink: 0; padding: 16px; }
  #dash-accounts .acc-bal { font-size: 20px; margin-top: 8px; }

  /* Accounts page */
  #accs-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .acc-card { padding: 14px; }
  .acc-bal { font-size: 20px; margin-top: 8px; }

  /* Transaction list */
  .tbl-head { display: none; }
  .tbl-date-row { padding: 10px 16px 6px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
  .tbl-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 4px; min-height: 52px;
    grid-template-columns: none; border-bottom: 1px solid var(--border);
  }
  .tbl-cat { flex-shrink: 0; }
  .tbl-cat-ico { width: 40px; height: 40px; border-radius: var(--r-full); font-size: 18px; }
  .tbl-cat-name { display: none; }
  .tbl-desc { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 1px; padding-right: 4px; white-space: normal; overflow: hidden; }
  .tbl-desc-main { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .tbl-desc-tags { margin-top: 2px; }
  .tbl-acc { display: none; }
  .tbl-date { font-size: 11px; color: var(--t3); white-space: nowrap; flex-shrink: 0; }
  .tbl-amt { flex-shrink: 0; }
  .tbl-amt-num { font-size: 14px; }
  .tbl-acts { opacity: 1; flex-shrink: 0; gap: 2px; }

  /* Filters */
  .period-bar { gap: 7px; }
  .period-bar .tabs { flex-wrap: wrap; width: 100%; }
  .period-bar .tabs .tb { flex: 1; min-width: 0; font-size: 11px; padding: 5px 6px; }
  .period-bar select { width: 100% !important; }
  .custom-dates { flex-wrap: wrap; }
  .custom-dates input[type=date] { flex: 1; min-width: 120px; width: auto; }
  .custom-dates .btn { width: 100%; justify-content: center; }
  #tx-totals.g3 { grid-template-columns: repeat(3,1fr) !important; gap: 6px; }
  #tx-totals .sc { padding: 10px 10px 8px; border-radius: 14px; }
  #tx-totals .sc-icon { display: none; }
  #tx-totals .sc-val { font-size: 13px; margin-top: 4px; word-break: break-all; }
  #tx-totals .sc-label { font-size: 8px; letter-spacing: 0.06em; }
  #tx-totals .sc-sub { display: none; }

  /* Charts */
  .chart-wrap { height: 190px; }
  .chart-md   { height: 160px; }
  .chart-sm   { height: 130px; }

  /* Analytics */
  #an-stats.g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ph .tabs { flex-wrap: wrap; gap: 4px; }
  .ph .tabs .tb { font-size: 11px; padding: 5px 10px; }

  /* Goals */
  #goals-grid.g3 { grid-template-columns: 1fr !important; }

  /* Heatmap */
  .heatmap-wrap { overflow-x: scroll; -webkit-overflow-scrolling: touch; }

  /* Modals — fullscreen from bottom */
  .mo { align-items: flex-end; }
  .mo.show { overflow: hidden; }
  .modal {
    width: 100% !important; max-width: 100% !important;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 0 20px;
    transform: translateY(100%);
    border: none;
    display: flex; flex-direction: column;
    overflow-y: auto; scrollbar-width: none;
  }
  .modal::-webkit-scrollbar { display: none; }
  .mo.show .modal { transform: translateY(0) scale(1); }
  .modal::before { display: none; }

  .mh { margin-bottom: 4px; flex-shrink: 0; padding-top: 20px; }
  .mf {
    flex-shrink: 0; margin-top: auto;
    padding: 16px 0 calc(70px + env(safe-area-inset-bottom));
    background: var(--surface);
    gap: 8px; justify-content: flex-end; display: flex;
  }

  /* Forms */
  .fg-grid { grid-template-columns: 1fr; gap: 16px 0; }
  .input-amount { font-size: 15px; }
  .tx-toprow { flex-direction: column; gap: 16px; margin-top: 0; }
  .tx-toprow .tx-date-fg { flex: 0 0 auto; width: 100%; }
  .mo-tx-toggle { margin-bottom: 16px; }
  .mo-tx-grid { margin-top: 16px; }
  .tx-tags { margin-top: 16px; }
  input, select { font-size: 16px !important; }

  /* Notifications */
  .notif {
    bottom: 80px; left: 12px; right: 12px;
    transform: translateX(0) translateY(calc(100% + 100px));
    min-width: 0; max-width: none;
    white-space: normal; border-radius: var(--r-lg);
  }
  .notif.show { transform: translateX(0) translateY(0); }

  .version-tag { display: none; }
}

/* XS */
@media (max-width: 400px) {
  .main { padding: 12px 12px 80px; }
  .sc-val { font-size: 17px; }
  .pt { font-size: 20px; }
  #accs-grid { grid-template-columns: 1fr !important; }
  .mob-tab span { font-size: 9px; }
  .mob-tab svg { width: 20px; height: 20px; }
}

/* Safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 680px) {
    .mob-nav {
      height: calc(64px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
    }
    .main { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
    .notif { bottom: calc(76px + env(safe-area-inset-bottom)); }
    .mob-more-menu { padding-bottom: calc(64px + env(safe-area-inset-bottom) + 16px); }
  }
}

/* Landscape */
@media (max-width: 680px) and (orientation: landscape) {
  .main { padding-top: 10px; }
  .modal { max-height: 88dvh; }
  .chart-wrap { height: 140px; }
}

/* No hover on touch */
@media (hover: none) {
  .sc:hover, .acc-card:hover, .goal-card:hover, .tbl-row:hover {
    transform: none; box-shadow: var(--shadow-md); background: inherit;
  }
  .tbl-acts { opacity: 1; }
}

/* ══════════════════════════════════════
   MORE MENU
══════════════════════════════════════ */
.mob-more-overlay {
  display: none; position: fixed; inset: 0; z-index: 98;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.mob-more-overlay.show { display: block; }

.mob-more-menu {
  position: fixed; bottom: -100%; left: 0; right: 0; z-index: 99;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--border);
  padding: 0 16px 100px;
  transition: bottom var(--transition-lg);
  box-shadow: var(--shadow-lg);
  max-height: calc(80dvh - 64px);
  overflow-y: auto;
}
.mob-more-menu.show { bottom: 64px; }
.mob-more-handle { width: 32px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 20px; }

.mob-more-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 4px;
  border: none; background: transparent;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
  border-radius: 0;
}
.mob-more-item:last-child { border-bottom: none; }
.mob-more-item:active { background: var(--surface-2); }

.mob-more-ico {
  width: 44px; height: 44px; border-radius: var(--r-full);
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mob-more-ico svg { width: 20px; height: 20px; color: var(--accent); }
.mob-more-label { flex: 1; text-align: left; }
.mob-more-title { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.mob-more-sub   { display: block; font-size: 12px; color: var(--t3); margin-top: 2px; }
.mob-more-arrow { width: 16px; height: 16px; color: var(--t3); flex-shrink: 0; }

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mob-more-menu { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
}

/* ══════════════════════════════════════
   SETTINGS PAGE
══════════════════════════════════════ */
.settings-btns { display: flex; flex-direction: column; gap: 8px; }
.settings-btn { width: 100%; justify-content: flex-start; border-radius: var(--r-md) !important; }
@media (min-width: 681px) {
  .settings-btns { flex-direction: row; flex-wrap: wrap; }
  .settings-btn { width: auto; }
}

/* ══════════════════════════════════════
   SHOPPING LIST
══════════════════════════════════════ */
.shop-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.shop-item:last-child { border-bottom: none; }
.shop-item:hover { background: var(--surface-2); }
.shop-done { opacity: 0.5; }
.shop-done .shop-name { text-decoration: line-through; color: var(--t2); }
.shop-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  color: #fff;
}
.shop-check:hover { border-color: var(--accent); }
.shop-check.checked { background: var(--accent); border-color: var(--accent); }
.shop-name { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }
.shop-qty {
  font-size: 12px; color: var(--t2);
  background: var(--surface-2); padding: 1px 7px;
  border-radius: var(--r-full);
  font-weight: 500; margin-left: 6px;
}
.shop-del { opacity: 0; transition: opacity var(--transition); }
.shop-item:hover .shop-del { opacity: 1; }
@media (hover: none) { .shop-del { opacity: 1; } }
.shop-section-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 8px 6px;
  font-size: 11px; font-weight: 700; color: var(--t3);
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════
   OBLIGATIONS
══════════════════════════════════════ */
.obl-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.obl-stat { text-align: center; }
.obl-stat-label { font-size: 10px; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.obl-stat-val { font-family: var(--font-num); font-size: 18px; font-weight: 500; }
.obl-stat-main .obl-stat-val { font-size: 22px; }

.obl-budget-block { display: flex; flex-direction: column; gap: 12px; }
.obl-budget-row { display: flex; gap: 0; }
.obl-budget-item { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.obl-budget-item--center { text-align: center; align-items: center; }
.obl-budget-item--right  { text-align: right; align-items: flex-end; }
.obl-budget-label { font-size: 11px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.08em; }
.obl-budget-val { font-family: var(--font-num); font-size: 22px; font-weight: 500; letter-spacing: -0.03em; color: var(--text); }
.obl-pbar-wrap { display: flex; flex-direction: column; gap: 6px; }
.obl-pbar-track { position: relative; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.obl-pbar-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.obl-pbar-fill--paid { background: var(--green); opacity: 0.5; }
.obl-pbar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--t3); }

.obl-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.obl-item:last-child { border-bottom: none; }
.obl-item:hover { background: var(--surface-2); }
.obl-paid { opacity: 0.55; }
.obl-paid .obl-item-name { text-decoration: line-through; color: var(--t2); }
.obl-item-info { flex: 1; min-width: 0; }
.obl-item-name { font-size: 14px; font-weight: 600; color: var(--text); }
.obl-item-note { font-size: 11px; color: var(--t3); margin-top: 2px; }
.obl-item-right { text-align: right; flex-shrink: 0; }
.obl-item-amount { font-family: var(--font-num); font-size: 15px; font-weight: 500; }
.obl-item-pct { font-size: 10px; color: var(--t3); margin-top: 2px; }

/* ══════════════════════════════════════
   DIRECTION TOGGLE
══════════════════════════════════════ */
.direction-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--t2);
  cursor: pointer; font-size: 13px;
  transition: all var(--transition);
  flex: 1;
}
.direction-btn:hover { background: var(--surface-2); }
.direction-btn.active.in  { background: var(--green-bg);  color: var(--green);  border-color: var(--green);  }
.direction-btn.active.out { background: var(--red-bg);    color: var(--red);    border-color: var(--red);    }

#tx-direction-toggle { display: flex; gap: 8px; margin-bottom: 10px; }

/* ══ FINAL TWEAKS ══ */

/* Transaction page card — table fills card edge-to-edge */
#page-transactions .card { padding: 0; overflow: hidden; }
.tbl-body .tbl-date-row:first-child { padding-top: 14px; }
#page-transactions .card.card-sm { padding: 14px 16px; }

/* Settings user info */
#settings-user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

/* Dashed add-account card */
.acc-card[style*="dashed"] {
  border: 1.5px dashed var(--border);
  background: transparent;
  cursor: pointer; box-shadow: none;
  transition: background var(--transition), border-color var(--transition);
}
.acc-card[style*="dashed"]:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}

/* Modal scrollbar */
.modal::-webkit-scrollbar { width: 3px; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Analytics line chart card background */
#page-analytics .card:first-of-type { background: var(--surface); }
