/* ============================================================
   flow-ui.css - the single stylesheet for the Batches redesign.
   Sections, in order: THEME, COMPONENTS, BRANDSYNC HOST FIXES,
   BRANDSYNC COMPONENT HOOKS, PAGE.
   Rules:
   - Hex colours ONLY in THEME, as --fl-* custom properties (designer values).
   - COMPONENTS and PAGE use only var(--fl-*) for colours.
   - --bs-* declarations ONLY in the BRANDSYNC COMPONENT HOOKS block, scoped
     under ".fl-page <bs-element>", with values from --fl-* aliases.
   - Every selector starts with ".fl-" or ".fl-page " (approved exceptions:
     ":root" in THEME and "html:has(.fl-page) body").
   - No !important.
   ============================================================ */

/* ============================================================
   THEME
   ============================================================ */
:root {
    /* Typography */
    --fl-font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    --fl-h1-size: 24px; /* 28px from 640px, see media block */
    --fl-h1-line-height: 30px; /* 35px from 640px */
    --fl-h1-letter-spacing: -0.025em;
    --fl-weight-strong: var(--bs-font-weight-semibold);
    --fl-body-sm-size: var(--bs-text-style-body-sm-size);
    --fl-body-sm-weight: var(--bs-text-style-body-sm-weight);
    --fl-body-sm-line-height: var(--bs-text-style-body-sm-line-height);
    --fl-label-md-size: var(--bs-text-style-label-md-size);
    --fl-label-md-weight: var(--bs-text-style-label-md-weight);
    --fl-caption-size: var(--bs-text-style-caption-size);
    --fl-cell-primary-line-height: 18px;
    --fl-cell-secondary-line-height: 14px;
    --fl-font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; /* batch ids; same stack as app.css, kept here so the flow layer does not depend on app.css */
    --fl-batch-name-max-width: 30rem; /* cap of the file name in the Batch cell; longer names are cut with an ellipsis */

    /* Colours - designer values (measured from the prototype) */
    --fl-surface-shell: #f7f8fa; /* designer value */
    --fl-surface-page: #f7f8fa; /* designer value */
    --fl-surface-card: #ffffff; /* designer value */
    --fl-surface-table-head: #eef0f5; /* designer value */
    --fl-surface-row-hover: #eef0f5; /* designer value */
    --fl-border-default: #e5e5e5; /* designer value */
    --fl-text-default: #1a1a1a; /* designer value */
    --fl-text-secondary: #5c5c5c; /* designer value */
    --fl-icon-default: #474747; /* designer value */
    --fl-icon-muted: #707070; /* designer value */
    --fl-primary: #1d5fd1; /* designer value */
    --fl-primary-hover: #174fb0; /* designer value */
    --fl-primary-pressed: #123f8e; /* designer value */
    --fl-focus-ring: #111111; /* designer value */
    --fl-badge-bg: #f2f2f2; /* designer value */
    --fl-badge-bg-selected: #edf0fa; /* designer value */
    --fl-action-bg: transparent;
    --fl-action-hover-bg: #f2f2f2; /* designer value */
    --fl-action-pressed-bg: #e5e5e5; /* designer value */
    --fl-chip-neutral-bg: #f2f2f2; /* designer value */
    --fl-chip-neutral-text: #1a1a1a; /* designer value */
    --fl-chip-info-bg: #edf0fa; /* designer value */
    --fl-chip-info-text: #00518c; /* designer value */
    --fl-chip-success-bg: #e5f5e9; /* designer value */
    --fl-chip-success-text: #0d5a3f; /* designer value */
    --fl-chip-warning-bg: #ffefdb; /* designer value */
    --fl-chip-warning-text: #664700; /* designer value */
    --fl-chip-error-bg: #fcecea; /* designer value */
    --fl-chip-error-text: #961c1f; /* designer value */
    --fl-text-error: var(--bs-text-error);
    --fl-surface-error: var(--bs-surface-error);

    /* Spacing and shape */
    --fl-space-200: var(--bs-spacing-200);
    --fl-space-300: var(--bs-spacing-300);
    --fl-gap-xs: var(--bs-spacing-50);
    --fl-gap-sm: var(--bs-spacing-100);
    --fl-radius-card: 12px;
    --fl-radius-control: 8px;

    /* Page frame. Pixel max-widths are used on purpose: no BrandSync token exists for
       max-width, and Flow sets font-size on html so rem would drift. */
    --fl-page-gutter: var(--bs-spacing-300); /* 24px side padding at ALL widths, as in the prototype */
    --fl-page-pad-y: var(--bs-spacing-300); /* 24px top/bottom below 640px */
    --fl-page-max-width: 1280px;

    /* Table */
    --fl-cell-pad-y: var(--bs-spacing-100); /* 8px */
    --fl-cell-pad-x: var(--bs-spacing-150); /* 12px */
    --fl-row-height: 48px; /* header row only; resolves to about 48.5px with border-collapse */
    --fl-col-check: var(--bs-spacing-600); /* 48px */
    --fl-empty-pad-y: var(--bs-spacing-500);
    --fl-empty-pad-x: var(--bs-spacing-300);

    /* Tab badge (plain element, registry P06) */
    --fl-badge-height: 24px;
    --fl-badge-min-width: 20px;
    --fl-badge-pad-x: var(--bs-spacing-100);
    --fl-badge-size: 12px;
    --fl-badge-weight: 500;
    --fl-badge-line-height: 16px;

    /* Status chip */
    --fl-chip-pad-start: var(--bs-spacing-100); /* 8px */
    --fl-chip-pad-end: var(--bs-spacing-150); /* 12px */
    --fl-chip-gap: 6px;
    --fl-chip-line-height: 20; /* unitless: BrandSync multiplies by 1px */

    /* Tab separator (bs-divider) */
    --fl-divider-thickness: 1px;
    --fl-divider-inset: 0;

    /* Row action buttons */
    --fl-action-size: 32px;
    --fl-action-icon: 16px;
    --fl-action-pad: 0; /* 1px border + centred 16px icon fits 32px; padding 8px would squeeze the icon */

    /* Checkbox placeholder */
    --fl-checkbox-border-width: 2px;
    --fl-checkbox-gap: 0; /* no label, so no gap after the box (host = 20px box only) */

    /* Filter bar, search field, filter triggers, date field */
    --fl-input-border-hover: #c1c1c1; /* designer value: 60% #e5e5e5 + 40% #8a8a8a */
    --fl-filter-height: 32px;
    --fl-filter-gap: 12px;
    --fl-list-gap: 16px;
    --fl-search-width: 240px;
    --fl-date-width: 144px;
    --fl-menu-width: 224px; /* filter menu popup width */
    --fl-menu-item-pad-y: var(--bs-spacing-150); /* 12px */
    --fl-menu-item-pad-x: var(--bs-spacing-200); /* 16px */
    --fl-menu-item-line-height: 21; /* unitless: bs-menu-item multiplies it by 1px */
    --fl-menu-selected-color: var(--fl-primary); /* label colour of the selected menu item */
    --fl-menu-selected-weight: 600; /* label weight of the selected menu item */
    --fl-page-size-width: 80px; /* rows-per-page select in the table footer */
    --fl-upload-list-max-height: 240px; /* scroll area of the selected files in the upload dialog */
    --fl-input-pad-x: var(--bs-spacing-150); /* 12px */
    --fl-input-pad-y: var(--bs-spacing-50); /* 4px */
    --fl-input-gap: var(--bs-spacing-100); /* 8px */
    --fl-input-icon-size: 16px;
    --fl-filter-pad-x: var(--bs-spacing-150); /* 12px */

    /* Selection bar above the table */
    --fl-surface-selected: var(--fl-badge-bg-selected); /* selection bar background */
    --fl-selection-bar-pad-y: var(--bs-spacing-100); /* 8px */
    --fl-selection-bar-pad-x: var(--bs-spacing-200); /* 16px */
    --fl-selection-bar-gap: var(--bs-spacing-150); /* 12px */
    --fl-selection-count-weight: 600;
}

