/*!
 * Osool — application styles
 * Remaps Bootstrap 5.3's --bs-* variables onto the token ramp (tokens.css
 * must load first), then layers the §3 design system and the §3.6
 * component inventory on top. Editorial and dense: borders not shadows,
 * generous type, tight vertical rhythm, almost no decoration.
 * Plan ref: docs/osool-wireframes-plan.md §3
 */

/* ======================================================================
   1. Bootstrap variable remap
   ====================================================================== */
:root {
  --bs-body-bg: var(--n-25);
  --bs-body-color: var(--n-800);
  --bs-border-color: var(--n-100);
  --bs-emphasis-color: var(--n-900);
  --bs-secondary-color: var(--n-600);
  --bs-tertiary-bg: var(--n-50);
  --bs-link-color: var(--n-900);
  --bs-link-hover-color: var(--n-900);
  --bs-link-decoration: underline;
  --bs-primary: var(--n-900);
  --bs-primary-rgb: var(--n-900-rgb);

  /* Bootstrap's opacity-aware utilities (.text-body, .text-muted, .bg-*,
     .border-*-subtle …) read the "-rgb" companion, not the hex var above —
     without this remap those utilities silently stay Bootstrap-grey in
     dark mode even though every hex token remapped correctly. */
  --bs-body-bg-rgb: var(--n-25-rgb);
  --bs-body-color-rgb: var(--n-800-rgb);
  --bs-emphasis-color-rgb: var(--n-900-rgb);
  --bs-secondary-color-rgb: var(--n-600-rgb);
  --bs-tertiary-bg-rgb: var(--n-50-rgb);
  --bs-light-rgb: var(--n-50-rgb);
  --bs-dark-rgb: var(--n-900-rgb);

  --bs-font-sans-serif: var(--font-latin);
  --bs-body-font-size: 0.9375rem; /* 15px body */
  --bs-body-line-height: 1.53;
  --bs-border-radius: var(--radius-container);
  --bs-border-radius-sm: var(--radius-control);
  --bs-border-radius-lg: var(--radius-container);
  --bs-card-border-color: var(--n-100);
  --bs-card-bg: var(--n-0);
  --bs-table-border-color: var(--n-100);
}

/* ======================================================================
   2. Base
   ====================================================================== */
html {
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-family: var(--font-latin);
}

html[lang="ar"] body,
html[dir="rtl"] body {
  font-family: var(--font-arabic);
  font-size: calc(0.9375rem + 1px);
  line-height: 1.65;
}

a {
  color: var(--bs-link-color);
}

hr {
  border-color: var(--n-100);
  opacity: 1;
}

/* Every number aligns. Apply directly, or rely on .num utility. */
.num,
.tabular-nums,
table td.text-end,
.kpi-figure {
  font-variant-numeric: tabular-nums;
}

/* Visible focus ring on every interactive element (§10.3) */
:focus-visible {
  outline: 2px solid var(--n-900);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

::selection {
  background: var(--n-900);
  color: var(--n-0);
}

/* ======================================================================
   3. Type scale (§3.4)
   ====================================================================== */
.text-display,
h1.page-title {
  font-size: 1.75rem;   /* 28px */
  line-height: 2.125rem; /* 34px */
  font-weight: 600;
  color: var(--n-900);
  letter-spacing: -0.01em;
}

.text-section-title,
h2.section-title {
  font-size: 1.125rem; /* 18px */
  line-height: 1.5rem; /* 24px */
  font-weight: 600;
  color: var(--n-900);
}

/* Named .text-prose, not .text-body — Bootstrap already ships a
   .text-body *utility* class (color: var(--bs-body-color) !important) and
   colliding with it means Bootstrap's !important wins regardless of
   source order. */
.text-prose {
  font-size: 0.9375rem; /* 15px */
  line-height: 1.4375rem; /* 23px */
}

.text-data,
table {
  font-size: 0.875rem; /* 14px */
  line-height: 1.25rem; /* 20px */
}

.text-micro,
.label-micro,
.chip,
.badge-provenance {
  font-size: 0.71875rem; /* 11.5px */
  line-height: 1rem; /* 16px */
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi-figure {
  font-size: 1.875rem; /* 30px */
  line-height: 2.125rem; /* 34px */
  font-weight: 600;
  color: var(--n-900);
}

html[lang="ar"] .text-display,
html[lang="ar"] h1.page-title { font-size: 1.8125rem; line-height: 2.25rem; }
html[lang="ar"] .text-section-title,
html[lang="ar"] h2.section-title { font-size: 1.1875rem; line-height: 1.625rem; }
html[lang="ar"] .text-micro,
html[lang="ar"] .label-micro,
html[lang="ar"] .chip { font-size: 0.75rem; line-height: 1.125rem; }

/* ======================================================================
   4. Layout shell — header / footer (rendered by js/shell.js)
   ====================================================================== */
#shell-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: 72px;
  display: flex;
  align-items: center;
  background: var(--n-0);
  border-bottom: var(--border-hairline);
  transition: height var(--dur-base) var(--ease-in-out);
}

#shell-header.is-condensed {
  height: 56px;
}

.shell-container {
  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.shell-wordmark {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--n-900);
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
}

.shell-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex: 1;
  justify-content: center;
  min-width: 0; /* let it shrink/scroll instead of forcing the header wide */
}

/* Below 768px the six-tab nav becomes the bottom bar (§9.6, .shell-bottom-bar
   below), so the header's own tab row is not shown at all — leaving it in
   as a scroller meant the header still competed for width with the wordmark
   and the action buttons at 375px. */
@media (max-width: 767.98px) {
  .shell-nav {
    display: none;
  }
}

.shell-nav a {
  color: var(--n-600);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding-block: calc(var(--sp-6) + 2px) var(--sp-2);
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.shell-nav a:hover {
  color: var(--n-900);
}

.shell-nav a.is-active {
  color: var(--n-900);
  border-bottom-color: var(--n-900);
  font-weight: 600;
}

.shell-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.shell-actions button {
  background: none;
  border: none;
  color: var(--n-600);
  padding: var(--sp-2);
  border-radius: var(--radius-control);
  line-height: 1;
}

.shell-actions button:hover {
  color: var(--n-900);
  background: var(--n-50);
}

#shell-footer {
  border-top: var(--border-hairline);
  background: var(--n-0);
  padding-block: var(--sp-8);
  margin-top: var(--sp-16);
  color: var(--n-600);
  font-size: 0.8125rem;
}

main {
  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: var(--sp-6);
}

/* ======================================================================
   5. Component inventory (§3.6)
   ====================================================================== */

/* -- KPI tile --------------------------------------------------------- */
.kpi-tile {
  background: var(--n-0);
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  padding: var(--sp-4);
}

.kpi-tile .kpi-label {
  color: var(--n-600);
  margin-bottom: var(--sp-2);
}

.kpi-tile .kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-top: var(--sp-1);
}

.kpi-tile .kpi-delta.is-positive { color: var(--pos); }
.kpi-tile .kpi-delta.is-negative { color: var(--neg); }

