/* ==========================================================================
   Dashboard kit: <x-dash.*> (resources/views/components/dash). Restyled to match the core home dashboard (resources/views/home, .db-* in bb-pages.css):
   hairline-divided metric panel with a tinted lead card, icon chips, shadowed cards, tint tiles. Colour comes from tokens only, per-component hue via .bd-tint-*.
   Tokens only; the kit's own tokens (--bb-dash-gap, --bb-chart-main/-muted/-grid) live in app.css.
   Loaded on every app page next to reports.css (layouts/partials/css.blade.php). JS: public/js/bb-dash.js.

   LAYOUT (documented convention)
     .bd-page        vertical stack of the dashboard's blocks, gap = --bb-dash-gap (24px; 16px on a phone)
     .bd-grid        responsive grid with the same gap. Pick the widest layout; it folds on its own:
       .bd-grid-2    1 col -> 2 cols from 768px
       .bd-grid-3    1 col -> 2 cols from 768px -> 3 cols from 1200px
       .bd-grid-4    2 cols from 480px -> 4 cols from 1200px
       .bd-span-2    on a child: spans 2 columns from 768px (a wide chart next to a narrow list)
     OTHER HELPERS
       .bd-filterbar  row holding <x-dash.filters> and a one-line .bd-filter-note (what the filters drive)
       .bd-finding    one sentence under the page title: the single most useful finding
       .bd-note       small muted line (a footnote under a strip or a card)
       .bd-figs / .bd-fig   2-4 small summary figures in a row inside a card (label + figure), above a chart
       .bd-chart      the box a Highcharts chart is drawn in; it fills its card (BBDash.chart resizes it), min height on tokens
       .bd-count      small count badge next to a card title (primary tint, grey at zero)
     COMPONENTS: hero, section, stats > kpi / pair, tiles > tile, card (icon + tint + link), list > list-row, bars, empty, filters
   ========================================================================== */

[hidden].bd-custom, .bd-kpi [hidden] { display: none !important; }

/* ---- layout ---- */
.bd-page { display: flex; flex-direction: column; gap: var(--bb-dash-gap); margin-bottom: var(--bb-dash-gap); min-width: 0; }
.bd-page > * { min-width: 0; }
/* no gutter of its own: the layout's content wrapper (section.content) already gives 24px / 20px, which is exactly where the
   core dashboard's content starts. An extra gutter here doubled the gap on the left and the top. */
.bd-page > .bb-ph { margin: 0; }
.bd-grid { display: grid; gap: var(--bb-dash-gap); grid-template-columns: minmax(0, 1fr); align-items: stretch; }
.bd-grid > * { min-width: 0; }
.bd-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) {
    .bd-grid-2, .bd-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bd-span-2 { grid-column: span 2; }
}
@media (min-width: 1200px) {
    .bd-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .bd-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 479px) { .bd-grid-4 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 639px) { :root { --bb-dash-gap: var(--bb-space-16); } }

/* ---- tints: one hue per component (icon chip, KPI icon, lead-card edge). Set on the element, read as --bd-ci / --bd-ci-bg ---- */
.bd-tint-primary { --bd-ci: var(--bb-primary); --bd-ci-bg: var(--bb-primary-glow); }
.bd-tint-success { --bd-ci: var(--bb-success); --bd-ci-bg: var(--bb-success-glow); }
.bd-tint-danger { --bd-ci: var(--bb-danger); --bd-ci-bg: var(--bb-danger-glow); }
.bd-tint-warning { --bd-ci: var(--bb-warning); --bd-ci-bg: var(--bb-warning-glow); }
.bd-tint-info { --bd-ci: var(--bb-info); --bd-ci-bg: var(--bb-info-glow); }
.bd-tint-neutral { --bd-ci: var(--bb-secondary); --bd-ci-bg: var(--bb-surface-hover); }
/* icon in a tinted square (card header) */
.bd-ci { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; width: var(--bb-space-32); height: var(--bb-space-32); border-radius: var(--bb-radius-md); background: var(--bd-ci-bg, var(--bb-primary-glow)); }
.bd-ci svg { width: var(--bb-space-16); height: var(--bb-space-16); color: var(--bd-ci, var(--bb-primary)); }
/* small orange link ("Label →") in a section or card header */
.bd-link { font-size: var(--bb-text-sm); font-weight: 600; color: var(--bb-primary-text); text-decoration: none; white-space: nowrap; }
.bd-link:hover, .bd-link:focus { color: var(--bb-primary-hover); text-decoration: underline; }

