:root {
  color-scheme: light;

  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;

  --text: #14171c;
  --text-2: #39404a;
  --muted: #5c6672;
  --muted-2: #8a939e;

  --line: #d8dce2;
  --line-2: #c4cad2;
  --rule: #a9b1bb; /* section dividers: a step darker than --line-2 so they read in light mode */

  --primary: #0b5d43;
  --primary-600: #094d37;
  --primary-soft: #e6f0eb;
  --primary-tint: #d7e9e0;
  --primary-tint-line: #b7d5c9;
  --accent: #2fbf7f;

  --income: #0e7a4d;
  --expense: #b5343f;
  --transfer: #3f4aa8;
  --bill: #a26a10;
  --info: #256fa0;

  --danger: #b5343f;
  --danger-soft: #fbecee;

  --transfer-soft: #eceef8;
  --bill-soft: #f6efe0;
  --info-soft: #e9f2f8;
  --purple-soft: #f3eefb;
  --grid-line: rgba(20, 23, 28, 0.03);
  --chart-grid: #e3e7ec;
  --chart-label: #5c6672;
  --on-primary: #ffffff;
  --focus-ring: rgba(11, 93, 67, 0.12);
  --toast-bg: #14171c;
  --toast-fg: #ffffff;

  --shadow-2: 0 6px 20px rgba(15, 23, 34, 0.14);
  --shadow-3: 0 24px 56px rgba(15, 23, 34, 0.24);

  --r-xs: 2px;
  --r: 3px;
  --r-lg: 4px;

  --masthead-h: 56px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1013;
  --surface: #14181d;
  --surface-2: #1a1f25;
  --surface-3: #222831;

  --text: #e7ebef;
  --text-2: #b7c0c9;
  --muted: #8b96a1;
  --muted-2: #636e79;

  --line: #262d36;
  --line-2: #323b46;
  --rule: #323b46;

  --primary: #4f927a;
  --primary-600: #64a88d;
  --primary-soft: #16261f;
  --primary-tint: #1d3429;
  --primary-tint-line: #2e4f40;
  --accent: #4f927a;
  --on-primary: #ffffff;

  --income: #64a88d;
  --expense: #d97c84;
  --transfer: #8995d9;
  --bill: #cba153;
  --info: #6fa1c6;

  --danger: #d97c84;
  --danger-soft: #2c1e21;
  --transfer-soft: #202333;
  --bill-soft: #2b2518;
  --info-soft: #172229;
  --purple-soft: #251f30;

  --grid-line: rgba(255, 255, 255, 0.03);
  --chart-grid: #262d36;
  --chart-label: #8b96a1;
  --focus-ring: rgba(79, 146, 122, 0.22);
  --toast-bg: #e7ebef;
  --toast-fg: #0d1013;

  --shadow-2: 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 24px 56px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* No pinch or double-tap zoom of the page; charts zoom themselves. */
/* No pull-down (or pull-up) bounce at the ends of the page: it does nothing here. */
html, body { overscroll-behavior-y: none; }
html {
  height: 100%; touch-action: pan-x pan-y;
  /* No grey flash on tapped links, and no text inflation when the phone turns. */
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
/* The page runs edge to edge (viewport-fit=cover): keep it clear of the notch
   when the phone is on its side, and of the home indicator. */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.drawer, .chat-panel.floating { padding-bottom: env(safe-area-inset-bottom); }
/* A long press on the tabs or a button shouldn't open the link preview or
   select its label, as it wouldn't in an app. */
.tabnav, .masthead-actions, .btn, .icon-btn { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 19px; }
h2 { font-size: 13px; }
h3 { font-size: 13px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.num, .stat-value, .tx-amount, .cat-amount, .num-value { font-variant-numeric: tabular-nums; }

.stat-value, .num-value, .tx-amount, .cat-amount,
.tx-table .num { font-family: var(--mono); letter-spacing: -0.01em; }
.table-widget td.num { font-variant-numeric: tabular-nums; }

.icon {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}
.icon.big { width: 28px; height: 28px; stroke-width: 1.5; }

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

.app { min-height: 100%; }
/* App pages: the window itself never scrolls. The masthead stays put and
   .content scrolls beneath it, so the scrollbar runs only beside what moves.
   --app-h is the height of the screen still in view; app.js shortens it (and
   sets --app-top) while the keyboard is up on Queries. */
:root { --app-h: 100dvh; }
html:has(.app.shell), html:has(.app.shell) body { overflow: hidden; }
.app.shell {
  position: fixed; top: var(--app-top, 0px);
  left: env(safe-area-inset-left); right: env(safe-area-inset-right);
  height: var(--app-h); min-height: 0;
  display: flex; flex-direction: column;
}
.app.shell > .main { flex: 1; min-height: 0; }
.app.shell .masthead, .app.shell > .conn-banner { flex: none; }
.app.shell .content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: none; }
.app.shell .content:focus { outline: none; }
.main { display: flex; flex-direction: column; min-width: 0; }

.masthead {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center;
  height: var(--masthead-h);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; flex: none; margin-right: 10px; }
.brand .gw { width: 30px; height: 30px; }
.brand-name {
  font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -0.02em;
}
.brand .gw-seg,
.brand .gw-head {
  transform-box: fill-box;
  transform-origin: center;
}
.brand.wiggle .gw-seg { animation: brand-wiggle-seg 1s ease; }
.brand.wiggle .gw-seg-1 { animation-delay: 0s; }
.brand.wiggle .gw-seg-2 { animation-delay: -0.08s; }
.brand.wiggle .gw-seg-3 { animation-delay: -0.16s; }
.brand.wiggle .gw-head { animation: brand-wiggle-head 1s ease; animation-delay: -0.24s; }
@keyframes brand-wiggle-seg {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  15% { transform: translateY(-2.4px) rotate(-2.5deg); }
  35% { transform: translateY(2.4px) rotate(2.5deg); }
  55% { transform: translateY(-2px) rotate(-2deg); }
  75% { transform: translateY(2px) rotate(2deg); }
  90% { transform: translateY(0) rotate(0deg); }
}
@keyframes brand-wiggle-head {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  15% { transform: translateY(2.6px) rotate(3deg); }
  35% { transform: translateY(-2.6px) rotate(-3deg); }
  55% { transform: translateY(2px) rotate(2deg); }
  75% { transform: translateY(-2px) rotate(-2deg); }
  90% { transform: translateY(0) rotate(0deg); }
}
.brand-mark {
  display: inline-block;
  width: 9px; height: 9px; border-radius: 1px;
  background: var(--accent);
  flex: none;
}
.brand-mark.lg {
  width: 44px; height: 44px; border-radius: 4px;
  background: var(--primary-soft);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary); margin: 0 auto 14px;
}
.brand-mark.lg .icon { width: 20px; height: 20px; }
.status-dot { width: 7px; height: 7px; border-radius: 1px; background: var(--accent); flex: none; }

.period-wrap { flex: none; margin-left: 12px; position: relative; }
.period-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; max-width: 220px; padding: 0 9px 0 10px;
  border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--surface); color: var(--text-2);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.01em;
  cursor: pointer; transition: border-color 0.14s;
}
.period-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.period-trigger .icon { width: 13px; height: 13px; color: var(--muted); transition: transform 0.15s; }
.period-trigger:hover { border-color: var(--muted-2); }
.period-trigger[aria-expanded="true"] { border-color: var(--primary); }
.period-trigger[aria-expanded="true"] .icon { transform: rotate(180deg); }
.period-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; width: 288px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); padding: 4px 0 0;
}
.period-options { display: flex; flex-direction: column; padding: 0 4px; }
.period-options button {
  text-align: left; border: 0; background: none; color: var(--text-2);
  font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 3px; cursor: pointer;
}
.period-options button:hover, .period-options button:focus-visible { background: var(--surface-2); color: var(--text); }
.period-options button[aria-selected="true"] { color: var(--primary); font-weight: 600; }
.period-custom { border-top: 1px solid var(--line); margin-top: 4px; padding: 9px 12px 12px; }
.period-custom.selected .period-custom-head { color: var(--primary); }
.period-custom-head { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.period-custom-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 9px; }
.period-custom-fields label { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 11.5px; color: var(--muted); }
.period-custom input[type="date"] {
  width: 100%; min-width: 0; border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--surface); color: var(--text);
  font-family: var(--mono); font-size: 11.5px; padding: 5px 6px; outline: none;
}
.period-custom input[type="date"]:focus { border-color: var(--primary); }
.period-custom .btn { width: 100%; justify-content: center; }

.masthead-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: 12px; align-self: stretch; }
.masthead-actions .icon-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* Hidden amounts: the text stays (so nothing moves) but is see-through, with
   the same redaction bar over every value whatever its size. */
