/*
 * Beam shared components — Stage 1.U S3.
 *
 * Gallery coverage index:
 * primary-btn, secondary-btn, tertiary-btn, icon-btn, link-btn, btn-primary, btn-tertiary,
 * field, field-affix, input-base, beam-select, beam-multi-select,
 * beam-checkbox, beam-radio, beam-toggle, segmented-control, toggle-chip,
 * beam-panel, beam-section, beam-table, beam-table-toolbar,
 * workspace, workflow-tabs,
 * beam-tooltip, tag-chip, meta-chip, summary-strip, beam-banner,
 * beam-modal, file-upload, file-upload-item, download-csv-button,
 * ag-theme-beam, beam-empty-state.
 */

.primary-btn,
.btn-primary,
.secondary-btn,
.btn-tertiary,
.tertiary-btn,
.download-csv-button {
    align-items: center;
    appearance: none;
    border-radius: var(--radius-button);
    box-sizing: border-box;
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: var(--body-small-font-size);
    font-weight: var(--headings-large-h5-font-weight);
    gap: var(--space-2);
    justify-content: center;
    line-height: var(--body-small-line-height);
    min-height: var(--control-height);
    padding: var(--control-pad-y) var(--control-pad-x);
    text-decoration: none;
    white-space: nowrap;
}

/* Primary is TEAL, everywhere (decision D-06).
   `.btn-primary` had two contradictory definitions: teal in buttons.css (Figma Buttons 2.0,
   `--primary-300`) and near-black here. This file is unlayered and loads after main.css, so the
   near-black won on every surface that links it — which is why site-setup.css:1984 carries a
   `button.btn-primary` specificity patch to force teal back, and why the three surfaces using the
   `.primary-btn` spelling (admin globals, site globals, ui-gallery) rendered near-black.
   Teal is the shipped brand action colour, so it wins and the near-black is retired. */
.primary-btn,
.btn-primary {
    background: var(--primary-300);
    border: 1px solid var(--primary-300);
    color: var(--corelight-100);
}

.secondary-btn,
.btn-tertiary,
.download-csv-button {
    background-color: var(--corelight-100);
    border: 1px solid var(--corelight-900);
    border-color: var(--corelight-900);
    color: var(--coredark-700);
}

/* Tertiary = the ghost/text tier the vocabulary was missing (standards §9). Transparent until
   hovered, no border, so it reads as clearly subordinate to the outlined secondary. Cancel in a
   modal footer and Back in a page action bar are the canonical uses. */
.tertiary-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--coredark-700);
}

.tertiary-btn:hover:not(:disabled) {
    background: var(--light-300);
}

.primary-btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.secondary-btn:hover:not(:disabled),
.btn-tertiary:hover:not(:disabled),
.download-csv-button:hover:not(:disabled) {
    background: var(--corelight-300);
}

/* Disabled is a MUTED TREATMENT, not a pale wash of the enabled colour (standards §9, S-02).
   `opacity: .45` over teal produced a pale mint that is indistinguishable from an idle-but-
   enabled Save — the audit measured exactly that confusion on the component modals and Add Site.
   A disabled control now reads as grey, so "can't press this" is legible without hovering, and
   the text keeps enough contrast to be read (the pale-teal-on-white combination failed §12). */
.primary-btn:disabled,
.btn-primary:disabled,
.secondary-btn:disabled,
.btn-tertiary:disabled,
.tertiary-btn:disabled,
.download-csv-button:disabled {
    background: var(--light-700);
    border-color: var(--light-700);
    color: var(--coredark-100);
    cursor: not-allowed;
    opacity: 1;
}

.primary-btn--compact,
.secondary-btn--compact,
.btn-primary--compact,
.btn-tertiary--compact,
.tertiary-btn--compact {
    min-height: var(--control-height-sm);
    padding-inline: var(--space-4);
}

.btn-icon {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    justify-content: center;
}

.icon-btn {
    align-items: center;
    appearance: none;
    background: var(--corelight-100);
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-button);
    color: var(--coredark-700);
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: var(--body-large-font-size);
    height: var(--control-height);
    justify-content: center;
    line-height: var(--body-large-line-height);
    padding: 0;
    width: var(--control-height);
}

.icon-btn--lg {
    height: calc(var(--control-height) + var(--space-2));
    width: calc(var(--control-height) + var(--space-2));
}

