/* Brand (docs/brand): grid paper, pencil and highlighter colours; Archivo + Azeret Mono.
   Lime (--accent) is a fill only, always with --on-accent text on it. Text links and "better"
   figures use --accent-ink, which passes contrast on the page. */
@font-face { font-family: "Archivo"; src: url("/fonts/archivo.woff2") format("woff2");
             font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Azeret Mono"; src: url("/fonts/azeret-mono.woff2") format("woff2");
             font-weight: 400 700; font-display: swap; }
:root {
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Azeret Mono", ui-monospace, Menlo, monospace;
  --bg: #f4f6f1;        /* grid paper */
  --card: #fbfcf9;      /* sheet */
  --text: #1a1d16;      /* pencil */
  --muted: #586052;     /* note */
  --border: #cdd3c5;
  --grid: #e3e8dd;      /* grid line: bar tracks, hover */
  --accent: #d2f54a;    /* highlighter: fills only */
  --accent-ink: #3d5c00;/* lime family, dark enough for text and thin lines */
  --accent-soft: #eef7cc;
  --on-accent: #161b05; /* text, borders and shadows on lime */
  --edge: #161b05;      /* button borders and their offset shadow */
  --input-border: #737b6d; /* 3:1 against sheet and paper, so boxes are visible */
  --warn: #8a5300;
  --error: #b42318;

  /* Investment types. Hues kept clear of the status colours (green / amber / red). */
  --type-etf: #1d5fc4;        --type-etf-bg: #e7effc;
  --type-complex: #7a3fd1;    --type-complex-bg: #f1eafd;
  --type-fund: #0b7285;       --type-fund-bg: #e1f3f6;
  --type-portfolio: #a3307a;  --type-portfolio-bg: #fbe9f4;
  --type-neutral: #586052;    --type-neutral-bg: transparent;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121510;
    --card: #181c15;
    --text: #e8ebe2;
    --muted: #9ea695;
    --border: #30362a;
    --grid: #232920;
    --accent: #c6f432;
    --accent-ink: #c6f432;
    --accent-soft: #232b12;
    --on-accent: #161b05;
    --edge: #5d6852;    /* a dark shadow would vanish on the dark page */
    --input-border: #687160;
    --warn: #f0b45a;
    --error: #ff8a80;
    color-scheme: dark;

    --type-etf: #8ab4ff;        --type-etf-bg: #18284a;
    --type-complex: #c4a6ff;    --type-complex-bg: #2a1f48;
    --type-fund: #6fd3e3;       --type-fund-bg: #10333a;
    --type-portfolio: #f39bd3;  --type-portfolio-bg: #3d1a32;
    --type-neutral: #9ea695;    --type-neutral-bg: transparent;
  }
}

* { box-sizing: border-box; }

/* Keyboard focus: one visible ring on everything you can tab to. */
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
tr:focus-visible { outline-offset: -2px; }
/* File inputs are visually hidden, so their label shows the ring instead. */
.upload:has(input:focus-visible) .button,
.upload:has(input:focus-visible) .link-like { outline: 2px solid var(--text); outline-offset: 2px; }

