/* --- Index Page Custom Classes for Inline Styles --- */
.entity-header-row-inner {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}
.kpi-cards-row {
    display: flex;
    gap: var(--space-lg);
}
.btn-create {
    white-space: nowrap;
    margin-top: var(--space-xl);
    padding: var(--space-sm) var(--space-xl);
    line-height: var(--line-height-normal);
    font-weight: var(--font-weight-medium);
}

.btn-create-icon {
    margin-right: var(--space-sm);
}
.entity-export-btns {
    gap: var(--space-sm);
}
.entity-table {
    margin-bottom: 0;
    width: 100%;
}
.entity-table thead th {
    font-weight: 500;
    color: #1e293b;
    background: #fff !important;
    border-bottom: 0.0625rem solid #e2e8f0;
}
.entity-table tbody tr:nth-child(even) td {
    background: #f8fafc !important;
}
.entity-table tbody tr:nth-child(odd) td {
    background: #fff !important;
}
.entity-table tbody tr:hover td {
    background: #f1f5f9 !important;
}
.entity-table .entity-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}
.entity-table .entity-link:hover {
    text-decoration: underline;
}
.entity-table .cell-phone {
    color: #64748b;
    font-size: var(--font-size-sm);
}

/* ----- Layout global : sidebar (largeur fixe) + header + main ----- */
/* Sidebar = même largeur partout. Header/main = alignés à droite (var ou .app-sidebar.is-collapsed). */
.sidebar-provider {
    padding-top: 0;
    margin-top: 0;
}
.sidebar,
.app-sidebar {
    width: var(--sidebar-width-expanded);
    min-width: var(--sidebar-width-expanded);
    box-sizing: border-box;
    background: var(--sidebar-bg);
    font-family: var(--font-sans);
}
.sidebar *,
.app-sidebar * {
    box-sizing: border-box;
}
.app-sidebar.is-collapsed,
.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    min-width: var(--sidebar-width-collapsed);
}
.app-sidebar .sidebar-header {
    padding: var(--sidebar-padding-y) var(--sidebar-padding-x);
}
.app-sidebar .sidebar-search-wrap {
    padding-left: var(--sidebar-padding-x);
    padding-right: var(--sidebar-padding-x);
}
.app-sidebar .sidebar-footer {
    padding: var(--sidebar-padding-y) var(--sidebar-padding-x);
}
.app-sidebar .sidebar-nav ul > li {
    margin-bottom: var(--sidebar-gap);
}
.app-sidebar .menu-item {
    border-radius: var(--sidebar-item-radius);
}
.app-sidebar .menu-link {
    min-height: var(--sidebar-item-height);
}
.header-navbar {
    left: var(--sidebar-width-expanded);
    width: calc(100% - var(--sidebar-width-expanded));
    top: 0;
    height: var(--header-height);
}
.app-sidebar.is-collapsed ~ .header-navbar,
body.sidebar-collapsed .header-navbar {
    left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

/* ----- Pages liste (patients + autres listes) : layout global ----- */
/* Masquer le header global sur toute page liste (patient, contact, product, etc.) */
.sidebar-provider:has(.patient-list-page) .header-navbar,
.sidebar-provider:has(.entity-list-page) .header-navbar,
.sidebar-provider:has(.entity-container > .entity-header-row) .header-navbar,
.sidebar-provider:has(main.main-area) .header-navbar {
    display: none !important;
}

.main-content:has(.patient-list-page),
.main-content:has(.entity-list-page),
.main-content:has(.entity-container > .entity-header-row) {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 0;
    height: 100vh;
    overflow: hidden;
    margin-left: var(--sidebar-width-expanded);
    width: calc(100% - var(--sidebar-width-expanded));
    padding: 0;
    font-family: var(--font-sans);
    font-size: clamp(1rem, 1vw + 0.5rem, 1.125rem);
}
.app-sidebar.is-collapsed ~ .main-content:has(.patient-list-page),
body.sidebar-collapsed .main-content:has(.patient-list-page),
.app-sidebar.is-collapsed ~ .main-content:has(.entity-list-page),
body.sidebar-collapsed .main-content:has(.entity-list-page),
.app-sidebar.is-collapsed ~ .main-content:has(.entity-container > .entity-header-row),
body.sidebar-collapsed .main-content:has(.entity-container > .entity-header-row) {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

/* Pages legacy (entity-header-row) : header bleu + scroll corps, sans modifier les templates */
.main-content:has(.entity-container > .entity-header-row) > .alert {
    flex-shrink: 0;
    margin: var(--space-md) var(--page-padding-x) 0;
}

.main-content:has(.entity-container > .entity-header-row) > .entity-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    background: #f8fafc;
    box-sizing: border-box;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-shrink: 0;
    min-height: var(--header-height);
    background: var(--page-header-nav);
    color: #e2e8f0;
    padding: var(--space-md) var(--space-xl);
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
    margin-bottom: 0;
    gap: var(--space-lg);
    align-items: center;
    box-sizing: border-box;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-title {
    color: #e2e8f0;
    font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem);
    font-weight: 500;
    line-height: var(--line-height-tight);
    margin: 0 0 var(--space-xs) 0;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-desc {
    color: #e2e8f0;
    opacity: 0.85;
    margin: 0;
    font-size: var(--font-size-md);
    line-height: var(--line-height-relaxed);
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-create {
    flex-shrink: 0;
    margin: 0;
    background: #22c55e;
    color: #fff;
    border: none;
    padding: var(--space-sm) var(--space-xl);
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.18s, transform 0.18s;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-create:hover {
    background: #16a34a;
    color: #fff;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-secondary,
.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-outline-light {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.4);
    background: transparent;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-secondary:hover,
.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-outline-light:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.55);
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .entity-filters {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.main-content:has(.entity-container > .entity-header-row) .entity-header-row .entity-filters label {
    color: rgba(255, 255, 255, 0.85);
}

.main-content:has(.entity-container > .entity-header-row) > .entity-container > :not(.entity-header-row) {
    padding-inline: var(--page-padding-x);
    box-sizing: border-box;
}

.main-content:has(.entity-container > .entity-header-row) > .entity-container > .entity-header-row + * {
    padding-top: var(--space-md);
}

.main-content:has(.entity-container > .entity-header-row) > .entity-container > :last-child {
    padding-bottom: var(--space-md);
}

.patient-list-page,
.entity-list-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.patient-list-header,
.entity-list-header {
    position: sticky;
    top: 0;
    z-index: 2;
    min-height: var(--header-height);
    background: var(--page-header-nav);
    color: #e2e8f0;
    flex-shrink: 0;
    margin-top: 0;
    padding: var(--space-md) var(--space-xl);
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
    width: 100%;
    box-sizing: border-box;
}

.patient-list-header-row-top,
.entity-list-header-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: var(--space-lg);
}

.patient-list-header-title-block,
.entity-list-header-title-block {
    flex: 0 1 auto;
}

.patient-list-header .entity-header-title,
.entity-list-header .entity-header-title {
    color: #e2e8f0;
    font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem);
    font-weight: 500;
    line-height: var(--line-height-tight);
    margin: 0 0 var(--space-xs) 0;
}
.patient-list-header .entity-header-desc,
.entity-list-header .entity-header-desc {
    color: #e2e8f0;
    opacity: 0.85;
    margin: 0;
    font-size: var(--font-size-md);
    line-height: var(--line-height-relaxed);
}

.patient-list-header-row-bottom,
.entity-list-header-row-bottom {
    margin-top: var(--space-md);
}

.patient-list-header .kpi-card {
    border-radius: var(--radius-lg);
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15);
    padding: var(--space-md) var(--space-lg);
    min-width: 10rem;
}
.patient-list-header .kpi-card-value {
    font-size: clamp(1.25rem, 1.5vw + 0.75rem, 1.75rem);
    font-weight: 500;
}

.patient-list-header .btn-create,
.entity-list-header .btn-create {
    flex-shrink: 0;
    margin: 0;
    background: #22c55e;
    color: #fff;
    border: none;
    padding: var(--space-sm) var(--space-xl);
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.18s, transform 0.18s;
}
.patient-list-header .btn-create:hover,
.entity-list-header .btn-create:hover {
    background: #16a34a;
    color: #fff;
}

.patient-list-body,
.entity-list-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-md) var(--page-padding-x);
    background: #f8fafc;
}
.patient-list-body .entity-container,
.entity-list-body .entity-container {
    width: 100%;
    max-width: var(--container-max-w);
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    min-height: clamp(40vh, 80vh, 100vh);
    gap: var(--space-lg);
}