@media (min-width: 640px) {
    :root {
        --fl-h1-size: 28px;
        --fl-h1-line-height: 35px;
        --fl-page-pad-y: var(--bs-spacing-400); /* 32px */
    }
}

@media (min-width: 1920px) {
    :root {
        --fl-page-max-width: 1536px;
    }
}

@media (min-width: 2560px) {
    :root {
        --fl-page-max-width: 1920px;
    }
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* LAYOUT: page frame used by Components/Layout/FlowUiLayout.razor */
.fl-shell {
    box-sizing: border-box;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--fl-surface-shell);
}

.fl-shell__main {
    box-sizing: border-box;
    flex: 1 1 0%;
    display: flex;
    justify-content: center;
    padding: var(--fl-page-pad-y) var(--fl-page-gutter);
}

.fl-shell__container {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--fl-page-max-width);
}

.fl-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--fl-space-200);
}

.fl-page-header__text {
    display: flex;
    flex-direction: column;
    gap: var(--fl-gap-xs);
}

/* Set explicitly: app.css has global h1 rules. */
.fl-page-header__title {
    margin: 0;
    font-size: var(--fl-h1-size);
    font-weight: var(--fl-weight-strong);
    line-height: var(--fl-h1-line-height);
    letter-spacing: var(--fl-h1-letter-spacing);
    color: var(--fl-text-default);
}

