:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --card: #fffcf6;
  --fg: #2d3340;
  --muted: #6a7280;
  --accent: #2a8f80;
  --down: #c24747;
  --line: #ddd4c8;
  --header: #c5d9d4;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0 auto;
  max-width: 1100px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  padding: 1.25rem 1.5rem 3rem;
}
h1 { margin: 0.2rem 0; font-size: 1.45rem; max-width: 38rem; line-height: 1.25; }
h2 { margin: 0; font-size: 1.1rem; }
.logo-banner {
  width: 100vw;
  max-width: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  background: #fff;
  min-height: 5.5rem;
}
.logo-banner-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1100px;
  min-height: 5.5rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  gap: 1rem;
}
.brand-lockup {
  display: block;
  min-width: 0;
  max-width: calc(100% - 5.5rem);
  flex: 0 1 auto;
  line-height: 0;
}
.brand-logo {
  display: block;
  height: 5.5rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.eyebrow { margin: 0.45rem 0 0; }
.eyebrow, .lede, .hint, footer { color: var(--muted); }
.lede { max-width: 40rem; }
.hero-actions { margin: 0.7rem 0 0.15rem; }
#hero-cta {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 0.45rem 0.95rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.lang { display: flex; flex: 0 0 auto; gap: 0.35rem; align-self: flex-start; }
.search, .controls, .cols, .compare-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: end;
}
.search { margin: 1.1rem 0 0.2rem; }
.toolbar {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 1.15rem;
  margin: 1.15rem 0 1.25rem;
}
.toolbar .controls, .toolbar .cols { margin: 0; }
.compare-bar { margin: 0.45rem 0; align-items: center; }
.compare-hint-inline {
  margin: 0;
  flex: 1 1 auto;
  white-space: nowrap;
}
.controls {
  flex-wrap: nowrap;
  width: 100%;
  overflow-x: auto;
}
.cols {
  flex-wrap: wrap;
  width: 100%;
  overflow-x: visible;
}
.controls label { min-width: 0; flex: 0 1 auto; }
.controls input, .controls select {
  min-width: 0;
  width: 4.6rem;
  padding: 0.2rem 0.3rem;
  font-size: 0.78rem;
}
.controls #sector { width: 11rem; }
.controls #industry { width: 11rem; }
.controls #country { width: 6.4rem; }
.class-hint {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: #5c6570;
}
.controls button {
  padding: 0.28rem 0.5rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.cols { align-items: flex-start; flex-direction: column; gap: 0.35rem 0.45rem; }
.cols-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
}
.cols-head button {
  padding: 0.18rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
}
.col-combos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem 0.35rem;
}
.col-combos button {
  padding: 0.14rem 0.42rem;
  font-size: 0.66rem;
  font-weight: 600;
  background: #fff;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.col-combos button.active, .col-combos button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.col-combos button:disabled,
.col-combos button:disabled.active {
  opacity: 1;
  background: #f3f3f3;
  color: #bdbdbd;
  border-color: #e0e0e0;
}
.col-combos button {
  position: relative;
}
.col-combos button::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 0.28rem);
  z-index: 30;
  width: max(14rem, 100%);
  min-width: 12rem;
  max-width: 18rem;
  padding: 0.4rem 0.5rem;
  background: var(--fg);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(45, 51, 64, 0.2);
}
.col-combos button:hover::after,
.col-combos button:focus-visible::after {
  opacity: 1;
}
.cols p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.compare-bar { justify-content: space-between; align-items: center; }
label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.72rem; color: var(--muted); }
input, select {
  background: #fff;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.32rem 0.45rem;
  min-width: 5.5rem;
}
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-weight: 650;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.ghost, .lang button {
  background: #e8e2d6;
  color: var(--fg);
}
.lang button.active, .lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }
#colboxes { display: flex; flex-wrap: wrap; gap: 0.28rem 0.7rem; align-items: center; }
.metrics-frame {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem 0.8rem;
  background: var(--card);
  gap: 0.5rem;
}
#metrics-body { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; }
.metrics-frame.is-collapsed #metrics-body,
.metrics-frame.is-collapsed #cols-all,
.metrics-frame.is-collapsed #cols-none {
  display: none;
}
.col-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.12rem 0.35rem;
  border: none;
  border-radius: 0;
  padding: 0.2rem 0.15rem;
  margin: 0.12rem 0.2rem 0.12rem 0;
  background: transparent;
}
.col-group-name {
  background: #e8e2d6;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.14rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 650;
  white-space: nowrap;
  line-height: 1.2;
}
.col-group-name:hover { filter: brightness(0.97); }
.col-group-name.active, .col-group-name[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#colboxes label {
  flex-direction: row;
  align-items: center;
  color: var(--fg);
  font-size: 0.68rem;
  gap: 0.12rem;
  white-space: nowrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.08rem 0.32rem;
}
#colboxes label.col-selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#colboxes label.col-unavailable {
  background: #f3f3f3;
  color: #bdbdbd;
  border-color: #e0e0e0;
}
#colboxes label.col-unavailable input {
  accent-color: #c0c0c0;
  filter: grayscale(1);
  opacity: 0.55;
}
#colboxes input { min-width: 0; width: auto; padding: 0; }
.chips { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.sym { font-weight: 700; }
.table-wrap { overflow: auto; background: var(--card); border-radius: 10px; border: 1px solid var(--line); }
.compare-table {
  overflow-x: auto;
  max-width: 100%;
}
.compare-table table,
#compare {
  table-layout: fixed;
  width: max-content;
  max-width: none;
}
.browse-table {
  max-height: min(70vh, 52rem);
  overflow: auto;
}
.browse-table table {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}
.browse-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header);
  color: var(--fg);
  box-shadow: 0 1px 0 var(--line);
  padding-right: 1.05rem;
}
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 3;
}
.col-resizer-grip {
  position: absolute;
  top: 22%;
  bottom: 22%;
  right: 4px;
  width: 5px;
  border-left: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
  opacity: 0.7;
  pointer-events: none;
}
.col-resizer:hover .col-resizer-grip { opacity: 1; border-color: var(--accent); }
.browse-table th, .browse-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 0.44rem;
  padding-bottom: 0.44rem;
  line-height: 1.15;
}
.browse-table button {
  padding: 0.22rem 0.45rem;
  font-size: 0.72rem;
}
.browse-table th.col-add, .browse-table td.col-add {
  width: 4.6rem;
  min-width: 4.6rem;
  max-width: 4.6rem;
  overflow: visible;
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--card);
}
.browse-table thead th.col-add {
  z-index: 6;
  background: var(--header);
}
.browse-table th.col-frozen-symbol, .browse-table td.col-frozen-symbol {
  position: sticky;
  left: 4.6rem;
  z-index: 4;
  background: var(--card);
}
.browse-table thead th.col-frozen-symbol {
  z-index: 6;
  background: var(--header);
}
.compare-table th.col-frozen-symbol, .compare-table td.col-frozen-symbol {
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--card);
}
.compare-table thead th.col-frozen-symbol {
  z-index: 6;
  background: var(--header);
}
.compare-table th.col-frozen-metric, .compare-table td.col-frozen-metric {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--card);
}
.compare-table thead th.col-frozen-metric {
  z-index: 7;
  background: var(--header);
}
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { cursor: pointer; color: var(--muted); position: relative; }
th.sort-asc::after { content: " ▲"; }
th.sort-desc::after { content: " ▼"; }
.up { color: var(--accent); }
.down { color: var(--down); }
footer { margin-top: 1.5rem; font-size: 0.8rem; }
.delayed { background: #e8e2d6; color: var(--fg); padding: 0.45rem 0.7rem; border-radius: 8px; font-size: 0.85rem; }
.stub-banner { background: #f3e2c4; color: #6a4a12; padding: 0.5rem 0.75rem; border-radius: 8px; }
.legal { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }
.legal a { color: var(--accent); }
.ad-slot {
  min-height: 90px;
  max-width: 728px;
  margin: 1.5rem auto;
  background: #f4f4f4;
  border: 1px solid #cfcfcf;
  border-radius: 2px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}
.mock-ad {
  color: #8a8a8a;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.35rem 0.6rem;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.ad-kicker {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: #9a9a9a;
}
.ad-size { font-size: 0.68rem; color: #b0b0b0; }
.ad-slot-rail {
  min-height: 90px;
  margin: 1.5rem auto;
}
a.set-factsheet, a.yahoo-quote { color: var(--accent); text-decoration: none; }
a.set-factsheet:hover, a.yahoo-quote:hover { text-decoration: underline; }
a.yahoo-quote { font-size: 0.72rem; font-weight: 600; }
.sym-links { display: inline-flex; align-items: baseline; gap: 0.35rem; }
.empty-state { color: var(--muted); font-style: italic; }
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem;
  margin: 0.65rem 0 0;
}
.pager-btn.active, .pager button[aria-current="page"] {
  background: var(--accent);
  color: #fff;
}
.pager-page {
  width: 3.4rem;
  min-width: 3.4rem;
  text-align: center;
}
#table.is-loading tbody { opacity: 0.45; }
#table.is-loading thead { opacity: 1; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  body { padding: 1rem; }
  .logo-banner { min-height: 4.4rem; }
  .logo-banner-inner { min-height: 4.4rem; padding: 0 1rem; }
  .brand-logo { height: 4.4rem; }
  input, select { min-width: 0; }
  /* Keep the stock list visible below compare on phone (MAX_COMPARE=5). */
  body.compare-active .browse-table,
  body.compare-active #table,
  body.compare-active #pager {
    visibility: visible;
  }
  .compare-table, .browse-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #compare {
    display: table;
    width: max-content;
  }
  #table {
    display: table;
    width: max-content;
    min-width: 100%;
  }
}

@media (max-width: 500px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
  }
  .logo-banner { min-height: 3.7rem; }
  .logo-banner-inner { align-items: flex-start; min-height: 3.7rem; }
  .brand-lockup { max-width: calc(100% - 5.5rem); }
  .brand-logo { height: 3.7rem; }
  header, footer, .search, .toolbar, .controls, .cols, #compare-panel, .ad-slot, .table-wrap, .browse-table, .compare-table {
    max-width: 100%;
    box-sizing: border-box;
  }
  .table-wrap, .browse-table, .compare-table, .controls, .ad-slot {
    width: 100%;
    overflow-x: auto;
  }
  body.compare-active .browse-table,
  body.compare-active #table,
  body.compare-active #pager {
    visibility: visible;
  }
  .compare-table table {
    width: max-content;
    table-layout: fixed;
  }
  .compare-table th,
  .compare-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 3.2rem;
  }
}