.icon-btn:hover:not(:disabled) {
    background: var(--corelight-300);
}

.link-btn {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--text-link);
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: var(--radius-xs);
}

.field {
    color: var(--coredark-700);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

.field > span:first-child,
.field__label {
    color: var(--coredark-700);
    font-size: var(--body-small-font-size);
    font-weight: var(--headings-large-h5-font-weight);
    line-height: var(--body-small-line-height);
}

.field-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--drawer-w) - var(--space-8))), 1fr));
}

.input-base,
.field input:not([type="checkbox"]):not([type="radio"]),
.field textarea,
.field select,
.beam-select {
    appearance: none;
    background: var(--corelight-100);
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-input);
    box-sizing: border-box;
    color: var(--coredark-700);
    font-family: inherit;
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
    min-height: var(--control-height);
    padding: var(--space-2) var(--space-3);
    width: 100%;
}

.field textarea {
    min-height: calc(var(--control-height) * 2);
    resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.input-base:focus,
.beam-select:focus {
    border-color: var(--text-link);
    box-shadow: 0 0 0 var(--radius-xs) var(--map-polygon-hover);
    outline: none;
}

.field-affix {
    align-items: stretch;
    display: flex;
    min-width: 0;
    position: relative;
}

.field-affix input {
    padding-right: calc(var(--space-8) + var(--space-4));
}

.field-affix__suffix,
.input-suffix,
.input-suffix-right {
    align-items: center;
    color: var(--text-secondary);
    display: inline-flex;
    font-size: var(--body-small-font-size);
    inset-block: 0;
    padding-inline: var(--space-3);
    pointer-events: none;
    position: absolute;
    right: 0;
}

.beam-select,
.field select {
    background-image: linear-gradient(45deg, transparent 50%, var(--coredark-700) 50%),
        linear-gradient(135deg, var(--coredark-700) 50%, transparent 50%);
    background-position: calc(100% - var(--space-4)) 50%,
        calc(100% - var(--space-3)) 50%;
    background-repeat: no-repeat;
    background-size: var(--space-1) var(--space-1),
        var(--space-1) var(--space-1);
    padding-right: var(--space-8);
}

.beam-checkbox,
.beam-radio {
    align-items: center;
    color: var(--coredark-700);
    display: inline-flex;
    font-size: var(--body-small-font-size);
    gap: var(--space-2);
    line-height: var(--body-small-line-height);
}

.beam-checkbox input,
.beam-radio input {
    accent-color: var(--coredark-700);
    height: var(--space-4);
    width: var(--space-4);
}

.beam-toggle {
    align-items: center;
    color: var(--coredark-700);
    cursor: pointer;
    display: inline-flex;
    font-size: var(--body-small-font-size);
    gap: var(--space-2);
}

.beam-toggle input {
    appearance: none;
    background: var(--corelight-900);
    border-radius: var(--control-height);
    cursor: pointer;
    height: var(--space-5);
    position: relative;
    width: calc(var(--space-8) + var(--space-2));
}

.beam-toggle input::after {
    background: var(--corelight-100);
    border-radius: 50%;
    content: "";
    height: calc(var(--space-4) - var(--radius-xs));
    left: var(--radius-xs);
    position: absolute;
    top: var(--radius-xs);
    transition: transform 120ms ease;
    width: calc(var(--space-4) - var(--radius-xs));
}

.beam-toggle input:checked {
    background: var(--coredark-700);
}

.beam-toggle input:checked::after {
    transform: translateX(var(--space-5));
}

.segmented-control,
.beam-multi-select__trigger-row {
    align-items: center;
    background: var(--corelight-100);
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-md);
    display: inline-flex;
    overflow: hidden;
}

.segmented-control__button {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--coredark-700);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--body-small-font-size);
    font-weight: var(--headings-large-h5-font-weight);
    line-height: var(--body-small-line-height);
    min-height: var(--control-height-sm);
    padding: var(--space-2) var(--space-4);
}

.segmented-control__button + .segmented-control__button {
    border-left: 1px solid var(--border-strong);
}

.segmented-control__button--active,
.segmented-control__button[aria-selected="true"] {
    background: var(--text-link);
    color: var(--corelight-100);
}