/* ---- hero: page title, welcome line, filters on the right, quick-action buttons under it ---- */
.bd-hero { display: flex; flex-direction: column; gap: var(--bb-space-16); min-width: 0; }
.bd-hero-inner { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--bb-space-16); flex-wrap: wrap; }
.bd-hero-titles { min-width: 0; }
.bd-hero-title { margin: 0; font-size: var(--bb-text-3xl); font-weight: 700; line-height: var(--bb-leading-tight); letter-spacing: -0.02em; color: var(--bb-text); }
.bd-hero-sub { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); margin-top: var(--bb-space-4); font-size: var(--bb-text-base); font-weight: 500; color: var(--bb-text-muted); }
.bd-hero-dot { width: var(--bb-space-4); height: var(--bb-space-4); border-radius: var(--bb-radius-circle); background: var(--bb-text-faint); }
.bd-hero-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); }
.bd-hero-actions { display: flex; gap: var(--bb-space-8); min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.bd-hero-actions::-webkit-scrollbar { display: none; }
.bd-hero-actions > * { flex: 0 0 auto; }
@media (max-width: 899px) { .bd-hero-inner { flex-direction: column; align-items: stretch; } }
@media (max-width: 639px) {
    .bd-hero-title { font-size: var(--bb-text-xl); }
    /* phones: every action visible, two per row, instead of a strip that hides the last ones off-screen */
    .bd-hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
    .bd-hero-actions > * { min-width: 0; width: 100%; height: auto; min-height: var(--bb-space-40); white-space: normal; line-height: var(--bb-leading-tight); text-align: center; }
}

/* ---- section heading: bold title left, small link right ---- */
.bd-section { display: flex; align-items: baseline; justify-content: space-between; gap: var(--bb-space-12); margin: 0 0 var(--bb-space-12); }
.bd-section-title { margin: 0; font-size: var(--bb-text-lg); font-weight: 700; line-height: var(--bb-leading-tight); letter-spacing: -0.01em; color: var(--bb-text); }
.bd-section-sub { margin: var(--bb-space-2) 0 0; font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bd-section-actions { display: flex; align-items: center; gap: var(--bb-space-12); font-size: var(--bb-text-sm); font-weight: 600; }
.bd-section-actions a:not(.bd-link) { color: var(--bb-primary-text); }

/* ---- metric panel: one container, equal columns, 1px hairlines (the gap shows the container's colour). A hero KPI is the wider first column ---- */
.bd-stats {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px;
    background: var(--bb-border); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); overflow: hidden;
}
.bd-stats:has(> .is-hero:first-child) { grid-template-columns: minmax(0, 1.3fr); }
@media (max-width: 899px) {
    .bd-stats, .bd-stats:has(> .is-hero:first-child) { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-columns: auto; }
    .bd-stats > .is-hero { grid-column: 1 / -1; }
    .bd-stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    /* a full-width lead card counts as one: with it, an even total leaves a lone last figure that should span the row */
    .bd-stats:has(> .is-hero) > :last-child:nth-child(even) { grid-column: 1 / -1; }
}

/* ---- KPI: icon + label, figure, change chip + baseline ---- */
.bd-kpi { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; row-gap: var(--bb-space-4); min-width: 0; padding: var(--bb-space-16) var(--bb-space-20); background: var(--bb-surface); color: var(--bb-text); text-align: left; text-decoration: none; transition: background-color 0.15s; }
a.bd-kpi:hover, a.bd-kpi:focus { background: var(--bb-surface-hover); color: var(--bb-text); text-decoration: none; }
a.bd-kpi:focus-visible { outline: var(--bb-space-2) solid var(--bb-primary); outline-offset: calc(-1 * var(--bb-space-2)); }
/* icon (col 1) and label (col 2) share the first row; the figure and the change line take the full width */
.bd-kpi-icon { display: flex; grid-column: 1; align-self: center; margin-inline-end: var(--bb-space-8); margin-bottom: var(--bb-space-4); }
.bd-kpi > :is(.bd-kpi-value, .bd-kpi-meta) { grid-column: 1 / -1; }
.bd-kpi-label { grid-column: 1 / -1; margin-bottom: var(--bb-space-4); }
.bd-kpi-icon + .bd-kpi-label { grid-column: 2; }
.bd-kpi-icon svg { width: calc(var(--bb-space-12) + var(--bb-space-2)); height: calc(var(--bb-space-12) + var(--bb-space-2)); color: var(--bd-ci, var(--bb-primary)); }
.bd-kpi-label { min-width: 0; overflow: hidden; font-size: var(--bb-text-base); font-weight: 500; line-height: var(--bb-leading-normal); color: var(--bb-text-muted); text-overflow: ellipsis; white-space: nowrap; }
.bd-kpi-value { display: block; margin: 0; font-size: var(--bb-text-2xl); font-weight: 700; line-height: var(--bb-leading-tight); letter-spacing: -0.02em; color: var(--bb-text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* Six figures in one row leave each about 130px: a smaller figure that stays on one line beats "Rs" / "16,700.00" */
@media (min-width: 900px) { .bd-stats:has(> :nth-child(6)) .bd-kpi-value { font-size: var(--bb-text-xl); white-space: nowrap; } }
.bd-kpi-value.is-missing, .bd-kpi.is-muted .bd-kpi-value { color: var(--bb-text-faint); }
.bd-kpi.is-good .bd-kpi-value { color: var(--bb-success-text); }
.bd-kpi.is-warn .bd-kpi-value { color: var(--bb-warning-text); }
.bd-kpi.is-bad .bd-kpi-value { color: var(--bb-danger-text); }
.bd-kpi-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-2) var(--bb-space-8); min-height: calc(var(--bb-text-sm) * var(--bb-leading-normal)); font-size: var(--bb-text-sm); line-height: var(--bb-leading-normal); }
.bd-kpi-delta { display: inline-flex; align-items: center; gap: var(--bb-space-4); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bb-text-muted); }
.bd-kpi-delta[hidden] { display: none; }
.bd-kpi-delta.is-good { color: var(--bb-success-text); }
.bd-kpi-delta.is-bad { color: var(--bb-danger-text); }
/* the arrow follows the sign of the change, drawn from a triangle so no icon markup is needed */
.bd-kpi-delta.is-up::before, .bd-kpi-delta.is-down::before { content: ""; flex: 0 0 auto; width: var(--bb-space-8); height: var(--bb-space-8); background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.bd-kpi-delta.is-down::before { transform: rotate(180deg); }
.bd-kpi-hint { color: var(--bb-text-muted); font-weight: 500; }
/* lead card: tinted wash, 3px edge in the tint, a larger figure */
.bd-kpi.is-hero { align-content: center; padding: var(--bb-space-24); --bb-edge-color: var(--bd-ci, var(--bb-primary)); box-shadow: var(--bb-shadow-inset-edge); }
.bd-kpi.is-hero::before { content: ""; position: absolute; inset: 0; background: var(--bd-ci-bg, var(--bb-primary-glow)); pointer-events: none; }
.bd-kpi.is-hero > * { position: relative; }
.bd-kpi.is-hero .bd-kpi-label, .bd-kpi.is-hero .bd-kpi-icon { margin-bottom: var(--bb-space-8); }
.bd-kpi.is-hero .bd-kpi-label { font-size: var(--bb-text-md); color: var(--bb-text-body); }
.bd-kpi.is-hero .bd-kpi-value { font-size: var(--bb-text-4xl); letter-spacing: -0.03em; }
.bd-kpi.is-hero .bd-kpi-meta { margin-top: var(--bb-space-8); }
@media (max-width: 639px) {
    .bd-kpi { padding: var(--bb-space-12); }
    .bd-kpi-value { font-size: var(--bb-text-lg); }
    .bd-kpi.is-hero { padding: var(--bb-space-16); }
    .bd-kpi.is-hero .bd-kpi-value { font-size: var(--bb-text-3xl); }
    /* labels wrap to 2 lines instead of one-line ellipsis; two lines reserved so cards in a row stay equal */
    .bd-kpi:not(.is-hero) .bd-kpi-icon { align-self: start; }
    .bd-kpi:not(.is-hero) .bd-kpi-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; min-height: 2.5em; line-height: var(--bb-leading-tight); white-space: normal; overflow-wrap: anywhere; }
}

