/* Styles FlipPulse Web UI - Thèmes Clair & Sombre (contraste optimisé) */

:root,
html.light-theme,
body.light-theme {
    color-scheme: light;
    --primary-color: #09B1BA;
    --secondary-color: #007782;
    --accent-color: #FF5E5B;
    --surface-bg: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-elevated: #f1f5f9;
    --page-bg: #f1f5f9;
    --text-color: #0f172a;
    --text-strong: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
    --transition-speed: 0.18s;
    --border-radius: 0.45rem;

    /* Tokens Bootstrap 5.3 thème clair */
    --bs-body-bg: var(--page-bg);
    --bs-body-color: var(--text-color);
    --bs-emphasis-color: #0f172a;
    --bs-secondary-color: #475569;
    --bs-tertiary-bg: #f8fafc;
    --bs-secondary-bg: #f1f5f9;
    --bs-card-bg: #ffffff;
    --bs-card-color: #0f172a;
    --bs-border-color: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--page-bg);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

/* Header sobre */
.app-header {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 1030;
    padding: 0.45rem 1rem;
    min-height: 58px;
}

.app-header .navbar-brand {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-color);
}

.app-header .header-icon-btn {
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
}

.app-header .header-icon-btn:hover {
    color: var(--text-color);
    background-color: rgba(15, 23, 42, 0.06);
}

.header-btn {
    border-radius: var(--border-radius);
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.header-btn:hover {
    background-color: rgba(15, 23, 42, 0.05);
    border-color: #cbd5e1;
    color: var(--text-color);
}

/* Sidebar */
.sidebar {
    background-color: var(--surface-bg);
    border-right: 1px solid var(--border-color);
}

.nav-link {
    font-weight: 500;
    font-size: 0.9rem;
    color: #475569;
    padding: 0.5rem 0.75rem;
    margin: 0.15rem 0;
    border-radius: var(--border-radius);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    white-space: nowrap;
}

.nav-link i {
    color: #64748b;
    transition: color var(--transition-speed) ease;
}

.nav-link:hover:not(.active) {
    background-color: rgba(9, 177, 186, 0.08);
    color: var(--primary-color);
}

.nav-link:hover:not(.active) i {
    color: var(--primary-color);
}

.nav-link.active {
    background-color: rgba(9, 177, 186, 0.12);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-link.active i {
    color: var(--primary-color);
}

main {
    padding-bottom: 2rem;
}

/* Cards */
.card {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background-color: var(--surface-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.card-footer {
    background-color: var(--surface-subtle);
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
}

/* Product cards */
#cardView .card {
    border-radius: var(--border-radius);
    overflow: hidden;
}

#cardView .card-img-top {
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
}

#cardView .card-body {
    padding: 0.75rem;
}

#cardView .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
    max-height: 2.4rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

#cardView .card-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

#cardView .card-footer {
    background-color: var(--surface-bg);
    border-top: 1px solid var(--border-color);
    padding: 0.65rem 0.75rem;
}

/* Tables */
.table-hover tbody tr:hover {
    background-color: rgba(9, 177, 186, 0.05);
}

.process-status {
    display: inline-block;
    padding: 0.2rem 0.45rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 0.45rem 0.9rem;
}

.btn-sm {
    padding: 0.25rem 0.65rem;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.78rem;
}

