/* A company reference desk: geographic/classification filters beside a calm ledger */
body[data-view="companies"] {
  --explorer-ink: #15171c;
  --explorer-muted: #5b6270;
  --explorer-line: #e1e4ea;
  --explorer-paper: #ffffff;
  --explorer-surface: #f5f6f9;
  --explorer-brand: #252347;
  --explorer-accent: #3b3990;
  --explorer-step: 8px;
  color: var(--explorer-ink);
  background: var(--explorer-paper);
}
body[data-view="companies"] .container {
  width: calc(100% - 80px);
  max-width: 1440px;
}
body[data-view="companies"] .site-header {
  background: var(--explorer-paper);
  border-color: var(--explorer-line);
}
body[data-view="companies"] .header-inner {
  max-width: 1520px;
  min-height: 68px;
  padding: 12px 40px;
}
body[data-view="companies"] .brand {
  color: var(--explorer-brand);
}
.explorer-opening {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 48px;
  padding-block: 38px 30px;
}
.explorer-opening .eyebrow {
  margin: 0 0 10px;
  color: var(--explorer-muted);
  font-size: 10px;
  letter-spacing: 0.07em;
}
body.directory-page[data-view="companies"] h1 {
  margin: 0;
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.045em;
}
body.directory-page[data-view="companies"] .explorer-opening .directory-intro {
  margin-top: 12px;
  max-width: 650px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--explorer-muted);
}
.explorer-snapshot {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 10px;
  align-items: baseline;
  text-align: right;
  flex: none;
}
.explorer-snapshot strong {
  font-family: var(--display);
  font-weight: 650;
  font-size: 28px;
  letter-spacing: -0.045em;
}
.explorer-snapshot > span {
  font-size: 12px;
  color: var(--explorer-muted);
}
.explorer-snapshot small {
  grid-column: 1/-1;
  font-size: 11px;
  color: var(--explorer-muted);
}
.explorer-workspace {
  padding: 0 0 40px;
}
.explorer-workspace .company-filters {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 32px;
  margin: 0;
  padding: 0;
  border: 0;
}
.explorer-sidebar {
  position: sticky;
  top: calc(var(--explorer-header-height, 69px) + 12px);
  z-index: 11;
  max-height: calc(100dvh - var(--explorer-header-height, 69px) - 24px);
  overflow-y: auto;
  align-self: start;
  display: grid;
  gap: 24px;
  padding: 24px;
  background: var(--explorer-surface);
  border: 1px solid var(--explorer-line);
  border-radius: 14px;
}
.explorer-filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.explorer-filter-heading h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.025em;
}
.explorer-filter-heading .company-filter-reset {
  padding: 4px 0;
  min-height: 36px;
  width: auto;
  border: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--explorer-accent);
  background: transparent;
}
.explorer-filter-heading .company-filter-reset:disabled {
  color: var(--explorer-muted);
  opacity: 0.5;
}
.explorer-workspace label {
  font-size: 12px;
  color: var(--explorer-muted);
  gap: 8px;
}
.explorer-workspace .directory-select-trigger,
.explorer-workspace select {
  height: 44px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #c8cdd7;
  border-radius: 8px;
  color: var(--explorer-ink);
  background: var(--explorer-paper);
  font-size: 12px;
}
.explorer-sidebar-note {
  padding-top: 20px;
  border-top: 1px solid var(--explorer-line);
}
.explorer-sidebar-note .eyebrow {
  font-size: 10px;
  color: var(--explorer-muted);
}
.explorer-sidebar-note p {
  margin: 8px 0 16px;
  font-size: 12px;
  color: var(--explorer-muted);
  line-height: 1.6;
}
.explorer-sidebar-note a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  font-size: 12px;
}
.explorer-results {
  min-width: 0;
}
.explorer-search-row {
  position: sticky;
  top: calc(var(--explorer-header-height, 69px) + 12px);
  z-index: 10;
  padding-bottom: 12px;
  background: var(--explorer-paper);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 16px;
  align-items: center;
}
.explorer-search-row::before {
  content: "";
  position: absolute;
  top: -12px;
  inset-inline: 0;
  height: 12px;
  background: var(--explorer-paper);
}
.explorer-results button,
.explorer-results a {
  scroll-margin-top: calc(
    var(--explorer-header-height, 69px) + var(--explorer-search-height, 60px) +
      var(--explorer-mobile-controls-height, 0px) + 36px
  );
}
.explorer-workspace .explorer-search-row .search-label,
.explorer-workspace .explorer-search-row .sort-label {
  grid-column: auto;
}
.explorer-search-row .company-search-control {
  display: block;
}
.explorer-search-row .company-search-control input {
  min-height: 48px;
  background: var(--explorer-surface);
  border: 1px solid #c8cdd7;
  border-radius: 8px;
  color: var(--explorer-ink);
  font-size: 14px;
  padding: 12px 44px;
}
.explorer-search-row .company-search-control input::placeholder {
  color: var(--explorer-muted);
}
.explorer-search-row .company-search-control > svg {
  top: 15px;
  left: 15px;
}
.explorer-search-row .company-search-clear {
  color: var(--explorer-muted);
  background: transparent;
  width: 40px;
  height: 44px;
  top: 2px;
  right: 2px;
}
.explorer-search-row .company-search-clear > svg {
  position: static;
  width: 16px;
  height: 16px;
  stroke: currentColor;
}
.explorer-search-row .directory-select-trigger {
  height: 48px;
}
.explorer-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0 0;
  border-bottom: 1px solid var(--explorer-line);
}
.explorer-list-toolbar .company-view-switch {
  gap: 24px;
}
.explorer-list-toolbar .company-view-switch button {
  min-height: 46px;
  font-size: 12px;
}
#company-results {
  margin: 0;
  font-size: 11px;
  color: var(--explorer-muted);
}
.explorer-results .active-filters {
  margin-block: 12px;
  gap: 8px;
}
.explorer-results .active-filters button {
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  background: var(--explorer-surface);
}
.explorer-results .ledger-table-wrap {
  overflow-x: visible;
}
.explorer-results .company-table {
  width: 100%;
  table-layout: fixed;
  min-width: 0;
}
.explorer-results .company-table thead th {
  padding: 16px 10px;
  font-size: 10px;
  color: var(--explorer-muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.explorer-results .company-table th:first-child {
  width: 39%;
  padding-left: 0;
}
.explorer-results .company-table th:nth-child(2) {
  width: 17%;
}
.explorer-results .company-table th:nth-child(3) {
  width: 26%;
}
.explorer-results .company-table th:nth-child(5) {
  width: 18%;
}
.explorer-results .company-table .status-text-cell {
  display: none;
}
.explorer-results .company-table tbody th,
.explorer-results .company-table tbody td {
  padding: 16px 10px;
  border-color: var(--explorer-line);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
.explorer-results .company-table tbody th {
  padding-left: 0;
  font-weight: 500;
}
.explorer-results .company-table tbody td {
  font-size: 12px;
  color: var(--explorer-muted);
}
.explorer-results .company-table tr:hover {
  background: var(--explorer-surface);
}
.explorer-results .company-identity {
  gap: 14px;
  align-items: center;
}
.explorer-results .company-logo {
  display: flex;
  flex: none;
  justify-content: center;
  align-items: center;
  --company-mark-size: 46px;
  width: 54px;
  height: 54px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--explorer-line);
  border-radius: 9px;
}
.explorer-results .company-logo img {
  margin: auto;
  width: var(--company-mark-size);
  height: var(--company-mark-size);
  object-fit: contain;
}
.explorer-results .company-initials {
  color: var(--explorer-muted);
  font: 500 13px var(--display);
}
.explorer-results .company-name {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: var(--explorer-ink);
  text-align: left;
  font: 600 14px/1.4 var(--sans);
  cursor: pointer;
}
.explorer-results button.company-name:hover {
  color: var(--explorer-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.explorer-results .company-ticker {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--explorer-muted);
}
.explorer-results .company-context,
.explorer-results .company-status-mobile {
  display: none;
}
.explorer-results .company-table .market-cap-cell {
  color: var(--explorer-ink);
  font-size: 14px;
}
.explorer-results .market-cap-heading,
.explorer-results .market-cap-cell {
  padding-right: 0;
}
.explorer-results .classification-sector {
  display: block;
  color: var(--explorer-ink);
  font-size: 12px;
}
.explorer-results .classification-industry {
  display: block;
  margin-top: 5px;
  color: var(--explorer-muted);
  font-size: 10px;
  line-height: 1.5;
}
.explorer-results .directory-pagination {
  margin-top: 20px;
}
.explorer-results .directory-pagination button {
  border: 1px solid var(--explorer-line);
  border-radius: 7px;
  padding: 10px 14px;
  color: var(--explorer-ink);
  background: var(--explorer-paper);
}
.explorer-results .directory-pagination button:disabled {
  opacity: 0.4;
}
.explorer-results .market-cap-note {
  margin: 24px 0 8px;
  gap: 8px 20px;
  flex-wrap: wrap;
  font-size: 10px;
}
.explorer-results > .ledger-note {
  font-size: 11px;
  line-height: 1.6;
}
.explorer-source-notes {
  margin-left: 262px;
  padding-top: 8px;
}
.explorer-source-notes .directory-download {
  gap: 24px;
  font-size: 11px;
}
.explorer-source-notes .directory-download p {
  font-size: 11px;
}
.explorer-source-notes .directory-explainer {
  font-size: 11px;
}
body[data-view="companies"] .directory-footer {
  padding: 24px 0;
  background: var(--explorer-surface);
}
body[data-view="companies"] .directory-source,
body[data-view="companies"] .directory-footer > .container > p {
  font-size: 11px;
}
body[data-view="companies"] .directory-select-panel {
  box-shadow: 0 6px 24px #15171c12;
  border-color: var(--explorer-line);
  border-radius: 12px;
}
body[data-view="companies"] :focus-visible {
  outline: 2px solid var(--explorer-accent);
  outline-offset: 3px;
}
/* Keep identity, financial context and provenance visible in the same drawer */
.company-profile {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(540px, 100%);
  max-width: 100%;
  height: 100dvh;
  max-height: 100%;
  margin: 0;
  padding: 20px 24px;
  border: 0;
  border-left: 1px solid var(--explorer-line);
  background: var(--explorer-paper);
  color: var(--explorer-ink);
  overflow-y: auto;
}
.company-profile[open] { display: flex; flex-direction: column; }
.company-profile::backdrop { background: #15171c50; }
.profile-topbar {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.profile-topbar .eyebrow { color: var(--explorer-muted); font-size: 10px; }
.profile-close {
  width: 44px;
  height: 44px;
  border: 1px solid var(--explorer-line);
  border-radius: 8px;
  background: var(--explorer-paper);
  color: var(--explorer-ink);
  font-size: 24px;
  cursor: pointer;
}
.profile-close:hover { background: var(--explorer-surface); }
#profile-content {
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr) auto;
  flex: 1;
  min-height: 0;
}
.profile-company { display: flex; align-items: center; gap: 14px; }
.profile-company > div { min-width: 0; }
.profile-company img {
  flex: none;
  width: 64px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--explorer-line);
  border-radius: 10px;
  padding: 8px;
}
.profile-company h2 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0;
  overflow-wrap: anywhere;
}
.profile-company p { margin: 6px 0 0; font: 12px var(--mono); color: var(--explorer-muted); }
.profile-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin: 20px 0;
  padding-block: 18px;
  border-block: 1px solid var(--explorer-line);
}
.profile-facts div { min-width: 0; }
.profile-facts dt { font-size: 11px; color: var(--explorer-muted); margin-bottom: 4px; }
.profile-facts dd { margin: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.profile-overview { display: flex; flex-direction: column; min-height: 0; }
.profile-overview-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.profile-overview-header h3 { margin: 0; font-size: 16px; line-height: 1.5; }
.profile-overview-header a { display: inline-flex; align-items: center; min-height: 32px; font-size: 12px; color: var(--explorer-accent); }
.profile-overview .profile-description {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 8px;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--explorer-muted);
}
.profile-source {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  column-gap: 16px;
  border-top: 1px solid var(--explorer-line);
  margin-top: 18px;
  padding-top: 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--explorer-muted);
}
.profile-source p { margin: 4px 0; }
.profile-source > :first-child,
.profile-source > :nth-child(4),
.profile-source > :last-child { grid-column: 1 / -1; }
.profile-source a { display: inline-flex; min-height: 32px; align-items: center; color: var(--explorer-accent); }
@media (max-height: 700px) {
  /* Short viewports keep all content reachable rather than clipping it */
  #profile-content { display: block; flex: none; }
  .profile-overview .profile-description { overflow: visible; padding: 0; }
}
@media (max-width: 1100px) {
  body[data-view="companies"] .container {
    width: calc(100% - 48px);
  }
  body[data-view="companies"] .header-inner {
    padding-inline: 24px;
  }
  .explorer-workspace .company-filters {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 24px;
  }
  .explorer-sidebar {
    padding: 18px;
  }
  .explorer-source-notes {
    margin-left: 224px;
  }
  .explorer-search-row {
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 12px;
  }
  .explorer-filter-heading {
    display: grid;
    gap: 4px;
  }
  .explorer-filter-heading .company-filter-reset {
    justify-self: start;
  }
}
@media (max-width: 800px) {
  .explorer-opening {
    align-items: flex-start;
    gap: 20px;
  }
  .explorer-snapshot {
    display: none;
  }
  .explorer-workspace {
    --explorer-mobile-controls-height: calc(
      var(--explorer-sidebar-height, 66px) + 24px
    );
  }
  .explorer-workspace .company-filters {
    display: block;
  }
  .explorer-results {
    margin-top: 24px;
  }
  .explorer-search-row {
    top: calc(
      var(--explorer-header-height, 69px) +
        var(--explorer-sidebar-height, 66px) + 24px
    );
  }
  .explorer-search-row::before {
    top: calc(0px - var(--explorer-sidebar-height, 66px) - 24px);
    height: calc(var(--explorer-sidebar-height, 66px) + 24px);
  }
  .explorer-sidebar {
    max-height: max(
      62px,
      calc(
        100dvh - var(--explorer-header-height, 69px) -
          var(--explorer-search-height, 60px) - 120px
      )
    );
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 18px;
    gap: 16px;
  }
  .explorer-filter-heading {
    display: flex;
    grid-column: 1/-1;
  }
  .explorer-sidebar-note {
    display: none;
  }
  .explorer-source-notes {
    margin-left: 0;
  }
  .explorer-results .company-table th:nth-child(3),
  .explorer-results .company-table td:nth-child(3) {
    display: table-cell;
  }
  .explorer-results .company-table th:first-child {
    width: 40%;
  }
  .explorer-results .company-table th:nth-child(2) {
    width: 18%;
  }
  .explorer-results .company-table th:nth-child(3) {
    width: 22%;
  }
  .explorer-results .company-table th:nth-child(5) {
    width: 20%;
  }
  .explorer-results .company-context {
    display: none;
  }
}
@media (max-width: 550px) {
  body[data-view="companies"] .container {
    width: calc(100% - 32px);
  }
  body[data-view="companies"] .header-inner {
    padding-inline: 16px;
  }
  .explorer-opening {
    padding-block: 28px 24px;
  }
  body.directory-page[data-view="companies"]
    .explorer-opening
    .directory-intro {
    font-size: 14px;
  }
  .explorer-search-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .explorer-search-row .sort-label {
    max-width: none;
  }
  .explorer-list-toolbar {
    padding-top: 8px;
  }
  #company-results {
    flex: 1 1 100%;
    padding-bottom: 14px;
  }
  .explorer-sidebar {
    gap: 16px 12px;
    padding: 16px;
  }
  .explorer-filter-heading h2 {
    font-size: 14px;
  }
  .explorer-results .company-table th:nth-child(2),
  .explorer-results .company-table td:nth-child(2),
  .explorer-results .company-table th:nth-child(3),
  .explorer-results .company-table td:nth-child(3) {
    display: none;
  }
  .explorer-results .company-table th:first-child {
    width: 72%;
  }
  .explorer-results .company-table th:nth-child(5) {
    width: 28%;
  }
  .explorer-results .company-table tbody th,
  .explorer-results .company-table tbody td {
    padding-block: 18px;
  }
  .explorer-results .company-name {
    font-size: 12px;
  }
  .explorer-results .company-context {
    display: block;
    font-size: 10px;
  }
  .explorer-results .company-logo {
    --company-mark-size: 34px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }
  .explorer-results .company-identity {
    gap: 10px;
    align-items: flex-start;
  }
  .explorer-results .company-table .market-cap-cell {
    font-size: 12px;
  }
  .explorer-source-notes .directory-download {
    flex-direction: column;
    gap: 12px;
  }
  .company-profile {
    padding: 24px;
  }
  .profile-company h2 {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .company-profile[open] {
    animation: profile-enter 0.22s ease-out;
  }
  @keyframes profile-enter {
    from {
      transform: translateX(32px);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }
}

.explorer-filter-toggle {
  display: none;
}
.profile-description {
  margin-block: 12px 20px;
}
@media (max-width: 800px) {
  .explorer-filter-heading h2 {
    display: none;
  }
  .filters-enhanced .explorer-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    min-height: 40px;
    border: 0;
    background: transparent;
    font: 600 14px var(--sans);
    color: var(--explorer-ink);
  }
  .explorer-filter-toggle::after {
    content: "+";
    font-size: 18px;
  }
  .explorer-filter-toggle[aria-expanded="true"]::after {
    content: "−";
  }
  .explorer-sidebar.filters-enhanced:not(.is-expanded) > label {
    display: none;
  }
  .explorer-sidebar {
    padding-block: 10px;
  }
}

