:root {
  color-scheme: light;
  /* Typography, ledger-statement pairing: a serif display face for headings,
     a technical sans for body/UI, a mono face for figures that need to line
     up in columns. Shared across both themes. */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Surfaces & text (light theme, default) -- cool paper, ink text */
  --bg-page: #f4f5f7;
  --bg-card: #ffffff;
  --bg-hover: #eff1f4;
  --bg-subtle: #fbfbfc;
  --text: #1b2430;
  --text-muted: #667085;
  --border: #e3e6ea;
  --border-soft: #edeff2;
  --shadow: 0 1px 2px rgba(27,36,48,0.04), 0 2px 8px rgba(27,36,48,0.05);
  --shadow-md: 0 4px 12px rgba(27,36,48,0.08), 0 2px 6px rgba(27,36,48,0.06);

  /* Accent palette, matched to the fund-holdings report: deep teal primary,
     amber/plum/indigo/terracotta for asset-class distinctions. */
  --blue: #0f6f63;
  --blue-dark: #0b584e;
  --green: #2f7d52;
  --green-bg: #e7f2eb;
  --red: #b5533c;
  --red-bg: #f5e5e1;
  --amber: #c08a2e;
  --amber-bg: #f6ecda;
  --violet: #6d5a8c;
  --violet-bg: #ede8f2;
  --purple: #8b5a83;
  --purple-bg: #f1e7ef;
  --sky: #4f7fa0;
  --sky-bg: #e5edf2;
  --navy: #3d5a80;
  --navy-bg: #e7ecf3;
  --teal: #0891b2;
  --teal-bg: #e1f2f6;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #14181d;
  --bg-card: #1b2027;
  --bg-hover: #232a33;
  --bg-subtle: #20262e;
  --text: #eceef1;
  --text-muted: #9aa4b2;
  --border: #2c333c;
  --border-soft: #262c34;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 2px 10px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 18px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.4);

  --blue: #4fb8a6;
  --blue-dark: #3d9a8a;
  --green: #7fb06a;
  --green-bg: rgba(127,176,106,0.15);
  --red: #d98a72;
  --red-bg: rgba(217,138,114,0.15);
  --amber: #d9a648;
  --amber-bg: rgba(217,166,72,0.15);
  --violet: #a78bc4;
  --violet-bg: rgba(167,139,196,0.15);
  --purple: #c08fb8;
  --purple-bg: rgba(192,143,184,0.15);
  --sky: #6fa0c7;
  --sky-bg: rgba(111,160,199,0.15);
  --navy: #7c9bc4;
  --navy-bg: rgba(124,155,196,0.15);
  --teal: #45aec7;
  --teal-bg: rgba(69,174,199,0.15);
}

* { box-sizing: border-box; }
body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text);
  margin: 0;
}

.app-shell { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg-page); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 6;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; box-shadow: 0 2px 6px rgba(15,111,99,0.45); flex-shrink: 0;
}
.greeting-title { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; }
.greeting-sub { font-size: 0.85rem; margin-top: 2px; }
.topbar-date { font-size: 0.88rem; background: var(--bg-subtle); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); }

.topnav {
  display: flex; gap: 4px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0 24px; overflow-x: auto;
}
.topnav a {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  color: var(--text-muted); text-decoration: none; font-size: 0.88rem; font-weight: 600;
  padding: 13px 14px; border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.topnav a:hover { color: var(--text); background: var(--bg-hover); }
.topnav a.active { color: var(--blue-dark); border-bottom-color: var(--blue); }

/* App-wide standard for a page that slices one category by sub-type (e.g.
   Taxable vs IRA within Public Markets) -- each tab shows exactly one
   pure-category, pure-type table, never a blended one. */
.tabs {
  display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab-btn {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: none; border: none; color: var(--text-muted); font-family: inherit;
  font-size: 0.92rem; font-weight: 600; cursor: pointer;
  padding: 11px 16px; border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue-dark); border-bottom-color: var(--blue); }
.tab-btn .tab-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: inherit; opacity: 0.75; font-weight: 500; font-size: 0.85rem; }
.tab-panel[hidden] { display: none; }

.main-col { flex: 1; min-width: 0; }

main { max-width: 1140px; margin: 0 auto; padding: 28px 32px 60px; }
.flash { max-width: 1140px; margin: 16px auto 0; padding: 0 32px; }
.flash div { background: var(--green-bg); border: 1px solid var(--green); color: var(--green); padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 0.9rem; }

