/* Legacy markup in the prototype look — token-based, no markup changes needed.
   Loaded last; !important only where site.css/custom.css already use it. */

/* ==== Grids (GridDefaultStyleBootstrap adds .data-table and the .table-card wrapper) ==== */
.table-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-xs); }
.table-scroll { overflow-x: auto; }
.table-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border);
}
.table-footer:empty { display: none; }
.table-footer .summary { font-size: var(--fs-caption); color: var(--color-text-tertiary); margin: 0; }
.table-footer > nav, .table-footer > .pagination { margin-left: auto; }
.legacy-grid-context-line { font-size: var(--fs-caption); color: var(--color-text-tertiary); margin-bottom: var(--space-2); }
.rd-body .grid-view { margin-bottom: var(--space-5); }
.rd-body .grid-view > .summary { font-size: var(--fs-caption); color: var(--color-text-tertiary); margin-bottom: var(--space-2); }
.rd-body .grid-view > nav > .pagination, .rd-body .grid-view > .pagination { margin-top: var(--space-3); }

.rd-body table.data-table { width: 100%; margin: 0; border-collapse: collapse; font-size: var(--fs-table); color: var(--color-text-primary); }
.rd-body table.data-table > :not(caption) > * { border-width: 0; }
.rd-body table.data-table > :not(caption) > * > * {
  padding: var(--space-3) var(--space-4); border-width: 0 0 1px; border-style: solid; border-color: var(--color-border);
  background-color: transparent; box-shadow: none; vertical-align: middle;
}
.rd-body table.data-table > thead > tr > th {
  background: var(--color-surface-secondary); color: var(--color-text-secondary);
  font-weight: var(--fw-semibold); text-align: left; white-space: nowrap; line-height: var(--lh-tight);
}
.rd-body .grid-wrap-headers table.data-table > thead > tr > th { white-space: normal; }
/* custom.css paints .grid-view table.items th with !important. */
.rd-body .grid-view table.data-table > thead > tr > th { background-color: var(--color-surface-secondary) !important; background-image: none !important; }
.rd-body table.data-table > thead > tr > th a { color: inherit; text-decoration: none; }
.rd-body table.data-table > thead > tr > th a:hover { color: var(--color-text-primary); }
.rd-body table.data-table > thead > tr > th a.asc::after,
.rd-body table.data-table > thead > tr > th a.desc::after { margin-left: 6px; opacity: 0.7; }
.rd-body table.data-table > thead > tr > th a.asc::after { border-bottom-color: currentColor; }
.rd-body table.data-table > thead > tr > th a.desc::after { border-top-color: currentColor; }
.rd-body table.data-table > tbody > tr { transition: background-color var(--duration-fast); }
.rd-body table.data-table > tbody > tr:hover > td { background-color: var(--color-surface-hover); }
.rd-body table.data-table > tbody > tr:last-child > td { border-bottom: 0; }
.rd-body table.data-table > tbody > tr.selected > td { background-color: var(--color-primary-surface); }
.rd-body table.data-table td .empty, .rd-body .grid-view .empty { display: block; padding: var(--space-8) var(--space-4); text-align: center; color: var(--color-text-tertiary); }
.rd-body table.data-table input[type="checkbox"] { float: none; margin: 0 !important; accent-color: var(--color-primary); width: 16px; height: 16px; vertical-align: middle; }

/* Filter row */
.rd-body table.data-table > thead > tr.filters > td,
.rd-body table.data-table > thead > tr.filters > th { background: var(--color-surface); padding: var(--space-2) var(--space-3); }
.rd-body table.data-table tr.filters :is(input, select) {
  width: 100%; min-width: 70px; height: 32px; min-height: 32px; padding: 0 var(--space-2);
  font-size: var(--fs-caption); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  background-color: var(--color-surface); color: var(--color-text-primary); margin: 0;
}
.rd-body table.data-table tr.filters :is(input, select):focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); outline: none; }
.rd-body table.data-table tr.filters .select2-container { margin: 0; }

/* Compact grids (wide column sets) */
.rd-body #view-full-batch-labour-grid table.data-table > :not(caption) > * > * { padding: var(--space-2); }
.rd-body #view-full-batch-labour-grid table.data-table > thead > tr.filters > * { padding: var(--space-1) var(--space-2); }
.rd-body #view-full-batch-labour-grid table.data-table tr.filters :is(input, select) { min-width: 50px; }

/* Action column: ghost icon buttons (GridDefaultButtonClassBootstrap / UiActionIcon) */
.rd-body table.data-table td.col-actions, .rd-body table.data-table th.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.rd-body .grid-view .action-column a.icon-btn,
.rd-body table.data-table a.icon-btn { margin: 0 1px; color: var(--color-text-secondary) !important; text-decoration: none; }
.rd-body table.data-table a.icon-btn:hover { color: var(--color-text-primary) !important; }
.rd-body table.data-table a.icon-btn.delete:hover { color: var(--color-error) !important; background: var(--color-error-surface); }
.rd-body .grid-view .action-column a.btn-action { color: var(--color-text-secondary) !important; }
.rd-body .grid-view .action-column a.btn-action.icon-btn { padding: 0 !important; margin: 0 1px !important; }
.rd-body .grid-view img.smallIcon, .rd-body .grid-view .action-column img { width: 16px; height: 16px; vertical-align: middle; }

/* Row status (warnCss). Colour + the existing text; kept !important like site.css/custom.css. */
.rd-body tr.actionRequired > td, .rd-body tr.actionRequired > td a { color: var(--color-error) !important; }
.rd-body tr.warning > td, .rd-body tr.warning > td a { color: var(--color-warning) !important; }
.rd-body tr.earlyWarning > td, .rd-body tr.earlyWarning > td a { color: var(--color-info) !important; }
.rd-body tr.ready > td, .rd-body tr.ready > td a { color: var(--color-success) !important; }
.rd-body tr.odd > td, .rd-body tr.even > td { background-color: transparent; }

