/* Founder appearance options. Loaded after shared product/admin styles.
   A is the default; D deliberately inherits the original identity unchanged.
   These tokens describe brand and surfaces, never analytical blue, status or series.
   The server meta marker supplies no-JavaScript palette fallback. :where keeps
   specificity stable; an explicit root identity always takes precedence.
   Assets are reproducible with scripts/generate_identity_variants.py. */
html:is(:is([data-pi-identity="a"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="a"]))), :where(:not([data-pi-identity]):not(:has(meta[name="pi-identity"][content="b"], meta[name="pi-identity"][content="c"], meta[name="pi-identity"][content="d"])))) body,
html:is(:is([data-pi-identity="a"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="a"]))), :where(:not([data-pi-identity]):not(:has(meta[name="pi-identity"][content="b"], meta[name="pi-identity"][content="c"], meta[name="pi-identity"][content="d"])))) body :is(.pi-ui, .pi-admin-ui) {
  --pi-bg: #f4f5ef;
  --pi-surface: #ffffff;
  --pi-surface-muted: #e8eee6;
  --pi-border: #ced9cf;
  --pi-border-strong: #748a7b;
  --pi-text: #152b24;
  --pi-muted: #52655d;
  --pi-brand: #145a46;
  --pi-brand-soft: #e0eadf;
  --pi-action: #145a46;
  --pi-focus: #145a46;
  --pi-brand-contrast: #ffffff;
  --pi-link: var(--pi-brand);
  --pi-shadow: 0 3px 14px rgb(0 0 0 / 5%);
}
html:is(:is([data-pi-identity="a"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="a"]))), :where(:not([data-pi-identity]):not(:has(meta[name="pi-identity"][content="b"], meta[name="pi-identity"][content="c"], meta[name="pi-identity"][content="d"])))):is(.dark-mode, [data-theme="dark"]) body,
html:is(:is([data-pi-identity="a"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="a"]))), :where(:not([data-pi-identity]):not(:has(meta[name="pi-identity"][content="b"], meta[name="pi-identity"][content="c"], meta[name="pi-identity"][content="d"])))) body.dark-mode,
html:is(:is([data-pi-identity="a"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="a"]))), :where(:not([data-pi-identity]):not(:has(meta[name="pi-identity"][content="b"], meta[name="pi-identity"][content="c"], meta[name="pi-identity"][content="d"])))):is(.dark-mode, [data-theme="dark"]) body :is(.pi-ui, .pi-admin-ui),
html:is(:is([data-pi-identity="a"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="a"]))), :where(:not([data-pi-identity]):not(:has(meta[name="pi-identity"][content="b"], meta[name="pi-identity"][content="c"], meta[name="pi-identity"][content="d"])))) body.dark-mode :is(.pi-ui, .pi-admin-ui) {
  --pi-bg: #0c211a;
  --pi-surface: #132c22;
  --pi-surface-muted: #1e392d;
  --pi-border: #355345;
  --pi-border-strong: #789383;
  --pi-text: #f4f5ef;
  --pi-muted: #b2c6b7;
  --pi-brand: #a8ceb7;
  --pi-brand-soft: #254536;
  --pi-action: #145a46;
  --pi-focus: #a8ceb7;
  --pi-brand-contrast: #ffffff;
  --pi-link: var(--pi-brand);
  --pi-shadow: 0 3px 14px rgb(0 0 0 / 5%);
}
html:is([data-pi-identity="b"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="b"]))) body,
html:is([data-pi-identity="b"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="b"]))) body :is(.pi-ui, .pi-admin-ui) {
  --pi-bg: #f2f6f3;
  --pi-surface: #ffffff;
  --pi-surface-muted: #e4eee8;
  --pi-border: #c8dad0;
  --pi-border-strong: #6c8c7c;
  --pi-text: #102821;
  --pi-muted: #49655b;
  --pi-brand: #12644f;
  --pi-brand-soft: #dcece3;
  --pi-action: #12644f;
  --pi-focus: #12644f;
  --pi-brand-contrast: #ffffff;
  --pi-link: var(--pi-brand);
  --pi-shadow: 0 3px 14px rgb(0 0 0 / 5%);
}
html:is([data-pi-identity="b"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="b"]))):is(.dark-mode, [data-theme="dark"]) body,
html:is([data-pi-identity="b"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="b"]))) body.dark-mode,
html:is([data-pi-identity="b"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="b"]))):is(.dark-mode, [data-theme="dark"]) body :is(.pi-ui, .pi-admin-ui),
html:is([data-pi-identity="b"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="b"]))) body.dark-mode :is(.pi-ui, .pi-admin-ui) {
  --pi-bg: #081f19;
  --pi-surface: #102d23;
  --pi-surface-muted: #193c2f;
  --pi-border: #325748;
  --pi-border-strong: #739887;
  --pi-text: #f2f6f3;
  --pi-muted: #b0c8bb;
  --pi-brand: #a7d0ba;
  --pi-brand-soft: #204c3b;
  --pi-action: #12644f;
  --pi-focus: #a7d0ba;
  --pi-brand-contrast: #ffffff;
  --pi-link: var(--pi-brand);
  --pi-shadow: 0 3px 14px rgb(0 0 0 / 5%);
}
html:is([data-pi-identity="c"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="c"]))) body,
html:is([data-pi-identity="c"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="c"]))) body :is(.pi-ui, .pi-admin-ui) {
  --pi-bg: #f3f0e7;
  --pi-surface: #fffdf7;
  --pi-surface-muted: #e9e7dc;
  --pi-border: #d4d7c8;
  --pi-border-strong: #818a76;
  --pi-text: #243329;
  --pi-muted: #60695d;
  --pi-brand: #355740;
  --pi-brand-soft: #e3e7d9;
  --pi-action: #355740;
  --pi-focus: #355740;
  --pi-brand-contrast: #ffffff;
  --pi-link: var(--pi-brand);
  --pi-shadow: 0 3px 14px rgb(0 0 0 / 5%);
}
html:is([data-pi-identity="c"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="c"]))):is(.dark-mode, [data-theme="dark"]) body,
html:is([data-pi-identity="c"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="c"]))) body.dark-mode,
html:is([data-pi-identity="c"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="c"]))):is(.dark-mode, [data-theme="dark"]) body :is(.pi-ui, .pi-admin-ui),
html:is([data-pi-identity="c"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="c"]))) body.dark-mode :is(.pi-ui, .pi-admin-ui) {
  --pi-bg: #18241c;
  --pi-surface: #243228;
  --pi-surface-muted: #303f30;
  --pi-border: #4b5b47;
  --pi-border-strong: #8b9b80;
  --pi-text: #f3f0e7;
  --pi-muted: #c2c9b7;
  --pi-brand: #bdcbb3;
  --pi-brand-soft: #3b4e38;
  --pi-action: #355740;
  --pi-focus: #bdcbb3;
  --pi-brand-contrast: #ffffff;
  --pi-link: var(--pi-brand);
  --pi-shadow: 0 3px 14px rgb(0 0 0 / 5%);
}