h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; letter-spacing: -0.01em; }
h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; letter-spacing: -0.01em; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.hero-value .label { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.hero-value .asof { text-transform: none; letter-spacing: 0; margin-left: 6px; font-weight: 400; }
.big { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 2.7rem; font-weight: 600; margin: 6px 0; letter-spacing: -0.01em; }
.change { font-size: 1.05rem; font-weight: 600; }
.up { color: var(--green); }
.down { color: var(--red); }
.muted { color: var(--text-muted); }

.btn {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; border: none; padding: 11px 20px;
  border-radius: 9px; font-size: 0.92rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 6px rgba(15,111,99,0.35);
}
.btn:hover { filter: brightness(1.08); }
.btn.danger { background: linear-gradient(135deg, #c9634a, var(--red)); margin-top: 24px; box-shadow: 0 2px 6px rgba(181,83,60,0.3); }
.btn.danger:hover { filter: brightness(1.08); }

.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; font-weight: 600; color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-hover); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 999px;
  font-size: 1rem; color: var(--text); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); }

.scroll-top-btn {
  position: fixed; right: 28px; bottom: 28px; width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 700;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; border: none;
  box-shadow: var(--shadow-md); cursor: pointer; z-index: 20;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.scroll-top-btn.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-top-btn:hover { filter: brightness(1.08); }

.cards { display: flex; gap: 16px; margin: 24px 0; flex-wrap: wrap; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 18px;
  flex: 1; min-width: 200px; box-shadow: var(--shadow); border-top: 3px solid transparent;
  transition: box-shadow .15s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
a.card {
  display: block; text-decoration: none; color: inherit; cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease;
}
a.card:hover { transform: translateY(-2px); }
.card-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.card-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.35rem; font-weight: 600; margin-top: 6px; }
.card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.icon-badge {
  width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; margin-bottom: 10px;
}
.icon-cash { background: var(--sky-bg); color: var(--sky); }
.icon-invest { background: var(--violet-bg); color: var(--violet); }
.icon-retire { background: var(--purple-bg); color: var(--purple); }
.icon-realestate { background: var(--amber-bg); color: var(--amber); }
.icon-liability { background: var(--red-bg); color: var(--red); }
.icon-goal { background: var(--green-bg); color: var(--green); }
.icon-cashflow { background: var(--sky-bg); color: var(--blue); }
.icon-annuity { background: var(--teal-bg); color: var(--teal); }

.card.accent-cash { border-top-color: var(--sky); }
.card.accent-invest { border-top-color: var(--violet); }
.card.accent-retire { border-top-color: var(--purple); }
.card.accent-realestate { border-top-color: var(--amber); }
.card.accent-liability { border-top-color: var(--red); }
.card.accent-cashflow-pos { border-top-color: var(--green); }
.card.accent-cashflow-neg { border-top-color: var(--red); }
.card.accent-annuity { border-top-color: var(--teal); }

.table-scroll { overflow-x: auto; }
.table-scroll table.holdings { min-width: max-content; }

/* Overrides the min-width:max-content above -- that rule assumes every cell
   is short enough to want its full width on one line, which breaks down for
   raw bank-transaction text (some ACH descriptions run 150+ characters with
   no useful wrap points respected by the browser otherwise), stretching the
   table to 2000px+ and pushing Amount/Category off-screen with no visible
   scrollbar cue. Capping and wrapping the two free-text columns keeps the
   whole table within a normal window instead. */
.txn-table { min-width: 0; width: 100%; table-layout: fixed; }
.txn-table td, .txn-table th { white-space: normal; word-break: break-word; }
.txn-table td:nth-child(1), .txn-table th:nth-child(1) { width: 9%; }
.txn-table td:nth-child(2), .txn-table th:nth-child(2) { width: 26%; }
.txn-table td:nth-child(3), .txn-table th:nth-child(3) { width: 16%; }
.txn-table td:nth-child(4), .txn-table th:nth-child(4) { width: 10%; }
.txn-table td:nth-child(5), .txn-table th:nth-child(5) { width: 39%; }
/* The category <select> otherwise sizes itself to its widest option
   ("Subscriptions & Memberships"), which is wider than any reasonable
   column and was the actual cause of the table overflowing -- constraining
   it to the cell it's in fixes that regardless of how long a category name
   gets. */
.txn-table select { width: 100%; max-width: 100%; box-sizing: border-box; }

/* App-wide collapsible-list disclosure widget. Native <details>, no JS --
   wraps a long table (or any block) behind a clickable summary header,
   collapsed by default. Content-agnostic: works the same whether the child
   is a plain table.holdings, a .table-scroll wrapper, or a nested accordion
   of more details elements (see real_estate.html's property groups). */
details.list-details { margin: 16px 0; }
details.list-details > summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 18px; font-size: 0.92rem; font-weight: 600; color: var(--text); box-shadow: var(--shadow);
}
details.list-details > summary::-webkit-details-marker { display: none; }
details.list-details > summary::marker { content: ""; }
details.list-details > summary .table-count { color: var(--text-muted); font-weight: 400; }
details.list-details > summary .toggle-icon {
  width: 24px; height: 24px; border-radius: 50%; background: var(--bg-hover); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 700; color: var(--text-muted); line-height: 1; transition: transform .15s ease;
}
details.list-details[open] > summary { margin-bottom: 12px; }
details.list-details[open] > summary .toggle-icon { transform: rotate(45deg); }
/* Nested accordion rows (one details per group, e.g. property-by-state) --
   flatter/inline styling since each row sits inside an already-collapsible
   parent rather than needing its own card chrome. */