/* Pages show / dashboard (main-area) : même gouttière que /patients */
main.main-area > .content-area > .content-container {
    width: 100%;
    max-width: var(--container-max-w);
    margin-inline: auto;
    padding-inline: var(--page-padding-x);
    box-sizing: border-box;
}

.patient-list-body .entity-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(var(--space-sm), 1.5vw, var(--space-md));
    margin-bottom: var(--space-md);
}
.patient-list-body .entity-filters .form-select,
.entity-list-body .entity-filters .form-select {
    min-height: 2.5rem;
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    padding-inline: var(--space-md);
}
.patient-list-body .entity-filters > div,
.entity-list-body .entity-filters > div {
    flex: 0 1 auto;
    min-width: min(10rem, 100%);
}
.patient-list-body .entity-export-btns,
.entity-list-body .entity-export-btns {
    margin-left: auto;
    display: flex;
    gap: var(--space-sm);
}

.patient-list-page .patient-list-body .entity-table-wrapper,
.entity-list-page .entity-list-body .entity-table-wrapper {
    flex: 1;
    min-height: clamp(20rem, 50vh, 70vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 0.0625rem solid #e5e7eb;
    border-radius: var(--radius-lg);
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
}
.patient-list-page .patient-list-body .entity-table-scroll,
.entity-list-page .entity-list-body .entity-table-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.patient-list-body .entity-table-wrapper table,
.entity-list-body .entity-table-wrapper table,
.entity-table {
    width: 100%;
}
.patient-list-body .entity-table-wrapper thead,
.entity-list-body .entity-table-wrapper thead {
    background: #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 1;
}
.patient-list-body .entity-table-wrapper thead th,
.entity-list-body .entity-table-wrapper thead th {
    font-weight: 500;
    color: #1e293b;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-md);
    border-bottom: 0.0625rem solid #e2e8f0;
}
.patient-list-body .entity-table-wrapper table tr,
.patient-list-body .entity-table-wrapper table td,
.patient-list-body .entity-table-wrapper table th,
.entity-list-body .entity-table-wrapper table tr,
.entity-list-body .entity-table-wrapper table td,
.entity-list-body .entity-table-wrapper table th {
    background: transparent !important;
}
.patient-list-body .entity-table-wrapper thead th,
.entity-list-body .entity-table-wrapper thead th {
    background: #f1f5f9 !important;
}
.patient-list-body .entity-table-wrapper tbody tr:nth-child(even) td,
.entity-list-body .entity-table-wrapper tbody tr:nth-child(even) td {
    background: #f8fafc !important;
}
.patient-list-body .entity-table-wrapper tbody tr:nth-child(odd) td,
.entity-list-body .entity-table-wrapper tbody tr:nth-child(odd) td {
    background: #fff !important;
}
.patient-list-body .entity-table-wrapper tbody tr:hover td,
.entity-list-body .entity-table-wrapper tbody tr:hover td {
    background: #f1f5f9 !important;
}
.patient-list-body .entity-table-wrapper tbody td,
.entity-list-body .entity-table-wrapper tbody td {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-md);
    line-height: var(--line-height-relaxed);
    vertical-align: middle;
}
.patient-list-body .entity-table-wrapper .entity-link,
.entity-list-body .entity-table-wrapper .entity-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}
.patient-list-body .entity-table-wrapper .entity-link:hover,
.entity-list-body .entity-table-wrapper .entity-link:hover {
    text-decoration: underline;
}
.patient-list-body .entity-table-wrapper .cell-phone {
    color: #64748b;
    font-size: var(--font-size-sm);
}
.badge-pec {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
}
.badge-pec-had {
    background: #dbeafe;
    color: #1d4ed8;
}
.badge-pec-ssiad {
    background: #dcfce7;
    color: #15803d;
}
.badge-pec-other {
    background: #f1f5f9;
    color: #475569;
}

