:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #16191f;
  --muted: #667085;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --up: #12805c;
  --down: #c8372d;
  --warn-bg: #fff6e0;
  --warn-border: #f1c75b;
  --error-bg: #fdecea;
  --error-border: #f0a29b;
  --ok-bg: #e8f6ef;
  --ok-border: #8fd1b1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  /* Secondary text that is read, not just glanced at (leads, times, sources). */
  --secondary: #4d5566;
  --pill-bg: #f6f7f9;
  --pill-border: #e3e6eb;
  --logo-bg: #ffffff;
  --logo-filter: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --border: #2a2f3a;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --accent: #6b8cff;
    --accent-text: #0f1115;
    --up: #3ccf91;
    --down: #ff6b5e;
    --warn-bg: #2b2412;
    --warn-border: #6e5a1e;
    --error-bg: #2d1615;
    --error-border: #6f2a25;
    --ok-bg: #12261d;
    --ok-border: #24573f;
    --shadow: none;
    --secondary: #b6bdc9;
    --pill-bg: #232835;
    --pill-border: #363d4b;
    /* Logos often come on white; a dimmed light disc keeps them from glaring. */
    --logo-bg: #dfe3e8;
    --logo-filter: brightness(0.9);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
h1, h2 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
code { font-size: 0.92em; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
small { font-size: 0.82em; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, calc((100% - 1120px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.topbar nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 8px; }
footer { max-width: 1120px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 13px; }

.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.footnote { color: var(--muted); font-size: 13px; margin: 24px 0 8px; }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button:disabled { opacity: 0.7; cursor: progress; }

.hero, .card, .account, .panel, .empty {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 20px 24px; }
.big { margin: 4px 0 0; font-size: 34px; font-weight: 700; letter-spacing: -0.01em; }
.ccy { font-size: 0.55em; font-weight: 600; color: var(--muted); }
.sub { margin: 4px 0 0; font-weight: 600; }
.refresh { text-align: right; }

.notice { margin: 16px 0 0; padding: 12px 16px; border-radius: 10px; border: 1px solid; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.notice.error { background: var(--error-bg); border-color: var(--error-border); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-border); margin-bottom: 16px; }
.pill { display: inline-block; margin: 2px 0 2px 6px; padding: 0 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 16px 0; }
.card { display: block; padding: 16px 20px; color: var(--text); }
.card:hover { border-color: var(--accent); }
.card .value { margin: 4px 0 8px; font-size: 22px; font-weight: 700; }
.card dl { margin: 0; display: grid; gap: 2px; }
.card dl div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-weight: 600; text-align: right; }

.account { padding: 16px 20px; margin: 16px 0; scroll-margin-top: 72px; }
/* Account tiles open their holdings below the tiles, one at a time. */
html:not(.js) .account:target { display: block; }  /* without JavaScript the link still opens it */
.card.toggle .label { display: flex; justify-content: space-between; align-items: center; }
.card .chevron { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform 0.15s; margin-right: 2px; }
.card[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.card[aria-expanded="true"] .chevron { transform: rotate(-135deg); border-color: var(--accent); }
.card .more { margin: 8px 0 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.card .more .hide, .card[aria-expanded="true"] .more .show { display: none; }
.card[aria-expanded="true"] .more .hide { display: inline; }
.panel { padding: 20px 24px; margin: 0 0 16px; }
.empty { padding: 40px 24px; text-align: center; }
.empty p { color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.num { text-align: right; white-space: nowrap; }
tbody tr:hover { background: var(--bg); }
tfoot td { border-bottom: 0; color: var(--muted); font-weight: 600; }
.name { display: block; font-weight: 600; }
.ticker, .date { display: block; color: var(--muted); font-size: 12px; }
tr.sub td { border-bottom: 0; padding-top: 0; font-size: 13px; }

.upload { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin: 16px 0 0; }
.drop {
  flex: 1 1 260px; position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 12px 16px; border: 2px dashed var(--border); border-radius: 10px;
  color: var(--muted); cursor: pointer; text-align: center; overflow-wrap: anywhere;
}
.drop:hover { border-color: var(--accent); color: var(--text); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Phones: the holdings table turns into one card per position. */
@media (max-width: 720px) {
  main { padding: 16px 16px 8px; }
  .hero { padding: 16px; align-items: stretch; }
  .refresh { text-align: left; width: 100%; }
  .refresh .button { width: 100%; }
  .big { font-size: 28px; }
  .account { padding: 12px 16px; }
  table.holdings thead { display: none; }
  table.holdings, table.holdings tbody, table.holdings tfoot, table.holdings tr, table.holdings td { display: block; width: 100%; }
  table.holdings tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.holdings td { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; border: 0; text-align: right; }
  table.holdings td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  table.holdings td:first-child { display: block; text-align: left; margin-bottom: 4px; }
  table.holdings td:first-child::before, table.holdings td:empty { display: none; }
  table.holdings td .cell { text-align: right; }
  table.holdings td .date { display: inline; margin-left: 6px; }
  table.holdings tfoot tr { border-bottom: 0; }
  table.plain th, table.plain td { padding: 8px 4px; }
}

/* Step 4: charts, figures, tabs, results tables. */
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h1 { margin: 2px 0 0; }
.panel h2 { margin-bottom: 12px; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.figure { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.figure .amount { margin: 4px 0 0; font-size: 18px; font-weight: 700; }
.figure .meta { margin-top: 2px; }
.chart-box { position: relative; }
.chart { width: 100%; }
.chart-empty { padding: 24px 0; text-align: center; }
.ranges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.ranges button {
  min-height: 32px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ranges button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; min-height: 22px; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.legend strong { color: var(--text); }
.chart-key { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.key { font-weight: 700; margin-left: 8px; }
.key.buy { color: var(--up); }
.key.sell { color: var(--down); }
.key.avg { color: var(--text); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 16px; }
.tabs a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.card.placeholder { border-style: dashed; }
.card.placeholder .value { font-size: 18px; }
details summary { cursor: pointer; color: var(--accent); margin: 12px 0 4px; font-weight: 600; }
a.name { color: var(--text); }
a.name:hover { color: var(--accent); }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--border); }
.tag.buy, .tag.received { color: var(--up); }
.tag.sell { color: var(--down); }

@media (max-width: 720px) {
  .figures { grid-template-columns: 1fr 1fr; gap: 8px; }
  .figure { padding: 10px; }
  .figure .amount { font-size: 15px; }
  .panel { padding: 16px; }
  /* Period tables stay tables on phones, with only period, profit and return. */
  table.periods .optional { display: none; }
  table.periods th, table.periods td { padding: 8px 4px; }
}

/* PPE entry forms */
.forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 8px; }
.entry { display: grid; gap: 10px; align-content: start; padding: 16px; border: 1px solid var(--border); border-radius: 10px; }
.entry h3, .panel h3 { margin: 0; font-size: 15px; }
.panel h3 { margin: 16px 0 4px; }
.entry label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.entry input, .entry textarea {
  min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-weight: 400;
}
.entry textarea { resize: vertical; }
.entry.plan { margin-top: 12px; max-width: 560px; }
.entry .button { justify-self: start; }
.link-button { border: 0; background: none; color: var(--down); font: inherit; cursor: pointer; padding: 0; }

.notice .gaps { margin: 6px 0; padding-left: 20px; }

/* Reports and news */
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent);
  color: var(--accent-text); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.tabs a[aria-current="page"] .count { background: var(--accent-text); color: var(--accent); }
.news-tabs { margin: 8px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chips a { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--pill-border); color: var(--secondary); font-size: 13px; font-weight: 600; }
.chips a[aria-current="true"] { border-color: var(--accent); color: var(--accent); background: var(--bg); }
h2.day { margin: 20px 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-item time { color: var(--secondary); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 2px; }
/* About 80 characters a line: a long line is hard to follow back to the next one. */
.feed-body { max-width: 46rem; }
.feed-title { color: var(--text); font-weight: 600; font-size: 16px; line-height: 1.4; }
.feed-title:hover { color: var(--accent); }
.feed-item.new .feed-title::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.feed-meta { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--secondary); font-size: 12px; }
.ticker-pill { padding: 0 6px; border-radius: 4px; background: var(--pill-bg); border: 1px solid var(--pill-border); color: var(--text); font-weight: 700; }
.feed-meta .type { font-weight: 600; }
.feed-meta .flag { color: var(--down); font-weight: 700; }
.badge-new { color: var(--accent); font-weight: 700; }
.empty-feed { padding: 24px 0; }
.feed.compact .feed-item { padding: 8px 0; grid-template-columns: 64px 1fr; gap: 8px; }
.feed.compact .feed-meta { margin-top: 3px; }
.feed.compact .feed-title { font-size: 14px; }
.latest-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.latest-columns h3 { margin: 4px 0 4px; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.more-link { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 600; }
.entry.query { margin-top: 8px; max-width: 560px; }
@media (max-width: 720px) {
  .latest-columns { grid-template-columns: 1fr; gap: 12px; }
  .feed-item { grid-template-columns: 44px 1fr; gap: 8px; }
}
/* The menu does not fit beside the name on a phone; Pulpit leads home anyway. */
@media (max-width: 480px) {
  .topbar .brand { display: none; }
  .topbar nav { width: 100%; justify-content: space-between; gap: 0; }
  .topbar nav a { padding: 6px 7px; font-size: 14.5px; }
}
@media (max-width: 360px) { .topbar nav a { padding: 6px 4px; font-size: 13.5px; } }
/* Company logos next to tickers; light backing so dark logos stay visible in dark mode. */
.logo { width: 16px; height: 16px; border-radius: 50%; object-fit: contain; flex: none;
  background: var(--logo-bg); box-shadow: 0 0 0 1px var(--pill-border); filter: var(--logo-filter); }
.ticker-pill, .chips a { display: inline-flex; align-items: center; gap: 5px; }
.ticker-pill .logo { width: 15px; height: 15px; }
.feed-lead { margin: 6px 0 0; color: var(--secondary); font-size: 14.5px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 720px) { .feed-lead { -webkit-line-clamp: 2; font-size: 13px; } }

/* Financial ratios: tiles, the quarterly table and the comparison of companies. */
.figures-title { margin: 18px 0 4px; font-size: 15px; }
.ratio-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 4px; }
.figure.ratio .amount { font-size: 20px; }
.figure .changes { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; }
.table-scroll { overflow-x: auto; margin: 8px 0 0; -webkit-overflow-scrolling: touch; }
.results-table, .ratios-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.results-table th, .results-table td, .ratios-table th, .ratios-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.results-table thead th, .ratios-table thead th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-align: right; position: sticky; top: 0; background: var(--surface); }
.results-table thead th:first-child, .ratios-table thead th:first-child { text-align: left; }
.results-table tbody th, .ratios-table tbody th { text-transform: none; letter-spacing: normal; font-size: 14px; color: var(--text); }
.results-table tbody th { text-align: left; font-weight: 500; position: sticky; left: 0; background: var(--surface); }
.results-table tr.group th { padding-top: 14px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 0; }
.results-table tr[data-metric] { cursor: pointer; }
.results-table tr[data-metric]:hover td, .results-table tr[data-metric]:hover th { background: var(--pill-bg); }
.results-table tr[aria-selected="true"] th { color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.results-table tr[aria-selected="true"] td { background: var(--pill-bg); }
.results-table td:nth-last-child(2) { border-left: 1px solid var(--border); }
.change-col { font-size: 13px; }
.metric-chart { margin-top: 8px; }
.ratios-table thead th[data-sort] { cursor: pointer; user-select: none; }
.ratios-table thead th[aria-sort="descending"]::after { content: " ↓"; }
.ratios-table thead th[aria-sort="ascending"]::after { content: " ↑"; }
.ratios-table tbody th { text-align: left; font-weight: 400; }
.ratios-table .company { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.ratios-table .ticker { display: block; color: var(--secondary); font-size: 12.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ratios-table td { vertical-align: top; }
.cell-changes { display: block; font-size: 11.5px; line-height: 1.35; }
.cell-changes span { display: block; }
.ratios-table td.uncertain { color: var(--muted); text-decoration: underline dotted; }
.warn-text { color: var(--down); }
@media (max-width: 720px) {
  .figure.ratio .meta:not(.changes) { display: none; }
  .figure.ratio { padding: 10px 12px; }
}

/* Sign-in page and the sign-out link in the footer. */
.panel.login { max-width: 420px; margin: 48px auto; }
.panel.login h1 { margin-top: 0; }
.panel.login .entry { margin-top: 12px; }
footer .logout { display: inline; margin-left: 8px; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