/* -- Data table -------------------------------------------------------- */
.table-osool {
  border-collapse: separate;
  border-spacing: 0;
}

.table-osool thead th {
  position: sticky;
  top: 0;
  background: var(--n-0);
  color: var(--n-600);
  font-size: 0.71875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: var(--border-strong);
  padding-block: var(--sp-3);
  white-space: nowrap;
}

.table-osool thead th[data-sortable] {
  cursor: pointer;
  user-select: none;
}

.table-osool tbody tr:nth-child(even) {
  background: var(--n-50);
}

.table-osool tbody tr:hover {
  background: var(--n-100);
}

.table-osool td,
.table-osool th {
  border-bottom: var(--border-hairline);
  padding: var(--sp-2) var(--sp-3);
}

.table-osool td.num,
.table-osool th.num {
  text-align: end;
}

/* accounting-style negatives, never a bare minus (§3.3) */
.num-negative::before { content: "("; }
.num-negative::after { content: ")"; }

/* -- Panel --------------------------------------------------------------- */
.panel {
  background: var(--n-0);
  border: var(--border-hairline);
  border-radius: var(--radius-container);
}

.panel > .panel-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: var(--border-hairline);
}

.panel > .panel-header .panel-title {
  flex: 1;
}

.panel > .panel-body {
  padding: var(--sp-4);
}

.panel > .panel-body.is-flush {
  padding: 0;
}

/* cards do not nest — a card-in-a-card becomes a borderless well */
.panel .panel,
.panel .card {
  background: var(--n-50);
  border: none;
  border-radius: var(--radius-control);
}

/* -- Provenance chip ------------------------------------------------------ */
.badge-provenance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--sp-2);
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: default;
}

.badge-provenance.is-live {
  border: 1px solid var(--n-900);
  color: var(--n-900);
}

.badge-provenance.is-sample {
  border: 1px dashed var(--n-400);
  color: var(--n-600);
}

/* -- Filter bar ------------------------------------------------------------ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
}

.filter-bar .filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 4px var(--sp-3);
  font-size: 0.8125rem;
  background: var(--n-0);
}

.filter-bar .filter-chip button {
  border: none;
  background: none;
  color: var(--n-600);
  line-height: 1;
  padding: 0;
}

/* -- Peer-set builder ------------------------------------------------------- */
.peer-set-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--n-50);
  border: var(--border-hairline);
  border-radius: var(--radius-container);
}

.peer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--n-0);
  border: var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 4px var(--sp-3);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: opacity var(--dur-base) var(--ease-in-out);
}

.peer-chip button {
  border: none;
  background: none;
  padding: 0;
  color: var(--n-600);
  line-height: 1;
}

.peer-chip.is-removing {
  opacity: 0;
}

/* -- Timeline --------------------------------------------------------------- */
.timeline {
  position: relative;
  padding-inline-start: var(--sp-8);
}

.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(var(--sp-4) - 1px);
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--n-100);
}

.timeline-item {
  position: relative;
  padding-block-end: var(--sp-6);
}

.timeline-item::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(-1 * var(--sp-8) + var(--sp-1));
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--n-900);
  border: 2px solid var(--n-0);
  box-shadow: 0 0 0 1px var(--n-200);
}

.timeline-item .timeline-date {
  color: var(--n-600);
  font-size: 0.8125rem;
}

/* -- Segmented control ------------------------------------------------------- */
.segmented {
  display: inline-flex;
  border: var(--border-strong);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.segmented button {
  background: var(--n-0);
  border: none;
  padding: 6px var(--sp-3);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--n-600);
  border-inline-start: var(--border-hairline);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.segmented button:first-child {
  border-inline-start: none;
}

.segmented button.is-active {
  background: var(--n-900);
  color: var(--n-0);
}

/* -- Empty state -------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-6);
  color: var(--n-600);
}

.empty-state .empty-state-icon {
  color: var(--n-400);
}

/* -- Skeleton ------------------------------------------------------------------- */
.skeleton {
  position: relative;
  background: var(--n-100);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.5), transparent);
  animation: skeleton-shimmer 1.6s var(--ease-in-out) infinite;
}

:root[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.08), transparent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .skeleton::after {
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.08), transparent);
  }
}

@keyframes skeleton-shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}

/* -- Command palette ------------------------------------------------------------- */
.command-palette .modal-content {
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-overlay);
  border: var(--border-hairline);
}

.command-palette input[type="search"] {
  border: none;
  border-bottom: var(--border-hairline);
  border-radius: 0;
  padding: var(--sp-4);
  font-size: 1rem;
}

.command-palette input[type="search"]:focus {
  box-shadow: none;
}

.command-palette .command-result {
  padding: var(--sp-2) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}

.command-palette .command-result.is-active,
.command-palette .command-result:hover {
  background: var(--n-50);
}

/* ======================================================================
   6. Motion utility classes (§9), reduced-motion-safe by construction
      because --dur-* collapses to 0.01ms under prefers-reduced-motion
   ====================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.crossfade {
  transition: opacity var(--dur-base) var(--ease-in-out);
}

.is-dimmed {
  opacity: 0.4;
  transition: opacity var(--dur-fast) var(--ease-in-out);
}

/* ======================================================================
   7. Bootstrap component overrides
   ====================================================================== */
.card {
  box-shadow: none;
}

.dropdown-menu,
.modal-content,
.offcanvas {
  box-shadow: var(--shadow-overlay);
  border: var(--border-hairline);
}

.btn {
  border-radius: var(--radius-control);
  font-weight: 500;
}

.btn-dark {
  background: var(--n-900);
  border-color: var(--n-900);
}

.btn-outline-dark {
  color: var(--n-900);
  border-color: var(--n-200);
}

.btn-outline-dark:hover {
  background: var(--n-900);
  border-color: var(--n-900);
}

.form-control,
.form-select {
  border-radius: var(--radius-control);
  border-color: var(--n-200);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--n-600);
  box-shadow: 0 0 0 3px rgb(20 20 23 / 0.08);
}

/* ======================================================================
   8. Chart panel (§4, §4.3, §10.3) — every chart lives inside a .panel
      (§3.6) with a canvas node and a same-shaped <table> alternative,
      toggled by a single button. js/charts.js owns the toggle logic and
      the RTL mirror attribute; this file only lays the two states out.
   ====================================================================== */
.chart-panel-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
}

.panel-body.is-flush .chart-canvas {
  padding: var(--sp-4);
}

.chart-table-wrap {
  overflow-x: auto;
}

.chart-table-wrap[hidden] {
  display: none;
}

.chart-view-toggle[aria-pressed="true"] {
  background: var(--n-900);
  border-color: var(--n-900);
  color: var(--n-0);
}

/* Sparkline host cell — screener/watchlist/sector-index tables (§4.2). */
.sparkline-cell {
  width: 96px;
  height: 32px;
  display: inline-block;
}

/* Chart grid — two-up on the styleguide and any page laying out chart
   panels side by side; collapses to one column under 992px per §9.6. */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}

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