.patient-list-body .pagination-wrapper,
.entity-list-body .pagination-wrapper {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    margin: var(--space-lg) 0;
}
.patient-list-body .pagination-btn,
.entity-list-body .pagination-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background: transparent;
    color: #475569;
    border: 0.0625rem solid #cbd5e1;
    font-weight: 500;
    font-size: var(--font-size-md);
    text-decoration: none;
    transition: background 0.18s, color 0.18s, border 0.18s;
}
.patient-list-body .pagination-btn:hover:not(.pagination-btn-active),
.entity-list-body .pagination-btn:hover:not(.pagination-btn-active) {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}
.patient-list-body .pagination-btn-active,
.entity-list-body .pagination-btn-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    pointer-events: none;
}
.patient-list-body .pagination-btn:first-of-type:not([href]),
.patient-list-body .pagination-btn:last-of-type:not([href]),
.entity-list-body .pagination-btn:first-of-type:not([href]),
.entity-list-body .pagination-btn:last-of-type:not([href]) {
    opacity: 0.5;
    pointer-events: none;
}

@media (max-width: 56.25rem) {
    .main-content:has(.patient-list-page),
    .main-content:has(.entity-list-page) {
        margin-left: 0;
        width: 100%;
    }
    body.sidebar-collapsed .main-content:has(.patient-list-page),
    body.sidebar-collapsed .main-content:has(.entity-list-page),
    .app-sidebar.is-collapsed ~ .main-content:has(.entity-list-page) {
        margin-left: 0;
        width: 100%;
    }
    .patient-list-header-row-top,
    .entity-list-header-row-top {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }
    .patient-list-header-row-bottom .kpi-cards-row {
        flex-direction: column;
    }
    .patient-list-body .entity-filters,
    .entity-list-body .entity-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .patient-list-body .entity-filters > div,
    .entity-list-body .entity-filters > div {
        min-width: 100%;
    }
    .patient-list-body .entity-export-btns,
    .entity-list-body .entity-export-btns {
        margin-left: 0;
    }
}