/* Preserve normal document flow when the interactive directory is unavailable */
.explorer-workspace:not(.has-sticky-controls) .explorer-sidebar,
.explorer-workspace:not(.has-sticky-controls) .explorer-search-row {
  position: static;
  max-height: none;
  overflow: visible;
}
.explorer-workspace:not(.has-sticky-controls) .explorer-search-row::before {
  display: none;
}

/* The drawer keeps its identity and tabs in view as corporate detail grows */
#profile-content { grid-template-rows: auto auto minmax(0, 1fr); }
.profile-tabs {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  border-bottom: 1px solid var(--explorer-line);
}
.profile-tab {
  min-height: 44px;
  padding: 0 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--explorer-muted);
  font: 500 13px var(--sans);
  text-align: left;
  cursor: pointer;
}
.profile-tab[aria-selected="true"] { color: var(--explorer-accent); border-color: var(--explorer-accent); }
.profile-tab:hover { color: var(--explorer-ink); }
.profile-panel {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 18px 8px 4px 0;
}
.profile-panel[hidden] { display: none; }
.profile-panel .profile-facts { margin: 0 0 16px; padding: 0 0 16px; border-top: 0; gap: 12px 24px; }
.profile-panel h3 { margin: 0 0 14px; font-size: 14px; line-height: 1.5; }
.profile-panel .profile-corporate-facts { margin: 0; padding: 0; border: 0; }
.profile-wide-fact { grid-column: 1 / -1; }
.profile-unavailable { color: var(--explorer-muted); font-size: 12px !important; }
.profile-sources-link {
  min-height: 44px;
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--explorer-accent);
  font: 500 12px var(--sans);
  cursor: pointer;
}
.profile-sources-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.profile-business-panel .profile-description { overflow: visible; padding: 0; }
.profile-corporate-sources {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--explorer-line);
  font-size: 11px;
  line-height: 1.6;
  color: var(--explorer-muted);
}
.profile-corporate-sources h3 { margin-bottom: 8px; font-size: 12px; color: var(--explorer-ink); }
.profile-corporate-sources a { display: inline-flex; align-items: center; min-height: 32px; color: var(--explorer-accent); }
.profile-corporate-sources p { margin: 0 0 8px; }
@media (max-height: 700px) {
  #profile-content { display: grid; flex: 1; }
}
@media (max-width: 420px) {
  .profile-tabs { gap: 18px; }
  .profile-tab { font-size: 12px; }
  .profile-panel .profile-facts { gap: 12px 16px; }
}
