/* PortuFlow Dark Theme v1
   Loaded after module CSS so the theme can normalize every PortuFlow module
   without changing business/domain layouts. */

/* Theme control styling is intentionally available in both themes. */
[data-theme-toggle] {
  display:flex;
  align-items:center;
  gap:.55rem;
}
[data-theme-toggle] [data-theme-icon] {
  width:1.2rem;
  display:inline-grid;
  place-items:center;
  font-size:1.05rem;
  line-height:1;
}

.user-menu #theme-toggle { color:#35414c; }
.user-menu #theme-toggle:hover { background:#f3f5f7; }
.user-menu #logout { color:var(--danger); }
.login-theme-toggle {
  position:fixed;
  top:18px;
  right:18px;
  z-index:20;
  min-height:38px;
  padding:7px 11px;
  border:1px solid rgba(255,255,255,.35);
  border-radius:7px;
  background:rgba(255,255,255,.92);
  color:#33404b;
  box-shadow:0 2px 10px rgba(0,0,0,.12);
}

html[data-theme="dark"] {
  --ink:#e7edf3;
  --muted:#9ca9b5;
  --line:#34414d;
  --primary:#66a6ff;
  --surface:#151b21;
  --sidebar:#11171d;
  --danger:#ff7f8a;

  --pf-ui-primary:#66a6ff;
  --pf-ui-primary-hover:#8bbcff;
  --pf-ui-success:#55c98a;
  --pf-ui-danger:#ff7f8a;
  --pf-ui-warning:#e4b84f;
  --pf-ui-ink:#e7edf3;
  --pf-ui-muted:#9ca9b5;
  --pf-ui-line:#34414d;
  --pf-ui-line-strong:#455462;
  --pf-ui-surface:#171e25;
  --pf-ui-surface-soft:#1d2630;
  --pf-ui-surface-hover:#25313c;
  --pf-ui-shadow:0 1px 3px rgba(0,0,0,.35);
  --pf-ui-dialog-shadow:0 20px 60px rgba(0,0,0,.58);
  color-scheme:dark;
}

html[data-theme="dark"] body {
  background:#0f1419;
  color:var(--pf-ui-ink);
}
html[data-theme="dark"] body:not(.login-page) #main { background:#0f1419; }
html[data-theme="dark"] a { color:var(--pf-ui-primary); }
html[data-theme="dark"] .muted,
html[data-theme="dark"] small,
html[data-theme="dark"] .breadcrumbs,
html[data-theme="dark"] .legacy-breadcrumbs { color:var(--pf-ui-muted); }

