/* Report styles. Structure only: every color, font, size, weight, radius and shadow
   is an --e9-* token from the engine9 components library, vendored in ui/e9/ (see
   scripts/sync-e9-theme.mjs). Light and dark come from data-theme on <html>, set by
   theme.js. No raw colors, px font sizes, numeric weights or all-caps here:
   test/theme.test.js enforces the library's rules (docs/theming.md there). */

/* Page shell */
html, body { margin: 0; background: var(--e9-color-bg); }
.fr-wrap { max-width: 1240px; margin: 0 auto; padding: 20px 24px 64px; }
.fr-gate { max-width: 560px; margin: 12vh auto; padding: var(--e9-space-6); background: var(--e9-color-surface-raised); border: var(--e9-border-width) solid var(--e9-color-border); border-top: 4px solid var(--e9-color-brand); border-radius: var(--e9-radius-md); box-shadow: var(--e9-shadow-sm); }
.fr-gate h1 { font-size: var(--e9-text-title-size); font-weight: var(--e9-text-title-weight); margin: 0 0 var(--e9-space-2); }
.fr-gate p { line-height: var(--e9-line-height-normal); margin: var(--e9-space-2) 0; }
.fr-gate .fr-msg { color: var(--e9-color-negative); }
body[data-auth="in"] .fr-gate, body[data-auth="checking"] .fr-gate { display: none; }
.fr-account { display: inline-flex; align-items: center; }
.ef-tab[disabled] { opacity: 0.45; cursor: not-allowed; }
.fr-build-note { font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); margin: 0 0 var(--e9-space-4); }
.dash-skeleton { min-height: 1.2em; background: linear-gradient(90deg, var(--e9-color-surface-sunken), var(--e9-color-border), var(--e9-color-surface-sunken)); background-size: 200% 100%; border-radius: var(--e9-radius-xs); animation: fr-shimmer 1.4s infinite linear; color: transparent; }
@keyframes fr-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .dash-skeleton { animation: none; } }

/* Report layout and type */
.ef { color: var(--e9-color-ink); display: flex; flex-direction: column; gap: var(--e9-space-5); }
.ef-title { font-size: var(--e9-font-size-2xl); font-weight: var(--e9-text-title-weight); line-height: var(--e9-line-height-tight); margin: 0; }
.ef-eyebrow { font-size: var(--e9-text-label-size); font-weight: var(--e9-text-label-weight); letter-spacing: var(--e9-text-label-tracking); color: var(--e9-color-label); margin: 0 0 var(--e9-space-1); }
.ef-lede { font-size: var(--e9-font-size-md); color: var(--e9-color-ink); margin: var(--e9-space-2) 0 0; max-width: 70ch; line-height: var(--e9-line-height-normal); }
.ef-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: var(--e9-space-3); }
.ef-tiles > .ef-card { border-top: 3px solid var(--e9-series-1); }
.ef-stack { display: flex; flex-direction: column; gap: var(--e9-space-3); }
.ef-card { background: var(--e9-color-surface-raised); border: var(--e9-border-width) solid var(--e9-color-border); border-radius: var(--e9-radius-md); box-shadow: var(--e9-shadow-sm); padding: 20px; min-width: 0; }
.ef-tile-label { font-size: var(--e9-text-label-size); font-weight: var(--e9-text-label-weight); letter-spacing: var(--e9-text-label-tracking); color: var(--e9-color-ink-muted); }
.ef-tile-value { font-size: var(--e9-font-size-2xl); font-weight: var(--e9-font-weight-semibold); line-height: var(--e9-line-height-tight); margin-top: var(--e9-space-1); font-variant-numeric: tabular-nums; }
.ef-tile-note { font-size: var(--e9-text-meta-size); font-weight: var(--e9-text-meta-weight); color: var(--e9-color-ink-muted); margin-top: var(--e9-space-1); line-height: 1.4; }
.ef-good { color: var(--e9-color-positive); } .ef-bad { color: var(--e9-color-negative); } .ef-warn { color: var(--e9-color-warning); }
.ef-h2 { font-size: var(--e9-text-heading-size); font-weight: var(--e9-text-heading-weight); line-height: var(--e9-line-height-tight); margin: 0; }
.ef-sub { font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); margin: var(--e9-space-1) 0 0; line-height: 1.45; max-width: 75ch; }