/* Hidden on screen, still read by screen readers and reachable by keyboard. */
.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; }
/* Live message areas stay in the page (so screen readers hear changes) but take no space when empty. */
.live:empty { margin: 0; }
.signin-alt { margin-top: 20px; }
.signin-alt > summary { cursor: pointer; }
.signin-alt[open] > summary { margin-bottom: 12px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
/* Figures in one monospace face, so amounts line up and read as data. */
.num, td.num, .big, .cost, .tile-val, .rank-total, .rank-lines dd, .rank-diff, input[type="number"] {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.dash .wrap { max-width: 1240px; }  /* dashboard is mostly wide tables */
header { padding-top: 32px; }
h1 { margin: 0; font-size: 2rem; font-weight: 850; font-stretch: 112%; line-height: 1.02; letter-spacing: -0.015em; text-wrap: balance; }
h2 { margin-top: 0; font-size: 0.95rem; font-weight: 800; font-stretch: 125%; text-transform: uppercase; letter-spacing: 0.05em; }
h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 700; font-stretch: 105%; }
mark, .hl { background: linear-gradient(transparent 10%, var(--accent) 10%, var(--accent) 90%, transparent 90%); color: var(--on-accent);
            padding: 0 0.1em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* Brand bar: the mark (tick on a highlighter) and the wordmark. */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand .mark { width: 34px; height: 34px; flex: none; }
.brand span { font-weight: 850; font-stretch: 118%; font-size: 1.5rem; line-height: 1; letter-spacing: -0.01em; }
.brand-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.meta { font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.home h1 { font-size: clamp(2rem, 5.2vw, 3.4rem); max-width: 17ch; margin-top: 12px; }
.lede { color: var(--muted); margin-top: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 20px;
  margin: 16px 0;
}

input, select, button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 8px;
}
/* Buttons: lime rectangles with a hard offset shadow. Text buttons (.link) and tabs/chips stay quiet. */
button { cursor: pointer; background: var(--accent); color: var(--on-accent); border: 1.5px solid var(--on-accent);
         box-shadow: 3px 3px 0 var(--edge); font-weight: 700; font-stretch: 112%; padding: 7px 16px; }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
button.link { background: none; color: var(--muted); border: none; box-shadow: none; transform: none; font-weight: 400; font-stretch: 100%; padding: 4px 6px; min-height: 32px; min-width: 32px; }
button.link:hover { color: var(--error); }
input, select { border: 1.5px solid var(--input-border); }
input[type="number"] { width: 100%; min-width: 80px; }

.row { display: flex; gap: 8px; margin-top: 12px; }
.row input { flex: 1; min-width: 0; }
/* Add-box suggestions (replaces the browser's datalist, which can't be styled or delayed). */
.combo { position: relative; flex: 1; min-width: 0; display: flex; }
.combo input { flex: 1; min-width: 0; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10; margin: 0; padding: 4px; list-style: none;
  max-height: 320px; overflow-y: auto; background: var(--card); color: var(--text);
  border: 1px solid var(--input-border); box-shadow: 4px 4px 0 var(--edge); }
a.fund-link { color: inherit; text-decoration: underline; text-decoration-color: var(--input-border); text-underline-offset: 2px; }
a.fund-link:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.suggest li { padding: 6px 10px; cursor: pointer; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--accent-soft); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.grid.assumptions { grid-template-columns: repeat(auto-fit, minmax(200px, 330px)); }
.card > label.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.9rem; color: var(--muted); }
/* Results groups: three boxed panels so each category reads as separate. */
.group { margin-top: 28px; }
#results-status + .group { margin-top: 0; }
#breakdown > h3, #custom-body > h3 { margin-top: 20px; }  /* space below the cards */
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 12px; }
.group-name { margin: 0; font-size: 0.95rem; font-weight: 800; font-stretch: 125%; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text); }
.group-desc { flex-basis: 100%; margin: 0; font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.group-gap { margin-left: auto; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.group .result { background: var(--card); }
.group .result.best { background: var(--accent-soft); }
details.group > summary { cursor: pointer; list-style: none; margin-bottom: 0; border-top: 2px solid var(--text); padding-top: 12px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .group-name::before { content: "▸" / ""; display: inline-block; width: 1.1em; color: var(--muted); }
details.group[open] > summary .group-name::before { content: "▾" / ""; }
details.group > summary .group-desc { padding-left: 1.1em; }
details.group[open] > summary { margin-bottom: 12px; }
details.group:not([open]):hover .group-name { text-decoration: underline; text-underline-offset: 3px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.holdings td:first-child { min-width: 180px; }
.etf-name { display: block; font-size: 0.85rem; color: var(--muted); }
.min-hint { display: block; margin-top: 4px; font-size: 0.82rem; color: var(--warn); }
.min-hint[hidden] { display: none; }
.min-hint::before { content: "⚠ " / ""; }
input.below-min { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.etf-name .cost { white-space: nowrap; font-variant-numeric: tabular-nums; }
.etfs tbody tr:hover { background: var(--accent-soft); }

.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.result { border: 1px solid var(--border); padding: 16px; }
.result.best { border-color: var(--accent); background: var(--accent-soft); }
.badge { display: inline-block; font-size: 0.66rem; font-weight: 800; font-stretch: 125%; text-transform: uppercase; letter-spacing: 0.06em; border: 1.5px solid currentColor; padding: 1px 5px; margin-left: 8px; vertical-align: 2px; }
.big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 0.9rem; }
.lines { width: 100%; margin-top: 8px; }
.lines td { border: none; padding: 2px 0; }
.lines tr.total td { border-top: 1px solid var(--border); font-weight: 600; padding-top: 6px; }
.warn { color: var(--warn); font-size: 0.85rem; margin: 6px 0 0; }
.error { color: var(--error); font-size: 0.9rem; }
.hint, .disclaimer { color: var(--muted); font-size: 0.85rem; }
.summary { margin: 0 0 16px; font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-head h2 { margin-bottom: 0; }
button.reset { color: var(--muted); font-size: 0.9rem; }
button.reset:hover { color: var(--accent-ink); }
#reset-note button.link { color: var(--accent-ink); text-decoration: underline; }
.custom { margin-top: 16px; }
.custom summary { cursor: pointer; color: var(--accent-ink); }
.custom form { margin-top: 12px; }
ul.notes { padding-left: 18px; margin: 8px 0; font-size: 0.9rem; }
.tiers { font-size: 0.85rem; }
#etf-filter { width: 100%; margin-bottom: 8px; }
a { color: var(--accent-ink); }
.small { font-size: 0.85rem; margin: 0 0 6px; }
td.worse { color: var(--error); }
td.better { color: var(--accent-ink); }
.result.na { opacity: 0.7; border-style: dashed; }

/* Results: a ranked list, cheapest first. One row per option: rank, name, total, a bar to scale, then
   the fee lines. The cheapest row sits in a lime band. */
ol.ranks { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.rank { padding: 14px 0; border-bottom: 1px solid var(--border); }
.rank.best { background: var(--accent); color: var(--on-accent); margin: 0 -12px; padding-inline: 12px; border-bottom-color: transparent;
             --muted: #3a4514; --border: rgb(22 27 5 / 0.25); --grid: rgb(22 27 5 / 0.14); --text: #161b05; --accent-ink: #161b05; }
.rank.check, .rank.below-min { box-shadow: inset 3px 0 0 var(--warn); padding-left: 12px; }
.rank.na { box-shadow: inset 3px 0 0 var(--error); padding-left: 12px; }
.rank.na .rank-head, .rank.na .rank-lines { opacity: 0.75; }
.rank-head { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 4px 14px; align-items: baseline; }
.rank-head.solo { grid-template-columns: minmax(0, 1fr) auto; } /* a list of one has no rank number */
.rank-n { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.rank-who h4 { margin: 0 0 2px; font-size: 1.05rem; font-stretch: 105%; }
.rank-who .small { margin: 0; }
.rank-total { text-align: right; }
.rank-total .big { line-height: 1; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.04em; }
.rank-total .small { margin: 2px 0 0; font-family: var(--font); }
.rank-diff { font-size: 0.8rem; color: var(--muted); }
.rank-bar { grid-column: 2 / -1; height: 8px; margin-top: 6px; background: var(--grid); position: relative; }
.rank-bar i { position: absolute; inset: 0 auto 0 0; background: var(--text); }
.rank-head.solo .rank-bar { grid-column: 1 / -1; }
.rank-lines { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 10px 0 0 calc(2rem + 14px); }
.rank-head.solo + .rank-lines { margin-left: 0; }
.rank-lines > div { display: flex; gap: 6px; align-items: baseline; }
.rank-lines dt { font-size: 0.8rem; color: var(--muted); }
.rank-lines dd { margin: 0; font-size: 0.85rem; }
.rank-lines .end dd { font-weight: 700; }
ul.flags { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.flag { font-size: 0.875rem; padding: 6px 10px 6px 30px; position: relative;
        color: var(--text); background: color-mix(in srgb, var(--c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.flag::before { content: "⚠" / ""; position: absolute; left: 10px; top: 6px; color: var(--c); }
.flag.warn { --c: var(--warn); }
.flag.bad { --c: var(--error); }
.flag.bad::before { content: "✕" / ""; }
@media (max-width: 640px) {
  .rank-head { grid-template-columns: 1.5rem minmax(0, 1fr) auto; gap: 4px 10px; }
  .rank-total .big { font-size: 1.35rem; }
  .rank-lines { margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  /* Only the name sits beside the rank number; the lines under it and the bar start at the left edge. */
  .rank-head:not(.solo) .rank-who { display: contents; }
  .rank-head:not(.solo) .rank-n { grid-row: 1; grid-column: 1; }
  .rank-head:not(.solo) .rank-who h4 { grid-row: 1; grid-column: 2; }
  .rank-head:not(.solo) .rank-who .small { grid-column: 1 / 3; }
  .rank-head:not(.solo) .rank-total { grid-row: 1 / span 2; grid-column: 3; max-width: 11rem; }
  .rank-head .rank-bar { grid-column: 1 / -1; }
  .card { padding: 16px; }
  details.group > summary .group-gap { margin-left: 0; padding-left: 1.1em; }
}

/* First-year fees by holding: options down, holdings across; names column stays put when scrolling. */
.by-holding table { font-size: 0.9rem; }
.by-holding th, .by-holding td { padding: 10px 12px; vertical-align: top; }
.by-holding td.num, .by-holding th.num { min-width: 128px; }
.by-holding tbody th { font-weight: 600; color: var(--text); white-space: normal; min-width: 150px; }
.by-holding tbody th, .by-holding thead th:first-child { position: sticky; left: 0; background: var(--bg); z-index: 1; }
.by-holding .who.end { justify-content: flex-end; }
.by-holding tbody tr:hover > * { background: var(--accent-soft); }
.by-holding .cell-amt { display: block; font-weight: 600; }
.by-holding td .etf-name { white-space: nowrap; }
.by-holding td.total { font-weight: 700; border-left: 1px solid var(--border); }
.by-holding tr.na td, .by-holding tr.na th { color: var(--muted); }
.by-holding .cell-body { display: block; }
/* Phones: one block per platform (name and first-year total on top, then a line per holding) instead of
   a table wider than the screen. The header row stays for screen readers; the ARIA roles keep it a table. */
@media (max-width: 640px) {
  .table-scroll.by-holding { overflow: visible; }
  .by-holding table, .by-holding tbody { display: block; width: 100%; }
  .by-holding thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .by-holding tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px;
                         padding: 12px 0 8px; border-top: 2px solid var(--text); }
  .by-holding tbody tr:last-child { border-bottom: 1px solid var(--border); }
  .by-holding tbody tr:hover > * { background: none; }
  .by-holding th, .by-holding td { padding: 0; min-width: 0; border: 0; }
  .by-holding tbody th { position: static; grid-row: 1; grid-column: 1; min-width: 0; font-size: 1rem; background: none; }
  .by-holding td.total { grid-row: 1; grid-column: 2; border-left: 0; font-family: var(--mono); font-size: 1rem; }
  .by-holding td.total::before { content: none; }
  .by-holding td:not(.total) { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px;
                               margin-top: 8px; padding: 8px 0 0 12px; border-top: 1px solid var(--grid); }
  .by-holding td:not(.total)::before { content: attr(data-label) "\A" attr(data-sub); white-space: pre-line;
                                       text-align: left; font-weight: 600; color: var(--text); font-size: 0.85rem; }
  .by-holding tr.na td:not(.total)::before { color: var(--muted); }
  .by-holding .cell-body { text-align: right; }
}
.cell-flag { display: inline-block; margin-top: 3px; font-size: 0.78rem; font-weight: 600; padding: 0 6px;
             color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); white-space: nowrap; }
.cell-flag.warn { --c: var(--warn); }
.cell-flag.bad { --c: var(--error); }
.na-note { color: var(--warn); font-size: 0.85rem; margin: 0 0 8px; font-weight: 600; }

/* ---- dashboard ---- */
/* Status: Last run, Next run, Funds tracked in one row. */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
/* One type per line: badge, then its count. */
.type-counts { display: grid; grid-template-columns: max-content max-content; gap: 4px 10px; align-items: center; margin: 4px 0 6px; }
.type-counts > .type { justify-self: start; }
.type-counts > span:not(.type) { text-align: right; }
/* Fee changes: give the fund name room; fee text wraps instead. */
#changes td.fund { min-width: 14rem; }
#changes td.change { white-space: nowrap; }
.tile { border: 1px solid var(--border); padding: 12px; }
.tile-val { font-size: 1.25rem; font-weight: 700; margin: 4px 0; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; } }
.pill { display: inline-block; font-size: 0.8rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.pill.success, .pill.not_modified, .pill.changed, .pill.applied { color: var(--accent-ink); border-color: var(--accent-ink); }
.pill.partial, .pill.warn, .pill.stale, .pill.blocked { color: var(--warn); border-color: var(--warn); }
.pill.failed, .pill.error, .pill.held, .pill.parse_error, .pill.not_found { color: var(--error); border-color: var(--error); }
.pill.daily, .pill.running { color: var(--muted); }
.attention { border-color: var(--warn); }
.att-head { display: flex; justify-content: space-between; align-items: center; }
.att-head h2 { margin: 0; }
.att-list, .log { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.9rem; }
.att-list li, .log li { padding: 6px 0; border-top: 1px solid var(--border); }
/* Message on the left, Dismiss always in its own column on the right. */
.att-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.att-text { overflow-wrap: anywhere; }
.att-actions { display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.retry-note { margin: 8px 0 0; font-size: 0.9rem; }
.tablist { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tab { background: none; color: var(--text); border-color: var(--border); box-shadow: none; }
.tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--on-accent); }
.check.inline { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; font-size: 0.9rem; color: var(--muted); }
tr.run { cursor: pointer; }
tr.run:hover { background: var(--accent-soft); }
.log-toggle { color: var(--text); padding: 0; min-height: 0; min-width: 0; text-decoration: underline dotted; text-underline-offset: 3px; }
ul.diff { list-style: none; padding: 0; margin: 6px 0; font-size: 0.85rem; white-space: normal; }
ul.diff li { padding: 2px 0; }
tr.next td { font-weight: 600; }
td.tickers { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
tr.stale td { background: rgba(240, 180, 90, 0.08); }
tr.skipped { opacity: 0.55; }
pre { white-space: pre-wrap; font-size: 0.85rem; margin: 4px 0; }
#doc-view { flex: 0 0 auto; }
.nowrap { white-space: nowrap; }
.pill.active { color: var(--accent-ink); border-color: var(--accent-ink); }
.pill.inactive { color: var(--error); border-color: var(--error); }
.pill.running-check { color: var(--warn); border-color: var(--warn); }
.todo { display: grid; gap: 4px; }
.todo-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 0.9rem; }
.upload { cursor: pointer; }
.upload .button { display: inline-block; background: var(--accent); color: var(--on-accent); border: 1.5px solid var(--on-accent); box-shadow: 3px 3px 0 var(--edge); font-weight: 700; padding: 6px 12px; font-size: 0.9rem; }
.link-like { color: var(--accent-ink); text-decoration: underline; }

/* ---- investment type badges (square corners; status pills are round) ---- */
.type {
  --c: var(--type-neutral); --b: var(--type-neutral-bg);
  display: inline-block; font-size: 0.8rem; font-weight: 600; line-height: 1.5;
  padding: 0 6px; border-radius: 2px; white-space: nowrap; vertical-align: 1px;
  color: var(--c); background: var(--b); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.type-etf { --c: var(--type-etf); --b: var(--type-etf-bg); }
.type-complex { --c: var(--type-complex); --b: var(--type-complex-bg); }
.type-fund { --c: var(--type-fund); --b: var(--type-fund-bg); }
.type-portfolio { --c: var(--type-portfolio); --b: var(--type-portfolio-bg); }
.type-custom { border-style: dashed; }
.type-platform { --c: var(--type-neutral); }
.who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* fee list */
.list-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.list-tools #etf-filter { flex: 1 1 220px; width: auto; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: none; color: var(--text); border: 1.5px solid var(--border); box-shadow: none; font-weight: 400; font-stretch: 100%;
        padding: 3px 10px; font-size: 0.85rem; display: inline-flex; gap: 6px; align-items: center; }
.chip:active { transform: none; box-shadow: none; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { border-color: var(--on-accent); background: var(--accent); color: var(--on-accent); font-weight: 700; }
.chip[aria-pressed="true"] .n { color: var(--on-accent); }
.chip .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--muted)); }
.etfs td { vertical-align: top; }
.etfs .sub { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.etfs .sub b { color: var(--type-fund); font-weight: 600; }
.etfs .next { display: block; font-size: 0.85rem; color: var(--warn); white-space: nowrap; }
.etfs .incl { display: block; font-size: 0.8rem; color: var(--muted); white-space: nowrap; cursor: help; }

/* fee list: title, filters and column headers stay visible while scrolling */
.list-head { position: sticky; top: 0; z-index: 2; background: var(--card);
             margin: -20px -20px 0; padding: 16px 20px 8px; }
.list-head h2 { margin-bottom: 10px; }
.list-head .list-tools { margin-bottom: 0; }
.table-clip { overflow-x: clip; } /* not a scroll box, so the sticky headers below still work */
.etfs thead th { position: sticky; top: var(--list-head-h, 0px); z-index: 1; background: var(--card);
                 border-bottom: none; box-shadow: inset 0 -1px 0 var(--border); }
@media (max-width: 640px) {
  .etfs .opt { display: none; } /* transaction costs and PDS date: still in the total and the PDS link */
  /* Too narrow for every column: the table scrolls sideways instead of being cut off. A scroll box
     can't keep the headings pinned, so on phones they scroll with the list. */
  .table-clip { overflow-x: auto; }
  .etfs thead th { position: static; }
  .etfs th, .etfs .next { white-space: normal; }
  .etfs th, .etfs td { padding: 6px; }
}

/* Bigger targets on touch screens. */
@media (pointer: coarse) {
  button, .chip, .upload .button, select, input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; }
  button.link { min-width: 44px; }
  input[type="checkbox"] { width: 22px; height: 22px; }
}

/* Glossary, type legend and the fee list's "Show all". */
.glossary, .legend { margin-top: 16px; font-size: 0.9rem; }
.glossary summary, .legend summary { cursor: pointer; color: var(--accent-ink); }
.glossary dl, .legend dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 10px 0 0; }
.glossary dt { font-weight: 600; }
.glossary dd, .legend dd { margin: 0; color: var(--muted); }
.legend { margin: 8px 0; }
button.more { margin-top: 4px; }
#etf-count { margin: 8px 0 0; }

/* Phones: each holding becomes a small card instead of a wide table. */
@media (max-width: 640px) {
  .holdings thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .holdings, .holdings tbody, .holdings td { display: block; }
  .holdings tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; position: relative;
                 border: 1px solid var(--border); padding: 10px; margin-bottom: 10px; }
  .holdings td { border: none; padding: 0; text-align: left; }
  .holdings td:first-child { grid-column: 1 / -1; min-width: 0; padding-right: 40px; }
  .holdings td[data-label]::before { content: attr(data-label); display: block; font-size: 0.85rem; color: var(--muted); }
  .holdings td.remove { position: absolute; top: 4px; right: 4px; }
  .holdings input[type="number"] { min-width: 0; }
  .glossary dl, .legend dl { grid-template-columns: 1fr; }
  .glossary dd, .legend dd { margin-bottom: 6px; }
}

/* Site footer: copyright, then small links split by thin bars. */
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; column-gap: 24px; row-gap: 4px;
               text-align: center;
               margin-top: 24px; padding-top: 12px; padding-bottom: 24px; border-top: 2px solid var(--text);
               font-size: 0.75rem; color: var(--muted); }
.site-footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; list-style: none; margin: 0; padding: 0; }
.footer-links li + li { border-left: 1px solid var(--border); margin-left: 8px; padding-left: 8px; }
.footer-links a { color: var(--text); text-decoration: none; }
.footer-links a:hover, .footer-links a:focus-visible { text-decoration: underline; }
.footer-links a[aria-current="page"] { color: var(--muted); }

/* Breadcrumb trail at the top of server-built pages. */
.crumbs { margin: 20px 0 8px; font-size: 0.85rem; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; list-style: none; margin: 0; padding: 0; color: var(--muted); }
.crumbs li { display: inline-flex; align-items: center; }
.crumbs li + li::before { content: "" / ""; width: 6px; height: 6px; margin: 0 10px 0 8px; opacity: 0.6;
                          border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); }
.crumbs a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.crumbs a:hover, .crumbs a:focus-visible { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.crumbs [aria-current="page"] { color: var(--text); font-weight: 600; }

/* One investment's cost on each platform (pages.py). */
.platform-costs th, .platform-costs td { padding: 10px 12px; vertical-align: middle; }
.platform-costs thead th { font-size: 0.8rem; }
.platform-costs td.num, .platform-costs th.num { white-space: nowrap; }
.platform-costs tbody th { font-weight: 600; color: var(--text); white-space: normal; min-width: 160px; }
.platform-costs .name { display: block; }
.platform-costs td.total { font-weight: 700; }
.platform-costs tr.best > * { background: var(--accent); color: var(--on-accent); }
.platform-costs .tag { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 0.75rem; font-weight: 600; }
.platform-costs .tag.best { color: var(--on-accent); }
.platform-costs .tag.best::before { content: "✓" / ""; }
.platform-costs .tag.check { color: var(--warn); font-weight: 400; }
.platform-costs tr.na > * { color: var(--muted); }
.platform-costs tr.na .name { font-weight: 400; }
.platform-costs .per { display: none; }
.fund-fees { margin-top: 4px; }
.fund-fees th, .fund-fees td { padding: 8px 0; }
.fund-fees th { font-weight: 400; color: var(--text); }
.fund-fees tr:last-child > * { font-weight: 700; border-bottom: none; }

/* Phones: each platform is a compact row (name and total on top, the other figures below), so the
   total never scrolls out of view. */
@media (max-width: 640px) {
  .platform-costs, .platform-costs tbody { display: block; }
  .platform-costs thead { display: none; }
  .platform-costs tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 10px 12px;
                       border-bottom: 1px solid var(--border); }
  .platform-costs tr > * { padding: 0; border: none; background: none !important; box-shadow: none !important; min-width: 0; }
  .platform-costs tr.best { background: var(--accent); color: var(--on-accent); }
  .platform-costs tbody th { flex: 1 1 55%; }
  .platform-costs td.total { margin-left: auto; text-align: right; }
  .platform-costs .per { display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
  .platform-costs td[data-label] { order: 1; font-size: 0.8rem; color: var(--muted); }
  .platform-costs td[data-label]::before { content: attr(data-label) " "; }
  .platform-costs td.why { order: 1; flex-basis: 100%; font-size: 0.85rem; }
}

/* "Did you mean" list on the not-found page. */
.suggest-list { list-style: none; margin: 0; padding: 0; }
.suggest-list li { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--border); }
.suggest-list li:last-child { border-bottom: none; }
.suggest-list a { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; padding: 10px 0; color: var(--text); text-decoration: none; }
.suggest-list a strong { min-width: 3.5em; color: var(--accent-ink); }
.suggest-list .sub { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-list a:hover .sub, .suggest-list a:focus-visible .sub { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.suggest-list .cost { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Links to the server-built pages. */
a.ticker-link { color: inherit; text-decoration: none; }
a.ticker-link:hover strong, a.ticker-link:focus-visible strong { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.platform-costs a.name { color: var(--text); text-decoration: none; }
.platform-costs a.name:hover, .platform-costs a.name:focus-visible { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.platform-costs th .sub { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.link-list a { display: inline-block; padding: 6px 12px; border: 1.5px solid var(--border); text-decoration: none; color: var(--text); font-size: 0.9rem; }
.link-list a:hover, .link-list a:focus-visible { border-color: var(--text); background: var(--accent); color: var(--on-accent); }
a.platform-link { color: inherit; text-decoration: none; }
a.platform-link:hover, a.platform-link:focus-visible { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.footer-platforms { flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 8px; }

/* Dashboard Settings menu (top right of the brand bar) and its modal dialogs (src/settings.js). */
.settings { position: relative; margin-left: auto; }
button.settings-button { background: var(--card); color: var(--text); border-color: var(--input-border); }
.settings-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 180px; margin: 0; padding: 4px;
  list-style: none; background: var(--card); color: var(--text); border: 1px solid var(--input-border); box-shadow: 4px 4px 0 var(--edge); }
.settings-menu button { display: block; width: 100%; text-align: left; background: none; color: inherit; border: none;
  box-shadow: none; transform: none; font-weight: 400; font-stretch: 100%; padding: 8px 10px; min-height: 40px; }
.settings-menu button:hover, .settings-menu button:focus-visible { background: var(--bg); }
dialog.modal { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; background: var(--card);
  color: var(--text); border: 1px solid var(--input-border); box-shadow: 6px 6px 0 var(--edge); }
dialog.modal::backdrop { background: rgb(0 0 0 / 0.45); }
.modal-body { padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { margin: 0; }
.modal .row input { flex: 1; min-width: 0; }
@media (max-width: 640px) {
  .modal-body { padding: 16px; }
  .modal .row { flex-wrap: wrap; }
}