/* Entity filters avec marge bottom */
.entity-filters {
    margin-bottom: var(--space-lg);
}

/* Gap pour d-flex */
.d-flex.gap-2 {
    gap: var(--space-sm);
}

/* Table sans marge bottom */
.table-no-margin {
    margin-bottom: 0;
}

/* Bouton full width */
.btn-full-width {
    width: 100%;
}

/* Product search suggestions */
.product-suggestions {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 0.0625rem solid #eee;
    border-radius: 0.5rem;
    box-shadow: 0 0.375rem 1.125rem rgba(0,0,0,0.06);
    max-height: 20rem;
    overflow-y: auto;
    display: none;
}

.product-suggestions.is-open {
    display: block;
}

.product-suggestions-header {
    padding: 0.5rem 0.75rem;
    font-weight: 500;
    color: #1565c0;
}

.product-suggestions-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-top: 0.0625rem solid #f6f6f6;
}

.product-search-container {
    position: relative;
}

/* Icon size */
.icon-size-lg {
    font-size: 1.2em;
}

/* Stock transfer card */
.stock-transfer-card {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.06);
    padding: 1.5rem;
    border: 0.0625rem solid #e5e7eb;
}

/* Position relative */
.position-relative {
    position: relative;
}

/* Hidden element */
.hidden-element {
    display: none;
}

/* Dictionary specific */
.dictionary-select-wrapper {
    flex: 0 0 auto;
    min-width: 20rem;
}

.dictionary-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
    color: #374151;
}

.dictionary-form-container {
    display: none;
}

.dictionary-form-container.is-open {
    display: block;
}

.dictionary-form-wrapper {
    padding: var(--space-xl);
}

.dictionary-form-title {
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: #222;
}