/* Shared decorative surface details; D has no overrides here. */
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) body.pi-site.pi-page--regime::before {
  background-image: none;
}
/* The independent-voice landing uses the shared open canvas in every palette.
   Theme-aware art and text keep the same contrast roles as the working pages. */
/* The selected illustration is set before paint, and stays stable for a visit. */
html[data-pi-landing-art="circles"] [data-landing-artwork="landscape"],
html:not([data-pi-landing-art="circles"]) [data-landing-artwork="circles"] { display: none; }
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .pi-home-art .pi-phase-frame { background: var(--pi-bg); }

/* Flask-Admin keeps Bootstrap. This adapter only maps its existing brand tokens
   and explicit brand surfaces; status alerts keep their established colors. */
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) body {
  --aw-bg: var(--pi-bg);
  --aw-surface: var(--pi-surface);
  --aw-muted-surface: var(--pi-surface-muted);
  --aw-text: var(--pi-text);
  --aw-muted: var(--pi-muted);
  --aw-border: var(--pi-border);
  --aw-control-border: var(--pi-border-strong);
  --aw-link: var(--pi-link);
}
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) body > :is(.container, .container-fluid) > .navbar {
  background: var(--pi-surface) !important;
  border-bottom: 1px solid var(--pi-border);
}
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .pi-workspace-menu .nav-link { color: var(--pi-text) !important; }
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .pi-workspace-menu .active > .nav-link { color: var(--pi-brand) !important; border-bottom-color: var(--pi-brand); }
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .pi-workspace-task { border-top-color: var(--pi-brand); }
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) :is(.pi-workspace-tool button, .btn-primary, .pi-record-actions > li > .pi-record-create) {
  background: var(--pi-action);
  border-color: var(--pi-action);
  color: #fff;
}
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) body > :is(.container, .container-fluid) :is(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--pi-focus);
  outline-offset: 3px;
}
/* Appearance is a Bootstrap account form. Fixed swatches identify the options;
   the cards themselves follow the currently applied palette and theme. */