/* ==== Detail views (DetailView / LegacyCDetailView) — label/value look ==== */
.rd-body table.detail-view {
  width: 100%; margin-bottom: var(--space-5); border-collapse: separate; border-spacing: 0;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  font-size: var(--fs-body); --bs-table-striped-bg: transparent; --bs-table-bg: transparent;
}
.rd-body table.detail-view > tbody > tr > th,
.rd-body table.detail-view > tbody > tr > td {
  padding: var(--space-3) var(--space-4); border: 0; border-bottom: 1px solid var(--color-border);
  background: transparent; box-shadow: none; vertical-align: top; text-align: left;
}
.rd-body table.detail-view > tbody > tr:last-child > th,
.rd-body table.detail-view > tbody > tr:last-child > td { border-bottom: 0; }
.rd-body table.detail-view > tbody > tr > th {
  width: 34%; color: var(--color-text-tertiary); font-size: 11px; font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.6;
}
.rd-body table.detail-view > tbody > tr > td { color: var(--color-text-primary); line-height: 1.5; }
.rd-body table.detail-view .not-set, .rd-body .not-set { color: var(--color-text-tertiary); font-style: italic; }

/* ==== Portlets (raw markup; LegacyCPortlet itself now emits .card) ==== */
.rd-body .portlet {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); margin-bottom: var(--space-5);
}
.rd-body .portlet-decoration {
  display: flex; align-items: center; gap: var(--space-2);
  background: transparent; color: var(--color-text-primary); border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-5);
}
.rd-body .portlet-title { font-size: var(--fs-card-title); font-weight: var(--fw-semibold); color: var(--color-text-primary); display: flex; align-items: center; gap: var(--space-2); }
.rd-body .portlet-title img { width: 18px; height: 18px; object-fit: contain; }
.rd-body .portlet-content { padding: var(--space-5); }
.rd-body .card.portlet > .card-body > ul.operations, .rd-body .portlet-content ul.operations { list-style: none; margin: 0; padding: 0; }

/* ==== Bootstrap 2 fluid grid (row-fluid / spanN) — zero specificity so page rules in site.css win ==== */
:where(.rd-body .row-fluid)::after { content: ""; display: table; clear: both; }
:where(.rd-body .row-fluid > [class*="span"]) { float: left; box-sizing: border-box; min-height: 1px; }
:where(.rd-body .row-fluid > [class*="span"] + [class*="span"]) { margin-left: 2.12765957%; }
:where(.rd-body .row-fluid > .span1) { width: 6.38297872%; }
:where(.rd-body .row-fluid > .span2) { width: 14.89361702%; }
:where(.rd-body .row-fluid > .span3) { width: 23.40425532%; }
:where(.rd-body .row-fluid > .span4) { width: 31.91489362%; }
:where(.rd-body .row-fluid > .span5) { width: 40.42553191%; }
:where(.rd-body .row-fluid > .span6) { width: 48.93617021%; }
:where(.rd-body .row-fluid > .span7) { width: 57.44680851%; }
:where(.rd-body .row-fluid > .span8) { width: 65.95744681%; }
:where(.rd-body .row-fluid > .span9) { width: 74.46808511%; }
:where(.rd-body .row-fluid > .span10) { width: 82.97872340%; }
:where(.rd-body .row-fluid > .span11) { width: 91.48936170%; }
:where(.rd-body .row-fluid > .span12) { width: 100%; margin-left: 0; }
@media (max-width: 767.98px) {
  .rd-body .row-fluid > [class*="span"] { float: none; width: 100%; margin-left: 0; }
  .rd-body .row-fluid > [class*="span"] + [class*="span"] { margin-top: var(--space-3); }
}

/* ==== Legacy forms (Yii1-style .form/.row markup and bare inputs) ==== */
body.rd-body :where(
  input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"],
  input[type="tel"], input[type="url"], input[type="date"], input[type="datetime-local"], input[type="time"],
  input[type="month"], input[type="week"], select, textarea
):where(:not(.form-control, .form-select, .input, .select, .textarea, .select2-search__field, .rd-chrome *)) {
  max-width: 100%; padding: var(--space-2) var(--space-3);
  font-family: inherit; font-size: var(--fs-body); line-height: 1.4; color: var(--color-text-primary);
  background-color: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
body.rd-body :where(input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"],
  input[type="tel"], input[type="url"], input[type="date"], input[type="datetime-local"], input[type="time"], select:not([multiple]):not([size]))
  :where(:not(.form-control, .form-select, .input, .select, .select2-search__field, .rd-chrome *)) { min-height: 38px; }
body.rd-body :where(input, select, textarea):where(:not(.rd-chrome *)):hover:not(:disabled):not([readonly]) { border-color: var(--color-text-tertiary); }
body.rd-body :where(input, select, textarea):where(:not(.rd-chrome *, [type="checkbox"], [type="radio"])):focus {
  outline: none; border-color: var(--color-primary); box-shadow: var(--focus-ring);
}
body.rd-body :where(input, select, textarea):where(:disabled, [readonly]):where(:not(.date-input, .rd-chrome *, [type="checkbox"], [type="radio"])) {
  background-color: var(--color-surface-secondary); color: var(--color-text-secondary);
}
body.rd-body :where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--color-primary); }
body.rd-body :where(input, textarea)::placeholder { color: var(--color-text-tertiary); }

body.rd-body :where(.form, .form-group, .ui-dialog-content, .wide.form) label:where(:not(.form-check-label, .btn)),
body.rd-body :where(.form .row, .control-group) > label {
  font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--color-text-secondary);
}
.rd-body .note, .rd-body p.note { font-size: var(--fs-caption); color: var(--color-text-tertiary); margin-bottom: var(--space-4); }
.rd-body span.required, .rd-body .required-mark { color: var(--color-error); }
.rd-body .errorMessage, .rd-body .help-block-error, .rd-body .has-error .help-block { color: var(--color-error); font-size: var(--fs-caption); }
.rd-body .help-block, .rd-body .hint { font-size: var(--fs-caption); color: var(--color-text-tertiary); }
.rd-body .has-error :is(input, select, textarea), .rd-body :is(input, select, textarea).error { border-color: var(--color-error) !important; }
.rd-body .has-error > label, .rd-body label.error { color: var(--color-error); }
.rd-body .has-success :is(input, select, textarea) { border-color: var(--color-success); }
.rd-body .errorSummary, .rd-body .error-summary {
  height: auto; padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4);
  background: var(--color-error-surface); color: var(--color-text-primary);
  border: 1px solid var(--color-error); border-radius: var(--radius-md); font-size: var(--fs-label);
}
.rd-body .errorSummary p, .rd-body .error-summary p { margin: 0 0 var(--space-1); font-weight: var(--fw-semibold); color: var(--color-error); }
.rd-body .errorSummary ul, .rd-body .error-summary ul { margin: 0; padding-left: var(--space-5); }
.rd-body .form .buttons, .rd-body .form .row.buttons, .rd-body .form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }

