/* PerpMetric unified venue shell — HOME-E5 geometry, venue content retained. */
body.shell-unified {
  --shell-max: 1560px;
  --shell-radius: 3px;
}

body.shell-unified .pm-global-nav {
  display: none;
}

body.shell-unified .topbar.unified-shell-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: min(var(--shell-max), calc(100% - 32px));
  min-height: 58px;
  margin: 0 auto;
  padding: 0 18px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  box-shadow: none;
  backdrop-filter: blur(10px);
}

body.shell-unified .topbar.unified-shell-header::before,
body.shell-unified .topbar.unified-shell-header::after {
  content: none;
}

body.shell-unified .shell-wordmark {
  display: flex;
  align-items: center;
  min-width: 0;
  text-decoration: none;
}

body.shell-unified .shell-wordmark img {
  display: block;
  width: 178px;
  height: auto;
  max-width: none;
}

body.shell-unified .shell-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

body.shell-unified .shell-nav a {
  position: relative;
  padding: 20px 0 18px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

body.shell-unified .shell-nav a:hover,
body.shell-unified .shell-nav a:focus-visible {
  color: var(--text);
}

body.shell-unified .shell-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 13px;
  height: 1px;
  background: var(--accent);
  transition: right 120ms ease;
}

body.shell-unified .shell-nav a:hover::after,
body.shell-unified .shell-nav a:focus-visible::after {
  right: 0;
}

body.shell-unified .shell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

body.shell-unified .topbar .system-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 4px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.045em;
  white-space: nowrap;
}

body.shell-unified .shell-venue-chip {
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-soft);
  border-radius: var(--shell-radius);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

body.shell-unified .shell-venue-chip:hover,
body.shell-unified .shell-venue-chip:focus-visible,
body.shell-unified .shell-venue-chip[aria-current="page"] {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line-soft));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-2));
}

body.shell-unified .shell-chip-logo {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

body.shell-unified .shell-chip-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body.shell-unified .shell-lighter-logo-light {
  display: none;
}

:root[data-theme="light"] body.shell-unified .shell-lighter-logo-dark {
  display: none;
}

:root[data-theme="light"] body.shell-unified .shell-lighter-logo-light {
  display: block;
}

body.shell-unified .shell-venue-chip.shell-lighter {
  color: var(--text-muted);
}

body.shell-unified .shell-venue-chip em {
  padding: 2px 4px;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  font-size: 0.52rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.045em;
}

body.shell-unified .topbar .theme-control {
  min-height: 32px;
  margin: 0;
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  box-shadow: none;
}

body.shell-unified .topbar .theme-option {
  min-height: 26px;
  padding: 0 7px;
  border-radius: 2px;
  font-size: 0.62rem;
}

body.shell-unified main {
  width: min(var(--shell-max), calc(100% - 32px));
  max-width: var(--shell-max);
  margin-inline: auto;
}

body.shell-unified .panel,
body.shell-unified .market-state,
body.shell-unified .kpi,
body.shell-unified .market-workspace,
body.shell-unified .market-workspace-panel,
body.shell-unified .research-workspace,
body.shell-unified .research-market-browser,
body.shell-unified .research-market-detail,
body.shell-unified .research-focus,
body.shell-unified .research-answer,
body.shell-unified .research-data-quality,
body.shell-unified .research-advanced,
body.shell-unified .research-benchmark,
body.shell-unified .leader-card,
body.shell-unified .theme-control,
body.shell-unified .market-workspace-tabs,
body.shell-unified .market-workspace-tab {
  border-radius: var(--shell-radius);
}

body.shell-unified .badge,
body.shell-unified .status-dot {
  border-radius: 999px;
}

@media (max-width: 1320px) {
  body.shell-unified .topbar.unified-shell-header { gap: 16px; }
  body.shell-unified .shell-nav { gap: 16px; }
  body.shell-unified .topbar .system-status span:last-child { display: none; }
  body.shell-unified .shell-venue-chip { padding-inline: 8px; }
}

@media (max-width: 1120px) {
  body.shell-unified .topbar.unified-shell-header {
    grid-template-columns: auto 1fr;
    padding-top: 9px;
    padding-bottom: 9px;
  }
  body.shell-unified .shell-nav { justify-content: flex-end; }
  body.shell-unified .shell-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  body.shell-unified .topbar.unified-shell-header,
  body.shell-unified main {
    width: min(100% - 20px, var(--shell-max));
  }
  body.shell-unified .topbar.unified-shell-header {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
  }
  body.shell-unified .shell-wordmark img { width: 154px; }
  body.shell-unified .shell-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  body.shell-unified .shell-nav a { padding: 7px 0 9px; }
  body.shell-unified .shell-nav a::after { bottom: 4px; }
  body.shell-unified .shell-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
}

/* =========================================================
   FRONTEND CLOSEOUT — canonical HOME-E5 visual alignment
   ========================================================= */

/* The production wordmark is a light monochrome asset.
   Convert it to a strong dark mark only in light theme. */
:root[data-theme="light"] body.shell-unified .shell-wordmark img {
  filter: brightness(0);
  opacity: .94;
}

/* Match the HOME-E5 compact institutional geometry for visible
   container surfaces. Semantic pills/status indicators stay rounded. */
body.shell-unified .kpis,
body.shell-unified .breadth-grid,
body.shell-unified .market-leaders,
body.shell-unified .market-controls,
body.shell-unified .market-controls input,
body.shell-unified .instrument-control input,
body.shell-unified .instrument-control select,
body.shell-unified .workspace-view-toolbar,
body.shell-unified .workspace-view-summary span,
body.shell-unified .price-history-card,
body.shell-unified .signal-context,
body.shell-unified .signal-terminal,
body.shell-unified .signal-empty-state,
body.shell-unified .signal-show-all-button,
body.shell-unified .research-state,
body.shell-unified .research-freshness-notice,
body.shell-unified .research-workspace-summary,
body.shell-unified .research-purpose,
body.shell-unified .research-scope-tabs,
body.shell-unified .research-scope-tab,
body.shell-unified .research-market-search input,
body.shell-unified .research-filter-field select,
body.shell-unified .research-market-option.is-selected,
body.shell-unified .research-filter-reset,
body.shell-unified .research-show-all,
body.shell-unified .research-outcomes-table tr,
body.shell-unified .research-scenario-field select,
body.shell-unified .research-horizon-card {
  border-radius: var(--shell-radius);
}

/* Primary container tabs use the same near-square system. */
body.shell-unified .market-workspace {
  border-radius: var(--shell-radius) var(--shell-radius) 0 0;
}

/* Preserve meaning-driven rounded shapes only. */
body.shell-unified .research-workspace-status,
body.shell-unified .research-live-state,
body.shell-unified #researchAnswerReliability,
body.shell-unified .badge,
body.shell-unified .status-dot,
body.shell-unified .market-state-age.freshness-live.freshness-quiet {
  border-radius: 999px;
}

/* =========================================================
   CONSISTENCY R2 — contain Lighter mark inside venue chip
   ========================================================= */
body.shell-unified .shell-venue-chip.shell-lighter .shell-chip-logo {
  position: relative;
  overflow: hidden;
  contain: paint;
  line-height: 0;
}

body.shell-unified .shell-venue-chip.shell-lighter .shell-chip-logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}