.btn-icon {
    padding: 0.25rem 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #ffffff;
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.btn-group .btn {
    border-radius: var(--border-radius);
}

.btn-group > .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-group .btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

/* Flash messages */
.flash-message {
    box-shadow: var(--shadow-md);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

/* Form controls */
.form-control,
.form-select {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.7rem;
}

.form-select {
    padding-right: 2rem;
}

.form-control-sm,
.form-select-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
}

.form-select-sm {
    padding-right: 1.85rem;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.18rem rgba(9, 177, 186, 0.16);
}

.form-switch .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Modals */
.modal-content {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.9rem 1.25rem;
}

.modal-footer {
    background-color: var(--surface-subtle);
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}

/* Footer */
.footer {
    background-color: var(--surface-bg);
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding: 1.1rem 0;
}

.footer a {
    color: var(--text-muted);
}

.footer a:hover {
    color: var(--primary-color) !important;
}

/* Badges (sécurité contraste sur thème clair ET sombre) */
.badge {
    font-weight: 500;
    padding: 0.32em 0.58em;
    border-radius: 0.375rem;
}

.badge.bg-secondary {
    background-color: #e2e8f0 !important;
    color: #334155 !important;
}

.badge.bg-light {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.badge.bg-success {
    background-color: #16a34a !important;
    color: #ffffff !important;
}

.badge.bg-warning,
.badge.bg-warning.text-dark,
.badge.bg-info,
.badge.bg-info.text-dark {
    color: #0f172a !important;
}

.badge-soft-success { background-color: #dcfce7; color: #166534; }
.badge-soft-warning { background-color: #fef3c7; color: #92400e; }
.badge-soft-danger  { background-color: #fee2e2; color: #991b1b; }

.badge-coef {
    background-color: #334155 !important;
    color: #ffffff !important;
    border-color: #475569 !important;
    font-weight: 600;
}

/* Tables list view */
#listView .table {
    border-collapse: separate;
    border-spacing: 0;
}

#listView .table th {
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-muted);
}

#listView .table td {
    vertical-align: middle;
    padding: 0.75rem;
}

#listView .img-thumbnail {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

/* Utilities */
.micro {
    font-size: 0.76rem;
}

/* =====================================================================
   DARK THEME (Bootstrap 5.3 + surcharges cohérentes)
   ===================================================================== */
html[data-bs-theme="dark"],
html.dark-theme,
body.dark-theme {
    color-scheme: dark;
    --surface-bg: #131b23;
    --surface-subtle: #18222c;
    --surface-elevated: #1e2a36;
    --page-bg: #0b1116;
    --text-color: #e2e8f0;
    --text-strong: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #273442;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.55);

    /* Tokens Bootstrap 5.3 thème sombre */
    --bs-body-bg: #0b1116;
    --bs-body-color: #e2e8f0;
    --bs-emphasis-color: #f8fafc;
    --bs-secondary-color: #94a3b8;
    --bs-tertiary-bg: #18222c;
    --bs-secondary-bg: #1e2a36;
    --bs-card-bg: #131b23;
    --bs-card-color: #e2e8f0;
    --bs-modal-bg: #131b23;
    --bs-modal-color: #e2e8f0;
    --bs-dropdown-bg: #131b23;
    --bs-dropdown-color: #e2e8f0;
    --bs-border-color: #273442;
    --bs-table-bg: #131b23;
    --bs-table-color: #e2e8f0;
    --bs-table-striped-bg: #16202a;
    --bs-table-hover-bg: rgba(9, 177, 186, 0.12);
    --bs-table-hover-color: #f8fafc;
}

body.dark-theme,
body.dark-theme main {
    background-color: var(--page-bg);
    color: var(--text-color);
}

body.dark-theme .app-header {
    background-color: #10171e;
    border-bottom-color: var(--border-color);
    color: var(--text-color);
}

body.dark-theme .app-header .header-icon-btn {
    color: #94a3b8;
}

body.dark-theme .app-header .header-icon-btn:hover {
    color: #f8fafc;
    background-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .header-btn {
    border-color: var(--border-color);
    color: var(--text-color);
}

body.dark-theme .header-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: #384857;
    color: #ffffff;
}

body.dark-theme .sidebar,
body.dark-theme .card,
body.dark-theme .card-header,
body.dark-theme .footer,
body.dark-theme .modal-content,
body.dark-theme .modal-header,
body.dark-theme .dropdown-menu,
body.dark-theme .bg-white {
    background-color: var(--surface-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .card-footer,
body.dark-theme .modal-footer,
body.dark-theme .bg-light,
body.dark-theme .bg-body-tertiary,
body.dark-theme .bg-body-secondary {
    background-color: var(--surface-subtle) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

/* Sous-conteneurs imbriqués en thème sombre pour préserver le relief */
body.dark-theme .bg-light .bg-white,
body.dark-theme .card-body .bg-white,
body.dark-theme .modal-body .bg-white,
body.dark-theme .notes-box,
body.dark-theme .item-img-container,
body.dark-theme .nego-box,
body.dark-theme pre.bg-body-tertiary,
body.dark-theme pre.bg-light {
    background-color: #0e141a !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .nego-box .nego-header {
    border-bottom-color: var(--border-color) !important;
}

body.dark-theme .dropdown-header {
    color: var(--text-muted) !important;
}

body.dark-theme .dropdown-item,
body.dark-theme .dropdown-item-text {
    color: var(--text-color) !important;
}

body.dark-theme .dropdown-item:hover,
body.dark-theme .dropdown-item:focus {
    background-color: rgba(9, 177, 186, 0.16) !important;
    color: #ffffff !important;
}

body.dark-theme .dropdown-item.text-danger {
    color: #fda4af !important;
}

body.dark-theme .dropdown-divider {
    border-color: var(--border-color) !important;
}

body.dark-theme .sidebar {
    border-right-color: var(--border-color);
}

body.dark-theme .nav-link {
    color: #cbd5e1;
}

body.dark-theme .nav-link i {
    color: #94a3b8;
}

body.dark-theme .nav-link:hover:not(.active) {
    background-color: rgba(9, 177, 186, 0.14);
    color: #38d9e2;
}

body.dark-theme .nav-link:hover:not(.active) i {
    color: #38d9e2;
}

body.dark-theme .nav-link.active {
    background-color: rgba(9, 177, 186, 0.18);
    color: #38d9e2;
}

body.dark-theme .nav-link.active i {
    color: #38d9e2;
}

body.dark-theme .nav-pills .nav-link.active .badge.bg-white {
    background-color: rgba(11, 17, 22, 0.35) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
}

body.dark-theme .border-bottom,
body.dark-theme .border-top,
body.dark-theme .border,
body.dark-theme .border-end,
body.dark-theme .border-start,
body.dark-theme .table,
body.dark-theme .table > :not(caption) > * > * {
    border-color: var(--border-color) !important;
}

/* Tableaux thème sombre */
body.dark-theme .table {
    --bs-table-bg: var(--surface-bg);
    --bs-table-color: #e2e8f0;
    --bs-table-border-color: var(--border-color);
    background-color: var(--surface-bg) !important;
    color: #e2e8f0 !important;
}

body.dark-theme .table > :not(caption) > * > * {
    background-color: transparent !important;
    color: #e2e8f0 !important;
}

body.dark-theme .table > thead.table-light > tr > th,
body.dark-theme thead.table-light > tr > th,
body.dark-theme .table-light,
body.dark-theme .table-light > tr > th,
body.dark-theme .table-light > th {
    background-color: var(--surface-subtle) !important;
    color: #94a3b8 !important;
}

body.dark-theme .table > :not(caption) > tr.table-info > *,
body.dark-theme .table-info,
body.dark-theme .table-info > td,
body.dark-theme .table-info > th {
    background-color: #10323e !important;
    color: #bae6fd !important;
}

body.dark-theme .table > :not(caption) > tr.table-success > *,
body.dark-theme .table-success,
body.dark-theme .table-success > td,
body.dark-theme .table-success > th {
    background-color: #122f20 !important;
    color: #bbf7d0 !important;
}

body.dark-theme .table > :not(caption) > tr.table-danger > *,
body.dark-theme .table-danger,
body.dark-theme .table-danger > td,
body.dark-theme .table-danger > th {
    background-color: #38171d !important;
    color: #fecdd3 !important;
}

body.dark-theme .table > :not(caption) > tr.table-warning > *,
body.dark-theme .table > :not(caption) > tr.sub-req-pending > *,
body.dark-theme .table-warning,
body.dark-theme .table-warning > td,
body.dark-theme .table-warning > th,
body.dark-theme tr.sub-req-pending,
body.dark-theme tr.sub-req-pending > td {
    --bs-table-bg: #272112 !important;
    --bs-table-color: #fde68a !important;
    background-color: #272112 !important;
    color: #fde68a !important;
}

body.dark-theme tr.sub-req-pending .text-dark,
body.dark-theme tr.sub-req-pending .fw-bold,
body.dark-theme tr.sub-req-pending .text-secondary,
body.dark-theme tr.sub-req-pending div,
body.dark-theme tr.sub-req-pending small {
    color: #fde68a !important;
}

/* Lisibilité générale du texte en thème sombre */
body.dark-theme .text-body,
body.dark-theme .text-secondary,
body.dark-theme .form-label,
body.dark-theme .form-check-label,
body.dark-theme label,
body.dark-theme .card-title,
body.dark-theme .modal-title,
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme h5,
body.dark-theme h6 {
    color: var(--text-strong) !important;
}

/* .text-dark utilisé sur du texte courant en thème clair bascule en clair, SAUF sur fonds vifs (bg-warning, bg-info) */
body.dark-theme .text-dark {
    color: #f1f5f9 !important;
}

body.dark-theme .bg-warning,
body.dark-theme .bg-warning.text-dark,
body.dark-theme .bg-warning .text-dark,
body.dark-theme .badge.bg-warning,
body.dark-theme .badge.bg-warning.text-dark,
body.dark-theme .bg-info,
body.dark-theme .bg-info.text-dark,
body.dark-theme .bg-info .text-dark,
body.dark-theme .badge.bg-info,
body.dark-theme .badge.bg-info.text-dark,
body.dark-theme .btn-warning,
body.dark-theme .btn-info {
    color: #0f172a !important;
}

body.dark-theme .text-muted,
body.dark-theme .form-text,
body.dark-theme .table .text-muted {
    color: var(--text-muted) !important;
}

body.dark-theme code:not(.badge) {
    color: #7dd3fc;
}

/* Champs de saisie en thème sombre (normal, focus, disabled, readonly) */
body.dark-theme .form-control,
body.dark-theme .form-select,
body.dark-theme textarea,
body.dark-theme .input-group-text {
    background-color: #0b1116 !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-theme .input-group-text {
    background-color: var(--surface-subtle) !important;
    color: #cbd5e1 !important;
}

body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus,
body.dark-theme textarea:focus {
    background-color: #0b1116 !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}

body.dark-theme .form-control:disabled,
body.dark-theme .form-control[readonly],
body.dark-theme .form-select:disabled,
body.dark-theme fieldset:disabled .form-control,
body.dark-theme fieldset:disabled .form-select {
    background-color: var(--surface-subtle) !important;
    color: #94a3b8 !important;
    border-color: var(--border-color) !important;
    opacity: 1 !important;
}

body.dark-theme .form-control::placeholder {
    color: #64748b !important;
}

body.dark-theme .form-select option {
    background-color: #131b23;
    color: #e2e8f0;
}

body.dark-theme .form-check-input:not(:checked) {
    background-color: #0b1116;
    border-color: #475569;
}

/* Alertes en thème sombre */
body.dark-theme .alert-light {
    background-color: var(--surface-subtle) !important;
    color: #cbd5e1 !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .alert-warning {
    background-color: #2a210f !important;
    color: #fde68a !important;
    border-color: #6b5218 !important;
}

body.dark-theme .alert-info {
    background-color: #0f2933 !important;
    color: #bae6fd !important;
    border-color: #164e63 !important;
}

body.dark-theme .alert-danger {
    background-color: #35161b !important;
    color: #fecdd3 !important;
    border-color: #6b212c !important;
}

body.dark-theme .alert-success {
    background-color: #112d1d !important;
    color: #bbf7d0 !important;
    border-color: #166534 !important;
}

/* Boutons et contrôles en thème sombre */
body.dark-theme .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

body.dark-theme .btn-light {
    background-color: #24303c !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

body.dark-theme .btn-dark {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-outline-secondary {
    color: #cbd5e1 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-outline-secondary:hover,
body.dark-theme .btn-outline-secondary:focus {
    background-color: #334155 !important;
    border-color: #64748b !important;
    color: #ffffff !important;
}

body.dark-theme .btn-outline-dark {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-outline-dark:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* Onglets & accordéons en thème sombre */
body.dark-theme .nav-tabs,
body.dark-theme .nav-tabs .nav-link:not(.active) {
    border-color: var(--border-color);
    color: var(--text-muted);
}

body.dark-theme .nav-tabs .nav-link.active {
    background-color: var(--surface-bg);
    border-color: var(--border-color) var(--border-color) var(--surface-bg);
    color: var(--text-strong);
}

body.dark-theme .nav-pills .nav-link:not(.active) {
    color: #cbd5e1;
}

body.dark-theme .accordion-item,
body.dark-theme .accordion-button,
body.dark-theme .accordion-body {
    background-color: var(--surface-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

/* Badges en thème sombre */
body.dark-theme .badge-soft-success {
    background-color: #14402d !important;
    color: #86efac !important;
}

body.dark-theme .badge-soft-warning {
    background-color: #4a3a14 !important;
    color: #fde68a !important;
}

body.dark-theme .badge-soft-danger {
    background-color: #4c1d24 !important;
    color: #fda4af !important;
}

body.dark-theme .log-critical {
    color: #fda4af !important;
}

body.dark-theme .badge.bg-secondary,
body.dark-theme .badge.bg-light,
body.dark-theme .badge.bg-white,
body.dark-theme .badge.bg-dark-subtle,
body.dark-theme .badge.bg-secondary-subtle,
body.dark-theme .bg-dark-subtle,
body.dark-theme .bg-secondary-subtle {
    background-color: #24303c !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

body.dark-theme .badge.bg-light.text-dark,
body.dark-theme .badge.bg-white.text-dark {
    color: #f1f5f9 !important;
}

body.dark-theme .list-group-item {
    background-color: var(--surface-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

body.dark-theme .list-group-item-action:hover,
body.dark-theme .list-group-item-action:focus {
    background-color: rgba(9, 177, 186, 0.14) !important;
}

body.dark-theme .table-hover > tbody > tr:hover,
body.dark-theme .table-items > tbody > tr:hover {
    background-color: rgba(9, 177, 186, 0.1) !important;
}

body.dark-theme .table-hover > tbody > tr:hover > *,
body.dark-theme .table-items > tbody > tr:hover > * {
    --bs-table-accent-bg: transparent !important;
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    background-color: transparent !important;
}

body.dark-theme .table-hover tbody tr:hover .item-img-container {
    background-color: #0e141a !important;
}

body.dark-theme .badge-coef {
    background-color: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

/* Historique de disponibilité — mode calendrier & petits carrés */
.status-cal-weekdays,
.status-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.status-cal-weekday {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 2px;
}

.status-cal-pad {
    min-height: 48px;
    border-radius: 8px;
}

.status-cal-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 4px 2px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    line-height: 1.15;
    width: 100%;
}

.status-cal-tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.status-cal-tile .cal-day-num {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.85;
}

.status-cal-tile .cal-day-pct {
    font-size: 0.72rem;
    font-weight: 700;
    margin-top: 2px;
}

.status-heatmap-scroll {
    overflow-x: auto;
    padding-bottom: 4px;
}

.status-heatmap-months {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 16px;
    gap: 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: 22px;
    margin-bottom: 4px;
    min-height: 15px;
}

.status-heatmap-body {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.status-heatmap-days-col {
    display: grid;
    grid-template-rows: repeat(7, 16px);
    gap: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 16px;
    width: 16px;
    text-align: right;
    flex-shrink: 0;
}

.status-heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 16px);
    grid-auto-flow: column;
    grid-auto-columns: 16px;
    gap: 4px;
}

.status-heat-sq {
    width: 16px;
    height: 16px;
    padding: 0;
    border-radius: 3px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.status-heat-sq:hover {
    transform: scale(1.18);
}

.status-heat-pad {
    width: 16px;
    height: 16px;
}

.status-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid transparent;
    vertical-align: middle;
}

.status-cal-tile.is-today,
.status-heat-sq.is-today {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.status-cal-tile.is-selected,
.status-heat-sq.is-selected {
    box-shadow: 0 0 0 2px var(--text-strong);
}

/* Niveaux de couleur mode clair */
.status-lvl-100 {
    background-color: #16a34a;
    border-color: #15803d;
    color: #ffffff;
}
.status-lvl-high {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #14532d;
}
.status-lvl-medium {
    background-color: #fef3c7;
    border-color: #fcd34d;
    color: #78350f;
}
.status-lvl-low {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #7f1d1d;
}
.status-lvl-down {
    background-color: #cbd5e1;
    border-color: #64748b;
    color: #0f172a;
}
.status-lvl-empty {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    color: #64748b;
}

/* Niveaux de couleur mode sombre */
body.dark-theme .status-lvl-100,
[data-bs-theme="dark"] .status-lvl-100 {
    background-color: #15803d;
    border-color: #22c55e;
    color: #f0fdf4;
}
body.dark-theme .status-lvl-high,
[data-bs-theme="dark"] .status-lvl-high {
    background-color: #14532d;
    border-color: #22c55e;
    color: #bbf7d0;
}
body.dark-theme .status-lvl-medium,
[data-bs-theme="dark"] .status-lvl-medium {
    background-color: #78350f;
    border-color: #f59e0b;
    color: #fef3c7;
}
body.dark-theme .status-lvl-low,
[data-bs-theme="dark"] .status-lvl-low {
    background-color: #7f1d1d;
    border-color: #ef4444;
    color: #fecaca;
}
body.dark-theme .status-lvl-down,
[data-bs-theme="dark"] .status-lvl-down {
    background-color: #334155;
    border-color: #64748b;
    color: #f1f5f9;
}
body.dark-theme .status-lvl-empty,
[data-bs-theme="dark"] .status-lvl-empty {
    background-color: #161e27;
    border-color: #2a3542;
    color: #94a3b8;
}

@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }
    .navbar-brand {
        font-size: 1.1rem;
    }
}

/* =====================================================================
   NAVIGATION MOBILE FIXE EN BAS D'ECRAN
   ===================================================================== */
.fp-mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1015;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
}

.fp-mobile-bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.3rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.1;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.fp-mobile-bottom-nav-item i {
    font-size: 1.15rem;
    line-height: 1;
}

.fp-mobile-bottom-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fp-mobile-bottom-nav-item:hover,
.fp-mobile-bottom-nav-item.active,
.fp-mobile-bottom-nav-item[aria-current="page"],
.fp-mobile-bottom-nav-item[aria-expanded="true"] {
    color: var(--primary-color);
    background-color: rgba(9, 177, 186, 0.1);
}

.fp-mobile-bottom-nav-item.active,
.fp-mobile-bottom-nav-item[aria-current="page"] {
    font-weight: 600;
}

body.dark-theme .fp-mobile-bottom-nav,
[data-bs-theme="dark"] .fp-mobile-bottom-nav {
    background-color: #10171e;
    border-top-color: var(--border-color);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.45);
}

body.dark-theme .fp-mobile-bottom-nav-item,
[data-bs-theme="dark"] .fp-mobile-bottom-nav-item {
    color: #94a3b8;
}

body.dark-theme .fp-mobile-bottom-nav-item:hover,
body.dark-theme .fp-mobile-bottom-nav-item.active,
body.dark-theme .fp-mobile-bottom-nav-item[aria-current="page"],
body.dark-theme .fp-mobile-bottom-nav-item[aria-expanded="true"],
[data-bs-theme="dark"] .fp-mobile-bottom-nav-item:hover,
[data-bs-theme="dark"] .fp-mobile-bottom-nav-item.active,
[data-bs-theme="dark"] .fp-mobile-bottom-nav-item[aria-current="page"],
[data-bs-theme="dark"] .fp-mobile-bottom-nav-item[aria-expanded="true"] {
    color: #38d9e2;
    background-color: rgba(9, 177, 186, 0.18);
}

@media (max-width: 767.98px) {
    body.has-mobile-bottom-nav footer.footer {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    }
    body.has-mobile-bottom-nav .sidebar-sticky {
        padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    }
    body.has-mobile-bottom-nav main {
        padding-bottom: 1.75rem;
    }
}

/* =====================================================================
   TIROIR DE FILTRES MOBILE (OFFCANVAS-MD) & CHIPS ACTIFS
   ===================================================================== */
@media (min-width: 768px) {
    .fp-filter-drawer {
        display: block;
        background-color: transparent !important;
        border: 0 !important;
    }
    .fp-filter-drawer .offcanvas-header {
        display: none !important;
    }
    .fp-filter-drawer .offcanvas-body {
        display: block;
        padding: 0;
        overflow: visible;
    }
    .fp-filter-panel {
        background-color: var(--surface-bg);
        color: var(--text-color);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
        padding: 1rem;
    }
}

@media (max-width: 767.98px) {
    .fp-filter-drawer {
        --bs-offcanvas-width: min(92vw, 390px);
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        background-color: var(--surface-bg);
        color: var(--text-color);
        border-left: 1px solid var(--border-color);
    }
    .fp-filter-drawer .fp-filter-drawer-body {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        padding: 0;
        overflow: hidden;
    }
    .fp-filter-drawer .fp-filter-panel,
    .fp-filter-drawer .fp-filter-form {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }
    .fp-filter-drawer .fp-filter-fields {
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1rem;
        -webkit-overflow-scrolling: touch;
    }
    .fp-filter-drawer .fp-filter-drawer-footer {
        flex-shrink: 0;
        display: flex;
        gap: 0.5rem;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--border-color);
        background-color: var(--surface-bg);
    }
    #itemsFilterDrawer .form-control,
    #itemsFilterDrawer .form-select {
        min-height: 44px;
        font-size: 1rem;
    }
}

body.dark-theme .offcanvas,
body.dark-theme .offcanvas-md,
body.dark-theme .fp-filter-drawer,
body.dark-theme .fp-filter-drawer .offcanvas-header,
body.dark-theme .fp-filter-drawer .fp-filter-drawer-footer,
[data-bs-theme="dark"] .offcanvas,
[data-bs-theme="dark"] .offcanvas-md,
[data-bs-theme="dark"] .fp-filter-drawer,
[data-bs-theme="dark"] .fp-filter-drawer .offcanvas-header,
[data-bs-theme="dark"] .fp-filter-drawer .fp-filter-drawer-footer {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-color: var(--border-color);
}

@media (min-width: 768px) {
    body.dark-theme .fp-filter-drawer,
    [data-bs-theme="dark"] .fp-filter-drawer {
        background-color: transparent !important;
    }
    body.dark-theme .fp-filter-panel,
    [data-bs-theme="dark"] .fp-filter-panel {
        background-color: var(--surface-bg);
        color: var(--text-color);
        border-color: var(--border-color);
    }
}

.fp-active-filters-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .fp-active-filters-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }
}

.fp-filter-chip {
    flex: 0 0 auto;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.45rem 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background-color: var(--surface-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

body.dark-theme .fp-filter-chip,
[data-bs-theme="dark"] .fp-filter-chip {
    background-color: var(--surface-subtle);
    color: #e2e8f0;
    border-color: var(--border-color);
}

.fp-filter-chip-remove {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    min-height: 26px;
    border: 0;
    border-radius: 999px;
    background-color: rgba(100, 116, 139, 0.14);
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.fp-filter-chip-remove:hover {
    background-color: rgba(239, 68, 68, 0.18);
    color: #ef4444;
}

.fp-filter-clear-all {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
}

.fp-filter-clear-all:hover {
    text-decoration: underline;
}

body.dark-theme .fp-filter-clear-all,
[data-bs-theme="dark"] .fp-filter-clear-all {
    color: #38d9e2;
}

/* États focus clavier haute visibilité (clair & sombre) */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.fp-mobile-bottom-nav-item:focus-visible,
.fp-filter-chip-remove:focus-visible,
.fp-lightbox-trigger:focus-visible,
.fp-lightbox-img:focus-visible,
.fp-undo-toast-close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

body.dark-theme a:focus-visible,
body.dark-theme button:focus-visible,
body.dark-theme .btn:focus-visible,
body.dark-theme .form-control:focus-visible,
body.dark-theme .form-select:focus-visible,
body.dark-theme .form-check-input:focus-visible,
body.dark-theme .fp-mobile-bottom-nav-item:focus-visible,
body.dark-theme .fp-filter-chip-remove:focus-visible,
body.dark-theme .fp-lightbox-trigger:focus-visible,
body.dark-theme .fp-lightbox-img:focus-visible,
body.dark-theme .fp-undo-toast-close:focus-visible,
[data-bs-theme="dark"] a:focus-visible,
[data-bs-theme="dark"] button:focus-visible,
[data-bs-theme="dark"] .btn:focus-visible,
[data-bs-theme="dark"] .form-control:focus-visible,
[data-bs-theme="dark"] .form-select:focus-visible,
[data-bs-theme="dark"] .form-check-input:focus-visible,
[data-bs-theme="dark"] .fp-mobile-bottom-nav-item:focus-visible,
[data-bs-theme="dark"] .fp-filter-chip-remove:focus-visible,
[data-bs-theme="dark"] .fp-lightbox-trigger:focus-visible,
[data-bs-theme="dark"] .fp-lightbox-img:focus-visible,
[data-bs-theme="dark"] .fp-undo-toast-close:focus-visible {
    outline-color: #38d9e2;
}

/* =====================================================================
   SOURCING AVANCE (/items) : BANNIERE TEMPS REEL, LIGHTBOX, SWIPE, MASSE
   ===================================================================== */
.fp-new-items-banner {
    position: sticky;
    top: 66px;
    z-index: 1010;
    text-align: center;
    padding: 0.5rem 0.75rem 0;
    pointer-events: none;
}

.fp-new-items-banner .btn {
    pointer-events: auto;
}

@keyframes fpNewFlashLight {
    0% { box-shadow: 0 0 0 3px rgba(9, 177, 186, 0.45); }
    100% { box-shadow: 0 0 0 0 rgba(9, 177, 186, 0); }
}

.fp-item-new-flash > .card {
    animation: fpNewFlashLight 2.4s ease-out;
}

/* Lightbox photo haute lisibilité */
.fp-lightbox-trigger {
    cursor: zoom-in;
}

.fp-lightbox-stage {
    overflow: auto;
    max-height: 78vh;
    max-height: 78dvh;
    background-color: var(--surface-subtle);
}

.fp-lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    max-height: 75dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    border-radius: var(--border-radius);
    transition: transform 0.16s ease;
}

.fp-lightbox-img.is-zoomed {
    max-width: none;
    max-height: none;
    width: min(180%, 1400px);
    cursor: zoom-out;
}

body.dark-theme .fp-lightbox-stage,
[data-bs-theme="dark"] .fp-lightbox-stage {
    background-color: #0b1116;
}

/* Gestes tactiles Swipe Mode Sniper Mobile */
.fp-sniper-card {
    touch-action: pan-y;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.fp-sniper-card.fp-swiping {
    transition: none;
}

.fp-sniper-card.fp-swipe-right {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.fp-sniper-card.fp-swipe-left {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.fp-sniper-swipe-badge {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    display: none;
    padding: 0.25rem 0.8rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.fp-sniper-card.fp-swipe-right .fp-sniper-swipe-badge {
    display: inline-flex;
    align-items: center;
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.fp-sniper-card.fp-swipe-left .fp-sniper-swipe-badge {
    display: inline-flex;
    align-items: center;
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.fp-sniper-card.fp-swipe-right.fp-swipe-ready .fp-sniper-swipe-badge {
    background-color: #f59e0b;
    color: #111827;
}

.fp-sniper-card.fp-swipe-left.fp-swipe-ready .fp-sniper-swipe-badge {
    background-color: #ef4444;
    color: #ffffff;
}

/* Cases de sélection multiple & barre flottante actions en masse */
.fp-bulk-check-wrap {
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.28rem;
    border-radius: 0.45rem;
    background-color: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.16);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

body.dark-theme .fp-bulk-check-wrap,
[data-bs-theme="dark"] .fp-bulk-check-wrap {
    background-color: rgba(19, 27, 35, 0.92);
    border-color: var(--border-color);
}

.fp-item-entry.fp-selected > .card {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgba(9, 177, 186, 0.28);
}

tr.fp-item-entry.fp-selected > td {
    background-color: rgba(9, 177, 186, 0.08);
}

.fp-bulk-actions-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 1rem;
    z-index: 1032;
    width: min(96vw, 940px);
    max-width: calc(100vw - 1rem);
    background-color: var(--surface-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.65rem 0.9rem;
}

.fp-bulk-tag-group {
    width: auto;
    max-width: 210px;
}

body.dark-theme .fp-bulk-actions-bar,
[data-bs-theme="dark"] .fp-bulk-actions-bar {
    background-color: #131b23;
    color: #e2e8f0;
    border-color: #2f4052;
}

/* Bandeau Annuler après masquage */
.fp-undo-toast {
    position: fixed;
    right: 1rem;
    bottom: 1.25rem;
    z-index: 1036;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: calc(100vw - 2rem);
    padding: 0.6rem 0.85rem;
    border-radius: var(--border-radius);
    background-color: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    box-shadow: var(--shadow-lg);
}

body.light-theme .fp-undo-toast,
[data-bs-theme="light"] .fp-undo-toast {
    background-color: #1e293b;
    color: #f8fafc;
}

.fp-undo-toast-close {
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.78;
    font-size: 1.15rem;
    line-height: 1;
    padding: 0 0.2rem;
    cursor: pointer;
}

.fp-undo-toast-close:hover {
    opacity: 1;
}

@media (max-width: 767.98px) {
    body.has-mobile-bottom-nav .fp-bulk-actions-bar {
        bottom: calc(4.4rem + env(safe-area-inset-bottom, 0px));
        padding: 0.55rem 0.7rem;
    }
    body.has-mobile-bottom-nav .fp-undo-toast {
        left: 0.75rem;
        right: 0.75rem;
        bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
        justify-content: space-between;
    }
    .fp-bulk-tag-group {
        max-width: 100%;
        width: 100%;
    }
}

/* =====================================================================
   RAPIDITE, RETOURS VISUELS & ACCESSIBILITE (CTRL+K, SKELETON, FOCUS)
   ===================================================================== */
.fp-skip-link {
    position: fixed;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 2000;
    padding: 0.5rem 0.9rem;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: #ffffff !important;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-md);
}

/* Skeletons de chargement */
@keyframes fpSkeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.fp-skeleton {
    display: block;
    border-radius: var(--border-radius);
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: fpSkeletonShimmer 1.35s ease-in-out infinite;
}

body.dark-theme .fp-skeleton,
[data-bs-theme="dark"] .fp-skeleton {
    background: linear-gradient(90deg, #1b2631 25%, #273645 50%, #1b2631 75%);
    background-size: 200% 100%;
}

@keyframes fpFeedLoadBar {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

.fp-feed-loading-bar {
    position: relative;
    height: 3px;
    width: 100%;
    overflow: hidden;
    background-color: rgba(9, 177, 186, 0.14);
}

.fp-feed-loading-bar::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 34%;
    background-color: var(--primary-color);
    animation: fpFeedLoadBar 1.05s ease-in-out infinite;
}

/* Palette de commandes rapide Ctrl+K */
.fp-kbd-hint {
    font-size: 0.7rem;
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
    background-color: var(--surface-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.fp-cmd-content {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.fp-cmd-list {
    max-height: min(60vh, 420px);
    max-height: min(60dvh, 420px);
    overflow-y: auto;
}

.fp-cmd-group-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 0.45rem 0.65rem 0.2rem;
}

.fp-cmd-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.7rem;
    border: 0;
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-color);
    text-align: left;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.fp-cmd-item:hover,
.fp-cmd-item.active {
    background-color: rgba(9, 177, 186, 0.12);
    color: var(--primary-color);
}

.fp-cmd-meta {
    flex-shrink: 0;
    font-size: 0.74rem;
    color: var(--text-muted);
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.dark-theme .fp-cmd-content,
[data-bs-theme="dark"] .fp-cmd-content {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-color: var(--border-color);
}

body.dark-theme .fp-kbd-hint,
[data-bs-theme="dark"] .fp-kbd-hint {
    background-color: #18222c;
    color: #94a3b8;
    border-color: var(--border-color);
}

body.dark-theme .fp-cmd-item:hover,
body.dark-theme .fp-cmd-item.active,
[data-bs-theme="dark"] .fp-cmd-item:hover,
[data-bs-theme="dark"] .fp-cmd-item.active {
    background-color: rgba(9, 177, 186, 0.2);
    color: #38d9e2;
}

.fp-cmd-item:focus-visible,
.fp-skip-link:focus-visible,
.nav-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

body.dark-theme .fp-cmd-item:focus-visible,
body.dark-theme .fp-skip-link:focus-visible,
body.dark-theme .nav-link:focus-visible,
[data-bs-theme="dark"] .fp-cmd-item:focus-visible,
[data-bs-theme="dark"] .fp-skip-link:focus-visible,
[data-bs-theme="dark"] .nav-link:focus-visible {
    outline-color: #38d9e2;
}

/* =====================================================================
   OPTIMISATIONS IPHONE / SAFARI IOS & RESPONSIVE MOBILE
   ===================================================================== */
html,
body {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.card-body,
.card-header,
.modal-body {
    min-width: 0;
}

.fp-card-dropdown-safe {
    overflow: visible;
}

@media (max-width: 767.98px) {
    /* Suppression du zoom automatique iOS Safari sur focus de champs (< 16px) */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
    select,
    textarea,
    .form-control:not(.form-control-color),
    .form-control-sm:not(.form-control-color),
    .form-select,
    .form-select-sm {
        font-size: 16px !important;
    }

    /* Modals confortables au-dessus du clavier virtuel iOS */
    .modal-dialog {
        margin: max(0.5rem, env(safe-area-inset-top, 0.5rem)) auto max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
        max-width: calc(100vw - 1rem);
    }

    .modal-content {
        max-height: calc(100dvh - 1rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1 1 auto;
    }

    .modal-header,
    .modal-footer {
        flex-shrink: 0;
        padding: 0.75rem 1rem;
    }

    /* Onglets et pilules navigables au doigt sans retour à la ligne désordonné */
    .nav-pills:not(.nav-stacked),
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .nav-pills:not(.nav-stacked)::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-pills:not(.nav-stacked) .nav-item,
    .nav-tabs .nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    /* Conversion propre des tableaux larges en cartes empilées lisibles sur iPhone */
    .fp-cards-wrap {
        overflow: visible !important;
    }

    .card:has(.fp-cards-wrap) {
        overflow: visible;
    }

    table.fp-mobile-cards-table,
    table.fp-mobile-cards-table tbody,
    table.fp-mobile-cards-table tr,
    table.fp-mobile-cards-table td {
        display: block;
        width: 100%;
    }

    table.fp-mobile-cards-table thead {
        display: none;
    }

    table.fp-mobile-cards-table tbody tr {
        position: relative;
        padding: 0.85rem 0.9rem;
        border-bottom: 1px solid var(--border-color);
        background-color: transparent;
    }

    table.fp-mobile-cards-table tbody tr:last-child {
        border-bottom: 0;
    }

    table.fp-mobile-cards-table tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.3rem 0 !important;
        border: 0 !important;
        text-align: right !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    table.fp-mobile-cards-table tbody td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 44%;
        text-align: left;
        font-size: 0.72rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-muted);
        padding-top: 0.15rem;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-title {
        display: block;
        text-align: left !important;
        padding-right: 2.5rem !important;
        padding-bottom: 0.45rem !important;
        margin-bottom: 0.25rem;
        border-bottom: 1px dashed var(--border-color) !important;
        font-size: 0.95rem;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-title::before,
    table.fp-mobile-cards-table tbody td.fp-cell-actions::before,
    table.fp-mobile-cards-table tbody td.fp-cell-empty::before {
        display: none;
        content: none;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-photo {
        display: block;
        text-align: left !important;
        padding-top: 0 !important;
        padding-bottom: 0.35rem !important;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-photo::before {
        display: none;
        content: none;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-check {
        position: absolute;
        top: 0.85rem;
        right: 0.85rem;
        width: auto;
        padding: 0 !important;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-check::before {
        display: none;
        content: none;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        align-items: center;
        gap: 0.4rem;
        padding-top: 0.55rem !important;
        margin-top: 0.25rem;
        border-top: 1px solid var(--border-color) !important;
        text-align: left !important;
    }

    table.fp-mobile-cards-table tbody td.fp-cell-empty {
        display: block;
        text-align: center !important;
        padding: 2rem 1rem !important;
    }

    /* Barres d'outils et en-têtes compacts sur mobile */
    .bulk-toolbar {
        top: calc(58px + env(safe-area-inset-top, 0px));
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
        padding: 0.65rem 0.75rem;
    }

    .fp-sniper-hero-img {
        max-height: min(44dvh, 330px);
    }

    .fp-mobile-full {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    h1.h3,
    .h3 {
        font-size: 1.28rem;
    }

    .card-header,
    .card-body {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .status-cal-weekdays,
    .status-cal-grid {
        gap: 3px;
    }

    .status-cal-tile,
    .status-cal-pad {
        min-height: 40px;
        padding: 3px 1px;
        border-radius: 6px;
    }

    .status-cal-tile .cal-day-num {
        font-size: 0.66rem;
    }

    .status-cal-tile .cal-day-pct {
        font-size: 0.62rem;
    }

    .btn-group-sm > .btn,
    .btn-sm {
        font-size: 0.82rem;
    }
}

/* Badges & mise en évidence violet pour annonces hors critère personnalisé ("bon deal mais hors champ") */
.fp-badge-violet {
    background-color: #7c3aed !important;
    color: #ffffff !important;
    border: 1px solid #6d28d9;
}

.fp-badge-violet-subtle {
    background-color: rgba(124, 58, 237, 0.14) !important;
    color: #6d28d9 !important;
    border: 1px solid rgba(124, 58, 237, 0.35) !important;
}

[data-bs-theme="dark"] .fp-badge-violet-subtle {
    background-color: rgba(139, 92, 246, 0.22) !important;
    color: #ddd6fe !important;
    border-color: rgba(167, 139, 250, 0.4) !important;
}

tr.fp-item-hors-champ > td:first-child {
    box-shadow: inset 4px 0 0 #7c3aed;
}

tr.fp-item-hors-champ {
    background-color: rgba(124, 58, 237, 0.06) !important;
}

.card.fp-item-hors-champ,
.fp-sniper-card.fp-item-hors-champ {
    border: 2px solid rgba(124, 58, 237, 0.65) !important;
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.08) 0%, transparent 45%);
}

[data-bs-theme="dark"] tr.fp-item-hors-champ {
    background-color: rgba(139, 92, 246, 0.10) !important;
}

[data-bs-theme="dark"] .card.fp-item-hors-champ,
[data-bs-theme="dark"] .fp-sniper-card.fp-item-hors-champ {
    border-color: rgba(167, 139, 250, 0.7) !important;
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.14) 0%, transparent 45%);
}

/* Barre des filtres personnalisés & groupes avancés (/items) */
.fp-presets-strip {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.fp-presets-strip::-webkit-scrollbar {
    display: none;
}

@media (min-width: 768px) {
    .fp-presets-strip {
        flex-wrap: wrap;
        overflow-x: visible;
    }
}

.fp-preset-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    border-radius: 999px;
    padding: 0.32rem 0.72rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.fp-preset-pill:hover {
    border-color: var(--bs-primary);
    transform: translateY(-1px);
}

.fp-preset-pill.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.25);
}

.fp-preset-pill[data-color="success"].active {
    background-color: #198754;
    border-color: #198754;
    box-shadow: 0 2px 8px rgba(25, 135, 84, 0.25);
}

.fp-preset-pill[data-color="danger"].active {
    background-color: #dc3545;
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.25);
}

.fp-preset-pill[data-color="warning"].active {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #111827;
}

.fp-preset-pill[data-color="info"].active {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: #111827;
}

.fp-preset-pill[data-color="violet"].active {
    background-color: #7c3aed;
    border-color: #7c3aed;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.30);
}

.fp-preset-pill[data-color="secondary"].active {
    background-color: #6c757d;
    border-color: #6c757d;
}

.fp-adv-filter-group {
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.65rem;
    padding: 0.75rem;
    height: 100%;
}

.fp-adv-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.55rem;
}

@media (prefers-reduced-motion: reduce) {
    .fp-skeleton,
    .fp-feed-loading-bar::after,
    .fp-item-new-flash > .card {
        animation: none !important;
    }
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =====================================================================
   ONGLET ARTICLES (/items) : NOTES PERSO, MASQUÉS & RESPONSIVE IPHONE
   ===================================================================== */
.fp-user-note-box {
    background-color: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-left: 3px solid #f59e0b;
    color: var(--text-color);
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
    font-size: 0.76rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

body.dark-theme .fp-user-note-box,
[data-bs-theme="dark"] .fp-user-note-box {
    background-color: rgba(245, 158, 11, 0.15);
    border-color: rgba(251, 191, 36, 0.36);
    border-left-color: #fbbf24;
    color: #fef3c7;
}

@media (max-width: 767.98px) {
    table.fp-mobile-cards-table tbody td.fp-cell-actions .btn-group {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.42rem !important;
        width: 100%;
    }
    table.fp-mobile-cards-table tbody td.fp-cell-actions .btn-group > .btn,
    table.fp-mobile-cards-table tbody td.fp-cell-actions .btn-group > form {
        flex: 0 0 auto;
        margin-left: 0 !important;
    }
    table.fp-mobile-cards-table tbody td.fp-cell-actions .btn-group > .btn,
    table.fp-mobile-cards-table tbody td.fp-cell-actions .btn-group > form > .btn {
        border-radius: var(--bs-btn-border-radius) !important;
        min-width: 42px !important;
        min-height: 42px !important;
        width: auto !important;
        height: auto !important;
        padding: 0.35rem 0.65rem !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        line-height: 1.2 !important;
    }
    .fp-items-toggles-strip {
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.65rem;
        width: 100%;
        padding: 0.25rem 0.1rem;
    }
    .fp-items-toggles-strip::-webkit-scrollbar {
        display: none;
    }
    .fp-items-toggles-strip > * {
        flex: 0 0 auto;
    }
    .fp-sniper-secondary-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem !important;
    }
    .fp-sniper-secondary-grid > .btn {
        width: 100%;
        min-width: 0;
        padding-left: 0.45rem;
        padding-right: 0.45rem;
        font-size: 0.84rem;
    }
    #cardView .card-footer .btn-sm {
        min-height: 38px;
        min-width: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    body.has-mobile-bottom-nav .fp-bulk-actions-bar {
        left: max(0.5rem, env(safe-area-inset-left, 0.5rem));
        right: max(0.5rem, env(safe-area-inset-right, 0.5rem));
        transform: none;
        width: auto;
        max-width: none;
        max-height: 44dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-dialog {
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

@media (max-width: 390px) {
    .fp-mobile-filter-bar .btn {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
        font-size: 0.8rem;
    }
}

.fp-confirm-armed,
.fp-confirm-armed:hover,
.fp-confirm-armed:focus {
    background-color: var(--bs-danger) !important;
    border-color: var(--bs-danger) !important;
    color: #ffffff !important;
    font-weight: 600;
}

.fp-smart-builder-box {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(99, 102, 241, 0.06));
    border: 1px solid rgba(14, 165, 233, 0.28);
    border-radius: 0.65rem;
}

.fp-tag-suggestion-pill {
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0.28rem 0.58rem;
    border-radius: 999px;
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: all 0.14s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.fp-tag-suggestion-pill:hover {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.fp-tag-suggestion-pill.is-active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #ffffff;
}

.fp-auto-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    font-size: 0.67rem;
    padding: 0.16rem 0.44rem;
    border-radius: 999px;
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    cursor: pointer;
    transition: all 0.14s ease;
    line-height: 1.2;
}

.fp-auto-tag-chip:hover,
.fp-auto-tag-chip.is-active {
    border-color: var(--bs-primary);
    background-color: rgba(14, 165, 233, 0.14);
    color: var(--bs-primary);
}

.fp-auto-tags-bar {
    border-top: 1px dashed var(--bs-border-color);
    padding-top: 0.55rem;
    margin-top: 0.55rem;
}