.toggle-chip,
.tag-chip,
.meta-chip {
    align-items: center;
    appearance: none;
    background: var(--corelight-300);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--coredark-700);
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: var(--body-small-font-size);
    gap: var(--space-1);
    line-height: var(--body-small-line-height);
    padding: var(--space-2) var(--space-3);
}

.toggle-chip--active,
.tag-chip--selected,
.meta-chip--selected {
    background: var(--coredark-700);
    border-color: var(--coredark-700);
    color: var(--corelight-100);
}

.beam-panel,
.beam-section {
    background: var(--surface-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
    padding: var(--space-5);
}

.beam-section {
    border-radius: 0;
    border-inline: 0;
    padding: var(--space-6);
}

.beam-panel__header,
.beam-section__header,
.beam-table-toolbar {
    align-items: center;
    display: flex;
    gap: var(--space-3);
    justify-content: space-between;
    min-width: 0;
}

.beam-panel__title,
.beam-section__title {
    color: var(--text-primary);
    font-size: var(--headings-large-h4-font-size);
    font-weight: var(--headings-large-h4-font-weight);
    line-height: var(--headings-large-h4-line-height);
    margin: 0;
}

.beam-panel__description,
.beam-section__description,
.beam-empty-state {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
    margin: 0;
}

.beam-empty-state {
    align-items: center;
    border: 1px dashed var(--corelight-900);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    min-height: calc(var(--control-height) * 3);
    padding: var(--space-6);
}

.beam-table {
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text-primary);
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
    width: 100%;
}

.beam-table th,
.beam-table td {
    border-bottom: 1px solid var(--surface-divider);
    padding: var(--space-3);
    text-align: left;
    vertical-align: middle;
}

.beam-table th {
    background: var(--table-header-bg);
    border-radius: 0;
    color: var(--table-header-fg);
    font-size: var(--table-header-font-size);
    font-weight: var(--table-header-font-weight);
}

.beam-table__double-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.beam-table__secondary {
    color: var(--text-secondary);
}

.beam-table__status {
    background: var(--table-status-bg);
    border-radius: var(--radius-sm);
    color: var(--table-status-text);
    display: inline-flex;
    font-weight: var(--headings-large-h5-font-weight);
    padding: var(--space-1) var(--space-2);
}

.beam-table__progress {
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    height: var(--space-2);
    overflow: hidden;
}

.beam-table__progress-bar {
    background: var(--table-progress-fill);
    height: 100%;
}

.summary-strip {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(calc(var(--drawer-collapse-handle-w) * 5), 1fr));
}

.summary-strip__item {
    background: var(--surface-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3);
}

.summary-strip__label {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
}

.summary-strip__value {
    color: var(--text-primary);
    font-size: var(--headings-large-h4-font-size);
    font-weight: var(--headings-large-h4-font-weight);
    line-height: var(--headings-large-h4-line-height);
}

.beam-banner {
    align-items: flex-start;
    background: var(--surface-muted);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
}

.beam-banner--stale {
    background: var(--status-stale-bg);
    border-color: var(--status-stale-border);
    color: var(--status-stale-text);
}

.beam-banner--changed {
    background: var(--status-changed-bg);
    border-color: var(--status-changed-border);
    color: var(--status-changed-text);
}

.beam-banner--error {
    background: var(--status-error-bg);
    border-color: var(--status-error-border);
    color: var(--status-error-text);
}

.workspace {
    background: var(--surface-canvas);
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1fr) var(--workspace-drawer-w, var(--drawer-w));
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    min-width: 0;
}

.workspace__header {
    background: var(--surface-panel);
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    min-width: 0;
}

.workspace__canvas {
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
}

.workspace__settings {
    background: var(--surface-panel);
    border-left: 1px solid var(--border-strong);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

.workspace__settings-header {
    align-items: center;
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    min-height: calc(var(--control-height) + var(--space-8));
    padding: var(--space-4) var(--space-6);
}

.workspace__settings-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.workspace__settings-footer {
    align-items: center;
    border-top: 1px solid var(--surface-divider);
    display: flex;
    flex: 0 0 auto;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-4) var(--space-6);
}

.workspace__settings-tag {
    align-items: center;
    appearance: none;
    background: var(--surface-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button) 0 0 var(--radius-button);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    height: var(--drawer-collapse-handle-w);
    justify-content: center;
    position: absolute;
    right: 100%;
    top: var(--space-4);
    width: var(--drawer-collapse-handle-w);
}

