/**
 * CAWorkflow Form System v2 — one presentation layer for all 18 modules.
 *
 * Zero field/submit/AJAX manipulation. Every selector is anchored to an
 * explicitly opted-in Form API form (.wf-ui) or an audited WF admin page.
 * No @import, external font, icon font, hidden security notice, or build step.
 */
:where(.wf-ui, .wf-saas-admin) {
  /* The shared token contract, usable by all owning modules. */
  --wf-ui-font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Bengali", system-ui, Arial, sans-serif;
  --wf-ui-canvas: #f5f7fb;
  --wf-ui-surface: #ffffff;
  --wf-ui-surface-soft: #f8faff;
  --wf-ui-ink: #17243b;
  --wf-ui-copy: #33445e;
  --wf-ui-muted: #53647c;
  --wf-ui-hint: #60718a;
  --wf-ui-line: #dce4f0;
  --wf-ui-line-strong: #bac8dc;
  --wf-ui-primary: #244ab7;
  --wf-ui-primary-hover: #17388f;
  --wf-ui-primary-soft: #e9efff;
  --wf-ui-focus: #6f90f5;
  --wf-ui-positive: #08735c;
  --wf-ui-positive-bg: #e9f7f1;
  --wf-ui-warning: #8b5705;
  --wf-ui-warning-bg: #fff5dc;
  --wf-ui-danger: #ab283d;
  --wf-ui-danger-hover: #8f1c31;
  --wf-ui-danger-bg: #fff0f2;
  --wf-ui-radius-xs: 7px;
  --wf-ui-radius-sm: 10px;
  --wf-ui-radius-md: 14px;
  --wf-ui-radius-lg: 18px;
  --wf-ui-shadow: 0 1px 2px rgba(24, 43, 76, .035), 0 7px 22px rgba(24, 43, 76, .045);
  --wf-ui-gap: clamp(14px, 2vw, 22px);
}

/* Bridge the previous dashboard and the Tauri components onto one palette. */
.wf-saas-admin {
  --wf-ink: var(--wf-ui-ink);
  --wf-muted: var(--wf-ui-muted);
  --wf-border: var(--wf-ui-line);
  --wf-border-dark: var(--wf-ui-line-strong);
  --wf-canvas: var(--wf-ui-canvas);
  --wf-surface: var(--wf-ui-surface);
  --wf-panel: var(--wf-ui-surface-soft);
  --wf-brand: var(--wf-ui-primary);
  --wf-brand-hover: var(--wf-ui-primary-hover);
  --wf-brand-subtle: var(--wf-ui-primary-soft);
  --wf-success: var(--wf-ui-positive);
  --wf-warn: var(--wf-ui-warning);
  --wf-danger: var(--wf-ui-danger);
  --wf-radius: var(--wf-ui-radius-lg);
  --wf-radius-sm: var(--wf-ui-radius-sm);
  --wf-shadow: var(--wf-ui-shadow);
  --tag-accent: var(--wf-ui-primary);
  --tag-accent-hover: var(--wf-ui-primary-hover);
  --tag-accent-bg: var(--wf-ui-primary-soft);
  --tag-border: var(--wf-ui-line);
  --tag-border-hover: var(--wf-ui-line-strong);
  --tag-text: var(--wf-ui-ink);
  --tag-text-secondary: var(--wf-ui-muted);
  --tag-surface: var(--wf-ui-surface);
  --tag-radius: var(--wf-ui-radius-md);
}