/* Native date inputs still present on unmigrated views */
body.rd-body input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }
[data-theme='dark'] body.rd-body input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }

/* ==== Date picker (LegacyCJuiDatePicker → .date-field, app.js) ==== */
.date-field { position: relative; display: block; }
.date-field .date-input { cursor: pointer; padding-right: 36px !important; width: 100%; }
.date-field .date-input:disabled { cursor: not-allowed; }
.date-field .date-input.is-locked { cursor: default; background-color: var(--color-surface-secondary); color: var(--color-text-secondary); }
.date-field-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--color-text-tertiary); pointer-events: none; display: flex; }
.date-picker-popover {
  position: fixed; top: 0; left: 0; z-index: 100000; /* above jQuery UI 1.8 modal overlay (maxZ from 10500), which swallows mousedown on anything lower */
  width: 272px; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--space-3);
  opacity: 0; transform: translateY(-4px) scale(0.98); pointer-events: none; visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard), visibility 0s linear var(--duration-fast);
}
.date-picker-popover.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; visibility: visible; transition-delay: 0s; }
.date-picker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.date-picker-label { font-size: var(--fs-label); font-weight: var(--fw-semibold); color: var(--color-text-primary); display: flex; gap: 4px; }
.date-picker-select {
  height: 26px; min-height: 0; width: auto; min-width: 0; padding: 0 20px 0 6px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background-color: var(--color-surface); color: var(--color-text-primary); font: inherit; cursor: pointer;
}
.date-picker-select:hover { background-color: var(--color-surface-hover); }
.date-picker-nav { width: 26px; height: 26px; border: 0; background: none; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--color-text-secondary); cursor: pointer; padding: 0; }
.date-picker-nav:hover { background: var(--color-surface-hover); }
.date-picker-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 4px; }
.date-picker-weekdays span { font-size: 11px; font-weight: var(--fw-semibold); color: var(--color-text-tertiary); }
.date-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.date-picker-day {
  height: 30px; border: 0; background: none; padding: 0; border-radius: var(--radius-sm); font-size: var(--fs-caption);
  color: var(--color-text-primary); display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
span.date-picker-day { cursor: default; }
button.date-picker-day:hover { background: var(--color-surface-hover); }
.date-picker-day.is-muted { color: var(--color-text-tertiary); }
.date-picker-day.is-today:not(.is-selected) { font-weight: var(--fw-bold); color: var(--color-primary); }
.date-picker-day.is-selected { background: var(--color-primary); color: var(--color-on-primary); font-weight: var(--fw-medium); }
.date-picker-footer { display: flex; justify-content: space-between; margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--color-border); }
.date-picker-footer button { font-size: var(--fs-caption); color: var(--color-primary); font-weight: var(--fw-medium); padding: 4px 6px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; }
.date-picker-footer button:hover { background: var(--color-surface-hover); }
@media (max-width: 575.98px) { .date-picker-popover { width: min(272px, calc(100vw - 32px)); } }