.workflow-tabs {
    align-items: flex-end;
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    gap: var(--space-1);
    min-width: 0;
}

.workflow-tabs__tab {
    appearance: none;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: var(--body-small-font-size);
    font-weight: var(--headings-large-h5-font-weight);
    gap: var(--space-2);
    line-height: var(--body-small-line-height);
    padding: var(--space-3) var(--space-4) calc(var(--space-3) - var(--radius-xs));
}

/* D-07: the active tab accent is teal, like every other active state.
   This was `--text-link` (the settings-surface blue) — so the CANONICAL tab primitive was blue
   while WP-13 had
   already converged globals' local `.admin-globals-sub-tab` to teal. The WP-16 consistency matrix
   caught the inversion: the exception had been fixed and the canon left wrong. It is also the
   blue in S-17's "Load|Tariffs underline", since the meter modal uses this primitive.
   `--text-link` itself is unchanged — links still use it. */
.workflow-tabs__tab--active,
.workflow-tabs__tab[aria-selected="true"] {
    border-bottom-color: var(--primary-300);
    color: var(--primary-300);
}

.workflow-tabs__tab--disabled,
.workflow-tabs__tab[aria-disabled="true"] {
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.55;
}

.workflow-tabs__tab--stale {
    color: var(--status-stale-text);
}

.workflow-tabs__tab--processing {
    color: var(--text-link);
}

.workflow-tabs__icon,
/* Segments and tabs size to their LONGEST label and never truncate (standards §6: "Quar…" is a
   defect). `white-space: nowrap` plus no width cap means the group grows instead of clipping; if
   a group genuinely cannot fit, its container scrolls rather than the label being cut. */
.workflow-tabs__label {
    display: inline-flex;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}

.workflow-tabs {
    overflow-x: auto;
}

.segmented-control__button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.beam-tooltip-anchor {
    display: inline-flex;
    position: relative;
}

.beam-tooltip {
    background: var(--tooltip-bg);
    border-radius: var(--radius-tooltip);
    color: var(--tooltip-text);
    display: block;
    filter: drop-shadow(0 var(--space-1) var(--space-2) var(--map-polygon-hover));
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
    max-width: var(--drawer-w);
    padding: var(--space-2) var(--space-3);
    position: absolute;
    transform: translateY(calc(-1 * var(--space-2)));
    width: max-content;
    z-index: var(--z-toast);
}

.beam-tooltip.hidden,
.beam-multi-select__listbox.hidden,
.beam-modal.hidden {
    display: none;
}

.beam-tooltip:not(.hidden) {
    display: block;
}

.beam-multi-select {
    position: relative;
    width: 100%;
}

.beam-multi-select__trigger {
    min-width: 100%;
}

.beam-multi-select__listbox {
    background: var(--surface-panel);
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-md);
    box-shadow: 0 var(--space-2) var(--space-4) var(--map-polygon-hover);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    left: 0;
    margin-top: var(--space-1);
    min-width: 100%;
    padding: var(--space-2);
    position: absolute;
    top: 100%;
    z-index: var(--z-dropdown);
}

.beam-multi-select__listbox:not(.hidden) {
    display: flex;
}

.beam-multi-select__option {
    align-items: center;
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2);
}

.beam-modal {
    align-items: center;
    /* WP-04: was --map-polygon-hover, a 16% hover tint that did not read as a backdrop (S-18). */
    background: var(--scrim);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: var(--space-6);
    position: fixed;
    z-index: var(--z-modal);
}

.beam-modal:not(.hidden) {
    display: flex;
}

.beam-modal__panel {
    background: var(--surface-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-modal);
    box-shadow: 0 var(--space-4) var(--space-8) var(--map-polygon-hover);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - (var(--space-6) * 2));
    max-width: var(--globals-modal-w);
    min-width: min(100%, var(--drawer-w));
    overflow: hidden;
    width: min(100%, calc(var(--drawer-w) * 2));
}