.dictionary-form-button {
    margin-top: var(--space-lg);
}

.dictionary-explanations-container {
    display: none;
}

.dictionary-explanations-container.is-open {
    display: block;
}

.dictionary-explanations-title {
    margin-bottom: var(--space-md);
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: #222;
}

.dictionary-empty-message {
    padding: var(--space-2xl);
    text-align: center;
    color: #6b7280;
}

.dictionary-pagination {
    display: none;
}

.dictionary-pagination.is-open {
    display: flex;
}

.dictionary-page-info {
    padding: 0 var(--space-lg);
    font-size: var(--font-size-md);
    color: #374151;
}

/* Icon margin right small */
.icon-margin-right-small {
    margin-right: var(--space-xs);
}

/* Dictionary overlay */
.overlay-content h3 {
    margin-bottom: var(--space-md);
    font-size: var(--font-size-xl);
    font-weight: 500;
    color: #222;
}

.overlay-content p {
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-md);
    color: #6b7280;
    line-height: var(--line-height-normal);
}

.overlay-content select {
    margin-bottom: var(--space-xl);
}

/* Dictionary explanation paragraph */
.dictionary-explanation-p {
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-sm);
    color: #6b7280;
    line-height: var(--line-height-relaxed);
}

.dictionary-explanation-strong {
    color: #222;
}

/* Dictionary error message */
.dictionary-error-message {
    padding: var(--space-xl);
    background: rgba(239, 68, 68, 0.1);
    border: 0.0625rem solid #ef4444;
    border-radius: var(--radius-md);
    color: #ef4444;
    margin: var(--space-md);
}

/* Dictionary sortable header */
.dictionary-sortable-header {
    cursor: pointer;
    user-select: none;
}

.dictionary-sort-indicator {
    color: #2563eb;
}
.kpi-card-value {
    font-size: var(--font-size-2xl);
    font-weight: 500;
    line-height: var(--line-height-tight);
}
.entity-link-disabled {
    color: #6c757d;
    cursor: not-allowed;
    text-decoration: none;
    pointer-events: none;
    opacity: 0.6;
}

.entity-link {
    text-decoration: none;
    color: inherit;
    line-height: var(--line-height-normal);
}
/* --- Index KPI Cards --- */
.kpi-card {
    background: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-xl);
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 10.625rem;
    margin-left: 1.125rem;
    margin-right: 0;
    font-size: var(--font-size-sm);
    font-weight: 500;
    gap: 0.25rem;
    line-height: var(--line-height-relaxed);
}

/* ---- Fees pages (RH + Compta) ---- */

/* Grille liste notes de frais (format show) */
.sections-container.fees-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-xl, var(--space-xl, 1.5rem));
    max-width: 100%;
}

.fees-period-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.04);
    padding: clamp(0.5rem, 1vw, 0.875rem);
    margin-bottom: clamp(0.75rem, 1.5vw, 1.25rem);
}

.fees-period-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(0.5rem, 1vw, 0.875rem);
    margin-bottom: clamp(0.25rem, 0.75vw, 0.5rem);
}

.fees-period-title {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    font-weight: 500;
    line-height: var(--line-height-tight);
    color: #111827;
}

.fees-period-meta {
    display: flex;
    align-items: center;
    gap: clamp(0.25rem, 0.75vw, 0.5rem);
}

.fees-period-total {
    font-weight: 500;
    color: #111827;
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
}

/* Fees tables: align amount & compact toggle columns */
.fees-col-amount {
    text-align: right;
}

