:root {
  --bg: #f6f7f9; --surface: #ffffff; --ink: #1c2330; --muted: #667085; --line: #e3e6ec;
  --accent: #2f5fd0; --accent-soft: #e8eefb; --good: #1f7a4d; --good-soft: #e5f4ec;
  --warn: #9a6200; --warn-soft: #fbf1dc; --bad: #a8362f; --bad-soft: #f8e6e4;
  --chart-grid: #eceff4; --chart-text: #667085;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1a1e26; --ink: #e8eaef; --muted: #98a2b3; --line: #2a303b;
    --accent: #7c9cf2; --accent-soft: #232c45; --good: #5fcf98; --good-soft: #17301f;
    --warn: #e5b44f; --warn-soft: #33290f; --bad: #f08a82; --bad-soft: #351b19;
    --chart-grid: #232832; --chart-text: #98a2b3; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .num { font-variant-numeric: tabular-nums; text-align: right; }

/* shell */
.topbar { display: flex; gap: 1.25rem; align-items: center; padding: .6rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 650; color: var(--ink); letter-spacing: .01em; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a, .nav span { padding: .35rem .7rem; border-radius: 7px; color: var(--muted); }
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .soon { opacity: .6; cursor: default; }
.nav .soon::after { content: " soon"; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.search { position: relative; }
.search input { width: 16rem; max-width: 40vw; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.suggestions { position: absolute; right: 0; top: 2.4rem; width: 22rem; max-width: 90vw; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); z-index: 20; }
.suggestions a { display: flex; gap: .6rem; padding: .5rem .8rem; color: var(--ink); }
.suggestions a:hover { background: var(--accent-soft); text-decoration: none; }
.suggestions .empty { padding: .6rem .8rem; color: var(--muted); }
.layout { display: grid; grid-template-columns: 15rem 1fr; gap: 1.25rem; padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
.sidebar h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .4rem; }
.sidebar h3:first-child { margin-top: 0; }
.sidebar p { margin: .2rem 0 0; }
main { min-width: 0; }
.footer { color: var(--muted); font-size: .8rem; padding: 1rem 1.25rem 2rem; text-align: center; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .sidebar { order: 2; }
  .search input { width: 10rem; } .topbar { flex-wrap: wrap; } }

/* cards, tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; } .grid.two { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .45rem .5rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* chips, meters */
.chip { display: inline-flex; gap: .35rem; align-items: baseline; padding: .15rem .55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink); font-size: .85rem; white-space: nowrap; }
.chip b { font-weight: 650; }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.plain { background: var(--bg); border: 1px solid var(--line); }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 4rem; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.rating { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; min-width: 9.5rem; }
.rating .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rating .value { font-size: 1.7rem; font-weight: 650; line-height: 1.1; }
.rating .sub { font-size: .8rem; color: var(--muted); }

/* stock header + tabs */
.stock-head { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: flex-start; }
.stock-title .symbol { font-size: 1.6rem; font-weight: 700; } .stock-title .price { font-size: 1.3rem; font-weight: 600; margin-left: .8rem; }
.up { color: var(--good); } .down { color: var(--bad); }
.ratings { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .9rem; }
.badges { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: .5rem 0 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .8rem 1.2rem; }
.kv div span { display: block; } .kv .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kv .v { font-size: 1.05rem; font-weight: 600; }
ul.plain { margin: .3rem 0; padding-left: 1.1rem; } ul.plain li { margin: .15rem 0; }
.plus::marker { content: "+  "; color: var(--good); } .minus::marker { content: "–  "; color: var(--bad); }
.chart { width: 100%; height: 420px; } .chart.small { height: 280px; }
.pills { display: inline-flex; gap: .25rem; margin-bottom: .6rem; }
.pills button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .25rem .75rem; border-radius: 999px; cursor: pointer; font: inherit; }
.pills button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.note { background: var(--warn-soft); color: var(--warn); padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.attribution { font-size: .75rem; color: var(--muted); margin-top: .4rem; }
details > summary { cursor: pointer; color: var(--accent); }

/* statements, links as pills, news */
a.pill { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .25rem .75rem; border-radius: 999px; }
a.pill:hover { text-decoration: none; background: var(--accent-soft); }
a.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
table.statement td:first-child, table.statement th:first-child { position: sticky; left: 0; background: var(--surface); }
ul.news { list-style: none; padding-left: 0; } ul.news li { padding: .5rem 0; border-bottom: 1px solid var(--line); } ul.news li:last-child { border-bottom: 0; }
.chip.small { font-size: .7rem; padding: .05rem .4rem; }

/* glossary links: quiet dotted underline so tables stay readable */
a.gl { color: inherit; text-decoration: underline; text-decoration-color: var(--accent, #2563eb); text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: help; }
a.gl:hover { color: var(--accent, #2563eb); }
ul.points li { margin: .35rem 0; }
.def h3 { margin: 1rem 0 .2rem; }
.def p { margin: .1rem 0; }
.gloss-list { columns: 2 18rem; column-gap: 2rem; }
.gloss-list li { break-inside: avoid; }

.filters { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: flex-end; margin-top: .8rem; }
.filters fieldset { border: 0; padding: 0; margin: 0; }
.filters legend { font-size: .8rem; color: var(--muted, #666); padding: 0; margin-bottom: .2rem; }
.filters label { margin-right: .6rem; white-space: nowrap; }

.flash { background: var(--good-soft, #e7f6ec); border: 1px solid var(--line, #ddd); border-radius: 8px; padding: .6rem .9rem; margin-bottom: 1rem; }
.flash.error { background: var(--bad-soft, #fdeaea); }
.badge { background: var(--accent, #2563eb); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .72rem; }
.side-list { margin: .25rem 0; }
.add-to-list { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; margin-bottom: .4rem; }
table.progress th.group { text-align: center; border-bottom: 1px solid var(--line, #ddd); }
.spark { display: block; }

table.progress { font-size: .82rem; }
table.progress th, table.progress td { padding: .3rem .4rem; white-space: nowrap; }
table.progress td .chip { margin-left: .15rem; }
table.progress .name { display: block; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }

.wl-bar { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; margin-bottom: .75rem; }
.wl-bar .pills { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
table.wl th.sortable { cursor: pointer; } table.wl th.sortable:hover { color: var(--ink); }
table.wl tbody.wlrow { border-top: 1px solid var(--line); }
table.wl td, table.wl th { border-bottom: 0; vertical-align: middle; }
table.wl .stockcell { min-width: 9rem; } table.wl .stockcell span { display: block; }
table.wl td.sc { min-width: 5.2rem; text-align: center; background: color-mix(in srgb, var(--heatc, transparent) var(--heat, 0%), transparent); border-radius: 8px; }
table.wl td.sc .big { font-size: 1.25rem; font-weight: 650; line-height: 1.2; }
table.wl td.sc .chg { font-size: .8rem; min-height: 1.1rem; white-space: nowrap; }
table.wl .bbcell div { white-space: nowrap; }
table.wl button.expand { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .2rem .5rem; }
table.wl .detailrow td { background: var(--bg); border-radius: 8px; padding: .8rem 1rem; }
.detailgrid { display: grid; grid-template-columns: minmax(18rem, 2fr) 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 800px) { .detailgrid { grid-template-columns: 1fr; } }
table.inner th, table.inner td { padding: .2rem .5rem; border-bottom: 1px solid var(--line); }
table.inner th:first-child { text-transform: none; font-size: .85rem; color: var(--ink); }
.noteform { display: flex; gap: .4rem; } .noteform input[type=text] { flex: 1; min-width: 8rem; }

.linechart { width: 100%; height: auto; max-height: 320px; }
.linechart .grid { stroke: var(--chart-grid); stroke-width: 1; } .linechart .axis { fill: var(--chart-text); font-size: 11px; }
.swatch { display: inline-block; width: 1.6rem; border-top: 3px solid; vertical-align: middle; margin-right: .4rem; }
table.wl .poscell { white-space: nowrap; min-width: 8rem; line-height: 1.35; }
.chip.real { background: var(--warn-soft); color: var(--warn); } .chip.paper { background: var(--accent-soft); color: var(--accent); }
.kpis { display: flex; flex-wrap: wrap; gap: .5rem 2rem; } .kpis div span { display: block; } .kpis .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpis .v { font-size: 1.25rem; font-weight: 650; }

.lead { font-size: 1.1rem; margin: 0 0 .75rem; }
.kpis .v.small { font-size: 1rem; }

/* portfolio sheet */
.crumbs { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; } .crumbs select { margin-left: .35rem; }
.sheet-toolbar { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.sheet-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
table.sheet { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .85rem; }
table.sheet th, table.sheet td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.sheet thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; border-bottom: 2px solid var(--line); }
table.sheet tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
table.sheet tbody tr:hover td { background: var(--accent-soft); }
table.sheet tfoot td { font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; background: var(--bg); }
table.sheet .name { display: block; max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
table.sheet .grp { border-left: 2px solid var(--line); }
.addbar { padding: .6rem 1rem; } .addrow { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin: .25rem 0; }
.addrow b { min-width: 6.5rem; }
button.linkish { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* review flags */
ul.flags { list-style: none; margin: .5rem 0; padding: 0; }
ul.flags li { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .55rem 0; border-top: 1px solid var(--line); }
ul.flags li:first-child { border-top: 0; }
.flagcard { border-left: 3px solid var(--warn); }

/* transaction editing */
td.txactions { white-space: normal; }
details.txedit { display: inline-block; margin-right: .6rem; vertical-align: top; }
details.txedit[open] { display: block; margin-bottom: .4rem; }
details.txedit summary { cursor: pointer; list-style: none; display: inline; color: var(--accent); }

/* sign-in pages and account menu */
body.authpage { display: flex; justify-content: center; padding: 3rem 1rem; }
.authbox { width: 100%; max-width: 26rem; }
.stackform { display: flex; flex-direction: column; gap: .75rem; }
.stackform label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.stackform input[type=text], .stackform input[type=password] { padding: .5rem .6rem; font: inherit; }
button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.usermenu { white-space: nowrap; color: var(--muted); }
.flash.error { background: var(--bad-soft); color: var(--bad); }

/* screener: dropdown layout, hints, extra filters */
.filters fieldset select { min-width: 8.5rem; }
.hint { display: block; max-width: 15rem; margin-top: .2rem; font-size: .74rem; color: var(--muted, #666); line-height: 1.25; }
.presets { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .8rem; }
.morefilters { flex-basis: 100%; }
.morefilters summary { cursor: pointer; color: var(--accent, #2563eb); font-size: .9rem; }
.morefilters .inner { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line, #e5e7eb); }
.formactions { flex-basis: 100%; display: flex; gap: 1rem; align-items: center; }
.howto { margin: -.2rem 0 .6rem; }
.welcome { border-left: 4px solid var(--accent, #2563eb); }
table.whatif { width: auto; min-width: 22rem; }