details.list-details details.accordion-item { border-top: 1px solid var(--border-soft); }
details.list-details details.accordion-item:first-of-type { border-top: none; }
details.list-details details.accordion-item > summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 4px; font-size: 0.88rem; font-weight: 600; color: var(--text);
}
details.list-details details.accordion-item > summary::-webkit-details-marker { display: none; }
details.list-details details.accordion-item > summary::marker { content: ""; }
details.list-details details.accordion-item[open] > summary .toggle-icon { transform: rotate(45deg); }
details.list-details details.accordion-item > summary .toggle-icon {
  width: 20px; height: 20px; border-radius: 50%; background: var(--bg-hover); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.92rem; font-weight: 700; color: var(--text-muted); line-height: 1; transition: transform .15s ease;
}
details.list-details details.accordion-item > div { padding-bottom: 12px; }

table.holdings {
  width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
table.holdings th, table.holdings td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border-soft); font-size: 0.92rem; font-variant-numeric: tabular-nums; }

/* Denser variant for tables with more columns than usual (e.g. Gross/Loan/Net
   split alongside % and count) -- shrinks type and padding so it still fits
   without triggering horizontal scroll at normal widths. */
table.holdings.table-compact th, table.holdings.table-compact td { padding: 8px 10px; font-size: 0.78rem; }
table.holdings.table-compact th { font-size: 0.66rem; }
table.holdings.table-compact table.nested-table th, table.holdings.table-compact table.nested-table td { padding: 6px 10px; font-size: 0.76rem; }
table.holdings th { background: var(--bg-subtle); font-weight: 700; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }

.sortable-th { cursor: pointer; user-select: none; position: relative; }
.sortable-th:hover { color: var(--text); background: var(--bg-hover); }
.sortable-th::after { content: "\2195"; margin-left: 5px; opacity: 0.35; font-size: 0.9em; }
.sortable-th[data-sort-dir="asc"]::after { content: "\2191"; opacity: 1; color: var(--blue-dark); }
.sortable-th[data-sort-dir="desc"]::after { content: "\2193"; opacity: 1; color: var(--blue-dark); }
table.holdings tr:last-child td { border-bottom: none; }
table.holdings tbody tr:hover { background: var(--bg-hover); }
table.holdings a { color: var(--blue-dark); font-weight: 600; text-decoration: none; }
table.holdings a:hover { text-decoration: underline; }

.form {
  display: flex; flex-direction: column; gap: 14px; max-width: 480px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 14px; padding: 22px; box-shadow: var(--shadow);
}
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--text); font-weight: 500; }
.form input, .form select, .form textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.92rem; font-family: inherit;
  background: var(--bg-page); color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15,111,99,0.15); }
.field-group { display: flex; flex-direction: column; gap: 14px; border-top: 1px dashed var(--border); padding-top: 14px; }

/* Compact grid form -- same visual density as .re-detail-grid, for edit
   forms with many short fields that don't need the wide, tall single-column
   .form layout. */