body.privacy .stat-value:not(.no-blur):not(:empty),
body.privacy .account-balance:not(.no-blur):not(:empty),
body.privacy .cat-amount:not(.no-blur):not(:empty),
body.privacy .num-value:not(.no-blur):not(:empty),
body.privacy .num-caption:not(.no-blur):not(:empty),
body.privacy .num-trend:not(.no-blur):not(:empty),
body.privacy .stat-trend:not(.no-blur):not(:empty),
body.privacy .account-row p:not(.no-blur):not(:empty),
body.privacy .settings-account-balance:not(.no-blur):not(:empty),
body.privacy .settings-account-opening:not(.no-blur):not(:empty),
body.privacy .valuation-value:not(.no-blur):not(:empty),
body.privacy .balance-panel-now:not(.no-blur):not(:empty),
body.privacy .valuation-compare:not(.no-blur):not(:empty),
body.privacy .table-widget td.num:not(.no-blur):not(:empty),
body.privacy .chart-hover-tip .chart-tip-value:not(.no-blur):not(:empty) {
  position: relative; color: transparent !important; text-shadow: none;
}
body.privacy .stat-value:not(.no-blur):not(:empty) *,
body.privacy .account-balance:not(.no-blur):not(:empty) *,
body.privacy .cat-amount:not(.no-blur):not(:empty) *,
body.privacy .num-value:not(.no-blur):not(:empty) *,
body.privacy .num-caption:not(.no-blur):not(:empty) *,
body.privacy .num-trend:not(.no-blur):not(:empty) *,
body.privacy .stat-trend:not(.no-blur):not(:empty) *,
body.privacy .account-row p:not(.no-blur):not(:empty) *,
body.privacy .settings-account-balance:not(.no-blur):not(:empty) *,
body.privacy .settings-account-opening:not(.no-blur):not(:empty) *,
body.privacy .valuation-value:not(.no-blur):not(:empty) *,
body.privacy .balance-panel-now:not(.no-blur):not(:empty) *,
body.privacy .valuation-compare:not(.no-blur):not(:empty) *,
body.privacy .table-widget td.num:not(.no-blur):not(:empty) *,
body.privacy .chart-hover-tip .chart-tip-value:not(.no-blur):not(:empty) * { color: transparent !important; visibility: hidden; }
body.privacy .stat-value:not(.no-blur):not(:empty)::after,
body.privacy .account-balance:not(.no-blur):not(:empty)::after,
body.privacy .cat-amount:not(.no-blur):not(:empty)::after,
body.privacy .num-value:not(.no-blur):not(:empty)::after,
body.privacy .num-caption:not(.no-blur):not(:empty)::after,
body.privacy .num-trend:not(.no-blur):not(:empty)::after,
body.privacy .stat-trend:not(.no-blur):not(:empty)::after,
body.privacy .account-row p:not(.no-blur):not(:empty)::after,
body.privacy .settings-account-balance:not(.no-blur):not(:empty)::after,
body.privacy .settings-account-opening:not(.no-blur):not(:empty)::after,
body.privacy .valuation-value:not(.no-blur):not(:empty)::after,
body.privacy .balance-panel-now:not(.no-blur):not(:empty)::after,
body.privacy .valuation-compare:not(.no-blur):not(:empty)::after,
body.privacy .table-widget td.num:not(.no-blur):not(:empty)::after,
body.privacy .chart-hover-tip .chart-tip-value:not(.no-blur):not(:empty)::after {
  /* Figure spaces struck through with a thick line: a bar of fixed width that
     follows the value's own alignment and size. */
  content: "\2007\2007\2007\2007\2007"; position: absolute; inset: 0; visibility: visible;
  white-space: pre; overflow: hidden;
  text-decoration: line-through; text-decoration-thickness: 0.62em; text-decoration-color: var(--line-2);
  text-decoration-skip-ink: none;
}
body.privacy #accOpening,
body.privacy #accValuation { -webkit-text-security: disc; }
@supports not (-webkit-text-security: disc) {
  body.privacy #accOpening,
  body.privacy #accValuation { color: transparent; }
}
/* Svg text can't take ::after, so charts draw a bar beside the real text. */
.privacy-mask { display: none; }
body.privacy .privacy-mask { display: inline; }
.privacy-mask { fill: var(--line-2); }
body.privacy .chart-y-label,
body.privacy .pie-total { display: none; }

.icon-btn {
  position: relative; width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--surface); color: var(--text-2);
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.icon-btn:hover { border-color: var(--muted-2); background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 5px; width: 6px; height: 6px;
  border-radius: 1px; background: var(--danger); border: 1px solid #fff;
}
.avatar {
  width: 32px; height: 32px; border-radius: 3px; border: 1px solid var(--line-2);
  background: var(--surface-3); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar .icon { width: 16px; height: 16px; }

.tabnav {
  display: flex; align-items: stretch; gap: 2px;
  flex: 1; min-width: 0;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabnav::-webkit-scrollbar { display: none; }
.tabnav-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 13px;
  border-bottom: 2px solid transparent;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  white-space: nowrap;
  flex: none;
  transition: color 0.14s, border-color 0.14s;
}
.tabnav-item:hover { color: var(--text); }
.tabnav-item.active {
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-index {
  font-family: var(--mono); font-size: 10px; color: var(--muted-2);
  letter-spacing: 0.05em;
}
.tabnav-item.active .tab-index { color: var(--primary); }
.tab-icon { display: none; }
.cell-cat-inline { display: none; }
/* Dates have the month written out, and the short form when the table is narrow. */
.date { white-space: nowrap; }
.date-short { display: none; }
.table-widget, .table-panel, .import-review { container-type: inline-size; }
@container (max-width: 640px) {
  .date-long { display: none; }
  .date-short { display: inline; }
}
.tabnav-spacer { flex: 1; }
.tabnav-item.tabnav-icon { height: 100%; padding: 0 8px; }
.tabnav-item.tabnav-icon .icon { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 3px;
  padding: 7px 13px; font-weight: 500; font-size: 13px;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 2px; }
.btn-xs .icon { width: 12px; height: 12px; }
.btn .icon { width: 14px; height: 14px; }
.link { border: none; background: none; color: var(--primary); font-weight: 500; padding: 0; }
.link:hover { text-decoration: underline; }

.content { --content-x: 22px; padding: 20px var(--content-x) 40px; width: 100%; }
.view { display: none; }
/* A page reaches the phone in pieces of a few KB, and the browser may draw
   after any of them: the tab bar with one tab across it, a button with half
   its label. Nothing is drawn until the page's last element (#pageEnd) is
   in, so the page before stays up and the new one appears whole. */
body:not(:has(> #pageEnd)) > .app { display: none; }
.view.active { display: block; }

/* Moving between pages: the browser keeps the old page up until the new one
   has painted, then swaps them with a quick crossfade, instead of a blank
   frame and a fade-in. The masthead is its own layer so it holds still. */
@view-transition { navigation: auto; }
.masthead { view-transition-name: masthead; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.12s; }
::view-transition-group(masthead), ::view-transition-old(masthead), ::view-transition-new(masthead) { animation-duration: 0s; }
/* Phone browsers (Safari especially) flicker the sticky masthead's tabs
   during the swap; they already hold the old page until the new one paints. */
@media (prefers-reduced-motion: reduce), (max-width: 760px) {
  @view-transition { navigation: none; }
}


.query-head { align-items: center; }
.query-wrap { flex: 1; min-width: 0; }
.query-bar {
  display: flex; align-items: center; gap: 10px;
  height: 44px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--surface);
  padding: 0 6px 0 14px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.query-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.query-bar .icon { color: var(--muted-2); width: 16px; height: 16px; }
.query-bar input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text);
}
.query-bar input::placeholder { color: var(--muted-2); }
.query-submit { height: 32px; padding: 0 12px; }
.query-submit .icon { width: 15px; height: 15px; }

/* The message list runs from the masthead down to the composer; only a
   small gap is left under the suggestions. */
.content:has(#view-queries.active) { padding-top: 0; padding-bottom: 12px; display: flex; flex-direction: column; }
#view-queries.active {
  display: flex;
  flex-direction: column;
  flex: 1 0 0;
  min-height: 460px;
}
.queries-page { flex: 1; min-height: 0; display: flex; flex-direction: row; }
.queries-sidebar {
  flex: none;
  width: 232px;
  margin: 12px 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, margin-right 0.2s ease;
}
.queries-sidebar.collapsed { width: 0; margin-right: 0; border: none; }
.queries-sidebar-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.queries-sidebar-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.queries-sidebar-toggle .icon { transform: rotate(180deg); }
.queries-days {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px;
}
.queries-day {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%;
  border: 1px solid transparent; border-radius: 3px;
  background: transparent; color: var(--text-2);
  font-size: 12.5px; text-align: left;
  padding: 7px 9px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.queries-day:hover { background: var(--surface-2); color: var(--text); }
.queries-day-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.queries-day-count { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); }
.queries-day-summary {
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.queries-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.queries-sidebar-expand { position: absolute; top: 12px; left: 8px; z-index: 5; height: 32px; }
/* The list reaches the edge of the window so its scrollbar sits there, clear
   of the messages; the padding keeps them in line with the composer. */
.queries-messages {
  --bar: 8px;
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  margin-right: calc(-1 * var(--content-x));
  padding: 16px calc(var(--content-x) - var(--bar)) 12px 2px;
}
.queries-messages::-webkit-scrollbar { width: var(--bar); }
.queries-messages::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.queries-messages::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }
.queries-messages::-webkit-scrollbar-track { background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  .queries-messages { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
}
/* Touch screens draw the scrollbar over the content, taking no width. */
@media (pointer: coarse) {
  .queries-messages { padding-right: var(--content-x); }
}
.msg-day {
  align-self: center;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 10px;
  margin: 6px 0 2px;
}
.queries-composer {
  flex: none;
  display: flex; align-items: flex-end; gap: 10px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--surface);
  padding: 8px 8px 8px 14px;
  margin-top: 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.queries-composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.queries-composer textarea {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 14px; line-height: 1.4; color: var(--text);
  resize: none; max-height: 140px;
  /* One line is as tall as the send button, so the two line up. */
  padding: calc((32px - 1.4em) / 2) 0;
}
.queries-composer textarea::placeholder { color: var(--muted-2); }
.queries-suggestions {
  flex: none;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 2px 0;
}
.queries-suggestions[hidden] { display: none; }
.queries-suggestions .chip { font-size: 11.5px; }
.queries-messages .widget {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 14px;
  margin: 0;
  box-shadow: none;
}
.queries-messages .widget-title { font-size: 12px; }
.queries-messages .widget-head { margin-bottom: 8px; }
.queries-messages .widget-actions { opacity: 1; }
.queries-messages .chart-host svg { max-height: 360px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 20px 0 10px;
}
.section-head.inside { margin: 0 0 14px; }
.section-head h2 {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px;
}
.section-head h2::before {
  content: ""; width: 8px; height: 8px; background: var(--primary);
  border-radius: 1px; flex: none;
}
.section-head-actions { display: flex; align-items: center; gap: 10px; }
/* A trailing button takes the free space, keeping any note beside the heading. */
.section-head > .btn { margin-left: auto; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.stats-grid.three { grid-template-columns: repeat(3, 1fr); }
.stats-grid.col { grid-template-columns: 1fr; }
.stat-card {
  position: relative;
  background: var(--surface);
  padding: 13px 15px;
}
.stat-icon {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; border-radius: 3px;
  background: var(--surface-3); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.stat-icon .icon { width: 14px; height: 14px; }
.stat-card.compact { padding: 12px 14px; }
.stat-card.compact .stat-label { margin-bottom: 5px; }
.stat-card.compact .stat-value { font-size: 19px; }
.stat-card.compact .stat-trend { margin-top: 5px; }
.stat-label {
  color: var(--muted); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 8px;
}
.stat-value { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.stat-value.ok { color: var(--income); font-size: 17px; }
.stat-trend {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 7px; font-size: 12px; color: var(--muted);
}
.stat-trend .icon { width: 12px; height: 12px; }
.stat-trend.up { color: var(--income); }
.stat-trend.down { color: var(--expense); }

.overview {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 20px;
}
.overview .stats-grid { border: none; }
.panel.overview-chart {
  border: none; border-radius: 0; box-shadow: none;
  display: flex; flex-direction: column; justify-content: center;
  padding: 15px 18px;
}
.overview-chart .chart-host svg { width: 100%; height: auto; }

.chip {
  border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 3px; padding: 4px 11px; font-size: 12px;
  font-weight: 500; color: var(--text-2);
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.chip:hover { border-color: var(--muted-2); color: var(--text); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-600); }

.widgets-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 72px;
  grid-auto-flow: row dense;
  gap: 12px;
}
.widget {
  grid-column: span 6;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 13px 15px;
  position: relative;
  overflow: hidden;
}
.widget.span-4 { grid-column: span 4; }
.widget.span-8 { grid-column: span 8; }
.widget.span-12 { grid-column: span 12; }
.widget-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.widget-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.widget .chart-host { flex: 1; min-height: 0; }
.widget .chart-host svg { width: 100%; height: 100%; }
.widget .table-widget { flex: 1; min-height: 0; overflow: auto; }
.table-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--line-2); }
.table-link:hover { color: var(--primary); border-bottom-color: var(--primary); }
.widget .num-widget, .widget .text-widget { flex: none; }
.widget-empty {
  flex: 1; height: 100%; min-height: 72px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.widgets-grid .pie-wrap { flex: 1; min-height: 0; align-content: center; }
/* A long key scrolls inside the widget instead of being cut off. */
.widgets-grid .pie-legend { max-height: 100%; overflow-y: auto; padding-right: 4px; }
.widgets-grid .pie-chart { flex: 1 1 120px; min-width: 90px; min-height: 0; height: 100%; max-width: 100%; }
.widgets-grid .pie-chart svg { display: block; width: 100%; height: 100%; }
.widget-actions { display: flex; align-items: center; gap: 5px; opacity: 0; transition: opacity 0.14s; }

.widgets-grid.editing .widget { outline: 1px dashed var(--line-2); outline-offset: -1px; cursor: grab; touch-action: none; }
.widgets-grid.editing .widget:hover { outline-color: var(--primary); }
.widgets-grid.editing .widget-actions { opacity: 1; }
.widget.dragging { opacity: 0.35; }
.widgets-grid.editing .widget.drop-target { outline: 2px solid var(--primary); outline-offset: -2px; }

.resize-handle { position: absolute; z-index: 3; touch-action: none; display: none; }
.widgets-grid.editing .resize-handle { display: block; }
.rh-w { left: 0; top: 0; bottom: 0; width: 12px; cursor: ew-resize; }
.rh-e { right: 0; top: 0; bottom: 0; width: 12px; cursor: ew-resize; }
.rh-s { left: 0; right: 0; bottom: 0; height: 12px; cursor: ns-resize; }
.rh-w::after, .rh-e::after {
  content: ""; position: absolute; top: 50%; transform: translateY(-50%);
  width: 4px; height: 36px; border-radius: 2px; background: var(--muted-2); opacity: 0.55;
}
.rh-w::after { left: 4px; }
.rh-e::after { right: 4px; }
.rh-s::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px; background: var(--muted-2); opacity: 0.55;
}
.rh-s::after { bottom: 4px; }
.resize-handle:hover::after { background: var(--primary); opacity: 1; }

body.resizing { user-select: none; }
body.dragging-widget { user-select: none; cursor: grabbing; }
.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.85;
  box-shadow: var(--shadow-3);
  transform-origin: top left;
}
.widget:hover .widget-actions { opacity: 1; }
.widget-btn {
  width: 25px; height: 25px; border-radius: 3px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.widget-btn:hover { border-color: var(--muted-2); color: var(--text-2); }
.widget-btn .icon { width: 13px; height: 13px; }
.widget-btn.pinned-on { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.chart-host { width: 100%; }
.chart-host svg { display: block; width: 100%; height: auto; }
/* Line charts handle sideways drags and pinches themselves (x-axis zoom). */
.chart-host[data-chart-type="line"] { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart-host.chart-panning { cursor: grabbing; }
.chart-zoom-reset {
  position: absolute; top: 4px; right: 6px;
  padding: 3px 8px; font-size: 11px; line-height: 1.3;
  border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--surface); color: var(--text-2);
}
.chart-zoom-reset:hover { background: var(--surface-2); color: var(--text); }
.chart-tooltip { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }

.chart-hover-tip {
  position: fixed; z-index: 1200; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2);
  padding: 7px 10px; font-size: 12px; line-height: 1.35;
  white-space: nowrap; font-family: var(--font);
}
.chart-hover-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 5px solid var(--line);
}
.chart-hover-tip::before {
  content: ""; position: absolute; left: 50%; bottom: -4px; margin-left: -4px; z-index: 1;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 4px solid var(--surface);
}
.chart-hover-tip.below::after { bottom: auto; top: -5px; border-top-color: transparent; border-bottom: 5px solid var(--line); }
.chart-hover-tip.below::before { bottom: auto; top: -4px; border-top-color: transparent; border-bottom: 4px solid var(--surface); }
.chart-hover-tip .chart-tip-label { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.chart-hover-tip .chart-tip-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.pane-skeleton { display: flex; flex-direction: column; gap: 12px; }
.sk-block {
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.1s linear infinite;
}
.sk-row { height: 64px; }
@keyframes sk-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-block { animation: none; } }

.num-widget .num-value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.num-widget .num-caption { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.num-widget .num-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--income); margin-top: 8px; font-weight: 500;
}
.num-widget .num-trend.down { color: var(--expense); }

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

.table-widget { overflow-x: auto; }
.table-widget table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table-widget th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 7px 9px;
  border-bottom: 1px solid var(--line);
}
.table-widget td { padding: 7px 9px; border-bottom: 1px solid var(--line); }
.table-widget tr:last-child td { border-bottom: none; }
.table-widget td.num, .table-widget th.num { text-align: right; }