.fl-page-header__subtitle {
    margin: 0;
    font-size: var(--fl-body-sm-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-text-secondary);
}

.fl-page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--fl-gap-sm);
}

/* TABS: bs-tabs on top, a 1px separator directly below (48 + 1 = 49px) */
.fl-tab-bar {
    display: flex;
    flex-direction: column;
}

.fl-tab-bar bs-tabs {
    align-self: flex-start;
}

.fl-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: var(--fl-badge-height);
    min-width: var(--fl-badge-min-width);
    padding: 0 var(--fl-badge-pad-x);
    border-radius: var(--fl-radius-control);
    font-size: var(--fl-badge-size);
    font-weight: var(--fl-badge-weight);
    line-height: var(--fl-badge-line-height);
    font-variant-numeric: tabular-nums;
    color: var(--fl-text-default);
    background: var(--fl-badge-bg);
}

.fl-tab-badge--selected {
    background: var(--fl-badge-bg-selected);
}

/* DATA TABLE: semantic table styled with the designer palette (registry P05) */
.fl-table-card {
    box-sizing: border-box;
    background: var(--fl-surface-card);
    border-radius: var(--fl-radius-card);
    overflow-x: auto;
}

.fl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fl-body-sm-size);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-text-default);
}

.fl-table th,
.fl-table td {
    box-sizing: border-box;
    padding: var(--fl-cell-pad-y) var(--fl-cell-pad-x);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
    border-bottom: 1px solid var(--fl-border-default);
}

/* Only the header gets a forced height; body rows take their natural height (8 + 32 + 8 + line). */
.fl-table th {
    height: var(--fl-row-height);
    background: var(--fl-surface-table-head);
    color: var(--fl-text-secondary);
    font-size: var(--fl-label-md-size);
    font-weight: var(--fl-label-md-weight);
    line-height: var(--fl-body-sm-line-height);
}

.fl-table tbody tr:last-child td {
    border-bottom: 0;
}

.fl-table__row {
    transition: background 150ms ease;
}

.fl-table__row:hover {
    background: var(--fl-surface-row-hover);
}

.fl-table__col-check {
    width: var(--fl-col-check);
}

.fl-table__col-actions {
    width: 1%;
}

.fl-cell-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--fl-gap-sm);
}

.fl-table__sort {
    display: inline-flex;
    align-items: center;
    margin-left: var(--fl-gap-xs);
    color: var(--fl-icon-muted);
    vertical-align: middle;
}

.fl-table__sort--active {
    color: var(--fl-text-secondary);
}

/* A native button is the sortable header; the ascending state rotates the caret-down icon. */
.fl-table__sort-button {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.fl-table__sort-button:hover {
    color: var(--fl-text-default);
}

.fl-table__sort-button:focus-visible {
    outline: 2px solid var(--fl-focus-ring);
    outline-offset: 2px;
}

.fl-table__sort--asc svg {
    transform: rotate(180deg);
}

/* Info hint next to a column header: the wrapper resets the inherited header text rules, because the tooltip bubble inherits them through the shadow DOM (the header is nowrap and medium weight). */
.fl-info-hint {
    margin-left: var(--fl-gap-xs);
    vertical-align: middle;
    white-space: normal;
    font-weight: var(--fl-body-sm-weight);
    text-align: left;
}

.fl-info-hint__button {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--fl-icon-muted);
    cursor: help;
}

.fl-info-hint__button:hover {
    color: var(--fl-text-default);
}

.fl-info-hint__button:focus-visible {
    outline: 2px solid var(--fl-focus-ring);
    outline-offset: 2px;
}

.fl-cell-identity {
    display: inline-flex;
    align-items: center;
    gap: var(--fl-gap-sm);
}