/* Charts */
.ef-chart { position: relative; margin-top: var(--e9-space-3); min-height: 220px; }
.ef-bars { display: flex; align-items: flex-end; gap: 4px; height: 200px; border-bottom: var(--e9-border-width) solid var(--e9-color-border-strong); }
.ef-bar-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.ef-bar { width: 72%; border-radius: 3px 3px 0 0; min-height: 1px; }
.ef-bar-top { font-size: var(--e9-font-size-2xs); color: var(--e9-color-ink); margin-bottom: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ef-axis { display: flex; gap: 4px; margin-top: 6px; }
.ef-axis > div { flex: 1 1 0; min-width: 0; text-align: center; font-size: var(--e9-font-size-2xs); color: var(--e9-color-ink-muted); white-space: nowrap; overflow: hidden; }
.ef-tip { position: absolute; pointer-events: none; background: var(--e9-popover-bg); color: var(--e9-popover-ink); border: var(--e9-border-width) solid var(--e9-popover-border); box-shadow: var(--e9-popover-shadow); border-radius: var(--e9-radius-sm); padding: 6px 8px; font-size: var(--e9-font-size-xs); white-space: nowrap; z-index: 5; }
.ef-tip[hidden] { display: none; }
.ef-share { margin-top: var(--e9-space-3); display: flex; flex-direction: column; gap: var(--e9-space-4); }
.ef-share-row { display: flex; justify-content: space-between; gap: var(--e9-space-2); font-size: var(--e9-font-size-md); }
.ef-track { height: 10px; border-radius: var(--e9-radius-pill); background: var(--e9-color-surface-sunken); margin-top: 6px; overflow: hidden; }
.ef-fill { height: 10px; border-radius: var(--e9-radius-pill); }
.ef-legend { display: flex; flex-wrap: wrap; gap: var(--e9-space-3); margin-top: var(--e9-space-2); font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); }
.ef-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ef-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.ef-key-ly { height: 0; border-top: 2px solid var(--e9-color-ink); border-radius: 0; width: 14px; }
.ef-ly-tick { position: absolute; left: 8%; right: 8%; height: 0; border-top: 2px solid var(--e9-color-ink); pointer-events: none; }
.ef-col-active .ef-bar { outline: 2px solid var(--e9-color-ink); outline-offset: 1px; }
.ef-caption { font-size: var(--e9-text-meta-size); color: var(--e9-color-ink); margin: var(--e9-space-2) 0 0; line-height: 1.45; max-width: 80ch; }
.ef-bars.ef-has-axis, .ef-axis.ef-has-axis { padding-left: 38px; position: relative; }
.ef-grid { position: absolute; left: 38px; right: 0; height: 0; border-top: var(--e9-border-width) solid var(--e9-color-border); pointer-events: none; }
.ef-grid-label { position: absolute; left: -38px; width: 32px; text-align: right; transform: translateY(-50%); font-size: var(--e9-font-size-2xs); color: var(--e9-color-ink-muted); font-variant-numeric: tabular-nums; }
.ef-hatch { background-image: repeating-linear-gradient(135deg, color-mix(in srgb, var(--e9-color-surface-raised) 55%, transparent) 0 2px, transparent 2px 6px); }
.ef-cellbar { position: relative; display: block; min-width: 64px; padding-bottom: 5px; text-align: right; }
.ef-cellbar-fill { position: absolute; left: 0; bottom: 0; height: 3px; border-radius: 2px; }
.ef-cellbar-val { position: relative; }

/* Tables */
.ef-tablewrap { overflow-x: auto; margin-top: var(--e9-space-3); }
.ef-table { width: 100%; border-collapse: collapse; font-size: var(--e9-font-size-xs); font-variant-numeric: tabular-nums; }
.ef-table th { text-align: right; color: var(--e9-color-ink-muted); padding: 0 8px 8px; white-space: nowrap; font-size: var(--e9-text-label-size); font-weight: var(--e9-text-label-weight); letter-spacing: var(--e9-text-label-tracking); border-bottom: var(--e9-border-width) solid var(--e9-color-border-strong); vertical-align: bottom; }
.ef-table th:nth-child(-n+2), .ef-table td:nth-child(-n+2) { text-align: left; }
.ef-table td { text-align: right; padding: 8px; border-top: var(--e9-border-width) solid var(--e9-color-border); white-space: nowrap; }
.ef-table td:nth-child(2) { white-space: normal; min-width: 220px; color: var(--e9-color-ink); }
.ef-table-num th:nth-child(2), .ef-table-num td:nth-child(2) { text-align: right; }
.ef-table-num td:nth-child(2) { min-width: 0; white-space: nowrap; }
.ef-table-num td:first-child { white-space: normal; min-width: 120px; }
.ef-table-codes th:nth-child(3), .ef-table-codes td:nth-child(3) { text-align: left; }
.ef-table-codes td:nth-child(2) { min-width: 0; }
.ef-code { white-space: normal !important; word-break: break-all; min-width: 220px; max-width: 420px; font-family: var(--e9-font-mono); font-size: var(--e9-font-size-xs); }
.ef-table-alt th:nth-child(2), .ef-table-alt td:nth-child(2) { text-align: right; }
.ef-table-alt td:nth-child(2) { min-width: 0; white-space: nowrap; }
.ef-table-text th, .ef-table-text td { text-align: left !important; white-space: normal !important; vertical-align: top; min-width: 0 !important; }
.ef-table-text td:nth-child(3), .ef-table-text td:nth-child(5) { min-width: 200px !important; }