.fees-col-toggle {
    text-align: center;
    width: clamp(4rem, 6vw, 5rem);
}
.kpi-hospitalisation {
    background: linear-gradient(135deg,#2563eb,#60a5fa);
    color: #fff;
}
.kpi-suspension {
    background: linear-gradient(135deg,#f59e42,#fbbf24);
    color: #fff;
}
@media (max-width: 56.25rem) {
    .entity-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .kpi-card {
        margin-left: 0;
        margin-top: 0.625rem;
        min-width: 7.5rem;
        font-size: var(--font-size-md);
        padding: 0.625rem 1rem;
    }
}
.title-spacing {
    margin-top: var(--space-xl);
}

.transmission-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: calc(100vw - var(--sidebar-width-expanded));
    margin-left: auto;
    margin-right: 0;
    box-sizing: border-box;
    overflow-x: auto;
    padding: 0 var(--space-xl);
}

@media (max-width: 56.25rem) {
    .transmission-container {
        max-width: 100vw;
        margin-left: 0;
        margin-right: 0;
        padding: 0 var(--space-md);
    }
}

.main-content {
    margin-left: var(--sidebar-width-expanded);
    margin-top: var(--header-height);
    box-sizing: border-box;
    width: calc(100% - var(--sidebar-width-expanded));
    transition: margin-left 160ms ease, margin-top 160ms ease, width 160ms ease;
    padding: var(--space-md) var(--page-padding-x);
}
.app-sidebar.is-collapsed ~ .main-content,
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

/* Sidebar : largeur fixe partout (annule navbar 30% sur petits écrans) */
@media (max-width: 75em) {
    .sidebar,
    .app-sidebar {
        width: var(--sidebar-width-expanded) !important;
        min-width: var(--sidebar-width-expanded) !important;
    }
    .app-sidebar.is-collapsed,
    .sidebar.collapsed {
        width: var(--sidebar-width-collapsed) !important;
        min-width: var(--sidebar-width-collapsed) !important;
    }
}
@media (max-width: 56.25rem) {
    :root {
        --sidebar-width-expanded: 0;
        --sidebar-width-collapsed: 0;
        --header-height: 0;
    }
    .transmission-container {
        max-width: 100vw;
        margin-left: 0;
        margin-right: 0;
        padding: 0 var(--space-md);
    }

    .main-content {
        margin-left: 0;
        margin-top: 0;
        width: 100%;
        padding: var(--space-sm) var(--page-padding-x);
    }
}

.transmission-form-grid {
    display: grid;
    grid-template-columns: 1fr 2rem 1fr;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
    align-items: stretch;
}
.transmission-form-block,
.task-form-block {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.04);
    padding: var(--space-xl);
    min-width: 0;
}
.task-form-block {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: var(--space-xl) 0 var(--space-xl) 0;
}
.separator-block {
    display: flex;
    align-items: center;
    justify-content: center;
}
.vertical-separator {
    width: 0.125rem;
    height: 90%;
    background: linear-gradient(to bottom, #e5e7eb 10%, #cbd5e1 90%);
    border-radius: var(--radius-sm);
    margin: 0 var(--space-sm);
}
@media (max-width: 56.25rem) {
    .transmission-form-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    .separator-block,
    .vertical-separator {
        display: none;
    }
    .transmission-form-block,
    .task-form-block {
        padding: var(--space-md);
    }
}

.btn-modern-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: #f3f4f6;
    color: #2563eb;
    border: 0.0625rem solid #2563eb;
    border-radius: var(--radius-md);
    padding: 0.625rem 1.5rem;
    font-weight: 500;
    font-size: var(--font-size-md);
    line-height: var(--line-height-normal);
    text-decoration: none;
    transition: background 0.18s, color 0.18s, border 0.18s;
    margin-top: var(--space-lg);
}
.btn-modern-back:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.subtitle-transmission {
    font-size: var(--font-size-lg);
    color: #4b5563;
    margin-bottom: var(--space-lg);
    margin-top: -0.5rem;
    line-height: var(--line-height-relaxed);
}

.transmission-main-wrapper {
    width: 90%;
    max-width: 100rem;
    margin: 0 auto;
}

.align-left {
    text-align: left !important;
}

@media (max-width: 56.25rem) {
    .transmission-main-wrapper {
        width: 100%;
        padding: 0 var(--space-sm);
    }
}

.transmission-grid-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.875rem;
    margin-bottom: var(--space-xl);
    align-items: start;
}

.transmission-form-simple,
.task-form-simple {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: none;
    border: 0.0625rem solid #e5e7eb;
    padding: var(--space-xl) var(--space-lg);
}

