/* tickerfacts — minimal, fast, system-font styling. Speed is the product, so this
   stays small and ships no JS. */
:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --fg: #e7ecf1;
  --muted: #8b97a4;
  --line: #232a31;
  --accent: #4aa8ff;
  --pos: #3fb950;
  --neg: #f0664b;
  --max: 1040px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Developers / MCP onboarding */
.developers { max-width: 760px; }
.developers h2 { margin-top: 2rem; }
.developers h3 { margin: 1.25rem 0 0.25rem; color: var(--muted); font-size: 0.95rem; }
.developers li { margin: 0.35rem 0; }
.developers code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.85em;
}
.developers pre.code {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.5rem 0 1rem;
}
.developers pre.code code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre;
}
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Links inside running text must not rely on color alone (WCAG 1.4.1):
   underline them. Nav, tabs, table, and button-like links stay clean; they
   are distinguishable by placement. */
p a, li a { text-decoration: underline; }

.site-header {
  display: flex; align-items: center; gap: 1rem;
  max-width: var(--max); margin: 0 auto; padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--fg); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; color: var(--accent); }

form.search { display: flex; gap: 0.4rem; margin-left: auto; }
form.search input {
  background: var(--panel); border: 1px solid var(--line); color: var(--fg);
  padding: 0.45rem 0.6rem; border-radius: 8px; min-width: 220px; font-size: 0.95rem;
}
form.search input:focus { outline: none; border-color: var(--accent); }
form.search button {
  background: var(--accent); color: #04121f; border: 0; border-radius: 8px;
  padding: 0.45rem 0.9rem; font-weight: 600; cursor: pointer;
}