.chart-panel-wide {
  grid-column: 1 / -1;
}

/* ======================================================================
   9. Company page (§8.6) — the core product story. Everything below is
      specific to company.html: the header/banner, the sticky scroll-spy
      sub-nav + Compare strip, the board monogram avatars, the statement
      table's indent/total rules, the provenance viewer's image+rows
      layout, and the company-picker modal shared with the Phase 5
      peer-set builder.
   ====================================================================== */

/* -- Chart containment inside Bootstrap's flex grid ------------------------
   A Bootstrap flex column's default min-width is `auto`, which lets an
   ApexCharts SVG's own first-paint intrinsic measurement (taken before the
   row's flex layout has finished distributing space) win over the
   column's own CSS width — the chart ends up measuring against something
   far wider than its column (observed: a radial gauge sized to roughly
   the full row instead of its own half), which then paints past its
   panel's edge into the sibling column. Forcing min-width:0 on every
   flex/grid column that can host a chart makes the CSS width authoritative
   before ApexCharts ever measures it — the standard fix for this class of
   ApexCharts-in-flexbox bug. Scoped to .company-section so it cannot
   change any other page's Bootstrap grid behaviour. */
.company-section .row > [class*="col-"] {
  min-width: 0;
}
.company-section .chart-canvas {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

/* -- Company header -------------------------------------------------------- */
.company-header {
  position: relative;
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  overflow: hidden;
  background: var(--n-0);
}

.company-header-banner {
  position: relative;
  height: 160px;
  overflow: hidden;
}

.company-header-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.company-header-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(20 20 23 / 0.15) 0%, rgb(20 20 23 / 0.72) 100%);
}

/* The company's own name is the page's one <h1> (§10.3) — it is a heading
   in the markup and a lockup in the layout, so the browser's own heading
   metrics are reset here rather than fought elsewhere. */
.company-header-titles {
  margin: 0;
  font-size: inherit;
  font-weight: 400;
  position: absolute;
  inset-inline-start: var(--sp-6);
  inset-block-end: var(--sp-4);
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.company-header-symbol {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px var(--sp-2);
  border: 1px solid rgb(255 255 255 / 0.6);
  border-radius: var(--radius-control);
}

.company-header-name-en {
  font-size: 1.5rem;
  font-weight: 600;
}

.company-header-name-ar {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  opacity: 0.92;
}

.company-header-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
}

.company-header-meta {
  color: var(--n-600);
  font-size: 0.8125rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.company-header-meta .dot-sep::before {
  content: "·";
  margin-inline-end: 6px;
  color: var(--n-400);
}

.company-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.company-header-actions .btn-star.is-active {
  background: var(--n-900);
  color: var(--n-0);
  border-color: var(--n-900);
}

.company-header-actions .btn-star.is-bouncing {
  animation: company-star-bounce var(--dur-slow) var(--ease-out);
}

@keyframes company-star-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* -- Sticky bar: Compare strip (conditional) + scroll-spy sub-nav --------- */
.company-sticky-bar {
  position: sticky;
  top: 72px;
  z-index: 1020;
  background: var(--n-25);
  transition: top var(--dur-base) var(--ease-in-out);
}

header#shell-header.is-condensed + main .company-sticky-bar {
  top: 56px;
}

.compare-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--n-900);
  color: var(--n-0);
  font-size: 0.8125rem;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
}

.compare-strip .compare-strip-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-inline-end: 4px;
}

.compare-strip button {
  border: 1px solid rgb(255 255 255 / 0.4);
  background: none;
  color: var(--n-0);
  border-radius: var(--radius-control);
  padding: 2px var(--sp-3);
  font-size: 0.75rem;
}

.company-subnav {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  padding-inline: var(--sp-2);
  border: var(--border-hairline);
  border-top: none;
  background: var(--n-0);
  overflow-x: auto;
  scrollbar-width: none;
}

.company-subnav::-webkit-scrollbar {
  display: none;
}

.company-subnav a {
  flex: none;
  color: var(--n-600);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  padding-block: var(--sp-3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.company-subnav a:hover {
  color: var(--n-900);
}

.company-subnav a.is-active {
  color: var(--n-900);
  border-bottom-color: var(--n-900);
  font-weight: 600;
}

.company-section {
  scroll-margin-top: var(--company-scroll-offset, 128px);
  padding-block: var(--sp-12) 0;
}

.company-section:first-of-type {
  padding-block-start: var(--sp-8);
}

/* -- KPI row, single and Compare-mode split -------------------------------- */
.kpi-tile {
  position: relative;
}

.kpi-tile .kpi-tile-chip {
  position: absolute;
  inset-block-start: var(--sp-2);
  inset-inline-end: var(--sp-2);
  font-size: 0.625rem;
  padding: 1px 6px;
}

.kpi-compare-group {
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  padding: var(--sp-3);
}

.kpi-compare-group .kpi-compare-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--n-600);
  margin-bottom: var(--sp-2);
}

.kpi-compare-group .kpi-compare-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* -- Governance: board / senior-executive cards, monogram avatars --------- */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
}

.board-card {
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  padding: var(--sp-3);
  display: flex;
  gap: var(--sp-3);
}

.board-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--n-100);
  color: var(--n-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.board-card-body {
  min-width: 0;
}

.board-card-name {
  font-weight: 600;
  color: var(--n-900);
  font-size: 0.875rem;
}

.board-card-role {
  color: var(--n-600);
  font-size: 0.8125rem;
  margin-block: 2px;
}

.board-card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-block-start: var(--sp-2);
}

/* -- Financials: statement table indent + totals, restated delta --------- */
.statement-table td.row-label[data-level="1"] { padding-inline-start: calc(var(--sp-3) + var(--sp-4)); }
.statement-table td.row-label[data-level="2"] { padding-inline-start: calc(var(--sp-3) + var(--sp-8)); }

.statement-table tr.is-total td {
  font-weight: 600;
  border-top: var(--border-strong);
}

.statement-table td.is-restated {
  background: color-mix(in srgb, var(--c-2) 14%, transparent);
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  margin-inline-start: 6px;
  background: color-mix(in srgb, var(--c-2) 22%, transparent);
  color: var(--n-800);
}

/* -- Documents: provenance viewer ------------------------------------------ */
.provenance-viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--sp-4);
}

@media (max-width: 991.98px) {
  .provenance-viewer {
    grid-template-columns: 1fr;
  }
}

.provenance-viewer-image {
  border: var(--border-hairline);
  border-radius: var(--radius-control);
  overflow: auto;
  background: var(--n-50);
  max-height: 720px;
}

.provenance-viewer-image img {
  width: 100%;
  display: block;
}

.provenance-note-ref {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--n-600);
  vertical-align: super;
  margin-inline-start: 2px;
}

.provenance-table tr.is-total td {
  font-weight: 600;
  border-top: var(--border-strong);
}

/* -- Ownership donut legend -------------------------------------------------- */
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.8125rem;
}

.donut-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

/* -- Company picker modal (§8.4/§8.6, shared with the Phase 5 peer-set
   builder) ------------------------------------------------------------- */