/* ---- pair: two compact KPIs sharing one cell (the home "returns" cell) ---- */
.bd-pair { display: grid; grid-template-rows: 1fr 1fr; gap: 1px; min-width: 0; background: var(--bb-border); }
.bd-pair .bd-kpi { grid-template-columns: auto minmax(0, 1fr) auto; align-content: center; row-gap: 0; padding: var(--bb-space-8) var(--bb-space-20); }
.bd-pair .bd-kpi-icon, .bd-pair .bd-kpi-label { grid-row: 1; margin-bottom: 0; }
.bd-pair .bd-kpi-label { grid-column: 1 / 3; }
.bd-pair .bd-kpi-icon + .bd-kpi-label { grid-column: 2; }
.bd-pair .bd-kpi > .bd-kpi-meta { grid-column: 3; grid-row: 1; min-height: 0; justify-content: flex-end; }
.bd-pair .bd-kpi > .bd-kpi-value { grid-row: 2; font-size: var(--bb-text-lg); }
@media (max-width: 899px) { .bd-stats > .bd-pair { grid-column: 1 / -1; } }
@media (max-width: 639px) { .bd-pair .bd-kpi { padding: var(--bb-space-8) var(--bb-space-12); } .bd-pair .bd-kpi:not(.is-hero) .bd-kpi-label { min-height: 0; } }

