/* Document reset and rendering baseline */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-block-size: 100%;
  color-scheme: var(--native-control-color-scheme);
  background-color: var(--color-bg);
  font-family: var(--font-sans);
  font-synthesis: none;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-block-size: 100%;
  margin: var(--space-0);
  background-color: #08090d;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(0, 242, 254, 0.06), transparent 75%);
  background-size: 36px 36px, 36px 36px, 100% 100%;
  background-attachment: fixed;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  overflow-wrap: break-word;
}

#app {
  min-block-size: 100svh;
  isolation: isolate;
}

:where(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd) {
  margin: var(--space-0);
}

:where(ul, ol, menu) {
  margin: var(--space-0);
  padding-inline-start: var(--space-6);
}

:where(ul, ol, menu)[role="list"] {
  padding: var(--space-0);
  list-style: none;
}

:where(img, picture, video, canvas, svg) {
  display: block;
  max-inline-size: 100%;
}

:where(img, video) {
  block-size: auto;
}

:where(button, input, optgroup, select, textarea) {
  margin: var(--space-0);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
}

:where(button, select) {
  text-transform: none;
}

iframe {
  border: var(--space-0);
}

[hidden] {
  display: none !important;
}

/* Type hierarchy */
:where(h1, h2, h3, h4, h5, h6) {
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-4xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

h3 {
  font-size: var(--text-2xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
}

h4 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
}

h5 {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

h6 {
  font-size: var(--text-md);
  line-height: var(--leading-snug);
}

p {
  line-height: var(--leading-relaxed);
  text-wrap: pretty;
}

small {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

:where(strong, b) {
  font-weight: var(--weight-semibold);
}

:where(code, kbd, samp, pre) {
  font-family: var(--font-mono);
  font-feature-settings: var(--font-feature-numeric);
}

:not(pre) > code,
kbd {
  border: var(--border-subtle);
  border-radius: var(--radius-xs);
  background-color: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

:not(pre) > code {
  padding: var(--space-1) var(--space-2);
}

kbd {
  padding: var(--space-1) var(--space-2);
  box-shadow: var(--shadow-xs);
}

pre {
  max-inline-size: 100%;
  margin: var(--space-0);
  overflow: auto;
  border: var(--border-default);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  padding: var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  tab-size: 2;
}

pre code {
  border: var(--space-0);
  background: transparent;
  padding: var(--space-0);
  color: inherit;
  font-size: inherit;
}

blockquote {
  border-inline-start: var(--border-accent);
  padding-inline-start: var(--space-5);
  color: var(--color-text-secondary);
}

hr {
  block-size: var(--border-width);
  margin: var(--space-6) var(--space-0);
  border: var(--space-0);
  background-color: var(--color-divider);
}

abbr[title] {
  text-decoration-color: var(--color-border-accent);
  text-underline-offset: var(--space-1);
  cursor: help;
}

mark {
  border-radius: var(--radius-xs);
  background-color: var(--color-warning-soft);
  padding-inline: var(--space-1);
  color: var(--color-text);
}

::selection {
  background-color: var(--color-selection-bg);
  color: var(--color-selection-text);
  text-shadow: none;
}

/* Links and native buttons */
a {
  color: var(--color-text);
  text-decoration-color: var(--color-border-accent);
  text-decoration-thickness: var(--border-width);
  text-underline-offset: var(--space-1);
  transition: var(--transition-colors);
}

a:not([href]) {
  color: inherit;
  text-decoration: none;
}

a[aria-current="page"] {
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

:where(button, input[type="button"], input[type="submit"], input[type="reset"]) {
  display: inline-flex;
  min-block-size: var(--size-touch-min);
  min-inline-size: var(--size-touch-min);
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: var(--border-default);
  border-radius: var(--radius-control);
  appearance: none;
  background-color: var(--color-surface-elevated);
  padding: var(--space-2) var(--space-4);
  color: var(--color-text);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-none);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-xs);
  transition: var(--transition-colors);
  -webkit-tap-highlight-color: transparent;
}

:where(button, input[type="button"], input[type="submit"], input[type="reset"]):active:not(:disabled):not([aria-disabled="true"]) {
  border-color: var(--color-border-strong);
  background-color: var(--color-surface-active);
  box-shadow: var(--shadow-inset);
}

:where(button, [role="button"])[aria-pressed="true"] {
  border-color: var(--color-border-accent);
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
}

button::-moz-focus-inner {
  border: var(--space-0);
  padding: var(--space-0);
}

/* Forms and native controls */
label,
legend {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
}

fieldset {
  min-inline-size: var(--space-0);
  margin: var(--space-0);
  border: var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

legend {
  padding-inline: var(--space-2);
}

:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  ) {
  inline-size: 100%;
  min-block-size: var(--size-control-md);
  max-inline-size: 100%;
  border: var(--border-width) solid var(--color-control-border);
  border-radius: var(--radius-control);
  appearance: none;
  background-color: var(--color-control-bg);
  padding: var(--space-3) var(--space-4);
  color: var(--color-control-text);
  caret-color: var(--color-control-caret);
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  line-height: var(--leading-normal);
  box-shadow: var(--shadow-inset);
  transition: var(--transition-colors);
}

:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  )::placeholder {
  color: var(--color-control-placeholder);
  opacity: 1;
}

textarea {
  min-block-size: calc(var(--size-control-lg) + var(--size-control-lg));
  resize: vertical;
}

select {
  appearance: auto;
  cursor: pointer;
}

select[multiple] {
  min-block-size: calc(var(--size-control-lg) + var(--size-control-lg));
  padding-block: var(--space-3);
}

:where(option, optgroup) {
  background-color: var(--color-surface);
  color: var(--color-text);
}

optgroup {
  font-weight: var(--weight-semibold);
}

:where(input[type="checkbox"], input[type="radio"]) {
  inline-size: var(--space-5);
  block-size: var(--space-5);
  flex: none;
  accent-color: var(--native-control-accent-color);
  cursor: pointer;
}

:where(input[type="range"], progress) {
  accent-color: var(--native-control-accent-color);
}

input[type="range"] {
  cursor: pointer;
}

input[type="color"] {
  inline-size: var(--size-control-md);
  block-size: var(--size-control-md);
  border: var(--border-default);
  border-radius: var(--radius-control);
  background-color: var(--color-control-bg);
  padding: var(--space-1);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  min-block-size: var(--size-control-sm);
  margin-inline-end: var(--space-3);
  border: var(--border-default);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-elevated);
  padding-inline: var(--space-3);
  color: var(--color-text);
  font: inherit;
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition-colors);
}