/* Canonical modal size scale (standards §8, I-02): size to content, four steps.
   `min()` against 96vw keeps every step sound at 1280 wide; the panel's own max-height plus body
   scroll keep it sound at 690 high.
   ADDITIVE ONLY. `--sm` and `--lg` keep their existing values because they have live consumers on
   other packages' surfaces — `full-systems-table.html:149` (WP-09) and `admin/globals.clj:790,1661`
   (WP-13) — and silently rewidening those from WP-04 would be exactly the fence breach this
   campaign forbids. The kill-list records the migration: `--sm` is really a 320px drawer width,
   not the standards' ~480 confirm, so its consumer moves to `--confirm` when WP-09 touches it. */
.beam-modal__panel--sm {
    width: var(--drawer-w); /* legacy 320px — see note above */
}

.beam-modal__panel--confirm {
    width: min(480px, 96vw);
}

.beam-modal__panel--md {
    width: min(720px, 96vw);
}

.beam-modal__panel--lg {
    width: var(--globals-w); /* legacy min(960px, 92vw) — see note above */
}

.beam-modal__panel--xl,
.beam-modal__panel--full {
    width: var(--globals-modal-w);
}

.beam-modal__header,
.beam-modal__footer {
    align-items: center;
    background: var(--surface-panel);
    display: flex;
    gap: var(--space-3);
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
}

.beam-modal__header {
    border-bottom: 1px solid var(--surface-divider);
}

.beam-modal__footer {
    border-top: 1px solid var(--surface-divider);
    justify-content: flex-end;
}

.beam-modal__title {
    color: var(--text-primary);
    font-size: var(--headings-large-h4-font-size);
    font-weight: var(--headings-large-h4-font-weight);
    line-height: var(--headings-large-h4-line-height);
    margin: 0;
}

.beam-modal__body {
    overflow: auto;
    padding: var(--space-6);
}

.beam-modal__close,
.modal-close-button {
    align-items: center;
    appearance: none;
    background: var(--corelight-100);
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-button);
    color: var(--coredark-700);
    cursor: pointer;
    display: inline-flex;
    height: var(--control-height);
    justify-content: center;
    width: var(--control-height);
}

.file-upload {
    align-items: center;
    background: var(--surface-panel);
    border: 1px dashed var(--corelight-900);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    justify-content: center;
    min-height: calc(var(--control-height) * 4);
    padding: var(--space-6);
    text-align: center;
}

.file-upload--dragover {
    background: var(--surface-muted);
    border-color: var(--text-link);
}

.file-upload__input {
    display: none;
}

.file-upload-item {
    align-items: center;
    background: var(--surface-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    display: flex;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-3);
}

.file-upload-item--error {
    background: var(--file-upload-error-bg);
    border-color: var(--file-upload-error-border);
}

.file-upload-item--grid {
    align-items: stretch;
    flex-direction: column;
    width: calc(var(--drawer-collapse-handle-w) * 5);
}

.file-upload-item__thumb {
    align-items: center;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    display: flex;
    height: calc(var(--control-height) * 2);
    justify-content: center;
}

.file-upload-item__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.file-upload-item__name {
    color: var(--text-primary);
    font-weight: var(--headings-large-h5-font-weight);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-upload-item__meta,
.file-upload-item__error {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
}

.file-upload-item__error {
    color: var(--status-error-text);
}

.file-upload-item__progress {
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    height: var(--space-2);
    overflow: hidden;
}

.file-upload-item__progress-bar {
    background: var(--file-upload-progress);
    height: 100%;
}

.ag-theme-beam {
    --ag-background-color: var(--ag-beam-background);
    --ag-foreground-color: var(--ag-beam-foreground);
    --ag-border-color: var(--ag-beam-border);
    --ag-header-background-color: var(--surface-muted);
    --ag-odd-row-background-color: var(--surface-page);
    --ag-selected-row-background-color: var(--map-polygon-hover);
    --ag-row-hover-color: var(--surface-muted);
    --ag-font-family: inherit;
}

@media (max-width: 700px) {
    .beam-panel__header,
    .beam-section__header,
    .beam-table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .beam-modal {
        padding: var(--space-3);
    }
}

.ui-gallery {
    background: var(--surface-page);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-6);
}

.ui-gallery__header {
    background: var(--coredark-700);
    color: var(--corelight-100);
    padding: var(--space-6);
}

.ui-gallery__header h1,
.ui-gallery__header p {
    margin: 0;
}

.ui-gallery__header h1 {
    font-size: var(--headings-large-h2-font-size);
    font-weight: var(--headings-large-h2-font-weight);
    line-height: var(--headings-large-h2-line-height);
}