/* ---- attention tiles: number in a tinted square, label, sub-label. Grey when the count is zero ---- */
.bd-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--bb-space-64) * 2 + var(--bb-space-40)), 1fr)); gap: var(--bb-space-12); }
@media (max-width: 639px) { .bd-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 419px) { .bd-tiles { grid-template-columns: minmax(0, 1fr); } }
.bd-tile { display: flex; align-items: center; gap: var(--bb-space-12); min-width: 0; padding: var(--bb-space-12) var(--bb-space-16); background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-md); color: var(--bb-text); text-decoration: none; transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s; }
a.bd-tile:hover, a.bd-tile:focus { color: var(--bb-text); text-decoration: none; transform: translateY(-1px); border-color: var(--bb-border-strong); box-shadow: var(--bb-shadow-md); }
a.bd-tile:focus-visible { outline: var(--bb-space-2) solid var(--bb-primary); outline-offset: var(--bb-space-2); }
.bd-tile-count { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; min-width: var(--bb-space-40); height: var(--bb-space-40); padding: 0 var(--bb-space-8); border-radius: var(--bb-radius-md); font-size: var(--bb-text-xl); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bd-tile-warning .bd-tile-count { background: var(--bb-warning-bg); color: var(--bb-warning-text); }
.bd-tile-danger .bd-tile-count { background: var(--bb-danger-bg); color: var(--bb-danger-text); }
.bd-tile-info .bd-tile-count { background: var(--bb-info-bg); color: var(--bb-info-text); }
.bd-tile-success .bd-tile-count { background: var(--bb-success-bg); color: var(--bb-success-text); }
.bd-tile-neutral .bd-tile-count, .bd-tile-zero .bd-tile-count { background: var(--bb-surface-raised); color: var(--bb-text-faint); }
.bd-tile-zero { opacity: 0.72; }
.bd-tile-text { display: flex; flex-direction: column; min-width: 0; }
.bd-tile-label { font-size: var(--bb-text-sm); font-weight: 700; line-height: var(--bb-leading-tight); overflow-wrap: anywhere; }
.bd-tile-sub { margin-top: var(--bb-space-2); font-size: var(--bb-text-xs); font-weight: 600; color: var(--bb-text-muted); font-variant-numeric: tabular-nums; }
.bd-tiles-clear { display: flex; align-items: center; gap: var(--bb-space-8); padding: var(--bb-space-12) var(--bb-space-16); border-radius: var(--bb-radius-md); background: var(--bb-success-bg); color: var(--bb-success-text); font-size: var(--bb-text-base); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .bd-tile, .bd-kpi { transition: none; } a.bd-tile:hover { transform: none; } }

/* ---- card: header (icon chip, title, link, actions) over a hairline, then the body ---- */
.bd-card { display: flex; flex-direction: column; min-width: 0; background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); box-shadow: var(--bb-shadow-xs); }
.bd-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--bb-space-12); padding: var(--bb-space-12) var(--bb-space-16); border-bottom: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg) var(--bb-radius-lg) 0 0; }
.bd-card-titles { min-width: 0; flex: 1; }
.bd-card-title { margin: 0; overflow: hidden; font-size: var(--bb-text-md); font-weight: 700; line-height: var(--bb-leading-tight); letter-spacing: -0.01em; color: var(--bb-text); text-overflow: ellipsis; }
.bd-card-sub { margin: var(--bb-space-2) 0 0; font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bd-card-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); font-size: var(--bb-text-sm); }
.bd-card-body { flex: 1; min-width: 0; padding: var(--bb-space-16); }
.bd-card-body.is-fill { display: flex; flex-direction: column; }
.bd-card-body[hidden] { display: none; }
.bd-card-body.is-flush { padding: 0; overflow-x: auto; }
.bd-card-body.is-flush > .bb-table-card { border: 0; border-radius: 0; box-shadow: none; }
/* collapsible card (the home accordion): the whole header row is the toggle (a real button, keyboard and screen-reader friendly) */
.bd-card.is-collapsible { overflow: hidden; transition: border-color 0.18s; }
.bd-card.is-collapsible.is-open { border-color: var(--bb-primary-border); }
.bd-card.is-collapsible .bd-card-head:hover, .bd-card.is-collapsible.is-open .bd-card-head { background: var(--bb-surface-raised); }
.bd-card.is-collapsible:not(.is-open) .bd-card-head { border-bottom-color: transparent; }
.bd-card-toggle { display: flex; align-items: center; gap: var(--bb-space-12); flex: 1; min-width: 0; margin: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bd-card-toggle:focus-visible { outline: var(--bb-space-2) solid var(--bb-primary); outline-offset: var(--bb-space-2); border-radius: var(--bb-radius-sm); }
.bd-card-toggle::after { content: ""; flex: 0 0 auto; order: 3; width: var(--bb-space-8); height: var(--bb-space-8); margin-inline-start: auto; border-right: var(--bb-space-2) solid var(--bb-text-muted); border-bottom: var(--bb-space-2) solid var(--bb-text-muted); transform: rotate(45deg) translate(calc(-1 * var(--bb-space-2)), calc(-1 * var(--bb-space-2))); transition: transform 0.18s; }
.bd-card-toggle[aria-expanded="true"]::after { transform: rotate(225deg) translate(calc(-1 * var(--bb-space-2)), calc(-1 * var(--bb-space-2))); }
.bd-card-toggle .bd-card-titles, .bd-card-toggle .bd-card-title, .bd-card-toggle .bd-card-sub { display: block; }
.bd-card-toggle .bd-card-title { font-size: var(--bb-text-md); font-weight: 700; color: var(--bb-text); }
/* count badge next to a title: primary tint, grey at zero */
.bd-count { display: inline-flex; align-items: center; justify-content: center; min-width: var(--bb-space-20); height: var(--bb-space-20); margin-inline-start: var(--bb-space-8); padding: 0 var(--bb-space-6); border-radius: var(--bb-radius-full); background: var(--bb-primary-tint); font-size: var(--bb-text-xs); font-weight: 700; color: var(--bb-primary-text); font-variant-numeric: tabular-nums; vertical-align: middle; }
.bd-count.is-zero { background: var(--bb-surface-raised); color: var(--bb-text-faint); }
.bd-count:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .bd-card-toggle::after, .bd-card.is-collapsible { transition: none; } }
.bd-card-foot { padding: var(--bb-space-12) var(--bb-space-16); border-top: 1px solid var(--bb-border); font-size: var(--bb-text-sm); }
.bd-card { scroll-margin-top: calc(var(--bb-space-64) + var(--bb-space-16)); }
.bd-card-more { font-weight: 600; color: var(--bb-primary-text); }
.bd-card-more:hover { color: var(--bb-primary-hover); text-decoration: underline; }