.fl-cell-identity > svg {
    flex-shrink: 0;
    color: var(--fl-icon-default);
}

.fl-cell-stack {
    display: inline-flex;
    flex-direction: column;
    gap: var(--bs-spacing-75);
}

.fl-cell-stack__primary {
    font-weight: var(--fl-weight-strong);
    line-height: var(--fl-cell-primary-line-height);
    color: var(--fl-text-default);
}

.fl-cell-stack__secondary {
    font-size: var(--fl-caption-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-cell-secondary-line-height);
    color: var(--fl-text-secondary);
}

/* Batch cell: ID text + copy button on one line. The wrapper keeps the line's own height so the
   taller button overflows equally above and below instead of growing the row. */
.fl-cell-copyable {
    display: flex;
    align-items: center;
    gap: var(--bs-spacing-50);
}

.fl-cell-stack__primary.fl-cell-copyable {
    height: var(--fl-cell-primary-line-height);
}

.fl-cell-stack__secondary.fl-cell-copyable {
    height: var(--fl-cell-secondary-line-height);
}

/* Batch cell: the file name text is capped and cut with an ellipsis (text-overflow needs its own block; the line is a flex row, so the text gets a wrapper with min-width 0). The copy button never shrinks, and the id is shown in a monospace font so every id has the same width and the copy icons line up down the column. */
.fl-cell-stack__text {
    min-width: 0;
    max-width: var(--fl-batch-name-max-width);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fl-cell-stack__id {
    font-family: var(--fl-font-mono);
}

.fl-cell-copyable > bs-icon-button {
    flex-shrink: 0;
}

/* 20px button, 14px icon. Higher specificity than ".fl-page bs-icon-button" (0,1,1) so the
   Actions-column buttons keep their 32px sizing. Padding 0: the host is a border-box flex
   container that centres its one slotted icon, so the icon is centred without padding. */
.fl-page bs-icon-button.fl-copy-button {
    --bs-icon-button-size-sm: 20px;
    --bs-icon-button-icon-size-sm: 14px;
    --bs-icon-button-padding: 0;
    --bs-icon-button-radius: var(--bs-border-radius-50);
}

.fl-cell-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--fl-gap-sm);
    color: var(--fl-text-default);
}

.fl-cell-inline > svg {
    color: var(--fl-text-secondary);
}

.fl-table__empty {
    margin: 0;
    padding: var(--fl-empty-pad-y) var(--fl-empty-pad-x);
    text-align: center;
    color: var(--fl-text-secondary);
}

/* Footer under the table: range text on the left, bs-pagination on the right. The gap below the
   table comes from ".fl-list" (flex column, --fl-list-gap). */
.fl-table-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--fl-filter-gap);
}

.fl-table-footer__range {
    margin: 0;
    font-size: var(--fl-body-sm-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-text-secondary);
}

.fl-table-footer__start {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--fl-list-gap);
}

.fl-selection-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--fl-selection-bar-gap);
    padding: var(--fl-selection-bar-pad-y) var(--fl-selection-bar-pad-x);
    background: var(--fl-surface-selected);
    border: 1px solid var(--fl-border-default);
    border-radius: var(--fl-radius-control);
}

.fl-selection-bar__count {
    margin: 0;
    font-size: var(--fl-body-sm-size);
    line-height: var(--fl-body-sm-line-height);
    font-weight: var(--fl-selection-count-weight);
    color: var(--fl-text-default);
}

.fl-page-size {
    display: flex;
    align-items: center;
    gap: var(--fl-input-gap);
}

.fl-page-size__label {
    margin: 0;
    white-space: nowrap;
    font-size: var(--fl-body-sm-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-text-secondary);
}

.fl-page-size__field {
    flex: 0 0 auto;
    width: var(--fl-page-size-width);
}

/* UPLOAD DIALOG: bs-dialog is the last child of ".fl-page" (a flex column with a gap). "display: contents"
   keeps its empty host from taking a row; BrandSync draws the open dialog itself, fixed to the viewport. */
.fl-upload-dialog {
    display: contents;
}

.fl-upload-dialog__body {
    display: flex;
    flex-direction: column;
    gap: var(--fl-list-gap);
}

.fl-upload-dialog__description {
    margin: 0;
    font-size: var(--fl-body-sm-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-text-secondary);
}

.fl-upload-dialog__notices {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--fl-input-gap);
    font-size: var(--fl-body-sm-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-chip-error-text);
}