/* Shell */
html[data-theme="dark"] .app-header {
  background:#151b21;
  border-bottom-color:#2d3944;
  box-shadow:0 2px 8px rgba(0,0,0,.34);
}
html[data-theme="dark"] .top-nav a,
html[data-theme="dark"] .top-dropdown-toggle,
html[data-theme="dark"] .calculator-link,
html[data-theme="dark"] .user-menu-toggle { color:#bec9d3; }
html[data-theme="dark"] .top-nav a:hover,
html[data-theme="dark"] .top-nav a[aria-current=page],
html[data-theme="dark"] .top-dropdown-toggle:hover,
html[data-theme="dark"] .calculator-link:hover,
html[data-theme="dark"] .user-menu-toggle:hover { color:#fff; background:#202a33; }
html[data-theme="dark"] .user-identity strong { color:#e8eef4; }
html[data-theme="dark"] .user-identity small,
html[data-theme="dark"] .chevron { color:#91a0ac; }
html[data-theme="dark"] .user-menu,
html[data-theme="dark"] .top-dropdown-menu {
  background:#1a222a;
  border-color:#3a4855;
  box-shadow:0 8px 24px rgba(0,0,0,.42);
}
html[data-theme="dark"] .user-menu button,
html[data-theme="dark"] .top-nav .top-dropdown-menu > a { color:#d7e0e8; background:transparent; }
html[data-theme="dark"] .user-menu button:hover,
html[data-theme="dark"] .user-menu button:focus-visible,
html[data-theme="dark"] .top-nav .top-dropdown-menu > a:hover,
html[data-theme="dark"] .top-nav .top-dropdown-menu > a:focus-visible,
html[data-theme="dark"] .top-nav .top-dropdown-menu > a[aria-current=page] {
  color:#fff;
  background:#25313c;
}
html[data-theme="dark"] #sidebar-wrapper,
html[data-theme="dark"] .app-sidebar { background:#11171d; border-color:#2d3944; }
html[data-theme="dark"] .sidebar-brand-row { background:#11171d; }
html[data-theme="dark"] .sidebar-section-title { color:#81909d; }
html[data-theme="dark"] .sidebar-item,
html[data-theme="dark"] .submenu a { color:#bec9d3; }
html[data-theme="dark"] .sidebar-item:hover,
html[data-theme="dark"] .submenu a:hover { color:#fff; background:#202a33; }
html[data-theme="dark"] .sidebar-item[aria-current=page],
html[data-theme="dark"] .submenu a[aria-current=page] { color:#fff; background:#26394c; }
html[data-theme="dark"] .submenu { background:#151d24; border-color:#2d3944; }
html[data-theme="dark"] #sidebar-mini-toggle,
html[data-theme="dark"] .mobile-menu-toggle { color:#d7e0e8; background:#1b242c; border-color:#3b4955; }
html[data-theme="dark"] .portuflow-footer { background:#0b1014; border-top:1px solid #27323b; }

/* Page chrome, cards, panels */
html[data-theme="dark"] .page-heading h1,
html[data-theme="dark"] .billing-page-head h1,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4 { color:#eef3f7; }
html[data-theme="dark"] .card,
html[data-theme="dark"] .billing-panel,
html[data-theme="dark"] .legacy-grid-panel,
html[data-theme="dark"] body.legacy-resource-page #record-list.legacy-resource-panel,
html[data-theme="dark"] .legacy-resource-panel,
html[data-theme="dark"] .customer-profile-summary,
html[data-theme="dark"] .billing-contract-context,
html[data-theme="dark"] .billing-summary-cell,
html[data-theme="dark"] .legacy-rental-job-summary-field,
html[data-theme="dark"] details,
html[data-theme="dark"] fieldset {
  color:var(--pf-ui-ink);
  background:var(--pf-ui-surface);
  border-color:var(--pf-ui-line);
  box-shadow:var(--pf-ui-shadow);
}
html[data-theme="dark"] .billing-panel-title,
html[data-theme="dark"] .legacy-grid-heading,
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-heading,
html[data-theme="dark"] .dialog-heading,
html[data-theme="dark"] .customer-profile-summary,
html[data-theme="dark"] summary {
  color:#e7edf3;
  background:var(--pf-ui-surface-soft);
  border-color:var(--pf-ui-line);
}

/* Forms */
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  color:#edf2f7 !important;
  background:#111820 !important;
  border-color:#455462 !important;
  box-shadow:none;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:#778692; opacity:1; }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color:#66a6ff !important;
  box-shadow:0 0 0 3px rgba(102,166,255,.16) !important;
}
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled,
html[data-theme="dark"] input[readonly],
html[data-theme="dark"] textarea[readonly] {
  color:#aeb9c3 !important;
  background:#202832 !important;
}
html[data-theme="dark"] option { color:#edf2f7; background:#111820; }
html[data-theme="dark"] label,
html[data-theme="dark"] legend { color:#d9e2ea; }
html[data-theme="dark"] .field-error { color:#ff929b; }

/* Buttons */
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] button.button.secondary,
html[data-theme="dark"] a.button.secondary,
html[data-theme="dark"] button:not(.button):not(.sidebar-item):not(.top-dropdown-toggle):not(.user-menu-toggle):not(.calculator-link):not(.login-theme-toggle) {
  border-color:#52616e;
  background:#202932;
  color:#dbe4ec;
}
html[data-theme="dark"] .button.secondary:hover:not(:disabled),
html[data-theme="dark"] button.button.secondary:hover:not(:disabled),
html[data-theme="dark"] a.button.secondary:hover,
html[data-theme="dark"] button:not(.button):not(.sidebar-item):not(.top-dropdown-toggle):not(.user-menu-toggle):not(.calculator-link):not(.login-theme-toggle):hover:not(:disabled) {
  border-color:#71808d;
  background:#2a3641;
  color:#fff;
}
html[data-theme="dark"] .button,
html[data-theme="dark"] button.button,
html[data-theme="dark"] a.button,
html[data-theme="dark"] .legacy-add-button { color:#07111a; }

/* Tables and grids */
html[data-theme="dark"] table { color:#e3eaf0; }
html[data-theme="dark"] th,
html[data-theme="dark"] .legacy-grid-body thead th,
html[data-theme="dark"] .table-scroll > table thead th {
  color:#dce5ec !important;
  background:#202a33 !important;
  border-color:#3a4855 !important;
}
html[data-theme="dark"] td,
html[data-theme="dark"] .legacy-grid-body tbody td,
html[data-theme="dark"] .table-scroll > table tbody td {
  color:#d8e1e9;
  background:#171e25;
  border-color:#313e49 !important;
}
html[data-theme="dark"] tbody tr:nth-child(even) td { background:#1a222a; }
html[data-theme="dark"] tbody tr:hover td { background:#24303a !important; }
html[data-theme="dark"] .legacy-grid-body,
html[data-theme="dark"] .table-scroll { background:#171e25; }
html[data-theme="dark"] .pager,
html[data-theme="dark"] .legacy-grid-body .pager,
html[data-theme="dark"] body.legacy-resource-page #record-list > .pager {
  color:var(--pf-ui-muted);
  background:#171e25;
  border-color:var(--pf-ui-line);
}

/* Filters/toolbars */
html[data-theme="dark"] .standard-filters,
html[data-theme="dark"] .list-toolbar,
html[data-theme="dark"] .legacy-grid-before,
html[data-theme="dark"] .legacy-resource-before,
html[data-theme="dark"] .billing-toolbar,
html[data-theme="dark"] .billing-filters,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .filter-fields {
  color:#dce4eb;
  background:#171e25;
  border-color:#34414d !important;
}

/* Dialogs / overlays */
html[data-theme="dark"] dialog {
  color:var(--pf-ui-ink);
  background:#171e25;
  border-color:#455462;
  box-shadow:var(--pf-ui-dialog-shadow);
}
html[data-theme="dark"] dialog::backdrop { background:rgba(0,0,0,.72); }
html[data-theme="dark"] dialog hr,
html[data-theme="dark"] hr { border-color:#34414d; }

/* Tabs */
html[data-theme="dark"] #main button[role="tab"],
html[data-theme="dark"] dialog button[role="tab"],
html[data-theme="dark"] .customer-tab {
  color:#aebac5 !important;
  background:#171e25 !important;
  border-color:#34414d !important;
}
html[data-theme="dark"] #main button[role="tab"][aria-selected="true"],
html[data-theme="dark"] dialog button[role="tab"][aria-selected="true"],
html[data-theme="dark"] .customer-tab.active,
html[data-theme="dark"] .customer-tab[aria-selected="true"] {
  color:#7fb4ff !important;
  background:#202a33 !important;
  border-bottom-color:#66a6ff !important;
}

/* Common notices / status chips */
html[data-theme="dark"] .notice,
html[data-theme="dark"] .billing-alert,
html[data-theme="dark"] .legacy-module-note,
html[data-theme="dark"] .billing-empty {
  color:#d9e3eb;
  background:#1c2730;
  border-color:#455462;
}
html[data-theme="dark"] .notice.error,
html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .error-summary {
  color:#ffc0c5;
  background:#3a1f24;
  border-color:#763d46;
}
html[data-theme="dark"] .notice.success,
html[data-theme="dark"] .alert-success {
  color:#b7f0cf;
  background:#173226;
  border-color:#2f6b4c;
}
html[data-theme="dark"] .notice.warning,
html[data-theme="dark"] .alert-warning {
  color:#f2ddb0;
  background:#372d18;
  border-color:#76612d;
}

/* Module-specific light surfaces that otherwise leak through. */
html[data-theme="dark"] [class*="billing-"][class*="card"],
html[data-theme="dark"] [class*="billing-"][class*="summary"],
html[data-theme="dark"] [class*="legacy-rental-"][class*="card"],
html[data-theme="dark"] [class*="legacy-rental-"][class*="panel"],
html[data-theme="dark"] [class*="customer-"][class*="card"],
html[data-theme="dark"] [class*="customer-"][class*="panel"],
html[data-theme="dark"] [class*="customer-"][class*="summary"],
html[data-theme="dark"] [class*="calendar-"][class*="panel"],
html[data-theme="dark"] [class*="inventory-"][class*="panel"] {
  color:#dce4eb;
  background:#171e25;
  border-color:#34414d;
}
html[data-theme="dark"] pre,
html[data-theme="dark"] code {
  color:#dce7f0;
  background:#10171d;
  border-color:#33414c;
}

/* Calendar / FullCalendar */
html[data-theme="dark"] .fc {
  --fc-page-bg-color:#171e25;
  --fc-neutral-bg-color:#202a33;
  --fc-neutral-text-color:#aeb9c3;
  --fc-border-color:#3b4854;
  --fc-button-text-color:#e7edf3;
  --fc-button-bg-color:#273440;
  --fc-button-border-color:#52616e;
  --fc-button-hover-bg-color:#334451;
  --fc-button-hover-border-color:#71808d;
  --fc-button-active-bg-color:#3b5268;
  --fc-button-active-border-color:#7ea9cf;
  --fc-today-bg-color:rgba(102,166,255,.11);
  color:#e7edf3;
}
html[data-theme="dark"] .fc .fc-col-header-cell,
html[data-theme="dark"] .fc .fc-daygrid-day,
html[data-theme="dark"] .fc .fc-timegrid-slot { background:#171e25; }
html[data-theme="dark"] .fc .fc-scrollgrid,
html[data-theme="dark"] .fc-theme-standard td,
html[data-theme="dark"] .fc-theme-standard th { border-color:#3b4854; }

/* Login */
html[data-theme="dark"] body.login-page {
  background-color:#0a0e12;
  background-blend-mode:multiply;
}
html[data-theme="dark"] .login-card {
  color:#e7edf3;
  background:rgba(20,27,33,.96);
  border-color:#41505c;
  box-shadow:0 24px 70px rgba(0,0,0,.58);
}
html[data-theme="dark"] .login-theme-toggle {
  color:#dce5ec;
  background:rgba(23,30,37,.94);
  border-color:#4b5a67;
}
html[data-theme="dark"] .login-theme-toggle:hover { background:#26323d; }

/* Scrollbars */
html[data-theme="dark"] * { scrollbar-color:#536575 #151c22; }
html[data-theme="dark"] *::-webkit-scrollbar { width:12px; height:12px; }
html[data-theme="dark"] *::-webkit-scrollbar-track { background:#151c22; }
html[data-theme="dark"] *::-webkit-scrollbar-thumb { background:#536575; border:3px solid #151c22; border-radius:999px; }
html[data-theme="dark"] *::-webkit-scrollbar-thumb:hover { background:#667b8d; }

/* ==========================================================================\n   PortuFlow Dark Theme v2 — hardening / token parity\n   This block intentionally comes last. Legacy modules contain highly specific\n   light-theme selectors, so dark mode must win without changing their layout.\n   ========================================================================== */
html[data-theme="dark"] {
  --pf-theme-bg:#0d1318;
  --pf-theme-sidebar:#10171d;
  --pf-theme-header:#141c23;
  --pf-theme-surface:#171f27;
  --pf-theme-surface-2:#1d2730;
  --pf-theme-surface-3:#25313c;
  --pf-theme-control:#121a21;
  --pf-theme-text:#e7edf3;
  --pf-theme-text-soft:#c3ced7;
  --pf-theme-muted:#91a0ac;
  --pf-theme-border:#34424e;
  --pf-theme-border-strong:#4b5b68;
  --pf-theme-accent:#72adff;
  --pf-theme-accent-soft:#243b54;
  --pf-theme-row:#171f27;
  --pf-theme-row-alt:#1b242d;
  --pf-theme-row-hover:#24313c;
}

/* Core surfaces */
html[data-theme="dark"] body,
html[data-theme="dark"] body.portuflow-shell,
html[data-theme="dark"] #main,
html[data-theme="dark"] #page,
html[data-theme="dark"] main {
  background:var(--pf-theme-bg)!important;
  color:var(--pf-theme-text)!important;
}
html[data-theme="dark"] .app-header {
  background:var(--pf-theme-header)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .app-brand {
  background:transparent!important;
}
html[data-theme="dark"] .app-brand img {
  box-sizing:border-box;
  padding:0;
  border-radius:0;
  background:transparent;
}

/* Sidebar: legacy shell explicitly paints every item white in light mode. */
html[data-theme="dark"] #sidebar-wrapper,
html[data-theme="dark"] .app-sidebar,
html[data-theme="dark"] .sidebar-brand-row,
html[data-theme="dark"] .menu-group,
html[data-theme="dark"] .sidebar-exit,
html[data-theme="dark"] .has-submenu,
html[data-theme="dark"] .submenu {
  background:var(--pf-theme-sidebar)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .sidebar-item,
html[data-theme="dark"] .submenu-toggle,
html[data-theme="dark"] .submenu a {
  background:transparent!important;
  color:var(--pf-theme-text-soft)!important;
}
html[data-theme="dark"] .sidebar-item:hover,
html[data-theme="dark"] .submenu-toggle:hover,
html[data-theme="dark"] .submenu a:hover {
  background:var(--pf-theme-surface-2)!important;
  color:#fff!important;
}
html[data-theme="dark"] .sidebar-item[aria-current="page"],
html[data-theme="dark"] .sidebar-item.active,
html[data-theme="dark"] .submenu a[aria-current="page"] {
  background:var(--pf-theme-accent-soft)!important;
  color:#fff!important;
}
html[data-theme="dark"] .sidebar-item.danger,
html[data-theme="dark"] #sidebar-logout { color:#ff8792!important; }
html[data-theme="dark"] .sidebar-icon svg { fill:currentColor!important; }

/* Header/dropdowns */
html[data-theme="dark"] .top-nav a,
html[data-theme="dark"] .top-dropdown-toggle,
html[data-theme="dark"] .calculator-link,
html[data-theme="dark"] .user-menu-toggle {
  background:transparent!important;
  color:var(--pf-theme-text-soft)!important;
}
html[data-theme="dark"] .top-nav a:hover,
html[data-theme="dark"] .top-dropdown-toggle:hover,
html[data-theme="dark"] .calculator-link:hover,
html[data-theme="dark"] .user-menu-toggle:hover {
  background:var(--pf-theme-surface-2)!important;
  color:#fff!important;
}
html[data-theme="dark"] .user-menu,
html[data-theme="dark"] .top-dropdown-menu {
  background:var(--pf-theme-surface-2)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] .user-menu button,
html[data-theme="dark"] .top-dropdown-menu a,
html[data-theme="dark"] #theme-toggle {
  background:transparent!important;
  color:var(--pf-theme-text)!important;
}
html[data-theme="dark"] #logout { color:#ff8792!important; }
html[data-theme="dark"] .user-menu button:hover,
html[data-theme="dark"] .top-dropdown-menu a:hover {
  background:var(--pf-theme-surface-3)!important;
  color:#fff!important;
}

/* Unified containers + legacy module containers */
html[data-theme="dark"] .card,
html[data-theme="dark"] .billing-panel,
html[data-theme="dark"] .legacy-grid-panel,
html[data-theme="dark"] .legacy-resource-panel,
html[data-theme="dark"] body.legacy-resource-page #record-list.legacy-resource-panel,
html[data-theme="dark"] .legacy-rental-detail-hero,
html[data-theme="dark"] .legacy-rental-detail-section,
html[data-theme="dark"] .legacy-rental-items-wrap,
html[data-theme="dark"] .legacy-rental-job-plan-section,
html[data-theme="dark"] .legacy-rental-repeat-settings,
html[data-theme="dark"] .legacy-rental-overview,
html[data-theme="dark"] .legacy-rental-metric,
html[data-theme="dark"] .legacy-rental-overview-details,
html[data-theme="dark"] .legacy-rental-job-summary-grid,
html[data-theme="dark"] .billing-ruc-card,
html[data-theme="dark"] .billing-form-section,
html[data-theme="dark"] .customer-profile-summary,
html[data-theme="dark"] .customer-tab-panel,
html[data-theme="dark"] .customer-tab-table-wrap,
html[data-theme="dark"] .customer-dossier-body,
html[data-theme="dark"] .customer-dossier-content,
html[data-theme="dark"] details,
html[data-theme="dark"] fieldset {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .billing-panel-title,
html[data-theme="dark"] .legacy-grid-heading,
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-heading,
html[data-theme="dark"] .dialog-heading,
html[data-theme="dark"] .legacy-dialog-heading,
html[data-theme="dark"] .customer-profile-head,
html[data-theme="dark"] summary {
  background:var(--pf-theme-surface-2)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}

/* Toolbars / filter rows / list chrome */
html[data-theme="dark"] .standard-filters,
html[data-theme="dark"] .list-toolbar,
html[data-theme="dark"] .legacy-grid-before,
html[data-theme="dark"] .legacy-grid-after,
html[data-theme="dark"] .legacy-resource-before,
html[data-theme="dark"] .legacy-resource-extra-filters,
html[data-theme="dark"] .billing-toolbar,
html[data-theme="dark"] .billing-filters,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .filter-fields,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-before,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-after {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}

/* Tables: exact legacy selectors are intentionally repeated with !important. */
html[data-theme="dark"] table,
html[data-theme="dark"] .table-scroll,
html[data-theme="dark"] .legacy-grid-body,
html[data-theme="dark"] body.legacy-resource-page #record-list {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
}
html[data-theme="dark"] table thead th,
html[data-theme="dark"] .table-scroll > table thead th,
html[data-theme="dark"] .legacy-grid-body table thead th,
html[data-theme="dark"] body.legacy-resource-page #record-list thead th,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body thead th,
html[data-theme="dark"] body[data-page="users"] .legacy-filter-row th {
  background:var(--pf-theme-surface-2)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] table tbody td,
html[data-theme="dark"] .table-scroll > table tbody td,
html[data-theme="dark"] .legacy-grid-body table tbody td,
html[data-theme="dark"] body.legacy-resource-page #record-list tbody td,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body tbody td,
html[data-theme="dark"] .billing-detail-table td,
html[data-theme="dark"] .billing-detail-lines td,
html[data-theme="dark"] .billing-ruc-result td,
html[data-theme="dark"] .billing-lines-editor td,
html[data-theme="dark"] .legacy-rental-detail-table td,
html[data-theme="dark"] .legacy-rental-linked-jobs-table td,
html[data-theme="dark"] .legacy-rental-items-table td {
  background:var(--pf-theme-row)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] table tbody tr:nth-child(even) > td,
html[data-theme="dark"] .table-scroll > table tbody tr:nth-child(even) > td,
html[data-theme="dark"] .legacy-grid-body table tbody tr:nth-child(even) > td,
html[data-theme="dark"] body.legacy-resource-page #record-list tbody tr:nth-child(even) > td,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body tbody tr:nth-child(even) > td {
  background:var(--pf-theme-row-alt)!important;
}
html[data-theme="dark"] table tbody tr:hover > td,
html[data-theme="dark"] .table-scroll > table tbody tr:hover > td,
html[data-theme="dark"] .legacy-grid-body table tbody tr:hover > td,
html[data-theme="dark"] body.legacy-resource-page #record-list tbody tr:hover > td,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body tbody tr:hover > td {
  background:var(--pf-theme-row-hover)!important;
}
html[data-theme="dark"] .pager,
html[data-theme="dark"] .legacy-grid-body .pager,
html[data-theme="dark"] body.legacy-resource-page #record-list .pager,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body .pager {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-muted)!important;
  border-color:var(--pf-theme-border)!important;
}

/* Form controls */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] body.legacy-resource-page #record-list select,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body select {
  background:var(--pf-theme-control)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:#758592!important; }
html[data-theme="dark"] option { background:var(--pf-theme-control);color:var(--pf-theme-text); }
html[data-theme="dark"] label,
html[data-theme="dark"] legend { color:var(--pf-theme-text-soft)!important; }

/* Secondary/action buttons that are hard-coded white by legacy modules. */
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] a.button.secondary,
html[data-theme="dark"] button.button.secondary,
html[data-theme="dark"] .row-actions button,
html[data-theme="dark"] .legacy-grid-body .row-actions button,
html[data-theme="dark"] body[data-page="users"] .legacy-grid-body .row-actions button,
html[data-theme="dark"] .legacy-rental-close-button,
html[data-theme="dark"] .legacy-add-product,
html[data-theme="dark"] .legacy-rental-job-summary > summary,
html[data-theme="dark"] .pager .button.secondary {
  background:var(--pf-theme-surface-2)!important;
  color:var(--pf-theme-text-soft)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] .button.secondary:hover:not(:disabled),
html[data-theme="dark"] .row-actions button:hover:not(:disabled),
html[data-theme="dark"] .pager .button.secondary:hover:not(:disabled) {
  background:var(--pf-theme-surface-3)!important;
  color:#fff!important;
}
/* Preserve semantic border/icon colors on action buttons without white fills. */
html[data-theme="dark"] .row-actions button[data-action="Editar"] { color:#72adff!important;border-color:#4d8fef!important; }
html[data-theme="dark"] .row-actions button[data-action="Consultar"] { color:#c1ccd5!important;border-color:#657684!important; }
html[data-theme="dark"] .row-actions button[data-action="Desactivar"] { color:#ff8792!important;border-color:#b94e59!important; }
html[data-theme="dark"] .row-actions button[data-action="Activar"] { color:#6ed39a!important;border-color:#3b8b60!important; }

/* Dialogs */
html[data-theme="dark"] dialog,
html[data-theme="dark"] .legacy-form-dialog,
html[data-theme="dark"] .legacy-operation-dialog {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] dialog::backdrop { background:rgba(0,0,0,.76)!important; }

/* Tabs */
html[data-theme="dark"] #main button[role="tab"],
html[data-theme="dark"] dialog button[role="tab"],
html[data-theme="dark"] .customer-tab,
html[data-theme="dark"] .calendar-tab {
  background:transparent!important;
  color:var(--pf-theme-text-soft)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] #main button[role="tab"][aria-selected="true"],
html[data-theme="dark"] dialog button[role="tab"][aria-selected="true"],
html[data-theme="dark"] .customer-tab.active,
html[data-theme="dark"] .customer-tab[aria-selected="true"],
html[data-theme="dark"] .calendar-tab.active {
  background:var(--pf-theme-surface-2)!important;
  color:var(--pf-theme-accent)!important;
  border-bottom-color:var(--pf-theme-accent)!important;
}

/* Billing / rental / customer module light leaks */
html[data-theme="dark"] .billing-subnav a,
html[data-theme="dark"] .billing-contract-context,
html[data-theme="dark"] .billing-summary-cell,
html[data-theme="dark"] .legacy-rental-info-field,
html[data-theme="dark"] .legacy-rental-table-wrap,
html[data-theme="dark"] .customer-profile-meta,
html[data-theme="dark"] .customer-tab-toolbar,
html[data-theme="dark"] .customer-tab-footer {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}

/* Calendar / map surrounding UI. Google map tiles remain provided by Google. */
html[data-theme="dark"] #calendar-pane,
html[data-theme="dark"] #map-pane,
html[data-theme="dark"] .calendar-toolbar,
html[data-theme="dark"] .calendar-filter-grid,
html[data-theme="dark"] .calendar-picker-panel,
html[data-theme="dark"] #map-legend {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .map-route-block,
html[data-theme="dark"] .map-route-heading { border-color:var(--pf-theme-border)!important; }
html[data-theme="dark"] .map-route-stop,
html[data-theme="dark"] .map-route-count,
html[data-theme="dark"] .map-route-status { color:var(--pf-theme-muted)!important; }
html[data-theme="dark"] .site-map-canvas {
  background:#111820!important;
  border-color:var(--pf-theme-border-strong)!important;
}

/* Notices */
html[data-theme="dark"] .notice,
html[data-theme="dark"] .legacy-module-note,
html[data-theme="dark"] .billing-empty,
html[data-theme="dark"] .map-message {
  background:#1c2730!important;
  color:var(--pf-theme-text-soft)!important;
  border-color:var(--pf-theme-border-strong)!important;
}

/* FullCalendar token parity */
html[data-theme="dark"] .fc {
  --fc-page-bg-color:var(--pf-theme-surface);
  --fc-neutral-bg-color:var(--pf-theme-surface-2);
  --fc-neutral-text-color:var(--pf-theme-muted);
  --fc-border-color:var(--pf-theme-border);
  --fc-button-text-color:var(--pf-theme-text);
  --fc-button-bg-color:var(--pf-theme-surface-2);
  --fc-button-border-color:var(--pf-theme-border-strong);
  --fc-button-hover-bg-color:var(--pf-theme-surface-3);
  --fc-button-hover-border-color:#6b7d8b;
  --fc-button-active-bg-color:#30465a;
  --fc-button-active-border-color:#6f9bc2;
  --fc-today-bg-color:rgba(114,173,255,.10);
}

/* Login + scrollbars */
html[data-theme="dark"] .login-card { background:rgba(20,28,35,.97)!important; }
html[data-theme="dark"] * { scrollbar-color:#536575 #151c22; }

/* ==========================================================================\n   PortuFlow Dark Theme v3 — cascade/order + module heading parity\n   ========================================================================== */
html[data-theme="dark"] {
  --pf-ui-control-bg:var(--pf-theme-control);
  --pf-ui-control-border:var(--pf-theme-border-strong);
  --pf-ui-text-strong:var(--pf-theme-text);
  --pf-ui-text-soft:var(--pf-theme-text-soft);
  --pf-ui-row:var(--pf-theme-row);
  --pf-ui-row-alt:var(--pf-theme-row-alt);
}

/* Legacy resource headings are injected after boot and their CSS uses more
   specific selectors than generic h2 rules. Match that specificity exactly. */
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-heading h2,
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-heading h2 span,
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-icon,
html[data-theme="dark"] .legacy-grid-heading h2,
html[data-theme="dark"] .legacy-grid-heading h2 span,
html[data-theme="dark"] .legacy-grid-icon,
html[data-theme="dark"] .billing-panel-title h2,
html[data-theme="dark"] .billing-panel-title h3,
html[data-theme="dark"] .page-heading h1,
html[data-theme="dark"] .billing-page-head h1 {
  color:var(--pf-theme-text)!important;
}
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-icon svg,
html[data-theme="dark"] .legacy-grid-icon svg,
html[data-theme="dark"] .billing-title-icon {
  fill:currentColor!important;
  color:var(--pf-theme-text-soft)!important;
}
html[data-theme="dark"] body.legacy-resource-page .legacy-resource-summary,
html[data-theme="dark"] .legacy-grid-summary,
html[data-theme="dark"] .page-heading + .muted {
  color:var(--pf-theme-muted)!important;
}

/* Rental module contains many original light-only blocks. Normalize every
   surface while retaining semantic status/accent colors. */
html[data-theme="dark"] .legacy-rental-detail-hero,
html[data-theme="dark"] .legacy-rental-detail-section,
html[data-theme="dark"] .legacy-rental-info-field,
html[data-theme="dark"] .legacy-rental-table-wrap,
html[data-theme="dark"] .legacy-rental-contract-block,
html[data-theme="dark"] .legacy-rental-items-wrap,
html[data-theme="dark"] .legacy-rental-flow-card,
html[data-theme="dark"] .legacy-rental-linked-jobs,
html[data-theme="dark"] .legacy-rental-job-plan-section,
html[data-theme="dark"] .legacy-rental-job-editor,
html[data-theme="dark"] .legacy-rental-repeat-settings,
html[data-theme="dark"] .legacy-rental-overview,
html[data-theme="dark"] .legacy-rental-metric,
html[data-theme="dark"] .legacy-rental-overview-details,
html[data-theme="dark"] .legacy-rental-job-summary-grid {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .legacy-rental-section-heading,
html[data-theme="dark"] .legacy-rental-job-plan-heading,
html[data-theme="dark"] .legacy-rental-job-editor-heading,
html[data-theme="dark"] .legacy-rental-job-group>h4,
html[data-theme="dark"] .legacy-rental-metrics,
html[data-theme="dark"] .legacy-rental-overview-details>summary {
  background:var(--pf-theme-surface-2)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .legacy-rental-hero-title h3,
html[data-theme="dark"] .legacy-rental-info-field strong,
html[data-theme="dark"] .legacy-rental-flow-card strong,
html[data-theme="dark"] .legacy-rental-job-editor-heading strong,
html[data-theme="dark"] .legacy-rental-metric strong,
html[data-theme="dark"] .legacy-rental-site-summary strong,
html[data-theme="dark"] .legacy-rental-job-summary-grid dd {
  color:var(--pf-theme-text)!important;
}
html[data-theme="dark"] .legacy-rental-number,
html[data-theme="dark"] .legacy-rental-info-field small,
html[data-theme="dark"] .legacy-rental-contract-block p,
html[data-theme="dark"] .legacy-rental-flow-card>span:last-child,
html[data-theme="dark"] .legacy-rental-job-plan-heading p,
html[data-theme="dark"] .legacy-rental-metric small,
html[data-theme="dark"] .legacy-rental-metric span,
html[data-theme="dark"] .legacy-rental-site-summary span,
html[data-theme="dark"] .legacy-rental-job-summary-grid dt {
  color:var(--pf-theme-muted)!important;
}
html[data-theme="dark"] .legacy-rental-section-heading h3,
html[data-theme="dark"] .legacy-rental-contract-block h3,
html[data-theme="dark"] .legacy-rental-linked-jobs>h3,
html[data-theme="dark"] .legacy-rental-job-plan-heading h3,
html[data-theme="dark"] .legacy-rental-overview-details>summary {
  color:var(--pf-theme-accent)!important;
}
html[data-theme="dark"] .legacy-rental-form .legacy-reference-value,
html[data-theme="dark"] .legacy-rental-form .legacy-readonly-value {
  background:var(--pf-theme-control)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border-strong)!important;
}

/* Common module-specific text that otherwise inherits light hard-codes. */
html[data-theme="dark"] .customer-profile-name,
html[data-theme="dark"] .customer-tab-panel h2,
html[data-theme="dark"] .customer-tab-panel h3,
html[data-theme="dark"] .billing-panel strong,
html[data-theme="dark"] .jobs-detail h2,
html[data-theme="dark"] .jobs-detail h3,
html[data-theme="dark"] .legacy-form-dialog h2,
html[data-theme="dark"] .legacy-form-dialog h3,
html[data-theme="dark"] .legacy-operation-dialog h2,
html[data-theme="dark"] .legacy-operation-dialog h3 {
  color:var(--pf-theme-text)!important;
}

/* Keep filter/header rows dark even when dynamically injected legacy CSS lands
   after the initial page styles. */
html[data-theme="dark"] body.legacy-resource-page #record-list .legacy-resource-filter-row th,
html[data-theme="dark"] body[data-page="users"] .legacy-filter-row th {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text-soft)!important;
  border-color:var(--pf-theme-border)!important;
}

/* Remaining legacy light surfaces shared by Jobs, Recurrence, Calendar, Billing
   and Users. These are visual-only overrides; semantic warning/success colors
   remain intact. */
html[data-theme="dark"] .legacy-operation-step,
html[data-theme="dark"] .legacy-repeat-panel,
html[data-theme="dark"] .legacy-repeat-stats>div,
html[data-theme="dark"] .legacy-php-table,
html[data-theme="dark"] .legacy-photo-placeholder,
html[data-theme="dark"] .legacy-rental-job-box,
html[data-theme="dark"] .legacy-rental-job-summary-field,
html[data-theme="dark"] .legacy-repeat-settings,
html[data-theme="dark"] .legacy-repeat-days,
html[data-theme="dark"] .legacy-form-note,
html[data-theme="dark"] .legacy-recurrence-form .legacy-day-grid,
html[data-theme="dark"] .legacy-dynamic-form .legacy-reference-field,
html[data-theme="dark"] .legacy-contract-block .form-grid,
html[data-theme="dark"] .legacy-job-form .legacy-form-intro,
html[data-theme="dark"] .legacy-form .form-actions,
html[data-theme="dark"] .legacy-dynamic-form .legacy-form-actions,
html[data-theme="dark"] body[data-page="users"] .legacy-password-reset,
html[data-theme="dark"] body[data-page="users"] .legacy-profile-photo-preview,
html[data-theme="dark"] body[data-page="users"] .legacy-profile-photo-controls>input[type=file],
html[data-theme="dark"] .billing-form-section,
html[data-theme="dark"] .billing-contract-context>div,
html[data-theme="dark"] .billing-live-totals>div,
html[data-theme="dark"] .calendar-filter-card,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .calendar-picker-panel,
html[data-theme="dark"] .scheduler,
html[data-theme="dark"] .scheduler-resource-cell,
html[data-theme="dark"] .scheduler-event {
  background:var(--pf-theme-surface)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .scheduler-event:hover,
html[data-theme="dark"] .calendar-picker-option:hover {
  background:var(--pf-theme-surface-3)!important;
  color:#fff!important;
}
html[data-theme="dark"] .calendar-filter-field select,
html[data-theme="dark"] .calendar-filter-field input,
html[data-theme="dark"] .calendar-picker-button {
  background:var(--pf-theme-control)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] .billing-subnav a {
  background:var(--pf-theme-surface-2)!important;
  color:var(--pf-theme-text-soft)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] .billing-subnav a:hover,
html[data-theme="dark"] .billing-subnav a.active,
html[data-theme="dark"] .billing-subnav a[aria-current="page"] {
  background:var(--pf-theme-accent-soft)!important;
  color:#fff!important;
}

/* PortuFlow merge compatibility — 2026-10-05
   Dark-mode coverage for controls added after the v1.19 visual branch. */
html[data-theme="dark"] .column-filter-toolbar {
  background:var(--pf-theme-surface)!important;
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .column-filter-toolbar .column-filter-sort,
html[data-theme="dark"] .column-filter-orphan,
html[data-theme="dark"] .column-filter-row .column-filter-mini-label,
html[data-theme="dark"] .standard-filters .filter-lookup-name {
  color:var(--pf-theme-muted)!important;
}
html[data-theme="dark"] .column-filter-toolbar .column-filter-sort select,
html[data-theme="dark"] .column-filter-row .column-filter-input,
html[data-theme="dark"] .column-filter-orphan .column-filter-input,
html[data-theme="dark"] .standard-filters .filter-lookup-control input,
html[data-theme="dark"] .standard-filters .filter-lookup-control select {
  background:var(--pf-theme-control)!important;
  color:var(--pf-theme-text)!important;
  border-color:var(--pf-theme-border-strong)!important;
}
html[data-theme="dark"] .job-reconstruction {
  border-color:var(--pf-theme-border)!important;
}
html[data-theme="dark"] .job-reconstruction-readonly,
html[data-theme="dark"] .job-reconstruction-badge.is-unknown {
  color:var(--pf-theme-muted)!important;
  background:var(--pf-theme-surface-2)!important;
}
html[data-theme="dark"] .job-reconstruction-badge.is-estimated {
  color:#f2ca72!important;
  background:#3b3019!important;
}

/* The general search must remain legible in dark mode. */
html[data-theme="dark"] .column-filter-toolbar .pf-list-general-search input[type="search"] {
  background:#18212a; color:#e7edf3; border-color:#41505e;
}
html[data-theme="dark"] .column-filter-toolbar .pf-list-general-search input[type="search"]::placeholder {
  color:#9ca9b5; opacity:1;
}

/* Shared compact filter trigger: preserve contrast in dark mode even against legacy !important rules. */
html[data-theme="dark"] .pf-data-grid .pf-filter-toolbar .pf-filter-toggle.button.secondary,
html[data-theme="dark"] .calendar-unified-toolbar .pf-filter-toggle.button.secondary {
  background:#1f2a35 !important;
  color:#dce8f2 !important;
  border-color:#4a5c6d !important;
}
html[data-theme="dark"] .pf-filter-popover .pf-filter-panel-actions .pf-filter-apply {
  background:#66a6ff !important;
  color:#091723 !important;
  border-color:#66a6ff !important;
}

/* Portuflow 1.23.48 — tres estilos, un solo motor visual.
   Todas las paletas usan los mismos componentes y preservan la geometría. */
html[data-pf-palette="slate"][data-theme="light"] {
  --pf-sidebar-bg:#293d53; --pf-sidebar-ink:#eff5fc; --pf-sidebar-muted:#bacddd;
  --pf-sidebar-active:#426285; --pf-sidebar-hover:#354d67; --pf-sidebar-border:#415970;
  --pf-sidebar-sub:#21364d; --pf-sidebar-brand:#f6faff; --pf-sidebar-accent:#a6d2ff;
  --pf-header-bg:#fff; --pf-page-bg:#f3f6fa;
  --pf-ui-primary:#1769d2; --pf-ui-primary-hover:#1256ad;
  --pf-ui-ink:#263548; --pf-ui-muted:#63758a; --pf-ui-text-strong:#263548;
  --pf-ui-text-soft:#4e6277; --pf-ui-line:#dae2eb; --pf-ui-line-strong:#c6d2df;
  --pf-ui-surface:#fff; --pf-ui-surface-soft:#f3f6fa; --pf-ui-surface-hover:#e8f0fa;
  --pf-ui-row:#fff; --pf-ui-row-alt:#f8fafd;
  --pf-ui-control-bg:#fff; --pf-ui-control-border:#b8c9da;
  --primary:var(--pf-ui-primary); --surface:var(--pf-ui-surface-soft); --ink:var(--pf-ui-ink);
  --line:var(--pf-ui-line); --muted:var(--pf-ui-muted); --sidebar:var(--pf-sidebar-bg);
}
html[data-pf-palette="steel"][data-theme="light"] {
  --pf-sidebar-bg:#d6dee7; --pf-sidebar-ink:#263548; --pf-sidebar-muted:#52697f;
  --pf-sidebar-active:#b4cbe5; --pf-sidebar-hover:#c4d2e0; --pf-sidebar-border:#b9c8d6;
  --pf-sidebar-sub:#e6edf4; --pf-sidebar-brand:#203c56; --pf-sidebar-accent:#1658aa;
  --pf-header-bg:#fff; --pf-page-bg:#f8fafc;
  --pf-ui-primary:#1769d2; --pf-ui-primary-hover:#1256ad;
  --pf-ui-ink:#27374b; --pf-ui-muted:#607286; --pf-ui-text-strong:#27374b;
  --pf-ui-text-soft:#4d6175; --pf-ui-line:#dce3eb; --pf-ui-line-strong:#c4d2df;
  --pf-ui-surface:#fff; --pf-ui-surface-soft:#f6f9fc; --pf-ui-surface-hover:#ebf1f8;
  --pf-ui-row:#fff; --pf-ui-row-alt:#fafcfe;
  --pf-ui-control-bg:#fff; --pf-ui-control-border:#bfccda;
  --primary:var(--pf-ui-primary); --surface:var(--pf-ui-surface-soft); --ink:var(--pf-ui-ink);
  --line:var(--pf-ui-line); --muted:var(--pf-ui-muted); --sidebar:var(--pf-sidebar-bg);
}
html[data-pf-palette="petrol"][data-theme="light"] {
  --pf-sidebar-bg:#214750; --pf-sidebar-ink:#f0f9f8; --pf-sidebar-muted:#b8d8db;
  --pf-sidebar-active:#346e77; --pf-sidebar-hover:#2b5d65; --pf-sidebar-border:#37616a;
  --pf-sidebar-sub:#1c3d45; --pf-sidebar-brand:#f0f9f8; --pf-sidebar-accent:#b9eeea;
  --pf-header-bg:#fff; --pf-page-bg:#f5f8f8;
  --pf-ui-primary:#166f77; --pf-ui-primary-hover:#115b62;
  --pf-ui-ink:#243d43; --pf-ui-muted:#59737a; --pf-ui-text-strong:#243d43;
  --pf-ui-text-soft:#4c676e; --pf-ui-line:#dae6e5; --pf-ui-line-strong:#bad1cf;
  --pf-ui-surface:#fff; --pf-ui-surface-soft:#f1f7f6; --pf-ui-surface-hover:#e6f2f0;
  --pf-ui-row:#fff; --pf-ui-row-alt:#f9fcfb;
  --pf-ui-control-bg:#fff; --pf-ui-control-border:#b6cac8;
  --primary:var(--pf-ui-primary); --surface:var(--pf-ui-surface-soft); --ink:var(--pf-ui-ink);
  --line:var(--pf-ui-line); --muted:var(--pf-ui-muted); --sidebar:var(--pf-sidebar-bg);
}
html[data-pf-palette="slate"][data-theme="dark"] {
  --pf-sidebar-bg:#121e2c; --pf-sidebar-ink:#eaf3ff; --pf-sidebar-muted:#a5bdd4;
  --pf-sidebar-active:#294b70; --pf-sidebar-hover:#203850; --pf-sidebar-border:#2f445a;
  --pf-sidebar-sub:#172838; --pf-sidebar-brand:#eaf3ff; --pf-sidebar-accent:#9bd0ff;
  --pf-header-bg:#1b2735; --pf-page-bg:#101923;
  --pf-ui-primary:#91c2ff; --pf-ui-primary-hover:#b5d8ff;
  --pf-ui-ink:#eaf1f9; --pf-ui-muted:#a6b7cb; --pf-ui-text-strong:#edf4fb;
  --pf-ui-text-soft:#d1deec; --pf-ui-line:#35485b; --pf-ui-line-strong:#496078;
  --pf-ui-surface:#1d2b3a; --pf-ui-surface-soft:#27384b; --pf-ui-surface-hover:#30465d;
  --pf-ui-row:#1d2b3a; --pf-ui-row-alt:#223246;
  --pf-ui-control-bg:#223346; --pf-ui-control-border:#52687e;
  --primary:var(--pf-ui-primary); --surface:var(--pf-ui-surface); --ink:var(--pf-ui-ink);
  --line:var(--pf-ui-line); --muted:var(--pf-ui-muted); --sidebar:var(--pf-sidebar-bg);
}
html[data-pf-palette="steel"][data-theme="dark"] {
  --pf-sidebar-bg:#202831; --pf-sidebar-ink:#ecf3fa; --pf-sidebar-muted:#a9bbc9;
  --pf-sidebar-active:#34465d; --pf-sidebar-hover:#2c3948; --pf-sidebar-border:#394756;
  --pf-sidebar-sub:#1b2530; --pf-sidebar-brand:#f0f5fa; --pf-sidebar-accent:#9ec9ff;
  --pf-header-bg:#242e39; --pf-page-bg:#151b23;
  --pf-ui-primary:#9ec9ff; --pf-ui-primary-hover:#bddcff;
  --pf-ui-ink:#edf3f9; --pf-ui-muted:#a9baca; --pf-ui-text-strong:#eff5fb;
  --pf-ui-text-soft:#d0deeb; --pf-ui-line:#415164; --pf-ui-line-strong:#586c80;
  --pf-ui-surface:#28333f; --pf-ui-surface-soft:#344251; --pf-ui-surface-hover:#3c4c5e;
  --pf-ui-row:#28333f; --pf-ui-row-alt:#2d3a47;
  --pf-ui-control-bg:#2b3947; --pf-ui-control-border:#586b7f;
  --primary:var(--pf-ui-primary); --surface:var(--pf-ui-surface); --ink:var(--pf-ui-ink);
  --line:var(--pf-ui-line); --muted:var(--pf-ui-muted); --sidebar:var(--pf-sidebar-bg);
}
html[data-pf-palette="petrol"][data-theme="dark"] {
  --pf-sidebar-bg:#10282e; --pf-sidebar-ink:#e8f7f5; --pf-sidebar-muted:#accfd0;
  --pf-sidebar-active:#20545d; --pf-sidebar-hover:#193f48; --pf-sidebar-border:#32565d;
  --pf-sidebar-sub:#10242a; --pf-sidebar-brand:#eaf9f7; --pf-sidebar-accent:#acf0ea;
  --pf-header-bg:#1d3035; --pf-page-bg:#101d22;
  --pf-ui-primary:#9ce8e1; --pf-ui-primary-hover:#b6f1ec;
  --pf-ui-ink:#e7f4f3; --pf-ui-muted:#abcaca; --pf-ui-text-strong:#edf9f8;
  --pf-ui-text-soft:#c9e3e1; --pf-ui-line:#35545b; --pf-ui-line-strong:#4a6b73;
  --pf-ui-surface:#20343a; --pf-ui-surface-soft:#29444a; --pf-ui-surface-hover:#315159;
  --pf-ui-row:#20343a; --pf-ui-row-alt:#254047;
  --pf-ui-control-bg:#294149; --pf-ui-control-border:#55757b;
  --primary:var(--pf-ui-primary); --surface:var(--pf-ui-surface); --ink:var(--pf-ui-ink);
  --line:var(--pf-ui-line); --muted:var(--pf-ui-muted); --sidebar:var(--pf-sidebar-bg);
}

/* Compatibilidad con la capa oscura previa, que usa tokens internos y !important.
   La paleta seleccionada prevalece sin duplicar sus reglas de componentes. */
html[data-pf-palette][data-theme="dark"] {
  --pf-theme-bg:var(--pf-page-bg);
  --pf-theme-sidebar:var(--pf-sidebar-bg);
  --pf-theme-header:var(--pf-header-bg);
  --pf-theme-surface:var(--pf-ui-surface);
  --pf-theme-surface-2:var(--pf-ui-surface-hover);
  --pf-theme-surface-3:var(--pf-ui-surface-soft);
  --pf-theme-control:var(--pf-ui-control-bg);
  --pf-theme-text:var(--pf-ui-ink);
  --pf-theme-text-soft:var(--pf-ui-text-soft);
  --pf-theme-muted:var(--pf-ui-muted);
  --pf-theme-border:var(--pf-ui-line);
  --pf-theme-border-strong:var(--pf-ui-line-strong);
  --pf-theme-accent:var(--pf-ui-primary);
  --pf-theme-accent-soft:var(--pf-sidebar-active);
  --pf-theme-row:var(--pf-ui-row);
  --pf-theme-row-alt:var(--pf-ui-row-alt);
  --pf-theme-row-hover:var(--pf-ui-surface-hover);
}

/* Menú: un solo contraste lateral, independientemente del modo. */
html[data-pf-palette] body.portuflow-shell #sidebar-wrapper,
html[data-pf-palette] body.portuflow-shell .app-sidebar {
  background:var(--pf-sidebar-bg); border-color:var(--pf-sidebar-border);
}
html[data-pf-palette] body.portuflow-shell .sidebar-brand-row {
  background:var(--pf-sidebar-bg); border-bottom:1px solid var(--pf-sidebar-border);
  min-height:48px; padding:0 10px 0 14px; margin-bottom:4px;
}
html[data-pf-palette] body.portuflow-shell .sidebar-brand { color:var(--pf-sidebar-brand); font-size:17px; }
html[data-pf-palette] body.portuflow-shell #sidebar-mini-toggle {
  background:transparent; border:1px solid var(--pf-sidebar-border);
  color:var(--pf-sidebar-ink); width:32px; height:32px; font-size:17px;
}
html[data-pf-palette] body.portuflow-shell #sidebar-mini-toggle:hover { background:var(--pf-sidebar-hover); }
html[data-pf-palette] body.portuflow-shell .sidebar-section-title {
  color:var(--pf-sidebar-muted); font-size:10px; font-weight:700;
  margin:14px 12px 5px; letter-spacing:1px;
}
html[data-pf-palette] body.portuflow-shell .sidebar-item {
  min-height:37px; padding:7px 12px; margin:1px 0; border:0;
  border-radius:7px; background:transparent;
  color:var(--pf-sidebar-ink); font-size:13px; font-weight:500;
}
html[data-pf-palette] body.portuflow-shell .sidebar-item:hover,
html[data-pf-palette] body.portuflow-shell .sidebar-item:focus-visible { background:var(--pf-sidebar-hover); color:var(--pf-sidebar-ink); }
html[data-pf-palette] body.portuflow-shell .sidebar-item[aria-current="page"],
html[data-pf-palette] body.portuflow-shell .sidebar-item.active {
  background:var(--pf-sidebar-active); color:var(--pf-sidebar-ink); font-weight:650;
  box-shadow:inset 3px 0 var(--pf-sidebar-accent);
}
html[data-pf-palette] body.portuflow-shell .sidebar-icon { color:inherit; width:22px; flex-basis:22px; margin-right:10px; }
html[data-pf-palette] body.portuflow-shell .submenu {
  background:var(--pf-sidebar-sub); padding:4px 7px 6px 30px; border:0; border-radius:8px;
}
html[data-pf-palette] body.portuflow-shell .submenu a {
  display:block; color:var(--pf-sidebar-ink); border-radius:5px;
  font-size:12px; padding:7px 9px;
}
html[data-pf-palette] body.portuflow-shell .submenu a:hover,
html[data-pf-palette] body.portuflow-shell .submenu a:focus-visible { background:var(--pf-sidebar-hover); color:var(--pf-sidebar-ink); }
html[data-pf-palette] body.portuflow-shell .submenu a[aria-current="page"] {
  color:var(--pf-sidebar-accent); background:var(--pf-sidebar-active); font-weight:700;
}
html[data-pf-palette] body.portuflow-shell .sidebar-exit {
  margin-top:auto; padding:10px 0 8px; border-top:1px solid var(--pf-sidebar-border);
  background:var(--pf-sidebar-bg);
}
html[data-pf-palette] body.portuflow-shell .sidebar-item.danger { color:#ffc2c2; }
html[data-pf-palette="steel"][data-theme="light"] body.portuflow-shell .sidebar-item.danger { color:#a52339; }
html[data-pf-palette] body.portuflow-shell.sidebar-mini .sidebar-item {
  width:44px; min-height:44px; margin:2px auto; padding:9px 0; justify-content:center;
}
html[data-pf-palette] body.portuflow-shell.sidebar-mini .sidebar-icon { margin:0; }
html[data-pf-palette] body.portuflow-shell.sidebar-mini #sidebar-mini-toggle { width:40px; height:40px; }
html[data-pf-palette] body.portuflow-shell.sidebar-mini .sidebar-brand-row { min-height:48px; }

/* Header y superficies usan tokens sin modificar tamaños o distribución. */
html[data-pf-palette] body.portuflow-shell .app-header {
  background:var(--pf-header-bg); border-bottom-color:var(--pf-ui-line);
}
html[data-pf-palette] body.portuflow-shell #pf-workspace,
html[data-pf-palette] body.portuflow-shell #pf-workspace #main {
  background:var(--pf-page-bg); color:var(--pf-ui-ink);
}
html[data-pf-palette] body.portuflow-shell .top-nav a,
html[data-pf-palette] body.portuflow-shell .top-dropdown-toggle,
html[data-pf-palette] body.portuflow-shell .calculator-link,
html[data-pf-palette] body.portuflow-shell .user-menu-toggle { color:var(--pf-ui-text-strong); }
html[data-pf-palette] body.portuflow-shell .top-nav a:hover,
html[data-pf-palette] body.portuflow-shell .top-dropdown-toggle:hover,
html[data-pf-palette] body.portuflow-shell .calculator-link:hover,
html[data-pf-palette] body.portuflow-shell .user-menu-toggle:hover { background:var(--pf-ui-surface-hover); color:var(--pf-ui-text-strong); }
html[data-pf-palette] body.portuflow-shell .user-identity strong { color:var(--pf-ui-text-strong); }
html[data-pf-palette] body.portuflow-shell .user-identity small,
html[data-pf-palette] body.portuflow-shell .chevron { color:var(--pf-ui-muted); }
html[data-pf-palette] body.portuflow-shell .user-menu,
html[data-pf-palette] body.portuflow-shell .top-dropdown-menu {
  color:var(--pf-ui-ink); background:var(--pf-ui-surface); border-color:var(--pf-ui-line);
}
html[data-pf-palette] body.portuflow-shell .user-menu button,
html[data-pf-palette] body.portuflow-shell .top-nav .top-dropdown-menu > a {
  background:transparent; color:var(--pf-ui-ink);
}
html[data-pf-palette] body.portuflow-shell .user-menu button:hover,
html[data-pf-palette] body.portuflow-shell .top-nav .top-dropdown-menu > a:hover {
  background:var(--pf-ui-surface-hover); color:var(--pf-ui-text-strong);
}
html[data-pf-palette] body.portuflow-shell > .portuflow-footer { background:#212529; border-color:transparent; }
html[data-pf-palette] body.portuflow-shell > .portuflow-footer .copyright,
html[data-pf-palette] body.portuflow-shell > .portuflow-footer .version { color:#ffc107; }
html[data-pf-palette] body.portuflow-shell .card,
html[data-pf-palette] body.portuflow-shell .legacy-grid-panel,
html[data-pf-palette] body.portuflow-shell .billing-panel { background:var(--pf-ui-surface); border-color:var(--pf-ui-line); }
html[data-pf-palette] body.portuflow-shell .breadcrumbs,
html[data-pf-palette] body.portuflow-shell .muted { color:var(--pf-ui-muted); }

/* Apariencia: 1 fila oculta en el perfil + panel flotante de 216 px. */
html[data-pf-palette] body.portuflow-shell .user-menu { z-index:100; }
html[data-pf-palette] body.portuflow-shell #appearance-toggle {
  display:flex; align-items:center; gap:9px;
  padding:8px 12px; min-height:36px; font-size:13px; text-align:left;
}
html[data-pf-palette] body.portuflow-shell .pf-appearance-chevron { margin-left:auto; font-size:16px; }
html[data-pf-palette] body.portuflow-shell #appearance-panel {
  position:absolute; top:0; right:calc(100% + 6px);
  width:216px; padding:10px; border:1px solid var(--pf-ui-line);
  border-radius:10px; background:var(--pf-ui-surface); color:var(--pf-ui-ink);
  box-shadow:0 8px 28px #0003; z-index:101;
}
html[data-pf-palette] body.portuflow-shell .pf-appearance-heading {
  margin:0 0 6px; font-size:11px; font-weight:700; letter-spacing:.03em;
  color:var(--pf-ui-muted);
}
html[data-pf-palette] body.portuflow-shell .pf-appearance-heading:not(:first-child) { margin-top:10px; }
html[data-pf-palette] body.portuflow-shell .pf-appearance-palettes,
html[data-pf-palette] body.portuflow-shell .pf-appearance-modes { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
html[data-pf-palette] body.portuflow-shell .user-menu #appearance-panel button {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3px; width:100%; min-height:50px; padding:5px 2px;
  border:1px solid var(--pf-ui-line); border-radius:7px;
  font-size:11px; font-weight:600; line-height:1.25; font-family:inherit; color:var(--pf-ui-ink); background:var(--pf-ui-surface-soft);
}
html[data-pf-palette] body.portuflow-shell .user-menu #appearance-panel .pf-appearance-modes button { min-height:39px; }
html[data-pf-palette] body.portuflow-shell .user-menu #appearance-panel button[aria-pressed="true"] {
  border-color:var(--pf-ui-primary); background:var(--pf-ui-surface-hover);
  box-shadow:inset 0 0 0 1px var(--pf-ui-primary);
}
html[data-pf-palette] body.portuflow-shell .user-menu #appearance-panel button:focus-visible {
  outline:2px solid var(--pf-ui-primary); outline-offset:2px;
}
html[data-pf-palette] body.portuflow-shell .pf-appearance-swatch {
  display:block; width:20px; height:15px; border-radius:4px; border:1px solid #0002;
}
html[data-pf-palette] body.portuflow-shell .pf-appearance-slate { background:#293d53; }
html[data-pf-palette] body.portuflow-shell .pf-appearance-steel { background:#d6dee7; }
html[data-pf-palette] body.portuflow-shell .pf-appearance-petrol { background:#214750; }
@media (max-width:700px) {
  html[data-pf-palette] body.portuflow-shell #appearance-panel { right:0; top:calc(100% + 6px); width:216px; }
}

/* Submenús de la barra contraída: se presentan fuera del scroll lateral. */
html[data-pf-palette] body.portuflow-shell ~ .pf-mini-flyout,
.pf-mini-flyout {
  position:fixed; z-index:140; width:228px; max-width:calc(100vw - 75px);
  max-height:calc(100dvh - 20px); overflow-y:auto;
  padding:8px; border:1px solid var(--pf-sidebar-border);
  border-radius:9px; color:var(--pf-sidebar-ink); background:var(--pf-sidebar-bg);
  box-shadow:0 10px 28px #0004;
}
.pf-mini-flyout-heading { font-size:11px; font-weight:700; padding:6px 9px; color:var(--pf-sidebar-muted); }
.pf-mini-flyout a { display:block; padding:9px; font-size:13px; line-height:1.25; border-radius:6px;
  color:var(--pf-sidebar-ink); text-decoration:none; }
.pf-mini-flyout a:hover,.pf-mini-flyout a:focus-visible { background:var(--pf-sidebar-hover); color:var(--pf-sidebar-ink); }
.pf-mini-flyout a[aria-current="page"] { background:var(--pf-sidebar-active); color:var(--pf-sidebar-accent); }
@media (prefers-reduced-motion:reduce) {
  html[data-pf-palette] body.portuflow-shell #sidebar-wrapper,
  html[data-pf-palette] body.portuflow-shell .sidebar-item { transition:none; }
}

/* ========================================================================
   v1.23.49 — paridad de contraste y geometría desde el primer render
   No cambia la estructura, los permisos, los datos ni las seis combinaciones.
   ======================================================================== */

/* Respetar hidden incluso cuando una clase .button, .sidebar-item o un
   componente de UI tiene un display explícito. Evita acciones prematuras. */
html[data-pf-palette] [hidden]:not([hidden="until-found"]) {
  display:none !important;
}

/* Los iconos insertados por los módulos no deben aparecer con el tamaño
   SVG intrínseco (300 × 150) antes de la hoja de su grid. */
html[data-pf-palette] .legacy-resource-heading .legacy-resource-icon svg,
html[data-pf-palette] .legacy-resource-heading .legacy-create svg,
html[data-pf-palette] .legacy-resource-before .legacy-create svg,
html[data-pf-palette] .legacy-grid-heading .legacy-grid-icon svg,
html[data-pf-palette] .legacy-add-button svg,
html[data-pf-palette] #record-list .row-actions svg {
  display:inline-block;
  flex:0 0 16px;
  width:16px;
  height:16px;
  min-width:16px;
  max-width:16px;
  max-height:16px;
  vertical-align:middle;
  fill:currentColor;
}
html[data-pf-palette] body.legacy-resource-page .legacy-resource-heading .legacy-create,
html[data-pf-palette] body.legacy-resource-page .legacy-resource-before .legacy-create {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  gap:6px;
  min-height:34px;
  max-width:100%;
  box-sizing:border-box;
  padding:6px 11px;
  font-size:13px;
  line-height:1.2;
  white-space:nowrap;
}

/* Inicio: las tarjetas reutilizan enlaces del menú para conservar permisos.
   El color lateral NUNCA debe heredarse dentro de tarjetas de fondo claro. */
html[data-pf-palette] body.portuflow-shell #home-links > a {
  display:flex;
  align-items:center;
  gap:9px;
  min-height:54px;
  box-sizing:border-box;
  padding:14px 16px;
  border:1px solid var(--pf-ui-line);
  border-radius:7px;
  background:var(--pf-ui-surface) !important;
  color:var(--pf-ui-text-strong) !important;
  font-weight:500;
  text-decoration:none;
}
html[data-pf-palette] body.portuflow-shell #home-links > a .sidebar-icon,
html[data-pf-palette] body.portuflow-shell #home-links > a .sidebar-text {
  color:inherit;
}
html[data-pf-palette] body.portuflow-shell #home-links > a:hover,
html[data-pf-palette] body.portuflow-shell #home-links > a:focus-visible {
  background:var(--pf-ui-surface-hover) !important;
  color:var(--pf-ui-primary) !important;
  border-color:var(--pf-ui-line-strong);
}

/* Trabajos servidos: listado normal (no usa decorador de iconos).
   Las acciones deben mostrar su texto, no un cuadrado vacío. */
html[data-pf-palette] body.portuflow-shell .pf-served-page .pf-served-pane .row-actions {
  min-width:110px;
  width:auto;
}
html[data-pf-palette] body.portuflow-shell .pf-served-page .pf-served-pane .row-actions button {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:auto;
  min-width:92px;
  height:32px;
  min-height:32px;
  box-sizing:border-box;
  margin:1px 2px;
  padding:5px 9px;
  font-size:12px;
  line-height:1.2;
  font-weight:600;
  white-space:nowrap;
  border:1px solid var(--pf-ui-control-border);
  border-radius:6px;
  background:var(--pf-ui-surface);
  color:var(--pf-ui-primary);
}
html[data-pf-palette] body.portuflow-shell .pf-served-page .pf-served-pane .row-actions button:hover {
  border-color:var(--pf-ui-primary);
  background:var(--pf-ui-surface-hover);
}

/* Contrastes de la paleta oscura, sin sobrescribir los estados semánticos. */
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-switch {
  background:var(--pf-ui-surface);
  border-color:var(--pf-ui-line-strong);
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-switch button[role="tab"] {
  background:transparent !important;
  color:var(--pf-ui-text-soft) !important;
  border-color:transparent !important;
  box-shadow:none;
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-switch button[role="tab"][aria-selected="true"] {
  background:var(--pf-ui-surface-hover) !important;
  color:var(--pf-ui-primary) !important;
  border-color:var(--pf-ui-line-strong) !important;
  box-shadow:inset 0 0 0 1px var(--pf-ui-line);
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-pane.pf-data-grid {
  background:var(--pf-ui-surface);
  border-color:var(--pf-ui-line);
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-help > summary,
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-help-content {
  background:var(--pf-ui-surface-soft);
  color:var(--pf-ui-ink);
  border-color:var(--pf-ui-line-strong);
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-pane .row-actions button {
  background:var(--pf-ui-surface-soft) !important;
  color:var(--pf-ui-primary) !important;
  border-color:var(--pf-ui-line-strong) !important;
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-served-page .pf-served-pane .row-actions button:hover {
  background:var(--pf-ui-surface-hover) !important;
  border-color:var(--pf-ui-primary) !important;
}

/* Resaltar la columna ordenada con el mismo acento que los enlaces, nunca
   azul oscuro sobre encabezado oscuro. */
html[data-pf-palette][data-theme="dark"] body.portuflow-shell :is(.pf-data-grid,.legacy-resource-panel,.legacy-grid-body) th:is(.is-sorted,[aria-sort="ascending"],[aria-sort="descending"]) {
  color:var(--pf-ui-primary) !important;
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell :is(.pf-data-grid,.legacy-resource-panel,.legacy-grid-body) th .legacy-sort-indicator {
  color:var(--pf-ui-primary);
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .pf-data-grid .pf-grid-table a {
  color:var(--pf-ui-primary);
}

/* Acciones principales y complementarias en la misma familia visual. */
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .legacy-resource-heading .legacy-create,
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .legacy-resource-before .legacy-create,
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .legacy-add-button {
  background:var(--pf-ui-primary) !important;
  border-color:var(--pf-ui-primary) !important;
  color:#0a1a29 !important;
}
html[data-pf-palette="petrol"][data-theme="dark"] body.portuflow-shell .legacy-resource-heading .legacy-create,
html[data-pf-palette="petrol"][data-theme="dark"] body.portuflow-shell .legacy-resource-before .legacy-create,
html[data-pf-palette="petrol"][data-theme="dark"] body.portuflow-shell .legacy-add-button {
  color:#09232a !important;
}
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .legacy-resource-heading .legacy-create:hover,
html[data-pf-palette][data-theme="dark"] body.portuflow-shell .legacy-resource-before .legacy-create:hover {
  background:var(--pf-ui-primary-hover) !important;
  border-color:var(--pf-ui-primary-hover) !important;
}

/* El control de apariencia no debe modificar las dimensiones existentes. */
@media (prefers-reduced-motion:reduce) {
  html[data-pf-palette] body.portuflow-shell .legacy-resource-heading .legacy-create,
  html[data-pf-palette] body.portuflow-shell .pf-served-page .row-actions button {
    transition:none;
  }
}

/* Portuflow 1.23.53 — aplicación consistente de tokens a paneles reales. */
html[data-theme="dark"] body[data-billing="legacy-financial"] :is(
  .legacy-financial-health,.legacy-financial-health-grid > div,.legacy-financial-context,
  #record-list,.legacy-financial-summary > div,.legacy-financial-file,
  .legacy-financial-detail-table,.pf-context-help-content) {
  background:var(--pf-ui-surface,#18212b)!important;
  color:var(--pf-ui-ink,#e7edf3)!important;
  border-color:var(--pf-ui-line,#34414d)!important;
}
html[data-theme="dark"] body[data-billing="legacy-financial"] :is(
  .legacy-financial-health-grid > div,.legacy-financial-summary > div,
  .pf-legacy-loading-v17) {background:var(--pf-ui-surface-soft,#202c37)!important;}
html[data-theme="dark"] body[data-billing="legacy-financial"] :is(
  .legacy-financial-health-grid strong,.legacy-financial-summary strong,
  .legacy-financial-detail-table th,.pf-financial-customer-tag) {
  color:var(--pf-ui-ink,#e7edf3)!important;
}
html[data-theme="dark"] body[data-billing="legacy-financial"] :is(
  .legacy-financial-health-grid small,.pf-legacy-loading-v17-copy small) {
  color:var(--pf-ui-muted,#9ca9b5)!important;
}
html[data-theme="dark"] body[data-billing="legacy-financial"] .pf-context-help > summary {
  background:var(--pf-ui-surface-soft,#202c37)!important;
  color:var(--pf-ui-primary,#66a6ff)!important;
  border-color:var(--pf-ui-line-strong,#455462)!important;
}
html[data-theme="dark"] body[data-billing="legacy-financial"] #record-list :is(
  .row-actions button,.row-actions a.button) {
  background:var(--pf-ui-surface-soft,#202c37)!important;
  color:var(--pf-ui-primary,#66a6ff)!important;
  border-color:var(--pf-ui-line-strong,#455462)!important;
  font-size:12px!important;
}
html[data-theme="dark"] body[data-billing="legacy-financial"] #record-list :is(
  .row-actions button,.row-actions a.button):hover {
  background:var(--pf-ui-surface-hover,#293847)!important;
  border-color:var(--pf-ui-primary,#66a6ff)!important;
}
/* Corregir contrastes de los paneles de ayuda presentes en todo el sistema. */
html[data-theme="dark"] :is(.calendar-info-panel,.pf-served-help-content,.pf-job-hint-text) {
  background:var(--pf-ui-surface-soft,#1d2630)!important;
  color:var(--pf-ui-ink,#e7edf3)!important;
  border-color:var(--pf-ui-line-strong,#455462)!important;
}
html[data-theme="dark"] :is(.calendar-info > summary,.pf-served-help > summary,.pf-job-hint > summary) {
  background:var(--pf-ui-surface-soft,#1d2630)!important;
  color:var(--pf-ui-primary,#66a6ff)!important;
  border-color:var(--pf-ui-line-strong,#455462)!important;
}
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document-file small,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document-empty {
  color:var(--pf-ui-muted,#9ca9b5)!important;
}

/* 1.23.53 — contraste de acciones, navegación y filtros financieros:
   vencer las reglas heredadas de botones blancos con !important. */
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #page .legacy-financial-shortcuts .button.secondary,
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #record-list .pf-filter-toolbar .button.secondary {
  background:var(--pf-ui-surface-soft,#20303a) !important;
  color:var(--pf-ui-ink,#e7edf3) !important;
  border-color:var(--pf-ui-line-strong,#455462) !important;
}
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #page .legacy-financial-shortcuts .button.secondary:hover,
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #record-list .pf-filter-toolbar .button.secondary:hover {
  background:var(--pf-ui-surface-hover,#2b3946) !important;
  color:var(--pf-ui-primary,#66a6ff) !important;
}
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #record-list.pf-data-grid .pf-grid-scroll .pf-grid-table .row-actions button.button.secondary,
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #record-list.pf-data-grid .pf-grid-scroll .pf-grid-table .row-actions a.button.secondary {
  background:var(--pf-ui-surface-soft,#20303a) !important;
  color:var(--pf-ui-primary,#66a6ff) !important;
  border-color:var(--pf-ui-line-strong,#455462) !important;
}
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #record-list.pf-data-grid .pf-grid-scroll .pf-grid-table .row-actions button.button.secondary:hover,
html[data-theme="dark"] body.legacy-resource-page[data-billing="legacy-financial"] #record-list.pf-data-grid .pf-grid-scroll .pf-grid-table .row-actions a.button.secondary:hover {
  background:var(--pf-ui-surface-hover,#2b3946) !important;
  border-color:var(--pf-ui-primary,#66a6ff) !important;
}


/* v1.23.83 — Paridad de apariencia de componentes operativos.
   Solo superficies de interfaz; no cambia los fondos de impresión ni los
   colores semánticos de alertas, estados, disponibilidad o fotografías. */

/* Inventario: matriz de disponibilidad (antes permanecía blanca en oscuro). */
html[data-theme="dark"] .pf-sc-availability,
html[data-theme="dark"] .pf-sc-availability__table-scroll,
html[data-theme="dark"] .pf-sc-availability__physical,
html[data-theme="dark"] .pf-sc-availability__selection,
html[data-theme="dark"] .pf-sc-availability__stat {
  background:var(--pf-ui-surface)!important;
  color:var(--pf-ui-ink)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] .pf-sc-availability__stat,
html[data-theme="dark"] .pf-sc-availability__physical,
html[data-theme="dark"] .pf-sc-availability__selection {
  background:var(--pf-ui-surface-soft)!important;
}
html[data-theme="dark"] .pf-sc-availability__head h2,
html[data-theme="dark"] .pf-sc-availability__range,
html[data-theme="dark"] .pf-sc-availability__stat strong,
html[data-theme="dark"] .pf-sc-availability__overview strong,
html[data-theme="dark"] .pf-sc-availability__audit summary {
  color:var(--pf-ui-ink)!important;
}
html[data-theme="dark"] .pf-sc-availability__head p,
html[data-theme="dark"] .pf-sc-availability__stat span,
html[data-theme="dark"] .pf-sc-availability__stat small,
html[data-theme="dark"] .pf-sc-availability__overview span,
html[data-theme="dark"] .pf-sc-availability__physical p,
html[data-theme="dark"] .pf-sc-availability__selection small,
html[data-theme="dark"] .pf-sc-availability__audit,
html[data-theme="dark"] .pf-sc-availability__table th:first-child small {
  color:var(--pf-ui-muted)!important;
}
html[data-theme="dark"] .pf-sc-availability__table thead th,
html[data-theme="dark"] .pf-sc-availability__table thead th:first-child {
  background:var(--pf-ui-surface-soft)!important;
  color:var(--pf-ui-text-strong)!important;
  border-color:var(--pf-ui-line)!important;
  box-shadow:none!important;
}
html[data-theme="dark"] .pf-sc-availability__table th:first-child,
html[data-theme="dark"] .pf-sc-availability__table tbody td,
html[data-theme="dark"] .pf-sc-availability__total {
  background:var(--pf-ui-row)!important;
  color:var(--pf-ui-text-soft)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] .pf-sc-availability__table tbody tr:nth-child(even):not(.pf-sc-availability__sum):not(.pf-sc-availability__excluded) > td,
html[data-theme="dark"] .pf-sc-availability__table tbody tr:nth-child(even):not(.pf-sc-availability__sum):not(.pf-sc-availability__excluded) > th:first-child {
  background:var(--pf-ui-row-alt)!important;
}
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__excluded > th,
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__excluded > td {
  background:var(--pf-ui-surface-soft)!important;
  color:var(--pf-ui-muted)!important;
}
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__sum > th,
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__sum > td {
  background:var(--pf-ui-surface-hover)!important;
  color:var(--pf-ui-ink)!important;
}
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__qty {
  background:#68c995!important;
  color:#0b2b20!important;
  border-color:#418a64!important;
}
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__qty--zero,
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__excluded .pf-sc-availability__qty {
  background:var(--pf-ui-surface-soft)!important;
  color:var(--pf-ui-muted)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__qty:hover:not(.pf-sc-availability__qty--zero),
html[data-theme="dark"] .pf-sc-availability__table .pf-sc-availability__qty:focus-visible:not(.pf-sc-availability__qty--zero) {
  background:#8ce3b3!important;
}

/* Inventario: ficha expandible, pestañas y microayudas. */
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-tabs-document,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document-section,
html[data-theme="dark"] body[data-page="inventory"] #record-list .pf-row-details-row > .pf-row-details-cell {
  background:var(--pf-ui-surface)!important;
  color:var(--pf-ui-ink)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-tab[aria-selected="true"] {
  background:var(--pf-ui-surface-hover)!important;
  color:var(--pf-ui-primary)!important;
  border-bottom-color:var(--pf-ui-primary)!important;
}
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-tab:not([aria-selected="true"]),
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document-field dd,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document-note,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document-heading h3 {
  color:var(--pf-ui-ink)!important;
}
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document-field dt,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-tab-hint,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-cell-subtle {
  color:var(--pf-ui-muted)!important;
}
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document-section h4,
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-document a {
  color:var(--pf-ui-primary)!important;
}
html[data-theme="dark"] body[data-page="inventory"] .pf-inventory-hint,
html[data-theme="dark"] body[data-page="inventory"] #record-list .pf-row-expand-toggle {
  background:var(--pf-ui-control-bg)!important;
  color:var(--pf-ui-text-soft)!important;
  border-color:var(--pf-ui-control-border)!important;
}

/* Clientes y Trabajos: expedientes internos y relaciones. */
html[data-theme="dark"] body[data-page="customers"] #record-dialog.customer-dossier-active .customer-related-heading,
html[data-theme="dark"] .customer-tabs,
html[data-theme="dark"] body[data-page="customers"] #record-dialog.customer-dossier-active .customer-tab-panel,
html[data-theme="dark"] body[data-page="customers"] #record-dialog.customer-dossier-active .customer-tab-panel .table-scroll,
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-job-document,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document,
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-row-details-row > .pf-row-details-cell,
html[data-theme="dark"] body[data-page="jobs"] #record-list .pf-row-details-row > .pf-row-details-cell {
  background:var(--pf-ui-surface)!important;
  color:var(--pf-ui-ink)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] body[data-page="customers"] .customer-related-heading h3,
html[data-theme="dark"] body[data-page="customers"] .customer-profile-name,
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-job-document strong,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document strong {
  color:var(--pf-ui-text-strong)!important;
}
html[data-theme="dark"] body[data-page="customers"] .customer-profile-meta,
html[data-theme="dark"] body[data-page="customers"] .customer-tab-count,
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-job-document dt,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document dt {
  color:var(--pf-ui-muted)!important;
}
html[data-theme="dark"] body[data-page="customers"] .customer-tab-count,
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-job-document-status,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document-status,
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-job-document-table th,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document-table th {
  background:var(--pf-ui-surface-soft)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] body[data-page="customers"] #customer-jobs-list .pf-job-document-table td,
html[data-theme="dark"] body[data-page="jobs"] .pf-job-document-table td {
  background:var(--pf-ui-row)!important;
  border-color:var(--pf-ui-line)!important;
}

/* Calendario: cuadrícula propia (no es FullCalendar). */
html[data-theme="dark"] .scheduler,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .calendar-filter-card,
html[data-theme="dark"] .scheduler-resource-cell,
html[data-theme="dark"] .scheduler-day-cell {
  background:var(--pf-ui-surface)!important;
  color:var(--pf-ui-ink)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] .scheduler-corner,
html[data-theme="dark"] .scheduler-day-header,
html[data-theme="dark"] .scheduler-group-label,
html[data-theme="dark"] .scheduler-group-fill {
  background:var(--pf-ui-surface-soft)!important;
  color:var(--pf-ui-text-soft)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] .scheduler-day-header.today {
  background:var(--pf-ui-surface-hover)!important;
  color:var(--pf-ui-primary)!important;
}
html[data-theme="dark"] .calendar-picker-option:hover {
  background:var(--pf-ui-surface-hover)!important;
}

/* Contabilidad, clientes, formularios y calculadora: superficies aún claras. */
html[data-theme="dark"] .legacy-financial-health-grid > div,
html[data-theme="dark"] .billing-summary-cell,
html[data-theme="dark"] .legacy-form .legacy-fe-section,
html[data-theme="dark"] .legacy-form .form-actions,
html[data-theme="dark"] .legacy-form .audit,
html[data-theme="dark"] .calc-card,
html[data-theme="dark"] .statement-toolbar {
  background:var(--pf-ui-surface)!important;
  color:var(--pf-ui-ink)!important;
  border-color:var(--pf-ui-line)!important;
}
html[data-theme="dark"] .legacy-financial-health-grid > div,
html[data-theme="dark"] .legacy-form .legacy-fe-section,
html[data-theme="dark"] .legacy-form .audit {
  background:var(--pf-ui-surface-soft)!important;
}
/* Los estados de cuenta mantienen papel blanco para pantalla/impresión. */
html[data-theme="dark"] .statement-paper { color-scheme:light; }