/* Baseline: compact enough for daily office use, not tiny or decorative. */
form.wf-ui {
  font-family: var(--wf-ui-font);
  color: var(--wf-ui-ink);
  font-size: .925rem;
  line-height: 1.55;
  accent-color: var(--wf-ui-primary);
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}
.wf-ui,
.wf-ui *,
.wf-ui *::before,
.wf-ui *::after { box-sizing: border-box; }
.wf-ui :where(.form-item, .form-wrapper, .js-form-wrapper, .fieldset, .details-wrapper, .claro-details, .field--widget-entity-reference-autocomplete) {
  min-width: 0;
}
.wf-ui :where(.form-item, .js-form-item) {
  margin-block: 0 16px;
}
.wf-ui :where(label:not(.option), .form-item__label:not(.option), .fieldset__label, .field-group-fieldset > legend) {
  color: var(--wf-ui-ink);
  font-size: .86rem;
  font-weight: 670;
  letter-spacing: -.006em;
  line-height: 1.4;
}
.wf-ui :where(label:not(.option), .form-item__label:not(.option)) {
  margin-bottom: 7px;
}
.wf-ui :where(.form-required, .form-item__label.form-required)::after { color: var(--wf-ui-danger); }
.wf-ui :where(.description, .form-item__description, .fieldset__description, .form-text, small) {
  color: var(--wf-ui-muted);
  font-size: .79rem;
  line-height: 1.52;
  max-width: 92ch;
}
.wf-ui :where(.description, .form-item__description) { margin-top: 6px; }
.wf-ui :where(.description, .form-item__description) a { text-decoration: underline; text-underline-offset: 2px; }

/* Leave native control semantics intact. No custom faux checkboxes/selects. */
.wf-ui :where(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="password"], select, textarea) {
  font: inherit;
  font-size: .9rem;
  line-height: 1.35;
  color: var(--wf-ui-ink);
  background-color: var(--wf-ui-surface);
  border: 1px solid var(--wf-ui-line-strong);
  border-radius: var(--wf-ui-radius-sm);
  min-height: 44px;
  max-width: 100%;
  padding: 10px 12px;
  transition: border-color 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}
.wf-ui :where(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="search"], input[type="password"], select, textarea) {
  width: min(100%, 620px);
}
.wf-ui :where(input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"]) {
  width: min(100%, 230px);
}
.wf-ui textarea { min-height: 105px; resize: vertical; }
.wf-ui input::placeholder,
.wf-ui textarea::placeholder { color: var(--wf-ui-hint); opacity: 1; }
.wf-ui :where(input, textarea, select):hover:not(:disabled):not([readonly]) {
  border-color: #8ea3c3;
}
.wf-ui :where(input, textarea, select):disabled {
  opacity: 1;
  color: #526078;
  background: #eef2f7;
  border-color: #d8e1ed;
  cursor: not-allowed;
}
.wf-ui :where(input, textarea):read-only:not([type="checkbox"]):not([type="radio"]):not([type="submit"]) {
  background-color: #f4f6fa;
}
.wf-ui :where(input, textarea, select, button, a.button, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--wf-ui-focus);
  outline-offset: 2px;
}
.wf-ui :where(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="password"], select, textarea):focus-visible {
  border-color: var(--wf-ui-primary);
  box-shadow: 0 0 0 3px var(--wf-ui-primary-soft);
}
.wf-ui :where(input, textarea, select)[aria-invalid="true"],
.wf-ui .form-item--error :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
.wf-ui .error :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  border-color: var(--wf-ui-danger);
  background-color: #fffafa;
}
.wf-ui :where(.form-item--error-message, .form-item__error-message) {
  color: var(--wf-ui-danger);
  font-size: .8rem;
  font-weight: 580;
  margin-top: 5px;
}
.wf-ui :where(.form-type--checkbox, .form-type--radio) { margin-block: 6px 12px; }
.wf-ui :where(input[type="checkbox"], input[type="radio"]) {
  flex: 0 0 auto;
  min-width: 19px;
  width: 19px;
  min-height: 19px;
  height: 19px;
  margin: 0 7px 0 1px;
  vertical-align: -.24em;
  accent-color: var(--wf-ui-primary);
  cursor: pointer;
}
.wf-ui :where(.form-type--checkbox label, .form-type--radio label, label.option) {
  cursor: pointer;
  color: var(--wf-ui-copy);
  font-size: .9rem;
  line-height: 1.5;
  font-weight: 520;
}
.wf-ui :where(.form-checkboxes, .form-radios) > :where(.form-item, .js-form-item) { margin: 5px 0 11px; }
.wf-ui .form-type--checkbox .description { margin-left: 27px; }