.fl-upload-dialog__footer {
    display: flex;
    width: 100%;
}

.fl-upload-dialog__submit {
    flex: 1 1 auto;
}

.fl-upload-files {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--fl-input-gap);
    max-height: var(--fl-upload-list-max-height);
    overflow-y: auto;
}

.fl-upload-file {
    display: flex;
    align-items: center;
    gap: var(--fl-filter-gap);
    padding: var(--fl-input-gap) var(--fl-filter-gap);
    border: 1px solid var(--fl-border-default);
    border-radius: var(--fl-radius-control);
    background: var(--fl-surface-card);
}

.fl-upload-file__icon {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--fl-icon-muted);
}

.fl-upload-file__text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.fl-upload-file__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fl-body-sm-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-body-sm-line-height);
    color: var(--fl-text-default);
}

.fl-upload-file__meta {
    font-size: var(--fl-caption-size);
    font-weight: var(--fl-body-sm-weight);
    line-height: var(--fl-cell-secondary-line-height);
    color: var(--fl-text-secondary);
}

.fl-upload-file__status {
    display: inline-flex;
    flex: 0 0 auto;
}

.fl-upload-file--uploaded .fl-upload-file__status {
    color: var(--fl-chip-success-text);
}

.fl-upload-file--failed .fl-upload-file__status,
.fl-upload-file--failed .fl-upload-file__meta {
    color: var(--fl-chip-error-text);
}

.fl-state {
    padding: var(--fl-cell-pad-x);
    color: var(--fl-text-secondary);
}

.fl-state--error {
    background: var(--fl-surface-error);
    color: var(--fl-text-error);
    border-radius: var(--fl-radius-card);
}

.fl-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* LIST: filter bar above the table */
.fl-list {
    display: flex;
    flex-direction: column;
    gap: var(--fl-list-gap);
}

.fl-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--fl-filter-gap);
}

.fl-search-field {
    flex: 0 0 auto;
    width: var(--fl-search-width);
}

.fl-date-field {
    flex: 0 0 auto;
    width: var(--fl-date-width);
}

.fl-filter-trigger__label {
    color: var(--fl-text-secondary);
    font-weight: var(--fl-body-sm-weight);
}

.fl-filter-trigger__value {
    color: var(--fl-text-default);
    font-weight: var(--fl-label-md-weight);
}

@media (max-width: 767px) {
    .fl-filter-bar > .fl-search-field {
        flex: 1 1 100%;
        width: 100%;
    }
}

/* ------------------------------------------------------------
   BRANDSYNC HOST FIXES
   Selectors in this block must start with ".fl-page ".
   ------------------------------------------------------------ */
/* Avoid an unstyled flash while the custom element upgrades after prerender. */
.fl-page bs-button:not(:defined) {
    visibility: hidden;
}

.fl-page bs-tabs:not(:defined),
.fl-page bs-chip-informative:not(:defined),
.fl-page bs-icon-button:not(:defined),
.fl-page bs-checkbox:not(:defined) {
    visibility: hidden;
}

/* Keep the separator's 1px height reserved before bs-divider upgrades, so the layout does not jump. */
.fl-page bs-divider:not(:defined) {
    display: block;
    min-height: var(--fl-divider-thickness);
    visibility: hidden;
}

/* Before bs-tooltip-trigger upgrades, hide the slotted info button so it does not flash unstyled. */
.fl-page bs-tooltip-trigger:not(:defined) {
    visibility: hidden;
}

/* Same for the filter bar controls: reserve the 32px height until they upgrade. */
.fl-page bs-input:not(:defined),
.fl-page bs-button.fl-filter-trigger:not(:defined) {
    display: block;
    min-height: var(--fl-filter-height);
    visibility: hidden;
}

/* Before bs-popover upgrades, its slotted menu would show as plain text. */
.fl-page bs-popover.fl-filter-menu:not(:defined) {
    display: inline-block;
    min-height: var(--fl-filter-height);
}

.fl-page bs-popover.fl-filter-menu:not(:defined) > bs-menu {
    display: none;
}

/* Before bs-popover upgrades, its slotted panel would show as plain content. */
.fl-page bs-popover.fl-filter-date:not(:defined) {
    display: inline-block;
    min-height: var(--fl-filter-height);
}

.fl-page bs-popover.fl-filter-date:not(:defined) > .fl-filter-date__panel {
    display: none;
}

