/* Reteller Unified Coordinated Light (White + Deep-Plum Brand Panels) & Dark (Deep-Plum) Theme (v23)
 * Loaded render-blocking in <head> of app/Views/layouts/app.php for zero white flash.
 */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --rt-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --rt-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Light Canvas & Surfaces */
  --rt-bg: #f7f8fb;
  --rt-surface: #ffffff;
  --rt-surface-2: #f1f3f8;
  --rt-surface-3: #e8ecf4;
  --rt-paper: #ffffff;
  --rt-soft: #f1f3f8;
  --rt-ink: #171923;
  --rt-text: #171923;
  --rt-muted: #555d70;
  --rt-border: #e2e6ef;
  --rt-accent: #6d28d9;
  --rt-purple: #6d28d9;
  --rt-accent-hover: #5b21b6;
  --rt-accent-soft: #f3edff;
  --rt-accent-ink: #5b21b6;
  --rt-on-accent: #ffffff;
  --rt-input-bg: #ffffff;

  /* Independent Deep-Plum Brand Panel Tokens (Header, Wallet, Auth Brand, Public Hero/Final) */
  --rt-brand-bg: #1d1527;
  --rt-brand-bg-deep: #17121e;
  --rt-brand-surface: #282131;
  --rt-brand-border: #3a2c48;
  --rt-brand-text: #f7f3fc;
  --rt-brand-muted: #d2c3e3;
  --rt-brand-accent: #d4b0fa;

  /* Semantic Status Colours (Light WCAG AA) */
  --rt-success: #15803d;
  --rt-success-soft: #dcfce7;
  --rt-danger: #dc2626;
  --rt-danger-soft: #fee2e2;
  --rt-warning: #b45309;
  --rt-warning-soft: #fef3c7;

  /* Bridge legacy variables */
  --bg: var(--rt-bg); --surface: var(--rt-surface); --surface-2: var(--rt-surface-2); --surface-3: var(--rt-surface-3);
  --text: var(--rt-text); --ink: var(--rt-text); --heading: var(--rt-text); --muted: var(--rt-muted);
  --line: var(--rt-border); --border: var(--rt-border); --brand: var(--rt-accent); --brand-text: var(--rt-accent-ink); --on-brand: var(--rt-on-accent); --accent: var(--rt-accent);
  --ra-bg: var(--rt-bg); --ra-surface: var(--rt-surface); --ra-soft: var(--rt-surface-2); --ra-line: var(--rt-border); --ra-text: var(--rt-text); --ra-muted: var(--rt-muted); --ra-purple: var(--rt-accent); --ra-tint: var(--rt-accent-soft);
  --rc-ink: var(--rt-text); --rc-muted: var(--rt-muted); --rc-line: var(--rt-border); --rc-soft: var(--rt-surface-2); --rc-accent: var(--rt-accent);
  --rw-bg: var(--rt-bg); --rw-surface: var(--rt-surface); --rw-line: var(--rt-border); --rw-text: var(--rt-text); --rw-muted: var(--rt-muted);
  --tx-ink: var(--rt-text); --tx-muted: var(--rt-muted); --tx-line: var(--rt-border); --tx-soft: var(--rt-surface-2); --tx-purple: var(--rt-accent); --tx-green: var(--rt-success); --tx-red: var(--rt-danger);
}