.ui-gallery__row {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.ui-gallery__row-label {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
    font-weight: var(--headings-large-h5-font-weight);
    line-height: var(--body-small-line-height);
    text-transform: uppercase;
}

.ui-gallery__controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.ui-gallery__wide {
    width: min(100%, var(--globals-w));
}

.ui-gallery__narrow {
    width: min(100%, var(--drawer-w));
}

.ui-gallery__chart-grid,
.ui-gallery__load-demo {
    min-width: min(100%, calc(var(--drawer-w) * 2));
    overflow-x: auto;
}

.beam-chart-canvas {
    background: var(--corelight-100);
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-card);
    box-sizing: border-box;
    max-width: 100%;
}

.load-canvas-readout {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
    min-height: var(--body-small-line-height);
}

.ui-gallery__load-demo .load-canvas {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ui-gallery__load-demo .load-kpi-strip,
.ui-gallery__load-demo .load-canvas-toolbar,
.ui-gallery__load-demo .load-canvas-actions,
.ui-gallery__load-demo .load-canvas-tabs,
.ui-gallery__load-demo .load-canvas-toggle,
.ui-gallery__load-demo .load-canvas-legend {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.ui-gallery__load-demo .load-kpi {
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-card);
    padding: var(--space-2) var(--space-3);
}

.ui-gallery__load-demo .load-kpi span,
.ui-gallery__load-demo .load-canvas-card__meta,
.ui-gallery__load-demo .load-canvas-legend,
.ui-gallery__load-demo .load-canvas-empty {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
}

.ui-gallery__load-demo .load-kpi strong,
.ui-gallery__load-demo .load-canvas-card__title {
    color: var(--text-primary);
    display: block;
    font-size: var(--body-large-font-size);
    font-weight: var(--headings-large-h5-font-weight);
}

.ui-gallery__load-demo .load-canvas-toolbar {
    justify-content: space-between;
}

.ui-gallery__load-demo .load-canvas-tabs,
.ui-gallery__load-demo .load-canvas-toggle {
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-button);
    gap: 0;
    overflow: hidden;
}

.ui-gallery__load-demo .load-canvas-tabs button,
.ui-gallery__load-demo .load-canvas-toggle button {
    background: var(--corelight-100);
    border: 0;
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    padding: var(--space-2) var(--space-3);
}

.ui-gallery__load-demo .load-canvas-tabs button.active,
.ui-gallery__load-demo .load-canvas-toggle button.active {
    background: var(--coredark-700);
    color: var(--corelight-100);
}

.ui-gallery__load-demo .load-canvas-charts {
    display: grid;
    gap: var(--space-4);
}

.ui-gallery__load-demo .load-canvas-card {
    border: 1px solid var(--corelight-900);
    border-radius: var(--radius-card);
    padding: var(--space-3);
}

.ui-gallery__load-demo .load-canvas-card__header {
    align-items: baseline;
    display: flex;
    gap: var(--space-3);
    justify-content: space-between;
}

.ui-gallery__load-demo .load-canvas-chart {
    height: auto;
    max-width: 100%;
}

.ui-gallery__load-demo .load-canvas-legend i {
    border-radius: var(--radius-xs);
    display: inline-block;
    height: var(--space-3);
    margin-right: var(--space-1);
    width: var(--space-3);
}

.ui-gallery__load-demo .load-heatmap {
    display: grid;
    gap: var(--radius-xs);
    grid-template-columns: calc(var(--space-8) + var(--space-2)) repeat(24, minmax(var(--space-4), 1fr));
}

.ui-gallery__load-demo .load-heatmap__hour,
.ui-gallery__load-demo .load-heatmap__month {
    color: var(--text-secondary);
    font-size: var(--body-small-font-size);
    line-height: var(--body-small-line-height);
    text-align: center;
}

.ui-gallery__load-demo .load-heatmap__cell {
    aspect-ratio: 1;
    min-width: var(--space-4);
}

.ui-gallery__modal-demo .beam-modal {
    background: transparent;
    padding: 0;
    position: static;
}

.ui-gallery__token-grid {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(calc(var(--drawer-collapse-handle-w) * 6), 1fr));
}

.ui-gallery__token {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
}

.ui-gallery__swatch {
    background: var(--token-swatch, var(--surface-muted));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    height: var(--control-height);
}