.form-compact {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 26px 24px; box-shadow: var(--shadow); max-width: none;
}
.form-compact .form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; }
@media (max-width: 1100px) { .form-compact .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .form-compact .form-grid { grid-template-columns: 1fr; } }
.form-compact .form-section-label {
  grid-column: 1 / -1; font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding-top: 14px; border-top: 1px dashed var(--border);
}
.form-compact .form-section-label:first-child { border-top: none; padding-top: 0; }
.form-compact label {
  display: flex; flex-direction: column; gap: 4px; font-size: 0.76rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em;
}
.form-compact input {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.88rem;
  font-family: inherit; background: var(--bg-page); color: var(--text);
}
.form-compact input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15,111,99,0.15); }
.form-compact .btn { margin-top: 18px; }

/* Dollar-amount inputs -- visual $ prefix so a money field reads as money
   even though HTML's <input type="number"> can't carry a currency symbol
   itself; value is pre-formatted to 2 decimals server-side (see the
   money_value macro) so the field never shows Python's raw float repr
   (e.g. "5500.0") when the page loads. */
.money-field { position: relative; }
.money-field .money-prefix {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.88rem; pointer-events: none;
}
.money-field input { padding-left: 20px !important; }

/* Expandable table rows -- click a row to reveal a nested breakdown table
   underneath it. App-wide standard: any <tr class="expandable-row"
   data-target="some-id"> paired with a following <tr class="nested-row"
   id="some-id"> works automatically via the delegated click handler in
   base.html, on every page, no extra JS needed. */
tr.expandable-row { cursor: pointer; }
tr.expandable-row:hover { background: var(--bg-hover); }
tr.expandable-row .expand-chevron {
  display: inline-block; margin-left: 6px; font-size: 0.7rem; color: var(--text-muted);
  transition: transform .15s ease;
}
tr.expandable-row.open .expand-chevron { transform: rotate(90deg); }
tr.nested-row { display: none; }
tr.nested-row.open { display: table-row; }
tr.nested-row > td { padding: 0 !important; background: var(--bg-subtle); }
table.nested-table { width: 100%; border-collapse: collapse; }
table.nested-table th, table.nested-table td {
  padding: 8px 20px 8px 46px; font-size: 0.85rem; border-bottom: 1px solid var(--border-soft);
  text-align: left; font-variant-numeric: tabular-nums;
}
table.nested-table th {
  text-transform: uppercase; font-size: 0.68rem; letter-spacing: .03em; color: var(--text-muted);
  font-weight: 700; background: transparent; padding-top: 10px;
}
table.nested-table tr:last-child td { border-bottom: none; padding-bottom: 10px; }
table.nested-table td.num, table.nested-table th.num { text-align: right; padding-right: 26px; }
table.nested-table a { color: var(--blue-dark); font-weight: 600; text-decoration: none; }
table.nested-table a:hover { text-decoration: underline; }

.report-list { list-style: none; padding: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.report-list li { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); background: var(--bg-card); }
.report-list li:first-child { border-radius: 14px 14px 0 0; }
.report-list li:last-child { border-radius: 0 0 14px 14px; border-bottom: none; }
.report-list a { color: var(--blue-dark); text-decoration: none; font-weight: 600; }
.report-list a:hover { text-decoration: underline; }