html[data-theme="dark"] {
  color-scheme: dark;
  /* Coordinated Deep-Plum Dark Mode */
  --rt-bg: #17121e;
  --rt-surface: #211b29;
  --rt-surface-2: #282131;
  --rt-surface-3: #33263f;
  --rt-paper: #211b29;
  --rt-soft: #282131;
  --rt-ink: #f7f3fc;
  --rt-text: #f7f3fc;
  --rt-muted: #c9bad8;
  --rt-border: #493957;
  --rt-accent: #c89ef5;
  --rt-purple: #c89ef5;
  --rt-accent-hover: #d8b8fa;
  --rt-accent-soft: #33263f;
  --rt-accent-ink: #efe2ff;
  --rt-on-accent: #17121e;
  --rt-input-bg: #1b1524;

  --rt-brand-bg: #1d1527;
  --rt-brand-bg-deep: #17121e;
  --rt-brand-surface: #282131;
  --rt-brand-border: #493957;
  --rt-brand-text: #f7f3fc;
  --rt-brand-muted: #c9bad8;
  --rt-brand-accent: #c89ef5;

  /* Semantic Status Colours (Dark WCAG AA) */
  --rt-success: #4ade80;
  --rt-success-soft: rgba(74, 222, 128, 0.16);
  --rt-danger: #f87171;
  --rt-danger-soft: rgba(248, 113, 113, 0.16);
  --rt-warning: #fbbf24;
  --rt-warning-soft: rgba(251, 191, 36, 0.16);

  --bg: var(--rt-bg); --surface: var(--rt-surface); --surface-2: var(--rt-surface-2); --surface-3: var(--rt-surface-3);
  --text: var(--rt-text); --ink: var(--rt-text); --heading: var(--rt-text); --muted: var(--rt-muted);
  --line: var(--rt-border); --border: var(--rt-border); --brand: var(--rt-accent); --brand-text: var(--rt-accent-ink); --on-brand: var(--rt-on-accent); --accent: var(--rt-accent);
  --ra-bg: var(--rt-bg); --ra-surface: var(--rt-surface); --ra-soft: var(--rt-surface-2); --ra-line: var(--rt-border); --ra-text: var(--rt-text); --ra-muted: var(--rt-muted); --ra-purple: var(--rt-accent); --ra-tint: var(--rt-accent-soft);
  --rc-ink: var(--rt-text); --rc-muted: var(--rt-muted); --rc-line: var(--rt-border); --rc-soft: var(--rt-surface-2); --rc-accent: var(--rt-accent);
  --rw-bg: var(--rt-bg); --rw-surface: var(--rt-surface); --rw-line: var(--rt-border); --rw-text: var(--rt-text); --rw-muted: var(--rt-muted);
  --tx-ink: var(--rt-text); --tx-muted: var(--rt-muted); --tx-line: var(--rt-border); --tx-soft: var(--rt-surface-2); --tx-purple: var(--rt-accent); --tx-green: var(--rt-success); --tx-red: var(--rt-danger);
}