/* File/upload and autocomplete styles preserve contributed widget behaviors. */
.wf-ui input[type="file"] { max-width: 100%; font: inherit; font-size: .86rem; }
.wf-ui input[type="file"]::file-selector-button {
  border-radius: var(--wf-ui-radius-xs);
  border: 1px solid var(--wf-ui-line-strong);
  background: #f4f6fb;
  color: var(--wf-ui-copy);
  padding: 8px 12px;
  margin-right: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.wf-ui .chosen-container { max-width: 100%; font-family: var(--wf-ui-font); }
.wf-ui .chosen-container :where(input[type="text"],input[type="search"]) {
  min-height: 0;
  width: auto;
  padding: 0 4px;
  border: 0;
  outline: 0;
  box-shadow: none;
}
.wf-ui :where(.form-managed-file, .form-item--managed-file, .js-form-managed-file) { max-width: 100%; }
.wf-ui .form-managed-file :where(input[type="file"], .form-file) { max-width: 100%; }
.wf-ui .form-item input.form-autocomplete { background-repeat: no-repeat; }

/* Existing Drupal fieldsets/details become consistent sections, never reparented. */
.wf-ui :where(fieldset, .fieldset, details, .claro-details) { min-width: 0; }
.wf-ui .wf-ui-section,
.wf-ui :where(.fieldset, fieldset, details, .claro-details):not(.wf-ui-section):not(.ta-reg-level) {
  background: var(--wf-ui-surface);
  border: 1px solid var(--wf-ui-line);
  border-radius: var(--wf-ui-radius-md);
  box-shadow: 0 1px 3px rgba(24, 43, 76, .03);
  margin-block: 0 17px;
}
.wf-ui :where(fieldset, .fieldset) > legend,
.wf-ui :where(details, .claro-details) > summary {
  color: var(--wf-ui-ink);
  font-size: .98rem;
  font-weight: 720;
  line-height: 1.4;
}
.wf-ui :where(details, .claro-details) > summary {
  cursor: pointer;
  border-radius: var(--wf-ui-radius-sm);
  padding: 14px 18px;
  min-height: 44px;
}
.wf-ui :where(details, .claro-details) > summary:hover { background: var(--wf-ui-surface-soft); }
.wf-ui :where(details, .claro-details)[open] > summary { border-bottom: 1px solid var(--wf-ui-line); }
.wf-ui :where(details, .claro-details) > :where(.details-wrapper, .claro-details__wrapper) { padding: 16px 18px; }
.wf-ui .wf-ui-section > :where(.form-item, .form-wrapper, .js-form-item) { margin-bottom: 16px; }
.wf-ui :where(fieldset, .fieldset) .fieldset__wrapper,
.wf-ui :where(fieldset, .fieldset) .fieldset-wrapper { min-width: 0; }
/* Two short inputs side by side only in audited fieldset groups. */
@media (min-width: 760px) {
  .wf-ui .wf-ui-section-grid > .fieldset__wrapper,
  .wf-ui .wf-ui-section-grid > .fieldset-wrapper,
  .wf-ui .wf-ui-section-grid > .details-wrapper,
  .wf-ui fieldset.wf-ui-section-grid > .fieldset__wrapper {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 22px;
    align-items: start;
  }
  .wf-ui .wf-ui-section-grid > :where(.fieldset__wrapper, .fieldset-wrapper) > :where(.description, .fieldset__description) { grid-column: 1 / -1; }
}
.wf-ui .wf-ui-danger-section { border-color: #efb8c1 !important; }
.wf-ui .wf-ui-danger-section > summary { color: var(--wf-ui-danger); }
.wf-ui .wf-ui-danger-section :where(.description, .form-item__description) { color: #674650; }

/* Small, high-trust forms: one readable card and a clear action area. */
.wf-ui--confirm:not(.wf-saas-compact-form),
.wf-ui--approval:not(.wf-saas-compact-form),
.wf-ui--compact:not(.wf-saas-compact-form) {
  max-width: 840px;
  padding: clamp(16px, 2.3vw, 26px);
  margin-block: 14px 24px;
  border: 1px solid var(--wf-ui-line);
  border-radius: var(--wf-ui-radius-lg);
  background: var(--wf-ui-surface);
  box-shadow: var(--wf-ui-shadow);
}
.wf-ui--confirm > :where(.form-item, .form-wrapper),
.wf-ui--approval > :where(.form-item, .form-wrapper) { max-width: 100%; }
.wf-ui--approval :where(input[type="datetime-local"], .form-type--datetime) { max-width: 100%; }
.wf-ui--destructive { --wf-ui-primary: var(--wf-ui-danger); --wf-ui-primary-hover: var(--wf-ui-danger-hover); }
.wf-ui--destructive .form-actions :where(input[type="submit"],button[type="submit"],.button--primary) {
  background: var(--wf-ui-danger);
  border-color: var(--wf-ui-danger);
  color: #fff;
}
.wf-ui--destructive .form-actions :where(input[type="submit"],button[type="submit"],.button--primary):hover {
  background: var(--wf-ui-danger-hover);
  border-color: var(--wf-ui-danger-hover);
}
.wf-ui--destructive :is(.form-actions a, .form-actions .button):not([type="submit"]) {
  --wf-ui-primary: #244ab7;
}

/* Global form actions: primary CTA visually distinct, never sticky over data. */
.wf-ui :where(.form-actions, .form-wrapper.form-actions) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 18px 0 10px;
}
.wf-ui :where(input[type="submit"], button, a.button, .button, input[type="button"], input[type="reset"]) {
  font-family: var(--wf-ui-font);
  font-weight: 650;
  letter-spacing: 0;
  border-radius: var(--wf-ui-radius-sm);
  min-height: 42px;
  padding: 9px 17px;
  max-width: 100%;
  box-shadow: none;
  transition: border-color 130ms ease, background-color 130ms ease, color 130ms ease;
}
.wf-ui :where(input[type="submit"], button, a.button, .button, input[type="button"], input[type="reset"]):disabled,
.wf-ui :where(.is-disabled, [aria-disabled="true"]) {
  cursor: not-allowed;
  opacity: .65;
}
.wf-ui :where(input[type="submit"], button, .button, input[type="button"], input[type="reset"]):not(.button--primary):not(.wf-danger-action) {
  border: 1px solid var(--wf-ui-line-strong);
  background: var(--wf-ui-surface);
  color: var(--wf-ui-copy);
}
.wf-ui :where(input[type="submit"], button, .button, input[type="button"], input[type="reset"]):not(.button--primary):not(.wf-danger-action):hover:not(:disabled) {
  background: var(--wf-ui-surface-soft);
  border-color: #9ab0d1;
}
.wf-ui :where(input[type="submit"],button,.button).button--primary,
.wf-ui :where(input[type="submit"],button).wf-ui-primary-action {
  background: var(--wf-ui-primary);
  color: white;
  border: 1px solid var(--wf-ui-primary);
}
.wf-ui :where(input[type="submit"],button,.button).button--primary:hover:not(:disabled),
.wf-ui :where(input[type="submit"],button).wf-ui-primary-action:hover:not(:disabled) {
  background: var(--wf-ui-primary-hover);
  border-color: var(--wf-ui-primary-hover);
}
.wf-ui .wf-danger-action,
.wf-ui :where(button,input[type="submit"]).wf-danger-action {
  color: var(--wf-ui-danger);
  border-color: #efbcc4;
  background: var(--wf-ui-danger-bg);
}
.wf-ui .wf-danger-action:hover:not(:disabled) { background: #ffe2e7; border-color: #de8999; }
.wf-ui :where(.form-actions, .tag-filter-bar) a:not(.button) { font-weight: 610; }

/* Human-scale settings pages, filter toolbars and device-management tables. */
.wf-ui--settings { max-width: 1180px; }
.wf-ui--settings > :where(.form-item, .form-wrapper):not(.form-actions):not(.wf-page-intro):not(.wf-panel):not(.wf-ui-section) { margin-bottom: 17px; }
.wf-ui--people { max-width: 1230px; }
.wf-ui--queue { max-width: 100%; }
.wf-ui .wf-ui-toolbar {
  border: 1px solid var(--wf-ui-line);
  border-radius: var(--wf-ui-radius-md);
  padding: clamp(12px, 1.6vw, 19px);
  margin-block: 0 16px;
  background: var(--wf-ui-surface);
  box-shadow: var(--wf-ui-shadow);
}
.wf-ui--queue .wf-ui-toolbar :where(.form-item, .js-form-item, .form-actions) { margin: 0; }
.wf-ui--queue .wf-ui-toolbar :where(input[type="text"], input[type="search"], select) { width: 100%; }
.wf-ui--queue .wf-ui-toolbar.tag-filter-bar { margin-block: 0 16px; }
.wf-ui--queue .wf-ui-toolbar.tag-filter-row { gap: 11px; }
.wf-ui--queue .wf-ui-toolbar.tag-bulk { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.wf-ui--queue .wf-ui-toolbar.tag-bulk :where(.form-item, select) { width: min(100%, 320px); }
.wf-ui--queue .tag-btn { border-radius: var(--wf-ui-radius-sm) !important; font-size: .85rem !important; }
.wf-ui--queue .tag-table { font-size: .83rem; }

/* Accessible overflow for real tables, including tableselect and editable rows. */
.wf-ui .wf-ui-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  background: white;
  border: 1px solid var(--wf-ui-line);
  border-radius: var(--wf-ui-radius-md);
  margin-block: 10px 17px;
  scrollbar-width: thin;
}
.wf-ui .wf-ui-table-scroll:focus-visible { outline: 3px solid var(--wf-ui-focus); outline-offset: 2px; }
.wf-ui .wf-ui-table-scroll > table { width: 100%; min-width: 600px; margin: 0; }
.wf-ui .wf-ui-table-scroll table :where(th, td) { vertical-align: middle; overflow-wrap: anywhere; }
.wf-ui .wf-ui-table-scroll table :where(th) {
  white-space: normal;
  color: var(--wf-ui-copy);
  background: var(--wf-ui-surface-soft);
  font-size: .79rem;
}
.wf-ui .wf-ui-table-scroll table :where(td) { font-size: .84rem; }
.wf-ui .wf-ui-table-scroll input[type="checkbox"] { width: 19px; }
.wf-ui .wf-ui-table-scroll .form-item { margin-bottom: 0; }
.wf-ui :where(.pager, .pager__items) { max-width: 100%; }

/* The registration and onboarding form has its own step logic and branded
 * structure. Harmonize the primitives without reflowing its AJAX wrappers. */
.wf-ui--auth { max-width: 580px; }
.wf-ui--auth :where(.form-item, .form-wrapper) { max-width: 100%; }
.wf-ui--wizard,
.wf-ui--onboarding { --wf-ui-radius-md: 13px; }
.wf-ui--wizard :where(.ta-reg-wizard, .ta-reg-wizard-form, .ta-reg-step),
.wf-ui--onboarding :where(.ta-onboarding-card, .ta-reg-step) { max-width: 100%; }
.wf-ui--wizard :where(.ta-reg-actions, .form-actions) { min-width: 0; }
.wf-ui--wizard :where(input, select, textarea) { font-size: max(16px, 1rem); }
.wf-ui--account :where(.form-wrapper, .field--type-entity-reference) { max-width: 100%; }
.wf-ui--entity :where(.field--type-entity-reference, .field--type-datetime, .field--widget-entity-reference-autocomplete) { max-width: 100%; }


/* Assignment-filter / attendance Views exposed forms, never global Views UI. */
.wf-ui--filter {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 14px;
  width: 100%;
  max-width: 100%;
  padding: clamp(12px, 1.5vw, 18px);
  background: var(--wf-ui-surface);
  border: 1px solid var(--wf-ui-line);
  border-radius: var(--wf-ui-radius-md);
  box-shadow: var(--wf-ui-shadow);
  margin-block: 10px 18px;
}
.wf-ui--filter > :where(.form-item, .form-wrapper):not(.form-actions) { flex: 1 1 185px; margin: 0; }
.wf-ui--filter > .form-actions { margin: 0; }
.wf-ui--filter :where(input[type="text"],input[type="search"],select) { width: 100%; }

/* Progressive enhancements: character count and standard Drupal AJAX states. */
.wf-ui .wf-ui-char-count {
  display: block;
  margin-top: 5px;
  color: var(--wf-ui-muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  max-width: min(100%, 620px);
}
.wf-ui .wf-ui-char-count--near { color: var(--wf-ui-warning); font-weight: 650; }
.wf-ui :where(.ajax-progress, .ajax-progress-throbber) { color: var(--wf-ui-muted); font-size: .8rem; }
.wf-ui :where(.ajax-progress-throbber .throbber, .ajax-progress .throbber) { vertical-align: middle; }
.wf-ui :where(.messages, .form-item--error-message) { max-width: 100%; overflow-wrap: anywhere; }
.wf-ui :where(.messages--error, .messages--warning) { border-left-width: 4px; }

/* Reduced density on tablets; a usable single-column mobile canvas. */
@media (max-width: 950px) {
  .wf-ui .wf-ui-toolbar { padding: 13px; }
  .wf-ui--settings { max-width: 100%; }
}
@media (max-width: 700px) {
  form.wf-ui { font-size: .9rem; }
  .wf-ui :where(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="password"], input[type="search"], select, textarea) { width: 100%; }
  .wf-ui :where(input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"]) { max-width: 100%; }
  .wf-ui :where(details, .claro-details) > summary { padding: 13px 14px; }
  .wf-ui :where(details, .claro-details) > :where(.details-wrapper, .claro-details__wrapper) { padding: 12px 14px; }
  .wf-ui--queue .wf-ui-toolbar { display: flex; flex-wrap: wrap; gap: 9px; }
  .wf-ui--queue .wf-ui-toolbar > :where(.form-item, .form-wrapper) { flex: 1 1 175px; }
  .wf-ui .wf-ui-table-scroll > table { min-width: 600px; }
  /* Prevent iOS Safari input-focus zoom for all site and WebView forms. */
  .wf-ui :where(input[type="text"],input[type="email"],input[type="tel"],input[type="url"],input[type="password"],input[type="search"],input[type="number"],input[type="date"],input[type="time"],select,textarea) { font-size: 16px; }
}
@media (max-width: 440px) {
  .wf-ui :where(.form-actions, .form-wrapper.form-actions) { align-items: stretch; }
  .wf-ui :where(.form-actions, .form-wrapper.form-actions) > :where(.button, .form-submit, button) { flex: 1 1 auto; }
  .wf-ui :where(input[type="submit"],button,.button) { white-space: normal; overflow-wrap: anywhere; }
  .wf-ui :where(.fieldset, fieldset) { max-width: 100%; }
  .wf-ui .wf-ui-table-scroll { border-radius: 10px; }
  .wf-ui--queue .wf-ui-toolbar > :where(.form-item, .form-wrapper) { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .wf-ui :where(input, textarea, select, button, a.button, .button),
  .wf-ui :where(details, summary) { transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  .wf-ui { --wf-ui-line-strong: #697a92; --wf-ui-line: #aebcd1; }
  .wf-ui :where(input, textarea, select):focus-visible { outline: 3px solid #1445b7; }
}
