/* AGPEV dark theme — activated via html[data-theme="dark"] (localStorage agpev.theme) */

html[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary: #0f172a;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-light: #334155;
    --border-medium: #475569;
}

html[data-theme="dark"] body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
    color: var(--text-primary);
}

html[data-theme="dark"] .agpev-main-content,
html[data-theme="dark"] .agpev-card,
html[data-theme="dark"] .agpev-card-body,
html[data-theme="dark"] .agpev-stat-card,
html[data-theme="dark"] .ui-widget-content,
html[data-theme="dark"] .ui-panel,
html[data-theme="dark"] .ui-datatable,
html[data-theme="dark"] .ui-dialog .ui-dialog-content {
    background: #111827 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .agpev-card,
html[data-theme="dark"] .agpev-stat-card {
    border-color: #334155 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] .agpev-card-header,
html[data-theme="dark"] .agpev-card-title,
html[data-theme="dark"] .agpev-stat-content p,
html[data-theme="dark"] .agpev-stat-content h3 {
    color: #f8fafc !important;
}

html[data-theme="dark"] .agpev-sidebar {
    background: #0b1220 !important;
    border-color: #1e293b !important;
}

html[data-theme="dark"] .agpev-menu-item,
html[data-theme="dark"] .agpev-menu-group-header,
html[data-theme="dark"] .agpev-sidebar-user-footer,
html[data-theme="dark"] .user-name,
html[data-theme="dark"] .user-role,
html[data-theme="dark"] .logout-label {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .agpev-footer {
    background: #0b1220 !important;
    color: #94a3b8 !important;
}

html[data-theme="dark"] .ui-datatable thead th,
html[data-theme="dark"] .ui-datatable tbody td,
html[data-theme="dark"] .engins-recents-table th,
html[data-theme="dark"] .engins-recents-table td {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .ui-inputfield,
html[data-theme="dark"] .ui-selectonemenu,
html[data-theme="dark"] .ui-selectonemenu-label,
html[data-theme="dark"] .ui-selectonemenu-label.ui-inputfield,
html[data-theme="dark"] .ui-selectcheckboxmenu,
html[data-theme="dark"] .ui-selectcheckboxmenu-label,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    -webkit-text-fill-color: #f1f5f9 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] select option,
html[data-theme="dark"] .ui-selectonemenu-item,
html[data-theme="dark"] .ui-selectcheckboxmenu-item {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .login-container,
html[data-theme="dark"] .login-form-wrapper {
    background: #111827 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .login-form-wrapper h2,
html[data-theme="dark"] .login-form-wrapper p,
html[data-theme="dark"] .login-form-wrapper label {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .agpev-prefs .agpev-lang-select {
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
}

.agpev-prefs {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.agpev-lang-select {
    height: 40px;
    min-width: 118px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(15, 23, 42, 0.28);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 0 8px;
    cursor: pointer;
}

.agpev-lang-select option {
    background-color: #ffffff;
    color: #0f172a;
    font-weight: 600;
}

html[data-theme="dark"] .agpev-lang-select option {
    background-color: #1e293b;
    color: #f8fafc;
}

.agpev-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
}

.agpev-theme-toggle:hover,
.agpev-lang-select:hover {
    background: rgba(255, 255, 255, 0.22);
}

.agpev-prefs--login {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 50;
}

.agpev-prefs--login .agpev-lang-select,
.agpev-prefs--login .agpev-theme-toggle {
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
}

@media (max-width: 768px) {
    .agpev-lang-select {
        min-width: 92px;
        font-size: 11px;
    }
}

/* Remaining light surfaces in dark mode */
html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] .agpev-main-content,
html[data-theme="dark"] .agpev-content,
html[data-theme="dark"] .agpev-page-content,
html[data-theme="dark"] .agpev-card-body,
html[data-theme="dark"] .agpev-chart-container,
html[data-theme="dark"] .agpev-fleet-chart-panel,
html[data-theme="dark"] .agpev-fleet-kpi,
html[data-theme="dark"] .agpev-chantier-flotte-kpi,
html[data-theme="dark"] .agpev-chantier-flotte-legends,
html[data-theme="dark"] .agpev-fleet-chart-empty,
html[data-theme="dark"] .agpev-chantier-flotte-chart-empty,
html[data-theme="dark"] .agpev-quick-action-btn,
html[data-theme="dark"] .engins-recents-table-container,
html[data-theme="dark"] .utilization-gauge,
html[data-theme="dark"] .agpev-distribution-list,
html[data-theme="dark"] .agpev-costs-summary,
html[data-theme="dark"] .cost-item,
html[data-theme="dark"] .jqplot-target,
html[data-theme="dark"] .ui-chart,
html[data-theme="dark"] .ui-tabs,
html[data-theme="dark"] .ui-tabs-panel,
html[data-theme="dark"] .ui-dialog,
html[data-theme="dark"] .ui-dialog-titlebar,
html[data-theme="dark"] .ui-overlaypanel,
html[data-theme="dark"] .ui-paginator,
html[data-theme="dark"] .ui-panelgrid,
html[data-theme="dark"] .ui-panelgrid td,
html[data-theme="dark"] .ui-panelgrid .ui-panelgrid-cell,
html[data-theme="dark"] .ui-datatable-header,
html[data-theme="dark"] .ui-datatable-footer,
html[data-theme="dark"] .ui-messages,
html[data-theme="dark"] .ui-growl-item,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr:nth-child(even) {
    background: #111827 !important;
    background-color: #111827 !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .agpev-fleet-kpi,
html[data-theme="dark"] .agpev-chantier-flotte-kpi {
    background: linear-gradient(180deg, #1e293b 0%, #111827 100%) !important;
}

html[data-theme="dark"] .agpev-fleet-kpi-label,
html[data-theme="dark"] .agpev-chantier-flotte-kpi-label,
html[data-theme="dark"] .agpev-fleet-chart-subtitle,
html[data-theme="dark"] .agpev-chantier-flotte-subtitle,
html[data-theme="dark"] .agpev-card-subtitle,
html[data-theme="dark"] .utilization-label,
html[data-theme="dark"] .cost-label,
html[data-theme="dark"] .distribution-label,
html[data-theme="dark"] .agpev-fleet-chart-panel-title,
html[data-theme="dark"] .agpev-fleet-chart-panel-title span,
html[data-theme="dark"] .agpev-page-title,
html[data-theme="dark"] .agpev-alert-content,
html[data-theme="dark"] .agpev-alert-content p,
html[data-theme="dark"] .agpev-alert-content strong,
html[data-theme="dark"] .agpev-alerts-section-title {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .agpev-fleet-kpi-value {
    color: #f8fafc !important;
}

html[data-theme="dark"] .agpev-chantier-flotte-type-legend {
    background: #1e293b !important;
}

html[data-theme="dark"] .jqplot-title {
    display: none;
}

html[data-theme="dark"] .jqplot-xaxis-tick,
html[data-theme="dark"] .jqplot-yaxis-tick,
html[data-theme="dark"] .jqplot-xaxis-label,
html[data-theme="dark"] .jqplot-yaxis-label,
html[data-theme="dark"] .jqplot-point-label,
html[data-theme="dark"] .jqplot-data-label,
html[data-theme="dark"] .jqplot-table-legend,
html[data-theme="dark"] .jqplot-table-legend td,
html[data-theme="dark"] .jqplot-highlighter-tooltip,
html[data-theme="dark"] .jqplot-cursor-tooltip {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .jqplot-table-legend {
    background: #1e293b !important;
    border: 1px solid #475569 !important;
}

html[data-theme="dark"] .jqplot-grid-canvas,
html[data-theme="dark"] .jqplot-series-canvas,
html[data-theme="dark"] .jqplot-event-canvas,
html[data-theme="dark"] .jqplot-target canvas,
html[data-theme="dark"] .agpev-chart-container canvas {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}

html[data-theme="dark"] .agpev-card:has(.fa-gas-pump),
html[data-theme="dark"] .agpev-card:has(.fa-gas-pump) .agpev-card-body,
html[data-theme="dark"] .agpev-card:has(.fa-chart-bar),
html[data-theme="dark"] .agpev-card:has(.fa-chart-bar) .agpev-card-body,
html[data-theme="dark"] .agpev-card:has(.fa-clock),
html[data-theme="dark"] .agpev-card:has(.fa-clock) .agpev-card-body {
    background: #111827 !important;
    background-image: none !important;
}

html[data-theme="dark"] .agpev-card:has(.fa-gas-pump) .agpev-card-body::before {
    background: none !important;
}

html[data-theme="dark"] .agpev-card:has(.fa-gas-pump) .jqplot-point-label {
    color: #fde68a !important;
}

html[data-theme="dark"] .jqplot-highlighter-tooltip,
html[data-theme="dark"] .agpev-card:has(.fa-gas-pump) .jqplot-highlighter-tooltip {
    background: #0f172a !important;
    color: #f1f5f9 !important;
    border: 1px solid #475569 !important;
}

html[data-theme="dark"] .ui-widget-header,
html[data-theme="dark"] .ui-tabs .ui-tabs-nav,
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li a,
html[data-theme="dark"] .ui-dialog-title {
    background: #0b1220 !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .login-container,
html[data-theme="dark"] .login-form-wrapper,
html[data-theme="dark"] .login-form-wrapper h2 {
    background: #111827 !important;
}

html[data-theme="dark"] body.login-page,
html[data-theme="dark"] .login-merged-container {
    background: #0f172a !important;
}

html[data-theme="dark"] .agpev-alert-item {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .agpev-quick-action-btn {
    color: #f8fafc !important;
}

html[data-theme="dark"] .status-badge {
    filter: brightness(0.92);
}

.agpev-chart-container .jqplot-title {
    display: none;
}

html[data-theme="dark"] .agpev-sidebar,
html[data-theme="dark"] .agpev-sidebar-scroll,
html[data-theme="dark"] .agpev-menu-footer,
html[data-theme="dark"] .agpev-menu-group,
html[data-theme="dark"] .agpev-menu-group-header,
html[data-theme="dark"] .agpev-menu-items {
    background: #0b1220 !important;
    background-color: #0b1220 !important;
    color: #e2e8f0 !important;
    border-color: #1e293b !important;
}

html[data-theme="dark"] .agpev-menu-item {
    background: transparent !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .agpev-menu-item:hover,
html[data-theme="dark"] .agpev-menu-group-header:hover {
    background: #1e293b !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] .agpev-menu-item.active {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}

html[data-theme="dark"] .agpev-main-content,
html[data-theme="dark"] .agpev-content,
html[data-theme="dark"] .agpev-table-container,
html[data-theme="dark"] .agpev-card,
html[data-theme="dark"] .engin-group-section,
html[data-theme="dark"] .engin-group-header,
html[data-theme="dark"] .group-table-wrap,
html[data-theme="dark"] .ui-datatable-tablewrapper,
html[data-theme="dark"] .ui-widget-content,
html[data-theme="dark"] .ui-datatable .ui-datatable-data tr,
html[data-theme="dark"] .ui-datatable .ui-datatable-data td,
html[data-theme="dark"] .ui-datatable tbody tr,
html[data-theme="dark"] .ui-datatable tbody tr:hover,
html[data-theme="dark"] .ui-paginator,
html[data-theme="dark"] .ui-dialog-buttonpane,
html[data-theme="dark"] .jqplot-target,
html[data-theme="dark"] .agpev-chart-container,
html[data-theme="dark"] .agpev-fleet-chart-panel,
html[data-theme="dark"] .agpev-fleet-chart-canvas-wrap,
html[data-theme="dark"] .agpev-chantier-flotte-chart-canvas-wrap {
    background: #111827 !important;
    background-color: #111827 !important;
    background-image: none !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .chip,
html[data-theme="dark"] .eng-chip,
html[data-theme="dark"] .group-badge {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .notif-overlay-header,
html[data-theme="dark"] .ui-overlaypanel,
html[data-theme="dark"] .mobile-responsive-overlay {
    background: #111827 !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .notif-overlay-title {
    color: #f8fafc !important;
}

html[data-theme="dark"] .unread-notif-dark {
    background: #1e293b !important;
}

html[data-theme="dark"] .ui-selectonemenu-panel,
html[data-theme="dark"] .ui-autocomplete-panel,
html[data-theme="dark"] .ui-datepicker,
html[data-theme="dark"] .ui-datepicker-header,
html[data-theme="dark"] .ui-selectcheckboxmenu-panel,
html[data-theme="dark"] .ui-filter-column,
html[data-theme="dark"] .ui-column-filter,
html[data-theme="dark"] .ui-inputfield.ui-state-default {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .ui-selectonemenu-item,
html[data-theme="dark"] .ui-selectonemenu-list,
html[data-theme="dark"] .ui-autocomplete-item {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-selectonemenu-item.ui-state-highlight,
html[data-theme="dark"] .ui-selectonemenu-item:hover {
    background: #334155 !important;
    color: #f8fafc !important;
}

/* Engins page: cards, filters, count bar, dialogs — no leftover white surfaces */
html[data-theme="dark"] .cardY,
html[data-theme="dark"] .cardY-header,
html[data-theme="dark"] .cardY-body,
html[data-theme="dark"] .cardY-empty,
html[data-theme="dark"] .filters-panel,
html[data-theme="dark"] .view-toggle-topright,
html[data-theme="dark"] .view-toggle-topright .tab-toggle,
html[data-theme="dark"] .filters-toggle,
html[data-theme="dark"] .evt-card,
html[data-theme="dark"] .agpev-field-md.ui-selectonemenu,
html[data-theme="dark"] .agpev-field-md .ui-selectonemenu-trigger,
html[data-theme="dark"] .agpev-table-count-bar,
html[data-theme="dark"] .agpev-table-count-range,
html[data-theme="dark"] .assur-card,
html[data-theme="dark"] .group-mobile-cards,
html[data-theme="dark"] #enginDialogForm .engin-maint-tab,
html[data-theme="dark"] .agpev-panel,
html[data-theme="dark"] .agpev-grid,
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li,
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li a {
    background: #1e293b !important;
    background-color: #1e293b !important;
    background-image: none !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .tbl,
html[data-theme="dark"] .tbl .ui-datatable,
html[data-theme="dark"] .tbl .ui-datatable-tablewrapper,
html[data-theme="dark"] .tbl table {
    background: #111827 !important;
    background-color: #111827 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .cardY {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] .cardY-title,
html[data-theme="dark"] .cardY-sub,
html[data-theme="dark"] .agpev-col-label,
html[data-theme="dark"] .agpev-col-value,
html[data-theme="dark"] #enginDialogForm .engin-details-grid .ui-outputlabel,
html[data-theme="dark"] #enginDialogForm .engin-maint-tab .ui-outputlabel,
html[data-theme="dark"] #enginDialogForm .engin-maint-hint {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .agpev-table-count-bar {
    background: linear-gradient(135deg, #1e3a5f 0%, #14532d 100%) !important;
    border-color: #334155 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] .agpev-table-count-range {
    background: rgba(15, 23, 42, 0.65) !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .agpev-table-count-range strong {
    color: #93c5fd !important;
}

html[data-theme="dark"] .filters-toggle,
html[data-theme="dark"] .filters-toggle.active {
    background: #1e3a5f !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .view-toggle-topright .tab-toggle.agpev-btn-primary {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}

html[data-theme="dark"] .card-rented,
html[data-theme="dark"] .card-rented .cardY-header,
html[data-theme="dark"] .card-rented .cardY-body {
    background: #14532d !important;
}

html[data-theme="dark"] .card-panne,
html[data-theme="dark"] .card-panne .cardY-header,
html[data-theme="dark"] .card-panne .cardY-body {
    background: #4c0519 !important;
}

html[data-theme="dark"] .card-reparation,
html[data-theme="dark"] .card-reparation .cardY-header,
html[data-theme="dark"] .card-reparation .cardY-body {
    background: #0c4a6e !important;
}

html[data-theme="dark"] .card-maintenance,
html[data-theme="dark"] .card-maintenance .cardY-header,
html[data-theme="dark"] .card-maintenance .cardY-body {
    background: #431407 !important;
}

html[data-theme="dark"] .card-reforme,
html[data-theme="dark"] .card-reforme .cardY-header,
html[data-theme="dark"] .card-reforme .cardY-body {
    background: #2e1065 !important;
}

html[data-theme="dark"] .card-vendu,
html[data-theme="dark"] .card-vendu .cardY-header,
html[data-theme="dark"] .card-vendu .cardY-body {
    background: #422006 !important;
}

html[data-theme="dark"] .chip {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .eng-chip span:not([style*="background"]):not(.eng-compteur-badge),
html[data-theme="dark"] .eng-identity-title {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .eng-chip .eng-identity-model,
html[data-theme="dark"] .eng-identity-model {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .eng-chip .eng-identity-id,
html[data-theme="dark"] .eng-identity-id {
    color: #93c5fd !important;
}

html[data-theme="dark"] .eng-chip .eng-identity-counter,
html[data-theme="dark"] .eng-identity-counter {
    color: #86efac !important;
}

html[data-theme="dark"] .eng-chip .eng-identity-meta,
html[data-theme="dark"] .eng-identity-meta {
    color: #cbd5e1 !important;
}

/* Date / calendar popup: readable days, months, time */
html[data-theme="dark"] .ui-datepicker,
html[data-theme="dark"] #ui-datepicker-div,
html[data-theme="dark"] .ui-datepicker-calendar,
html[data-theme="dark"] .p-datepicker,
html[data-theme="dark"] .ui-monthpicker,
html[data-theme="dark"] .ui-timepicker,
html[data-theme="dark"] .ui-timepicker-div {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .ui-datepicker-header,
html[data-theme="dark"] .ui-datepicker-title,
html[data-theme="dark"] .ui-datepicker-calendar th,
html[data-theme="dark"] .ui-datepicker-calendar td,
html[data-theme="dark"] .ui-datepicker-buttonpane,
html[data-theme="dark"] .ui-timepicker-div dl,
html[data-theme="dark"] .ui-timepicker-div dt,
html[data-theme="dark"] .ui-timepicker-div dd {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .ui-datepicker .ui-state-default,
html[data-theme="dark"] .ui-datepicker td a,
html[data-theme="dark"] .ui-datepicker td span,
html[data-theme="dark"] .p-datepicker td > span,
html[data-theme="dark"] .p-datepicker td > a {
    background: #0f172a !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .ui-datepicker .ui-state-hover,
html[data-theme="dark"] .ui-datepicker td a:hover {
    background: #334155 !important;
    color: #fff !important;
}

html[data-theme="dark"] .ui-datepicker .ui-state-highlight,
html[data-theme="dark"] .ui-datepicker .ui-state-active,
html[data-theme="dark"] .p-datepicker .ui-state-active,
html[data-theme="dark"] .p-datepicker .ui-state-highlight {
    background: #2563eb !important;
    color: #fff !important;
    border-color: #3b82f6 !important;
}

html[data-theme="dark"] .ui-datepicker-month,
html[data-theme="dark"] .ui-datepicker-year,
html[data-theme="dark"] .ui-datepicker select,
html[data-theme="dark"] .ui-timepicker-div input,
html[data-theme="dark"] .ui-datepicker-buttonpane button {
    background: #0f172a !important;
    color: #f1f5f9 !important;
    border: 1px solid #475569 !important;
}

html[data-theme="dark"] .ui-datepicker .ui-datepicker-prev,
html[data-theme="dark"] .ui-datepicker .ui-datepicker-next,
html[data-theme="dark"] .ui-datepicker .ui-icon {
    filter: invert(1) brightness(1.4);
}

html[data-theme="dark"] .ui-calendar input,
html[data-theme="dark"] .ui-datepicker-trigger {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .ui-inputnumber,
html[data-theme="dark"] .ui-inputnumber input,
html[data-theme="dark"] .ui-spinner,
html[data-theme="dark"] .ui-spinner-input {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .eng-compteur-badge,
html[data-theme="dark"] .eng-chip .eng-compteur-badge,
html[data-theme="dark"] .eng-chip span.eng-compteur-badge,
html[data-theme="dark"] .eng-compteur-badge i,
html[data-theme="dark"] .eng-chip .eng-compteur-badge i {
    background: #ecfeff !important;
    color: #0f172a !important;
}

html[data-theme="dark"] .eng-compteur-badge i,
html[data-theme="dark"] .eng-chip .eng-compteur-badge i {
    background: transparent !important;
}

/*
 * Dark mode contrast: only the element that still has a light inline background
 * gets dark text. Do NOT paint descendants (that made table cells unreadable).
 */
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#fff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background: #fff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#ffffff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background: #ffffff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#f8fafc" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background: #f8fafc" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#f1f5f9" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background: #f1f5f9" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#ecfeff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background: #ecfeff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#eff6ff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#fde68a" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background:#e5e7eb" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background-color:#fff" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background-color:#f8fafc" i],
html[data-theme="dark"] body :not(.chip):not(.eng-chip):not(.ui-button):not(.agpev-btn):not(.ui-inputfield):not(.ui-datatable):not(.ui-widget)[style*="background-color:#ecfeff" i] {
    color: #0f172a !important;
}

/* Tables: light text on dark cells (beats inline color:#0f172a) */
html[data-theme="dark"] .ui-datatable thead th,
html[data-theme="dark"] .ui-datatable thead th .ui-column-title,
html[data-theme="dark"] .ui-datatable tbody td,
html[data-theme="dark"] .ui-datatable tfoot td,
html[data-theme="dark"] .ui-datatable tbody td > span:not([style*="background"]),
html[data-theme="dark"] .ui-datatable tbody td > div:not([style*="background"]),
html[data-theme="dark"] .ui-datatable tbody td [style*="color:#0f172a"],
html[data-theme="dark"] .ui-datatable tbody td [style*="color: #0f172a"],
html[data-theme="dark"] .ui-datatable tbody td [style*="color:#1e293b"],
html[data-theme="dark"] .ui-datatable tbody td [style*="color:#334155"],
html[data-theme="dark"] .ui-datatable tbody td [style*="color:#64748b"],
html[data-theme="dark"] .agpev-table tbody td,
html[data-theme="dark"] .tbl tbody td {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable thead th,
html[data-theme="dark"] .ui-datatable tbody td,
html[data-theme="dark"] .ui-datatable tfoot td,
html[data-theme="dark"] .tbl tbody td,
html[data-theme="dark"] .ui-datatable tbody tr,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr:nth-child(even),
html[data-theme="dark"] #tableViewY .ui-datatable tbody td {
    background: #1e293b !important;
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable thead th,
html[data-theme="dark"] .ui-datatable thead th .ui-column-title,
html[data-theme="dark"] .tbl thead th {
    background: linear-gradient(135deg, #1e3a5f 0%, #1d4ed8 100%) !important;
    color: #f8fafc !important;
}

/* Status rows: dark tints + light text (page CSS used pastel + !important) */
html[data-theme="dark"] .ui-datatable tbody tr.row-rented > td,
html[data-theme="dark"] .tbl tbody tr.row-rented > td,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr.row-rented > td,
html[data-theme="dark"] .ui-datatable tbody tr.loc-row-active > td,
html[data-theme="dark"] .ui-datatable tbody tr.loc-row-terminee > td {
    background: #14532d !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr.row-panne > td,
html[data-theme="dark"] .tbl tbody tr.row-panne > td,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr.row-panne > td {
    background: #4c0519 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr.row-reparation > td,
html[data-theme="dark"] .tbl tbody tr.row-reparation > td,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr.row-reparation > td {
    background: #0c4a6e !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr.row-maintenance > td,
html[data-theme="dark"] .tbl tbody tr.row-maintenance > td,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr.row-maintenance > td,
html[data-theme="dark"] .ui-datatable tbody tr.vidange-row-afaire > td {
    background: #431407 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr.row-reforme > td,
html[data-theme="dark"] .tbl tbody tr.row-reforme > td,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr.row-reforme > td {
    background: #2e1065 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr.row-vendu > td,
html[data-theme="dark"] .tbl tbody tr.row-vendu > td,
html[data-theme="dark"] #tableViewY .ui-datatable tbody tr.row-vendu > td {
    background: #422006 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr.vidange-row-urgent > td {
    background: #7f1d1d !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .ui-datatable tbody tr:hover > td {
    background: #334155 !important;
}