/* ==== jQuery UI (openDialog dialogs, datepicker, autocomplete) — custom.css forces its colours with !important ==== */
.rd-body .ui-widget { font-family: var(--font-sans); font-size: var(--fs-body); }
.rd-body .ui-widget :is(input, select, textarea, button) { font-family: var(--font-sans); font-size: var(--fs-body); }
.rd-body .ui-widget-overlay { background: rgb(6, 12, 24) !important; opacity: 0.5 !important; filter: none; backdrop-filter: blur(2px); }
.rd-body .ui-dialog.ui-widget-content {
  padding: 0; background: var(--color-surface) !important; color: var(--color-text-primary);
  border: 1px solid var(--color-border) !important; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  overflow: hidden; max-width: calc(100vw - 32px);
}
.rd-body .ui-dialog .ui-dialog-titlebar.ui-widget-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); margin: 0; border: 0 !important; border-bottom: 1px solid var(--color-border) !important;
  border-radius: 0; background: var(--color-surface) !important; color: var(--color-text-primary) !important;
}
.rd-body .ui-dialog .ui-dialog-title { float: none; margin: 0; font-size: var(--fs-section-title); font-weight: var(--fw-semibold); line-height: var(--lh-tight); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-body .ui-dialog .ui-dialog-titlebar-close {
  position: static; flex-shrink: 0; width: 32px; height: 32px; margin: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0 !important; border-radius: var(--radius-md); background: transparent !important; color: var(--color-text-secondary);
}
.rd-body .ui-dialog .ui-dialog-titlebar-close:hover { background: var(--color-surface-hover) !important; color: var(--color-text-primary); }
.rd-body .ui-dialog .ui-dialog-titlebar-close .ui-icon {
  position: static; margin: 0; width: 18px; height: 18px; background: currentColor !important; text-indent: -9999px; overflow: hidden;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / 18px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / 18px no-repeat;
}
.rd-body .ui-dialog .ui-dialog-content.ui-widget-content {
  padding: var(--space-5); border: 0 !important; background: var(--color-surface) !important; color: var(--color-text-primary);
}
.rd-body .ui-dialog .ui-dialog-buttonpane {
  margin: 0; padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface);
  display: flex; justify-content: flex-end;
}
.rd-body .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: none; display: flex; gap: var(--space-2); }
.rd-body .ui-dialog .ui-dialog-buttonpane button { margin: 0; }
.rd-body .ui-button, .rd-body .ui-widget-content .ui-button.ui-state-default, .rd-body .ui-dialog .ui-dialog-buttonpane button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 var(--space-4);
  font-size: var(--fs-label); font-weight: var(--fw-medium); border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong) !important; background: var(--color-surface) !important; color: var(--color-text-primary) !important;
}
.rd-body .ui-button:hover, .rd-body .ui-widget-content .ui-button.ui-state-hover, .rd-body .ui-dialog .ui-dialog-buttonpane button:hover { background: var(--color-surface-hover) !important; }
.rd-body .ui-button .ui-button-text { padding: 0; line-height: 1.2; }
.rd-body .ui-dialog .ui-resizable-handle { opacity: 0; }
/* Title left, X right: jQuery UI's .ui-helper-clearfix ::before/::after would be flex items and centre them. */
.rd-body .ui-dialog .ui-dialog-titlebar::before, .rd-body .ui-dialog .ui-dialog-titlebar::after,
.rd-body .ui-dialog .ui-dialog-buttonpane::before, .rd-body .ui-dialog .ui-dialog-buttonpane::after { display: none; content: none; }
.rd-body .ui-dialog .ui-dialog-title { flex: 1 1 auto; min-width: 0; width: auto; text-align: left; }
.rd-body .ui-dialog .ui-dialog-titlebar-close { margin-left: auto; }
/* Only the content scrolls: title bar and button pane stay put; the page behind is locked. */
.rd-body .ui-dialog.ui-widget-content { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.rd-body .ui-dialog .ui-dialog-titlebar, .rd-body .ui-dialog .ui-dialog-buttonpane { flex: 0 0 auto; }
.rd-body .ui-dialog .ui-dialog-content.ui-widget-content { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
html:has(body.rd-body > .ui-widget-overlay), body.rd-body:has(> .ui-widget-overlay) { overflow: hidden; }
/* Bottom Save row of dialog forms sticks to the bottom of the scrolling content. */
.rd-body .ui-dialog .ui-dialog-content :is(.form-sticky-footer, .row.buttons) {
  position: sticky; bottom: calc(-1 * var(--space-5)); z-index: 5;
  margin: var(--space-5) calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface); border-top: 1px solid var(--color-border);
}
@media (max-width: 767.98px) {
  .rd-body .ui-dialog.ui-widget-content { left: 16px !important; width: calc(100vw - 32px) !important; }
}

/* jQuery UI widgets inside content/dialogs (tabs, accordion, autocomplete, datepicker) */
.rd-body .ui-widget-content { border-color: var(--color-border) !important; background: var(--color-surface); color: var(--color-text-primary); }
.rd-body .ui-widget-header { background: var(--color-surface-secondary) !important; color: var(--color-text-primary) !important; border-color: var(--color-border) !important; }
.rd-body .ui-state-default, .rd-body .ui-widget-content .ui-state-default, .rd-body .ui-widget-header .ui-state-default {
  border: 1px solid transparent !important; background: transparent !important; color: var(--color-text-primary);
}
.rd-body .ui-state-hover, .rd-body .ui-widget-content .ui-state-hover, .rd-body .ui-widget-header .ui-state-hover,
.rd-body .ui-state-focus, .rd-body .ui-widget-content .ui-state-focus { background: var(--color-surface-hover) !important; border-color: transparent !important; color: var(--color-text-primary); }
.rd-body .ui-state-active, .rd-body .ui-widget-content .ui-state-active, .rd-body .ui-widget-header .ui-state-active {
  background: var(--color-primary) !important; border-color: var(--color-primary) !important; color: var(--color-on-primary) !important;
}
.rd-body .ui-state-highlight, .rd-body .ui-widget-content .ui-state-highlight { background: var(--color-primary-surface) !important; border-color: var(--color-primary-border) !important; color: var(--color-primary) !important; }
.rd-body .ui-state-error, .rd-body .ui-widget-content .ui-state-error { background: var(--color-error-surface) !important; border-color: var(--color-error) !important; color: var(--color-error) !important; }
.rd-body .ui-autocomplete.ui-menu {
  padding: var(--space-2); border: 1px solid var(--color-border) !important; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); background: var(--color-surface); max-height: 320px; overflow-y: auto;
}
.rd-body .ui-menu .ui-menu-item a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--fs-label); line-height: 1.4; }
.rd-body .ui-datepicker { width: 272px; padding: var(--space-3); border: 1px solid var(--color-border) !important; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); background: var(--color-surface) !important; }
.rd-body .ui-datepicker .ui-datepicker-header { background: transparent !important; border: 0 !important; padding: 0 0 var(--space-2); }
.rd-body .ui-datepicker .ui-datepicker-title { font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 26px; }
.rd-body .ui-datepicker .ui-datepicker-title select { min-height: 0; height: 28px; padding: 0 var(--space-1); font-size: var(--fs-caption); }
.rd-body .ui-datepicker .ui-datepicker-prev, .rd-body .ui-datepicker .ui-datepicker-next { top: 0; border-radius: var(--radius-sm); }
.rd-body .ui-datepicker th { font-size: 11px; font-weight: var(--fw-semibold); color: var(--color-text-tertiary); }
.rd-body .ui-datepicker td a.ui-state-default { text-align: center; padding: 6px 0; border-radius: var(--radius-sm); font-size: var(--fs-caption); }
.rd-body .ui-datepicker .ui-datepicker-buttonpane { border-top: 1px solid var(--color-border); margin-top: var(--space-2); padding-top: var(--space-2); }
.rd-body .ui-datepicker .ui-datepicker-buttonpane button { min-height: 28px; padding: 0 var(--space-2); font-size: var(--fs-caption); opacity: 1; }