.company-picker .modal-content {
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-overlay);
  border: var(--border-hairline);
}

.company-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-4) 0;
}

.company-picker-title {
  margin: 0;
}

.company-picker-search {
  margin: var(--sp-3) var(--sp-4);
  width: calc(100% - 2 * var(--sp-4));
  border: none;
  border-bottom: var(--border-hairline);
  border-radius: 0;
  padding: var(--sp-2) 0;
  font-size: 1rem;
  background: none;
  color: var(--n-900);
}

.company-picker-search:focus {
  outline: none;
  border-bottom-color: var(--n-900);
}

.company-picker-filters {
  padding-inline: var(--sp-4);
}

.company-picker-chip.is-active {
  background: var(--n-900);
  border-color: var(--n-900);
  color: var(--n-0);
}

.company-picker-results {
  max-height: 360px;
  overflow-y: auto;
  padding-block: var(--sp-2);
}

.company-picker-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
}

.company-picker-row:hover {
  background: var(--n-50);
}

.company-picker-row.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.company-picker-symbol {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  width: 52px;
  flex: none;
}

.company-picker-name {
  flex: 1;
  min-width: 0;
}

.company-picker-sector {
  color: var(--n-600);
}

.company-picker-empty {
  padding: var(--sp-6) var(--sp-4);
  color: var(--n-600);
  text-align: center;
}

/* -- Announcements: legal pin ------------------------------------------------ */
.legal-pin {
  border: 1px dashed var(--n-400);
  border-radius: var(--radius-container);
  padding: var(--sp-4);
}

/* ======================================================================
   10. Screener + Sector (§8.3, §8.4, §8.5) — the analyst workflow. The
       universe here is honestly 13 companies, not 270 (§6 constraint);
       every component below is built to demonstrate the real pattern
       against that real cohort rather than hide the gap. Shared across
       screener.html, sectors.html and sector.html.
   ====================================================================== */

.screener-section,
.sectors-section,
.sector-section {
  padding-block: var(--sp-8) var(--sp-16);
}

/* -- Coverage / honest-gap banner (screener + sectors) ---------------------- */
.coverage-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--n-50);
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  margin-block-end: var(--sp-4);
}

.coverage-banner-icon {
  flex: none;
  color: var(--n-600);
  margin-block-start: 2px;
}

.coverage-banner-body p {
  margin-bottom: 4px;
}

.coverage-banner-body a {
  color: var(--n-900);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* -- Coverage dot (screener results table, §8.5) ----------------------------
   Filled = full financials on file; hollow = reference data only. Colour
   never carries this meaning alone (§10.3) — both states also read out in
   the row's tooltip and in the Coverage filter's option text. */
.coverage-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.coverage-dot.is-full {
  background: var(--n-900);
  border: 1px solid var(--n-900);
}

.coverage-dot.is-reference {
  background: transparent;
  border: 1px solid var(--n-400);
}

.table-osool td.coverage-cell,
.table-osool th.coverage-cell {
  width: 1%;
  padding-inline-end: var(--sp-1);
}

/* -- Screener results table row is a full navigation target ---------------- */
.table-osool tbody tr.is-clickable {
  cursor: pointer;
}

/* -- Screener / sector-league sortable header caret -------------------------- */
.table-osool th[data-sortable] {
  cursor: pointer;
  user-select: none;
}

.table-osool th[data-sortable]::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-inline-start: 5px;
  vertical-align: middle;
  border-inline: 3px solid transparent;
  opacity: 0.35;
}

.table-osool th[data-sortable][data-dir="asc"]::after {
  border-bottom: 5px solid currentColor;
  opacity: 1;
}

.table-osool th[data-sortable][data-dir="desc"]::after {
  border-top: 5px solid currentColor;
  opacity: 1;
}

/* -- Pagination control (§8.5) ---------------------------------------------- */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-block: var(--sp-3);
}

.pagination-bar .pagination {
  margin: 0;
}

.pagination-bar .page-link {
  border-color: var(--n-200);
  color: var(--n-800);
  border-radius: var(--radius-control);
  margin-inline-start: 4px;
}

.pagination-bar .page-item:first-child .page-link,
.pagination-bar .page-item:last-child .page-link {
  border-radius: var(--radius-control);
}

.pagination-bar .page-item.active .page-link {
  background: var(--n-900);
  border-color: var(--n-900);
  color: var(--n-0);
}

.pagination-bar .page-item.disabled .page-link {
  color: var(--n-400);
  background: var(--n-0);
}

.pagination-bar .per-page-select {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--n-600);
  font-size: 0.8125rem;
}

.pagination-bar .per-page-select select {
  width: auto;
}

/* -- Sector index cards (§8.3) ----------------------------------------------- */
.sector-card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}

@media (max-width: 1199.98px) {
  .sector-card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575.98px) {
  .sector-card-grid { grid-template-columns: 1fr; }
}

.sector-card {
  display: flex;
  flex-direction: column;
  background: var(--n-0);
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  overflow: hidden;
  text-align: start;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.sector-card:hover {
  border-color: var(--n-400);
}

.sector-card-image {
  position: relative;
  aspect-ratio: 3 / 1;
  background: var(--n-50);
  overflow: hidden;
}

.sector-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sector-card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--n-400);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Sectors with no financials yet (§8.3) render muted — the empty state
   itself is the honest signal, never a fabricated sparkline. */
.sector-card.is-empty .sector-card-image {
  filter: grayscale(1);
  opacity: 0.55;
}

.sector-card.is-empty .sector-card-body {
  color: var(--n-600);
}

.sector-card-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}

.sector-card-name {
  font-weight: 600;
  color: var(--n-900);
  font-size: 1rem;
}

.sector-card-counts {
  color: var(--n-600);
}

.sector-card-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-block-start: auto;
  padding-block-start: var(--sp-2);
}

.sector-card-bar {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--n-100);
  overflow: hidden;
}

.sector-card-bar-fill {
  height: 100%;
  background: var(--n-900);
  border-radius: var(--radius-pill);
}

.sector-card-note {
  color: var(--n-400);
  font-style: italic;
}

/* -- Sector detail (§8.4) ----------------------------------------------------- */
.sector-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-end: var(--sp-4);
}

.sector-header-meta {
  color: var(--n-600);
}

/* Peer-set builder presets row — sits directly under the peer-set-bar
   chips (§3.6, §8.4). Reuses .peer-set-bar's chip visuals for consistency,
   the container itself is a plain flex row rather than the bordered well. */
.peer-preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-block-start: var(--sp-3);
}

.peer-preset-row button {
  border: var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--n-0);
  padding: 4px var(--sp-3);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--n-800);
}

.peer-preset-row button:hover {
  border-color: var(--n-600);
}

.peer-preset-row button:disabled {
  color: var(--n-400);
  cursor: not-allowed;
}

.peer-preset-row .peer-preset-sep {
  width: 1px;
  align-self: stretch;
  background: var(--n-100);
  margin-inline: 4px;
}