/* Disclosures, notes and messages */
.ef-details { font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); line-height: 1.55; }
.ef-details summary { cursor: pointer; color: var(--e9-color-ink); font-weight: var(--e9-font-weight-semibold); min-height: 44px; display: inline-flex; align-items: center; }
.ef-details p { margin: var(--e9-space-1) 0; max-width: 80ch; }
.ef-details.ef-card { padding: var(--e9-space-3) 20px; }
.ef-alt { margin-top: var(--e9-space-2); font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); }
.ef-alt summary { cursor: pointer; width: max-content; min-height: 44px; display: inline-flex; align-items: center; }
.ef-err { font-size: var(--e9-text-meta-size); color: var(--e9-color-negative); padding: var(--e9-space-3) 0; }
.ef-empty { font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); margin: var(--e9-space-3) 0 0; }
.ef-callout { margin: var(--e9-space-3) 0 0; padding: var(--e9-space-3); border-left: 3px solid var(--e9-color-warning); border-radius: 0 var(--e9-radius-sm) var(--e9-radius-sm) 0; background: var(--e9-color-warning-soft); color: var(--e9-color-ink); font-size: var(--e9-text-meta-size); line-height: var(--e9-line-height-normal); }
.ef-note { margin: var(--e9-space-3) 0 0; padding: var(--e9-space-3); border-left: 3px solid var(--e9-color-accent); border-radius: 0 var(--e9-radius-sm) var(--e9-radius-sm) 0; background: var(--e9-color-accent-soft); color: var(--e9-color-ink); font-size: var(--e9-text-meta-size); line-height: var(--e9-line-height-normal); max-width: 80ch; }
.ef-note b { font-weight: var(--e9-font-weight-bold); }
.ef-cov-note { margin: var(--e9-space-3) 0 0; padding: var(--e9-space-3); border: var(--e9-border-width) dashed var(--e9-color-border-strong); border-radius: var(--e9-radius-sm); background: var(--e9-color-surface); font-size: var(--e9-text-meta-size); line-height: var(--e9-line-height-normal); max-width: 80ch; }
.ef-cov-hid, [data-cov-when][hidden], [data-cov-unless][hidden] { display: none !important; }
.ef-cov-banner { margin: 0 0 var(--e9-space-4); }
.ef-cov-banner ul { margin: var(--e9-space-2) 0 0; padding-left: 1.2em; }
.ef-cov-banner li { margin: 0.2em 0; }
.ef-summary { border-left: 3px solid var(--e9-color-accent); }
.ef-sum-head { font-size: var(--e9-font-size-md); font-weight: var(--e9-font-weight-semibold); margin: var(--e9-space-2) 0 0; line-height: var(--e9-line-height-normal); max-width: 80ch; }
.ef-sum-meta { font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); margin: var(--e9-space-2) 0 0; }
.ef-gaps { margin: 0; padding-left: 1.2em; max-width: 82ch; line-height: var(--e9-line-height-normal); }
.ef-gaps li + li { margin-top: var(--e9-space-2); }
.ef-up::before, .ef-down::before { font-size: 0.42em; vertical-align: 0.42em; margin-right: 0.3em; }
.ef-up::before { content: "▲"; }
.ef-down::before { content: "▼"; }