/* ==== appAlert / appConfirm (js/appDialogs.js) ==== */
.rd-body .app-modal-overlay { background: rgba(6, 12, 24, 0.5); backdrop-filter: blur(2px); }
.rd-body .app-modal-card {
  background: var(--color-surface); color: var(--color-text-primary); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); width: 440px; max-width: calc(100vw - 32px); overflow: hidden;
}
.rd-body .app-modal-head {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5);
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.rd-body .app-modal-error .app-modal-head { background: var(--color-surface); border-bottom-color: var(--color-border); }
.rd-body .app-modal-title { font-size: var(--fs-section-title); font-weight: var(--fw-semibold); color: var(--color-text-primary); }
.rd-body .app-modal-icon {
  width: 32px; height: 32px; border-radius: var(--radius-md); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-weight: var(--fw-bold);
  background: var(--color-primary-surface); color: var(--color-primary);
}
.rd-body .app-modal-danger .app-modal-icon, .rd-body .app-modal-error .app-modal-icon { background: var(--color-error-surface); color: var(--color-error); }
.rd-body .app-modal-warning .app-modal-icon { background: var(--color-warning-surface); color: var(--color-warning); }
.rd-body .app-modal-body { padding: var(--space-5); font-size: var(--fs-body); color: var(--color-text-secondary); line-height: var(--lh-normal); }
.rd-body .app-modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); }
.rd-body .app-modal-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 var(--space-4);
  font-size: var(--fs-label); font-weight: var(--fw-medium); border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer;
}
.rd-body .app-modal-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.rd-body .app-modal-btn-primary { background: var(--color-primary); color: var(--color-on-primary); box-shadow: var(--shadow-xs); }
.rd-body .app-modal-btn-primary:hover { background: var(--color-primary-hover); }
.rd-body .app-modal-btn-danger { background: var(--color-error); color: var(--color-text-inverse); }
.rd-body .app-modal-btn-danger:hover { background: var(--red-700); }
.rd-body .app-modal-btn-secondary { background: var(--color-surface); color: var(--color-text-primary); border-color: var(--color-border-strong); }
.rd-body .app-modal-btn-secondary:hover { background: var(--color-surface-hover); }
.rd-body .app-modal-choices { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.rd-body .app-modal-choices:first-child { margin-top: 0; }
.rd-body .app-modal-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: var(--space-3) var(--space-4);
  text-align: left; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); cursor: pointer;
}
.rd-body .app-modal-choice:hover { border-color: var(--color-primary); background: var(--color-primary-surface); }
.rd-body .app-modal-choice:focus-visible { outline: none; border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.rd-body .app-modal-choice-label { font-weight: var(--fw-semibold); color: var(--color-text-primary); }
.rd-body .app-modal-choice-hint { font-size: var(--fs-caption); color: var(--color-text-secondary); }
.rd-body .email-viewer-headers dt, .rd-body .email-viewer-size { color: var(--color-text-secondary); }
.rd-body .email-viewer-body { border-color: var(--color-border); border-radius: var(--radius-md); }
.rd-body .ui-dialog .ui-dialog-content .email-viewer-actions.form-sticky-footer { margin-top: 0; justify-content: flex-end; }
.rd-body .email-viewer-note { background: var(--color-warning-surface); border-radius: var(--radius-md); }
/* Frozen grid header (js/stickyGridHeaders.js). */
.rd-body .grid-view thead.grid-head-stuck { position: relative; z-index: 4; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12); }
.rd-body .timer-toggle .timer-label { font-variant-numeric: tabular-nums; }
.rd-body .timer-toggle.timer-active { color: var(--color-success); border-color: var(--color-success); background: var(--color-success-surface); }
.rd-body .timer-toggle.timer-overtime { color: var(--color-error); border-color: var(--color-error); background: var(--color-error-surface); }
.rd-body .app-modal-choice:disabled { opacity: .55; cursor: not-allowed; border-color: var(--color-border-strong); background: var(--color-surface); }

/* ==== Select2 4.0 ==== */
.rd-body .select2-container--default .select2-selection--single,
.rd-body .select2-container--default .select2-selection--multiple {
  min-height: 38px; background: var(--color-surface); border: 1px solid var(--color-border-strong) !important; border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.rd-body .select2-container--default .select2-selection--single { height: 38px; }
.rd-body .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 36px; padding-left: var(--space-3); padding-right: 32px; color: var(--color-text-primary); font-size: var(--fs-body); }
.rd-body .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--color-text-tertiary); }
.rd-body .select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; width: 30px; right: 2px; background: transparent !important; }
.rd-body .select2-container--default .select2-selection--single .select2-selection__arrow b { border-top-color: var(--color-text-tertiary) !important; }
.rd-body .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { border-bottom-color: var(--color-text-tertiary) !important; border-top-color: transparent !important; }
.rd-body .select2-container--default .select2-selection__clear { color: var(--color-text-tertiary); margin-right: 6px; }
.rd-body .select2-container--default.select2-container--focus .select2-selection,
.rd-body .select2-container--default.select2-container--open .select2-selection { border-color: var(--color-primary) !important; box-shadow: var(--focus-ring); }
.rd-body .select2-container--default.select2-container--disabled .select2-selection { background: var(--color-surface-secondary); }
.rd-body .select2-container--default .select2-selection--multiple .select2-selection__rendered { padding: 3px 6px; }
.rd-body .select2-container--default .select2-selection--multiple .select2-selection__choice {
  margin: 3px 4px 0 0; padding: 2px 8px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-full);
  background: var(--color-surface-secondary); color: var(--color-text-primary); font-size: var(--fs-label);
}
.rd-body .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: var(--color-text-tertiary); margin-right: 4px; }
.rd-body .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { color: var(--color-error); }
.rd-body .select2-dropdown {
  background: var(--color-surface); color: var(--color-text-primary); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden;
}
.rd-body .select2-container--open .select2-dropdown--below { margin-top: 4px; border-top: 1px solid var(--color-border); border-radius: var(--radius-md); }
.rd-body .select2-container--open .select2-dropdown--above { margin-top: -4px; border-bottom: 1px solid var(--color-border); border-radius: var(--radius-md); }
.rd-body .select2-search--dropdown { padding: var(--space-2); }
.rd-body .select2-container--default .select2-search--dropdown .select2-search__field,
.rd-body .select2-container--default .select2-search--inline .select2-search__field {
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); padding: 6px var(--space-2); background: var(--color-surface); color: var(--color-text-primary); font-size: var(--fs-label);
}
.rd-body .select2-container--default .select2-search--inline .select2-search__field { border: 0; padding: 0; margin-top: 5px; }
.rd-body .select2-results__option { padding: var(--space-2) var(--space-3); font-size: var(--fs-label); }
.rd-body .select2-results > .select2-results__options { padding: 0 var(--space-2) var(--space-2); }
.rd-body .select2-container--default .select2-results__option[aria-selected="true"] { background: var(--color-surface-secondary); color: var(--color-text-primary); }
.rd-body .select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--color-primary-surface); color: var(--color-primary); border-radius: var(--radius-sm); }
.rd-body .select2-container--default .select2-results__group { font-size: var(--fs-caption); color: var(--color-text-tertiary); padding: var(--space-2) var(--space-3); }

