.overnight-shell {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.lab-toolbar {
  display: grid;
  grid-template-columns: 170px 180px 180px 170px minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lab-toolbar button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--accent);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}

.lab-toolbar button:hover:not(:disabled) {
  color: white;
  background: var(--accent);
}

.lab-toolbar button:disabled {
  border-color: var(--line);
  color: #9aa39f;
  background: var(--surface-2);
  cursor: default;
}

.lab-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lab-status > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.lab-status > div + div {
  border-left: 1px solid var(--line);
}

.lab-status span,
.lab-status small,
.metric-band span,
.metric-band small {
  color: var(--muted);
  font-size: 12px;
}

.lab-status strong {
  font-size: 18px;
}

.lab-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(620px, 100%);
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface);
}

.lab-tabs button {
  min-height: 42px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.lab-tabs button + button {
  border-left: 1px solid var(--line);
}

.lab-tabs button.active {
  color: white;
  background: var(--accent);
}

.lab-content {
  min-height: 420px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lab-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.lab-heading h2,
.lab-heading p {
  margin: 0;
}

.lab-heading h2 {
  font-size: 19px;
}

.lab-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.lab-heading > strong {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
}

.metric-band {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.metric-band > div {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 14px 16px;
}

.metric-band > div + div {
  border-left: 1px solid var(--line);
}

.metric-band strong {
  font-size: 20px;
  line-height: 1.2;
}

.lab-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px 10px;
}

.lab-section-heading h3,
.lab-section-heading p {
  margin: 0;
}

.lab-section-heading h3 {
  font-size: 15px;
}

.lab-section-heading p {
  color: var(--muted);
  font-size: 12px;
}

.lab-table-wrap {
  width: 100%;
  overflow: auto;
}

.lab-detail-table-wrap {
  max-height: min(680px, 72vh);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.lab-detail-table-wrap .lab-table th {
  position: sticky;
  z-index: 2;
  top: 0;
}

.lab-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.lab-table th,
.lab-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.lab-table th {
  position: relative;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
}

.lab-table th[data-sort] {
  padding-right: 24px;
  cursor: pointer;
  user-select: none;
}

.lab-table th[data-sort]::after {
  position: absolute;
  right: 9px;
  color: #9aa39f;
  content: "↕";
}

.lab-table th.sorted[aria-sort="ascending"]::after {
  content: "↑";
}

.lab-table th.sorted[aria-sort="descending"]::after {
  content: "↓";
}

.lab-table tbody tr:hover {
  background: #f7faf8;
}

.lab-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.company-cell {
  display: grid;
  gap: 2px;
}

.company-cell small {
  color: var(--muted);
}

.trading-style-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  vertical-align: 1px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.trading-style-institutional {
  border-color: #b8cadb;
  color: #4169a1;
  background: #eaf1f6;
}

.trading-style-hot_money {
  border-color: #e5d3ae;
  color: var(--gold);
  background: var(--gold-soft);
}

.trading-style-confluence {
  border-color: #e4c6c2;
  color: var(--market-up);
  background: var(--red-soft);
}

.status-tag,
.regime-tag,
.feasibility-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
}

.regime-strong,
.feasibility-observed_open {
  border-color: #e4c6c2;
  color: var(--market-up);
  background: var(--red-soft);
}

.regime-weak,
.status-blocked_limit_up,
.feasibility-blocked_one_word {
  border-color: #bcd7d0;
  color: var(--market-down);
  background: var(--accent-soft);
}

.regime-neutral,
.feasibility-queue_uncertain {
  border-color: #e5d3ae;
  color: var(--gold);
  background: var(--gold-soft);
}

.positive {
  color: var(--market-up);
}

.negative {
  color: var(--market-down);
}

.method-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.sector-method-band {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.table-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.sector-cohort-table {
  min-width: 960px;
}

.sector-detail-table {
  min-width: 1120px;
}

.method-band > div {
  min-width: 0;
  padding: 16px 18px;
}

.method-band > div + div {
  border-left: 1px solid var(--line);
}

.method-band strong,
.method-band span {
  display: block;
}

.method-band strong {
  margin-bottom: 5px;
  font-size: 13px;
}

.method-band span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.lab-empty,
.lab-error {
  padding: 64px 20px;
  color: var(--muted);
  text-align: center;
}

.lab-error {
  color: var(--market-down);
}

@media (max-width: 1100px) {
  .lab-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .metric-band > div:nth-child(4) {
    border-left: 0;
  }

  .metric-band > div:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .overnight-shell {
    padding: 10px;
  }

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

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

  .lab-status > div:nth-child(3) {
    border-left: 0;
  }

  .lab-status > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .method-band {
    grid-template-columns: 1fr 1fr;
  }

  .method-band > div:nth-child(3) {
    border-left: 0;
  }

  .method-band > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 500px) {
  .lab-toolbar,
  .lab-status,
  .metric-band,
  .method-band {
    grid-template-columns: 1fr;
  }

  .lab-status > div + div,
  .metric-band > div + div,
  .method-band > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .lab-tabs button {
    min-height: 50px;
    padding: 0 8px;
    font-size: 12px;
  }

  .lab-heading,
  .lab-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
