.research-page {
  --research-green: #62d98b;
  --research-blue: #72a7ff;
  max-width: 1420px;
  min-height: calc(100vh - 64px);
  padding: 44px 42px 100px;
}

.research-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 26px;
}

.research-head h1 {
  max-width: 780px;
  margin: 7px 0 8px;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.03;
  letter-spacing: -.045em;
}

.research-head p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.eyebrow, .filter-kicker {
  color: var(--accent);
  font: 700 10px 'SF Mono', Menlo, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.research-asof {
  flex: 0 0 auto;
  padding-bottom: 5px;
  color: var(--muted-2);
  font: 10px 'SF Mono', Menlo, monospace;
}

.research-flow {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0 0 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  list-style: none;
}

.research-flow li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 66px;
  padding: 0 20px;
  border-right: 1px solid var(--border);
}

.research-flow li:last-child { border-right: 0; }
.research-flow li::after {
  position: absolute;
  right: -7px;
  z-index: 2;
  width: 13px;
  height: 13px;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--surface);
  content: "";
  transform: rotate(45deg);
}
.research-flow li:last-child::after { display: none; }
.research-flow li > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font: 11px 'SF Mono', Menlo, monospace;
}
.research-flow li.active > span {
  border-color: rgba(98,217,139,.45);
  background: rgba(98,217,139,.1);
  color: var(--research-green);
}
.research-flow div { display: flex; flex-direction: column; gap: 3px; }
.research-flow strong { color: var(--text); font-size: 12px; }
.research-flow small { color: var(--muted-2); font-size: 10px; }

.research-modes {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.research-modes button {
  position: relative;
  padding: 10px 15px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}
.research-modes button.active { color: var(--text); }
.research-modes button.active::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  background: var(--accent);
  content: "";
}
.research-modes span { color: var(--accent); font: 10px 'SF Mono',Menlo,monospace; }

.filter-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
.filter-topline {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.market-filter { display: flex; gap: 5px; margin-top: 9px; }
.market-filter button {
  min-width: 45px;
  min-height: 31px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 10px 'SF Mono', Menlo, monospace;
}
.market-filter button.active {
  border-color: rgba(114,167,255,.48);
  background: rgba(114,167,255,.1);
  color: var(--research-blue);
}
.company-search { width: min(310px, 35vw); }
.company-search span, .filter-grid label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
}
.company-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
}
.company-search input:focus, .filter-grid input:focus { border-color: var(--accent); }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(115px, 1fr)) minmax(200px, 1.3fr);
  gap: 14px;
  padding: 17px 20px;
}
.filter-builder-wrap { padding: 18px 20px; }
.filter-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}
.filter-builder-head > div { display: flex; align-items: baseline; gap: 9px; }
.filter-builder-head small { color: var(--muted-2); font-size: 9px; }
.add-condition {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}
.add-condition:hover { border-color: var(--accent); }
.filter-builder { display: grid; gap: 7px; }
.condition-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) 70px minmax(150px, 1fr) 32px;
  gap: 7px;
}
.condition-row select,
.condition-value-wrap {
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 5px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
}
.condition-row select { padding: 0 9px; }
.condition-row select:focus,
.condition-value-wrap:focus-within { border-color: var(--accent); }
.condition-value-wrap {
  display: flex;
  overflow: hidden;
  align-items: stretch;
}
.condition-value {
  min-width: 0;
  width: 100%;
  padding: 0 10px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 11px 'SF Mono', Menlo, monospace;
}
.condition-unit {
  display: grid;
  min-width: 66px;
  padding: 0 7px;
  place-items: center;
  border-left: 1px solid var(--border);
  color: var(--muted-2);
  font: 8px 'SF Mono', Menlo, monospace;
  white-space: nowrap;
}
.remove-condition {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 18px;
}
.remove-condition:hover { background: var(--bg); color: #f87171; }
.filter-help {
  margin: 11px 0 0;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.5;
}
.filter-grid label > div {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
}
.filter-grid input[type="number"] {
  min-width: 0;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 11px 'SF Mono', Menlo, monospace;
}
.filter-grid b {
  display: grid;
  min-width: 34px;
  place-items: center;
  border-left: 1px solid var(--border);
  color: var(--muted-2);
  font: 9px 'SF Mono', Menlo, monospace;
}
.filter-grid .ownership-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  margin-top: 15px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
}
.ownership-toggle input { accent-color: var(--accent); }
.ownership-toggle span { margin: 0 !important; }
.ownership-toggle strong, .ownership-toggle small { display: block; }
.ownership-toggle strong { color: var(--text); font-size: 10px; }
.ownership-toggle small { margin-top: 3px; color: var(--muted-2); font-size: 8px; }
.filter-actions {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 20px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
}
.filter-actions > div { display: flex; align-items: center; gap: 8px; }
.active-criteria { display: flex; flex-wrap: wrap; gap: 6px; }
.criterion {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 9px;
}
.quiet-button, .run-screen {
  min-height: 32px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 700;
}
.quiet-button { border: 0; background: transparent; color: var(--muted); }
.run-screen {
  padding: 0 14px;
  border: 0;
  background: var(--accent);
  color: #07111f;
}

