/* Shared palette for public pages, documentation and the integration form. */
:root {
  color-scheme: dark;
  --theme-canvas: #111017;
  --theme-header: #15121c;
  --theme-panel: #1d1727;
  --theme-raised: #291f36;
  --theme-text: #f8f4ff;
  --theme-muted: #c7bbd4;
  --theme-line: #483950;
  --theme-accent: #d7b7fb;
  --theme-hover: #352745;
  --theme-success: #abdfc3;
  --theme-danger: #ffb5c7;
  --theme-warning: #f6cb97;
  --theme-focus: #d1adff;
}

html[data-theme="light"] {
  color-scheme: light;
  --theme-canvas: #f6f5fa;
  --theme-header: #fff;
  --theme-panel: #fff;
  --theme-raised: #f3edf9;
  --theme-text: #272034;
  --theme-muted: #574b65;
  --theme-line: #dcd3e6;
  --theme-accent: #613b8d;
  --theme-hover: #ede3f6;
  --theme-success: #236047;
  --theme-danger: #922d51;
  --theme-warning: #784a1b;
  --theme-focus: #7751ad;
  --background: var(--theme-canvas);
  --surface: var(--theme-panel);
  --surface-high: var(--theme-raised);
  --text: var(--theme-text);
  --muted: var(--theme-muted);
  --accent: var(--theme-accent);
  --line: var(--theme-line);
  --border: var(--theme-line);
}

.site-header { color: var(--theme-text); background: var(--theme-header); border-color: var(--theme-line); }
.site-header .language-switch { color: var(--theme-text); --language-line: var(--theme-line); }
.site-header :focus-visible, html[data-theme="light"] :focus-visible { outline-color: var(--theme-focus); }
.site-menu-group > summary, .site-menu-panel small { color: var(--theme-muted); }
.site-menu-group.is-current > summary, .site-menu-group > summary svg, .site-header .site-doc-jump { color: var(--theme-accent); }
.site-menu-group[open] > summary, .site-menu-group > summary:hover,
.site-menu-panel a:hover, .site-menu-panel a[aria-current="page"] { background: var(--theme-hover); color: var(--theme-text); }
.site-header .site-menu-panel {
  color: var(--theme-text);
  border-color: var(--theme-line);
  background: var(--theme-panel);
  box-shadow: 0 15px 28px #1e10252e;
}

