*, *::before, *::after { box-sizing: border-box; }

/*
 * RAHSA canonical continuous geometry.
 * Existing radii remain the size scale and fallback when corner-shape is unavailable.
 */
@supports (corner-shape: squircle) {
  :where(*, *::before, *::after) {
    corner-shape: var(--erp-corner-shape);
  }

  /* Exact circles, capsules and intentional edge-to-edge surfaces remain round. */
  :where(
    svg,
    svg *,
    input[type="radio"],
    .erp-badge,
    .erp-avatar,
    .erp-empty-state__icon,
    .erp-state__icon,
    .erp-grid-toolbar .erp-search-box .erp-input-shell > button,
    .erp-help,
    .erp-switch__track,
    .erp-switch__track i,
    .erp-select-chip,
    .erp-progress,
    .erp-progress i,
    .erp-spinner i,
    .erp-alert.is-toast .erp-alert__icon,
    .erp-connection i,
    .erp-count,
    .erp-notifications article > span,
    .erp-sidebar__context-grid .erp-context-switcher select,
    .erp-sidebar.is-collapsed .erp-sidebar__identity-card::after,
    .erp-connection-screen__ambient,
    .erp-connection-loader span,
    .erp-login-page__ambient,
    .erp-login-card__brand::after,
    .erp-login-spinner,
    .bi-dashboard-workbench--published,
    .bi-commandbar-button strong,
    .bi-filter-launch strong,
    .bi-quality-button strong,
    .bi-dashboard-workbench--published .bi-designer--published,
    .bi-filter-control summary strong,
    .bi-filter-categories strong,
    .bi-filter-state i,
    .bi-widget-help summary,
    .bi-widget-loading i,
    .bi-series-legend i,
    .bi-chart-legend i,
    .bi-active-filter-summary > div > button,
    .bi-dashboard-workbench--published-unified,
    .bi-designer-loading i,
    .bi-preparation-steps button > span,
    .bi-preparation-status-dot,
    .bi-workbench--query .bi-preparation-preview-empty .erp-icon,
    .bi-workbench--query .bi-preparation-step__head > span,
    .bi-workbench--model .bi-model-nodes article::after,
    .bi-workbench--model .bi-relationship-path strong,
    .status-dot,
    .activity-icon,
    .design-showcase-swatches span,
    .storage-file-info__permissions > span,
    .storage-tree__children::before,
    .storage-kind-icon
  ) {
    corner-shape: round;
  }
}

html, body { margin: 0; min-height: 100%; background: var(--erp-background-canvas); color: var(--erp-text-primary); font: var(--erp-font-body); }
body { min-width: 320px; }
/* Shared text direction: a Persian base with isolated, naturally ordered Latin
 * and numeric runs. Never reverse characters or alter the stored field value. */
html, body { direction: rtl; }
:is(h1, h2, h3, h4, h5, h6, p, label, legend, summary, option,
    th, td, caption, dt, dd, li, a, button, span, small, strong, em,
    .erp-field-description, .erp-field-message, .erp-numeric) {
  direction: rtl !important;
  unicode-bidi: isolate !important;
}
:is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
    textarea, select, [contenteditable="true"]):not(:where(.erp-date-input input)) {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: isolate !important;
}
/* Code and keyboard shortcuts are independent technical runs. */
pre, code, kbd {
  direction: ltr;
  unicode-bidi: isolate;
}
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, var(--erp-ambient-primary), transparent 30%),
    radial-gradient(circle at 88% 92%, var(--erp-ambient-secondary), transparent 28%);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--erp-text-link); text-decoration: none; }
:focus-visible { outline: 2px solid var(--erp-border-focus); outline-offset: 2px; box-shadow: var(--erp-shadow-focus); }
input:focus,
input:focus-visible,
textarea:focus,
textarea:focus-visible,
select:focus,
select:focus-visible {
  outline: 0;
  box-shadow: none;
}
::selection { background: var(--erp-color-primary-subtle); }
* {
  scrollbar-width: thin;
  scrollbar-color:
    color-mix(in srgb, var(--erp-text-tertiary) 62%, transparent)
    color-mix(in srgb, var(--erp-surface-secondary) 38%, transparent);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track {
  border-radius: var(--erp-radius-sm);
  background: color-mix(in srgb, var(--erp-surface-secondary) 38%, transparent);
}
*::-webkit-scrollbar-thumb {
  min-height: 42px;
  border: 3px solid transparent;
  border-radius: var(--erp-radius-sm);
  background: color-mix(in srgb, var(--erp-text-tertiary) 62%, transparent);
  background-clip: padding-box;
  transition: background-color var(--erp-motion-fast) var(--erp-ease-standard);
}
*::-webkit-scrollbar-thumb:hover {
  border-width: 2px;
  background: color-mix(in srgb, var(--erp-color-primary) 82%, transparent);
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:active {
  border-width: 2px;
  background: var(--erp-color-primary);
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner { background: transparent; }
.erp-sidebar__nav,
.erp-workspace-panel,
.erp-dialog__body,
.erp-select-options,
.erp-grid-column-manager__panel {
  scrollbar-gutter: stable;
}
.erp-grid-scroll { scrollbar-gutter: auto; }
.erp-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.erp-numeric { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

.erp-glass-subtle,
.erp-glass-standard,
.erp-glass-elevated {
  border: 1px solid var(--erp-border-glass);
  isolation: isolate;
}
.erp-glass-subtle {
  background: var(--erp-glass-toolbar);
  box-shadow: var(--erp-shadow-xs);
  -webkit-backdrop-filter: blur(var(--erp-blur-subtle)) saturate(112%);
  backdrop-filter: blur(var(--erp-blur-subtle)) saturate(112%);
}
.erp-glass-standard {
  background: var(--erp-glass-panel);
  box-shadow: var(--erp-shadow-glass);
  -webkit-backdrop-filter: blur(var(--erp-blur-default)) saturate(116%);
  backdrop-filter: blur(var(--erp-blur-default)) saturate(116%);
}
.erp-glass-elevated {
  background: var(--erp-glass-dialog);
  box-shadow: var(--erp-shadow-dialog);
  -webkit-backdrop-filter: blur(var(--erp-blur-strong)) saturate(120%);
  backdrop-filter: blur(var(--erp-blur-strong)) saturate(120%);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .erp-glass-subtle { background: var(--erp-solid-secondary); }
  .erp-glass-standard { background: var(--erp-solid-primary); }
  .erp-glass-elevated { background: var(--erp-background-elevated); }
}

@media (prefers-reduced-transparency: reduce) {
  .erp-glass-subtle,
  .erp-glass-standard,
  .erp-glass-elevated {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .erp-glass-subtle { background: var(--erp-solid-secondary); }
  .erp-glass-standard { background: var(--erp-solid-primary); }
  .erp-glass-elevated { background: var(--erp-background-elevated); }
  body::before { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto; transition-duration: .01ms; animation-duration: .01ms; animation-iteration-count: 1; } }