/* Sector charts + screener panels can sit in a Bootstrap flex column, same
   ApexCharts-measurement race as the company page (§8.6's own fix,
   documented there) — scoped locally so this phase does not depend on
   editing company.html's rule. */
.sector-section .row > [class*="col-"],
.screener-section .row > [class*="col-"] {
  min-width: 0;
}
.sector-section .chart-canvas,
.screener-section .chart-canvas {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

/* -- Toast (§9.4 "Add to watchlist… toast slides in from the bottom-end
   corner" — the same pattern, first built out here for the peer-set save
   and 4-series-ceiling notices). Fixed, stacked, auto-dismissing. */
.osool-toast-stack {
  position: fixed;
  inset-block-end: var(--sp-6);
  inset-inline-end: var(--sp-6);
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: min(360px, calc(100vw - 2 * var(--sp-6)));
}

.osool-toast {
  background: var(--n-900);
  color: var(--n-0);
  border-radius: var(--radius-container);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-overlay);
  font-size: 0.8125rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.osool-toast.is-visible {
  opacity: 1;
  transform: none;
}

/* -- Sector news panel Local/Global toggle reuses .segmented; sector news
   list reuses the front-page-style story-row pattern, defined fresh here
   since no card list component exists yet in shared CSS. */
.news-row-list {
  display: flex;
  flex-direction: column;
}

.news-row {
  display: flex;
  gap: var(--sp-3);
  padding-block: var(--sp-3);
  border-block-end: var(--border-hairline);
}

.news-row:last-child {
  border-block-end: none;
}

.news-row-thumb {
  flex: none;
  width: 72px;
  height: 48px;
  border-radius: var(--radius-control);
  overflow: hidden;
  background: var(--n-50);
}

.news-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.news-row-body {
  min-width: 0;
}

.news-row-title {
  color: var(--n-900);
  font-size: 0.875rem;
  font-weight: 500;
  display: block;
}

.news-row-meta {
  color: var(--n-600);
}

/* -- Comparison table sample-column dash marker (§8.4) ----------------------- */
.table-osool td.is-sample-cell {
  color: var(--n-400);
}

/* ======================================================================
   11. Market + Macro (§8.1, §8.2) — the acquisition surface.
   ====================================================================== */

.market-section,
.macro-section {
  padding-block: var(--sp-6) var(--sp-16);
}

/* Shared panel sub-heading: the one line under a panel header that says
   what the panel is measuring and, where it matters, what it is not. */
.panel-note {
  margin: 0;
  padding: var(--sp-2) var(--sp-4) 0;
  color: var(--n-600);
}

/* Generic mid-dot separator — the company header had a scoped copy; this
   is the same glyph made available to any inline meta line. */
.dot-sep::before {
  content: "·";
  margin-inline: var(--sp-2);
  color: var(--n-400);
}

/* -- Market strip (§8.1 #1) ------------------------------------------------
   Full-bleed line under the header; past 240px of scroll it docks, sitting
   directly beneath the (by then condensed) header rather than scrolling
   away — the one number a visitor wants while reading anything else. */
.market-strip {
  border-block-end: var(--border-hairline);
  background: var(--n-0);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-6);
  max-width: 1360px;
  margin-inline: auto;
  overflow-x: auto;
  scrollbar-width: none;
  transition: box-shadow var(--dur-base) var(--ease-in-out), padding var(--dur-base) var(--ease-in-out);
}

.market-strip::-webkit-scrollbar { display: none; }

.market-strip.is-docked {
  position: sticky;
  inset-block-start: 56px;
  z-index: 1010;
  box-shadow: 0 1px 0 0 var(--n-100), 0 6px 16px -12px rgb(20 20 23 / 0.3);
}

.market-strip-inner {
  display: flex;
  align-items: baseline;
  gap: var(--sp-6);
  flex: 1;
  white-space: nowrap;
}

.market-strip-item {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: 0.8125rem;
  color: var(--n-800);
}

.market-strip-label {
  color: var(--n-600);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.market-strip-figure {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--n-900);
}

.market-strip-delta.is-positive { color: var(--pos); }
.market-strip-delta.is-negative { color: var(--neg); }

.market-strip-asof {
  color: var(--n-400);
  font-size: 0.75rem;
}

/* -- Lead story (§8.1 #2) -------------------------------------------------- */
.lead-story {
  display: block;
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  overflow: hidden;
  background: var(--n-0);
}

.lead-story-image {
  aspect-ratio: 16 / 9;
  background: var(--n-50);
  overflow: hidden;
}

.lead-story-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lead-story-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: flex-start;
}

.lead-story-headline {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 600;
  color: var(--n-900);
  margin: 0;
  letter-spacing: -0.015em;
}

/* The standfirst is the same headline in the other language — real
   bilingual content, so it must be allowed to set its own direction. */
.lead-story-standfirst {
  color: var(--n-600);
  margin: 0;
  unicode-bidi: plaintext;
}

.lead-story-meta,
.story-card-meta {
  color: var(--n-600);
}

.lead-story-meta a,
.story-card-meta a {
  color: var(--n-800);
  text-decoration: none;
  border-block-end: 1px solid var(--n-200);
}

.lead-story-meta a:hover,
.story-card-meta a:hover { color: var(--n-900); }

/* -- Story grid (§8.1 #4) -------------------------------------------------- */
.market-category-chips {
  flex-wrap: wrap;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

@media (max-width: 575.98px) {
  .story-grid { grid-template-columns: minmax(0, 1fr); }
}

.story-card {
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  overflow: hidden;
  background: var(--n-0);
  display: flex;
  flex-direction: column;
  transition: border-color var(--dur-fast) var(--ease-in-out);
}

.story-card:hover { border-color: var(--n-200); }

.story-card-image {
  aspect-ratio: 16 / 9;
  background: var(--n-50);
  overflow: hidden;
}

.story-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-card-body {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: flex-start;
  flex: 1;
}

.story-card-headline {
  font-size: 0.9375rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--n-900);
  margin: 0;
}

/* -- Announcement feed (§8.1 #3) — the page's honest core ------------------ */
.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 620px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-block-end: var(--border-hairline);
}

.feed-item:last-child { border-block-end: none; }

