/*
 * Terminal's design tokens and the base styles the app shell paints with.
 *
 * The colours are one source for both themes. `light-dark()` holds the light value first
 * and the dark value second, and `color-scheme` decides which one applies: the page follows
 * the operating system through `prefers-color-scheme` until a person picks a theme, and
 * `theme.ts` then sets `data-theme` on the root element, which pins `color-scheme`.
 *
 * The tokens are not decorative: `test/contrast.test.ts` reads this file and holds the
 * declared text and interface pairs to WCAG AA in both themes, so a new colour fails CI
 * when it is unreadable.
 */
:root {
  color-scheme: light dark;

  /* Surfaces, borders and text. */
  --bg-app: light-dark(#f4f6fa, #080c14);
  --bg-panel: light-dark(#ffffff, #101726);
  --bg-raised: light-dark(#eef2f7, #162033);
  --border: light-dark(#d5dce6, #23314b);
  --text-primary: light-dark(#0f172a, #e6edf7);
  --text-secondary: light-dark(#475569, #94a3b8);
  --text-muted: light-dark(#5b6678, #7c8aa3);
  --accent: light-dark(#1d4ed8, #3b82f6);
  --danger: light-dark(#be123c, #f43f5e);

  /* Chart series colours. Each is readable on the chart surface in both themes (WCAG
   * non-text contrast), and the marker glyph swaps between white and near-black so the
   * little E/D/S labels stay legible in both. The contrast test holds these pairs to AA. */
  --chart-1: light-dark(#2563eb, #6fa8ff);
  --chart-2: light-dark(#ea580c, #ffa94d);
  --chart-3: light-dark(#16a34a, #51cf66);
  --chart-4: light-dark(#7c3aed, #c084fc);
  --chart-5: light-dark(#dc2626, #ff6b6b);
  --chart-6: light-dark(#0d9488, #2dd4bf);
  --chart-7: light-dark(#a16207, #facc15);
  --chart-8: light-dark(#92400e, #c08457);
  --chart-benchmark: light-dark(#6b7280, #9ca3af);
  --chart-tooltip-bg: light-dark(#ffffff, #101726);
  --chart-marker-label: light-dark(#ffffff, #0b1220);
  --chart-earnings: light-dark(#b45309, #f59e0b);
  --chart-dividend: light-dark(#1d4ed8, #60a5fa);
  --chart-split: light-dark(#7c3aed, #c084fc);
  --chart-beat: light-dark(#047857, #10b981);
  --chart-miss: light-dark(#be123c, #f43f5e);
  --positive: light-dark(#15803d, #4ade80);

  /* Type, spacing and shape. */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --radius-sm: 6px;
}

/* A chosen theme wins over the operating system's preference. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-block-size: 100dvh;
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-block-end: 1px solid var(--border);
  background: var(--bg-panel);
}

.app-name {
  font-weight: 650;
  letter-spacing: 0.01em;
}

.app-nav {
  display: flex;
  gap: var(--space-1);
}

.app-nav-link {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
}

.app-nav-link:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.app-nav-link[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

/* The organization switcher: one select naming the firm the page is acting in. */
.org-switcher-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
}

.org-switcher {
  min-block-size: 2.25rem;
  max-inline-size: 14rem;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  font: inherit;
}

.org-switcher-error {
  color: var(--danger);
  font-size: 0.875rem;
}

.theme-toggle {
  margin-inline-start: auto;
}

/* The sign-out control ends the header, with its failure message beside the button. */
.sign-out-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-inline-size: 0;
}

/* The wrapper's own display rule would otherwise beat the UA rule that hides `hidden`. */
.sign-out-wrap[hidden] {
  display: none;
}

.sign-out-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* The app frame fills the page so the footer sits at the bottom on a short route. */
#app {
  display: flex;
  flex: 1;
  flex-direction: column;
}

main {
  flex: 1;
  padding: var(--space-5);
}

.page-title {
  margin: 0 0 var(--space-4);
  font-size: 1.5rem;
  line-height: 1.2;
}

/* One-form pages: an invite names the firm and role, and the sign-in and password reset
 * pages ask for credentials. All use the same narrow column and field styling. */
.sign-in,
.invite,
.password-reset {
  max-inline-size: 32rem;
}

.sign-in p,
.invite p,
.password-reset p {
  margin: 0 0 var(--space-3);
}

.sign-in-form,
.invite-form,
.password-reset-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-inline-size: 24rem;
  margin-block-start: var(--space-4);
}

.sign-in-form label,
.invite-form label,
.password-reset-form label {
  font-weight: 600;
}

.sign-in-form input,
.invite-form input,
.password-reset-form input {
  min-block-size: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  font: inherit;
}

.sign-in-hint,
.invite-hint,
.password-reset-hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.sign-in-error,
.invite-error,
.password-reset-error {
  color: var(--danger);
}

/* The way out under the form for a person who cannot remember the password. */
.sign-in .sign-in-forgot {
  margin-block-start: var(--space-4);
}

/* The no-organization message: two plain sentences, the only thing the account sees. */
.no-organization {
  max-inline-size: 32rem;
  color: var(--text-secondary);
}

.no-organization p {
  margin: 0 0 var(--space-3);
}

/* Admin: the people screen's organization, platform-admin, member and invite sections. */
.admin {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-inline-size: 40rem;
}

.admin-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.admin-section h2 {
  margin: 0;
  font-size: 1.125rem;
}

.admin-section h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-form,
.admin-promote-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-inline-size: 24rem;
}

.admin-form label,
.admin-promote-form label {
  font-weight: 600;
}

.admin input,
.admin select {
  min-block-size: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  font: inherit;
}

.admin-hint,
.admin-copy-status,
.admin-promote-status {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.admin-error {
  margin: 0;
  color: var(--danger);
}

.admin-organizations,
.admin-platform-admins {
  margin: 0;
  padding-inline-start: var(--space-5);
}

/* The member list and the pending invites beside it, one row per mailbox. */
.admin-member-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.admin-members,
.admin-pending-invites {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-member,
.admin-pending-invite {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.admin-member-email {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.admin-member-roles {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* The role editor stays a closed row until an admin chooses a person. */
.admin-member-editor {
  inline-size: 100%;
}

.admin-member-editor summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.admin-role-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-block-start: var(--space-2);
}

.admin-role-form fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}

.admin-role-form legend {
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.admin-role-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.875rem;
}

/* The form controls' shared size rule does not fit a checkbox. */
.admin-role-check input {
  appearance: auto;
  inline-size: 1rem;
  block-size: 1rem;
  min-block-size: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.admin-role-form button {
  align-self: flex-start;
}

/* The removal confirmation stays closed until an admin chooses a person. */
.admin-member-removal {
  inline-size: 100%;
}

.admin-member-removal summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.admin-remove-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-block-start: var(--space-2);
}

.admin-remove-form p {
  margin: 0;
}

.admin-remove-form button {
  align-self: flex-start;
}

/* The revocation confirmation stays closed until an admin chooses an invite. */
.admin-pending-invite-revocation {
  inline-size: 100%;
}

.admin-pending-invite-revocation summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.admin-revoke-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-block-start: var(--space-2);
}

.admin-revoke-form p {
  margin: 0;
}

.admin-revoke-form button {
  align-self: flex-start;
}

.admin-member-status {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.admin-pending {
  margin-inline-start: auto;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.admin-invite-result {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-inline-size: 34rem;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

/* The panel's own display rule would otherwise beat the UA rule that hides `hidden`. */
.admin-invite-result[hidden] {
  display: none;
}

.admin-invite-result p {
  margin: 0;
}

.admin-link-row {
  display: flex;
  gap: var(--space-2);
}

.admin-link-row input {
  flex: 1;
  min-inline-size: 0;
}

/* Admin data: the platform admin's sync, activity, storage and health screens. These are
 * wider than the people screen because a stored-file table needs the row. */
.admin-data {
  max-inline-size: none;
  gap: var(--space-4);
}

.admin-data-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding-block-end: var(--space-1);
  border-block-end: 1px solid var(--border);
}

.admin-tab {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-secondary);
  text-decoration: none;
}

.admin-tab:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.admin-tab[aria-current="page"] {
  color: var(--text-primary);
  box-shadow: inset 0 -2px 0 var(--accent);
  font-weight: 600;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.admin-field-label {
  font-weight: 600;
}

.admin-data button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* The one admin form rule sizes every control; a radio and a checkbox keep their own. */
.admin input[type="checkbox"],
.admin input[type="radio"] {
  appearance: auto;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  min-block-size: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.admin .ds-form {
  max-inline-size: 46rem;
}

.ds-fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.ds-fieldset legend {
  padding-inline: var(--space-1);
  font-weight: 600;
}

.ds-choice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-weight: 400;
}

.ds-choice--disabled {
  color: var(--text-muted);
}

.ds-symbols-row[hidden] {
  display: none;
}

.ds-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.ds-preview {
  margin: 0;
  max-inline-size: 46rem;
  color: var(--text-secondary);
}

.ds-preview[data-preview="ready"] {
  color: var(--text-primary);
}

/* The section's own display rule would otherwise beat the UA rule that hides `hidden`. */
.ds-progress[hidden] {
  display: none;
}

.ds-progress-status {
  margin: 0;
  font-weight: 600;
}

.ds-progress-line {
  margin: 0;
  color: var(--text-secondary);
}

/* Tables of stored data and recent runs: one row per file or run, scrolling sideways when
 * the window is narrower than the smallest readable table. */
.data-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.data-section-head h2,
.data-storage-section h2 {
  margin: 0;
  font-size: 1.125rem;
}

.data-storage-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table.data-table {
  inline-size: 100%;
  min-inline-size: 44rem;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table caption {
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  text-align: start;
}

table.data-table th,
table.data-table td {
  padding: var(--space-2) var(--space-3);
  border-block-end: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

table.data-table thead th {
  background: var(--bg-raised);
  font-weight: 600;
}

table.data-table tbody tr:last-child th,
table.data-table tbody tr:last-child td {
  border-block-end: 0;
}

.data-table code,
.activity-table code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.data-hash code {
  white-space: nowrap;
}

.data-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-3);
}

.data-card {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.data-card-label {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.data-card-value {
  margin-block: var(--space-1);
  font-size: 1.5rem;
  font-weight: 650;
}

.data-card-detail {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.data-transforms summary {
  color: var(--accent);
  cursor: pointer;
}

.data-transforms ol {
  margin: var(--space-2) 0 0;
  padding-inline-start: var(--space-4);
  max-inline-size: 34rem;
}

.data-transforms li p {
  margin: var(--space-1) 0 0;
}

.activity-failure {
  max-inline-size: 24rem;
}

.activity-failure--none {
  color: var(--text-muted);
}

.activity-retry {
  display: block;
}

.activity-state[data-state="failed"] {
  color: var(--danger);
}

.health-thresholds {
  margin: 0;
  padding-inline-start: var(--space-4);
}

.health-thresholds li {
  margin-block-end: var(--space-1);
}

.state {
  color: var(--text-secondary);
}

.state p {
  margin: 0 0 var(--space-3);
}

/* A state with more than one next step, such as signing in or requesting a reset link. */
.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.state--loading {
  color: var(--text-muted);
}

.state--error {
  color: var(--danger);
}

footer {
  padding: var(--space-3) var(--space-5);
  border-block-start: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
}

footer code {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  /* The build SHA is one long word; let it wrap instead of widening the page. */
  overflow-wrap: anywhere;
}

/*
 * The phone layout (ACC-7). Below 640px the primary navigation leaves the header and
 * becomes a fixed bar at the bottom of the screen, where a thumb reaches it. Its links are
 * at least 44 by 44 pixels, the header keeps only the product name and the theme switch, and
 * the page reserves room for the bar so the footer is never hidden behind it. Nothing may
 * scroll sideways at 360, 390 or 430 pixels, so long text wraps and the bar spans the
 * viewport.
 */
@media (max-width: 640px) {
  /* The reservation applies only when the viewer has navigation; a signed-out page has none. */
  body:has(.app-nav) {
    padding-block-end: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  }

  .app-header {
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }

  .app-nav {
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 10;
    display: flex;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
    /* A shadow draws the separator without adding to the bar's height. */
    box-shadow: 0 -1px 0 var(--border);
    background: var(--bg-panel);
  }

  .app-nav-link {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-inline-size: 0;
    min-block-size: 44px;
    padding: var(--space-2);
    text-align: center;
  }

  button {
    min-inline-size: 44px;
    min-block-size: 44px;
  }

  /* The switcher is a thumb target too, and it must never widen the header. */
  .org-switcher {
    min-block-size: 44px;
    max-inline-size: min(14rem, 60vw);
  }

  .org-switcher-wrap {
    flex-wrap: wrap;
  }

  main {
    padding: var(--space-4);
  }

  /* A state's action is a standalone control, not a link inside a sentence. */
  .state a {
    display: inline-flex;
    align-items: center;
    min-block-size: 44px;
  }

  footer {
    padding: var(--space-3) var(--space-4);
  }
}

/*
 * The one chart component. Every chart in the app is this frame: a small action row (CSV,
 * PNG, SVG, Table), a series toggle row, the canvas and the numbers table. The canvas keeps
 * a fixed height so the page does not jump when the engine finishes loading.
 */
.invict-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-inline-size: 0;
  inline-size: 100%;
}

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.invict-chart-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-1);
  min-block-size: 1.75rem;
}

.invict-chart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.invict-chart-action,
.invict-chart-series-toggle {
  min-block-size: 1.75rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  font-size: 0.8125rem;
}

.invict-chart-action:hover,
.invict-chart-series-toggle:hover {
  border-color: var(--accent);
}

.invict-chart-series {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.invict-chart-series-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-primary);
}

.invict-chart-series-toggle[aria-pressed="false"] {
  border-style: dashed;
  color: var(--text-muted);
}

.invict-chart-series-toggle[aria-pressed="false"] .invict-chart-dot {
  opacity: 0.35;
}

.invict-chart-canvas {
  inline-size: 100%;
  block-size: 300px;
  min-block-size: 220px;
}

.invict-chart-empty {
  padding: var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.invict-chart-table-wrap {
  max-block-size: 18rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table.invict-chart-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

table.invict-chart-table th,
table.invict-chart-table td {
  padding: 0.35rem 0.55rem;
  border-block-end: 1px solid var(--border);
  text-align: start;
  white-space: nowrap;
}

table.invict-chart-table thead th {
  position: sticky;
  inset-block-start: 0;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.invict-chart-table tbody th {
  font-weight: 600;
  color: var(--text-primary);
}

.invict-chart-dot {
  display: inline-block;
  inline-size: 8px;
  block-size: 8px;
  margin-inline-end: 6px;
  border-radius: 999px;
  vertical-align: middle;
}

.invict-chart-table .positive {
  color: var(--positive);
}

.invict-chart-table .negative {
  color: var(--danger);
}

/* Tooltip rows: a colour dot per series and the muted calculated note. The dot is a class
 * rather than an inline style so the engine's tooltip markup passes the strict policy. */
.invict-chart-tooltip-marker {
  display: inline-block;
  inline-size: 8px;
  block-size: 8px;
  margin-inline-end: 4px;
  border-radius: 999px;
  background: var(--chart-1);
  vertical-align: middle;
}

.invict-chart-tooltip-marker--chart-1 {
  background: var(--chart-1);
}

.invict-chart-tooltip-marker--chart-2 {
  background: var(--chart-2);
}

.invict-chart-tooltip-marker--chart-3 {
  background: var(--chart-3);
}

.invict-chart-tooltip-marker--chart-4 {
  background: var(--chart-4);
}

.invict-chart-tooltip-marker--chart-5 {
  background: var(--chart-5);
}

.invict-chart-tooltip-marker--chart-6 {
  background: var(--chart-6);
}

.invict-chart-tooltip-marker--chart-7 {
  background: var(--chart-7);
}

.invict-chart-tooltip-marker--chart-8 {
  background: var(--chart-8);
}

.invict-chart-tooltip-marker--chart-benchmark {
  background: var(--chart-benchmark);
}

.invict-chart-tooltip-marker--chart-earnings {
  background: var(--chart-earnings);
}

.invict-chart-tooltip-marker--chart-dividend {
  background: var(--chart-dividend);
}

.invict-chart-tooltip-marker--chart-split {
  background: var(--chart-split);
}

.invict-chart-tooltip-marker--chart-beat {
  background: var(--chart-beat);
}

.invict-chart-tooltip-marker--chart-miss {
  background: var(--chart-miss);
}

.invict-chart-note {
  opacity: 0.72;
}

/* Calculated marker for values derived from other reported values (TTM sums). */
.invict-chart-calculated {
  display: inline-block;
  margin-inline-start: 0.25rem;
  padding: 0.02rem 0.3rem;
  border: 1px solid var(--chart-earnings);
  border-radius: 999px;
  color: var(--chart-earnings);
  font-family: var(--font-sans);
  font-size: 0.5625rem;
  font-weight: 700;
  line-height: 1.3;
  vertical-align: middle;
  white-space: nowrap;
}

/* The stock Chart screen: one row of range, measure and overlay controls over the chart. */
.stock-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-inline-size: 72rem;
}

.stock-chart-meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.stock-chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.stock-chart-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  border: 0;
}

.stock-chart-group legend {
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.stock-chart-control {
  min-block-size: 2rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.stock-chart-control[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

.stock-chart-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.stock-chart-readout {
  margin: 0;
  min-block-size: 1.5em;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* The stock tabs shared by the Overview and Chart screens. Each is a real link, and the
 * one being shown is marked for both styling and assistive technology. */
.stock-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-block-end: var(--space-3);
  border-block-end: 1px solid var(--border);
}

.stock-tab {
  padding: var(--space-2) var(--space-3);
  margin-block-end: -1px;
  border-block-end: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 550;
  text-decoration: none;
}

.stock-tab:hover {
  color: var(--text-primary);
}

.stock-tab[aria-current="page"] {
  border-block-end-color: var(--accent);
  color: var(--accent);
}

/* The stock Overview screen: a price banner, the performance panel and the supporting
 * panels. The two-column layout collapses to one column on a narrow screen. */
.stock-overview {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-inline-size: 72rem;
}

.stock-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.stock-banner-identity {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-inline-size: 0;
}

.stock-banner-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
}

.stock-banner-symbol {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.stock-banner-meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.stock-banner-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.stock-price {
  font-size: 1.75rem;
  font-weight: 650;
}

.stock-day-change {
  font-weight: 600;
}

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

.stock-change--down {
  color: var(--danger);
}

.stock-change--flat {
  color: var(--text-secondary);
}

.stock-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.stock-overview-main,
.stock-overview-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-inline-size: 0;
}

.stock-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-inline-size: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.stock-panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.stock-panel-empty {
  margin: 0;
  color: var(--text-secondary);
}

.stock-overview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.stock-overview-range {
  min-block-size: 2rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.stock-overview-range[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

.stock-metrics {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.stock-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-2);
  border-block-end: 1px solid var(--border);
}

.stock-metric:last-child {
  border-block-end: 0;
}

.stock-metric-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.stock-metric-value {
  margin: 0;
  font-weight: 600;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.stock-dividend-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
}

.stock-dividend-fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

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

.stock-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.stock-table th,
.stock-table td {
  padding: var(--space-2);
  border-block-end: 1px solid var(--border);
  text-align: start;
  white-space: nowrap;
}

.stock-table thead th {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
}

.stock-table tbody th {
  font-weight: 550;
}

.stock-table tbody tr:last-child th,
.stock-table tbody tr:last-child td {
  border-block-end: 0;
}

.stock-positive {
  color: var(--positive);
}

.stock-negative {
  color: var(--danger);
}

/* The stock Earnings screen: three headline tiles above the EPS chart and the full table. The
 * tiles are one column on a narrow screen. */
.stock-earnings {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-inline-size: 72rem;
}

.stock-earnings-meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.stock-earnings-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
}

.stock-earnings-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-inline-size: 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.stock-earnings-tile-label {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
}

.stock-earnings-tile-value {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
}

.stock-earnings-tile-number {
  font-size: 1.5rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.stock-earnings-tile-note {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.stock-earnings-chart {
  min-inline-size: 0;
}

.stock-earnings-link {
  align-self: flex-start;
  font-weight: 550;
}

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

  .stock-earnings-tiles {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .stock-banner {
    padding: var(--space-3);
  }

  .stock-price {
    font-size: 1.5rem;
  }

  .stock-panel {
    padding: var(--space-3);
  }

  .stock-tab {
    display: inline-flex;
    align-items: center;
    min-block-size: 44px;
  }

  /* The control's class rule beats the plain button rule above, so repeat the target here. */
  .stock-overview-range,
  .stock-chart-control {
    min-block-size: 44px;
  }
}

@media (max-width: 640px) {
  .invict-chart-canvas {
    block-size: 260px;
  }

  .stock-chart-panel {
    padding: var(--space-2);
  }
}