/* Base Typography & Controls */
html[data-theme], html[data-theme] body {
  background-color: var(--rt-bg) !important;
  color: var(--rt-text) !important;
  font-family: var(--rt-font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: var(--rt-font); }
code, pre, .tx-reference, .tx-provider-ref { font-family: var(--rt-mono); }
html[data-theme="dark"] code:not(pre code), html[data-theme="dark"] .ra-shell code { color: var(--rt-accent-ink) !important; background-color: var(--rt-surface-2); }

html[data-theme] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html[data-theme] select, html[data-theme] textarea {
  background-color: var(--rt-input-bg); color: var(--rt-text); border-color: var(--rt-border);
}
select option, select optgroup { background-color: var(--rt-surface); color: var(--rt-text); }
:focus-visible { outline: 2px solid var(--rt-accent); outline-offset: 2px; }

/* Compact Everyday Heading Scale (excludes public .p3-hero h1) */
html[data-theme] .r4-shell h1, html[data-theme] .ra-shell .page-head h1,
html[data-theme] .tx-workspace .tx-heading h1, html[data-theme] .cat-workspace .cat-heading h1, html[data-theme] .pf-page h1 {
  font-family: var(--rt-font); font-size: clamp(24px, 2.2vw, 30px) !important; line-height: 1.2 !important; font-weight: 650; letter-spacing: -0.02em; color: var(--rt-text) !important;
}
html[data-theme] .r4-shell h2, html[data-theme] .ra-shell h2, html[data-theme] .tx-workspace h2,
html[data-theme] .cat-workspace .cat-card-head h2, html[data-theme] .sw-workspace h2, html[data-theme] .pf-page h2 {
  font-family: var(--rt-font); font-size: 17px !important; line-height: 1.3 !important; font-weight: 600; color: var(--rt-text) !important;
}
@media (max-width: 750px) {
  html[data-theme] .r4-shell input:not([type="checkbox"]):not([type="radio"]), html[data-theme] .r4-shell select,
  html[data-theme] .ra-shell input:not([type="checkbox"]):not([type="radio"]), html[data-theme] .ra-shell select { font-size: 16px; }
}

/* Primary & Ghost Buttons */
html[data-theme] .btn:not(.ghost):not(.danger):not(.secondary),
html[data-theme] .ra-site .ra-submit, html[data-theme] .ra-recovery .ra-submit,
html[data-theme] .cat-button.primary, html[data-theme] .pf-page .pf-button,
html[data-theme] .rt-site.p3-site .p3-button {
  background: var(--rt-accent) !important; color: var(--rt-on-accent) !important; border-color: var(--rt-accent) !important;
}
html[data-theme] .btn.ghost, html[data-theme] .cat-button:not(.primary) {
  background: var(--rt-surface) !important; color: var(--rt-text) !important; border-color: var(--rt-border) !important;
}

/* Deep-Plum Brand Panels (Both Light & Dark Modes) */
html[data-theme] .ra-shell .ra-topbar,
html[data-theme] .ra-shell:has(.tx-workspace) .ra-topbar,
html[data-theme] .r4-app-header {
  background: var(--rt-brand-bg) !important;
  border-bottom: 1px solid var(--rt-brand-border) !important;
  color: var(--rt-brand-text) !important;
}
html[data-theme] .ra-shell .ra-header-search,
html[data-theme] .ra-shell:has(.tx-workspace) .ra-header-search {
  background: var(--rt-brand-surface) !important; border: 1px solid var(--rt-brand-border) !important; color: var(--rt-brand-text) !important;
}
html[data-theme] .ra-shell .ra-header-search input,
html[data-theme] .ra-shell:has(.tx-workspace) .ra-header-search input { background: transparent !important; border: 0 !important; color: var(--rt-brand-text) !important; }
html[data-theme] .ra-shell .ra-header-search input::placeholder { color: var(--rt-brand-muted) !important; }
html[data-theme] .ra-shell .ra-topbar svg, html[data-theme] .ra-shell .ra-header-search button,
html[data-theme] .ra-shell .ra-header-actions, html[data-theme] .ra-shell .ra-user-menu summary,
html[data-theme] .ra-shell .ra-user-menu summary > span, html[data-theme] .r4-app-header > .r4-logo { color: var(--rt-brand-text) !important; }
html[data-theme] .ra-shell .ra-topbar .ra-theme-switch, html[data-theme] .ra-shell .ra-topbar button[data-admin-menu],
html[data-theme] .ra-shell .ra-topbar .ra-desktop-collapse,
html[data-theme] .r4-shell .r4-header-tools .icon-toggle, html[data-theme] .r4-shell .r4-header-tools .bell-btn, html[data-theme] .r4-shell .r4-header-tools .menu-btn {
  background: var(--rt-brand-surface) !important; border-color: var(--rt-brand-border) !important; color: var(--rt-brand-text) !important;
}
html[data-theme] .r4-desktop-nav a { color: var(--rt-brand-muted) !important; }
html[data-theme] .r4-desktop-nav a[aria-current] { color: var(--rt-brand-text) !important; background: rgba(212, 176, 250, 0.2) !important; }

/* Selected Brand Cards (Wallet, Balance, Auth Brand, Public Hero/Final) */
html[data-theme] .r4-balance-card, html[data-theme] .wallet-card,
html[data-theme] .ra-story, html[data-theme] .r4-auth .r4-auth-brand {
  background-color: var(--rt-brand-bg) !important; border: 1px solid var(--rt-brand-border) !important; color: var(--rt-brand-text) !important;
}
html[data-theme] .r4-balance-card > strong, html[data-theme] .wallet-card .balance,
html[data-theme] .r4-auth .r4-auth-brand .r4-logo, html[data-theme] .r4-auth .r4-auth-brand h1, html[data-theme] .r4-auth .r4-auth-brand h2, html[data-theme] .r4-auth .r4-auth-brand strong { color: var(--rt-brand-text) !important; }
html[data-theme] .r4-balance-card > span, html[data-theme] .r4-balance-card p, html[data-theme] .r4-balance-card .r4-text-link, html[data-theme] .wallet-card small,
html[data-theme] .r4-auth .r4-auth-brand p, html[data-theme] .r4-auth .r4-auth-brand li, html[data-theme] .r4-auth .r4-auth-brand span, html[data-theme] .r4-auth .r4-auth-brand footer { color: var(--rt-brand-muted) !important; }
html[data-theme] .r4-balance-card .btn { background: var(--rt-brand-accent) !important; color: var(--rt-brand-bg-deep) !important; }

/* Public Homepage (div.rt-site.p3-site): Light = white content + deep-plum hero/final; Dark = full deep-plum */
html[data-theme] .rt-site.p3-site { background: var(--rt-bg) !important; color: var(--rt-text) !important; }
html[data-theme] .rt-site.p3-site .p3-hero, html[data-theme] .rt-site.p3-site .p3-final {
  background-color: var(--rt-brand-bg-deep) !important; color: var(--rt-brand-text) !important;
}
html[data-theme] .rt-site.p3-site .p3-hero h1, html[data-theme] .rt-site.p3-site .p3-final h2 { color: var(--rt-brand-text) !important; }
html[data-theme] .rt-site.p3-site .p3-hero p, html[data-theme] .rt-site.p3-site .p3-hero-benefits, html[data-theme] .rt-site.p3-site .p3-final p { color: var(--rt-brand-muted) !important; }
html[data-theme] .rt-site.p3-site .p3-codebox { background-color: #140f1b !important; border-color: var(--rt-brand-border) !important; }
html[data-theme] .rt-site.p3-site .p3-response { background: var(--rt-surface-2) !important; border-color: var(--rt-border) !important; color: var(--rt-text) !important; }
html[data-theme] .rt-site.p3-site .p3-response span { color: var(--rt-accent-ink) !important; }
html[data-theme] .rt-site.p3-site .p3-response code { color: var(--rt-text) !important; background: transparent !important; }
html[data-theme="dark"] .rt-site.p3-site .p3-networks, html[data-theme="dark"] .rt-site.p3-site .p3-section.p3-alt,
html[data-theme="dark"] .rt-site.p3-site .p3-section.p3-reliability, html[data-theme="dark"] .rt-site.p3-site .p3-start-card,
html[data-theme="dark"] .rt-site.p3-site .p3-features article { background-color: var(--rt-surface) !important; border-color: var(--rt-border) !important; color: var(--rt-text) !important; }
html[data-theme="dark"] .rt-site.p3-site h2, html[data-theme="dark"] .rt-site.p3-site h3, html[data-theme="dark"] .rt-site.p3-site .p3-faqs summary, html[data-theme="dark"] .rt-site.p3-site .p3-network b { color: var(--rt-text) !important; }
html[data-theme="dark"] .rt-site.p3-site .p3-section-head p, html[data-theme="dark"] .rt-site.p3-site .p3-lead, html[data-theme="dark"] .rt-site.p3-site .p3-features p, html[data-theme="dark"] .rt-site.p3-site .p3-faqs details > p { color: var(--rt-muted) !important; }

/* Admin Shell, Sidebar, Dropdowns & Dark-Mode Surfaces */
html[data-theme] .ra-shell {
  background: var(--rt-bg) !important; color: var(--rt-text) !important;
  --ra-menu-bg: var(--rt-surface); --ra-menu-text: var(--rt-text); --ra-menu-muted: var(--rt-muted);
  --ra-menu-soft: var(--rt-accent-soft); --ra-menu-accent: var(--rt-accent-ink); --ra-menu-line: var(--rt-border); --ra-menu-hover: var(--rt-surface-2);
}
html[data-theme] .ra-shell .main { background: var(--rt-bg) !important; }
html[data-theme] .ra-shell .ra-user-menu > div { background: var(--rt-surface) !important; border: 1px solid var(--rt-border) !important; color: var(--rt-text) !important; }
html[data-theme] .ra-shell .ra-user-menu > div > a { color: var(--rt-text) !important; }
html[data-theme] .ra-shell .ra-user-menu > div > a:hover { background: var(--rt-surface-2) !important; color: var(--rt-accent) !important; }
html[data-theme] .ra-shell .field > span, html[data-theme] .r4-shell .field > span { color: var(--rt-muted) !important; }
html[data-theme] .rp-wrap .rp-topbar a.rp-api-link, html[data-theme] .ra-shell .rc-table-actions a, html[data-theme] .cat-workspace .cat-link { color: var(--rt-accent) !important; }
html[data-theme] .r4-shell .r4-purchase-page .seg-toggle button { background: var(--rt-surface-2) !important; color: var(--rt-muted) !important; border-color: var(--rt-border) !important; }
html[data-theme] .r4-shell .r4-purchase-page .seg-toggle button.active { background: var(--rt-accent) !important; color: var(--rt-on-accent) !important; }

/* Fluid Admin Transactions Desktop Layout + Compact Vertical Density */
@media (min-width: 901px) {
  html[data-theme] .ra-shell .content.tx-page,
  html[data-theme] .ra-shell .content.tx-workspace,
  html[data-theme] .ra-shell .tx-workspace {
    max-width: none !important; width: 100% !important; padding: 20px 30px 40px !important; gap: 14px !important;
  }
  .tx-workspace .tx-metric { padding: 13px 16px !important; }
  .tx-workspace .tx-metric strong { margin: 5px 0 3px !important; font-size: 21px !important; }
  .tx-workspace .tx-filter-panel { padding: 16px 18px !important; }
  .tx-workspace .tx-filter-title { margin-bottom: 12px !important; }
  .tx-workspace .tx-date-filters { margin-top: 12px !important; }
  .tx-workspace .tx-advanced { margin-top: 12px !important; padding-top: 12px !important; }
}

/* Dark-Mode Scoped Component Surfaces (Deep Plum) */
html[data-theme="dark"] .r4-shell, html[data-theme="dark"] .r4-docs, html[data-theme="dark"] .r4-auth,
html[data-theme="dark"] .ra-site, html[data-theme="dark"] .rd-docs, html[data-theme="dark"] .ra-recovery {
  --r4-bg: var(--rt-bg); --r4-soft: var(--rt-surface-2); --r4-paper: var(--rt-surface); --r4-text: var(--rt-text); --r4-muted: var(--rt-muted); --r4-line: var(--rt-border); --r4-purple: var(--rt-accent); --r4-lavender: var(--rt-accent-soft);
  background: var(--rt-bg) !important; color: var(--rt-text) !important;
}
html[data-theme="dark"] .panel, html[data-theme="dark"] .card, html[data-theme="dark"] .table-card,
html[data-theme="dark"] .pin-card, html[data-theme="dark"] .bell-panel, html[data-theme="dark"] .cp-plan-card,
html[data-theme="dark"] .tx-workspace .tx-metric, html[data-theme="dark"] .tx-workspace .tx-filter-panel,
html[data-theme="dark"] .tx-workspace .tx-table, html[data-theme="dark"] .tx-workspace .tx-table tbody tr,
html[data-theme="dark"] .cat-workspace .cat-card, html[data-theme="dark"] .cat-workspace .cat-table, html[data-theme="dark"] .cat-workspace .cat-table td,
html[data-theme="dark"] .sw-workspace .sw-card, html[data-theme="dark"] .sw-workspace .sw-stat-grid > div, html[data-theme="dark"] .sw-workspace .sw-table td,
html[data-theme="dark"] .pl-workspace, html[data-theme="dark"] .pl-panel, html[data-theme="dark"] .pl-table,
html[data-theme="dark"] .pf-page .pf-panel, html[data-theme="dark"] .pf-page .pf-period,
html[data-theme="dark"] .ra-shell details, html[data-theme="dark"] .ra-shell details > summary, html[data-theme="dark"] .ra-shell .table-card-head, html[data-theme="dark"] .ra-shell .gw-group {
  background-color: var(--rt-surface) !important; color: var(--rt-text) !important; border-color: var(--rt-border) !important;
}
html[data-theme="dark"] table th, html[data-theme="dark"] .tx-workspace .tx-bulk-toolbar,
html[data-theme="dark"] .sw-workspace .sw-notice, html[data-theme="dark"] .pf-page .pf-shortcuts a, html[data-theme="dark"] .pf-page .pf-projections,
html[data-theme="dark"] .pl-inspect { background-color: var(--rt-surface-2) !important; color: var(--rt-muted) !important; border-color: var(--rt-border) !important; }
html[data-theme="dark"] table td, html[data-theme="dark"] .cat-workspace .cat-name, html[data-theme="dark"] .cat-workspace .cat-id,
html[data-theme="dark"] .sw-workspace .sw-stat-grid strong, html[data-theme="dark"] .sw-workspace .sw-rule-name,
html[data-theme="dark"] .ra-shell h3, html[data-theme="dark"] .ra-shell .rc-provider > div { color: var(--rt-text) !important; border-color: var(--rt-border) !important; }
html[data-theme="dark"] .tx-workspace .tx-metric-volume, html[data-theme="dark"] .pf-page .pf-net { background: var(--rt-accent-soft) !important; }
html[data-theme="dark"] .tx-workspace .tx-metric-volume strong { color: var(--rt-accent-ink) !important; }
html[data-theme="dark"] .ra-shell .thumb, html[data-theme="dark"] .thumb { background-color: var(--rt-accent) !important; color: var(--rt-on-accent) !important; }
html[data-theme="dark"] .ra-shell span[style*="#2563eb"], html[data-theme="dark"] .tx-page span[style*="#2563eb"] { background: rgba(59, 130, 246, 0.2) !important; color: #93c5fd !important; }
html[data-theme="dark"] .pf-page .is-profit { color: var(--rt-success) !important; }
html[data-theme="light"] .pf-page .is-profit { color: #15803d !important; }
html[data-theme="light"] .badge.active, html[data-theme="light"] .sw-badge.enabled { background: #dcfce7 !important; color: #156534 !important; }
html[data-theme="dark"] .badge.active, html[data-theme="dark"] .sw-badge.enabled { background: var(--rt-success-soft) !important; color: var(--rt-success) !important; }

/* v24: High-specificity !important local-root token bridges so later <body> page CSS can never reset tokens */
html[data-theme] .r4-shell,
html[data-theme] .r4-docs,
html[data-theme] .r4-auth {
  --r4-bg: var(--rt-bg) !important;
  --r4-soft: var(--rt-surface-2) !important;
  --r4-paper: var(--rt-surface) !important;
  --r4-text: var(--rt-text) !important;
  --r4-muted: var(--rt-muted) !important;
  --r4-line: var(--rt-border) !important;
  --r4-purple: var(--rt-accent) !important;
  --r4-lavender: var(--rt-accent-soft) !important;
  --r4-dark: var(--rt-brand-bg) !important;
  --rc-bg: var(--rt-bg) !important;
  --rc-surface: var(--rt-surface) !important;
  --rc-soft: var(--rt-surface-2) !important;
  --rc-text: var(--rt-text) !important;
  --rc-muted: var(--rt-muted) !important;
  --rc-line: var(--rt-border) !important;
  --rc-accent: var(--rt-accent) !important;
  --rc-tint: var(--rt-accent-soft) !important;
}

html[data-theme] .ra-shell .tx-workspace,
html[data-theme] .tx-workspace {
  --tx-ink: var(--rt-text) !important;
  --tx-muted: var(--rt-muted) !important;
  --tx-line: var(--rt-border) !important;
  --tx-soft: var(--rt-surface-2) !important;
  --tx-purple: var(--rt-accent) !important;
  --tx-green: var(--rt-success) !important;
  --tx-red: var(--rt-danger) !important;
}

/* Designated deep-plum brand panel for Transaction Volume metric card in both modes */
html[data-theme] .tx-workspace .tx-metric-volume {
  background: var(--rt-brand-bg) !important;
  border-color: var(--rt-brand-border) !important;
  color: var(--rt-brand-text) !important;
}
html[data-theme] .tx-workspace .tx-metric-volume strong {
  color: var(--rt-brand-text) !important;
}
html[data-theme] .tx-workspace .tx-metric-volume > span,
html[data-theme] .tx-workspace .tx-metric-volume small {
  color: var(--rt-brand-muted) !important;
}

html[data-theme] .ra-shell .cat-workspace,
html[data-theme] .cat-workspace {
  --cat-accent: var(--rt-accent) !important;
  --cat-line: var(--rt-border) !important;
  --cat-muted: var(--rt-muted) !important;
}

html[data-theme] .ra-shell .pf-page,
html[data-theme] .pf-page {
  --pf-ink: var(--rt-text) !important;
  --pf-muted: var(--rt-muted) !important;
  --pf-line: var(--rt-border) !important;
  --pf-soft: var(--rt-surface-2) !important;
  --pf-brand: var(--rt-accent) !important;
  --pf-profit: var(--rt-success) !important;
  --pf-loss: var(--rt-danger) !important;
}

html[data-theme] .ra-site,
html[data-theme] .rd-docs,
html[data-theme] .ra-recovery {
  --ra-bg: var(--rt-bg) !important;
  --ra-soft: var(--rt-surface-2) !important;
  --ra-text: var(--rt-text) !important;
  --ra-muted: var(--rt-muted) !important;
  --ra-line: var(--rt-border) !important;
  --ra-accent: var(--rt-accent) !important;
  --ra-tint: var(--rt-accent-soft) !important;
  --ra-input: var(--rt-input-bg) !important;
}

html[data-theme] .sw-workspace .sw-notice p,
html[data-theme] .sw-workspace .sw-worker,
html[data-theme] .sw-workspace .sw-card-title p,
html[data-theme] .sw-workspace .sw-summary p,
html[data-theme] .sw-workspace .sw-check small,
html[data-theme] .sw-workspace .sw-help,
html[data-theme] .sw-workspace .sw-stat-grid small,
html[data-theme] .sw-workspace .sw-table th,
html[data-theme] .sw-workspace .sw-table td small,
html[data-theme] .sw-workspace .sw-empty p,
html[data-theme] .sw-workspace .sw-facts dt,
html[data-theme] .sw-workspace .sw-rotation small,
html[data-theme] .cat-workspace .cat-table th {
  color: var(--rt-muted) !important;
}

/* v25: Final scoped hardcoded overrides (Light & Dark, head-safe specificity) */
html[data-theme] .cat-workspace .cat-placeholder {
  background: var(--rt-accent-soft) !important;
  color: var(--rt-accent-ink) !important;
}

html[data-theme] .ra-shell .content p.muted,
html[data-theme] .ra-shell .sub,
html[data-theme] .ra-shell .cell-sub,
html[data-theme] .ra-shell table th,
html[data-theme] .ra-shell .rc-provider small,
html[data-theme] .ra-shell .table-card-head .sub,
html[data-theme] .ra-shell .gw-title > .muted,
html[data-theme] .ra-shell .page-head p {
  color: var(--rt-muted) !important;
}

html[data-theme="dark"] .tx-workspace .tx-today-link,
html[data-theme="dark"] .tx-workspace .tx-open {
  background: var(--rt-accent-soft) !important;
  border-color: var(--rt-border) !important;
  color: var(--rt-accent-ink) !important;
}

html[data-theme="dark"] .cat-workspace .cat-breadcrumb span,
html[data-theme="dark"] .cat-workspace .cat-field,
html[data-theme="dark"] .cat-workspace .cat-field > span {
  color: var(--rt-text) !important;
}

html[data-theme="dark"] .sw-workspace a,
html[data-theme="dark"] .sw-workspace .sw-icon-button,
html[data-theme="dark"] .sw-workspace .sw-text-button {
  color: var(--rt-accent) !important;
}

html[data-theme="dark"] .sw-workspace .sw-chain > span,
html[data-theme="dark"] .sw-workspace .sw-chain b,
html[data-theme="dark"] .sw-workspace .sw-badge:not(.enabled),
html[data-theme="dark"] .sw-workspace .sw-step,
html[data-theme="dark"] .sw-workspace .sw-sequence {
  background: var(--rt-surface-2) !important;
  color: var(--rt-text) !important;
  border-color: var(--rt-border) !important;
}

html[data-theme="dark"] .sw-workspace .sw-feedback,
html[data-theme="dark"] .sw-workspace .sw-warning {
  background: var(--rt-warning-soft) !important;
  color: var(--rt-warning) !important;
  border-color: rgba(251, 191, 36, 0.3) !important;
}

/* v26: High-specificity themed select/input/textarea controls (Light=white, Dark=deep plum) */
html[data-theme] .ra-shell .tx-workspace .field select,
html[data-theme] .ra-shell .tx-workspace .field input:not([type="checkbox"]):not([type="radio"]),
html[data-theme] .ra-shell .cat-workspace .cat-field select,
html[data-theme] .ra-shell .cat-workspace .cat-field input:not([type="checkbox"]):not([type="radio"]),
html[data-theme] .ra-shell .cat-workspace .cat-field textarea,
html[data-theme] .ra-shell .sw-workspace select,
html[data-theme] .ra-shell .sw-workspace input:not([type="checkbox"]):not([type="radio"]),
html[data-theme] .ra-shell .pf-page input,
html[data-theme] .ra-shell select,
html[data-theme] .ra-shell input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html[data-theme] .ra-shell textarea,
html[data-theme] .r4-shell select,
html[data-theme] .r4-shell input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html[data-theme] .r4-shell textarea {
  background-color: var(--rt-input-bg) !important;
  color: var(--rt-text) !important;
  border-color: var(--rt-border) !important;
}
html[data-theme] .ra-shell .ra-header-search input,
html[data-theme] .ra-shell:has(.tx-workspace) .ra-header-search input {
  background-color: transparent !important;
  border: 0 !important;
  color: var(--rt-brand-text) !important;
}
html[data-theme="dark"] select,
html[data-theme="dark"] select option,
html[data-theme="dark"] select optgroup {
  color-scheme: dark;
  background-color: var(--rt-surface) !important;
  color: var(--rt-text) !important;
}
html[data-theme="light"] select,
html[data-theme="light"] select option,
html[data-theme="light"] select optgroup {
  color-scheme: light;
}

/* v27: Final 3 Light-mode native admin selectors (.rc-section-header p, .v-view.badge.muted, .vis-tag) */
html[data-theme] .ra-shell .rc-section-header p {
  color: var(--rt-muted) !important;
}
html[data-theme] .ra-shell .v-view.badge.muted {
  background-color: var(--rt-surface-2) !important;
  color: var(--rt-muted) !important;
}
html[data-theme="light"] .ra-shell .vis-tag {
  color: #15803d !important;
}
html[data-theme="dark"] .ra-shell .vis-tag {
  color: var(--rt-success) !important;
}

/* v26: High-specificity themed select/input/textarea controls (Light=white, Dark=deep plum) */
html[data-theme] .ra-shell .tx-workspace .field select,
html[data-theme] .ra-shell .tx-workspace .field input:not([type="checkbox"]):not([type="radio"]),
html[data-theme] .ra-shell .cat-workspace .cat-field select,
html[data-theme] .ra-shell .cat-workspace .cat-field input:not([type="checkbox"]):not([type="radio"]),
html[data-theme] .ra-shell .cat-workspace .cat-field textarea,
html[data-theme] .ra-shell .sw-workspace select,
html[data-theme] .ra-shell .sw-workspace input:not([type="checkbox"]):not([type="radio"]),
html[data-theme] .ra-shell .pf-page input,
html[data-theme] .ra-shell select,
html[data-theme] .ra-shell input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html[data-theme] .ra-shell textarea,
html[data-theme] .r4-shell select,
html[data-theme] .r4-shell input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html[data-theme] .r4-shell textarea {
  background-color: var(--rt-input-bg) !important;
  color: var(--rt-text) !important;
  border-color: var(--rt-border) !important;
}
html[data-theme] .ra-shell .ra-header-search input,
html[data-theme] .ra-shell:has(.tx-workspace) .ra-header-search input {
  background-color: transparent !important;
  border: 0 !important;
  color: var(--rt-brand-text) !important;
}
html[data-theme="dark"] select,
html[data-theme="dark"] select option,
html[data-theme="dark"] select optgroup {
  color-scheme: dark;
  background-color: var(--rt-surface) !important;
  color: var(--rt-text) !important;
}
html[data-theme="light"] select,
html[data-theme="light"] select option,
html[data-theme="light"] select optgroup {
  color-scheme: light;
}

/* v27: Final 3 Light-mode native admin selectors (.rc-section-header p, .v-view.badge.muted, .vis-tag) */
html[data-theme] .ra-shell .rc-section-header p {
  color: var(--rt-muted) !important;
}
html[data-theme] .ra-shell .v-view.badge.muted {
  background-color: var(--rt-surface-2) !important;
  color: var(--rt-muted) !important;
}
html[data-theme="light"] .ra-shell .vis-tag {
  color: #15803d !important;
}
html[data-theme="dark"] .ra-shell .vis-tag {
  color: var(--rt-success) !important;
}

/* v28: Fluid full-width desktop layout across ALL 30 routed admin views when sidebar is shown or hidden */
@media (min-width: 901px) {
  html[data-theme] .ra-shell .main {
    width: auto !important;
    max-width: none !important;
  }
  html[data-theme] .ra-shell .content,
  html[data-theme] .ra-shell .cat-workspace,
  html[data-theme] .ra-shell .sw-workspace,
  html[data-theme] .ra-shell .pf-page,
  html[data-theme] .ra-shell .pl-workspace,
  html[data-theme] .ra-shell .content.sr-settings,
  html[data-theme] .ra-shell .sr-settings {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 30px !important;
    padding-right: 30px !important;
    box-sizing: border-box !important;
  }
  /* Avoid double horizontal padding when a workspace sits inside .content */
  html[data-theme] .ra-shell .content > .cat-workspace,
  html[data-theme] .ra-shell .content > .sw-workspace,
  html[data-theme] .ra-shell .content > .pf-page,
  html[data-theme] .ra-shell .content > .pl-workspace {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* v29: First-paint desktop persisted compact sidebar state (prevents sidebar flash/jump before deferred JS) */
@media (min-width: 901px) {
  html.ra-pref-compact .ra-shell {
    --rc-sidebar: 0px !important;
    --ra-side: 0px !important;
  }
  html.ra-pref-compact .ra-shell .ra-sidebar {
    transform: translateX(-100%) !important;
    width: 0 !important;
    padding: 0 !important;
    border-right: 0 !important;
    pointer-events: none;
    visibility: hidden;
    overflow: hidden;
  }
  html.ra-pref-compact .ra-shell .ra-topbar {
    left: 0 !important;
    width: 100% !important;
  }
  html.ra-pref-compact .ra-shell .main {
    margin-left: 0 !important;
  }
}