.feed-time {
  color: var(--n-400);
  font-size: 0.75rem;
  padding-block-start: 2px;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.feed-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.feed-symbol {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--n-900);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

/* A title in the language the source actually carries — never mirrored to
   match the surrounding chrome (§8.1 #3), so it sets its own direction. */
.feed-title {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--n-800);
  text-decoration: none;
  unicode-bidi: isolate;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-title:hover { color: var(--n-900); text-decoration: underline; }

.feed-meta { color: var(--n-400); }

.feed-footer {
  border-block-start: var(--border-hairline);
  padding: var(--sp-3) var(--sp-4);
}

.feed-footer a {
  font-size: 0.8125rem;
  color: var(--n-900);
  font-weight: 500;
}

/* -- Movers (§8.1 #6) ------------------------------------------------------ */
.movers-split > [class*="col-"] + [class*="col-"] {
  border-inline-start: var(--border-hairline);
}

@media (max-width: 767.98px) {
  .movers-split > [class*="col-"] + [class*="col-"] {
    border-inline-start: none;
    border-block-start: var(--border-hairline);
  }
}

.movers-heading {
  margin: 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  color: var(--n-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mover-symbol { font-weight: 600; color: var(--n-900); }
.mover-name { color: var(--n-600); font-size: 0.8125rem; }
.mover-spark { width: 96px; }

/* -- Page hero strip (§8.2) ------------------------------------------------ */
.page-hero {
  position: relative;
  height: 240px;
  overflow: hidden;
  border-block-end: var(--border-hairline);
}

.page-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Heavy dark overlay — the image is atmosphere, the type is the content
   (§7.3), so contrast on the title is not left to the photograph. */
.page-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(10 10 12 / 0.86), rgb(10 10 12 / 0.5));
}

.page-hero-body {
  position: absolute;
  inset-block-end: var(--sp-6);
  inset-inline-start: 0;
  inset-inline-end: 0;
  z-index: 1;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: var(--sp-6);
}

.page-hero-title {
  color: #fff;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 var(--sp-1);
}

.page-hero-sub {
  color: rgb(255 255 255 / 0.78);
  font-size: 0.875rem;
  max-width: 62ch;
}

/* -- Macro KPI sparkline --------------------------------------------------- */
.kpi-spark {
  color: var(--c-1);
  margin-block-start: var(--sp-2);
  width: 100%;
  height: 26px;
}

/* Skeleton block group shown until the front page's first fetch resolves
   (§9.2 step 1) — removed by motion.js `swapSkeleton`. */
.market-skeleton { display: block; }

/* Plain tooltip body for the ApexCharts `custom` tooltips (football
   field), which bypass the library's own themed markup. */
.apex-tooltip-plain {
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.75rem;
  background: var(--n-900);
  color: var(--n-0);
}

/* KPI unit line — keeps "SAR bn" off the figure's own line, so a
   four-digit money-supply reading does not wrap mid-tile. */
.kpi-unit {
  color: var(--n-600);
  margin-block-start: -2px;
}

/* §9.3 — anchored scrolling must clear the condensed header and, on the
   front page, the docked market strip.
   Scoped to the things that are actually anchor targets: a bare `[id]`
   also applies to every button and input, and the browser honours
   scroll-margin when it scrolls a focused control into view — which
   jumped the page ~90px on any click in the sticky header. */
.panel,
section[id],
.company-section,
main > [id] {
  scroll-margin-top: 108px;
}

/* ======================================================================
   12. Technical + Valuation + Export (§8.7–8.9) — the switching-cost
       features. These are the three densest screens in the product, so
       every component below trades ornament for legible density.
   ====================================================================== */

.technical-section,
.valuation-section,
.export-section {
  padding-block: var(--sp-8) var(--sp-16);
}

/* -- Technical toolbar (§8.7) ---------------------------------------------
   Interval and range are two controls, deliberately: one is granularity,
   the other is span, and a single combined control hides the distinction
   the plan's own data requirements turn on. */
.tech-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: var(--border-hairline);
  border-radius: var(--radius-container);
  background: var(--n-0);
  margin-block-end: var(--sp-3);
}

.tech-toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.tech-toolbar-group.is-disabled,
#tech-adjusted-wrap.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tech-symbol-btn { font-weight: 600; }

/* The brush sits flush under the price chart, reading as one instrument
   rather than a second panel. */
.tech-brush {
  border-block-start: var(--border-hairline);
  padding-block-start: var(--sp-1);
}

/* -- Drawing / pattern tools (visual only, and they say so) --------------- */
.tool-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.tool-row-label {
  flex: 0 0 72px;
  color: var(--n-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tool-btn {
  border: var(--border-strong);
  background: var(--n-0);
  color: var(--n-800);
  border-radius: var(--radius-control);
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-in-out), transform var(--dur-fast) var(--ease-out);
}

.tool-btn:hover { background: var(--n-50); }
.tool-btn.is-pressed { transform: scale(0.96); background: var(--n-100); }

/* -- Valuation: method tabs (§8.8) ---------------------------------------- */
.method-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  border-block-end: var(--border-hairline);
}

.method-tab {
  border: none;
  background: none;
  color: var(--n-600);
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.875rem;
  font-weight: 500;
  border-block-end: 2px solid transparent;
  margin-block-end: -1px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-in-out), border-color var(--dur-base) var(--ease-in-out);
}

.method-tab:hover { color: var(--n-900); }

.method-tab.is-active {
  color: var(--n-900);
  border-block-end-color: var(--n-900);
}

/* The one greyed tab is how "the method set adapts to company stage and
   sector" is shown without building a stage classifier (§8.8). */
.method-tab.is-disabled {
  color: var(--n-200);
  cursor: not-allowed;
}

/* -- Valuation: assumption rows ------------------------------------------- */
.assumption-row {
  display: grid;
  grid-template-columns: 14px 1fr 132px;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-block-end: var(--border-hairline);
}

.assumption-row:last-child { border-block-end: none; }

.assumption-row.is-child {
  padding-inline-start: var(--sp-8);
  background: var(--n-25);
}

.assumption-row.is-changed { background: color-mix(in srgb, var(--c-2) 8%, transparent); }

/* Filled square = derived from data we hold. Hollow = assumed, and you
   should change it. The plan's own principle as an interface element. */
.prov-mark {
  width: 9px;
  height: 9px;
  display: inline-block;
  border: 1.5px solid var(--n-800);
}

.prov-mark.is-derived { background: var(--n-800); }
.prov-mark.is-assumed { background: transparent; }

.assumption-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: 0.8125rem;
  color: var(--n-800);
  min-width: 0;
}

.assumption-source {
  color: var(--n-400);
  flex-basis: 100%;
}

.assumption-expand {
  border: none;
  background: none;
  color: var(--n-600);
  padding: 0 2px;
  cursor: pointer;
  line-height: 1;
}

.assumption-control {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  justify-content: flex-end;
}

.assumption-input {
  width: 84px;
  text-align: end;
}

.assumption-suffix {
  color: var(--n-600);
  font-size: 0.8125rem;
  width: 12px;
}

.assumption-modified-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-2);
  flex: 0 0 auto;
}

.assumption-legend {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-block-start: var(--border-hairline);
  font-size: 0.75rem;
  color: var(--n-600);
}

.assumption-legend > span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

/* -- Valuation: output table --------------------------------------------- */
.output-table td.is-osool-col { color: var(--n-600); }
.output-table td.is-yours-col { color: var(--n-900); font-weight: 600; }
.output-table th:last-child { color: var(--n-900); }

/* -- Valuation: consensus (the SAMPLE slot, shown as a slot) -------------- */
.consensus-bar {
  position: relative;
  height: 28px;
  margin-block: var(--sp-2);
}

.consensus-track {
  position: absolute;
  inset-block-start: 12px;
  inset-inline: 0;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--n-100);
}