/* ---- empty and error states (the frame stays) ---- */
.bd-empty { display: flex; flex-direction: column; align-items: center; gap: var(--bb-space-4); padding: var(--bb-space-24) var(--bb-space-16); border: 1px dashed var(--bb-border-strong); border-radius: var(--bb-radius-md); text-align: center; }
.bd-empty-title { font-size: var(--bb-text-md); font-weight: 600; color: var(--bb-text-body); }
.bd-empty-text { margin: 0; max-width: 40ch; font-size: var(--bb-text-base); color: var(--bb-text-muted); }
.bd-empty-action { margin-top: var(--bb-space-8); }
.bd-error { display: flex; flex-direction: column; align-items: flex-start; gap: var(--bb-space-12); padding: var(--bb-space-16); border: 1px solid var(--bb-danger-border); border-radius: var(--bb-radius-md); }
.bd-error-text { margin: 0; font-size: var(--bb-text-base); font-weight: 500; color: var(--bb-danger-text); }

/* ---- loading skeleton (a quiet pulse, off for reduced motion) ---- */
.bd-skel { display: block; background: var(--bb-surface-hover); border-radius: var(--bb-radius-sm); animation: bd-pulse 1.4s ease-in-out infinite; }
.bd-skel-figure { width: 60%; height: var(--bb-text-2xl); }
.bd-skel-wrap { display: flex; flex-direction: column; gap: var(--bb-space-12); }
.bd-skel-line { width: 100%; height: var(--bb-space-12); }
.bd-skel-line:last-of-type { width: 60%; }
.bd-skel-block { width: 100%; height: calc(var(--bb-space-64) * 3); }
@keyframes bd-pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .bd-skel { animation: none; } }

