/* CRUD framework (framework/crud). Tokens only: works in light and dark. */
.xr-toasts { position: fixed; right: var(--sp-4, 16px); bottom: var(--sp-4, 16px); z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.xr-toast { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-md); font-size: var(--fs-body); }
.xr-toast-success { border-left: 4px solid var(--positive); }
.xr-toast-error { border-left: 4px solid var(--negative); background: var(--negative-soft-bg); }
.xr-toast-info { border-left: 4px solid var(--accent); }
.xr-toast-text { flex: 1; overflow-wrap: anywhere; }
.xr-toast-close { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 14px; line-height: 1; }

.xr-crud-toolbar { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 0; }
.xr-crud-toolbar:empty { display: none; }

/* A persistent inline note (same visual language as .xr-toast-info, but it
   stays on screen instead of firing once and disappearing -- see
   framework::fanout::default_site_notice). Was declared by pages before this
   had any styling (framework::report_page's Average Engage note among them);
   this is the shared definition every `.xr-note` gets now. */
.xr-note { padding: 6px 10px; border-radius: var(--radius-sm); border-left: 3px solid var(--accent); background: var(--bg-surface-sunken); color: var(--text-secondary); font-size: var(--fs-body); }
/* In the CRUD toolbar specifically: pushed to the left edge so the search box
   / export button on the right stay put, wraps rather than squeezing them. */
.xr-fanout-note { margin-right: auto; max-width: 60ch; }
.xr-crud-row-actions { display: inline-flex; gap: 4px; white-space: nowrap; }
.xr-crud-row-actions a { text-decoration: none; display: inline-flex; align-items: center; }
.xr-crud-row-actions a.disabled { opacity: 0.5; pointer-events: none; }
.xr-crud-danger-ghost, .xr-crud-danger-ghost:hover { color: var(--negative); }
.xr-btn-primary.xr-crud-danger { background: var(--negative); border-color: var(--negative); color: var(--text-inverse); }

.xr-crud-form { display: flex; flex-direction: column; gap: 12px; }
.xr-crud-fields { display: flex; flex-direction: column; gap: 12px; }
/* Hidden is a state, and must override later flex/grid layout declarations. */
.xr-crud-hidden { display: none !important; }
.xr-crud-loading { color: var(--text-secondary); padding: 8px 0; }
.xr-crud-field { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; align-items: start; }
.xr-crud-field-inline .xr-crud-label { padding-top: 0; }
.xr-crud-label { font-size: var(--fs-label); font-weight: 600; color: var(--text-secondary); padding-top: 8px; }
.xr-crud-req { color: var(--negative); }
.xr-crud-control { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.xr-crud-input { width: 100%; box-sizing: border-box; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); font: inherit; }
.xr-crud-input:focus { outline: 2px solid var(--ring); outline-offset: 0; }
.xr-crud-input:disabled { background: var(--bg-surface-sunken); color: var(--text-secondary); }
.xr-crud-textarea { resize: vertical; font-family: var(--font-mono); }
.xr-crud-field-invalid .xr-crud-input { border-color: var(--negative); }
.xr-crud-help { font-size: 12px; color: var(--text-secondary); }
.xr-crud-error { font-size: 12px; color: var(--negative); }
.xr-crud-banner { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--negative-soft-bg); color: var(--negative); border: 1px solid var(--negative); }
.xr-crud-notice { background: var(--accent-soft-bg); color: var(--accent-soft-fg); border-color: var(--border-default); } /* ui-polish: view-only banner */
/* A site banner that stays mounted after a site is picked (create forms) --
   same "settled" look as `.xr-crud-notice` instead of the alarming red. */
.xr-crud-banner-resolved { background: var(--accent-soft-bg); color: var(--accent-soft-fg); border-color: var(--border-default); }
.xr-crud-actions { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.xr-crud-spacer { flex: 1; }
.xr-crud-modal-title { font-weight: 700; margin-bottom: 8px; }
.xr-crud-page-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 16px; max-width: 900px; }
.xr-crud-confirm-msg { margin: 0 0 12px; overflow-wrap: anywhere; }
.xr-crud-confirm-type { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.xr-crud-switch { width: 34px; height: 18px; accent-color: var(--accent); }
/* A bare checkbox inside the flex control column stretches to its full width
   (721px on the delivery-rule form): size the box itself. */
.xr-crud-check { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); vertical-align: middle; }

.xr-crud-rows { display: flex; flex-direction: column; gap: 8px; }
.xr-crud-row { display: flex; gap: 8px; align-items: flex-end; padding: 8px; border: 1px dashed var(--border-default); border-radius: var(--radius-sm); }
.xr-crud-row-cell { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.xr-crud-row-label { font-size: 11px; color: var(--text-secondary); }

.xr-crud-picker { position: relative; }
.xr-crud-picker-clear { position: absolute; right: 6px; top: 6px; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; }
.xr-crud-picker-list { position: absolute; z-index: 50; left: 0; right: 0; margin: 2px 0 0; padding: 4px 0; list-style: none; max-height: 220px; overflow: auto; background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.xr-crud-picker-list li { padding: 6px 10px; cursor: pointer; }
.xr-crud-picker-list li:hover { background: var(--bg-hover); }
.xr-crud-picker-empty { color: var(--text-secondary); cursor: default !important; }
.xr-crud-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.xr-crud-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft-bg); color: var(--accent-soft-fg); font-size: 12px; }
.xr-crud-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; }

@media (max-width: 640px) { .xr-crud-field { grid-template-columns: 1fr; } .xr-crud-label { padding-top: 0; } }