.pi-appearance-settings { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--aw-border); }
.pi-appearance-form fieldset { min-width: 0; }
.pi-appearance-form legend { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; color: var(--aw-text); }
.pi-appearance-choice { height: 100%; padding-bottom: 1rem; }
.pi-appearance-option {
  display: block;
  height: 100%;
  padding: 1rem;
  border: 1px solid var(--aw-control-border);
  border-radius: 2px;
  color: var(--aw-text);
  background: var(--aw-surface);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.pi-appearance-option:hover { background: var(--aw-muted-surface); }
.pi-appearance-option:has(input:checked) {
  border-color: var(--aw-link);
  box-shadow: inset 0 0 0 1px var(--aw-link);
}
.pi-appearance-option:has(input:checked)::after {
  content: "Selected";
  display: block;
  color: var(--aw-link);
  font-size: .8rem;
  font-weight: 700;
  margin-top: .6rem;
}
.pi-appearance-option input[type="radio"] {
  accent-color: var(--aw-link);
  width: 1rem;
  height: 1rem;
  margin-right: .45rem;
  vertical-align: -.1rem;
}
.pi-appearance-option input[type="radio"]:focus-visible {
  outline: 2px solid var(--aw-link);
  outline-offset: 3px;
}
.pi-appearance-option:focus-within { outline: 2px solid var(--aw-link); outline-offset: 3px; }
html[data-theme] body .pi-admin-ui .pi-appearance-option strong { color: var(--aw-text); }
.pi-appearance-description { display: block; font-size: .9rem; line-height: 1.5; color: var(--aw-muted); }
.pi-appearance-swatches { display: flex; gap: .35rem; margin-block: .8rem; }
.pi-appearance-swatches i { display: block; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid rgb(0 0 0 / 25%); }
.pi-appearance-option[data-appearance-option="a"] { --pi-swatch-first: #0c211a; --pi-swatch-second: #145a46; --pi-swatch-third: #f4f5ef; }
.pi-appearance-option[data-appearance-option="b"] { --pi-swatch-first: #081f19; --pi-swatch-second: #12644f; --pi-swatch-third: #a7d0ba; }
.pi-appearance-option[data-appearance-option="c"] { --pi-swatch-first: #243329; --pi-swatch-second: #355740; --pi-swatch-third: #f3f0e7; }
.pi-appearance-option[data-appearance-option="d"] { --pi-swatch-first: #0a1425; --pi-swatch-second: #245bdb; --pi-swatch-third: #f4f7fc; }
.pi-appearance-swatches i:nth-child(1) { background: var(--pi-swatch-first); }
.pi-appearance-swatches i:nth-child(2) { background: var(--pi-swatch-second); }
.pi-appearance-swatches i:nth-child(3) { background: var(--pi-swatch-third); }
.pi-appearance-actions { gap: .65rem; margin-top: .75rem; }
.pi-appearance-actions .btn { white-space: normal; min-height: 40px; }
.pi-appearance-form [role="status"] { margin-top: .8rem; color: var(--aw-text); }
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .pi-workspace-theme {
  color: var(--aw-text);
  background: var(--aw-surface);
  border-color: var(--aw-control-border);
}
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .pi-workspace-theme:is(:hover, :active, :focus) {
  color: var(--aw-text);
  background: var(--aw-muted-surface);
  border-color: var(--aw-link);
}
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .navbar-toggler { color: var(--aw-text); border-color: var(--aw-control-border); }
/* Draw the menu icon with currentColor, avoiding Bootstrap's fixed white SVG. */
html:not(:is([data-pi-identity="d"], :where(:not([data-pi-identity]):has(meta[name="pi-identity"][content="d"])))) .navbar-toggler-icon {
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor);
  background-size: 75% 2px;
  background-position: center 25%, center 50%, center 75%;
  background-repeat: no-repeat;
}

.pi-appearance-actions { margin-bottom: 1rem; }
.pi-appearance-actions .btn-link { color: var(--aw-link); }
.pi-appearance-actions .btn-link:is(:hover, :focus) { color: var(--aw-link); text-decoration: underline; }
.pi-appearance-actions .btn-outline-secondary { color: var(--aw-text); border-color: var(--aw-control-border); }
.pi-appearance-actions .btn-outline-secondary:is(:hover, :focus) { color: var(--aw-text); background: var(--aw-muted-surface); border-color: var(--aw-link); }

/* CRS presentation follows the selected identity. Regime fills, left-hand
   regime borders, stress bars, deltas and plotted series retain their meaning. */
html body.pi-site .sa-panel.sa-panel :is(.sa-header, .sa-landing-card, .sa-contributor-panel) {
  background: var(--pi-surface);
  color: var(--pi-text);
  border-color: var(--pi-border);
  box-shadow: var(--pi-shadow);
}
html body.pi-site .sa-panel.sa-panel :is(.sa-header, .sa-landing-card) { border-top-color: var(--pi-brand); }
html body.pi-site .sa-panel.sa-panel :is(.sa-metric-row, .sa-landing-instrument-row, .sa-landing-driver-row, .sa-treemap-svg) {
  background: var(--pi-surface-muted);
  color: var(--pi-text);
  border-top-color: var(--pi-border);
  border-right-color: var(--pi-border);
  border-bottom-color: var(--pi-border);
}
html body.pi-site .sa-panel.sa-panel :is(.sa-landing-instrument-row, .sa-landing-driver-row, .sa-treemap-svg) { border-left-color: var(--pi-border); }
html body.pi-site .sa-panel.sa-panel :is(.sa-metric-title, .sa-metric-risk, .sa-landing-row-title, .sa-landing-score, .sa-contributor-table),
html body.pi-site #situational-awareness-panel .sa-metric-score { color: var(--pi-text); }
html body.pi-site .sa-panel.sa-panel :is(.sa-control-help, .sa-metric-range, .sa-metric-foot, .sa-metric-meta, .sa-contributor-help, .sa-treemap-summary, .sa-treemap-legend, .sa-landing-score-meta, .sa-landing-row-meta, .sa-landing-price-meta, .sa-landing-delta--flat, .sa-landing-delta--unknown, .sa-delta-flat, .sa-delta-unknown, .sa-contributor-table th) { color: var(--pi-muted); }
html body.pi-site .sa-panel.sa-panel :is(.sa-chart-text, .sa-chart-label, .sa-chart-axis-title, .sa-bubble-range-text, .sa-bubble-period-text, .sa-treemap-group-label) {
  fill: var(--pi-muted);
  color: var(--pi-muted);
}
/* Text inside pastel regime marks stays dark in both modes. */
html body.pi-site .sa-panel.sa-panel :is(.sa-bubble-label, .sa-bubble-score, .sa-bubble-percentile, .sa-bubble-risk-label, .sa-treemap-label, .sa-treemap-score, .sa-treemap-meta) { fill: #172033; }
html body.pi-site .sa-panel.sa-panel :is(.sa-chart-axis, .sa-chart-grid) { stroke: var(--pi-border); }
html body.pi-site .sa-panel.sa-panel .sa-asof-marker { stroke: var(--pi-muted); }
html body.pi-site .sa-panel.sa-panel .sa-chart-legend-bg { fill: var(--pi-surface); fill-opacity: .96; }
html body.pi-site .sa-panel.sa-panel .sa-loading-tag { color: var(--pi-muted); border-color: var(--pi-border-strong); }
html body.pi-site .sa-panel.sa-panel .sa-loading-tag::before { border-color: var(--pi-border); border-top-color: var(--pi-brand); }
html body.pi-site .sa-panel.sa-panel .sa-metric-row.is-clickable:is(:hover, :focus-visible) {
  outline: 2px solid var(--pi-focus);
  outline-offset: 2px;
  box-shadow: none;
  border-top-color: var(--pi-border);
  border-right-color: var(--pi-border);
  border-bottom-color: var(--pi-border);
}
/* Keep hover from overwriting the regime stripe. */
html body.pi-site .sa-panel.sa-panel .sa-metric-row.sa-regime-calm { border-left-color: #059669; }
html body.pi-site .sa-panel.sa-panel .sa-metric-row.sa-regime-transition { border-left-color: #2563eb; }
html body.pi-site .sa-panel.sa-panel .sa-metric-row.sa-regime-stress { border-left-color: #d97706; }
html body.pi-site .sa-panel.sa-panel .sa-metric-row.sa-regime-extreme { border-left-color: #dc2626; }
html body.pi-site .sa-panel.sa-panel .sa-treemap-cell.is-clickable:is(:hover, :focus) .sa-treemap-rect { stroke: var(--pi-focus); }
html body.pi-site .sa-panel.sa-panel .sa-stress-info-tag:focus { outline-color: var(--pi-focus); }
html body.pi-site .sa-panel.sa-panel .sa-stress-info-tag::after {
  background: var(--pi-text);
  color: var(--pi-bg);
  border-color: var(--pi-border-strong);
  box-shadow: var(--pi-shadow);
}
html body.pi-site .sa-help-modal :is(.modal-card-head, .modal-card-body, .modal-card-foot) {
  background: var(--pi-surface);
  border-color: var(--pi-border);
  color: var(--pi-text);
}
html body.pi-site .sa-help-modal :is(.modal-card-title, .content) { color: var(--pi-text); }