.consensus-mid,
.consensus-you {
  position: absolute;
  inset-block-start: 6px;
  width: 2px;
  height: 16px;
  transform: translateX(-1px);
}

.consensus-mid { background: var(--n-400); }
.consensus-you { background: var(--c-1); height: 22px; inset-block-start: 3px; width: 3px; }

.consensus-scale {
  display: flex;
  justify-content: space-between;
  color: var(--n-400);
}

/* -- Export: sheet preview (§8.9) ---------------------------------------- */
.sheet-tabs {
  margin: 0 var(--sp-4) var(--sp-2);
  width: fit-content;
}

.sheet-grid-wrap {
  overflow-x: auto;
  max-height: 520px;
}

/* A spreadsheet-like grid: hairlines on both axes, first column pinned so
   a wide model scrolls without losing the row labels (§9.6). */
.sheet-grid td,
.sheet-grid th {
  border-inline-end: var(--border-hairline);
  white-space: nowrap;
}

.sheet-grid td.row-label,
.sheet-grid th:first-child {
  position: sticky;
  inset-inline-start: 0;
  background: var(--n-0);
  z-index: 1;
}

.sheet-grid tbody tr:nth-child(even) td.row-label { background: var(--n-50); }

/* -- Export: format picker ------------------------------------------------ */
.format-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.format-option {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: var(--border-hairline);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-in-out);
}

.format-option:hover { border-color: var(--n-200); }
.format-option:has(input:checked) { border-color: var(--n-900); }

.format-option.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.format-option-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.format-option-name { font-weight: 500; color: var(--n-900); font-size: 0.875rem; }
.format-option-note { color: var(--n-600); }

.export-options legend {
  color: var(--n-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  float: none;
  width: auto;
}

/* The adjacent product with the highest retention impact, put in front of
   a reviewer at the moment it makes sense — and disabled (§8.9). */
.addin-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px dashed var(--n-200);
  border-radius: var(--radius-control);
  color: var(--n-400);
  font-size: 0.8125rem;
  cursor: not-allowed;
}

.addin-icon { font-size: 1rem; }

@media (max-width: 767.98px) {
  .assumption-row { grid-template-columns: 14px 1fr 108px; }
  .assumption-input { width: 64px; }
  .tool-row-label { flex-basis: 100%; }
}

/* ======================================================================
   13. Supporting pages + the §9 polish pass (§8.10, §8.11, §9.5, §9.6)
   ====================================================================== */

.coverage-section,
.watchlist-section,
.search-section {
  padding-block: var(--sp-8) var(--sp-16);
}

/* -- Coverage funnel (§8.10) — a stepped bar, 270 → 251 → 63 → 13 -------- */
.funnel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.funnel-step-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
}

.funnel-step-label { font-size: 0.875rem; color: var(--n-800); }
.funnel-step-count { font-size: 1.25rem; font-weight: 600; color: var(--n-900); }

.funnel-bar {
  height: 12px;
  background: var(--n-50);
  border-radius: 2px;
  overflow: hidden;
  margin-block: var(--sp-1);
}

.funnel-bar-fill {
  height: 100%;
  background: var(--c-1);
  border-radius: 2px;
  transition: width var(--dur-slow) var(--ease-out);
}

.funnel-step-drop { color: var(--n-600); }

/* -- Watchlist rows (§8.11) ------------------------------------------------ */
.watch-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.watch-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 150px 104px 84px 96px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-block-end: var(--border-hairline);
  background: var(--n-0);
}

.watch-row:last-child { border-block-end: none; }
.watch-row.is-dragging { opacity: 0.4; }
.watch-row.is-drop-target { box-shadow: inset 0 2px 0 0 var(--n-900); }

.watch-handle { color: var(--n-200); cursor: grab; }
.watch-row:active .watch-handle { cursor: grabbing; }

.watch-main {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  grid-template-areas: "symbol name" "symbol sector";
  gap: 0 var(--sp-3);
  text-decoration: none;
  min-width: 0;
}

.watch-symbol { grid-area: symbol; align-self: center; font-weight: 600; color: var(--n-900); }
.watch-name { grid-area: name; color: var(--n-800); font-size: 0.875rem; }
.watch-sector { grid-area: sector; color: var(--n-600); }
.watch-figure { color: var(--n-800); font-size: 0.875rem; text-align: end; }
.watch-spark { display: flex; justify-content: center; }
.watch-move { text-align: end; }

.watch-actions {
  display: flex;
  gap: var(--sp-1);
  justify-content: flex-end;
}

.watch-move-btn,
.watch-remove {
  border: var(--border-hairline);
  background: var(--n-0);
  color: var(--n-600);
  border-radius: var(--radius-control);
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-in-out), color var(--dur-fast) var(--ease-in-out);
}

.watch-move-btn:hover { background: var(--n-50); color: var(--n-900); }
.watch-remove:hover { background: var(--neg); border-color: var(--neg); color: #fff; }

.saved-set { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); align-items: flex-start; }

.saved-set-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.saved-set-name { font-weight: 600; color: var(--n-900); }

@media (max-width: 991.98px) {
  /* Tables never reflow into cards (§9.6) — but the watchlist is a list of
     rows, not a financial table, so it may stack. */
  .watch-row { grid-template-columns: 20px minmax(0, 1fr) 96px; }
  .watch-figure,
  .watch-spark { display: none; }
}

/* -- Search (§8.11) --------------------------------------------------------- */
.search-box {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border: var(--border-strong);
  border-radius: var(--radius-container);
  padding-inline: var(--sp-4);
  background: var(--n-0);
  color: var(--n-400);
}

.search-box:focus-within { border-color: var(--n-900); }

.search-box .form-control {
  border: none;
  padding-inline: 0;
  font-size: 1rem;
  background: transparent;
}

.search-box .form-control:focus { box-shadow: none; }

.search-group { margin-block-end: var(--sp-6); }