/* ---- ranked / status list ---- */
.bd-list { --bd-row-h: calc(var(--bb-space-48) + var(--bb-space-4)); margin: 0; padding: 0; list-style: none; }
.bd-cap-5 { max-height: calc(var(--bd-row-h) * 5); overflow-y: auto; }
.bd-cap-8 { max-height: calc(var(--bd-row-h) * 8); overflow-y: auto; }
.bd-cap-10 { max-height: calc(var(--bd-row-h) * 10); overflow-y: auto; }
.bd-cap-5, .bd-cap-8, .bd-cap-10 { overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--bb-border-strong) transparent; }
.bd-cap-5::-webkit-scrollbar, .bd-cap-8::-webkit-scrollbar, .bd-cap-10::-webkit-scrollbar { width: var(--bb-space-6); }
.bd-cap-5::-webkit-scrollbar-thumb, .bd-cap-8::-webkit-scrollbar-thumb, .bd-cap-10::-webkit-scrollbar-thumb { background: var(--bb-border-strong); border-radius: var(--bb-radius-full); }
.bd-cap-5::-webkit-scrollbar-track, .bd-cap-8::-webkit-scrollbar-track, .bd-cap-10::-webkit-scrollbar-track { background: transparent; }
.bd-row { display: flex; align-items: center; gap: var(--bb-space-12); min-height: var(--bd-row-h); padding: var(--bb-space-8) 0; border-top: 1px solid var(--bb-border); }
.bd-row:first-child { border-top: 0; }
.bd-row-rank { display: flex; flex: 0 0 var(--bb-space-20); align-items: center; justify-content: center; width: var(--bb-space-20); height: var(--bb-space-20); border-radius: var(--bb-radius-sm); background: var(--bb-surface-raised); font-size: var(--bb-text-xs); font-weight: 700; color: var(--bb-text-muted); }
.bd-row:first-child .bd-row-rank { background: var(--bb-primary-tint); color: var(--bb-primary-text); }
.bd-row-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.bd-row-title { overflow: hidden; font-size: var(--bb-text-base); font-weight: 600; line-height: var(--bb-leading-normal); color: var(--bb-text); text-overflow: ellipsis; white-space: nowrap; }
a.bd-row-title:hover { color: var(--bb-text); text-decoration: underline; }
.bd-row-sub { overflow: hidden; font-size: var(--bb-text-sm); color: var(--bb-text-muted); text-overflow: ellipsis; white-space: nowrap; }
.bd-row-value { flex: 0 0 auto; font-size: var(--bb-text-base); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; color: var(--bb-text); }
.bd-row-value.is-missing { color: var(--bb-text-faint); }
.bd-row-extra { display: flex; flex: 0 0 auto; align-items: center; gap: var(--bb-space-8); }
.bd-row.is-zero .bd-row-title, .bd-row.is-zero .bd-row-value { color: var(--bb-text-faint); }

