:root {
  --bg: #fafaf8; --surface: #ffffff; --text: #1c1d1f; --muted: #6b6f76; --line: #e6e5e1;
  --accent: #1f5f8b; --accent-soft: #e8f0f6; --up: #1d7a46; --down: #b3261e;
  --badge-bg: #eeede9; --shadow: 0 1px 2px rgba(0,0,0,.06);
  /* charts: colour-blind-checked series pair (blue / orange) + red for "selling" */
  --series-1: #2a78d6; --series-2: #eb6834; --series-neg: #e34948; --chart-grid: #e1e0d9; --chart-axis: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517; --surface: #1c1e21; --text: #e8e9eb; --muted: #9a9ea6; --line: #2e3136;
    --accent: #7fb6dd; --accent-soft: #1f2d38; --up: #5cc48a; --down: #f0857c;
    --badge-bg: #2a2d31; --shadow: none;
    --series-1: #3987e5; --series-2: #d95926; --series-neg: #e66767; --chart-grid: #2c2c2a; --chart-axis: #383835;
  }
}
* { 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; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.6rem; margin: 1.2rem 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 2rem 0 .6rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.small { font-size: .85rem; }
.up { color: var(--up); } .down { color: var(--down); }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); letter-spacing: .02em; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: var(--muted); padding: 6px 12px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }

/* hero / about */
.hero { padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: 2rem; }
.lede { font-size: 1.1rem; max-width: 760px; color: var(--muted); }
.prose { max-width: 780px; }
.prose li { margin: .35rem 0; }
.disclaimer { margin-top: 2rem; color: var(--muted); font-size: .9rem; }
.cta { margin: 1.2rem 0; display: flex; gap: 10px; flex-wrap: wrap; }
.button { display: inline-block; background: var(--accent); color: var(--surface); padding: 8px 16px; border-radius: 8px; font-weight: 600; }
.button:hover { text-decoration: none; opacity: .9; }

/* stats */
.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px;
        min-width: 150px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-label span { display: block; }
.stat-changes { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; max-width: 360px; }
.stat-changes b { font-size: 1.15rem; }
.note { background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; }

/* entity header */
.entity-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.entity-head h1 { margin-bottom: .1rem; }
.ticker-big { font-size: 1rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line);
              border-radius: 6px; padding: 2px 8px; vertical-align: middle; }
.quarter-picker select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
                         background: var(--surface); color: var(--text); margin-left: 6px; }

/* company profile under a security's name */
.profile { margin: .2rem 0 .6rem; }
.profile-desc { margin: 0 0 .4rem; font-size: 1.02rem; max-width: 760px; }
.profile-facts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: .9rem; }
.profile-facts li span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
/* a manager's corporate family (GLEIF) and the other managers its report includes */
.family { margin: .45rem 0 0; font-size: .88rem; max-width: 900px; line-height: 1.6; }
details.family summary, .included summary { color: var(--accent); cursor: pointer; }
.included { font-size: .88rem; margin: .7rem 0 .2rem; max-width: 900px; }
.included p { margin: 0 0 .2rem; }
.included ul { margin: 0 0 .3rem; padding-left: 1.2rem; }
.included li { margin: .1rem 0; }

/* search */
.search { position: relative; display: flex; gap: 8px; max-width: 560px; margin: 1rem 0; }
.search input { flex: 1; font: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
                background: var(--surface); color: var(--text); }
.search button { font: inherit; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
                 background: var(--surface); color: var(--text); cursor: pointer; }
.suggestions { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none;
               background: var(--surface); border: 1px solid var(--line); border-radius: 8px; z-index: 20;
               box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.suggestions li a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.suggestions li a:hover, .suggestions li a.sel { background: var(--accent-soft); text-decoration: none; }
.suggestions .detail { color: var(--muted); font-size: .85rem; }
.suggestions .extra { color: var(--muted); font-size: .85rem; white-space: nowrap; }

/* tables */
.data { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line);
        border-radius: 10px; overflow: hidden; font-variant-numeric: tabular-nums; }
.data th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
           font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tr:last-child td { border-bottom: none; }