/* Documented parts. bs-input "control" is the inner input (its font size is 16px with no hook). */
.fl-page bs-input::part(control) {
    font-size: var(--fl-body-sm-size);
}

/* bs-input has no aria-label prop: its "label" prop names the inner input, so the label is
   hidden visually (not display:none) through its documented "label" part. The rows-per-page
   select in the Batches footer also keeps its label as the accessible name only. */
.fl-page .fl-filter-bar bs-input::part(label),
.fl-page .fl-page-size bs-input::part(label) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Upload dropzone: a click anywhere on it opens the file picker (see batchUpload.enableClickToBrowse in app.js).
   The Browse button is hidden visually from the first paint (so it never flashes) but stays focusable and keeps
   its accessible name (its button-label). The pointer and focus rules apply once the click-through is attached
   (data-fl-clickable). Workaround: bs-file-upload has no prop to hide the button or make the dropzone clickable. */
.fl-page .fl-upload-dropzone[data-fl-clickable]::part(dropzone) {
    cursor: pointer;
}

.fl-page .fl-upload-dropzone[data-fl-clickable][disabled]::part(dropzone) {
    cursor: default;
}

.fl-page .fl-upload-dropzone::part(browse) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.fl-page .fl-upload-dropzone[data-fl-clickable]:focus-within::part(dropzone) {
    outline: 2px solid var(--fl-focus-ring);
    outline-offset: 2px;
}

/* The outlined bs-button is transparent: the host paints the card colour and the radius. */
.fl-page bs-button.fl-filter-trigger {
    background: var(--fl-surface-card);
    border-radius: var(--fl-radius-control);
}

/* Designer gap between value and caret (component default is 4px). */
.fl-page bs-button.fl-filter-trigger::part(end-icon) {
    margin-inline-start: var(--fl-input-gap);
}

/* Slotted icons of the filter controls use the muted icon colour. */
.fl-page bs-button.fl-filter-trigger svg,
.fl-page bs-input svg {
    color: var(--fl-icon-muted);
}

/* Flow's global "*{padding:0}" (app.css) beats the chip's :host padding, so set it again. */
.fl-page bs-chip-informative {
    padding-inline-start: var(--fl-chip-pad-start);
    padding-inline-end: var(--fl-chip-pad-end);
    border-radius: var(--fl-radius-control);
}

/* Slotted icons are light-DOM content: colour them here (the inner button colour does not reach them). */
.fl-page bs-icon-button svg {
    color: var(--fl-icon-default);
}

/* ------------------------------------------------------------
   BRANDSYNC COMPONENT HOOKS
   The only place that declares --bs-* properties. Always scoped under ".fl-page <bs-element>".
   ------------------------------------------------------------ */
/* Primary palette on the host, same override as the prototype. */
.fl-page bs-button {
    --bs-color-primary-default: var(--fl-primary);
    --bs-color-primary-hover: var(--fl-primary-hover);
    --bs-color-primary-pressed: var(--fl-primary-pressed);
    --bs-border-primary-focus: var(--fl-primary);
}

.fl-page bs-tabs,
.fl-page bs-tab {
    --bs-color-primary-default: var(--fl-primary);
    --bs-color-primary-hover: var(--fl-primary-hover);
    --bs-color-primary-pressed: var(--fl-primary-pressed);
}

.fl-page bs-tab {
    --bs-tab-color-default: var(--fl-text-secondary);
    --bs-tab-color-hover: var(--fl-text-default);
    --bs-tab-indicator-hover: var(--fl-icon-muted);
    --bs-tab-focus-ring-color: var(--fl-focus-ring);
}

.fl-page bs-chip-informative {
    --bs-chip-bg-neutral-container: var(--fl-chip-neutral-bg);
    --bs-chip-text-neutral: var(--fl-chip-neutral-text);
    --bs-chip-bg-info-container: var(--fl-chip-info-bg);
    --bs-chip-text-info: var(--fl-chip-info-text);
    --bs-chip-bg-success-container: var(--fl-chip-success-bg);
    --bs-chip-text-success: var(--fl-chip-success-text);
    --bs-chip-bg-warning-container: var(--fl-chip-warning-bg);
    --bs-chip-text-warning: var(--fl-chip-warning-text);
    --bs-chip-bg-error-container: var(--fl-chip-error-bg);
    --bs-chip-text-error: var(--fl-chip-error-text);
    --bs-chip-informative-gap: var(--fl-chip-gap);
    --bs-chip-informative-line-height: var(--fl-chip-line-height);
}