/* ==== Toasts: bootstrap-notify (acknowledgement-required notifications) ==== */
.rd-body [data-notify="container"] {
  display: flex !important; flex-direction: column; gap: var(--space-2);
  width: min(380px, calc(100vw - 32px)); max-width: 380px; min-width: 0; padding: var(--space-4) var(--space-5) var(--space-4) var(--space-4);
  background: var(--color-surface); color: var(--color-text-primary);
  border: 1px solid var(--color-border); border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: var(--fs-body); line-height: var(--lh-normal);
}
.rd-body [data-notify="container"].alert-danger { border-left-color: var(--color-error); }
.rd-body [data-notify="container"].alert-warning { border-left-color: var(--color-warning); }
.rd-body [data-notify="container"].alert-success { border-left-color: var(--color-success); }
.rd-body [data-notify="container"] [data-notify="icon"]:empty,
.rd-body [data-notify="container"] [data-notify="title"]:empty,
.rd-body [data-notify="container"] [data-notify="url"] { display: none; }
.rd-body [data-notify="container"] [data-notify="dismiss"] {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--color-text-tertiary); font-size: 20px; line-height: 1; cursor: pointer;
}
.rd-body [data-notify="container"] [data-notify="dismiss"]:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.rd-body [data-notify="container"] .progress { height: 3px; margin-top: var(--space-1); }
.rd-body .notification-acknowledge-link {
  display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3);
  min-height: 30px; padding: 0 var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text-primary) !important; font-size: var(--fs-caption); font-weight: var(--fw-medium); text-decoration: none;
}
.rd-body .notification-acknowledge-link:hover { background: var(--color-surface-hover); }
.rd-body .notification-acknowledge-link i { display: none; }

/* ==== jquery.loadmask ==== */
.rd-body .loadmask { background-color: var(--color-surface) !important; opacity: 0.6 !important; }
.rd-body .loadmask-msg {
  padding: var(--space-2); background: var(--color-surface) !important; border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.rd-body .loadmask-msg div { border: 0 !important; background-color: transparent !important; color: var(--color-text-secondary) !important; font: var(--fw-medium) var(--fs-label) / 1.4 var(--font-sans) !important; }

/* ==== CLEditor / elFinder / fileuploader ==== */
.rd-body .cleditorMain { border: 1px solid var(--color-border-strong) !important; border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); }
.rd-body .cleditorToolbar { background: var(--color-surface-secondary) !important; border-bottom: 1px solid var(--color-border); }
.rd-body .cleditorPopup, .rd-body .cleditorList { border: 1px solid var(--color-border) !important; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.rd-body .elfinder { border-color: var(--color-border) !important; border-radius: var(--radius-md); font-family: var(--font-sans); }
.rd-body .qq-uploader { position: relative; }

/* ==== Earlier Ui* design-system classes ==== */
.rd-body .ui-btn { min-height: 36px; padding: 0 var(--space-4); font-size: var(--fs-label); border-radius: var(--radius-md); }
.rd-body .ui-btn-outline { background: var(--color-surface); color: var(--color-text-primary) !important; border: 1px solid var(--color-border-strong); }
.rd-body .ui-btn-outline:hover { background: var(--color-surface-hover); box-shadow: none; }
.rd-body .ui-field .form-label { text-transform: none; letter-spacing: normal; font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--color-text-secondary); }
.rd-body .ui-field .form-control, .rd-body .ui-field .form-select { border-width: 1px; }

/* ==== Legacy headings and images ==== */
.rd-body .content-body h1 img, .rd-body .content-body h2 img { width: 24px; height: 24px; object-fit: contain; vertical-align: -4px; margin-right: var(--space-2); }
.rd-body .content-body :is(h2, h3) { color: var(--color-text-primary); font-weight: var(--fw-semibold); }
.rd-body .content-body hr { border-color: var(--color-border); opacity: 1; }
.rd-body .flash-success, .rd-body .flash-error, .rd-body .flash-notice {
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); border: 1px solid; border-radius: var(--radius-md); font-size: var(--fs-body); color: var(--color-text-primary);
}
.rd-body .flash-success { background: var(--color-success-surface); border-color: var(--color-success); }
.rd-body .flash-error { background: var(--color-error-surface); border-color: var(--color-error); }
.rd-body .flash-notice { background: var(--color-info-surface); border-color: var(--color-info); }

/* Row status shape (GridDefaultWarnCssBootstrap data-row-status): a distinct shape per level, so the status is not colour-only. */
.rd-body table.data-table > tbody > tr[data-row-status] > td:first-child,
.rd-body table.data-table > tbody > tr[data-row-status] > td:first-child[style*="display:none"] + td,
.rd-body table.data-table > tbody > tr[data-row-status] > td:first-child[style*="display: none"] + td { position: relative; padding-left: calc(var(--space-4) + 10px); }
.rd-body table.data-table > tbody > tr[data-row-status] > td:first-child::before,
.rd-body table.data-table > tbody > tr[data-row-status] > td:first-child[style*="display:none"] + td::before,
.rd-body table.data-table > tbody > tr[data-row-status] > td:first-child[style*="display: none"] + td::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 8px; height: 8px; margin-top: -4px; background: currentColor;
}
.rd-body table.data-table > tbody > tr[data-row-status="actionRequired"] > td:is(:first-child, [style*="display:none"] + td, [style*="display: none"] + td)::before { transform: rotate(45deg); }
.rd-body table.data-table > tbody > tr[data-row-status="warning"] > td:is(:first-child, [style*="display:none"] + td, [style*="display: none"] + td)::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 10px; height: 9px; left: 8px; }
.rd-body table.data-table > tbody > tr[data-row-status="earlyWarning"] > td:is(:first-child, [style*="display:none"] + td, [style*="display: none"] + td)::before { border-radius: 50%; }
.rd-body table.data-table > tbody > tr[data-row-status="ready"] > td:is(:first-child, [style*="display:none"] + td, [style*="display: none"] + td)::before { border-radius: 50%; background: transparent; border: 2px solid currentColor; }

/* Select2 dropdowns (appended to <body>) sit under the sticky header and form footer; inside dialogs/modals they are raised by app.js.
   !important + higher specificity beats js/functions.js's runtime "select2-modal-layer-fix" style (z-index 10600/10610 !important). */
body.rd-body .select2-container, body.rd-body .select2-dropdown { z-index: 4 !important; }
body.rd-body .select2-container:has(> .select2-dropdown-raised) { z-index: 10600 !important; }
body.rd-body .select2-dropdown.select2-dropdown-raised { z-index: 10610 !important; }