/* ---- bars: SVG rects sized by attributes, so no inline style ---- */
.bd-bars { display: flex; flex-direction: column; gap: var(--bb-space-16); }
.bd-bar-line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--bb-space-12); margin-bottom: var(--bb-space-6); font-size: var(--bb-text-base); }
.bd-bar-label { min-width: 0; overflow: hidden; color: var(--bb-text-body); text-overflow: ellipsis; white-space: nowrap; }
a.bd-bar-label:hover { color: var(--bb-text); text-decoration: underline; }
.bd-bar-value, .bd-legend-value { flex: 0 0 auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bb-text); }
.bd-track { height: var(--bb-space-8); overflow: hidden; background: var(--bb-surface-hover); border-radius: var(--bb-radius-full); }
.bd-track-tall { height: var(--bb-space-12); }
.bd-track svg { display: block; width: 100%; height: 100%; }
.bd-fill { fill: var(--bb-chart-main); }
.bd-fill.is-muted { fill: var(--bb-chart-muted); }
.bd-bars-stacked { display: flex; flex-direction: column; gap: var(--bb-space-12); }
.bd-seg { stroke: var(--bb-surface); stroke-width: 1; vector-effect: non-scaling-stroke; }
.bd-seg-1 { fill: var(--bb-chart-main); background: var(--bb-chart-main); }
.bd-seg-2 { fill: var(--bb-text-body); background: var(--bb-text-body); }
.bd-seg-3 { fill: var(--bb-text-faint); background: var(--bb-text-faint); }
.bd-seg-4 { fill: var(--bb-border-darker); background: var(--bb-border-darker); }
.bd-seg-5 { fill: var(--bb-border-strong); background: var(--bb-border-strong); }
.bd-seg-6 { fill: var(--bb-border); background: var(--bb-border); }
.bd-legend { display: flex; flex-direction: column; gap: var(--bb-space-8); margin: 0; padding: 0; list-style: none; font-size: var(--bb-text-base); }
.bd-legend-item { display: flex; align-items: center; gap: var(--bb-space-8); }
.bd-swatch { flex: 0 0 var(--bb-space-8); width: var(--bb-space-8); height: var(--bb-space-8); border-radius: var(--bb-radius-sm); }
.bd-legend-label { flex: 1; min-width: 0; overflow: hidden; color: var(--bb-text-body); text-overflow: ellipsis; white-space: nowrap; }