main { max-width: var(--max); margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.hero { text-align: center; padding: 4rem 0 2rem; }
.hero h1 { font-size: 2.4rem; letter-spacing: -0.03em; margin: 0 0 0.5rem; }
.hero .tagline { color: var(--muted); font-size: 1.1rem; margin: 0 0 1.6rem; }
form.search-lg { justify-content: center; margin: 0 auto; }
form.search-lg input { min-width: min(420px, 80vw); padding: 0.7rem 0.9rem; font-size: 1.05rem; }
form.search-lg button { padding: 0.7rem 1.3rem; }
.examples { color: var(--muted); margin-top: 1rem; }

.company-header h1 { font-size: 1.7rem; margin: 0 0 0.25rem; letter-spacing: -0.02em; }
.company-header .ticker { color: var(--muted); font-weight: 500; }
.company-header .meta { color: var(--muted); margin: 0 0 0.6rem; font-size: 0.9rem; }
.company-header .csv-btn { display: inline-block; margin: 0.1rem 0 0.7rem; background: var(--accent); color: #04121f; border-radius: 8px; padding: 0.45rem 0.9rem; font-weight: 600; font-size: 0.9rem; }
.company-header .csv-btn:hover { text-decoration: none; opacity: 0.92; }
.profile-chips {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; padding: 0;
}
.profile-chips li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.2rem 0.7rem; font-size: 0.8rem; color: var(--muted);
}
.profile-chips .k { color: var(--muted); }
.profile-chips .v { color: var(--fg); font-weight: 600; }
.row-sector { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 0.1rem; font-weight: 400; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.financials { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.financials th, table.financials td {
  padding: 0.55rem 0.8rem; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.financials thead th { color: var(--muted); font-weight: 600; background: var(--panel); }
table.financials .metric-col { text-align: left; position: sticky; left: 0; background: var(--bg); }
table.financials thead .metric-col { background: var(--panel); }
table.financials tbody tr:last-child td, table.financials tbody tr:last-child th { border-bottom: 0; }
table.financials tbody tr:hover td, table.financials tbody tr:hover .metric-col { background: var(--panel); }

.empty, .notfound { color: var(--muted); }
.notfound h1 { color: var(--fg); }

/* Make linked metric labels read as part of the table, not loud links. */
table.financials .metric-col a { color: var(--fg); }
table.financials .metric-col a:hover { color: var(--accent); text-decoration: none; }

/* Metric history (long-tail) page */
.crumbs { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.metric-page h1 { font-size: 1.6rem; letter-spacing: -0.02em; margin: 0 0 0.25rem; }
.metric-page .ticker { color: var(--muted); font-weight: 500; }
.metric-page .meta { color: var(--muted); margin: 0 0 1.25rem; font-size: 0.9rem; }
table.metric-history { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.metric-history th, table.metric-history td {
  padding: 0.55rem 0.9rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.metric-history thead th { color: var(--muted); font-weight: 600; background: var(--panel); }
table.metric-history tbody th { text-align: left; font-weight: 500; }
table.metric-history tbody tr:hover td, table.metric-history tbody tr:hover th { background: var(--panel); }
.change .pos { color: var(--pos); }
.change .neg { color: var(--neg); }
.metric-nav { margin-top: 1.5rem; color: var(--muted); font-size: 0.9rem; line-height: 2; }
.metric-nav .label { margin-right: 0.25rem; }
.metric-nav a { margin-right: 0.85rem; white-space: nowrap; }

/* Auto-generated "at a glance" summary */
.summary { font-size: 1.02rem; line-height: 1.6; margin: 0 0 1.25rem; max-width: 70ch; }

/* Key ratios panel (automated analysis on the company page) */
.ratios { margin: 0 0 1.5rem; }
.ratios-title { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 0 0 0.6rem; }
.ratios-title .fy { font-weight: 400; }
.ratio-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem;
}
.ratio {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem;
}
.ratio-val { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ratio-label { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }

/* Price + valuation block (company page) */
.valuation { margin: 0 0 1.25rem; }
.val-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.6rem;
}
.val {
  background: linear-gradient(180deg, rgba(56,189,248,0.07), var(--panel));
  border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem;
}
.val-num { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.val-label { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; text-transform: uppercase; letter-spacing: 0.03em; }
.price-note { color: var(--muted); font-size: 0.78rem; margin: 0.5rem 0 0; }

.nav-link { color: var(--fg); font-size: 0.95rem; }
.nav-link:hover { color: var(--accent); text-decoration: none; }

/* Screener */
.screener h1 { font-size: 1.7rem; letter-spacing: -0.02em; margin: 0 0 0.25rem; }
.screener .meta { color: var(--muted); margin: 0 0 1.1rem; font-size: 0.9rem; }
.screen-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem; margin-bottom: 1rem;
}
.screen-form label { color: var(--muted); font-size: 0.9rem; }
.screen-form input[type="number"], .screen-form select {
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
  padding: 0.35rem 0.5rem; border-radius: 7px; font-size: 0.9rem; margin-left: 0.2rem;
}
.screen-form input[type="number"] { width: 7rem; }
.screen-form button {
  background: var(--accent); color: #04121f; border: 0; border-radius: 8px;
  padding: 0.45rem 1rem; font-weight: 600; cursor: pointer; margin-left: auto;
}
.screener .count { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.6rem; }
table.screen-results { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.screen-results th, table.screen-results td {
  padding: 0.5rem 0.8rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.screen-results thead th { color: var(--muted); font-weight: 600; background: var(--panel); }
table.screen-results .metric-col { text-align: left; }
table.screen-results tbody tr:hover td, table.screen-results tbody tr:hover .metric-col { background: var(--panel); }

/* ---- Screener v2 (parity rebuild) ---- */
.screener { max-width: 1180px; }
.presets { margin: 0 0 0.9rem; font-size: 0.88rem; line-height: 1.9; }
.presets .label { color: var(--muted); }
.presets a {
  display: inline-block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.15rem 0.7rem; margin-right: 0.4rem; color: var(--fg);
}
.presets a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.screen-form {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.9rem 1rem; margin-bottom: 1rem;
}
.filter-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem 0.9rem;
}
.filter-grid label { display: flex; flex-direction: column; gap: 0.2rem; color: var(--muted); font-size: 0.78rem; }
.filter-grid input, .filter-grid select {
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
  padding: 0.35rem 0.5rem; border-radius: 7px; font-size: 0.9rem; width: 100%;
}
.filter-grid select { height: 2rem; }
.filter-grid input:focus, .filter-grid select:focus { outline: none; border-color: var(--accent); }
.filter-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 0.8rem; }
.filter-toggles .check { color: var(--fg); font-size: 0.88rem; }
.filter-toggles button {
  background: var(--accent); color: #04121f; border: 0; border-radius: 8px;
  padding: 0.45rem 1.1rem; font-weight: 600; cursor: pointer; margin-left: auto;
}
.filter-toggles .clear { color: var(--muted); font-size: 0.85rem; }

.screen-bar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 0.6rem; flex-wrap: wrap; gap: 0.5rem; }
.view-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.view-tabs .tab {
  font-size: 0.85rem; color: var(--muted); padding: 0.3rem 0.7rem; border-radius: 7px; border: 1px solid transparent;
}
.view-tabs .tab:hover { color: var(--fg); text-decoration: none; }
.view-tabs .tab.active { color: var(--fg); background: var(--panel); border-color: var(--line); }
.screen-bar .count { color: var(--muted); font-size: 0.9rem; margin: 0; }
.screen-bar .count strong { color: var(--fg); }

table.screen-results { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.88rem; }
table.screen-results th, table.screen-results td {
  padding: 0.4rem 0.7rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.screen-results thead th { background: var(--panel); position: sticky; top: 0; z-index: 1; }
table.screen-results thead th.sortable a { color: var(--muted); font-weight: 600; display: inline-block; }
table.screen-results thead th.sortable a:hover { color: var(--fg); text-decoration: none; }
table.screen-results thead th.active a { color: var(--accent); }
table.screen-results .metric-col { text-align: left; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.screen-results .metric-col a { color: var(--fg); }
table.screen-results td.tk { text-align: left; font-weight: 600; }
table.screen-results tbody tr:hover td, table.screen-results tbody tr:hover .metric-col { background: var(--panel); }
table.screen-results .neg { color: var(--neg); }
table.screen-results .na { color: var(--muted); }
table.screen-results td.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

.pager { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin: 1rem 0 0.4rem; }
.pager a, .pager .cur {
  min-width: 1.9rem; text-align: center; padding: 0.25rem 0.5rem; border-radius: 7px;
  border: 1px solid var(--line); font-size: 0.85rem;
}
.pager a { color: var(--fg); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .cur { background: var(--accent); color: #04121f; border-color: var(--accent); font-weight: 600; }
.per-select { color: var(--muted); font-size: 0.85rem; }
.per-select a { margin: 0 0.15rem; }
.per-select .cur { color: var(--fg); font-weight: 600; margin: 0 0.15rem; }

/* ---- Auth / Account / Error ---- */
.auth { max-width: 420px; }
.auth h1 { font-size: 1.7rem; margin: 0 0 1.2rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.6rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); font-size: 0.9rem; }
.auth-form input { background: var(--panel); border: 1px solid var(--line); color: var(--fg); padding: 0.6rem 0.7rem; border-radius: 8px; font-size: 1rem; }
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth .hint { color: var(--muted); font-size: 0.88rem; margin-top: 0.5rem; }
.auth .or { color: var(--muted); text-align: center; margin: 1rem 0 0.6rem; }
.auth button { background: var(--accent); color: #04121f; border: 0; border-radius: 8px; padding: 0.6rem 1rem; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.google-btn { display: block; text-align: center; background: var(--panel); border: 1px solid var(--line); color: var(--fg); padding: 0.6rem 1rem; border-radius: 8px; }
.google-btn:hover { border-color: var(--accent); text-decoration: none; }

button.secondary { background: var(--panel); border: 1px solid var(--line); color: var(--fg); padding: 0.45rem 1rem; border-radius: 8px; cursor: pointer; font-family: inherit; }
button.secondary:hover { border-color: var(--accent); }

/* Account */
.account h1 { font-size: 1.8rem; margin: 0 0 1.2rem; }
.account-info { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.5rem; max-width: 420px; margin: 0 0 1.2rem; }
.account-info dt { color: var(--muted); }
.account-info dd { margin: 0; font-weight: 500; }
.account .inline { display: inline-block; margin: 0.5rem 0; }
.account details.danger { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.account details.danger summary { color: var(--neg); cursor: pointer; }
.account .danger-btn { background: transparent; border: 1px solid var(--neg); color: var(--neg); padding: 0.45rem 1rem; border-radius: 8px; cursor: pointer; margin-top: 0.5rem; font-family: inherit; }

/* Error page */
.error-page h1 { font-size: 1.6rem; color: var(--fg); }
.error-page { color: var(--muted); }

.site-footer {
  max-width: var(--max); margin: 2rem auto 0; padding: 1rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem;
}

/* Metric chart: server-rendered SVG bars, no JS, no chart library. Colours live
   here rather than inline so the CSP needs no style-src relaxation. The series hue
   is the validated dark-surface categorical blue (OKLCH L 0.55, inside the
   0.48-0.67 band); the site's --accent (#4aa8ff, L 0.715) is too light for a mark
   on this surface and stays a link colour. --pos/--neg are reserved status colours
   and are never a series: a green bar would read as "good", not as data. */
:root { --series-1: #3987e5; }

.chart { margin: 0 0 1.25rem; }
.chart__svg {
  display: block;
  width: 100%;
  /* height follows width so the 720x150 viewBox fills the container. A fixed
     height with preserveAspectRatio="meet" pillarboxes the bars into the middle
     and leaves dead gutters; "none" would stretch the rounded ends and the label. */
  height: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
/* Recessive: a solid hairline, one shade off the surface. Never dashed. */
.chart__zero { stroke: var(--line); stroke-width: 1; }
.chart__bar { fill: var(--series-1); }
.chart__bar:hover { fill: var(--fg); }
/* A loss is still data, not a status. It keeps the series hue and reads as
   negative from its position below the zero rule, not from being red. */
.chart__bar--neg { fill: var(--series-1); opacity: 0.55; }
.chart__peak {
  fill: var(--muted);           /* text wears text tokens, never the series colour */
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart__cap {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0.1rem 0;
}