.form-simple {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.form-section-title {
    margin-bottom: 1.2rem;
    font-size: var(--font-size-lg);
    color: #222;
    font-weight: 500;
    letter-spacing: -0.03125em;
    line-height: var(--line-height-tight);
    padding-bottom: 0 !important;
}

.form-simple .form-section-title {
    margin-top: 0;
    margin-bottom: 1.2rem;
    font-size: var(--font-size-lg);
    color: #222;
    font-weight: 500;
    letter-spacing: -0.03125em;
    line-height: var(--line-height-tight);
    padding-bottom: 0 !important;
}

.form-simple .form-widget {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.form-simple input,
.form-simple textarea,
.form-simple select {
    border: 0.0625rem solid #e5e7eb;
    border-radius: 0;
    background: #fff;
    padding: 0.75rem 1rem;
    font-size: var(--font-size-md);
    line-height: var(--line-height-normal);
    margin-bottom: 1.1rem;
    transition: border 0.18s;
}

.form-simple input:focus,
.form-simple textarea:focus,
.form-simple select:focus {
    border-color: #2563eb;
    background: #f9fafb;
    outline: none;
}

.form-simple label {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
    display: block;
    line-height: var(--line-height-normal);
}

@media (max-width: 56.25rem) {
    .transmission-grid-forms {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }
    .transmission-form-simple,
    .task-form-simple {
        padding: var(--space-md);
    }
}

.entity-container {
    width: 95%;
    margin: 1.5625rem auto 0 auto;
}
.entity-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    gap: var(--space-xl);
}
.entity-header-title {
    margin-bottom: 0;
    font-size: var(--font-size-3xl);
    font-weight: 500;
    line-height: var(--line-height-tight);
}
.entity-header-desc {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
}
.entity-filters {
    width: 100%;
    display: flex;
    gap: clamp(0.5rem, 1vw, 0.75rem);
    margin-bottom: clamp(0.75rem, 1.5vw, 1.25rem);
}
.entity-filters > * {
    flex: 1 1 0;
    min-width: 0;
}
.entity-table-wrapper {
    width: 100%;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 0.0625rem solid #e5e7eb;
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.06);
    margin-bottom: clamp(0.75rem, 1.5vw, 1.25rem);
    overflow-x: auto;
}
/* Fond blanc sur toutes les lignes du tableau */
.entity-table-wrapper table tr,
.entity-table-wrapper table td,
.entity-table-wrapper table th {
    background: #fff !important;
}
.entity-table-wrapper table tr:hover td {
    background: #fff !important;
}
@media (max-width: 75rem) {
    .entity-container { width: 98%; }
}
@media (max-width: 56.25rem) {
    .entity-container { width: 100%; margin: 1rem 0 0 0; }
    .entity-header-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

/* Ajoute du padding aux cellules des tableaux Bootstrap patients */
.table.table-striped.table-hover.align-middle td,
.table.table-striped.table-hover.align-middle th {
    padding-top: clamp(0.5rem, 1vw, 0.9rem) !important;
    padding-bottom: clamp(0.5rem, 1vw, 0.9rem) !important;
    padding-left: clamp(0.75rem, 1.2vw, 1.1rem) !important;
    padding-right: clamp(0.75rem, 1.2vw, 1.1rem) !important;
    font-size: var(--font-size-md);
    line-height: var(--line-height-relaxed);
}

.pagination-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin: 1.375rem 0;
}

.pagination-btn {
    display: inline-block;
    font-size: var(--font-size-lg);
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius-lg);
    background: #f4f4f6;
    color: #374151;
    border: 0.0625rem solid #d1d5db;
    font-weight: 500;
    line-height: var(--line-height-normal);
    text-decoration: none;
    transition: background 0.18s, color 0.18s, border 0.18s;
}
.pagination-btn:hover {
    background: #e5e7eb;
    color: #222;
    border-color: #a1a1aa;
}
.pagination-btn-active {
    background: #e5e7eb;
    color: #222;
    border-color: #a1a1aa;
    pointer-events: none;
}