.results-head {
  display: flex;
  min-height: 58px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 0 3px 10px;
}
.results-head > div { display: flex; align-items: baseline; gap: 10px; }
.results-head span { color: var(--text); font-size: 12px; font-weight: 650; }
.results-head small { color: var(--muted-2); font-size: 9px; }
.results-head label { color: var(--muted-2); font-size: 9px; }
.results-head select {
  margin-left: 5px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
}
.research-results { display: grid; gap: 6px; }
.result-card {
  display: grid;
  grid-template-columns: minmax(210px, 1.45fr) repeat(4, minmax(105px, .72fr)) 86px;
  align-items: center;
  gap: 16px;
  min-height: 70px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.result-card:hover { border-color: var(--muted-2); transform: translateY(-1px); }
.result-identity { min-width: 0; }
.result-identity > div { display: flex; align-items: center; gap: 7px; }
.market-badge {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted-2);
  font: 8px 'SF Mono', Menlo, monospace;
}
.result-identity code { color: var(--accent); font-weight: 800; }
.result-identity h2 {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-metric { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.result-metric span { color: var(--muted-2); font-size: 8px; text-transform: uppercase; }
.result-metric strong { color: var(--text); font: 13px 'SF Mono',Menlo,monospace; }
.result-metric strong.positive { color: var(--research-green); }
.result-metric small { overflow: hidden; color: var(--muted-2); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.verify-button {
  display: grid;
  min-height: 31px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
}
.verify-button:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.trace-company-link { color: var(--accent); font-size: 10px; font-weight: 700; }
.research-empty {
  padding: 58px 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}
.research-empty strong { display: block; margin-bottom: 7px; color: var(--text); }

.company-drawer[hidden] { display: none; }
.company-drawer { position: fixed; inset: 0; z-index: 100; }
.drawer-backdrop { position: absolute; inset: 0; border: 0; background: rgba(0,0,0,.58); }
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  width: min(760px, 92vw);
  border-left: 1px solid var(--border);
  background: var(--bg);
  box-shadow: -18px 0 60px rgba(0,0,0,.24);
}
.drawer-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
}
.drawer-header h2 { margin: 4px 0 0; font-size: 20px; }
.drawer-header p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.drawer-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 25px; }
.company-research { padding: 24px 24px 70px; }
.research-loading { padding: 70px 0; color: var(--muted); text-align: center; }
.research-section { margin-bottom: 22px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.section-title h3 { margin: 0; font-size: 12px; }
.section-title span { color: var(--muted-2); font: 8px 'SF Mono',Menlo,monospace; }
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}
.metric-strip > div { padding: 13px; border-right: 1px solid var(--border); }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span, .metric-strip small { display: block; color: var(--muted-2); font-size: 8px; }
.metric-strip strong { display: block; margin: 5px 0 3px; font: 15px 'SF Mono',Menlo,monospace; }
.trend-card, .evidence-card, .monitor-card {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}
.trend-card { padding: 15px; }
.trend-legend { display: flex; justify-content: space-between; color: var(--muted-2); font-size: 8px; }
.trend-chart { display: block; width: 100%; height: 145px; margin-top: 8px; }
.trend-chart .grid { stroke: var(--border-soft); stroke-width: 1; }
.trend-chart .revenue-line { fill: none; stroke: var(--research-blue); stroke-width: 2; }
.trend-chart .margin-line { fill: none; stroke: var(--research-green); stroke-width: 2; }
.ownership-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.evidence-card { min-height: 130px; padding: 14px; }
.evidence-card > span { color: var(--muted-2); font-size: 8px; text-transform: uppercase; }
.evidence-card h4 { margin: 7px 0 4px; font-size: 13px; }
.evidence-card > p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.evidence-number { margin: 9px 0 2px; color: var(--research-green); font: 22px 'SF Mono',Menlo,monospace; }
.holder-list, .transaction-list { margin: 10px 0 0; padding: 0; list-style: none; }
.holder-list li, .transaction-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 8px;
}
.holder-list b, .transaction-list b { color: var(--text); font-weight: 600; }
.partial-note { margin-top: 8px !important; color: #d8a657 !important; }
.monitor-card { padding: 15px; }
.monitor-card > p { margin: 0 0 13px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.monitor-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.monitor-rules label { color: var(--muted-2); font-size: 8px; }
.monitor-rules div {
  display: flex;
  overflow: hidden;
  margin-top: 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.monitor-rules input {
  min-width: 0;
  width: 100%;
  padding: 8px;
  border: 0;
  outline: 0;
  background: var(--bg);
  color: var(--text);
}
.monitor-rules b { display: grid; min-width: 35px; place-items: center; color: var(--muted-2); font-size: 8px; }
.add-monitor {
  width: 100%;
  min-height: 38px;
  margin-top: 11px;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #07111f;
  cursor: pointer;
  font-weight: 800;
}
.monitor-status { min-height: 16px; margin-top: 8px; color: var(--muted); font-size: 9px; text-align: center; }

.watchlist-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 28px 0 18px; }
.watchlist-head h2 { margin: 6px 0 0; }
.watchlist-head p { max-width: 390px; margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.watchlist-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.watch-card { padding: 16px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.watch-card.triggered { border-color: rgba(216,166,87,.48); }
.watch-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.watch-card h3 { margin: 4px 0 0; font-size: 14px; }
.watch-card header button { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; }
.watch-state { display: inline-block; margin-top: 10px; padding: 3px 6px; border-radius: 4px; background: rgba(98,217,139,.09); color: var(--research-green); font-size: 8px; text-transform: uppercase; }
.watch-card.triggered .watch-state { background: rgba(216,166,87,.1); color: #d8a657; }
.trigger-list { margin: 10px 0 0; padding: 0; list-style: none; }
.trigger-list li { padding: 7px 0; border-top: 1px solid var(--border-soft); }
.trigger-list strong, .trigger-list span { display: block; }
.trigger-list strong { color: var(--text); font-size: 9px; }
.trigger-list span { margin-top: 3px; color: var(--muted); font-size: 8px; }
.baseline-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-top: 12px; }
.baseline-grid div { padding: 7px; border-radius: 4px; background: var(--bg); }
.baseline-grid span, .baseline-grid strong { display: block; }
.baseline-grid span { color: var(--muted-2); font-size: 7px; }
.baseline-grid strong { margin-top: 3px; font: 9px 'SF Mono',Menlo,monospace; }

@media (max-width: 1120px) {
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .result-card { grid-template-columns: minmax(180px,1.3fr) repeat(3,minmax(90px,.7fr)) 76px; }
  .result-card .result-metric:nth-of-type(4) { display: none; }
}

@media (max-width: 760px) {
  .research-page { padding: 28px 16px 70px; }
  .research-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .research-flow li { min-height: 55px; padding: 0 9px; }
  .research-flow li > span { width: 22px; height: 22px; }
  .research-flow small { display: none; }
  .filter-topline { align-items: stretch; flex-direction: column; gap: 16px; }
  .company-search { width: 100%; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .condition-row { grid-template-columns: minmax(0, 1fr) 58px 32px; }
  .condition-value-wrap { grid-column: 1 / 3; grid-row: 2; }
  .remove-condition { grid-column: 3; grid-row: 1 / 3; }
  .filter-grid .ownership-toggle { grid-column: 1 / -1; }
  .filter-actions { align-items: stretch; flex-direction: column; padding: 10px 14px; }
  .filter-actions > div:last-child { justify-content: flex-end; }
  .result-card { grid-template-columns: 1fr 1fr 72px; gap: 9px; }
  .result-card .result-metric:nth-of-type(n+3) { display: none; }
  .ownership-grid, .watchlist-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric-strip > div:nth-child(2) { border-right: 0; }
  .metric-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .monitor-rules { grid-template-columns: 1fr; }
  .watchlist-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .watchlist-head p { text-align: left; }
}