/* Related-record link lists (ul.relation-links > li.span3) as chips */
.rd-body ul.relation-links { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.rd-body ul.relation-links::before, .rd-body ul.relation-links::after { display: none; }
.rd-body ul.relation-links > li {
  float: none; width: auto !important; margin: 0; min-height: 0;
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 6px 10px; border-radius: var(--radius-full);
  background: var(--color-surface); border: 1px solid var(--color-border-strong); font-size: var(--fs-label); font-weight: var(--fw-medium);
}
.rd-body ul.relation-links > li > a { color: var(--color-text-primary); text-decoration: none; }
.rd-body ul.relation-links > li > a:hover { color: var(--color-primary); }
.rd-body ul.relation-links > li > img.smallIcon { display: none; }
/* Report dashboard: three equal columns, each item two text lines tall */
.rd-body ul.relation-links.relation-links-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rd-body ul.relation-links.relation-links-grid > li { display: flex; min-width: 0; line-height: 1.4; height: calc(2.8em + 14px); border-radius: var(--radius-md); }
.rd-body ul.relation-links.relation-links-grid > li > a { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-width: 0; height: 100%; }
.rd-body ul.relation-links.relation-links-grid > li > a > svg { flex: 0 0 auto; }
.rd-body ul.relation-links.relation-links-grid > li > a > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* ==========================================================================
   Phase 8 — dark-mode completion (legacy CSS / plugin colours that beat the token skins)
   ========================================================================== */

/* site.css forces h1 to 20px Calibri !important. */
.rd-body h1 { font-family: var(--font-sans) !important; }
.rd-body .main-column h1:not(.h2, .h3, .h4, .h5, .h6) { font-size: var(--fs-page-title) !important; }
.rd-body :is(.ui-dialog-content, .card-body, .tab-pane) h1:not(.h2, .h3, .h4, .h5, .h6) { font-size: var(--fs-section-title) !important; }

/* jQuery UI .ui-widget-content a {#222} (dialogs). :where() keeps (0,1,1) so component hover/active rules still win. */
.rd-body :where(.ui-widget-content) a { color: var(--color-primary); }
.rd-body :where(.ui-widget-content) a:where(:hover) { color: var(--color-primary-hover); }
.rd-body :where(.ui-widget-content) :where(td, th.detail-label) a:where(:not([class])) { color: var(--color-text-primary); }
.rd-body :where(.ui-widget-content) a:where(.btn) { color: var(--bs-btn-color); }
.rd-body :where(.ui-widget-content) a:where(.nav-link) { color: var(--bs-nav-link-color); }
.rd-body :where(.ui-widget-content) a:where(.dropdown-item) { color: var(--bs-dropdown-link-color); }
.rd-body :where(.ui-widget-content) a:where(.page-link) { color: var(--bs-pagination-color); }
.rd-body :where(.ui-widget-content) a:where(.icon-btn, .status-tab, .vtab) { color: var(--color-text-secondary); }
.rd-body :is(.ui-state-default, .ui-state-hover) a:not(.nav-link) { color: var(--color-text-primary); }
.rd-body .ui-state-highlight a { color: var(--color-primary); }
.rd-body .ui-state-error a { color: var(--color-error); }
.rd-body .ui-menu .ui-menu-item a { color: var(--color-text-primary); }
[data-theme='dark'] .rd-body .ui-datepicker .ui-icon { filter: invert(1) brightness(1.4); }

/* custom.css: dropdown hover #377ebd, navy input borders, legacy status text colours */
.rd-body .dropdown-menu li > a.dropdown-item:not(.active):is(:hover, :focus) { background-color: var(--bs-dropdown-link-hover-bg); }
.rd-body .dropdown-menu li > a:not(.dropdown-item):is(:hover, :focus) { background-color: var(--color-surface-hover); color: var(--color-text-primary); }
:where(.rd-body) input.input { border-color: var(--color-border-strong); }
.rd-body .actionRequired, .rd-body .actionRequired td a { color: var(--color-error) !important; }
.rd-body .warning, .rd-body .warning td a { color: var(--color-warning) !important; }
.rd-body .earlyWarning, .rd-body .earlyWarning td a { color: var(--color-info) !important; }
.rd-body .ready, .rd-body .ready td a { color: var(--color-success) !important; }
/* no violet token: documented exception (Yii1 purple) */
.rd-body :is(.userCheckRequired, tr.userCheckRequired > td, tr.userCheckRequired > td a) { color: #7c3aed !important; }
[data-theme='dark'] .rd-body :is(.userCheckRequired, tr.userCheckRequired > td, tr.userCheckRequired > td a) { color: #c4b5fd !important; }
.rd-body .input-note { color: var(--color-text-tertiary); font-size: var(--fs-caption); }
.rd-body .stat-block:hover { background: var(--color-surface-hover); }
.rd-body .stat-block:active { background: var(--color-primary) !important; color: var(--color-on-primary); }
.rd-body .service-task-table { width: 100%; }
.rd-body .service-task-table tbody tr { border-bottom-color: var(--color-border); }
.rd-body .service-task-table tbody tr.task-row:nth-child(even) { background: var(--color-surface-secondary); }
.rd-body .heirarchy-node { background-color: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text-primary); }
.rd-body .heirarchy-node.ready { background-color: var(--color-success-surface); border-color: var(--color-success); }
.rd-body .heirarchy-node.actionRequired { background-color: var(--color-error-surface); border-color: var(--color-error); }

/* Workflow progress grids: WorkOrder::workflowStepProgress() returns Bootstrap bg-/text- utilities (both !important) */
.rd-body td.sub-workflow-step.bg-white { background-color: transparent !important; }
.rd-body td.sub-workflow-step.bg-muted { background-color: var(--color-surface-secondary) !important; color: var(--color-text-tertiary); }
.rd-body td.sub-workflow-step.bg-success { background-color: var(--color-success-surface) !important; color: var(--color-success) !important; }
.rd-body td.sub-workflow-step.bg-warning { background-color: var(--color-warning-surface) !important; color: var(--color-warning) !important; }
.rd-body td.sub-workflow-step.bg-error { background-color: var(--color-error-surface) !important; color: var(--color-error) !important; }

/* Tree views (jquery.treeview, geo access tree) */
.rd-body .treeview ul { background-color: transparent; }
.rd-body .treeview a.selected { background-color: var(--color-primary-surface); color: var(--color-primary); }
.rd-body .treeview .hover { color: var(--color-primary); }
[data-theme='dark'] .rd-body .treeview .hitarea { filter: invert(.88) hue-rotate(180deg); }
.rd-body :is(#viewGeoTree, #geoAccessTree) .geo-expander { color: var(--color-text-secondary); }
[data-theme='dark'] .rd-body .geo-lock-overlay { background: rgba(7, 12, 23, 0.6) !important; color: var(--color-text-primary); }

/* Save overlay + dialog load errors injected by js/functions.js (shared with Yii1, not edited) */
[data-theme='dark'] .rd-body .global-save-overlay { background: rgba(7, 12, 23, 0.6); }
.rd-body .global-save-overlay__card { background: var(--color-surface); color: var(--color-text-primary); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); }
.rd-body .global-save-overlay__spinner { border-color: var(--color-border-strong); border-top-color: var(--color-primary); }
[data-theme='dark'] .rd-body :is(.ui-dialog-content, .tab-pane) div:is([style*="#b20000"], [style*="#a94442"]) { color: var(--color-error) !important; }

/* Page-scoped legacy skins still emitted in the redesign */
.rd-body .asset-site-admin #asset-site-grid thead th, .rd-body .asset-site-admin #asset-site-grid thead th a { color: var(--color-text-secondary); border-color: var(--color-border); }
.rd-body .asset-site-admin #asset-site-grid .filters td { background: var(--color-surface); }
.rd-body #roleOrderDialogOverlay > div { background: var(--color-surface) !important; color: var(--color-text-primary); border: 1px solid var(--color-border); }
.rd-body #roleOrderDialogOverlay > div > div:first-child { background: var(--color-surface) !important; border-bottom-color: var(--color-border) !important; }
[data-theme='dark'] .rd-body #uploadDropZone { background: var(--color-surface-secondary) !important; }
.rd-body ul.ui-sortable > li.ui-state-default { background: var(--color-surface) !important; border: 1px solid var(--color-border) !important; color: var(--color-text-primary); }

/* ddautofilter multiple-select (asset grid filter dialog) */
.rd-body .ms-drop { background: var(--color-surface); color: var(--color-text-primary); border-color: var(--color-border); box-shadow: var(--shadow-lg); }
.rd-body .ms-choice { background-color: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text-primary); }
.rd-body .ms-search input { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text-primary); }
.rd-body span.filter { color: var(--color-primary); }
.rd-body span.lead-filter { color: var(--color-success); }
.rd-body .dialogtest hr { border-top-color: var(--color-border); border-bottom-color: transparent; }

