/* FXV Grid Panel Runtime shared primitives ------------------------------
   Structural behavior is enabled only when the central contract declares
   primitive_mode=managed and responsive_owner=shared. Panel identity,
   semantic colours, and specialist renderer state remain panel-owned. */

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] :is(.fxv-pc-panel, .fxv-pc-body, .fxv-pc-card, .fxv-pc-heading, .fxv-pc-control-group, .fxv-pc-control-field) {
  box-sizing: border-box;
  min-inline-size: 0;
  min-block-size: 0;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-panel {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  align-content: flex-start !important;
  gap: var(--fxv-panel-space-md, .75rem) !important;
  inline-size: 100%;
  block-size: 100%;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-flow-alignment="center"] .fxv-pc-panel {
  justify-content: center !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-flow-alignment="end"] .fxv-pc-panel {
  justify-content: flex-end !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"]:is([data-fxv-panel-flow-alignment="center"], [data-fxv-panel-flow-alignment="end"]) .fxv-pc-body {
  flex-grow: 0;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-panel[data-fxv-surface~="inset"] {
  padding: var(--fxv-panel-space-lg, .9rem) !important;
  border-radius: var(--fxv-panel-radius-lg, 18px) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-toolbar {
  display: flex !important;
  flex: 0 0 auto;
  align-items: flex-start !important;
  align-content: flex-start !important;
  justify-content: space-between !important;
  gap: var(--fxv-panel-space-md, .75rem) !important;
  min-inline-size: 0;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-heading {
  flex: 1 1 12rem;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-title {
  overflow-wrap: anywhere;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] :is(.fxv-pc-tools, .fxv-pc-pills, .fxv-pc-actions) {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: var(--fxv-panel-space-xs, .4rem) !important;
  min-inline-size: 0;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] :is(.fxv-pc-tools, .fxv-pc-actions) {
  justify-content: flex-end !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] :is(.fxv-pc-pill, .fxv-pc-action, .fxv-pc-control-group, .fxv-pc-control-field) {
  min-inline-size: 0;
  max-inline-size: 100%;
}

/* Critical row actions are the final disclosure surface at constrained tiers.
   Identity and secondary detail may shrink or collapse; this slot may not. */
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-critical-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) max-content !important;
  align-items: start !important;
  justify-content: stretch !important;
  inline-size: 100%;
  min-inline-size: 0;
  overflow: visible !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-critical-row > :not([data-fxv-critical-action]) {
  min-inline-size: 0 !important;
  overflow: hidden;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] [data-fxv-critical-action] {
  flex: 0 0 auto !important;
  justify-self: end;
  align-self: flex-start;
  min-inline-size: max-content !important;
  max-inline-size: none !important;
  overflow: visible !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] [data-fxv-critical-action] > :is(button, a) {
  position: relative !important;
  inset: auto !important;
  display: inline-grid !important;
  flex: 0 0 auto !important;
  min-inline-size: var(--fxv-panel-control-compact, 2rem);
  min-block-size: var(--fxv-panel-control-compact, 2rem);
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
}

/* Overflow-menu primitive -------------------------------------------------
   Portal is the safe default because panel bodies and lower list rows are
   commonly clipped by scroll containers. Contained placement is explicit. */
.fxv-pc-overflow-menu {
  position: relative;
  min-inline-size: 0;
}

.fxv-pc-overflow-menu__popup[hidden] {
  display: none !important;
}

.fxv-pc-overflow-menu[data-fxv-menu-placement="contained"] > .fxv-pc-overflow-menu__popup--open {
  position: absolute;
  inset-block-start: calc(100% + .35rem);
  inset-inline-end: 0;
  display: grid !important;
  overflow: auto;
  overscroll-behavior: contain;
  max-inline-size: min(22rem, calc(100vw - 1rem));
  max-block-size: min(24rem, calc(100vh - 1rem));
  z-index: 6000;
}

.fxv-pc-overlay-root {
  position: fixed;
  inset: 0;
  z-index: 2147482500;
  pointer-events: none;
  overflow: visible;
}

.fxv-pc-overlay-root > .fxv-pc-overflow-menu__popup--portal {
  position: fixed !important;
  inset: auto !important;
  display: grid !important;
  pointer-events: auto;
  overflow: auto;
  overscroll-behavior: contain;
  max-inline-size: min(22rem, calc(100vw - 1rem));
  max-block-size: calc(100vh - 1rem);
  z-index: 1;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-pill {
  min-block-size: var(--fxv-panel-control-compact, 1.75rem) !important;
  padding: var(--fxv-panel-pill-pad-block, .35rem) var(--fxv-panel-pill-pad-inline, .65rem) !important;
  font-size: var(--fxv-panel-font-small, .78rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-action {
  min-block-size: var(--fxv-panel-control-compact, 1.8rem) !important;
  padding-block: var(--fxv-panel-pill-pad-block, .25rem) !important;
  padding-inline: var(--fxv-panel-pill-pad-inline, .6rem) !important;
  font-size: var(--fxv-panel-font-small, .78rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] :is(.fxv-pc-control-group, .fxv-pc-control-field) {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: var(--fxv-panel-space-xs, .4rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-control-group {
  min-block-size: var(--fxv-panel-control-compact, 1.75rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-body {
  flex: 1 1 auto;
  align-self: stretch;
  align-content: flex-start;
  overflow: auto;
  overscroll-behavior: contain;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-flow {
  display: grid !important;
  align-content: start !important;
  justify-content: stretch !important;
  gap: var(--fxv-panel-space-md, .75rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-flow[data-fxv-layout~="cards"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--fxv-pc-card-min, 17rem)), 1fr)) !important;
  grid-auto-rows: max-content !important;
  align-content: start !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-card {
  gap: var(--fxv-panel-space-sm, .55rem) !important;
  padding: var(--fxv-panel-space-lg, .85rem) !important;
  border-radius: var(--fxv-panel-radius-md, 16px) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-summary {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.75rem), 1fr));
  gap: var(--fxv-panel-space-sm, .55rem) !important;
  min-inline-size: 0;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-fields {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: var(--fxv-panel-space-md, .75rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-table-wrap {
  min-inline-size: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-table-wrap > table {
  min-inline-size: 100%;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-empty {
  grid-column: 1 / -1;
  inline-size: 100%;
  padding: var(--fxv-panel-space-lg, 1rem) !important;
  border-radius: var(--fxv-panel-radius-md, 16px) !important;
  text-align: center;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-footer {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--fxv-panel-space-md, .75rem) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] .fxv-pc-label {
  display: inline-flex;
  align-items: center;
  min-inline-size: 0;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] :is(.fxv-pc-label__short, .fxv-pc-label__icon) {
  display: none !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] .fxv-pc-toolbar,
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-toolbar {
  flex-direction: column !important;
  align-items: stretch !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] .fxv-pc-heading,
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-heading {
  flex: 0 0 auto !important;
  inline-size: 100%;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] :is(.fxv-pc-tools, .fxv-pc-actions),
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] :is(.fxv-pc-tools, .fxv-pc-actions) {
  inline-size: 100%;
  justify-content: flex-start !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] [data-fxv-compact~="narrow"],
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] [data-fxv-compact~="narrow"] {
  padding: var(--fxv-panel-space-md, .7rem) !important;
  border-radius: var(--fxv-panel-radius-sm, 12px) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] .fxv-pc-action[data-fxv-grow~="narrow"],
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-action[data-fxv-grow~="narrow"] {
  flex: 1 0 100%;
  inline-size: 100%;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] .fxv-pc-label__full,
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-label__full {
  display: none !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] .fxv-pc-label__short {
  display: inline !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-label__short {
  display: none !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-label__icon {
  display: inline !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-control-group[data-fxv-stack~="micro"] {
  inline-size: 100% !important;
  border-radius: var(--fxv-panel-radius-sm, 12px) !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-control-group[data-fxv-stack~="micro"] .fxv-pc-control-field {
  flex: 1 1 11rem;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-control-group[data-fxv-stack~="micro"] :is(select, button) {
  flex: 1 1 7rem;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] .fxv-pc-actions[data-fxv-grow~="micro"] > .fxv-pc-action {
  flex: 1 1 5rem;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="narrow"] [data-fxv-collapse~="hide-narrow"],
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] [data-fxv-collapse~="hide-narrow"],
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] [data-fxv-priority="secondary"][data-fxv-collapse~="hide-micro"],
.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-width-state="micro"] [data-fxv-priority="tertiary"] {
  display: none !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-height-state="short"] [data-fxv-collapse~="hide-short"] {
  display: none !important;
}

.grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"][data-fxv-panel-height-state="short"] .fxv-pc-panel {
  gap: var(--fxv-panel-space-sm, .55rem) !important;
}

@media (prefers-reduced-motion: reduce) {
  .grid-stack-item-content[data-fxv-panel-primitive-mode="managed"][data-fxv-panel-responsive-owner="shared"] * {
    scroll-behavior: auto !important;
  }
}