/* Tabs, toolbar and controls */
.ef-root { display: flex; flex-direction: column; }
.ef-root::before { content: ""; order: -4; display: block; height: 4px; margin-bottom: var(--e9-space-2); border-radius: var(--e9-radius-pill); background: var(--e9-color-brand); }
.ef-page[hidden] { display: none; }
.ef-tabs { display: flex; flex-wrap: wrap; gap: var(--e9-space-1); border-bottom: var(--e9-border-width) solid var(--e9-color-border); margin-bottom: var(--e9-space-5); }
.ef-tab { font: inherit; font-size: var(--e9-font-size-md); color: var(--e9-color-ink-muted); background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: var(--e9-space-2) var(--e9-space-3); cursor: pointer; min-height: 44px; transition: color var(--e9-transition-fast), border-color var(--e9-transition-fast); }
.ef-tab:hover { color: var(--e9-color-ink); }
.ef-tab[aria-selected="true"] { color: var(--e9-color-ink); border-bottom-color: var(--e9-color-accent); font-weight: var(--e9-font-weight-semibold); }
.ef-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: var(--e9-space-2); margin-bottom: var(--e9-space-2); font-size: var(--e9-text-meta-size); color: var(--e9-color-ink-muted); }
.ef-brand { margin-right: auto; display: inline-flex; align-items: baseline; gap: 10px; font-size: var(--e9-font-size-md); color: var(--e9-color-ink-muted); }
.ef-brand b { font-weight: var(--e9-font-weight-bold); font-size: var(--e9-font-size-xl); color: var(--e9-color-ink); }
.ef-brand i { font-style: normal; color: var(--e9-color-brand); }
.ef-seg { display: inline-flex; border: var(--e9-border-width) solid var(--e9-color-border-strong); border-radius: var(--e9-radius-sm); overflow: hidden; background: var(--e9-color-surface-raised); }
.ef-segbtn { font: inherit; font-size: var(--e9-font-size-sm); font-weight: var(--e9-font-weight-semibold); min-height: 44px; padding: 0 14px; color: var(--e9-color-ink); background: var(--e9-color-surface-raised); border: 0; cursor: pointer; transition: background-color var(--e9-transition-fast), color var(--e9-transition-fast); }
.ef-segbtn:hover { background: var(--e9-color-surface); }
.ef-segbtn + .ef-segbtn { border-left: var(--e9-border-width) solid var(--e9-color-border-strong); }
.ef-segbtn[aria-pressed="true"] { background: var(--e9-color-accent); color: var(--e9-color-accent-ink); }
.ef-root > .ef-toolbar { order: -3; }
.ef-root > .ef-tabs { order: -2; }
.ef-focusable:focus-visible { outline: 2px solid var(--e9-color-accent); outline-offset: 4px; border-radius: var(--e9-radius-xs); }
.ef-root a:focus-visible, .ef-root button:focus-visible, .ef-root summary:focus-visible, .ef-root [tabindex]:focus-visible { outline: 2px solid var(--e9-color-accent); outline-offset: 2px; box-shadow: var(--e9-focus-ring); }
.ef-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media print { .ef-tabs, .ef-toolbar, .ef-root::before { display: none; } }

/* Page shell for the client-side build */
body[data-auth="out"] #app, body[data-auth="checking"] #app { display: none; }
body[data-auth="in"] .fr-gate { display: none; }
body[data-auth="checking"] .fr-gate p.fr-gate-copy { visibility: hidden; }
body[data-auth="out"] .fr-period, body[data-auth="checking"] .fr-period { display: none; }
.fr-body { white-space: pre-wrap; line-height: var(--e9-line-height-normal); max-width: 80ch; margin-top: var(--e9-space-1); }
.fr-notes { list-style: none; margin: var(--e9-space-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--e9-space-3); }
.fr-note { border-left: 3px solid var(--e9-color-message-note); padding-left: var(--e9-space-3); }
.fr-note-resolved { opacity: 0.6; }
.fr-form { display: flex; flex-direction: column; gap: var(--e9-space-2); margin-top: var(--e9-space-3); max-width: 80ch; }
.fr-input { font: inherit; font-size: var(--e9-text-item-size); color: var(--e9-color-ink); background: var(--e9-color-surface-input); border: var(--e9-border-width) solid var(--e9-color-border); padding: 8px 10px; border-radius: var(--e9-radius-md); }
.fr-input::placeholder { color: var(--e9-color-ink-muted); }
.fr-input:focus { outline: none; border-color: var(--e9-color-accent); box-shadow: var(--e9-focus-ring); }
.fr-form .ef-segbtn { align-self: flex-start; }
.fr-link { font: inherit; font-size: var(--e9-text-meta-size); background: none; border: 0; padding: 0; color: var(--e9-color-accent); text-decoration: underline; cursor: pointer; }
.fr-link:hover { color: var(--e9-color-accent-hover); }
.fr-msg { font-size: var(--e9-text-meta-size); color: var(--e9-color-negative); margin: 0; min-height: 1em; }