:where(input[type="number"], output) {
  font-family: var(--font-mono);
  font-feature-settings: var(--font-feature-numeric);
}

:where(input, textarea):-webkit-autofill,
:where(input, textarea):-webkit-autofill:hover,
:where(input, textarea):-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-control-autofill-text);
  caret-color: var(--color-control-caret);
  box-shadow: var(--space-0) var(--space-0) var(--space-0) var(--space-16) var(--color-control-autofill-bg) inset;
}

:where(input[readonly], textarea[readonly]) {
  background-color: var(--color-control-bg-disabled);
  color: var(--color-text-secondary);
}

:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  ):disabled {
  border-color: var(--color-border-subtle);
  background-color: var(--color-control-bg-disabled);
}

:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  )[aria-invalid="true"],
:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  ):user-invalid {
  border-color: var(--color-error-border);
}

/* Data tables */
table {
  inline-size: 100%;
  border-collapse: collapse;
  border-spacing: var(--space-0);
  color: var(--color-text-secondary);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

caption {
  padding-block-end: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: start;
}

:where(th, td) {
  border-block-end: var(--border-subtle);
  padding: var(--space-3) var(--space-4);
  text-align: start;
  vertical-align: middle;
}

th {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

tbody tr {
  transition: background-color var(--duration-fast) var(--ease-out);
}

tbody tr:last-child > :where(th, td) {
  border-block-end: var(--space-0);
}

:where(th, td)[data-numeric],
.numeric {
  font-family: var(--font-mono);
  font-feature-settings: var(--font-feature-numeric);
  text-align: end;
}

/* Scrollbars */
* {
  scrollbar-color: var(--color-border-strong) var(--color-bg);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  inline-size: var(--space-2);
  block-size: var(--space-2);
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background-color: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  border-radius: var(--radius-pill);
  background-color: var(--color-border-strong);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-border-accent);
}

/* Keyboard focus and accessible states */
:focus-visible {
  outline: var(--border-width-strong) solid var(--color-focus-ring);
  outline-offset: var(--space-1);
  box-shadow: var(--shadow-focus);
}

:focus:not(:focus-visible) {
  outline: none;
}

#stockyield-page-content h1[tabindex="-1"]:focus {
  outline: none;
  box-shadow: none;
}

:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  ):focus-visible {
  border-color: var(--color-control-border-focus);
  outline: none;
  box-shadow: var(--shadow-focus);
}

:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  )[aria-invalid="true"]:focus-visible,
:where(
    input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea
  ):user-invalid:focus-visible {
  border-color: var(--color-error);
  box-shadow: var(--shadow-focus-error);
}

:where(button, input, select, textarea, a, [role="button"], [role="link"]):disabled,
:where(button, input, select, textarea, a, [role="button"], [role="link"])[aria-disabled="true"] {
  color: var(--color-text-disabled);
  cursor: not-allowed;
  opacity: var(--opacity-disabled);
  box-shadow: none;
}

[aria-busy="true"] {
  cursor: progress;
}

:target {
  scroll-margin-block-start: calc(var(--layout-header-height) + var(--space-4));
}

summary {
  cursor: pointer;
}

summary::marker {
  color: var(--color-accent-muted);
}

noscript {
  display: block;
  border-block-end: var(--border-warning);
  background-color: var(--color-warning-soft);
  padding: var(--space-3) var(--layout-page-gutter);
  color: var(--color-warning);
  text-align: center;
}

.visually-hidden,
.sr-only {
  position: absolute !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  padding: 0 !important;
  white-space: nowrap !important;
}

.skip-link {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: var(--z-toast);
  min-block-size: var(--size-touch-min);
  transform: translateY(calc(-100% - var(--space-4)));
  border: var(--border-accent);
  border-radius: var(--radius-control);
  background-color: var(--color-surface-inverse);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-inverse);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: var(--transition-transform);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* Generic layout utilities */
.container {
  inline-size: 100%;
  max-inline-size: var(--layout-content-max);
  margin-inline: auto;
  padding-inline: var(--layout-page-gutter);
}

.measure {
  max-inline-size: var(--layout-readable-max);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-4));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-3));
}

.split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--split-gap, var(--space-4));
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, var(--layout-sidebar-width))), 1fr));
  gap: var(--grid-gap, var(--layout-card-gap));
}

.flow > * + * {
  margin-block-start: var(--flow-gap, var(--space-4));
}

.scroll-x,
.table-scroll {
  max-inline-size: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.table-scroll {
  border: var(--border-subtle);
  border-radius: var(--radius-md);
}

/* Shared loading primitive */
.skeleton {
  position: relative;
  overflow: hidden;
  background-color: var(--color-surface-elevated);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.skeleton::after {
  position: absolute;
  inset: var(--space-0);
  content: "";
  background-image: linear-gradient(to right, transparent, var(--color-highlight), transparent);
  transform: translateX(-100%);
  animation: skeleton-sweep calc(var(--duration-slower) + var(--duration-slower)) var(--ease-in-out) infinite;
}

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

@media (hover: hover) and (pointer: fine) {
  :where(a[href]):hover {
    color: var(--color-accent-hover);
    text-decoration-color: currentColor;
  }

  :where(button, input[type="button"], input[type="submit"], input[type="reset"]):where(:not(:disabled):not([aria-disabled="true"])):hover,
  input[type="file"]::file-selector-button:hover {
    border-color: var(--color-border-strong);
    background-color: var(--color-surface-hover);
  }

  :where(
      input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="image"]):not([type="hidden"]),
      select,
      textarea
    ):hover:not(:disabled) {
    border-color: var(--color-control-border-hover);
    background-color: var(--color-control-bg-hover);
  }

  tbody tr:hover {
    background-color: var(--color-surface-hover);
  }
}

@media (prefers-contrast: more) {
  :focus-visible {
    outline-width: var(--border-width-strong);
  }

  :where(input, select, textarea) {
    border-color: var(--color-border-strong);
  }
}

@media (forced-colors: active) {
  :focus-visible {
    outline-color: Highlight;
    box-shadow: none;
  }

  :where(button, input, select, textarea, a, [role="button"], [role="link"]):disabled,
  :where(button, input, select, textarea, a, [role="button"], [role="link"])[aria-disabled="true"] {
    color: GrayText;
    opacity: 1;
  }

  .skeleton {
    background-color: CanvasText;
    opacity: var(--opacity-disabled);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0s !important;
    transition-duration: 0s !important;
  }

  .skeleton::after {
    display: none;
    animation: none !important;
  }
}