/* CLEditor popups and toolbar icons */
.rd-body .cleditorPopup { background-color: var(--color-surface); color: var(--color-text-primary); }
.rd-body .cleditorPrompt, .rd-body .cleditorMsg { background-color: var(--color-surface-secondary); color: var(--color-text-primary); }
.rd-body .cleditorDivider { background: var(--color-border); }
[data-theme='dark'] .rd-body .cleditorButton { filter: invert(.85) hue-rotate(180deg); }

/* Flot charts: labels, tooltip, legends */
.rd-body :is(.flot-text, .flot-tick-label, .tickLabel) { color: var(--color-text-secondary) !important; }
.rd-body #tooltip { background: var(--color-surface) !important; color: var(--color-text-primary); border-color: var(--color-border) !important; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.rd-body .pie-chart-label { background: var(--color-surface); color: var(--color-text-primary); }
.rd-body #divDepreciationLegend { background-color: var(--color-surface); }

/* ==========================================================================
   Phase 8 — responsive pass (shared legacy markup)
   ========================================================================== */
.rd-body :not(td) > .select2-container { max-width: 100%; }
.rd-body .typeahead.dropdown-menu { width: min(400px, calc(100vw - var(--space-8))) !important; }
.rd-body .thumbnail img { max-width: 100%; height: auto; display: block; }
.rd-body :is(#divDepreciation, #divWorkOrderTypes, #divWorkOrderLabourHours, #divWorkOrderTravel, [id^="divWorkOrderType"]) { max-width: 100%; overflow-x: auto; }
.rd-body .service-task-table textarea { width: 100%; min-width: 160px; }

/* Detail views: custom.css #custom-view th 210px; long values wrap; stacked on phones */
.rd-body table.detail-view > tbody > tr > td { overflow-wrap: anywhere; }
.rd-body :is(#custom-view, #_rd) table.detail-view > tbody > tr > th { width: 34%; }

/* custom.css floats .row labels at 25% and indents .errorMessage to match */
.rd-body :is(.form-rows, .field) .errorMessage { margin-left: 0; top: 0; }

/* Dual-list picker (LegacyJmultiselect2side): labels wrap. #_rd never matches; it only lifts specificity over the widget's inline #id rules. */
.rd-body .ms2side-widget.ui-dual-select:is(#_rd, .ui-dual-select) .ms2side-label { white-space: normal !important; flex-wrap: wrap !important; }

.rd-body .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 991.98px) {
  .rd-body [data-notify="container"] [data-notify="dismiss"] { width: 32px; height: 32px; }
  .rd-body table.data-table input[type="checkbox"] { width: 20px; height: 20px; }
  .date-picker-nav { width: 32px; height: 32px; }
  .date-picker-day { height: 36px; }
  .date-picker-footer button { min-height: 32px; }
}

@media (max-width: 767.98px) {
  .rd-body .grid-view:not(:has(.table-card)) { overflow-x: auto; }
  .rd-body .row label:not(.checkbox):not(.radio):not(.form-check-label) { float: none; width: auto; }
  .rd-body .errorMessage { margin-left: 0; top: 0; }
}

@media (max-width: 575.98px) {
  .rd-body table.detail-view, .rd-body table.detail-view > tbody, .rd-body table.detail-view > tbody > tr { display: block; }
  .rd-body table.detail-view > tbody > tr > :is(th, td) { display: block; width: auto !important; }
  .rd-body table.detail-view > tbody > tr > th { padding-bottom: 0; border-bottom: 0; }
  .rd-body .ui-dialog .ui-dialog-titlebar.ui-widget-header { padding: var(--space-3) var(--space-4); }
  .rd-body .ui-dialog .ui-dialog-content.ui-widget-content { padding: var(--space-4); }
  .rd-body .ui-dialog .ui-dialog-content :is(.form-sticky-footer, .row.buttons) {
    bottom: calc(-1 * var(--space-4)); margin: var(--space-4) calc(-1 * var(--space-4)) calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4);
  }
}