.section-divider { display: flex; align-items: center; gap: 12px; margin: 32px 0 18px; }
.section-divider::before, .section-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.section-divider span { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

.tab-panel.hidden { display: none; }
table.holdings tfoot td { font-weight: 700; background: var(--bg-subtle); border-top: 2px solid var(--border); }
table.holdings tr.totals-row td { border-bottom: none; }
table.holdings tr.group-header-row td {
  font-family: var(--font-display); font-weight: 600; font-size: 0.88rem;
  color: var(--text); background: var(--bg-subtle); padding-top: 12px; padding-bottom: 8px;
  border-top: 2px solid var(--border);
}
table.holdings tbody + tbody tr.group-header-row td { border-top: 2px solid var(--border); }

/* Opt-in collapsible groups (data-collapsible-groups on the group-by-bar) --
   a group starts expanded; clicking its header hides the member + subtotal
   rows via [hidden] until clicked again. Only .group-collapsible headers
   get the flex layout/pointer/icon -- a plain (non-collapsible) group
   header elsewhere in the app renders exactly as before. */
table.holdings tr.group-header-row.group-collapsible { cursor: pointer; }
table.holdings tr.group-header-row.group-collapsible:hover td { background: var(--bg-hover); }
/* The flex layout lives on this inner wrapper, not the <td> -- display:flex
   directly on a <td> breaks its table-cell/colspan sizing in some engines
   (it renders as a narrow, oddly-tall column instead of a normal-width
   row), which is exactly what a group-header td with a long label + the
   toggle icon triggered. */
table.holdings tr.group-header-row .group-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
table.holdings tr.group-header-row .toggle-icon {
  width: 22px; height: 22px; border-radius: 50%; background: var(--bg-hover); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: var(--text-muted); line-height: 1; transition: transform .15s ease;
  transform: rotate(45deg); /* expanded by default, reads as "x" */
}
table.holdings tr.group-header-row.collapsed .toggle-icon { transform: rotate(0deg); /* collapsed, reads as "+" */ }

.group-by-bar { display: flex; justify-content: flex-end; gap: 14px; flex-wrap: wrap; margin: 10px 0 8px; }
.group-by-bar:empty { display: none; }
.group-by-label { font-size: 0.82rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.group-by-select {
  font-family: inherit; font-size: 0.82rem; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; cursor: pointer;
}
.group-by-select:focus { outline: none; border-color: var(--blue); }
.save-flash { border-color: var(--green) !important; box-shadow: 0 0 0 2px var(--green-bg); transition: box-shadow .15s ease; }
.group-by-search-input {
  font-family: inherit; font-size: 0.82rem; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; width: 180px;
}
.group-by-search-input:focus { outline: none; border-color: var(--blue); }
.group-by-search-input::-webkit-search-cancel-button { cursor: pointer; }
.group-collapse-all-btn {
  font-family: inherit; font-size: 0.78rem; font-weight: 600; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 11px; cursor: pointer; align-self: center;
}
.group-collapse-all-btn:hover { background: var(--bg-hover); border-color: var(--blue); }

.pie-section { display: flex; align-items: center; gap: 32px; margin: 12px 0 4px; flex-wrap: wrap; }
.pie-donut {
  width: 180px; height: 180px; border-radius: 50%; flex-shrink: 0;
  position: relative; filter: drop-shadow(0 4px 10px rgba(16,24,40,0.12));
}
.pie-donut::after {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 112px; height: 112px; border-radius: 50%; background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--border);
}
.pie-legend { display: flex; flex-direction: column; gap: 11px; }
.pie-legend-item { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; }
.pie-swatch { width: 13px; height: 13px; border-radius: 4px; display: inline-block; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }

tr.stale-row { background: var(--amber-bg); }
.stale-badge {
  display: inline-block; background: var(--amber-bg); color: var(--amber); font-size: 0.7rem;
  font-weight: 700; padding: 2px 7px; border-radius: 5px; text-transform: uppercase;
}

.overview-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .overview-grid { grid-template-columns: 1fr; } }

.location-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 20px 0; }
.location-grid > section { min-width: 0; }
@media (max-width: 900px) { .location-grid { grid-template-columns: 1fr; } }
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 14px; font-size: 1.02rem; }
.panel .panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel .panel-header h3 { margin: 0; }
.panel-header a { font-size: 0.85rem; color: var(--blue-dark); text-decoration: none; font-weight: 600; }
.panel-header a:hover { text-decoration: underline; }

.networth-chart { width: 100%; height: 180px; }

.trend-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 16px 0; }
@media (max-width: 1000px) { .trend-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .trend-grid { grid-template-columns: 1fr; } }
.trend-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.trend-card-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.trend-card-title { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.trend-card-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.82rem; font-weight: 600; }
.trend-chart { width: 100%; height: 70px; display: block; }

