:root {
  --bg: #f5f7f3;
  --ink: #18201d;
  --muted: #65716b;
  --line: #dbe2dc;
  --surface: #ffffff;
  --surface-soft: #edf2ed;
  --accent: #0b7568;
  --accent-strong: #064d45;
  --warm: #c75b37;
  --shadow: 0 14px 34px rgb(24 32 29 / 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 112px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 54px) 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, white);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--warm);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  font-weight: 800;
}

.topbar__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.icon-button,
.reset-button,
.pager button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 0 14px;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.icon-button:hover,
.reset-button:hover,
.pager button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  padding: 0 clamp(18px, 4vw, 54px) 44px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 42px);
  align-items: start;
}

.filters {
  position: sticky;
  top: 0;
  min-height: calc(100svh - 112px);
  padding: 24px 0;
  border-right: 1px solid var(--line);
}

.search,
.filter-grid label,
.range label {
  display: grid;
  gap: 7px;
}

.search span,
.filter-grid span,
.range span,
.range p,
.segment legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input,
.filter-grid select,
.range input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.search input:focus,
.filter-grid select:focus,
.range input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(11 117 104 / 0.13);
}

.filter-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.filter-grid--compact {
  grid-template-columns: minmax(0, 1fr) 98px;
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  border: 0;
}

.segment legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.segment label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment label:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, white);
  color: var(--accent-strong);
  font-weight: 750;
}

.range {
  margin-top: 22px;
}

.range p {
  margin: 0 0 8px;
}

.range__inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-ranges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.quick-ranges button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.quick-ranges button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.reset-button {
  width: 100%;
  margin-top: 18px;
}

.results {
  min-width: 0;
  padding: 24px 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.metrics div {
  min-height: 88px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px 18px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metrics strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.05;
}

.sector-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.sector-item {
  min-width: 0;
}

.sector-item__top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sector-item__bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.sector-item__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transform-origin: left;
  animation: growBar 420ms ease both;
}

.table-shell {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 84px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 250px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 90px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 120px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 128px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fdfefc;
}

th,
td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 14px;
}

.ticker {
  font-weight: 850;
  color: var(--accent-strong);
}

.name {
  display: grid;
  gap: 5px;
  min-width: 190px;
  font-weight: 750;
}

.name small,
.industry,
.profile,
.cap-date {
  color: var(--muted);
}

.profile {
  line-height: 1.55;
}

.market-cap {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid color-mix(in srgb, var(--warm) 42%, var(--line));
  border-radius: 999px;
  padding: 0 8px;
  color: #8d321c;
  background: color-mix(in srgb, var(--warm) 9%, white);
  font-size: 12px;
  font-weight: 750;
}

.empty-state {
  display: none;
  margin: 0;
  padding: 42px;
  text-align: center;
  color: var(--muted);
}

.table-shell.is-empty table {
  display: none;
}

.table-shell.is-empty .empty-state {
  display: block;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}

@keyframes growBar {
  from {
    transform: scaleX(0);
  }
}

@media (max-width: 1020px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid--compact {
    grid-template-columns: 1fr 1fr;
  }

  .sector-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 0;
    align-items: start;
    flex-direction: column;
  }

  .topbar__meta {
    width: 100%;
    justify-content: space-between;
  }

  .filter-grid,
  .filter-grid--compact,
  .range__inputs,
  .metrics,
  .sector-strip {
    grid-template-columns: 1fr;
  }

  .metrics div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metrics div:last-child {
    border-bottom: 0;
  }

  .quick-ranges {
    grid-template-columns: 1fr 1fr;
  }

  table {
    min-width: 720px;
  }
}