/* Toggle Switch pour champs booléens */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: clamp(2.5rem, 4vw, 3.25rem);
    height: clamp(1.4rem, 2.4vw, 1.9rem);
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 2rem;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: clamp(1.1rem, 1.8vw, 1.4rem);
    width: clamp(1.1rem, 1.8vw, 1.4rem);
    left: clamp(0.2rem, 0.4vw, 0.3rem);
    bottom: clamp(0.2rem, 0.4vw, 0.3rem);
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
.toggle-switch input:checked + .toggle-slider {
    background-color: #28a745;
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(clamp(1.1rem, 1.8vw, 1.4rem));
}
.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0.125rem #28a745;
}
.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.toggle-label {
    font-size: var(--font-size-sm);
    color: #666;
    user-select: none;
}
.toggle-label.active {
    color: #28a745;
    font-weight: 500;
}

/* Overlay modal */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.overlay.active {
    display: flex;
}
.overlay-content {
    background: white;
    padding: var(--space-2xl);
    border-radius: var(--radius-lg);
    max-width: 31.25rem;
    width: 90%;
    box-shadow: 0 0.5rem 2rem rgba(0,0,0,0.15);
}

/* Dictionary layout - 2 colonnes */
.dictionary-content-layout {
    display: flex;
    gap: var(--space-xl);
    align-items: flex-start;
    margin-bottom: var(--space-lg);
}
.dictionary-sidebar-left {
    flex: 0 0 23%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}
.dictionary-main-right {
    flex: 1;
    min-width: 0;
}
@media (max-width: 56.25rem) {
    .dictionary-content-layout {
        flex-direction: column;
    }
    .dictionary-sidebar-left {
        flex: 1;
        width: 100%;
    }
    .dictionary-main-right {
        flex: 1;
        width: 100%;
    }
}

/* Groupement par période - menus repliables */
.fees-period-card {
    border: 0.0625rem solid #e5e7eb;
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    background: #ffffff;
    overflow: hidden;
}
.fees-period-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: #f9fafb;
    cursor: pointer;
}
.fees-period-header:hover {
    background: #f3f4f6;
}
.fees-period-header-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.fees-period-title {
    margin: 0;
    font-size: var(--font-size-md);
}
.fees-period-meta {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    font-size: var(--font-size-sm);
}
.fees-period-chevron i {
    transition: transform 0.18s ease;
}
.fees-period-content {
    padding: var(--space-sm) var(--space-md) var(--space-md);
}
.fees-period-card.is-collapsed .fees-period-content {
    display: none;
}
.fees-period-card.is-collapsed .fees-period-chevron i {
    transform: rotate(180deg); /* chevron vers le bas en mode replié */
}

/* Modal Corriger (notes de frais RH) */
.modal-overlay {
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 3000;
}
.modal-content.modal-corriger-content {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    width: min(90vw, 28rem);
    max-width: 95%;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.2);
}
.modal-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}
.modal-title {
    margin: 0;
    font-size: var(--font-size-lg);
}
.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
}
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-sm);
}
.modal-form-full {
    grid-column: 1 / -1;
}
.modal-form-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    margin-top: var(--space-md);
}
.icon-margin-right {
    margin-right: var(--space-xs);
}
.modal-correction-body {
    padding: var(--space-sm) 0;
}
.modal-correction-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.btn-link-muted,
.btn-show-correction {
    color: var(--bs-secondary-color, #6c757d);
    text-decoration: none;
    cursor: pointer;
    pointer-events: auto;
}
.btn-link-muted:hover,
.btn-show-correction:hover {
    color: var(--bs-body-color);
    text-decoration: underline;
}

/* Bouton \"Correction demandée\" avec un style badge/pill discret */
.btn-show-correction {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.125rem 0.5rem;
    border-radius: 50rem;
    background-color: rgba(25, 135, 84, 0.06); /* vert très léger */
    font-size: var(--font-size-sm);
}
.btn-show-correction i {
    color: #198754; /* même vert que btn-success Bootstrap */
}
.btn-show-correction:hover {
    background-color: rgba(25, 135, 84, 0.12);
}