.data .num { text-align: right; white-space: nowrap; }
.data .rank { color: var(--muted); width: 1%; }
.data .ticker { font-weight: 600; white-space: nowrap; }
.data .sub { display: block; color: var(--muted); font-size: .8rem; }
.data.compact td { padding: 5px 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: .2rem 0 .8rem; }
.tabs a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 12px 0; color: var(--muted); }

/* change badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px;
         background: var(--badge-bg); color: var(--muted); white-space: nowrap; }
.badge-new, .badge-added { color: var(--up); }
.badge-reduced, .badge-exited { color: var(--down); }

.footer { color: var(--muted); font-size: .8rem; padding: 2rem 16px 3rem; border-top: 1px solid var(--line); margin-top: 3rem; }
.footer p { margin: 0 0 .5rem; max-width: 780px; }
.table-wrap { overflow-x: auto; }

/* charts (drawn on the server as inline SVG: see webapp/charts.py) */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; margin: .4rem 0 1rem; }
.charts.one { grid-template-columns: minmax(0, 420px); }   /* a lone chart keeps the size it has beside others */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 8px;
              box-shadow: var(--shadow); min-width: 0; }
.chart-card h3 { font-size: .95rem; margin: 0; }
.chart-sub { color: var(--muted); font-size: .8rem; margin: 2px 0 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.s1 { background: var(--series-1); } .legend i.s2 { background: var(--series-2); } .legend i.neg { background: var(--series-neg); }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg.chart text.val { fill: var(--text); }
svg.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--chart-axis); stroke-width: 1; }
svg.chart .s1 { fill: var(--series-1); } svg.chart .s2 { fill: var(--series-2); } svg.chart .neg { fill: var(--series-neg); }
svg.chart rect:hover { opacity: .8; }
svg.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover { fill: var(--series-1); fill-opacity: .15; }
svg.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.spark { display: block; width: 64px; height: 18px; margin-top: 4px; }
svg.spark path { fill: none; stroke: var(--series-1); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
svg.spark circle { fill: var(--series-1); }
details.chart-data { margin-top: 2px; }
details.chart-data summary { font-size: .75rem; color: var(--muted); cursor: pointer; }
details.chart-data table { width: 100%; border-collapse: collapse; font-size: .8rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
details.chart-data th, details.chart-data td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; }
details.chart-data th { color: var(--muted); font-weight: 600; }
details.chart-data .num { text-align: right; }
/* a 13D holder's stated purpose, folded away under its name */
details.purpose { font-size: .8rem; color: var(--muted); margin-top: 3px; max-width: 640px; }
details.purpose summary { color: var(--accent); cursor: pointer; }   /* a table that is still too wide scrolls by itself, never the page */

/* Phones: tables drop secondary columns (.hide-sm) and show the essentials as small lines under the
   main cells instead (.sm); stat cards go two per row. */
@media (min-width: 641px) {
  .sm { display: none !important; }
}
@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .hero h1 { font-size: 1.5rem; }
  .topbar-inner { gap: 12px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
  .hero h1 { font-size: 1.45rem; }
  .lede { font-size: 1rem; }
  .topbar-inner { height: 52px; gap: 10px; }
  .brand { font-size: 1rem; }
  .topbar nav { gap: 2px; }
  .topbar nav a { padding: 6px 8px; }
  /* 16px or larger, otherwise iPhones zoom the page in when the field is tapped */
  .search input, .search button, .quarter-picker select { font-size: 16px; }
  .stat-row { gap: 10px; }
  .stat { flex: 1 1 calc(50% - 5px); min-width: 0; padding: 10px 12px; }
  .stat-value { font-size: 1.15rem; }
  .stat-changes { flex-basis: 100%; max-width: none; }
  .data { font-size: .9rem; }
  .data th { font-size: .7rem; padding: 7px 8px; }
  .data td, .data.compact td { padding: 7px 8px; }
  .data td a { overflow-wrap: anywhere; }
  .badge { font-size: .7rem; padding: 1px 6px; }
}
@media (max-width: 359px) {
  .topbar-inner { gap: 6px; }
  .topbar nav a { padding: 6px 5px; font-size: .9rem; }
}