/* ---- finding, note, summary figures, chart box ---- */
.bd-finding { margin: 0; font-size: var(--bb-text-lg); font-weight: 500; line-height: var(--bb-leading-normal); color: var(--bb-text); }
.bd-finding:empty { display: none; }
.bd-note { margin: 0; font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bd-note[hidden] { display: none; }
.bd-note-more { margin-top: var(--bb-space-12); }
.bd-note a { color: var(--bb-text-strong); font-weight: 600; }
.bd-figs { display: flex; flex-wrap: wrap; gap: var(--bb-space-8) var(--bb-space-32); margin: 0 0 var(--bb-space-16); }
.bd-fig { display: flex; flex-direction: column; gap: var(--bb-space-2); min-width: 0; }
.bd-fig-label { font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bd-fig-value { font-size: var(--bb-text-xl); font-weight: 600; line-height: var(--bb-leading-tight); color: var(--bb-text); font-variant-numeric: tabular-nums; }
.bd-fig-value:empty::after { content: "—"; color: var(--bb-text-faint); }
.bd-chart { position: relative; flex: 1 1 auto; min-width: 0; min-height: calc(var(--bb-space-64) * 3); }
@media (max-width: 639px) { .bd-chart { min-height: calc(var(--bb-space-64) * 2 + var(--bb-space-32)); } }
.bd-chart .highcharts-container { position: absolute !important; inset: 0; }
.bd-chart > .bd-empty, .bd-chart > .bd-error, .bd-chart > .bd-skel-wrap { position: absolute; inset: 0; justify-content: center; }

/* ---- filter bar ---- */
.bd-filterbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--bb-space-8) var(--bb-space-16); }
.bd-filter-note { margin: 0; font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bd-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8) var(--bb-space-12); margin: 0; }
.bd-presets { display: inline-flex; flex-wrap: nowrap; gap: var(--bb-space-2); padding: var(--bb-space-2); background: var(--bb-surface-raised); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-md); }
body .bd-presets .bd-preset { height: var(--bb-space-32); border-color: transparent; background: transparent; color: var(--bb-text-muted) !important; }
body .bd-presets .bd-preset:hover { color: var(--bb-text) !important; }
body .bd-presets .bd-preset[aria-pressed="true"] { background: var(--bb-surface); border-color: transparent; color: var(--bb-text) !important; box-shadow: var(--bb-shadow-xs); }
@media (max-width: 639px) {
    .bd-presets { overflow-x: auto; max-width: 100%; }
    /* nothing in a hero or a card header may be wider than the screen: let the buttons wrap or scroll inside their own row */
    .bd-hero, .bd-hero-inner, .bd-hero-titles, .bd-hero-controls, .bd-filters { min-width: 0; max-width: 100%; }
    .bd-card-head { flex-wrap: wrap; }
    .bd-card-actions { flex: 1 1 100%; min-width: 0; max-width: 100%; }
}
.bd-custom { display: flex; flex-wrap: wrap; gap: var(--bb-space-8); }
.bd-field { display: inline-flex; align-items: center; gap: var(--bb-space-6); margin: 0; font-weight: 400; }
.bd-field-label { font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bd-input { height: var(--bb-space-32); padding: 0 var(--bb-space-12); border: 1px solid var(--bb-border-strong); border-radius: var(--bb-radius-md); background: var(--bb-surface); color: var(--bb-text); font-family: inherit; font-size: var(--bb-text-sm); }
.bd-input:focus { outline: none; border-color: var(--bb-primary); box-shadow: var(--bb-ring); }
@media (max-width: 639px) { .bd-field-loc, .bd-field-loc .bd-input { width: 100%; } }

@media print { .bd-filters { display: none !important; } .bd-card, .bd-stats { break-inside: avoid; } }