.search-group-title {
  color: var(--n-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-block-end: var(--sp-2);
}

.search-result {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: baseline;
  padding: var(--sp-3) var(--sp-3);
  border-block-end: var(--border-hairline);
  text-decoration: none;
  border-inline-start: 2px solid transparent;
}

.search-result.is-active,
.search-result:hover {
  background: var(--n-50);
  border-inline-start-color: var(--n-900);
}

.search-result-group { color: var(--n-400); text-transform: uppercase; letter-spacing: 0.04em; }

.search-result-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.search-result-title {
  color: var(--n-900);
  font-size: 0.9375rem;
  unicode-bidi: isolate;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-subtitle,
.search-result-meta { color: var(--n-600); }

@media (max-width: 575.98px) {
  .search-result { grid-template-columns: minmax(0, 1fr); }
}

/* -- Command palette results (§9.5) ---------------------------------------- */
.command-palette #command-palette-results { max-height: 60vh; overflow-y: auto; }

.command-palette .command-result {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: baseline;
}

.command-result-group { color: var(--n-400); text-transform: uppercase; letter-spacing: 0.04em; }

.command-result-title {
  color: var(--n-900);
  unicode-bidi: isolate;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-result-sub { color: var(--n-600); grid-column: 2; }

.command-palette-footer {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  border-block-start: var(--border-hairline);
  color: var(--n-600);
}

/* Keycaps read left-to-right in both languages — they are literal keys,
   not prose (rtl.css isolates them; this is the visual treatment). */
.kbd-hint {
  border: var(--border-hairline);
  border-block-end-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.6875rem;
  color: var(--n-600);
  background: var(--n-25);
}

/* -- Shortcut overlay (§9.5) ------------------------------------------------ */
.shortcut-list { margin: 0; }

.shortcut-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: var(--sp-3);
  padding-block: var(--sp-2);
  border-block-end: var(--border-hairline);
}

.shortcut-row:last-child { border-block-end: none; }
.shortcut-row dt { display: flex; gap: var(--sp-1); }
.shortcut-row dd { margin: 0; color: var(--n-600); font-size: 0.875rem; }

/* -- Sign-in split screen (§8.11) ------------------------------------------ */
.signin-body { background: var(--n-0); }

.signin-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
}

.signin-brand {
  position: relative;
  overflow: hidden;
  background: var(--n-900);
}

.signin-brand img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.signin-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(10 10 12 / 0.88), rgb(10 10 12 / 0.42));
}

.signin-brand-body {
  position: absolute;
  inset-block-end: var(--sp-12);
  inset-inline: var(--sp-12);
  z-index: 1;
}

.signin-wordmark {
  color: #fff;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  display: block;
  margin-block-end: var(--sp-3);
}

.signin-positioning {
  color: rgb(255 255 255 / 0.82);
  font-size: 1.0625rem;
  max-width: 34ch;
}

.signin-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--sp-6);
}

.signin-form-inner { width: 100%; max-width: 380px; }

.persona-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.persona-chip {
  border: var(--border-strong);
  background: var(--n-0);
  color: var(--n-800);
  border-radius: var(--radius-pill);
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-in-out), color var(--dur-fast) var(--ease-in-out), border-color var(--dur-fast) var(--ease-in-out);
}

.persona-chip:hover { border-color: var(--n-900); }

.persona-chip.is-active {
  background: var(--n-900);
  border-color: var(--n-900);
  color: var(--n-0);
}

.persona-chip.is-bouncing { animation: company-star-bounce var(--dur-slow) var(--ease-out); }

.signin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-start: var(--sp-8);
  padding-block-start: var(--sp-4);
  border-block-start: var(--border-hairline);
}

@media (max-width: 767.98px) {
  .signin-split { grid-template-columns: minmax(0, 1fr); }
  .signin-brand { min-height: 220px; }
  .signin-brand-body { inset-block-end: var(--sp-6); inset-inline: var(--sp-6); }
}

/* -- Header persona chip (§8.11) ------------------------------------------- */
.shell-persona-chip {
  border: var(--border-hairline);
  border-radius: var(--radius-pill);
  padding: 2px var(--sp-3);
  font-size: 0.75rem;
  color: var(--n-800);
  white-space: nowrap;
}

/* -- Mobile bottom bar (§9.6) ---------------------------------------------- */
.shell-bottom-bar { display: none; }

@media (max-width: 767.98px) {
  .shell-bottom-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 1030;
    background: var(--n-0);
    border-block-start: var(--border-hairline);
    padding-block: var(--sp-1);
  }

  .shell-bottom-link {
    border: none;
    background: none;
    color: var(--n-600);
    font-size: 0.6875rem;
    text-align: center;
    text-decoration: none;
    padding: var(--sp-2) 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .shell-bottom-link.is-active { color: var(--n-900); font-weight: 600; }

  /* Clear the bar so the last row of any page is reachable. */
  body { padding-block-end: 56px; }
}

.shell-more-link {
  display: block;
  padding: var(--sp-3) 0;
  border-block-end: var(--border-hairline);
  color: var(--n-800);
  text-decoration: none;
}

.shell-more-link.is-active { color: var(--n-900); font-weight: 600; }

/* -- Responsive: filter bars become an offcanvas, charts scroll (§9.6) ----- */
@media (max-width: 767.98px) {
  .story-grid { grid-template-columns: minmax(0, 1fr); }
  .market-strip { padding-inline: var(--sp-4); }
  .market-strip.is-docked { inset-block-start: 52px; }
  .page-hero { height: 180px; }
  .page-hero-title { font-size: 1.5rem; }

  /* A financial table scrolls horizontally inside its own container with
     the first column pinned — it never becomes a stack of label/value
     pairs, which is unreadable (§9.6). */
  .chart-table-wrap { overflow-x: auto; }
  .table-osool td:first-child,
  .table-osool th:first-child {
    position: sticky;
    inset-inline-start: 0;
    background: var(--n-0);
    z-index: 1;
  }
}

@media (max-width: 1199.98px) {
  .tech-toolbar { gap: var(--sp-2); }
}

/* ≥1400px: content caps at 1360px (already set on `main`); nothing further
   to do here beyond letting the grid breathe. */

/* ======================================================================
   14. Overflow containment (§9.6 — "the page body must never scroll
       horizontally"). Flex and grid children default to `min-width: auto`,
       which makes a nowrap strip or a wide table push the whole document
       instead of scrolling inside its own container. These are the places
       that showed up at 375px.
   ====================================================================== */

.market-strip-inner,
.panel,
.panel-body,
.chart-table-wrap,
.company-subnav,
.sheet-grid-wrap,
.row > [class*="col-"] {
  min-width: 0;
}

/* A panel header carries a title, a provenance chip and up to two controls;
   below the widest breakpoints those have to wrap rather than extend. */
.panel > .panel-header,
.chart-panel-actions {
  flex-wrap: wrap;
}

/* A segmented control with five or more options is wider than a phone. It
   scrolls inside itself; the rounded ends stay because the border is on
   the container. */
.segmented {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: 0 0 auto; white-space: nowrap; }

/* Financial tables scroll inside their own container at every width, not
   only below 768px — a nine-column statement is wider than a laptop column
   too (§9.6: tables never reflow into cards). */
.panel-body.is-flush > table,
.panel-body.is-flush > .table-osool {
  display: block;
  overflow-x: auto;
}

.market-strip { max-width: min(1360px, 100%); }

/* A scroll container only contains what it is allowed to be narrower than.
   `min-width: 0` handles the flex case; a block-level wrapper also needs an
   explicit max so a 970px-wide model grid scrolls inside it. */
.chart-table-wrap,
.sheet-grid-wrap {
  max-width: 100%;
}

/* The macro event panel's actions are a label, a select and a toggle —
   more than a 375px header row carries, so the select gives way first. */
.chart-panel-actions {
  max-width: 100%;
  gap: var(--sp-2);
}

.chart-panel-actions .form-select {
  min-width: 0;
  max-width: 100%;
}

/* `width: fit-content` beats the segmented scroller's own max-width, so the
   export sheet tabs need their inline margins accounted for explicitly. */
.sheet-tabs {
  max-width: calc(100% - 2 * var(--sp-4));
}
