:where(.ui-page) {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-3);
}

:where(.ui-stack) {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
  min-width: 0;
}

:where(.ui-cluster) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
  min-width: 0;
}

:where(.ui-grid) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--ui-space-3);
  min-width: 0;
}

/* Canonical geometry for legacy semantic class names still used by PHP views. */
:where(html, body, *, *::before, *::after) {
  box-sizing: border-box;
}

:where(.header, .app-header, .page-header, .main-header, .workspace-header) {
  flex: 0 0 auto;
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ui-space-3) var(--ui-space-4);
  text-align: center;
}

:where(.topbar, .toolbar, .nav-bar, .navigation) {
  flex: 0 0 auto;
  width: 100%;
  min-height: var(--ui-control-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-3);
  padding: var(--ui-space-2) var(--ui-space-4);
}

:where(.topbar-actions, .panel-tools, .filter-actions, .actions, .inline-form) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
}

:where(.container, .content, .page-content, .workspace) {
  width: min(96%, 1240px);
  min-width: 0;
  margin-inline: auto;
}

:where(.card, .panel, .box, .section, .form-box, .filter-box, .summary-box, .stat-card, .modal-content) {
  min-width: 0;
  padding: var(--ui-space-4);
}

:where(.grid, .layout-grid, .form-grid, .filter-grid, .summary-grid, .stats-grid, .cards-grid, .reports-row) {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--ui-space-3);
}

:where(.field, .search-box) {
  min-width: 0;
}

:where(input, select, textarea, .search-box input) {
  width: 100%;
  max-width: 100%;
}

:where(textarea) {
  min-height: 82px;
  resize: vertical;
}

:where(.table-wrap, .table-scroll) {
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

:where(table) {
  width: 100%;
}

:where(.message, .notice, .alert, .empty) {
  padding: var(--ui-space-3);
}