.thinking-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 15px;
}
.thinking-card .head { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 13px; margin-bottom: 11px; }
.thinking-card .head .icon { color: var(--primary); }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--line);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.reason-steps { display: flex; flex-direction: column; gap: 6px; }
.reason-step { display: flex; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.reason-step .tick { color: var(--primary); flex: none; }
.reason-step .tick .icon { width: 13px; height: 13px; }
.reason-body { flex: 1; min-width: 0; }
.reason-sql {
  margin: 6px 0 2px; padding: 8px 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5; color: var(--text);
}
.reason-sql code { background: none; border: 0; padding: 0; font: inherit; color: inherit; }
.reason-step code {
  font-family: var(--mono); font-size: 11px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: 2px; padding: 1px 5px; color: var(--text-2);
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
}
.tx-list { display: flex; flex-direction: column; }
.tx-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.tx-row:last-child { border-bottom: none; }
.tx-icon {
  width: 32px; height: 32px; border-radius: 3px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
}
.tx-icon.transfer { background: var(--transfer); color: #fff; }
.tx-main { flex: 1; min-width: 0; }
.tx-merchant { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { color: var(--muted); font-size: 12px; }
.tx-amount { font-weight: 500; font-size: 13px; white-space: nowrap; }
.tx-amount.pos { color: var(--income); }
.tx-amount.neg { color: var(--expense); }
.tx-amount.transfer { color: var(--transfer); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em;
  border-radius: 2px; padding: 2px 6px;
  white-space: nowrap; vertical-align: middle;
}
.badge-soft { background: var(--surface-3); color: var(--muted); }
.badge-income { background: var(--primary-soft); color: var(--income); }
.badge-expense { background: var(--danger-soft); color: var(--expense); }
.badge-transfer { background: var(--transfer-soft); color: var(--transfer); }
.badge-recurring { background: var(--bill-soft); color: var(--bill); }
.badge-linked { background: var(--transfer-soft); color: var(--transfer); }
.badge-btn {
  border: none; padding: 2px 6px; cursor: pointer;
  font: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em;
}
.badge-btn:hover { filter: brightness(0.96); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; }
.field {
  border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--surface); padding: 7px 11px; font-size: 13px; outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.field:disabled { opacity: 0.6; cursor: not-allowed; background: var(--surface-2); }
.field.search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.field.search .icon { color: var(--muted-2); width: 14px; height: 14px; }
.field.search input { border: none; outline: none; flex: 1; font-size: 13px; background: transparent; }
.field.select { min-width: 140px; color: var(--text-2); }
.field-row { margin-bottom: 12px; }
.field-row label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 5px; color: var(--text-2); }
.field-row .field { width: 100%; }
textarea.field { display: block; resize: vertical; min-height: 64px; line-height: 1.45; }
.key-row { display: flex; align-items: center; gap: 8px; }
.key-row .field { flex: 1; min-width: 0; }
.key-row .btn { flex: none; }
.model-picker { position: relative; }
.model-picker .field { width: 100%; }
.model-picker-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px; overflow-y: auto; margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  box-shadow: var(--shadow-2);
}
.model-picker-list li {
  padding: 6px 11px; font-size: 13px; cursor: pointer; display: flex; gap: 8px; align-items: baseline;
}
.model-picker-list li .model-id { color: var(--muted); font-size: 11.5px; font-family: var(--mono); margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.model-picker-list li[aria-selected="true"] { font-weight: 600; }
.model-picker-list li.active { background: var(--surface-2); }
.model-picker-list .model-picker-empty { color: var(--muted); cursor: default; }
/* A field's label with an (i) beside it; the note it opens sits under them. */
.label-row { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.label-row label { margin: 0; }
/* AI providers: a chip per connected provider (click to edit, × to disconnect). */
.ai-connected { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 14px; font-size: 12.5px; }
.ai-chip {
  display: inline-flex; align-items: stretch; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface-2); font-size: 12px; overflow: hidden;
}
.ai-chip.current { border-color: var(--primary); }
.ai-chip.pending { border-style: dashed; }
.ai-chip button { background: none; border: 0; color: var(--text); cursor: pointer; font: inherit; }
.ai-chip-name { padding: 3px 4px 3px 10px; }
.ai-chip.pending .ai-chip-name { padding-right: 10px; color: var(--muted); }
.ai-chip-x { padding: 0 9px 0 5px; color: var(--muted) !important; font-size: 14px; line-height: 1; }
.ai-chip-x:hover { color: var(--danger) !important; }
/* The provider a model comes from, in the model menus. */
.model-provider {
  flex: none; align-self: center; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 1px 6px; border-radius: 3px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-2); width: 72px; text-align: center; box-sizing: border-box;
}
.model-picker-list li { align-items: center; }
.model-picker-list li .model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* What the model lists and the connection test have to say, one provider a line. */
.ai-status-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.ai-status-list li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.ai-status-list li.muted { border: 0; background: none; padding: 0; }
.ai-status-icon {
  flex: none; width: 16px; height: 16px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: #fff; margin-top: 1px;
}
.ai-status-ok .ai-status-icon { background: var(--income, #1a7f4b); }
.ai-status-bad .ai-status-icon { background: var(--danger); }
.ai-status-text { min-width: 0; overflow-wrap: anywhere; }
.ai-status-detail { display: block; color: var(--muted); margin-top: 2px; }
.ai-status-list .mono { font-family: var(--mono); font-size: 11.5px; }

.account-actions {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 10px; margin: 12px 0 4px; max-width: 300px;
}
.account-actions .btn { justify-content: center; }
.field-cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.field-hint { margin-top: 6px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.field-unit { display: flex; align-items: center; }
.field-unit-symbol {
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-right: none;
  border-radius: 3px 0 0 3px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.field-unit .field {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  border-radius: 0;
}
.field-unit .field + .field { border-left: none; }
.field-unit .field:last-child { border-radius: 0 3px 3px 0; }
.field-unit .field-date { flex: 0 0 150px; }

.table-panel { padding: 0; overflow: hidden; }
.tx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tx-table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 9px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.tx-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tx-table tr:last-child td { border-bottom: none; }
.tx-table tbody tr { transition: background 0.12s; }
.tx-table tbody tr:hover { background: var(--surface-2); }
.tx-table .num { text-align: right; }
.tx-orig { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.th-sort {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
}
.th-sort:hover, .th-sort.active { color: var(--text-2); }
.th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.th-sort-arrow { font-size: 8px; min-width: 8px; }
.tx-table tbody tr[data-tx-id] { cursor: default; }
.tx-table .cell-merchant { font-weight: 500; }
.tx-table .cell-sub { color: var(--muted); font-size: 12px; }
.tx-table .row-actions { opacity: 0; transition: opacity 0.12s; }
.tx-table tr:hover .row-actions { opacity: 1; }

.tx-table tr.editing td { background: var(--primary-soft); }
.tx-table tr.editing .row-actions { opacity: 1; }
.tx-editor-row td { padding: 0 14px 12px !important; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tx-editor {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  padding: 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 3px;
}
.tx-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; font-weight: 500; color: var(--muted);
}
.tx-field .field { min-width: 118px; font-weight: 400; }
.tx-field.grow { flex: 1; min-width: 170px; }
.tx-check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2); padding-bottom: 8px; cursor: pointer;
  user-select: none; white-space: nowrap;
}
.tx-check input { accent-color: var(--primary); }
.tx-editor-actions { display: flex; gap: 6px; margin-left: auto; order: 11; }
/* The transfer link: a list of the likely other legs to pick from. */
.tx-link-field { flex-basis: 100%; order: 10; }
.tx-link-hint { font-weight: 400; color: var(--muted-2); margin-left: 4px; }
.tx-link-list { display: flex; flex-direction: column; gap: 6px; }
.tx-link-option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.tx-link-option:hover { border-color: var(--line-2); background: var(--surface-2); }
.tx-link-option[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.tx-link-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-link-desc { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-link-meta { font-size: 11.5px; color: var(--muted); }
.tx-link-acct { display: inline-flex; align-items: center; gap: 5px; }
.tx-link-dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.tx-link-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.tx-link-amt .tx-link-good { font-family: var(--font); font-size: 10.5px; }
.tx-link-good { color: var(--primary); }
.tx-link-empty { font-size: 12.5px; font-weight: 400; color: var(--muted); padding: 8px 0; }
.tx-link-more { align-self: flex-start; }
.tx-link-linked { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 400; color: var(--text-2); padding: 6px 0; }
.tx-link-linked .icon { width: 14px; height: 14px; color: var(--primary); }
.tx-table tr.linked .cell-merchant { font-weight: 500; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
/* In Settings the categories are a band of their own between the accounts
   and the preferences, ruled off from both. */
.settings-categories {
  margin: 28px 0; padding: 8px 0 28px;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.settings-categories + .section-head { margin-top: 0; }
/* History: the same rule sets the audit log off from the timeline above it. */
.history-audit { margin-top: 28px; padding-top: 8px; border-top: 1px solid var(--rule); }
/* A page that isn't built yet. */
.page-placeholder { text-align: center; padding: 56px 20px; }
.page-placeholder .icon { width: 34px; height: 34px; color: var(--primary); margin-bottom: 10px; }
.page-placeholder h2 { margin: 0 0 6px; }
.page-placeholder p { margin: 0 auto; max-width: 340px; }
.category-form { margin-bottom: 16px; }
.category-form-title { font-size: 14px; margin: 0 0 12px; }
.category-form-note { color: var(--muted); font-size: 12px; margin: -8px 0 12px; }
.category-form-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.category-form-actions .spacer { flex: 1; }
.category-card { background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 15px; }
.category-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 72px;
  border-top: 0; border-left: 0; font: inherit; color: var(--muted); cursor: pointer;
}
.category-add:hover { color: var(--primary); background: var(--primary-soft); }
.category-card .cat-top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.category-card .cat-name { font-weight: 500; flex: 1; }
.category-card .cat-badge { color: var(--muted); font-size: 11.5px; }
.category-card .cat-edit {
  width: 24px; height: 24px; border: none; background: none; padding: 0;
  color: var(--muted-2); flex: none; margin-left: 2px;
}
.category-card .cat-edit:hover { color: var(--primary); background: var(--primary-soft); }
.category-card .cat-edit .icon { width: 13px; height: 13px; }
/* With a mouse, the edit button shows when the card is hovered or the button
   has keyboard focus; touch screens, which can't hover, always show it. */
@media (hover: hover) and (pointer: fine) {
  .category-card .cat-edit { opacity: 0; transition: opacity 0.12s; }
  .category-card:hover .cat-edit, .category-card .cat-edit:focus-visible { opacity: 1; }
}
.category-card .cat-amount { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.category-card .cat-amount.pos { color: var(--income); }
.category-card .cat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { background: var(--surface-2); }
.stat-card.clickable.selected { outline: 1px solid var(--primary); outline-offset: -1px; }
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.account-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.account-card:hover { border-color: var(--muted-2); }
.account-card.selected { border-color: var(--primary); outline: 1px solid var(--primary); outline-offset: -1px; }
.account-card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.account-dot { width: 9px; height: 9px; border-radius: 1px; flex: none; }
.account-name { font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-balance { font-size: 19px; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; }
.account-balance.neg { color: var(--expense); }
.account-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.account-tx-panel { margin-top: 0; }

.dropzone {
  border: 1px dashed var(--line-2); border-radius: var(--r);
  background: var(--surface); padding: 30px 22px; text-align: center;
  color: var(--text-2); margin-bottom: 20px;
  transition: border-color 0.14s, background 0.14s;
}
.dropzone { cursor: pointer; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .icon.big { color: var(--muted-2); margin-bottom: 8px; }
.dropzone.small { padding: 22px 16px; margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.schema-list {
  display: flex; flex-direction: column;
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.schema-card {
  background: var(--surface); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.schema-card .schema-logo {
  width: 30px; height: 30px; border-radius: 3px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #fff; font-size: 12px;
}
.schema-card .schema-main { flex: 1; min-width: 0; }
.schema-card .schema-name { font-weight: 500; font-size: 13px; }
.schema-card .schema-cols { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.schema-card .schema-conf { font-size: 11.5px; color: var(--income); font-weight: 500; }
.steps-list { list-style: none; padding: 4px 2px; display: flex; flex-direction: column; gap: 13px; }
.steps-list li { display: flex; align-items: center; gap: 11px; font-size: 13px; }
.step-num {
  width: 22px; height: 22px; border-radius: 3px; flex: none;
  background: var(--primary-soft); color: var(--primary-600);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11.5px;
}

.segmented {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--surface-2); padding: 4px; gap: 4px;
}
.segmented-item {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; background: transparent; border-radius: 3px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); cursor: pointer;
  transition: color 0.14s, background 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.segmented-item .icon { width: 15px; height: 15px; }
.segmented-item:hover { color: var(--text); }
.segmented-item.active {
  background: var(--primary-soft); color: var(--primary-600);
  border-color: var(--primary); font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 34, 0.1);
}

.tx-direction { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-bottom: 12px; }
.tx-direction .segmented-item { padding: 6px 12px; font-size: 13px; }

.timeline-controls { margin-bottom: 12px; }
.timeline-head {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 15px; border-bottom: 1px solid var(--line);
}
.timeline-ico { width: 18px; height: 18px; color: var(--primary); flex: none; }
.timeline-date-main { flex: 1; min-width: 0; }
.timeline-date-label { font-size: 11px; color: var(--muted-2); margin-bottom: 1px; }
.timeline-date { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.timeline-chip {
  font-size: 11px; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 3px 9px; white-space: nowrap;
}
.timeline-slider-wrap { padding: 14px 15px 8px; }
.timeline-slider-wrap input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0;
  background: transparent; cursor: pointer;
}
.timeline-slider-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--primary) var(--fill, 100%), var(--line-2) var(--fill, 100%));
}
.timeline-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 34, 0.28);
  margin-top: -5px;
}
.timeline-slider-wrap input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--line-2);
}
.timeline-slider-wrap input[type="range"]::-moz-range-progress {
  height: 6px; border-radius: 3px; background: var(--primary);
}
.timeline-slider-wrap input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 34, 0.28);
}
.timeline-ticks { position: relative; height: 24px; margin-top: 1px; }
.timeline-tick {
  position: absolute; top: 0; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
}
.timeline-tick::before {
  content: ""; width: 1px; height: 5px; background: var(--line-2); margin-bottom: 4px;
}
.timeline-tick[hidden] { display: none; }
.timeline-tick span { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
.timeline-tick.first { transform: none; align-items: flex-start; }
.timeline-tick.last { transform: translateX(-100%); align-items: flex-end; }
.timeline-accounts { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 16px; }
.timeline-account { background: var(--surface); padding: 10px 14px; display: flex; align-items: center; gap: 11px; cursor: pointer; }
.timeline-account:hover { background: var(--surface-2); }
.timeline-account.selected { outline: 1px solid var(--primary); outline-offset: -1px; }
.timeline-account .account-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.timeline-account .account-balance { font-family: var(--mono); font-weight: 600; font-size: 13.5px; }
.timeline-account .account-balance.neg { color: var(--expense); }

.history-list {
  display: flex; flex-direction: column;
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.history-item {
  background: var(--surface); padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start;
}
/* Undone: the change fades, the rail through it doesn't. */
.history-item.inactive > :not(.hg) { opacity: 0.55; }
.history-older { margin-top: 12px; }
.history-main { flex: 1; min-width: 0; display: block; }
.history-title { display: block; font-weight: 500; font-size: 13px; line-height: 26px; }
.history-title .who.you { color: var(--primary-600); }
.history-title .who.system, .history-title .who.import { color: var(--transfer); }
.history-sub { display: block; color: var(--muted); font-size: 12px; margin-top: -3px; }
.history-diff {
  margin-top: 9px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 2px; padding: 8px 11px; font-family: var(--mono); font-size: 11.5px;
  display: flex; flex-direction: column; gap: 2px;
}
.diff-add { color: var(--income); }
.diff-del { color: var(--expense); text-decoration: line-through; }
.history-effects {
  list-style: none; margin: 8px 0 0; padding: 0 0 0 10px;
  border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: var(--text-2);
}
.history-effects .who.system { color: var(--transfer); font-weight: 500; }
.history-effect-sub { color: var(--muted); }
.history-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; line-height: 26px; flex: none; }
/* Restore and ⋯ share one 26px row with the title and time. */
.history-actions { display: flex; align-items: center; gap: 6px; flex: none; height: 26px; }
.history-actions .btn-xs { height: 26px; padding-top: 0; padding-bottom: 0; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
/* Several blocks sharing one column, one under the other. */
.setting-stack { grid-column: span 4; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.setting-stack > .setting-block { grid-column: auto; }
.setting-divider { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }
.balance-panel {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
  padding: 12px 12px 10px; margin-bottom: 14px;
}
.balance-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.balance-panel-label { font-size: 12px; color: var(--muted); }
.balance-panel-now { font-family: var(--mono); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.balance-panel > .field-hint:first-of-type { margin: 2px 0 10px; }
.balance-update { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.balance-update .field-unit { min-width: 0; }
.balance-update .field-unit .field { min-width: 0; width: 100%; }
.balance-update input[type="date"].field { width: auto; }
.valuation-history { margin-top: 10px; }
.valuation-history summary { cursor: pointer; font-size: 12.5px; padding: 4px 0; }
.valuation-history .valuation-list { margin: 6px 0 0; }
.valuation-list { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.valuation-list li { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 11px; font-size: 13px; }
.account-danger {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px;
}
.account-danger .field-hint { margin: 0; flex: 1; min-width: 180px; }
.account-modal-foot { justify-content: flex-end; }
.valuation-list li + li { border-top: 1px solid var(--line); }
.valuation-date { color: var(--muted); min-width: 96px; }
.valuation-value { flex: 1; font-family: var(--mono); }
.setting-block {
  grid-column: span 4;
  background: var(--surface);
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.setting-block h2 { margin-bottom: 3px; font-size: 13px; }
.setting-block > .muted { margin-bottom: 14px; font-size: 12.5px; }
.setting-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.setting-head h2 { margin-bottom: 0; }
.setting-head .info-btn { margin-left: 0; }
.account-row {
  display: flex; align-items: center; gap: 11px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.account-row:last-child { border-bottom: none; }
.account-row .account-dot { width: 9px; height: 9px; border-radius: 1px; flex: none; }
.account-row div { flex: 1; }
.account-row p { margin: 0; font-size: 12px; }
.settings-accounts-block { grid-column: 1 / -1; }
.settings-accounts-block > .section-head { margin-top: 0; }
.settings-accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.settings-account-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.settings-account-card:hover { border-color: var(--muted-2); box-shadow: var(--shadow-2); }
/* The last card adds an account, as the last category card adds a category. */
.settings-account-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 72px;
  font: inherit; color: var(--muted); border-style: dashed;
}
.settings-account-add:hover { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); box-shadow: none; }
.settings-account-card-top {
  display: flex; align-items: center; gap: 9px; margin-bottom: 12px;
}
.settings-account-name {
  font-weight: 600; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.settings-account-balance {
  font-size: 19px; font-weight: 600;
  font-family: var(--mono); letter-spacing: -0.02em;
}
.settings-account-balance.neg { color: var(--expense); }
.settings-account-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.account-modal { max-width: 480px; }
.confirm-modal { max-width: 420px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 20px;
}
.modal-foot .spacer { flex: 1; }

.switch-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.switch-label input { display: none; }
.switch {
  width: 34px; height: 18px; border-radius: 2px; background: var(--line-2);
  position: relative; transition: background 0.15s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 1px; background: #fff; transition: transform 0.15s;
}
.switch-label input:checked + .switch { background: var(--primary); }
.switch-label input:checked + .switch::after { transform: translateX(16px); }

/* Phones have no room in the masthead for the balances toggle, so it lives in Settings there. */
.privacy-setting { display: none; }
.field-row label.switch-label { display: flex; font-size: 13px; color: var(--text); margin-bottom: 0; }
@media (max-width: 760px) {
  #privacyToggle { display: none; }
  .privacy-setting { display: block; }
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 34, 0.5);
  display: flex; align-items: flex-start; justify-content: center; padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  /* A pop-up taller than the screen scrolls here; margin: auto centres
     one that fits without cutting off the top of one that doesn't. */
  overflow-y: auto;
}
.modal-backdrop > .modal { margin: auto; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-3); position: relative; padding: 24px 26px 20px;
  animation: pop 0.18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.98) translateY(4px); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-right: 30px; }
.modal-head h3 { font-size: 16px; margin: 0; }
.modal-head p { margin: 2px 0 0; font-size: 12px; }
.modal-head-text { flex: 1; min-width: 0; }
.modal-head .brand-mark.lg { margin: 0; width: 38px; height: 38px; flex: none; }
.recurring-total { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.recurring-total strong { font-size: 18px; font-family: var(--mono); letter-spacing: -0.01em; }
.modal-body { max-height: 60vh; overflow-y: auto; overscroll-behavior: contain; }
/* The page behind an open pop-up stays put while it's scrolled. */
html:has(.modal-backdrop:not([hidden])), html.scroll-locked { overflow: hidden; }
html:has(.modal-backdrop:not([hidden])) .app.shell .content, html.scroll-locked .app.shell .content { overflow: hidden; }
html.scroll-locked, html.scroll-locked body { overscroll-behavior: none; }
.drawer-body, .chat-panel { overscroll-behavior: contain; }
.modal-backdrop { overscroll-behavior: contain; }
.recurring-modal { max-width: 540px; }
.tx-row .tx-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.recurring-row { align-items: center; }

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(15, 23, 34, 0.4); opacity: 0; transition: opacity 0.2s;
}
.drawer-backdrop.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 56;
  width: 380px; max-width: 92vw; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-3);
  transform: translateX(100%);
  transition: transform 0.22s ease; display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-body { padding: 16px 18px; flex: 1; overflow-y: auto; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 80; background: var(--toast-bg); color: var(--toast-fg); border-radius: 3px;
  padding: 10px 16px; font-size: 12.5px; box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: 8px; animation: toast-in 0.2s ease;
}
.toast .icon { color: var(--accent); width: 14px; height: 14px; }
.toast.toast-error .icon { color: var(--danger); }
/* Connection lost, signed out, or changed on another device. */
.conn-banner {
  position: sticky; top: 0; z-index: 90;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; font-size: 13px; text-align: center;
  background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--line);
}
.conn-banner[hidden] { display: none; }
.conn-banner.conn-lost { background: var(--danger-soft); }
.conn-banner .icon { width: 14px; height: 14px; color: var(--danger); flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .overview { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .widget { grid-column: span 12; }
  .widget.span-4, .widget.span-8 { grid-column: span 12; }
  .two-col { grid-template-columns: 1fr; }
  .setting-block, .setting-stack { grid-column: span 6; }
  .settings-accounts-block { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .masthead { padding: 0 10px; }
  .period-trigger { max-width: 170px; }
  .tabnav-item { padding: 0 9px; }
  .content { --content-x: 14px; padding: 16px var(--content-x) 36px; }
  .stats-grid, .stats-grid.three { grid-template-columns: 1fr 1fr; }
  /* An odd card out fills its row rather than leaving a grey gap beside it. */
  .stats-grid > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .category-grid { grid-template-columns: 1fr 1fr; }
  .category-card { min-width: 0; padding: 10px 12px; }
  .category-card .cat-top { margin-bottom: 6px; }
  .category-card .cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .setting-block, .setting-stack { grid-column: 1 / -1; }
  /* The whole pop-up scrolls, rather than a box inside it. */
  .modal-body { max-height: none; overflow: visible; }
  /* The Transactions page drops its Account column; other tx tables keep theirs. */
  #transactionsTable:not(.account-view) th:nth-child(4), #transactionsTable:not(.account-view) td:nth-child(4) { display: none; }
}

.gw { width: 26px; height: 26px; display: block; }

.brand-mark.lg .gw { width: 26px; height: 26px; }

.dash-shell.docked { display: flex; gap: 14px; align-items: flex-start; }
.dash-shell.docked .dash-main { flex: 1; min-width: 0; }

.chat-panel {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.chat-panel.floating {
  position: fixed; top: var(--masthead-h); right: 0; bottom: 0;
  width: 400px; max-width: 100vw; z-index: 45;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  border-radius: 0;
  border-right: none;
}
.chat-panel.floating.open { transform: none; }
.chat-panel.docked {
  position: sticky; top: calc(var(--masthead-h) + 10px);
  width: 380px; max-width: 100%;
  height: calc(100vh - var(--masthead-h) - 20px);
  border-radius: 3px;
  box-shadow: none;
  flex: none;
}

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 13px;
  border-bottom: 1px solid var(--line); flex: none;
}
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 3px;
  background: var(--primary-soft);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.chat-avatar .icon { width: 16px; height: 16px; color: var(--primary); }
.chat-meta { display: flex; flex-direction: column; min-width: 0; }
.chat-meta strong { font-size: 13px; }
.chat-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.chat-status .status-dot { width: 6px; height: 6px; background: var(--accent); }
.chat-actions { display: flex; gap: 5px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 13px;
  display: flex; flex-direction: column; gap: 13px;
  scroll-behavior: smooth;
}

.chat-messages {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chat-messages::-webkit-scrollbar { width: 0; height: 0; display: none; }

.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.user { justify-content: flex-end; }
.msg-avatar {
  width: 25px; height: 25px; border-radius: 3px;
  background: var(--primary-soft); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.msg-avatar .icon { width: 15px; height: 15px; color: var(--primary); }
.msg-content { max-width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.msg.user .msg-content { align-items: flex-end; max-width: 84%; }
.msg.assistant .msg-content { flex: 1; }
.msg-bubble {
  background: var(--surface-3); border-radius: 3px 3px 3px 0;
  padding: 8px 12px; font-size: 13px; color: var(--text);
  max-width: 100%; overflow-wrap: break-word;
}
.msg.user .msg-bubble {
  background: var(--primary-tint); color: var(--primary-600);
  border: 1px solid var(--primary-tint-line);
  border-radius: 3px 3px 0 3px;
  font-weight: 500;
}
.msg-text { font-size: 13px; color: var(--text-2); }

.msg-reason {
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface-2); padding: 7px 11px; font-size: 12px;
}
.msg-reason summary {
  cursor: pointer; font-weight: 500; color: var(--muted);
  user-select: none; list-style: none; display: flex; align-items: center; gap: 6px;
}
.msg-reason summary::-webkit-details-marker { display: none; }
.msg-reason summary::before { content: "›"; font-size: 13px; transition: transform 0.15s; }
.msg-reason[open] summary::before { transform: rotate(90deg); }
.msg-reason .reason-steps { margin-top: 7px; display: flex; flex-direction: column; gap: 5px; }

.chat-panel .widget {
  border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 13px; box-shadow: none; margin: 0;
}
.chat-panel .widget-title { font-size: 12px; }
.chat-panel .widget-head { margin-bottom: 7px; }
.chat-panel .widget-actions { opacity: 1; }
.chat-panel .chart-host svg { max-height: 200px; }

.chat-composer {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 13px; border-top: 1px solid var(--line); flex: none;
}
.chat-composer input {
  flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 3px;
  padding: 9px 11px; font-size: 13px; outline: none; background: var(--surface);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.chat-composer input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.chat-send { width: 38px; height: 38px; padding: 0; border-radius: 3px; flex: none; }
.chat-send .icon { width: 15px; height: 15px; }

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

.glowworm-loader {
  position: relative;
  width: 84px;
  height: 32px;
}
.glowworm {
  width: 100%;
  height: 100%;
  display: block;
}

.glow-worm {
  animation: glow-crawl 0.9s cubic-bezier(0.22, 0.85, 0.35, 1) both;
}

.glow-body {
  animation: glow-rock 0.5s ease-in-out infinite alternate;
  transform-box: view-box;
  transform-origin: 50% 61%;
}

.glow-worm .seg,
.glow-worm .glow-head {
  animation: glow-wriggle 0.42s ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}
.glow-worm .seg-tail { animation-delay: 0s; }
.glow-worm .seg-5 { animation-delay: -0.07s; }
.glow-worm .seg-4 { animation-delay: -0.14s; }
.glow-worm .seg-3 { animation-delay: -0.21s; }
.glow-worm .seg-2 { animation-delay: -0.28s; }
.glow-worm .glow-head { animation-delay: -0.35s; }

@keyframes glow-crawl {
  0%   { transform: translateX(-100px); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes glow-rock {
  from { transform: rotate(-2.2deg); }
  to   { transform: rotate(2.2deg); }
}
@keyframes glow-wriggle {
  from { transform: translateY(-2.4px) scaleY(1.04); }
  to   { transform: translateY(2.4px) scaleY(0.96); }
}

.msg.msg-in { animation: msg-in 0.22s ease-out both; }
.msg.msg-in .widget { animation: msg-in 0.28s ease-out 0.1s both; }
.glowworm-loader.worm-out { animation: worm-out 0.3s ease-in forwards; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
@keyframes worm-out {
  to { opacity: 0; transform: translateY(8px) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .glow-worm,
  .glow-body,
  .glow-worm .seg,
  .glow-worm .glow-head,
  .brand.wiggle .gw-seg,
  .brand.wiggle .gw-head,
  .msg.msg-in,
  .msg.msg-in .widget,
  .glowworm-loader.worm-out {
    animation: none;
  }
}

@media (max-width: 760px) {
  .chat-panel.floating { top: var(--masthead-h); width: 100vw; border-radius: 0; }
  .dash-shell.docked { flex-direction: column; }
  .chat-panel.docked { position: static; width: 100%; height: auto; max-height: 72vh; }
}

.chat-actions .icon-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
.badge-needsreview { background: var(--bill-soft); color: var(--bill); }
.badge-stale { background: var(--surface-3); color: var(--muted); }
.history-group { background: var(--surface); }
.history-group > summary {
  cursor: pointer; list-style: none; display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; user-select: none;
}
.history-group > summary::-webkit-details-marker { display: none; }
.history-group > summary::before {
  content: "›"; flex: none; width: 10px; line-height: 26px; color: var(--muted);
  transition: transform 0.15s;
}
.history-group[open] > summary::before { transform: rotate(90deg); }
.history-group > .history-item { border-top: 1px solid var(--line); background: var(--surface-2); }
.history-undone > summary { color: var(--muted); }
.history-undone > summary .history-title { color: var(--muted); }
/* History rail. Every change in effect sits on one line, newest at the top
   with "Now" on what is current; undone changes hang off it on a dashed
   branch from the point they were undone at. */
.history-list { --hg-w: 56px; --hg-main: 21px; --hg-lane: 39px; }
.hg-row, .hg-block > summary { position: relative; }
.history-list .hg-row, .history-list .hg-block > summary { padding-left: var(--hg-w); }
.hg { position: absolute; z-index: 2; left: 0; top: 0; bottom: 0; width: var(--hg-w); pointer-events: none; }
.hg::before {
  content: ""; position: absolute; left: var(--hg-main); width: 2px; top: -1px; bottom: -1px;
  background: var(--line-2);
}
.hg-no-up > .hg::before, .hg-no-up > summary > .hg::before { top: 25px; }
.hg-row.hg-no-down > .hg::before,
.hg-block.hg-no-down:not([open]) > summary > .hg::before,
.hg-block.hg-no-down[open] > .hg-row:last-child > .hg::before { bottom: auto; height: 26px; }
.hg-row.hg-no-up.hg-no-down > .hg::before,
.hg-block.hg-no-up.hg-no-down:not([open]) > summary > .hg::before { display: none; }
.hg-node {
  position: absolute; left: calc(var(--hg-main) - 4px); top: 20px; width: 10px; height: 10px;
  box-sizing: border-box; border: 2px solid var(--primary); border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 3px var(--surface);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.hg-node.system, .hg-node.import { background: var(--transfer); border-color: var(--transfer); }
.hg-child .hg-node { left: calc(var(--hg-main) - 2px); top: 22px; width: 6px; height: 6px; border-width: 0; box-shadow: 0 0 0 3px var(--surface-2); }
.is-head > .hg .hg-node, .is-head > summary > .hg .hg-node,
.pv-head > .hg .hg-node, .pv-head > summary > .hg .hg-node {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--primary-tint-line);
}
.is-head > .history-time::before, .is-head > summary > .history-time::before,
.pv-head > .history-time::before, .pv-head > summary > .history-time::before {
  content: "Now"; display: inline-block; margin-right: 8px; padding: 0 6px; line-height: 17px;
  border: 1px solid var(--primary-tint-line); border-radius: 2px;
  background: var(--primary-soft); color: var(--primary-600);
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 1px;
}
.history-list.is-previewing .is-head:not(.pv-head) > .history-time::before,
.history-list.is-previewing .is-head:not(.pv-head) > summary > .history-time::before { content: none; }
.history-list.is-previewing .is-head:not(.pv-head) > .hg .hg-node,
.history-list.is-previewing .is-head:not(.pv-head) > summary > .hg .hg-node { box-shadow: 0 0 0 3px var(--surface); }

/* The branch: hollow nodes off to the side of the line. */
.hg-undone { position: relative; --lane: var(--line-2); }
.hg-undone:not(.hg-through) .hg::before { display: none; }
.hg-undone::before {
  content: ""; position: absolute; z-index: 1; left: var(--hg-lane); top: 25px; bottom: 12px;
  border-left: 2px solid var(--lane); pointer-events: none;
}
.hg-undone::after {
  content: ""; position: absolute; z-index: 1; left: var(--hg-main); bottom: -1px;
  width: calc(var(--hg-lane) - var(--hg-main) + 2px); height: 14px; box-sizing: border-box;
  border-right: 2px solid var(--lane); border-bottom: 2px solid var(--lane);
  border-bottom-right-radius: 12px; pointer-events: none;
}
.hg-undone.hg-no-down::before, .hg-undone.hg-no-down::after { display: none; }
.hg-undone .hg-node { left: calc(var(--hg-lane) - 4px); background: var(--surface); border-color: var(--muted-2); }
.hg-undone .hg-child .hg-node { left: calc(var(--hg-lane) - 3px); top: 21px; width: 8px; height: 8px; border-width: 2px; }

.history-actions .btn-xs { gap: 5px; }
.history-actions .btn .icon { width: 13px; height: 13px; }
/* Undo and Rewind show on the row being pointed at; what's current and
   what's undone keep theirs in view. */
@media (hover: hover) {
  .hg-row { --row-bg: var(--surface); }
  .hg-child { --row-bg: var(--surface-2); }
  .hg-row:not(.is-head):not(.pv-source) > .history-actions {
    position: absolute; top: 12px; right: 14px; padding-left: 16px;
    background: linear-gradient(to right, transparent, var(--row-bg) 14px);
    opacity: 0; transition: opacity 0.12s;
  }
  .hg-row:hover > .history-actions, .hg-row:focus-within > .history-actions,
  .hg-row.pv-source > .history-actions { opacity: 1; }
}

/* Preview: before an action runs, the rows it touches take on how they'll
   look after it. */
.history-list .history-item, .history-group > summary { transition: background 0.15s; }
.history-list .history-main, .history-list .history-time { transition: opacity 0.15s; }
.pv-undo > .history-main, .pv-undo > .history-time,
.pv-undo > summary > .history-main, .pv-undo > summary > .history-time { opacity: 0.45; }
.pv-undo > .history-main > .history-title, .pv-undo > summary .history-title { text-decoration: line-through; text-decoration-color: var(--muted-2); }
.pv-undo > .hg .hg-node, .pv-undo > summary > .hg .hg-node { background: var(--surface); border: 2px solid var(--muted-2); }
.pv-undo.hg-child > .hg .hg-node { width: 8px; height: 8px; left: calc(var(--hg-main) - 3px); top: 21px; border-width: 1.5px; }
.hg-undone.pv-redo { --lane: var(--primary); }
.hg-undone.pv-redo > summary, .hg-undone.pv-redo > .history-item { background: var(--primary-soft); }
.hg-undone.pv-redo > .history-item.inactive > * { opacity: 1; }
.hg-undone.pv-redo .history-title { color: var(--text); }
.hg-undone.pv-redo .hg-node { background: var(--primary); border-color: var(--primary); }
.hg-undone.pv-delete { --lane: var(--danger); }
.hg-undone.pv-delete > summary, .hg-undone.pv-delete > .history-item { background: var(--danger-soft); }
.hg-undone.pv-delete .history-title { color: var(--danger); text-decoration: line-through; }
.hg-undone.pv-delete .hg-node { border-color: var(--danger); }
.pv-source { box-shadow: inset 0 0 0 1px var(--primary); }
/* While a preview is up, only the action being confirmed keeps its buttons. */
.history-list.is-previewing .hg-row:not(.pv-source) > .history-actions,
.history-list.is-previewing summary:not(.pv-source) > .history-actions { visibility: hidden; }
.hg-undone.pv-delete > summary.pv-source { box-shadow: inset 0 0 0 1px var(--danger); }

.history-confirm {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 70; width: min(560px, calc(100% - 32px)); box-sizing: border-box;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 4px; box-shadow: var(--shadow-2);
  padding: 10px 12px 10px 14px; animation: toast-in 0.2s ease;
}
.history-confirm[hidden] { display: none; }
.history-confirm-icon { color: var(--primary); }
.history-confirm.danger .history-confirm-icon { color: var(--danger); }
.history-confirm-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.history-confirm-text strong { font-size: 13px; font-weight: 600; }
.history-confirm-text span { font-size: 12px; color: var(--muted); }
.history-confirm-text span:empty { display: none; }
#view-history.is-confirming { padding-bottom: 76px; }
.progress-bar { position: relative; width: 100%; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); transition: width 150ms linear; }

.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 11px; font-weight: 600;
  margin-left: 6px; cursor: pointer; line-height: 1;
}
.info-btn:hover { color: var(--text); border-color: var(--text); }
/* The note an (i) opens: a speech bubble floating by the button, pointing at
   it. app.js moves it to <body> and places it; --arrow-x is where the tail sits. */
.info-popover {
  position: fixed; z-index: 1000; top: 0; left: 0;
  width: max-content; max-width: min(320px, calc(100vw - 32px));
  padding: 10px 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); border-radius: 6px;
  box-shadow: var(--shadow-2); font-size: 12.5px; line-height: 1.45;
  --arrow-x: 16px;
}
.info-popover.wide { max-width: min(420px, calc(100vw - 32px)); }
.info-popover::before {
  content: ""; position: absolute; left: var(--arrow-x); top: -6px;
  width: 10px; height: 10px; margin-left: -5px;
  background: inherit; border: 1px solid var(--line);
  border-right: 0; border-bottom: 0; transform: rotate(45deg);
}
.info-popover.above::before { top: auto; bottom: -6px; transform: rotate(225deg); }
.info-popover p { margin: 0 0 6px; font-size: 12.5px; }
.info-popover p:last-child { margin-bottom: 0; }
.info-popover .muted { color: var(--text-2); }
.info-popover code { font-family: ui-monospace, monospace; background: var(--line); padding: 1px 4px; border-radius: 3px; }
.date-format-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: 1fr; gap: 4px; }
.date-format-list button { font-family: ui-monospace, monospace; background: none; border: 1px dashed var(--line); border-radius: 3px; padding: 2px 6px; cursor: pointer; margin-right: 6px; }
.date-format-list button:hover { border-color: var(--primary); color: var(--primary); }
.date-read { display: grid; gap: 8px; margin-top: 8px; }
.date-preview { font-size: 13px; min-height: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-self: start; }
.date-raw { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 3px; padding: 2px 6px; color: var(--text); }
.date-arrow { color: var(--muted); font-size: 16px; line-height: 1; transform: translateY(-2px); }
.date-preview-ok { color: var(--primary); }
.date-preview-fail { color: var(--expense); }

.ai-progress { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px; }
.ai-progress-head { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ai-progress-steps { list-style: none; padding: 0; margin: 10px 0 6px; display: flex; flex-direction: column; gap: 4px; }
.ai-progress-steps li { color: var(--muted); font-size: 13px; padding-left: 18px; position: relative; }
.ai-progress-steps li::before { content: "·"; position: absolute; left: 6px; }
.ai-progress-steps li.active { color: var(--text); font-weight: 500; }
.ai-progress-steps li.active::before { content: "▸"; color: var(--primary); }
/* 100vh on iOS is the height with the toolbars hidden, taller than the
   screen while they show, so the page would scroll; dvh is what's visible.
   These pages are one card that fits: no rubber-band bounce either. */
.login-shell { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
html:has(.login-shell), html:has(.login-shell) body { overscroll-behavior: none; }
/* On a phone the card sits near the top, clear of the keyboard that comes
   up for the password, rather than in the middle where it would cover it. */
@media (max-width: 760px) {
  .login-shell { align-items: flex-start; padding-top: calc(max(20px, 18dvh) + env(safe-area-inset-top)); }
}
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 26px 26px 22px; box-shadow: var(--shadow-2); }
.login-card .brand { justify-content: center; display: flex; margin-bottom: 6px; }
.login-card h1 { text-align: center; font-size: 16px; margin: 8px 0 16px; }
.login-card .field { width: 100%; margin-bottom: 10px; }
.login-error { color: var(--expense); font-size: 12.5px; margin: 0 0 10px; }
.login-card h1.login-title { margin-bottom: 6px; }
.login-sub { text-align: center; font-size: 12.5px; margin: 0 0 16px; }
/* Signing in with a passkey, and the Passkeys settings. */
.login-passkey { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 10px; }
.login-passkey[hidden] { display: none; }
.login-or { font-size: 12px; }
.login-passkey .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.login-passkey .icon { width: 15px; height: 15px; }
.setting-block.is-unavailable { opacity: 0.45; }
.setting-block.is-unavailable * { cursor: default; }
.passkey-intro { margin: 0 0 12px; }
.passkey-list { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--line); }
.passkey-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.passkey-item > div { display: flex; flex-direction: column; min-width: 0; }
.passkey-item .muted { font-size: 12px; }
.offline-status { text-align: center; font-size: 11.5px; margin: 10px 0 0; min-height: 1.4em; }
.tx-editor .tx-field select.field { min-width: 200px; }

.msg-error { color: var(--danger); font-weight: 500; }
.queries-sidebar.collapsed ~ .queries-main .queries-messages { padding-top: 46px; }
.overview-chart .chart-host { height: 240px; }
.queries-messages .chart-host { height: 260px; }
.msg-error .msg-text, .msg-text.msg-error { color: var(--danger); }
#timelineChart { height: 240px; }

.queries-messages .widget-body { flex: none; min-height: 0; overflow: visible; }
.queries-messages .widget .chart-host { flex: none; min-height: 260px; height: 260px; }
.queries-messages .widget .chart-host svg { max-height: 360px; }
.queries-messages .widget .table-widget { flex: none; min-height: 0; overflow: auto; max-height: 360px; }

.msg-text { white-space: pre-wrap; overflow-wrap: break-word; }


.history-loading {
  align-self: center;
  font-size: 11px; color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
}

#view-import.import-active .import-idle { display: none; }
.schema-card .schema-account {
  flex: none; font-size: 11.5px; font-weight: 500; color: var(--text-2);
  background: var(--surface-3); border-radius: var(--r-xs); padding: 2px 7px;
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-review-banner {
  border: 1px solid var(--line); border-left: 3px solid var(--transfer);
  background: var(--transfer-soft); border-radius: var(--r);
  padding: 9px 12px; margin: 0 0 12px; font-size: 12.5px; color: var(--text-2);
}
.ai-review-banner strong { color: var(--text); }
.map-fields { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); margin: 6px 0 14px; }
.map-field { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; padding: 13px 14px; }
.map-field + .map-field { border-top: 1px solid var(--line); }
.map-field.mapping-changed { background: var(--transfer-soft); }
/* An unset optional column reads as a placeholder, not a choice. */
.map-field select:has(> option[value=""]:checked) { color: var(--muted-2); }
.map-field select option { color: var(--text); }
.map-field-label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.map-field-label .muted { font-size: 12px; }
.map-field-label .badge { align-self: flex-start; }
.map-field-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.map-field-body > .field.select, .map-amount-col > .field.select, .map-sub .field { max-width: 360px; }
.map-amount-col > .field.select { width: 100%; }
.map-sub { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 8px; }
.map-sub[hidden] { display: none; }
.map-sub-label { font-size: 12.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.map-radios { display: flex; flex-direction: column; gap: 6px; }
.map-radio { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.map-radio input { margin-top: 3px; accent-color: var(--primary); }
.map-radio > span { display: flex; flex-direction: column; }
.map-radio .muted { font-size: 12px; }
.map-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.map-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-family: var(--mono); }
.map-amount-preview ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: max-content max-content max-content; align-items: center; gap: 6px 8px; font-size: 13px; }
.map-amount-preview li { display: contents; }
.map-amount-preview .date-raw { justify-self: end; }
.map-fx-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-family: var(--mono); margin-bottom: 6px; }
.map-fx-row .field { width: 130px; }
.map-orig summary { cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.map-orig > p { font-size: 12px; margin: 6px 0; }
.map-orig .map-sub { margin-top: 6px; }
@media (max-width: 760px) {
  .map-field, .map-sub { grid-template-columns: 1fr; gap: 6px; }
}
#mappingRows .badge { margin-left: 8px; }

.import-review { padding: 16px 18px; }
.import-review-head { margin-bottom: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.review-schema-badge { flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-review-head .category-form-title { margin-bottom: 8px; font-size: 16px; }
.review-into { min-width: 0; }
.review-file { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The account an import goes into: one large button per account. */
.account-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.account-pick-option {
  display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 3px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.account-pick-option:hover { background: var(--surface-2); }
.account-pick-option[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.account-pick-dot { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.account-pick.busy .account-pick-option:not([aria-checked="true"]) { opacity: 0.5; cursor: wait; }
.import-review-head p { margin: 0; font-size: 12.5px; }
.cat-pipeline {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
}
.cat-pipeline li {
  display: flex; align-items: flex-start; gap: 10px; min-width: 0;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); font-size: 13px;
  transition: background 0.14s, border-color 0.14s;
}
.cat-pipeline li > div { min-width: 0; }
.cat-pipeline li strong { display: block; font-weight: 600; }
.cat-pipeline .step-note { display: block; color: var(--muted); font-size: 12px; }
.cat-pipeline li[data-state="active"] { border-color: var(--primary-tint-line); background: var(--primary-soft); }
.cat-pipeline li[data-state="done"] .step-num { background: var(--primary); color: var(--on-primary); }
.cat-pipeline li[data-state="skipped"] { opacity: 0.7; }
.cat-pipeline li[data-state="failed"] .step-num { background: var(--danger-soft); color: var(--danger); }
.import-review .progress-bar { margin-top: 10px; }

.review-cols {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px; margin-top: 16px; align-items: start;
}
.review-col { min-width: 0; }
.review-col-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 0 2px 7px; margin-bottom: 8px; border-bottom: 2px solid var(--line);
}
.review-col-todo .review-col-head { border-bottom-color: var(--bill); }
.review-col-done .review-col-head { border-bottom-color: var(--primary); }
.review-col-head h4 { margin: 0; font-size: 13px; font-weight: 600; }
.review-col-head .count { color: var(--muted); font-size: 12px; }
.review-col-head .btn { margin-left: auto; align-self: center; }
.review-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 62vh; overflow-y: auto; padding-right: 2px;
}
.review-empty {
  color: var(--muted); font-size: 12.5px; text-align: center;
  padding: 18px 12px; border: 1px dashed var(--line-2); border-radius: var(--r);
}
.review-group {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  padding: 9px 11px;
}
.review-group[data-state="pending"] { background: var(--surface-2); }
.review-col-todo .review-group[data-state="review"] { border-left: 3px solid var(--bill); }
.review-group-main { min-width: 0; }
.review-group-desc { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 500; font-size: 13px; }
.review-group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-group-desc .badge { flex: none; }
.review-search {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: var(--r);
  color: var(--muted); transition: color 0.12s, background 0.12s;
}
.review-search:hover, .review-search:focus-visible { color: var(--primary); background: var(--surface-2); }
.review-search .icon { width: 14px; height: 14px; }
@media (pointer: coarse) { .review-search { width: 32px; height: 32px; margin: -4px 0; } }
.review-group-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-group-cat { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-group-cat .field.select { flex: 1 1 170px; min-width: 0; max-width: 260px; }
.review-checking, .review-note { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.review-checking .spinner { width: 11px; height: 11px; }
.review-suggest {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--transfer);
  background: var(--transfer-soft); border: 1px dashed var(--transfer);
  border-radius: var(--r); padding: 4px 8px;
}
.review-suggest:hover { border-style: solid; }
.review-suggest .icon { width: 12px; height: 12px; }
.review-group-rows { grid-column: 1 / -1; font-size: 12px; }
.review-group-rows summary { cursor: pointer; color: var(--muted); width: max-content; }
.review-group-rows table { width: 100%; margin-top: 4px; border-collapse: collapse; }
.review-group-rows td { padding: 3px 0; border-top: 1px solid var(--line); color: var(--text-2); }
.review-group-rows td.num { text-align: right; }
.review-dups {
  margin: 0 0 14px; font-size: 13px;
  background: var(--bill-soft); border: 1px solid var(--bill); border-left-width: 4px; border-radius: var(--r);
}
.review-dups summary {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  cursor: pointer; list-style: none; color: var(--text);
}
.review-dups summary::-webkit-details-marker { display: none; }
.review-dups summary > .icon { flex: none; width: 18px; height: 18px; color: var(--bill); margin-top: 1px; }
.review-dups summary > span { flex: 1; }
.review-dups summary strong { color: var(--bill); }
.review-dups-sub { display: block; color: var(--text-2); margin-top: 2px; }
.review-dups .review-dups-chev { transition: transform .15s; }
.review-dups[open] .review-dups-chev { transform: rotate(180deg); }
.review-dups .tx-table { margin: 0 12px 10px; width: calc(100% - 24px); background: var(--surface); }
.review-footer {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.review-footer .field-row { margin: 0; min-width: 200px; }
.review-footer .review-schema-name { min-width: 240px; }
.review-footer .spacer { flex: 1; }
/* On wide screens the review fills the viewport exactly and only the two
   transaction lists scroll. */
@media (min-width: 901px) {
  .content:has(#view-import.import-reviewing) { padding-bottom: 20px; }
  #view-import.import-reviewing.active {
    display: flex; flex-direction: column;
    height: calc(var(--app-h) - var(--masthead-h) - 40px);
  }
  #view-import.import-reviewing #importFlow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  #view-import.import-reviewing .import-review { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  #view-import.import-reviewing .review-cols { flex: 1; min-height: 0; align-items: stretch; }
  #view-import.import-reviewing .review-col { display: flex; flex-direction: column; min-height: 0; }
  #view-import.import-reviewing .review-list { flex: 1; min-height: 0; max-height: none; }
  #view-import.import-reviewing .review-dups > div { max-height: 25vh; overflow-y: auto; }
}
@media (max-width: 900px) {
  .review-cols, .cat-pipeline { grid-template-columns: 1fr; }
  .review-list { max-height: none; }
}

.deleted-accounts { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.deleted-accounts h3 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.deleted-accounts > .muted { margin: 0 0 10px; font-size: 12px; }
.deleted-accounts-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.deleted-accounts-list li {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2);
}
.deleted-account-main { flex: 1; min-width: 180px; }
.deleted-account-main .settings-account-name { color: var(--text-2); }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { border-color: var(--danger); }
.setting-block code {
  font-family: var(--mono); font-size: 11.5px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: var(--r-xs); padding: 1px 5px;
}

/* ---- Phones: the page tabs move to a bar of icons with short labels
   under the masthead (iOS Safari's toolbar makes a bottom bar hard to tap),
   page titles go, tables drop columns they can't fit, and rows stack.
   --masthead-h covers both rows so sticky and full-height layouts clear them. ---- */
:root { --tabbar-h: 58px; --masthead-row: 56px; }
@media (max-width: 760px) {
  :root { --masthead-h: calc(var(--masthead-row) + var(--tabbar-h)); }
  /* The tabs wrap onto a second row of the sticky masthead rather than being
     fixed, so both move together when iOS rubber-bands the page. */
  .masthead { height: var(--masthead-h); flex-wrap: wrap; align-content: flex-start; }
  .masthead > :not(.tabnav) { height: var(--masthead-row); display: flex; align-items: center; }
  .tabnav {
    order: 1; flex: 0 0 calc(100% + 20px); margin: 0 -10px;
    height: var(--tabbar-h);
    border-top: 1px solid var(--line);
    gap: 0; overflow: visible;
  }
  .masthead .tabnav-item {
    flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 3px;
    padding: 0 2px; border-top: 0; border-bottom: 2px solid transparent;
    font-size: 9.5px; font-weight: 500; letter-spacing: -0.01em;
  }
  .masthead .tabnav-item.active { border-bottom-color: var(--primary); color: var(--primary); }
  .masthead .tabnav-item .tab-index { display: none; }
  .masthead .tabnav-item .tab-icon { display: block; width: 19px; height: 19px; }
  .masthead .tabnav-item.tabnav-icon { flex: none; padding: 0 8px; }
  .masthead .tabnav-item.tabnav-icon .icon { width: 19px; height: 19px; }
  .masthead .tabnav-item .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .masthead .period-wrap { margin-left: auto; }
  .content { padding-top: 12px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .content:has(#view-queries.active) { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .app.shell .content:has(#view-queries.active) { overflow: hidden; }
  #view-queries.active { min-height: 0; }
  /* With the keyboard up it covers the home indicator's strip. */
  html.kb-fit .content:has(#view-queries.active) { padding-bottom: 8px; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }

  /* The filters right below say the same; the heading keeps its button. */
  #accountsTxSub { display: none; }

  /* Account cards: one compact row (name and balance), scrolling sideways
     when there are more than fit. */
  .accounts-grid {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(108px, 1fr);
    gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none;
  }
  .accounts-grid .account-card { padding: 8px 10px; min-width: 0; }
  .accounts-grid .account-card-top { margin-bottom: 4px; gap: 7px; }
  .accounts-grid .account-card-top .badge, .accounts-grid .account-sub { display: none; }
  .accounts-grid .account-balance { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Transactions: category moves under the description. */
  .tx-table th, .tx-table td { padding: 8px 9px; }
  /* Date and category move under the description. */
  #transactionsTable .cell-cat, #transactionsTable th:nth-child(3),
  #transactionsTable th:nth-child(1), #transactionsTable tbody td.cell-sub:first-child { display: none; }
  #transactionsTable .cell-cat-inline { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
  .tx-table td.cell-sub { font-size: 11px; white-space: nowrap; }
  .tx-table td.tx-amount { white-space: nowrap; }
  .tx-table .row-actions { padding-left: 0; }

  /* History: title on its own line, time and buttons beneath. */
  .history-item, .history-group > summary { flex-wrap: wrap; row-gap: 4px; }
  .history-item > .history-main { flex: 1 1 100%; }
  /* Keep a group's chevron (10px + 12px gap) on the title's line. */
  .history-group > summary > .history-main { flex: 1 1 calc(100% - 22px); }
  .history-group > summary > .history-time { margin-left: 22px; }
  .history-item > .history-actions, .history-group > summary > .history-actions { margin-left: auto; }
  .history-list { --hg-w: 42px; --hg-main: 13px; --hg-lane: 29px; }
  .history-diff { font-size: 11px; }

  .tx-editor { flex-direction: column; align-items: stretch; }
  .tx-field, .tx-field.grow { min-width: 0; }
  .tx-field .field, .tx-editor .tx-field select.field { min-width: 0; width: 100%; }
  /* Phone date pickers keep an intrinsic width that ignores width: 100%. */
  input[type="date"].field { -webkit-appearance: none; appearance: none; display: block; max-width: 100%; box-sizing: border-box; }
  input[type="date"].field::-webkit-date-and-time-value { text-align: left; }
  .tx-editor-actions { margin-left: 0; justify-content: flex-end; }
  .tx-editor-row td { padding: 0 8px 10px !important; }
  .modal-foot { flex-wrap: wrap; }
  .account-modal-foot { flex-wrap: nowrap; }
  .account-modal-foot .btn { flex: 1; justify-content: center; }
  .balance-update { grid-template-columns: 1fr auto; }
  .balance-update .field-unit { grid-column: 1 / -1; }
  .balance-update .btn { justify-content: center; }
  .balance-update input[type="date"].field { width: 100%; }
}
/* Touch screens can't hover, so controls that appear on hover stay visible. */
@media (hover: none) {
  .tx-table .row-actions, .widget-actions { opacity: 1; }
}

/* iOS zooms into any focused text field under 16px; keep phones at 16px. */
@media (max-width: 760px) and (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}

/* Grouping rules in the query window */
.rules-empty { color: var(--muted); font-size: 13px; margin: 4px 0; }
.rules-table td, .rules-table th { padding: 7px 10px; }
.rules-table .row-actions { width: 1%; white-space: nowrap; text-align: right; }
.rule-draft-head { font-size: 13px; margin: 0 0 8px; }
.change-rows { max-height: 320px; overflow-y: auto; }
.change-skip td { opacity: .55; }
.rule-draft-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.valuation-compare { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; margin-bottom: 4px; }
.valuation-compare .icon { width: 14px; height: 14px; color: var(--muted); }

@media (max-width: 760px) {
  .import-review-head { flex-direction: column-reverse; gap: 4px; }
  .review-file { max-width: 100%; }
  .account-pick-option { flex: 1 1 auto; justify-content: center; }
}