/* shared HTML/AMP preview dialog */
.xr-html-preview { max-width: 960px; width: 100%; }
.xr-html-preview-body { display: flex; flex-direction: column; gap: var(--sp-2); height: min(72vh, 760px); }
.xr-html-preview-bar { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.xr-html-preview-width { width: 260px; }
.xr-html-preview-stage { flex: 1; min-height: 0; display: flex; justify-content: center; background: var(--bg-surface-sunken); border: 1px solid var(--border-default); border-radius: var(--radius-sm); overflow: auto; }
.xr-html-preview-frame { height: 100%; border: 0; background: #fff; max-width: 100%; }
.xr-html-preview-full {
  position: fixed; inset: 0; z-index: 1200; height: auto; padding: var(--sp-3);
  background: var(--bg-surface);
}

/* ==== forms framework extension (crud/form.rs: sections, tabs, groups) ==== */
.xr-crud-section { display: flex; flex-direction: column; gap: 12px; }
.xr-crud-section + .xr-crud-section { padding-top: 12px; border-top: 1px solid var(--border-default); }
.xr-crud-section-title { margin: 0; font-size: var(--fs-body); font-weight: 700; color: var(--text-primary); }
.xr-crud-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.xr-crud-cols-2 > .xr-crud-section-title, .xr-crud-cols-2 > .xr-crud-help, .xr-crud-cols-2 > .xr-crud-span-full { grid-column: 1 / -1; }
.xr-crud-cols-2 .xr-crud-field { grid-template-columns: 1fr; }
.xr-crud-cols-2 .xr-crud-label { padding-top: 0; }
.xr-crud-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-default); overflow-x: auto; }
.xr-crud-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-secondary); padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.xr-crud-tab:hover { color: var(--text-primary); }
.xr-crud-tab-active { color: var(--accent); border-bottom-color: var(--accent); }
.xr-crud-tab-err { color: var(--negative); }
.xr-crud-group { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.xr-crud-group-row { align-self: stretch; display: flex; gap: 8px; align-items: flex-end; padding: 8px; border: 1px dashed var(--border-default); border-radius: var(--radius-sm); min-width: 0; }
.xr-crud-group-cards .xr-crud-group-row { flex-direction: column; align-items: stretch; border-style: solid; }
.xr-crud-group-caption { font-size: var(--fs-label); font-weight: 600; color: var(--text-secondary); }
.xr-crud-group-cells { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.xr-crud-group-cards .xr-crud-group-cells { flex-direction: column; }
.xr-crud-group-cells > .xr-crud-row-cell { min-width: 140px; }
.xr-crud-group-tools { display: inline-flex; gap: 4px; white-space: nowrap; }
@media (max-width: 640px) { .xr-crud-cols-2 { grid-template-columns: 1fr; } .xr-crud-group-row { flex-direction: column; align-items: stretch; } }

/* ==== forms framework extension 2 (progress, result view, slots, header, file, confirm body) ==== */
.xr-crud-modal-title { display: flex; align-items: center; gap: 8px; }
.xr-crud-modal-title > span { flex: 1; min-width: 0; }
.xr-crud-header-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.xr-page-header .xr-crud-header-actions { align-self: flex-end; }
.xr-crud-crumbs { font-size: 12px; color: var(--text-secondary); margin: 0; }
.xr-crud-crumbs a { color: var(--accent); text-decoration: none; }
.xr-crud-crumbs a:hover { text-decoration: underline; }
.xr-crud-body { display: flex; flex-direction: column; gap: 12px; }
.xr-crud-body-aside { flex-direction: row; align-items: flex-start; }
.xr-crud-main { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 0; }
.xr-crud-body-aside > .xr-crud-aside { flex: 0 0 min(40%, 420px); position: sticky; top: 8px; }
.xr-crud-above, .xr-crud-aside { min-width: 0; }
.xr-crud-progress { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-surface-sunken); }
.xr-crud-progress-bar { position: relative; height: 4px; overflow: hidden; border-radius: 2px; background: var(--border-default); }
.xr-crud-progress-bar > span { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 2px; background: var(--accent); animation: xr-crud-indeterminate 1.2s ease-in-out infinite; }
@keyframes xr-crud-indeterminate { from { left: -35%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .xr-crud-progress-bar > span { animation: none; left: 0; width: 100%; opacity: 0.5; } }
.xr-crud-progress-text { display: flex; flex-wrap: wrap; gap: 8px; font-size: var(--fs-body); color: var(--text-secondary); }
.xr-crud-progress-text b { color: var(--text-primary); }
.xr-crud-result { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.xr-crud-success { background: var(--positive-soft-bg); color: var(--text-primary); border-color: var(--positive); }
.xr-crud-row-cell-block { flex-basis: 100%; }
/* Inside the wrapped column flex of a group row, a nested table's min-content
   width inflates the flex line and juts the cell out of the card; width:0
   zeroes that intrinsic contribution and min-width:100% restores the fill. */
.xr-crud-row-cell-block > .xr-table-compact-wrap { width: 0; min-width: 100%; }
.xr-crud-file { display: flex; flex-direction: column; gap: 6px; }
.xr-crud-file-current { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.xr-crud-file-current a { overflow-wrap: anywhere; color: var(--accent); }
.xr-crud-file-preview { max-width: 160px; max-height: 96px; object-fit: contain; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-surface-sunken); }
.xr-crud-file-input { font: inherit; color: var(--text-secondary); }
.xr-crud-confirm-extra { margin: 0 0 12px; }
@media (max-width: 900px) { .xr-crud-body-aside { flex-direction: column; align-items: stretch; } .xr-crud-body-aside > .xr-crud-aside { flex-basis: auto; position: static; } }
.xr-crud-notes:empty { display: none; }