.fl-page bs-icon-button {
    --bs-icon-button-size-sm: var(--fl-action-size);
    --bs-icon-button-icon-size-sm: var(--fl-action-icon);
    --bs-icon-button-padding: var(--fl-action-pad);
    --bs-icon-button-radius: var(--fl-radius-control);
    --bs-icon-button-neutral-container: var(--fl-action-bg);
    --bs-icon-button-neutral-border: var(--fl-border-default);
    --bs-icon-button-neutral-hover: var(--fl-action-hover-bg);
    --bs-icon-button-neutral-pressed: var(--fl-action-pressed-bg);
    --bs-icon-button-neutral-border-hover: var(--fl-border-default);
    --bs-icon-button-neutral-border-pressed: var(--fl-border-default);
}

.fl-page bs-divider {
    --bs-divider-thickness: var(--fl-divider-thickness);
    --bs-divider-color: var(--fl-border-default);
    --bs-divider-inset: var(--fl-divider-inset);
}

.fl-page bs-checkbox {
    --bs-checkbox-border-width-md: var(--fl-checkbox-border-width);
    --bs-checkbox-gap: var(--fl-checkbox-gap);
}

.fl-page bs-input {
    --bs-input-height: var(--fl-filter-height);
    --bs-input-icon-size: var(--fl-input-icon-size);
    --bs-input-padding-x: var(--fl-input-pad-x);
    --bs-input-padding-y: var(--fl-input-pad-y);
    --bs-input-gap: var(--fl-input-gap);
    --bs-input-radius: var(--fl-radius-control);
    --bs-input-field-bg: var(--fl-surface-card);
    --bs-input-field-border: var(--fl-border-default);
    --bs-input-field-border-hover: var(--fl-input-border-hover);
    --bs-input-field-border-focus: var(--fl-focus-ring);
    --bs-input-field-text: var(--fl-text-default);
    --bs-input-field-placeholder: var(--fl-text-secondary);
    --bs-input-icon-color: var(--fl-icon-muted);
}

/* BrandSync default is 44px (Figma); reduced to 40px to match the density of the Batches table. */
.fl-page bs-pagination {
    --bs-pagination-size: var(--bs-spacing-500);
}

.fl-page bs-button.fl-filter-trigger {
    --bs-button-height-sm: var(--fl-filter-height);
    --bs-button-padding-x-label-side: var(--fl-filter-pad-x);
    --bs-button-padding-x-icon-side: var(--fl-filter-pad-x);
    --bs-button-radius: var(--fl-radius-control);
    --bs-button-outlined-border: var(--fl-border-default);
    --bs-button-outlined-border-hover: var(--fl-border-default);
}

/* Filter menu (FilterMenu.razor). The stock bs-menu-item is 48px high with 16px muted text and no selected
   state; these hooks bring it to the Batches filter density. The focus ring is inset because the popup
   clips overflow. */
.fl-page bs-popover.fl-filter-menu {
    --bs-popover-bg: var(--fl-surface-card);
    --bs-popover-radius: var(--fl-radius-control);
    --bs-popover-shadow: none;
    --bs-popover-min-width: var(--fl-menu-width);
}

.fl-page bs-popover.fl-filter-menu::part(popup) {
    width: var(--fl-menu-width);
    border: 1px solid var(--fl-border-default);
    overflow: hidden;
}

.fl-page .fl-filter-menu bs-menu {
    --bs-menu-bg: transparent;
    --bs-menu-radius: 0;
    --bs-menu-padding-y: 0;
    --bs-menu-gap: 0;
    --bs-menu-shadow: none;
}

.fl-page .fl-filter-menu bs-menu-item {
    --bs-menu-item-radius: 0;
    --bs-menu-item-padding-y: var(--fl-menu-item-pad-y);
    --bs-menu-item-padding-x: var(--fl-menu-item-pad-x);
    --bs-menu-item-gap: var(--fl-input-gap);
    --bs-menu-item-color: var(--fl-text-default);
    --bs-menu-item-font-size: var(--fl-body-sm-size);
    --bs-menu-item-line-height: var(--fl-menu-item-line-height);
    --bs-menu-item-hover: var(--fl-surface-row-hover);
    --bs-menu-item-pressed: var(--fl-action-pressed-bg);
    --bs-menu-item-icon-color: var(--fl-icon-muted);
}

