/* Inflect — stock screener. One stylesheet, no inline styles (CSP style-src 'self').
   Palette validated with the dataviz skill's validator (scripts/validate_palette.js), 2026-11-08:
   light series #2a78d6 #eb6834 #1baf7a · dark series #3987e5 #d95926 #199e70 · surfaces #fcfcfb / #1a1a19. */
:root {
  --bg: #fcfcfb; --bg-2: #f3f3f1; --bg-3: #e9e9e6; --line: #dcdcd8; --line-2: #c9c9c4;
  --ink: #1b1b1a; --ink-2: #4e4e4b; --ink-3: #7a7a76;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --good: #0ca30c; --warn: #b7791f; --bad: #d03b3b; --good-bg: #e7f6e7; --bad-bg: #fbe9e9; --warn-bg: #fdf3e2;
  --link: #1f5fb0; --focus: #2a78d6;
  --radius: 8px; --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a19; --bg-2: #232322; --bg-3: #2d2d2b; --line: #3a3a37; --line-2: #4a4a46;
    --ink: #ececea; --ink-2: #b9b9b4; --ink-3: #8c8c87;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --good: #3fc43f; --warn: #d9a04a; --bad: #e35d5d; --good-bg: #1d2f1d; --bad-bg: #3a2020; --warn-bg: #3a2f1a;
    --link: #6aa6ef; --focus: #3987e5;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* header */
.top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
.top nav { margin-left: auto; display: flex; gap: 6px; font-size: 14px; }
.top nav a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px; }
.brand { min-height: 44px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 14px 16px 40px; }
h1 { font-size: 22px; margin: 6px 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 26px 0 8px; }
h3 { font-size: 15px; margin: 18px 0 6px; }
.lede { color: var(--ink-2); margin: 0 0 12px; max-width: 70ch; }

/* index tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.tab { flex: 0 0 auto; border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 8px 14px; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab .n { font-size: 12px; opacity: 0.75; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin: 6px 0 14px; }
.filters label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.filters input[type="search"], .filters select, .filters input[type="number"] { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); color: var(--ink); }
.filters input[type="search"] { width: 180px; }
.filters input[type="number"] { width: 72px; }
.filters input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--s1); }
.filters .count { margin-left: auto; color: var(--ink-2); font-size: 13px; }
.view { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.view button { min-height: 40px; min-width: 44px; padding: 0 12px; border: 0; background: var(--bg); color: var(--ink); }
.view button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* heat map */
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 3px; }
.cell { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; min-height: 52px; padding: 6px 7px; border-radius: 4px; color: #fff; text-decoration: none; border: 0; text-align: left; }
.cell:hover, .cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; text-decoration: none; }
.cell .t { font-weight: 700; font-size: 13px; line-height: 1.1; }
.cell .s { font-size: 12px; opacity: 0.95; font-variant-numeric: tabular-nums; }
.cell.ink-dark { color: #111; }
.cell.na { background: var(--bg-3); color: var(--ink-3); }
.cell .hv { position: absolute; inset: 0; }
.legend-scale { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend-scale .bar { height: 12px; width: 220px; border-radius: 3px; background: linear-gradient(90deg, #c23b3b 0%, #e59a8a 30%, #bdbdb8 50%, #86c58d 70%, #158a3e 100%); }

/* ranked table */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { text-align: left; font-weight: 600; color: var(--ink-2); background: var(--bg-2); position: sticky; top: 0; }
th.num { text-align: right; }
th button { background: none; border: 0; padding: 0; color: inherit; font-weight: 600; min-height: 28px; }
th button:hover { text-decoration: underline; }
th[aria-sort="descending"] button::after { content: " ↓"; }
th[aria-sort="ascending"] button::after { content: " ↑"; }
tbody tr:hover { background: var(--bg-2); }
td.name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line-2); color: var(--ink-2); }
.score { display: inline-block; min-width: 34px; text-align: center; padding: 2px 6px; border-radius: 5px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.score.na { background: var(--bg-3); color: var(--ink-3); font-weight: 500; }
.flag { color: var(--warn); }

/* states */
.empty { padding: 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--ink-2); max-width: 760px; }
.empty code, .steps code { font-family: var(--mono); font-size: 13px; background: var(--bg-3); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.steps { padding-left: 20px; }
.steps li { margin: 4px 0; }
.note { font-size: 13px; color: var(--ink-2); margin: 8px 0; }
.source { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }

/* company page */
.hero { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; margin-bottom: 8px; }
.hero h1 { margin: 0; }
.hero .meta { color: var(--ink-2); font-size: 14px; }
.hero .scorebig { margin-left: auto; text-align: right; }
.hero .scorebig .score { font-size: 26px; padding: 6px 14px; }
.hero .scorebig .small { display: block; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--bg-2); }
.tile .k { font-size: 12px; color: var(--ink-3); }
.tile .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .v.na { font-weight: 500; color: var(--ink-3); font-size: 15px; }
.tile .w { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.tile.good { border-color: var(--good); } .tile.bad { border-color: var(--bad); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status.good { color: var(--good); } .status.bad { color: var(--bad); } .status.warn { color: var(--warn); }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.status.bad::before { border-radius: 1px; } .status.warn::before { border-radius: 1px; transform: rotate(45deg); }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin: 10px 0 14px; position: sticky; top: 56px; z-index: 4; }
.controls label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.controls input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--s1); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { min-height: 40px; min-width: 44px; padding: 0 12px; border: 0; background: var(--bg); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.chart { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 8px; background: var(--bg); min-width: 0; }
.chart header { display: flex; align-items: baseline; gap: 10px; }
.chart h3 { margin: 0 0 4px; }
.chart .sub { color: var(--ink-3); font-size: 12px; }
.chart .tbtn { margin-left: auto; min-height: 32px; min-width: 44px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg-2); font-size: 12px; color: var(--ink-2); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin: 4px 0 2px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); }
.chart table { font-size: 12.5px; }
.chart .tablewrap { max-height: 260px; overflow: auto; margin-top: 6px; }
.grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.axis text { fill: var(--ink-3); font-size: 11px; }
.axis line.zero { stroke: var(--ink-3); stroke-width: 1.5; shape-rendering: crispEdges; }
.series path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series path.dash { stroke-dasharray: 5 4; }
.series circle { stroke: var(--bg); stroke-width: 2; }
.dlabel text { font-size: 11px; fill: var(--ink-2); font-weight: 600; }
.marker line { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.marker text { font-size: 11px; fill: var(--ink-2); }
.cross line { stroke: var(--ink-3); stroke-width: 1; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 9px; border-radius: 6px; font-size: 12px; line-height: 1.35; z-index: 20; max-width: 280px; }
.tip b { display: block; margin-bottom: 2px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.letters td:first-child { font-weight: 700; width: 44px; }
.letters td { white-space: normal; min-width: 120px; }
.letters .pts { text-align: right; font-variant-numeric: tabular-nums; width: 70px; }
.bar { height: 6px; border-radius: 3px; background: var(--bg-3); overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--s1); }
footer { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 8px 18px; }
footer a { color: var(--ink-2); }
.legal { max-width: 72ch; }
.legal h2 { margin-top: 22px; }
@media (max-width: 640px) {
  .wrap { padding: 10px 10px 32px; }
  .filters .count { margin-left: 0; width: 100%; }
  .controls { top: 52px; }
  .hero .scorebig { margin-left: 0; text-align: left; }
  td.name { max-width: 150px; }
}
@media (forced-colors: active) { .cell, .score { forced-color-adjust: none; border: 1px solid CanvasText; } }