/* Extra chart types */
.ef-pair { flex-direction: row; align-items: flex-end; justify-content: center; gap: 2px; }
.ef-pair-bar { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.ef-pair .ef-bar-top { font-size: var(--e9-font-size-3xs); }
.ef-sub-fig { display: block; font-size: var(--e9-font-size-2xs); color: var(--e9-color-ink); font-weight: var(--e9-font-weight-bold); margin-top: 2px; }
.ef-bar-col .ef-ly-tick { left: 4%; right: 4%; }
.ef-div { display: flex; border-bottom: 0; }
.ef-div .ef-bar-col { justify-content: flex-start; }
.ef-div-half { flex: 1 1 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.ef-div-down { align-items: flex-start; border-top: var(--e9-border-width) solid var(--e9-color-border-strong); }
.ef-line { width: 100%; height: auto; display: block; }
.ef-line text { font-size: var(--e9-font-size-2xs); fill: var(--e9-color-ink-muted); }

/* Scaled bars: gridlines, hover value, optional reference line */
.ef-plot { position: relative; }
.ef-plot .ef-grid { z-index: 0; }
.ef-bars.ef-scaled { position: relative; z-index: 1; gap: 2px; border-bottom: var(--e9-border-width) solid var(--e9-color-border-strong); }
.ef-group { display: flex; align-items: flex-end; justify-content: center; gap: 1px; width: 86%; height: 100%; }
.ef-group .ef-bar { flex: 1 1 0; width: auto; min-width: 2px; max-width: 28px; }
.ef-hovercol { cursor: default; outline-offset: 1px; }
.ef-hovercol:hover, .ef-hovercol:focus { background: color-mix(in srgb, var(--e9-color-ink) 6%, transparent); }
.ef-hover { display: none; position: absolute; top: 2px; left: 50%; transform: translateX(-50%); background: var(--e9-popover-bg); color: var(--e9-popover-ink); border: var(--e9-border-width) solid var(--e9-popover-border); box-shadow: var(--e9-popover-shadow); border-radius: var(--e9-radius-sm); padding: 6px 8px; font-size: var(--e9-font-size-xs); white-space: nowrap; z-index: 6; pointer-events: none; }
.ef-tip-left .ef-hover { left: 0; transform: none; }
.ef-tip-right .ef-hover { left: auto; right: 0; transform: none; }
.ef-hovercol:hover .ef-hover, .ef-hovercol:focus .ef-hover { display: block; }
.ef-ref { position: absolute; left: 38px; right: 0; height: 0; border-top: 2px dashed var(--e9-color-ink-muted); z-index: 2; pointer-events: none; }
.ef-ref span { position: absolute; right: 0; top: -18px; font-size: var(--e9-font-size-2xs); color: var(--e9-color-ink-muted); background: var(--e9-color-surface-raised); padding: 0 4px; }
.ef-plot.ef-has-axis { padding-left: 38px; box-sizing: border-box; }

/* Donor retention strips */
.ef-ret-row { margin-top: var(--e9-space-2); }
.ef-ret-strip { display: flex; height: 26px; margin-top: 4px; border-radius: var(--e9-radius-xs); overflow: hidden; }
.ef-ret-strip span { display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; font-size: var(--e9-font-size-xs); font-weight: var(--e9-font-weight-bold); }

/* A lone action button (outside a .ef-seg group), and the engine9 sign-in control
   that @engine9/id renders into [data-e9-mcp-button] in the toolbar. */
:not(.ef-seg) > .ef-segbtn { border: var(--e9-border-width) solid var(--e9-color-border-strong); border-radius: var(--e9-radius-sm); }
[data-e9-mcp-button] button { font: inherit; font-size: var(--e9-font-size-sm); font-weight: var(--e9-font-weight-semibold); min-height: 44px; padding: 0 14px; color: var(--e9-color-ink); background: var(--e9-color-surface-raised); border: var(--e9-border-width) solid var(--e9-color-border-strong); border-radius: var(--e9-radius-sm); cursor: pointer; transition: background-color var(--e9-transition-fast); }
[data-e9-mcp-button] button:hover { background: var(--e9-color-surface); }