.site-header[data-menu-ready] .site-menu-toggle, .site-header .site-theme-toggle {
  color: var(--theme-text);
  background: var(--theme-raised);
  border: 1px solid var(--theme-line);
}
.site-theme-toggle:not([hidden]) { display: grid; place-items: center; }
.site-theme-toggle {
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  border-radius: .48rem;
  cursor: pointer;
}
.site-header .site-theme-toggle:hover, .site-header .site-menu-toggle:hover { background: var(--theme-hover); }
.site-theme-toggle .site-theme-moon, .site-theme-toggle[aria-checked="true"] .site-theme-sun { display: none; }
.site-theme-toggle[aria-checked="true"] .site-theme-moon { display: block; }
html[data-theme="light"] .site-header .site-workspace {
  color: #fff;
  background: #603b90;
}
html[data-theme="light"] .site-header .site-workspace:hover { background: #7047a2; }

@media (max-width: 960px) {
  .site-theme-toggle { width: 2.3rem; height: 2.3rem; }
  .site-header[data-menu-ready] .site-menu { background: var(--theme-panel); border-color: var(--theme-line); }
  .site-header .site-menu-panel { background: transparent; box-shadow: none; }
}
@media (max-width: 390px) {
  .site-header-inner { width: calc(100% - 1.5rem); gap: .4rem; }
  .site-header .site-brand { font-size: 1.06rem; }
  .site-header .site-brand img { width: 1.4rem; }
  .site-header-actions { gap: .28rem; }
  .site-header-actions .language-switch, .site-header[data-menu-ready] .site-menu-toggle, .site-header .site-theme-toggle {
    width: 2rem;
    min-width: 2rem;
    height: 2.15rem;
    min-height: 2.15rem;
    padding: 0;
  }
  .site-header .site-workspace { min-height: 2.15rem; padding-inline: .5rem; font-size: .75rem; }
}

:root .directory-footer {
  background: var(--theme-header);
  color: var(--theme-text);
  border-color: var(--theme-line);
}
:root .directory-footer h2 { color: var(--theme-text); }
:root .directory-footer a, :root .directory-footer small { color: var(--theme-muted); }
:root .directory-footer a:hover { color: var(--theme-accent); }
:root .directory-floor { border-color: var(--theme-line); }

/* Product pages share the same surfaces as the rest of the site. */
.public-platform {
  color-scheme: inherit;
  --public-bg: var(--theme-canvas);
  --public-panel: var(--theme-panel);
  --public-raised: var(--theme-raised);
  --public-line: var(--theme-line);
  --public-text: var(--theme-text);
  --public-muted: var(--theme-muted);
  --public-accent: var(--theme-accent);
}
.product-platform { color-scheme: inherit; }
.product-platform :is(.product-sidebar,.product-intro,.product-cards article,.product-steps,.product-table,.product-ledger,.pool-model-card,.pool-sim) {
  background: var(--theme-panel);
  border-color: var(--theme-line);
}
.product-platform :is(.product-sidebar-label,#calculator-scenarios) { color: var(--theme-muted); }
.product-sidebar a:hover, .product-platform .public-button.secondary:hover { background: var(--theme-hover); }
.product-sidebar a[aria-current="page"], .product-platform :is(.product-steps li > span,.product-table thead th,.product-ledger dl > .product-ledger-total,.pool-sim-results > div:last-child) {
  background: var(--theme-raised);
  color: var(--theme-accent);
  border-color: var(--theme-line);
}
.product-platform .public-button.secondary, html[data-theme="light"] .public-button.secondary {
  background: var(--theme-panel);
  color: var(--theme-accent);
}
.product-platform .public-button.primary, html[data-theme="light"] .public-button.primary {
  background: #603b90;
  border-color: #603b90;
  color: #fff;
}
.product-platform .public-button.primary:hover, html[data-theme="light"] .public-button.primary:hover {
  background: #7047a2;
  border-color: #7047a2;
}
.product-platform :is(.pool-sim-fields input,.pool-sim-fields select,.calculation-input input,#calculator-example) {
  color: var(--theme-text);
  background: var(--theme-panel);
  border-color: var(--theme-line);
}
.product-platform .product-report-status { background: var(--theme-raised); border-color: var(--theme-line); }
.product-platform :is(.pool-sim-error,#pool-calendar-error,#calculator-error) { color: var(--theme-danger); }
html[data-theme="light"] .product-platform .calculation-output {
  background: var(--theme-raised);
  color: var(--theme-text);
  border-color: var(--theme-line);
}
html[data-theme="light"] .product-platform .calculation-output p { color: var(--theme-muted); }
html[data-theme="light"] .product-platform .calculation-output dl > div { border-color: var(--theme-line); }
html[data-theme="light"] .product-platform #margin-result { color: var(--theme-success); }
html[data-theme="light"] .product-platform #margin-result.is-loss { color: var(--theme-danger); }

/* Keep the reference text and controls legible in either palette. */
.documentation-page {
  --doc-bg: var(--theme-canvas);
  --doc-paper: var(--theme-panel);
  --doc-ink: var(--theme-text);
  --doc-text: var(--theme-muted);
  --doc-muted: var(--theme-muted);
  --doc-line: var(--theme-line);
  --doc-link: var(--theme-accent);
  --doc-soft: var(--theme-hover);
}
.documentation-page a:hover { color: var(--theme-accent); }
.documentation-page :focus-visible { outline-color: var(--theme-focus); }
.documentation-page .site-header a:hover { color: var(--theme-text); }
.documentation-page .site-header .site-workspace:hover { color: #1a1126; }
html[data-theme="light"] .documentation-page .site-header .site-workspace:hover { color: #fff; }
.documentation-page .doc-hero {
  background: linear-gradient(125deg, var(--theme-raised), var(--theme-panel) 80%);
}
.documentation-page :is(.doc-skip,.doc-search-field,.doc-search-panel,.doc-hero-links a,.doc-code-heading button) {
  background: var(--theme-panel);
  color: var(--theme-accent);
  border-color: var(--theme-line);
}
.documentation-page :is(.doc-sidebar,.doc-right) a:hover, .documentation-page .doc-downloads a:hover {
  background: var(--theme-hover);
}
.documentation-page .doc-hero-links a:first-child { background: #603b90; border-color: #603b90; color: #fff; }
.documentation-page :is(.doc-search kbd,.doc-table thead th,.doc-section code,.doc-section pre,.doc-code,.doc-note) {
  background: var(--theme-raised);
  border-color: var(--theme-line);
}
.documentation-page .doc-note { border-left-color: var(--theme-accent); }
.documentation-page .doc-section code { color: var(--theme-accent); }
.documentation-page .doc-section pre code { background: transparent; color: var(--theme-text); }

/* Landing and company pages use the light palette across reading and form surfaces. */
html[data-theme="light"] .infrastructure-page {
  color: var(--theme-text);
  background: radial-gradient(ellipse at 74% 0, #fcfaff, transparent 42rem), var(--theme-canvas);
  --landing-border: var(--theme-line);
  --landing-soft: var(--theme-muted);
}
html[data-theme="light"] .infrastructure-page #headline span { color: var(--theme-accent); }
html[data-theme="light"] .infrastructure-page #headline .hero-title-main { color: var(--theme-text); }
html[data-theme="light"] :is(.hero-secondary,.hero-settlement-flow) { color: var(--theme-muted); }
html[data-theme="light"] .hero-halo { background: radial-gradient(ellipse at 68% 30%, #ede4f666, transparent 70%); }
html[data-theme="light"] .infrastructure-page .hero-grid { opacity: .2; }
html[data-theme="light"] .ecosystem-references .technology-brand { color: var(--theme-text); }
html[data-theme="light"] .ecosystem-references .technology-brand img[src$=".svg"] { filter: brightness(0) saturate(100%) opacity(.8); }
html[data-theme="light"] :is(.process-grid li,.capacity-card,.stage,.task-card,.control-card,.resource-card,.exception-table,.faq details,.pool-terms) {
  background: var(--theme-panel);
  border-color: var(--theme-line);
}
html[data-theme="light"] :is(.pool-terms,.resource-card,.task-card,.exception-table,.faq details) { color: var(--theme-text); }
html[data-theme="light"] :is(.task-icon,.process-icon,.currency-input,.allowlist summary,.allowlist-options) {
  background: var(--theme-raised);
  color: var(--theme-accent);
  border-color: var(--theme-line);
}
html[data-theme="light"] .allowlist-options label:hover, html[data-theme="light"] .resource-card:hover { background: var(--theme-hover); }
html[data-theme="light"] :is(.expense-table thead th,.expense-table tbody td) { color: var(--theme-muted); border-color: var(--theme-line); }
html[data-theme="light"] .expense-table tfoot :is(th, td) { background: var(--theme-raised); border-color: var(--theme-line); }
html[data-theme="light"] :is(.task-message,.task-message[data-tone="hold"]) { color: var(--theme-accent); }
html[data-theme="light"] :is(.product-gateway,.architecture-notes article,.docs-links a,.team-grid article) {
  background: var(--theme-panel);
  border-color: var(--theme-line);
}
html[data-theme="light"] .docs-links a:hover { background: var(--theme-hover); }

html[data-theme="light"] .operations-strip { background: var(--theme-raised); border-color: var(--theme-line); }
html[data-theme="light"] :is(.operations-metric,.operations-status) {
  background: var(--theme-panel);
  border-color: var(--theme-line);
  color: var(--theme-text);
}
html[data-theme="light"] .operations-payout[data-metric-state="reported"] { background: #f0e7fa; border-color: #c8b4e0; }
html[data-theme="light"] :is(.operations-heading-mark,.operations-metric[data-metric-state="empty"] .operations-reading strong) {
  background: var(--theme-raised);
  border-color: var(--theme-line);
  color: var(--theme-accent);
}
html[data-theme="light"] :is(.operations-metric dt,.operations-reading) { color: var(--theme-text); }
html[data-theme="light"] :is(.operations-unit,.operations-metric small,.operations-rework) {
  color: var(--theme-muted);
  border-color: var(--theme-line);
}
html[data-theme="light"] :is(.operations-metric dt .icon,.operations-rework .icon) { color: var(--theme-accent); }

/* Code windows retain a dark editor palette inside the light site. */
html[data-theme="light"] :is(.architecture-window,.quickstart-window,.technical-lab .workbench,.company-window) {
  color: #f3e9ff;
  --landing-soft: #d1c1df;
  --accent: #dab9f9;
  --muted: #d1c1df;
}
html[data-theme="light"] .infrastructure-page .settlement-console {
  box-shadow: 0 1.5rem 3.25rem #311d4526;
}
html[data-theme="light"] .company-platform {
  --company-panel: var(--theme-panel);
  --company-icon-bg: var(--theme-raised);
  --company-icon-line: #d8c8e7;
}
html[data-theme="light"] .company-platform #main { background: radial-gradient(ellipse at 75% 0, #eee6f7, transparent 43rem); }
html[data-theme="light"] .company-window { box-shadow: 0 1.2rem 2.8rem #311d4526; }
html[data-theme="light"] .infrastructure-page .button { background: #603b90; border-color: #603b90; color: #fff; }
html[data-theme="light"] .infrastructure-page .button:hover { background: #7047a2; }
html[data-theme="light"] .company-nav-bar { background: var(--theme-panel); }
html[data-theme="light"] .company-nav a.is-active { background: var(--theme-hover); border-color: var(--theme-line); }
html[data-theme="light"] :is(.company-story,.company-next) {
  background: var(--theme-raised);
  border-color: var(--theme-line);
}
html[data-theme="light"] .company-window .support-map {
  --public-accent: #dfc4ff;
  --company-icon-line: #624d79;
}
html:not([data-theme="light"]) .company-doc-body {
  --public-line: var(--theme-line);
  --public-muted: var(--theme-muted);
  --public-accent: var(--theme-accent);
  background: var(--theme-panel);
  color: var(--theme-text);
}

html[data-theme="light"] .package-board {
  background: var(--theme-panel);
  color: var(--theme-text);
  border-color: var(--theme-line);
}
html[data-theme="light"] :is(.package-titlebar,.package-icon) {
  background: var(--theme-raised);
  color: var(--theme-accent);
  border-color: var(--theme-line);
}
html[data-theme="light"] .package-grid { background: var(--theme-line); }
html[data-theme="light"] .package-card { background: var(--theme-panel); }
html[data-theme="light"] .package-board :is(h2,h3,.package-metrics dd) { color: var(--theme-text); }
html[data-theme="light"] .package-board :is(code,.package-volume,.package-acceptance strong) { color: var(--theme-accent); }
html[data-theme="light"] .package-board :is(.package-metrics dt,.package-status,.package-entry-period,.package-acceptance label) { color: var(--theme-muted); }
html[data-theme="light"] .package-board [data-state="active"] .package-status { color: var(--theme-success); }
html[data-theme="light"] .package-board [data-state="dispute"] .package-status { color: var(--theme-warning); }
html[data-theme="light"] :is(.package-metrics,.package-entry + .package-entry) { border-color: var(--theme-line); }
html[data-theme="light"] :is(.package-entry summary:hover,.package-entry[open] summary) { background: var(--theme-hover); }
html[data-theme="light"] .package-entry summary::after { color: var(--theme-accent); }
html[data-theme="light"] .package-acceptance meter::-webkit-meter-bar { background: var(--theme-hover); }

html:not([data-theme="light"]) .company-intake { background: var(--theme-canvas); color: var(--theme-text); }
html:not([data-theme="light"]) .company-intake :is(.auth-top,.auth-card,.company-process) { border-color: var(--theme-line); }
html:not([data-theme="light"]) .company-intake :is(.brand,h1,h2,.auth-card) { color: var(--theme-text); }
html:not([data-theme="light"]) .company-intake :is(.language-switch,.company-back,small a) { color: var(--theme-accent); }
html:not([data-theme="light"]) .company-intake :is(.auth-intro > p,.auth-card p,.company-process ol,.auth-form small) { color: var(--theme-muted); }
html:not([data-theme="light"]) .company-intake .auth-card { background: var(--theme-panel); }
html:not([data-theme="light"]) .company-intake .auth-form :is(input,select,textarea) {
  background: var(--theme-raised);
  color: var(--theme-text);
  border-color: var(--theme-line);
}
html:not([data-theme="light"]) .company-intake .auth-form .error {
  background: var(--theme-raised);
  color: var(--theme-danger);
  border-color: var(--theme-line);
}
html[data-theme="light"] .company-intake .theme-toggle {
  background: var(--theme-panel);
  color: var(--theme-accent);
  border-color: var(--theme-line);
}

@media (max-width: 530px) {
  .company-nav:has(> a[href$="/help"]) { display: flex; }
  .company-nav:has(> a[href$="/help"]) a {
    flex: 1 0 auto;
    justify-content: center;
    font-size: .73rem;
    white-space: nowrap;
  }
}
