@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/InterVariable.2bf3d951bf9d.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../vendor/ibm-plex-mono/IBMPlexMono-Regular.b51685c998a0.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../vendor/ibm-plex-mono/IBMPlexMono-Medium.91abacd323ba.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../vendor/ibm-plex-mono/IBMPlexMono-SemiBold.7d69bd02da7b.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page-background: #151515;
  --charcoal: #0f1419;
  --charcoal-soft: #121920;
  --sidebar: #0f0f0f;
  --surface: #182027;
  --surface-raised: #1d262e;
  --surface-hover: #222d36;
  --line: #303a43;
  --line-soft: #252f37;
  --stone: #e8ecef;
  --text: #dce3e8;
  --muted: #a4afb7;
  --quiet: #84919b;
  --blue: #7ec8f8;
  --blue-strong: #a7dbfc;
  --blue-wash: #183447;
  --copper: #ff985a;
  --copper-wash: #44291f;
  --positive: #83d7ad;
  --danger: #ff8a8a;
  --danger-wash: #3b2024;
  --focus: #9bd8ff;
  --sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-family: var(--sans);
  color: var(--text);
  background: var(--page-background);
  line-height: 1.5;
}

* { box-sizing: border-box; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html { min-width: 320px; background: var(--page-background); }
body { margin: 0; min-height: 100svh; background: var(--page-background); }
button, input, select { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-underline-offset: .22em; text-decoration-thickness: 1px; }
a:hover { color: var(--blue-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { color: var(--charcoal); background: var(--blue); }

.icon { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; stroke-width: 1.8; }
.skip-link { position: fixed; z-index: 100; top: -5rem; left: 1rem; padding: .7rem 1rem; color: var(--charcoal); background: var(--stone); border-radius: 0; }
.skip-link:focus { top: .75rem; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: .7rem; min-height: 44px; color: var(--stone); text-decoration: none; }
.brand:hover { color: var(--stone); }
.brand-mark { display: inline-flex; width: 2.8rem; height: 2.3rem; }
.brand-mark svg { width: 100%; height: 100%; overflow: visible; }
.brand-mark .crumb { fill: #78a9c4; }
.brand-mark .crumb-1 { fill: var(--copper); }
.brand-mark .crumb-2 { fill: #b8d9ea; }
.brand-mark .crumb-3 { fill: #a8d4eb; }
.brand-mark .crumb-4 { fill: #94c9e5; }
.brand-mark .crumb-5 { fill: #82bad7; }
.brand-mark .crumb-6 { fill: #72a4bf; }
.brand-mark .crumb-7 { fill: #668da3; }
.brand-copy { display: grid; gap: .08rem; }
.brand-name { font: 500 1.05rem/1.1 var(--mono); letter-spacing: .055em; }
.brand-tagline { color: var(--muted); font: 400 .68rem/1.2 var(--mono); letter-spacing: .11em; }

/* Responsive application shell */
.app-shell { min-height: 100svh; }
.app-sidebar { display: none; }
.mobile-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; min-height: 52px; padding: .25rem .85rem; border-bottom: 1px solid var(--line-soft); background: var(--charcoal); }
.mobile-header .brand-mark { width: 2.15rem; height: 1.75rem; }
.app-main { width: 100%; max-width: 94rem; min-width: 0; margin-inline: auto; padding: 1.5rem 1rem 7.75rem; }
.mobile-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); min-height: 72px; padding: .35rem max(.35rem, env(safe-area-inset-right)) max(.35rem, env(safe-area-inset-bottom)) max(.35rem, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: #0d1318; box-shadow: 0 -12px 30px #0007; }
.mobile-nav > a, .mobile-more > summary { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .22rem; min-width: 0; min-height: 58px; padding: .2rem; border-radius: 0; color: var(--muted); font: 500 .65rem/1.1 var(--mono); text-decoration: none; list-style: none; }
.mobile-nav > a[aria-current="page"] { color: var(--blue); }
.mobile-nav .icon { width: 1.3rem; height: 1.3rem; }
.mobile-nav-add .icon { width: 1.8rem; height: 1.8rem; padding: .3rem; border-radius: 0; color: var(--charcoal); background: var(--copper); }
.mobile-more { position: relative; }
.mobile-more > summary { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mobile-more > summary::-webkit-details-marker { display: none; }
.mobile-more[open] > summary { color: var(--blue); }
.mobile-more-menu { position: fixed; right: 1rem; bottom: calc(5rem + env(safe-area-inset-bottom)); display: grid; width: min(15rem, calc(100vw - 2rem)); padding: .55rem; border: 1px solid var(--line); border-radius: 0; background: var(--surface-raised); box-shadow: 0 18px 50px #000b; }
.mobile-more-menu a, .mobile-more-menu button { display: flex; align-items: center; gap: .65rem; min-height: 44px; width: 100%; padding: .6rem .7rem; border: 0; border-radius: 0; color: var(--text); background: transparent; text-decoration: none; cursor: pointer; }
.mobile-more-menu a:hover, .mobile-more-menu button:hover { background: var(--surface-hover); }
.mobile-more-menu form { margin: 0; }

/* Type */
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--stone); font-family: var(--mono); font-weight: 500; }
h1 { margin-bottom: .55rem; font-size: clamp(1.9rem, 5vw, 2.7rem); line-height: 1.12; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { margin-bottom: .45rem; font-size: 1.1rem; line-height: 1.3; letter-spacing: -.015em; }
h3 { font-size: .95rem; }
p { margin-bottom: 1rem; }
.eyebrow { margin-bottom: .55rem; color: var(--blue); font: 500 .68rem/1.3 var(--mono); letter-spacing: .115em; text-transform: uppercase; }
.lede { max-width: 44rem; color: var(--muted); font-size: 1rem; }
.muted, .form-note { color: var(--muted); }
.form-note { margin: 1rem 0 0; font-size: .82rem; }
.copper-rule { display: block; width: 2rem; height: 3px; margin-top: 1.2rem; background: var(--copper); }

/* Shared components */
.page-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.page-heading { margin-bottom: 1.35rem; }
.page-heading > div { min-width: 0; }
.page-heading h1, .section-heading h2 { margin-bottom: 0; }
.panel { min-width: 0; padding: 1.15rem; border: 1px solid var(--line-soft); border-radius: 0; background: linear-gradient(145deg, var(--surface-raised), var(--surface)); box-shadow: 0 12px 30px #0002; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: .2rem .55rem; border: 1px solid #315b72; border-radius: 0; color: var(--blue-strong); background: var(--blue-wash); font: 500 .72rem/1 var(--mono); white-space: nowrap; }
.badge-muted { color: var(--muted); border-color: var(--line); background: transparent; }
.button-primary, .button-quiet { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .62rem .9rem; border-radius: 0; font-weight: 700; text-decoration: none; cursor: pointer; }
.button-primary { width: 100%; border: 1px solid #8ed1fa; color: var(--charcoal); background: var(--blue); }
.button-primary:hover { color: var(--charcoal); background: var(--blue-strong); }
.button-quiet { border: 1px solid var(--line); color: var(--text); background: #141c22; }
.button-quiet:hover { color: var(--stone); border-color: #495762; background: var(--surface-hover); }
.button-inline { width: auto; }
.button-danger { color: #190809; border-color: var(--danger); background: var(--danger); }
.button-danger:hover { color: #190809; background: #ffa1a1; }
.danger-link { color: var(--danger); }
.heading-actions, .form-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.heading-actions { margin-top: 0; }
.form-actions { align-items: center; margin-top: 1.35rem; }
.form-actions .button-primary { flex: 1; }
.back-link { display: inline-flex; align-items: center; min-height: 40px; margin-bottom: .7rem; color: var(--muted); font-family: var(--mono); font-size: .82rem; }
.messages { padding: .85rem 1rem; margin-bottom: 1rem; border: 1px solid #315b72; border-radius: 0; color: var(--blue-strong); background: var(--blue-wash); }
.messages p:last-child { margin-bottom: 0; }
.error-panel { max-width: 44rem; margin-inline: auto; }
.empty-state { max-width: 42rem; }

/* Forms */
.form-layout { width: 100%; max-width: 39rem; margin-inline: auto; }
.field { min-width: 0; margin-block: 1.1rem; }
label { display: block; margin-bottom: .4rem; color: var(--text); font: 500 .78rem/1.35 var(--mono); }
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select { width: 100%; max-width: 100%; min-width: 0; min-height: 46px; padding: .66rem .75rem; border: 1px solid #46535e; border-radius: 0; color: var(--stone); background: #11181e; font-size: .95rem; }
input::placeholder { color: var(--quiet); }
input:hover, select:hover { border-color: #61717e; }
input:focus, select:focus { border-color: var(--blue); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"] { width: 1.1rem; min-height: 1.1rem; height: 1.1rem; flex-shrink: 0; accent-color: var(--blue); }
input[type="radio"] { width: 1.1rem; min-height: 1.1rem; height: 1.1rem; flex-shrink: 0; accent-color: var(--blue); }
.field-help { margin: .45rem 0 0; color: var(--muted); font-size: .79rem; }
.form-errors, .field-errors { color: #ffb0b0; font-size: .84rem; }
.form-errors { padding: .75rem; margin-top: 1rem; border-left: 3px solid var(--danger); background: var(--danger-wash); }
.errorlist { margin: 0; padding: 0; list-style: none; }
div.tag-choice-tree, .filter-grid .field > div[id^="id_"] { max-height: 13rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 0; background: #11181e; }
div.tag-choice-tree { max-height: 15.5rem; padding: .3rem; }
div.tag-choice-tree label, .filter-grid .field > div[id^="id_"] label { display: flex; align-items: center; gap: .65rem; min-height: 40px; margin: 0; padding: .35rem .45rem; font-family: var(--sans); font-size: .86rem; }
div.tag-choice-tree label:hover, .filter-grid .field > div[id^="id_"] label:hover { background: var(--surface-hover); }
div.tag-choice-tree label:has(input[data-tag-indent="0"]) { font-weight: 650; background-color: var(--surface); }
div.tag-choice-tree label:has(input[data-tag-indent="1"]) { padding-left: 1.15rem; background-image: linear-gradient(var(--blue), var(--blue)); background-position: .45rem 0; background-size: 2px 100%; background-repeat: no-repeat; }
div.tag-choice-tree label:has(input[data-tag-indent="2"]) { padding-left: 2.4rem; background-image: linear-gradient(var(--blue), var(--blue)), linear-gradient(var(--copper), var(--copper)); background-position: .45rem 0, 1.7rem 0; background-size: 2px 100%; background-repeat: no-repeat; }
div.tag-choice-tree label:has(input[data-tag-indent="3"]) { padding-left: 3.65rem; background-image: linear-gradient(var(--blue), var(--blue)), linear-gradient(var(--copper), var(--copper)), linear-gradient(var(--positive), var(--positive)); background-position: .45rem 0, 1.7rem 0, 2.95rem 0; background-size: 2px 100%; background-repeat: no-repeat; }
.choice-filter-controls { margin-bottom: .45rem; }
.choice-filter-controls[hidden] { display: none; }
.choice-filter-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.choice-filter-bar .button-quiet { min-height: 46px; border-left: 0; }
.choice-filter-bar .button-quiet:disabled { color: var(--quiet); cursor: default; opacity: .65; }
.choice-filter-status { min-height: 1.25rem; margin: .35rem 0 0; color: var(--muted); font: 500 .72rem/1.4 var(--mono); }
.description-autocomplete-control { position: relative; }
.description-suggestions { position: absolute; z-index: 10; top: calc(100% - 1px); right: 0; left: 0; max-height: 16rem; overflow-y: auto; padding: .3rem; border: 1px solid #46535e; background: #11181e; box-shadow: 0 16px 30px #0008; }
.description-suggestions[hidden] { display: none; }
.description-suggestion { display: block; width: 100%; min-height: 42px; padding: .55rem .65rem; border: 0; color: var(--text); background: transparent; text-align: left; cursor: pointer; }
.description-suggestion:hover, .description-suggestion[aria-selected="true"] { color: var(--stone); background: var(--surface-hover); }
.conversion-field { padding-top: 1rem; border-top: 1px solid var(--line); }
.conversion-field ul { margin: 0; padding: 0; list-style: none; }
.conversion-field li label { display: flex; align-items: center; gap: .65rem; min-height: 42px; font-family: var(--sans); }
.comparison-panel { padding: .9rem 1rem; margin-top: 1rem; border-left: 3px solid var(--blue); background: var(--blue-wash); }
.comparison-panel p:last-child { margin-bottom: 0; }
.rate-calculation { overflow-wrap: anywhere; }
.transfer-form textarea { width: 100%; max-width: 100%; }

/* Home and login */
.home-heading { padding: clamp(1rem, 4vw, 2rem) 0 1.5rem; margin-bottom: 1rem; }
.home-heading-row { min-width: 0; }
.home-heading-row .lede { margin-bottom: 0; }
.home-heading-add { display: none; }
.setup-grid { display: grid; gap: .85rem; margin-bottom: .85rem; }
.setup-grid .panel { position: relative; overflow: hidden; }
.setup-grid .panel::before { position: absolute; inset: 0 auto 0 0; width: 2px; content: ""; background: var(--blue); }
.home-section-heading { align-items: center; margin: 1.5rem 0 .7rem; }
.home-section-heading .eyebrow { margin-bottom: .25rem; }
.home-section-heading h2 a { color: inherit; font-size: inherit; text-decoration: none; }
.home-section-heading h2 a:hover { color: var(--blue); text-decoration: underline; }
.home-summary { margin-top: 0; }
.home-recent-list { margin-bottom: 1.5rem; }
.summary-link { display: block; color: inherit; text-decoration: none; }
.summary-link > span { display: block; }
.summary-link:hover { border-color: #495762; }
.dashboard-grid { display: grid; align-items: start; gap: .85rem; margin-block: .85rem; }
.dashboard-panel { padding: 0; overflow: hidden; }
.dashboard-panel-heading { align-items: center; padding: 1rem 1rem .8rem; }
.dashboard-panel-heading .eyebrow { margin-bottom: .25rem; }
.dashboard-panel-heading a { font-size: .8rem; text-decoration: none; }
.dashboard-panel-heading a:hover { text-decoration: underline; }
.dashboard-note, .dashboard-empty { margin: 0; padding: 0 1rem 1rem; color: var(--muted); font-size: .78rem; }
.dashboard-table { table-layout: fixed; }
.dashboard-table th:first-child { width: 34%; }
.dashboard-table th:last-child { width: 28%; }
.dashboard-table tbody th { color: var(--text); font-weight: 600; }
.dashboard-table tbody th span { display: block; margin-top: .2rem; color: var(--muted); font-size: .7rem; font-weight: 400; }
.dashboard-table tbody a { color: inherit; text-decoration: none; }
.dashboard-table tbody a:hover { color: var(--blue); text-decoration: underline; }
.dashboard-table td:last-child { text-align: right; font-family: var(--mono); white-space: nowrap; }
.dashboard-table progress { display: block; width: 100%; height: .55rem; border: 0; background: var(--line); color: var(--blue); }
.dashboard-table progress::-webkit-progress-bar { background: var(--line); }
.dashboard-table progress::-webkit-progress-value { background: var(--blue); }
.dashboard-table progress::-moz-progress-bar { background: var(--blue); }
.trend-panel { margin-block: .85rem 1.5rem; }
.trend-context { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; padding: 0 1rem 1rem; }
.trend-context .dashboard-note { padding: 0; }
.trend-period-mobile { display: none; }
.trend-legend { display: flex; flex-wrap: wrap; gap: .8rem; margin: 0; padding: 0; list-style: none; color: var(--muted); font: 500 .72rem/1.4 var(--mono); }
.trend-legend li { display: flex; align-items: center; gap: .35rem; }
.trend-legend li::before { width: .9rem; height: 2px; content: ""; background: var(--blue); }
.trend-legend .is-expense::before { background: var(--copper); }
.trend-chart { padding: 0 1rem 1rem; overflow: hidden; }
.trend-chart-mobile { display: none; }
.trend-chart svg { display: block; width: 100%; height: auto; }
.trend-grid-line { stroke: var(--line); stroke-width: 1; }
.trend-tick-label, .trend-month-label { fill: var(--muted); font: 500 12px var(--mono); }
.trend-area { fill: #ff985a1a; }
.trend-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.trend-expense-line, .trend-expense-point { stroke: var(--copper); }
.trend-income-line, .trend-income-point { stroke: var(--blue); }
.trend-point { fill: var(--surface); stroke-width: 3; }
.trend-data { border-top: 1px solid var(--line-soft); }
.trend-data > summary { min-height: 44px; padding: .75rem 1rem; color: var(--blue); font: 500 .78rem/1.4 var(--mono); cursor: pointer; }
.trend-data[open] > summary { border-bottom: 1px solid var(--line-soft); }
.trend-data .money-cell { text-align: right; font-family: var(--mono); white-space: nowrap; }
.trend-data .money-cell.is-positive { color: var(--positive); }
.trend-data .money-cell.is-negative { color: var(--copper); }
.welcome-panel { display: flex; gap: 1rem; align-items: flex-start; max-width: 48rem; }
.welcome-panel p:last-child { margin-bottom: 0; }
.welcome-symbol { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid #315b72; border-radius: 0; color: var(--blue); background: var(--blue-wash); }
.login-layout { display: grid; place-items: center; min-height: calc(100svh - 4rem); }
.login-panel { width: min(100%, 28rem); padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px solid #343434; background: #1c1c1c; }
.login-panel form { display: grid; }
.login-panel .button-primary { justify-content: center; width: 100%; margin-top: .35rem; }
.login-brand { flex-direction: column; justify-content: center; gap: .8rem; width: 100%; margin-bottom: 2.25rem; text-align: center; }
.login-brand .brand-mark { width: 5.4rem; height: 4.4rem; }
.login-brand .brand-copy { justify-items: center; gap: .45rem; }
.login-brand .brand-name { font-size: 1.95rem; letter-spacing: .08em; }
.login-brand .brand-tagline { font-size: .72rem; line-height: 1.35; letter-spacing: .1em; }
.login-setup { text-align: center; }
.login-setup h1 { margin-bottom: .7rem; font-size: 1.35rem; }
.login-setup code { display: block; padding: .8rem; border: 1px solid var(--line); color: var(--blue-strong); background: #111; font: 500 .78rem/1.5 var(--mono); overflow-wrap: anywhere; user-select: all; }

/* Records and ledger */
.record-list { display: grid; gap: .65rem; margin: 0; padding: 0; list-style: none; }
.record { display: flex; align-items: center; flex-wrap: wrap; gap: .85rem; }
.record-symbol { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid #315b72; border-radius: 0; color: var(--blue); background: var(--blue-wash); }
.record-symbol .icon { width: 1.2rem; height: 1.2rem; }
.record-main { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.record h2, .record p { margin-bottom: .3rem; }
.record-link { display: inline-flex; align-items: center; min-height: 38px; max-width: 100%; color: var(--stone); text-decoration: none; overflow-wrap: anywhere; }
.record-link:hover, .record-link:focus-visible { color: var(--stone); text-decoration: underline; }
.ledger-record { position: relative; }
.ledger-summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .35rem 1rem; }
.ledger-summary h2 { min-width: 0; }
.ledger-amount { margin: 0; color: var(--copper); font: 500 1.05rem/1.3 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ledger-record.is-income .ledger-amount { color: var(--positive); }
.transaction-detail.is-income .ledger-amount { color: var(--positive); }
.ledger-meta { margin-bottom: .7rem; color: var(--muted); font-size: .85rem; }
.ledger-conversion { margin: -.1rem 0 .65rem; color: var(--muted); font: 400 .75rem/1.35 var(--mono); }
.ledger-table-head { display: none; }
.tag-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.tag-chips li { max-width: 100%; }
.tag-chips a { display: inline-flex; align-items: center; min-height: 28px; padding: .2rem .45rem; border: 1px solid transparent; border-radius: 0; color: #b4bec5; background: #222b32; font-size: .74rem; text-decoration: none; overflow-wrap: anywhere; }
.tag-chips a:hover { color: var(--stone); border-color: #53616c; background: var(--surface-hover); }
.ledger-facts { display: grid; grid-template-columns: minmax(7rem, auto) minmax(0, 1fr); gap: .7rem 1rem; }
.ledger-facts dt { color: var(--muted); font: 500 .76rem/1.4 var(--mono); }
.ledger-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .8rem; margin-block: 1.25rem; color: var(--muted); font: 400 .78rem/1.4 var(--mono); }
.account-value-summary { margin-bottom: 1.25rem; }
.account-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.account-groups { display: grid; gap: 1.5rem; }
.account-group .section-heading { margin-bottom: .7rem; }
.account-list-item { border: 1px solid var(--line-soft); background: var(--surface); }
.account-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1.25rem; min-height: 68px; padding: .75rem 1rem; color: var(--text); text-decoration: none; }
.account-row:hover { color: var(--stone); background: var(--surface-hover); }
.account-row-main { min-width: 0; flex: 1; }
.account-row h2, .account-row p { margin-bottom: .2rem; }
.inactive-accounts { padding-top: 1.25rem; margin-top: 1.5rem; border-top: 1px solid var(--line); }
.inactive-accounts .section-heading { margin-bottom: .7rem; }
.account-balance { display: grid; gap: .15rem; min-width: min(100%, 12rem); font-size: .78rem; text-align: right; }
.account-balance strong { color: var(--stone); font: 500 1rem/1.35 var(--mono); font-variant-numeric: tabular-nums; }
.account-balance span { color: var(--muted); }
.account-detail-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.account-status-form { margin: 0; }
.reconciliation-panel { margin-block: 1rem; border-left: 2px solid var(--copper); }
.reconciliation-overview { margin-bottom: 1rem; border-left: 2px solid var(--copper); scroll-margin-top: 1rem; }
.reconciliation-overview .child-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.reconciliation-overview .child-list li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem 1rem; padding-bottom: .45rem; border-bottom: 1px solid var(--line-soft); }
.reconciliation-overview .child-list li:last-child { padding-bottom: 0; border-bottom: 0; }
.account-history th span { display: block; margin-top: .2rem; color: var(--muted); font-size: .72rem; font-weight: 400; text-transform: capitalize; }
.transfer-preview { margin-bottom: 1rem; }
.transfer-preview > summary { display: flex; align-items: center; gap: .55rem; color: var(--stone); font: 500 .82rem/1.4 var(--mono); cursor: pointer; }
.transfer-preview[open] > summary { margin-bottom: .75rem; }
.transfer-preview-list { display: grid; gap: .6rem; margin: 0 0 .8rem; padding: 0; list-style: none; }
.transfer-preview-list li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem 1rem; border-bottom: 1px solid var(--line-soft); padding-bottom: .5rem; }
.transfer-preview-list span { color: var(--muted); font-size: .78rem; }

@media (max-width: 559px) {
  .transaction-add { display: none; }
  .tag-detail-group .tag-row .tag-path, .tag-detail-group .tag-child-action span { display: none; }
  .tag-detail-group .tag-child-action { padding-inline: .7rem; }
  .dashboard-breakdown-scroll { overflow: visible; }
  .dashboard-breakdown-table { display: block; }
  .dashboard-breakdown-table tbody { display: grid; grid-template-columns: minmax(0, 1fr) minmax(3.5rem, .65fr) max-content; column-gap: .55rem; padding-inline: .5rem; }
  .dashboard-breakdown-table thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .dashboard-breakdown-table tr { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: center; border-bottom: 1px solid var(--line); }
  .dashboard-breakdown-table th:first-child, .dashboard-breakdown-table th:last-child { width: auto; }
  .dashboard-breakdown-table th, .dashboard-breakdown-table td { min-width: 0; padding: .7rem .25rem; border: 0; }
  .trend-period-full, .trend-chart-desktop { display: none; }
  .trend-period-mobile, .trend-chart-mobile { display: block; }
  .trend-context { display: grid; justify-content: initial; }
  .trend-chart { padding-inline: .5rem; }
  .trend-data .table-scroll { overflow: visible; }
  .trend-data .dashboard-table, .trend-data .dashboard-table tbody { display: block; }
  .trend-data .dashboard-table thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .trend-data .dashboard-table tr { display: block; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
  .trend-data .dashboard-table th, .trend-data .dashboard-table td { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; width: auto; padding: .22rem 0; border: 0; }
  .trend-data .dashboard-table th { padding-bottom: .45rem; }
  .trend-data .dashboard-table td.money-cell { text-align: left; }
  .trend-data .money-cell::before { color: var(--muted); content: attr(data-label); font: 500 .68rem/1.5 var(--mono); text-align: left; text-transform: uppercase; letter-spacing: .05em; }
  .trend-data .money-cell a { text-align: right; }
  .summary-grid.account-detail-summary { grid-template-columns: 1fr; }
  .account-balance { width: 100%; text-align: left; }
}

/* Tags, rates, and filtering */
.tag-tree { margin: 1.25rem 0 0; padding: 0; list-style: none; }
.tag-tree-item { --tag-content-x: .45rem; border-right: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); }
.tag-tree-item.tree-depth-0 { border-top: 1px solid var(--line-soft); }
.tag-tree-item.tree-depth-0:not(:first-child) { margin-top: .3rem; }
.tag-tree-item:has(+ .tree-depth-0), .tag-tree-item:last-child { border-bottom: 1px solid var(--line-soft); }
.tag-tree-item.tree-depth-1 { --tag-content-x: 1.3rem; }
.tag-tree-item.tree-depth-2 { --tag-content-x: 2.55rem; }
.tag-tree-item.tree-depth-3 { --tag-content-x: 3.8rem; }
.tag-row { position: relative; display: flex; align-items: stretch; min-height: 58px; padding-left: var(--tag-content-x); color: var(--text); background-color: var(--surface); }
.tag-row-link { display: flex; flex: 1; align-items: center; gap: .7rem; min-width: 0; padding: .7rem .9rem .7rem 0; color: inherit; text-decoration: none; }
.tag-tree-item.tree-depth-0 .tag-row { min-height: 67.5px; background-color: var(--surface-raised); }
.tag-tree-item.tree-depth-1 .tag-row { background-image: linear-gradient(var(--blue), var(--blue)); background-position: .45rem 0; background-size: 2px 100%; background-repeat: no-repeat; }
.tag-tree-item.tree-depth-2 .tag-row { background-image: linear-gradient(var(--blue), var(--blue)), linear-gradient(var(--copper), var(--copper)); background-position: .45rem 0, 1.7rem 0; background-size: 2px 100%; background-repeat: no-repeat; }
.tag-tree-item.tree-depth-3 .tag-row { background-image: linear-gradient(var(--blue), var(--blue)), linear-gradient(var(--copper), var(--copper)), linear-gradient(var(--positive), var(--positive)); background-position: .45rem 0, 1.7rem 0, 2.95rem 0; background-size: 2px 100%; background-repeat: no-repeat; }
.tag-row:hover { color: var(--stone); background-color: var(--surface-hover); }
.tag-name-line { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .55rem; }
.tag-current-indicator { color: var(--copper); font: 500 .64rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.tag-child-action { display: flex; flex: none; align-items: center; gap: .35rem; padding: .65rem .75rem; border-left: 1px solid var(--line-soft); color: var(--muted); font: 500 .72rem/1.2 var(--mono); text-decoration: none; }
.tag-child-action:hover { color: var(--blue-strong); background-color: var(--blue-wash); }
.tag-child-action .icon { width: 1rem; height: 1rem; }
.tag-path { display: block; overflow-wrap: anywhere; }
.tag-row .tag-path { margin-top: .15rem; font-size: .78rem; }
.tag-detail-grid { display: grid; gap: 1rem; align-items: start; }
.tag-detail-group .tag-tree { margin-top: 0; }
.tag-detail-facts .ledger-facts { margin-top: 1.25rem; }
.detail-footer { margin-top: 1.25rem; }
.rate-list { display: grid; gap: .8rem; }
.rate-card .eyebrow { margin-bottom: .3rem; }
.rate-value { margin: .85rem 0 .2rem; color: var(--stone); font: 500 1.05rem/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.rate-history { padding-top: .9rem; margin-top: 1rem; border-top: 1px solid var(--line); }
.rate-history summary, .filter-panel > summary, .advanced-filters > summary { display: flex; align-items: center; gap: .55rem; min-height: 42px; color: var(--stone); font: 500 .82rem/1.4 var(--mono); cursor: pointer; }
.rate-history-list { padding-left: 1.25rem; }
.rate-history-list li { margin-block: .7rem; }
.panel.filter-panel { padding: 0; margin-bottom: 1rem; overflow: hidden; }
.filter-panel > summary { justify-content: space-between; padding: .75rem 1rem; }
.filter-panel[open] > summary { margin-bottom: 0; border-bottom: 1px solid var(--line-soft); }
.filter-panel > form { padding: .2rem 1rem 1rem; }
.filter-summary-label { display: inline-flex; align-items: center; gap: .55rem; }
.filter-status { padding: .2rem .45rem; border-radius: 0; color: var(--blue-strong); background: var(--blue-wash); font: 500 .66rem/1.2 var(--mono); white-space: nowrap; }
.filter-grid { display: grid; gap: 0 .9rem; }
.advanced-filters { padding-top: .5rem; margin-top: .5rem; border-top: 1px solid var(--line); }
.advanced-filters[open] > summary { margin-bottom: .35rem; }

/* Settings */
.settings-grid { display: grid; gap: .85rem; }
.settings-card { display: flex; align-items: flex-start; gap: 1rem; }
.settings-card > div { min-width: 0; flex: 1; }
.settings-card p { color: var(--muted); }
.settings-user-list { display: grid; gap: .4rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.settings-user-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 38px; padding-bottom: .35rem; border-bottom: 1px solid var(--line-soft); }

/* Analytics */
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-block: 1rem; }
.summary-grid .panel { position: relative; padding: .85rem; overflow: hidden; }
.summary-grid .panel::after { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; content: ""; background: var(--line); }
.summary-grid .summary-expense::after { background: var(--copper); }
.summary-grid .summary-income::after { background: var(--positive); }
.summary-grid .summary-net::after { background: var(--blue); }
.summary-grid .eyebrow { margin-bottom: .3rem; color: var(--muted); }
.summary-grid .panel > .eyebrow, .summary-grid .panel > .summary-value, .summary-grid .panel > small { display: block; }
.summary-value { margin: 0; color: var(--stone); font: 500 clamp(.95rem, 4vw, 1.35rem)/1.25 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.panel.analytics-controls { position: relative; display: block; min-height: 46px; padding: 46px 0 0; margin-block: 1rem; overflow: hidden; }
.analytics-control { display: block; height: 0; }
.analytics-control[open] { height: auto; }
.analytics-control > summary { position: absolute; z-index: 2; top: 0; display: flex; align-items: center; justify-content: center; min-height: 46px; color: var(--muted); cursor: pointer; list-style: none; user-select: none; }
.analytics-control > summary::-webkit-details-marker { display: none; }
.analytics-control > summary:hover, .analytics-control[open] > summary { color: var(--blue); background: var(--blue-wash); }
.analytics-control-refine > summary { right: 46px; left: 0; justify-content: flex-start; padding: .7rem 1rem; color: var(--stone); font: 500 .82rem/1.4 var(--mono); }
.analytics-controls:has(.analytics-control-save) .analytics-control-refine > summary { right: 92px; }
.analytics-control-status { position: absolute; z-index: 3; top: 23px; right: 50px; transform: translateY(-50%); border: 1px solid #805235; color: var(--copper); background: var(--copper-wash); pointer-events: none; }
.analytics-control-status.is-dirty { border-color: var(--copper); color: #ffd1b5; background: #583021; }
.analytics-controls:has(.analytics-control-save) .analytics-control-status { right: 96px; }
.analytics-control-saved > summary { right: 0; }
.analytics-controls:has(.analytics-control-save) .analytics-control-saved > summary { right: 46px; }
.analytics-control-save > summary { right: 0; }
.analytics-control-icon { width: 46px; border-left: 1px solid var(--line-soft); }
.analytics-control-content { width: 100%; min-width: 0; padding: 1.25rem 1rem 1rem; border-top: 1px solid var(--line-soft); background: #151d23; }
.analytics-control-content h2 { margin-bottom: .25rem; }
.refine-view-content { background: var(--surface); }
.control-content-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.control-content-heading .eyebrow { margin-bottom: .2rem; }
.save-view-content > form { max-width: 38rem; }
.save-view-content .field { margin-top: .75rem; }
.saved-view-quick-list { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.saved-view-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; border: 1px solid var(--line); background: var(--surface); }
.saved-view-name { display: flex; grid-column: 1; grid-row: 1; align-items: center; min-height: 46px; padding: .6rem .75rem; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.saved-view-name:hover, .saved-view-name[aria-current="page"] { color: var(--blue); background: var(--blue-wash); }
.saved-view-action-toggle { display: flex; align-items: center; justify-content: center; width: 46px; min-height: 46px; padding: 0; border: 0; border-left: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; user-select: none; }
.saved-view-action-toggle:hover { color: var(--blue); background: var(--blue-wash); }
.saved-view-action-toggle.danger-link:hover { color: var(--danger); background: var(--danger-wash); }
.saved-view-popover { width: min(30rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 1rem; overflow-y: auto; border: 1px solid var(--line); color: var(--text); background: var(--surface-raised); box-shadow: 0 18px 55px #000a; }
.saved-view-popover::backdrop { background: #0009; }
.saved-view-popover h3 { margin-bottom: .75rem; }
.saved-view-popover form { margin-top: .85rem; }
.analytics-table-panel { margin-top: 1rem; }
.saved-view-context { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--line-soft); background: #151d23; }
.saved-view-context h2, .saved-view-context p { margin-bottom: .25rem; }
.filter-detail-list { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0 0; padding: 0; list-style: none; }
.filter-detail-list li { padding: .28rem .5rem; border: 1px solid var(--line); color: var(--muted); background: #141c22; font-size: .76rem; }
.analytics-results { padding-top: .25rem; scroll-margin-top: 4rem; }
.analytics-results-heading { align-items: end; margin: 1.35rem 0 .7rem; }
.matching-transactions { margin-top: 1.35rem; scroll-margin-top: 1rem; }
.matching-transactions-heading { margin-bottom: .7rem; }

@media (max-width: 559px) {
  .analytics-control-refine > summary { padding-inline: .8rem; }
  .analytics-control-status { max-width: 8.5rem; overflow: hidden; text-overflow: ellipsis; }
  .analytics-control-content { padding: 1.1rem .85rem .85rem; }
}

.merge-layout { max-width: 48rem; }
.merge-layout > .panel + .panel, .merge-stale { margin-top: 1rem; }
.merge-preview h3 { margin-top: 1.25rem; font-size: 1rem; }
.merge-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-block: 1rem; background: var(--line); }
.merge-counts div { padding: .8rem; background: var(--surface); }
.merge-counts dt { color: var(--muted); font-size: .78rem; }
.merge-counts dd { margin: .25rem 0 0; color: var(--stone); font: 500 1.25rem/1.2 var(--mono); }
.merge-change-list { margin: .5rem 0 1rem; padding-left: 1.25rem; }
.merge-change-list li { margin-block: .45rem; }
.table-scroll { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
th, td { padding: .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { color: var(--muted); font: 500 .7rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .05em; }

/* Guest shell */
.guest-shell { min-height: 100svh; background: var(--page-background); }
.guest-main { width: 100%; padding: 2rem; }

@media (min-width: 560px) {
  .app-main { padding-inline: 1.5rem; }
  .setup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 760px) {
  .app-main { padding: 2.25rem 2rem 7.75rem; }
  .panel { padding: 1.3rem; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .app-shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
  .app-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100svh; padding: 1.6rem 1rem 1rem; border-right: 1px solid var(--line-soft); background: linear-gradient(180deg, var(--sidebar), #131313); }
  .sidebar-brand { align-self: flex-start; margin: 0 .55rem 2.5rem; }
  .sidebar-brand .brand-mark { width: 3.1rem; height: 2.55rem; }
  .main-nav { display: grid; gap: .3rem; }
  .main-nav a { position: relative; display: flex; align-items: center; gap: .75rem; min-height: 44px; padding: .55rem .7rem; border-radius: 0; color: #aeb8c0; text-decoration: none; }
  .main-nav a:hover { color: var(--stone); background: var(--surface); }
  .main-nav a[aria-current="page"] { color: var(--blue); background: #202a32; }
  .main-nav a[aria-current="page"]::before { position: absolute; top: .45rem; bottom: .45rem; left: -.72rem; width: 2px; content: ""; background: var(--blue); }
  .sidebar-user { display: grid; gap: .15rem; margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--line-soft); }
  .sidebar-user > *, .sidebar-user a, .sidebar-user button { display: flex; align-items: center; gap: .65rem; min-height: 40px; width: 100%; padding: .45rem .6rem; border: 0; border-radius: 0; color: var(--muted); background: transparent; font-size: .8rem; text-decoration: none; }
  .sidebar-user a:hover, .sidebar-user button:hover { color: var(--stone); background: var(--surface); }
  .sidebar-user a[aria-current="page"] { color: var(--blue); background: #202a32; }
  .sidebar-user form { margin: 0; padding: 0; }
  .sidebar-user button { cursor: pointer; }
  .sidebar-user > .sidebar-build { display: flex; gap: .4rem; min-height: 0; margin-top: .25rem; padding: .25rem .6rem 0; color: var(--quiet); font: 400 .62rem/1.4 var(--mono); }
  .sidebar-user > .sidebar-build a { min-height: 0; width: auto; padding: 0; color: var(--muted); font-size: inherit; text-decoration: underline; }
  .user-label { color: var(--text); }
  .mobile-header, .mobile-nav { display: none; }
  .app-main { grid-column: 2; padding: 3rem clamp(2rem, 5vw, 5.25rem); }
  .home-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; }
  .home-heading-add { display: inline-flex; flex: 0 0 auto; margin-top: .1rem; }
  .page-heading { align-items: center; }
  .rate-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
  .tag-detail-grid { grid-template-columns: minmax(0, 1.35fr) minmax(18rem, .65fr); }
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ledger-table-head { display: grid; grid-template-columns: minmax(13rem, 1.45fr) minmax(12rem, 1fr) minmax(11rem, 1fr) minmax(9rem, auto); gap: 1rem; padding: 0 .9rem .45rem; color: var(--quiet); font: 500 .68rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .05em; }
  .ledger-table-head span:last-child { text-align: right; }
  .ledger-record { display: grid; grid-template-columns: minmax(13rem, 1.45fr) minmax(12rem, 1fr) minmax(11rem, 1fr) minmax(9rem, auto); gap: .9rem 1rem; align-items: center; padding: .55rem .9rem; border-radius: 0; box-shadow: none; }
  .ledger-summary { display: contents; }
  .ledger-summary h2 { grid-column: 1; margin: 0; font-family: var(--sans); font-size: .9rem; font-weight: 600; }
  .ledger-summary .record-link { min-height: auto; }
  .ledger-summary .ledger-amount { grid-column: 4; grid-row: 1; text-align: right; white-space: nowrap; }
  .ledger-meta { grid-column: 2; grid-row: 1; margin: 0; }
  .ledger-record .tag-chips, .ledger-record > .muted:last-child { grid-column: 3; grid-row: 1; }
  .ledger-record .ledger-conversion { grid-column: 4; grid-row: 2; margin: -.55rem 0 0; text-align: right; }
  .record-list { gap: 2px; }
}

@media (min-width: 1250px) {
  .app-shell { grid-template-columns: 16rem minmax(0, 1fr); }
  .filter-grid.filter-grid-wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  a, button, input, select, .panel { transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, transform 140ms ease; }
  .button-primary:hover { transform: translateY(-1px); }
}

.saved-dashboard-panel { padding: 0; }
.saved-dashboard-content { padding: 0 1rem 1rem; }
.saved-dashboard-panel .dashboard-panel-heading h2 a { color: inherit; font-size: inherit; }
.saved-dashboard-content .summary-value { margin-bottom: .5rem; }

@media (max-width: 959px) {
  .form-layout.mobile-entry-focus { padding-bottom: 50svh; }
}