svg[data-points] { cursor: crosshair; }
.chart-hover-guide { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.6; pointer-events: none; }
.chart-hover-dot { stroke: var(--bg-card); stroke-width: 1.5; pointer-events: none; }
.chart-tooltip {
  position: fixed; z-index: 1000; pointer-events: none; display: none; white-space: nowrap;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 11px; box-shadow: var(--shadow-md);
}
.chart-tooltip-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.chart-tooltip-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.86rem; color: var(--text); }
.trend-card-footer { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.breakdown-row { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.92rem; }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row span:last-child { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.breakdown-row.total { font-weight: 700; border-top: 2px solid var(--border); margin-top: 4px; padding-top: 13px; font-size: 1.02rem; }

/* Dashboard shell: a fixed-dark sidebar (net worth + category breakdown,
   Empower/Personal-Capital style) alongside the existing panel/card content.
   The sidebar is intentionally dark in both light and dark site themes --
   a deliberate permanent accent panel, not something that should flip with
   --bg-card, so its colors are literal rather than theme variables. */
.dash-shell { display: flex; gap: 20px; align-items: flex-start; }
.dash-sidebar {
  width: 260px; flex-shrink: 0; background: #0f1b33; color: #e6eaf2;
  border-radius: 16px; padding: 24px 20px; box-shadow: var(--shadow);
}
.dash-sidebar .eyebrow { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #8b95ab; }
.dash-sidebar .nw-total { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.85rem; font-weight: 700; margin: 6px 0 2px; letter-spacing: -0.01em; color: #fff; }
.dash-sidebar .nw-change { font-size: 0.86rem; margin-bottom: 16px; font-weight: 600; }
.dash-sidebar .up { color: #22b573; }
.dash-sidebar .down { color: #e5544a; }
.dash-sidebar .muted { color: #8b95ab; }
.dash-sidebar .al-row { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 7px 0; border-top: 1px solid #263353; color: #c3cade; }
.dash-sidebar .cat-group { border-top: 1px solid #263353; padding: 9px 0; }
.dash-sidebar .cat-group:last-child { padding-bottom: 0; }
.dash-sidebar .cat-row { display: flex; justify-content: space-between; align-items: baseline; }
.dash-sidebar .cat-row a { color: inherit; text-decoration: none; }
.dash-sidebar .cat-row a:hover { text-decoration: underline; }
.dash-sidebar .cat-label { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #c3cade; }
.dash-sidebar .cat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.86rem; font-weight: 700; color: #fff; }
.dash-sidebar .cat-sub { font-size: 0.73rem; color: #8b95ab; margin-top: 2px; }
.dash-main { flex: 1; min-width: 0; }
@media (max-width: 860px) {
  .dash-shell { flex-direction: column; }
  .dash-sidebar { width: 100%; }
}

.movers-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-top: 1px solid var(--border-soft); font-size: 0.82rem; }
.movers-row:first-of-type { border-top: none; }
.movers-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%; }
.movers-row .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Tighter typography for the dashboard specifically -- scoped under
   .dash-main/.dash-sidebar (rather than changed on the shared .panel/
   .pie-legend-item/etc. classes themselves) so real_estate.html, which
   reuses those same classes, keeps its current sizing untouched. */
.dash-sidebar .nw-total { font-size: 1.7rem; }
.dash-main .panel { padding: 16px 18px; }
.dash-main .panel h3 { font-size: 0.92rem; }
.dash-main .panel-header { margin-bottom: 10px; }
.dash-main .pie-section { gap: 20px; margin: 8px 0 2px; }
.dash-main .pie-donut { width: 96px; height: 96px; }
.dash-main .pie-legend { gap: 7px; }
.dash-main .pie-legend-item { font-size: 0.8rem; gap: 7px; }
.dash-main .pie-swatch { width: 10px; height: 10px; border-radius: 3px; }
.dash-main .breakdown-row { font-size: 0.78rem; padding: 6px 0; }
.dash-main .section-divider { margin: 18px 0 10px; }
.dash-main .section-divider span { font-size: 0.7rem; }
.dash-main .card-grid-3-compact:first-of-type { margin-top: 0; }

.card-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 16px 0; }
@media (max-width: 900px) { .card-grid-3 { grid-template-columns: 1fr; } }

/* Tighter variants for the dashboard's "Totals" cards, so their density
   matches the overview tile grid above (.panel/.tile) instead of the more
   spacious default .card used elsewhere (holding detail, cash flow, etc.) --
   scoped as modifiers rather than changed in place so those other pages are
   untouched. */
.card-grid-3-compact { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
@media (max-width: 900px) { .card-grid-3-compact { grid-template-columns: 1fr; } }
.card-compact { padding: 12px 14px; border-top-width: 2px; }
.card-compact .icon-badge { width: 24px; height: 24px; border-radius: 7px; font-size: 0.76rem; margin-bottom: 6px; }
.card-compact .card-label { font-size: 0.68rem; }
.card-compact .card-value { font-size: 1.02rem; margin-top: 3px; }
.card-compact .card-sub { font-size: 0.7rem; margin-top: 2px; }
.card-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 16px 0; }
@media (max-width: 1100px) { .card-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .card-grid-4 { grid-template-columns: 1fr; } }
.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-list-item { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.9rem; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.mini-list-item:last-child { border-bottom: none; }
.mini-list-item .item-sub { font-size: 0.78rem; color: var(--text-muted); }

.progress-track { background: var(--bg-subtle); border-radius: 6px; height: 9px; overflow: hidden; margin-top: 8px; }
.progress-fill { background: linear-gradient(90deg, var(--blue), var(--blue-dark)); height: 100%; border-radius: 6px; }
.goal-row { padding: 15px 0; border-bottom: 1px solid var(--border-soft); }
.goal-row:last-child { border-bottom: none; }
.goal-row-top { display: flex; justify-content: space-between; font-size: 0.92rem; margin-bottom: 2px; }
.goal-row-sub { font-size: 0.8rem; color: var(--text-muted); }

.card-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 16px 0; }
@media (max-width: 1100px) { .card-grid-5 { grid-template-columns: repeat(2, 1fr); } }

.alert-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0; }
@media (max-width: 1100px) { .alert-strip { grid-template-columns: repeat(2, 1fr); } }
.alert-card {
  display: flex; align-items: center; gap: 12px; background: var(--bg-card); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow); border-left: 4px solid transparent;
}
.alert-card .icon-badge { margin-bottom: 0; flex-shrink: 0; }
.alert-card.alert-warn { border-left-color: var(--amber); }
.alert-card.alert-ok { border-left-color: var(--green); }
.alert-title { font-weight: 700; font-size: 0.92rem; }
.alert-sub { font-size: 0.76rem; color: var(--text-muted); }

.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
}
.status-pill.status-primary { background: var(--navy-bg); color: var(--navy); }
.status-pill.status-rented { background: var(--green-bg); color: var(--green); }
.status-pill.status-unknown { background: var(--bg-subtle); color: var(--text-muted); }

.quick-action {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.9rem;
}
.quick-action:hover { background: var(--bg-hover); }
.qa-arrow { margin-left: auto; color: var(--text-muted); }

.txn-list { display: flex; flex-direction: column; }
.txn-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.9rem; }
.txn-row:last-child { border-bottom: none; }
.txn-desc { font-weight: 600; }
.txn-cat { font-size: 0.78rem; color: var(--text-muted); }

.num, table.holdings td.num, table.holdings th.num, table.nested-table td.num, table.nested-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.stock-news { margin-top: 2px; font-size: 0.76rem; line-height: 1.3; max-width: 260px; }
.stock-news a { color: var(--text-muted); text-decoration: none; }
.stock-news a:hover { color: var(--text); text-decoration: underline; }
.stock-news-meta { display: block; color: var(--text-muted); opacity: 0.75; }

.star-rating { color: #c08a2e; letter-spacing: 1px; white-space: nowrap; cursor: default; }

/* Category Rules management (Operating P&L) -- one card per category, each
   a removable chip per keyword plus a small inline "add keyword" form, so
   editing rules is a couple of clicks instead of a code change. */
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 14px 0; }
.rule-category { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.rule-category-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.rule-category-name { font-weight: 700; font-size: 0.9rem; }
.rule-type-badge { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.rule-type-income { background: var(--green-bg); color: var(--green); }
.rule-type-expense { background: var(--red-bg); color: var(--red); }
.rule-type-transfer { background: var(--sky-bg); color: var(--blue); }
.rule-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rule-chip-form { display: inline-flex; }
.rule-chip {
  display: inline-flex; align-items: center; gap: 5px; background: var(--bg-subtle); border: 1px solid var(--border-soft);
  color: var(--text); font-size: 0.78rem; padding: 4px 8px 4px 10px; border-radius: 999px; cursor: pointer; font-family: inherit;
}
.rule-chip:hover { background: var(--bg-hover); border-color: var(--red); color: var(--red); }
.rule-chip-x { font-size: 0.9rem; opacity: 0.6; line-height: 1; }
.rule-chip:hover .rule-chip-x { opacity: 1; }
.rule-add-form { display: flex; gap: 6px; }
.rule-add-input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 0.8rem; color: var(--text); background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px;
}
.rule-add-input:focus { outline: none; border-color: var(--blue); }
.budget-amount-input {
  width: 100px; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 0.88rem; color: var(--text); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 8px;
}
.budget-amount-input:focus { outline: none; border-color: var(--blue); }
.rule-add-btn {
  font-family: inherit; font-size: 0.78rem; font-weight: 600; color: var(--blue); background: transparent;
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 12px; cursor: pointer;
}
.rule-add-btn:hover { background: var(--bg-hover); }
.rule-new-category { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.rule-new-category h4 { margin: 0 0 10px; font-size: 0.85rem; }
.rule-new-form { display: flex; gap: 8px; flex-wrap: wrap; }
.rule-new-form input, .rule-new-form select {
  font-family: inherit; font-size: 0.85rem; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px;
}
.rule-new-form input[type="text"] { flex: 1; min-width: 160px; }

.fund-account {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.fund-account summary {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; cursor: pointer;
  list-style: none; font-size: 0.92rem;
}
.fund-account summary::-webkit-details-marker { display: none; }
.fund-account summary::before {
  content: "\25B8"; color: var(--text-muted); font-size: 0.8rem; transition: transform .15s ease;
}
.fund-account[open] summary::before { transform: rotate(90deg); }
.fund-account summary:hover { background: var(--bg-hover); }
.fund-account-name { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.fund-account-meta { color: var(--text-muted); font-size: 0.82rem; }
.fund-account-total { margin-left: auto; font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
table.fund-table { border-top: 1px solid var(--border); }

/* Fund Holdings report tab: consolidated statement-style view reusing the
   .chip/.progress-fill color tokens and .fund-account card already used
   elsewhere, plus a few pieces unique to this view. */
.fh-totalstrip {
  display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 18px 22px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.fh-totalstrip .label { font-size: 0.76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.fh-totalstrip .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 600; margin-top: 2px; }
.fh-totalstrip .count { color: var(--text-muted); font-size: 0.86rem; }

.fh-ribbon-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.fh-ribbon-title { font-size: 0.88rem; font-weight: 700; margin-bottom: 12px; }
.fh-ribbon { display: flex; width: 100%; height: 12px; border-radius: 6px; overflow: hidden; background: var(--bg-subtle); }
.fh-ribbon span { height: 100%; }
.fh-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 9px 18px; margin-top: 14px; }
.fh-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; }
.fh-legend-item .name { flex: 1; }
.fh-legend-item .val { color: var(--text-muted); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.fh-jumpnav { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.fh-jumpnav a {
  font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-decoration: none;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card);
}
.fh-jumpnav a:hover { color: var(--blue-dark); border-color: var(--blue); }

.fh-mini-ribbon { display: flex; height: 5px; border-radius: 3px; overflow: hidden; margin: 0 18px 14px; background: var(--bg-subtle); }
.fh-mini-ribbon span { height: 100%; }

.re-detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; padding: 6px 26px 20px; border-top: 1px solid var(--border); }
@media (max-width: 1200px) { .re-detail-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .re-detail-grid { grid-template-columns: 1fr; } }
.re-detail-col { padding-top: 14px; }
.re-detail-col h4 {
  font-family: var(--font-body); font-size: 0.76rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin: 0 0 4px; font-weight: 700;
}
.re-detail-col .breakdown-row { padding: 8px 0; font-size: 0.86rem; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-sky { background: var(--sky-bg); color: var(--sky); }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-navy { background: var(--navy-bg); color: var(--navy); }
.chip-amber { background: var(--amber-bg); color: var(--amber); }
.chip-violet { background: var(--violet-bg); color: var(--violet); }
.chip-purple { background: var(--purple-bg); color: var(--purple); }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-muted { background: var(--bg-subtle); color: var(--text-muted); }

.fund-pct-row { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.fund-pct-row .pct-label { font-size: 0.82rem; color: var(--text-muted); width: 38px; flex-shrink: 0; }
.fund-pct-row .progress-track { flex: 1; margin-top: 0; }
.progress-fill.fill-sky { background: var(--sky); }
.progress-fill.fill-green { background: var(--green); }
.progress-fill.fill-navy { background: var(--navy); }
.progress-fill.fill-amber { background: var(--amber); }
.progress-fill.fill-violet { background: var(--violet); }
.progress-fill.fill-purple { background: var(--purple); }
.progress-fill.fill-red { background: var(--red); }
.progress-fill.fill-muted { background: var(--text-muted); }