.fl-page .fl-filter-menu bs-menu-item::part(item) {
    height: auto;
    text-align: left;
}

.fl-page .fl-filter-menu bs-menu-item::part(item):focus-visible {
    outline: 2px solid var(--fl-focus-ring);
    outline-offset: -2px;
}

.fl-page .fl-filter-menu bs-menu-item::part(icon) {
    width: var(--fl-input-icon-size);
    height: var(--fl-input-icon-size);
}

.fl-page .fl-filter-menu bs-menu-item[data-selected]::part(label) {
    color: var(--fl-menu-selected-color);
    font-weight: var(--fl-menu-selected-weight);
}

/* Filter date (FilterDate.razor). The popover popup is made transparent so the panel paints the single
   surface (1px border, no shadow, like the filter menu), and the calendar's own card is flattened. Nothing
   here may use overflow hidden: the calendar's month/year list is positioned inside it. */
.fl-page bs-popover.fl-filter-date {
    --bs-popover-bg: transparent;
    --bs-popover-shadow: none;
    --bs-popover-radius: var(--fl-radius-card);
    --bs-popover-min-width: 0;
}

.fl-page .fl-filter-date__panel {
    background: var(--fl-surface-card);
    border: 1px solid var(--fl-border-default);
    border-radius: var(--fl-radius-card);
}

.fl-page .fl-filter-date bs-datepicker {
    --bs-datepicker-bg: transparent;
    --bs-datepicker-shadow: none;
    --bs-datepicker-radius: var(--fl-radius-card);
    --bs-datepicker-color: var(--fl-text-default);
    --bs-datepicker-color-muted: var(--fl-text-secondary);
    --bs-datepicker-color-weekday: var(--fl-text-secondary);
    --bs-datepicker-hover: var(--fl-surface-row-hover);
    --bs-datepicker-selected-bg: var(--fl-primary);
    --bs-datepicker-selected-bg-hover: var(--fl-primary-hover);
    --bs-datepicker-selected-bg-pressed: var(--fl-primary-pressed);
    --bs-datepicker-selected-bg-focus: var(--fl-primary-hover);
    --bs-datepicker-today-border: var(--fl-primary);
    --bs-datepicker-focus-ring-color: var(--fl-focus-ring);
}

.fl-page .fl-filter-date__footer {
    display: flex;
    justify-content: flex-end;
    padding: var(--fl-gap-sm) var(--fl-input-pad-x);
    border-top: 1px solid var(--fl-border-default);
}

.fl-page .fl-filter-date bs-button.fl-filter-date__clear {
    --bs-button-height-sm: var(--fl-filter-height);
    --bs-button-padding-x-sm: var(--fl-filter-pad-x);
    --bs-button-radius: var(--fl-radius-control);
    --bs-button-subtle-color: var(--fl-text-default);
    --bs-button-subtle-hover: var(--fl-action-hover-bg);
    --bs-button-subtle-pressed: var(--fl-action-pressed-bg);
    --bs-button-subtle-focus: var(--fl-focus-ring);
}

/* "Clear selection" is a subtle bs-button, hooked to the filter height like the date Clear button. */
.fl-page .fl-selection-bar bs-button {
    margin-inline-start: auto;
    --bs-button-height-sm: var(--fl-filter-height);
    --bs-button-padding-x-sm: var(--fl-filter-pad-x);
    --bs-button-radius: var(--fl-radius-control);
    --bs-button-subtle-color: var(--fl-primary);
    --bs-button-subtle-hover: var(--fl-action-hover-bg);
    --bs-button-subtle-pressed: var(--fl-action-pressed-bg);
    --bs-button-subtle-focus: var(--fl-focus-ring);
}

/* ============================================================
   PAGE
   ============================================================ */
.fl-page {
    font-family: var(--fl-font-family);
    color: var(--fl-text-default);
    display: flex;
    flex-direction: column;
    gap: var(--fl-space-300);
}

/* T01 dark mode deferred to theme ticket.
   Keeps the body light on this page when Flow's dark mode (html.dark) is active.
   Still needed for the root canvas/overscroll; the dark topbar remains until the theme ticket.
   The only selector in this file that does not start with ".fl-" (besides :root). */
html:has(.fl-page) body {
    background: var(--fl-surface-page);
}
