/* === Syntheses PNCEE - Styles === */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --muted-color: #6c757d;
}

/* === Navigation === */
nav .nav-link {
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

nav .nav-link.active {
    opacity: 1;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}

nav .nav-link:hover {
    opacity: 1;
}

/* === Page Sections === */
.page-section[hidden] {
    display: none;
}

.page-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Actions bar with search left, button right */
.config-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}
.config-actions-bar input[type="search"] {
    margin: 0 !important;
    max-width: 20rem;
}

/* === Config Section Cards === */
.config-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.config-section h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* === User Guide === */
.guide-section {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: #fff;
}

.guide-section summary {
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-section summary::before {
    content: '\25B6';
    font-size: 0.65rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.guide-section[open] summary::before {
    transform: rotate(90deg);
}

.guide-section summary::-webkit-details-marker { display: none; }

.guide-content {
    padding: 0 0.9rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #444;
}

.guide-content h5 {
    font-size: 0.88rem;
    margin: 0.75rem 0 0.3rem;
    color: #333;
}

.guide-content h5:first-child {
    margin-top: 0;
}

.guide-content ul, .guide-content ol {
    margin: 0.3rem 0 0.5rem 1.2rem;
    padding: 0;
}

.guide-content p {
    margin: 0.3rem 0;
}

.guide-content table {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin: 0.3rem 0 0.5rem;
}

.guide-content table th,
.guide-content table td {
    border-bottom: 1px solid #eee;
}

.guide-content pre {
    overflow-x: auto;
}

/* === Placeholder selects (empty value selected) === */
select.select-placeholder {
    color: var(--muted-color);
}

/* === Form Groups === */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    font-weight: 600;
}

/* === Actions === */
.actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

/* === Action Buttons === */
.btn-action-blue,
.btn-action-green,
.btn-action-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0 0.9rem;
    margin: 0;
    color: #fff;
    border: none;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    line-height: 2rem;
    box-sizing: border-box;
    height: 2rem;
    vertical-align: middle;
}

.btn-action-blue { background: #1976d2; }
.btn-action-green { background: #2e7d32; }
.btn-action-outline {
    background: #fff;
    color: #555;
    border: 1px solid #adb5bd;
}

.btn-action-blue:hover,
.btn-action-green:hover { opacity: 0.88; }
.btn-action-outline:hover { background: #f1f3f5; }
.btn-action-outline.danger { color: #c62828; border-color: #c62828; }
.btn-action-outline.danger:hover { background: #ffebee; }

.btn-action-blue:disabled,
.btn-action-green:disabled,
.btn-action-outline:disabled { opacity: 0.5; cursor: default; }

/* === Small action buttons (edit/delete in tables) === */
.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    color: #333;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    background: #fff;
    cursor: pointer;
    gap: 0.2rem;
}

.btn-sm:hover {
    background: #f1f3f5;
}

.btn-sm.danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-sm.danger:hover {
    background: rgba(220, 53, 69, 0.1);
}

.btn-sm.insert {
    color: var(--success-color);
    border-color: var(--success-color);
    font-weight: 700;
}

.btn-sm.insert:hover {
    background: rgba(25, 135, 84, 0.1);
}

.btn-sm.insert-int {
    color: var(--muted-color);
    border-color: var(--muted-color);
    font-size: 0.65rem;
    font-weight: 700;
}

.btn-sm.insert-int:hover {
    background: rgba(108, 117, 125, 0.1);
}

/* === Info Icon (tooltip) === */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    font-size: 0.65rem;
    font-style: normal;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: 1.5px solid #9ca3af;
    border-radius: 50%;
    cursor: help;
    margin-left: 0.35rem;
    vertical-align: middle;
    position: relative;
    transition: color 0.15s, border-color 0.15s;
}
.info-icon:hover {
    color: #2563eb;
    border-color: #2563eb;
}


/* === Color Combo (hex + swatch + picker) === */
.color-combo {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.3rem;
}
.color-combo .color-swatch {
    display: inline-block;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 3px;
    border: 1.5px solid #ccc;
    cursor: pointer;
    flex-shrink: 0;
    vertical-align: middle;
}
.color-combo .color-swatch:hover { border-color: #888; }
.color-combo .col-color-hex {
    width: 5.5rem !important;
    max-width: 5.5rem !important;
    font-family: monospace !important;
    font-size: 0.8rem !important;
    padding: 0.15rem 0.3rem !important;
    margin: 0 !important;
    height: 1.6rem !important;
    text-transform: uppercase;
}
.color-combo .col-color-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* === Status Badges === */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.success {
    background: #d1e7dd;
    color: #0f5132;
}

.status-badge.running {
    background: #cfe2ff;
    color: #084298;
}

.status-badge.pending {
    background: #e2e3e5;
    color: #41464b;
}

.status-badge.needs-validation {
    background: var(--warning-color, #e6a817);
    color: #fff;
}

.status-badge.error {
    background: #f8d7da;
    color: #842029;
}

/* === History alert icons === */
#history-table td:nth-child(6) {
    white-space: nowrap;
}
.history-alert {
    cursor: help;
    font-size: 0.9rem;
    vertical-align: middle;
    margin-left: 0.35rem;
}
.history-alert-error {
    color: #dc3545;
}
.history-alert-warning {
    color: #e6a817;
}

/* === Download Button === */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-download:hover {
    opacity: 0.9;
}

.btn-sharepoint {
    background: #0078d4;
}

.btn-sharepoint-done {
    background: #107c10;
}

/* === Warnings === */
.warnings {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    list-style: none;
}

.warnings li {
    padding: 0.15rem 0;
    color: #856404;
    font-size: 0.85rem;
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay[hidden] {
    display: none;
}

/* === Compact layout overrides (PicoCSS) === */
main.container h2 {
    margin-bottom: 0.75rem;
}

main.container h3 {
    margin-bottom: 0.5rem;
}

main.container p {
    margin-bottom: 0.5rem;
}

main.container table {
    margin-bottom: 0.5rem;
}

main.container table th,
main.container table td {
    padding: 0.35rem 0.5rem;
}

/* === Mapping Editor === */
.mapping-editor {
    overflow-x: auto;
}

.mapping-editor table {
    font-size: 0.85rem;
    min-width: 700px;
}

.mapping-editor input,
.mapping-editor select,
.mapping-editor textarea {
    font-size: 0.85rem;
    padding: 0.15rem 0.4rem;
    margin-bottom: 0;
    height: auto;
    line-height: 1.3;
}

.mapping-editor td {
    overflow: hidden;
}

.mapping-editor td input,
.mapping-editor td select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Masquer la fleche dropdown des datalist (Chrome/Edge) */
.mapping-editor td input[list]::-webkit-calendar-picker-indicator {
    display: none !important;
}

.mapping-label-cell .label-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    max-height: calc(1.3em * 3);
    word-break: break-word;
}

/* Stats config table: compact inputs */
#stats-config-table input,
#stats-config-table select {
    font-size: 0.85rem;
    padding: 0.15rem 0.4rem;
    margin-bottom: 0;
    height: auto;
    line-height: 1.3;
}

/* Column label textarea: auto-height */
.col-label-textarea {
    width: 100%;
    min-height: 1.6rem;
    resize: vertical;
    overflow: hidden;
    font-family: inherit;
    field-sizing: content;
}

/* === Validation values textarea === */
.validation-values-textarea {
    width: 100%;
    min-height: 2.5rem;
    max-height: 7.5rem;
    resize: vertical;
    font-family: inherit;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    field-sizing: content;
    overflow-y: auto;
}

/* === Color swatch input === */
input[type="color"] {
    width: 3rem;
    height: 1.8rem;
    padding: 0.1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    cursor: pointer;
}

/* === Mapping source indicators === */
.source-indicator {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.3rem;
}

.source-indicator.mapped {
    background: var(--primary-color);
}

.source-indicator.unmapped {
    background: var(--warning-color);
}

.source-indicator.intermediate {
    background: var(--danger-color);
}

/* === Intermediate column rows === */
tr.intermediate-row {
    background: #f8f9fa;
}

tr.intermediate-row td:first-child {
    color: var(--muted-color);
    font-style: italic;
}

/* === Test mapping result column === */
.test-badge {
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    max-width: 14rem;
    white-space: normal;
    word-break: break-word;
    vertical-align: middle;
}
.test-badge-ok    { background: #d4edda; color: #155724; }
.test-badge-empty { background: #e9ecef; color: #6c757d; font-style: italic; }
.test-badge-missing { background: #fff3cd; color: #856404; }

.formula-vars-details {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.3rem;
    position: relative;
}
.formula-vars-details summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: #0d6efd;
    list-style: none;
    padding: 0.1rem 0.3rem;
    border-radius: 50%;
    background: #e7f1ff;
    user-select: none;
}
.formula-vars-details summary::-webkit-details-marker { display: none; }
.formula-vars-table {
    position: fixed;
    z-index: 1000;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.35rem;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    font-size: 0.78rem;
    padding: 0.35rem 0.5rem;
    max-width: 28rem;
    width: max-content;
    white-space: normal;
    word-break: break-word;
}
.formula-vars-table td { padding: 0.1rem 0.5rem; vertical-align: top; }
.formula-vars-table tr td:first-child { font-family: monospace; color: #0d6efd; white-space: nowrap; }
.formula-vars-table tr td:last-child  { color: #333; }

/* === Formula display in mapping === */
.formula-preview {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
    color: #555;
    background: #e9ecef;
    padding: 0.15rem 0.4rem;
    border-radius: 0.15rem;
    max-width: 20rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* === Button for opening formula editor === */
.btn-open-formula {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font-size: 0.7rem;
    color: #333;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    background: #f8f9fa;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 0.2rem;
}

.btn-open-formula:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* === Kizeo forms table === */
#forms-table input,
#forms-table select {
    font-size: 0.8rem;
    padding: 0.15rem 0.35rem;
    margin-bottom: 0;
    height: auto;
}

/* === User info in nav === */
.user-info {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.role-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.role-badge.role-admin {
    background: #0d6efd;
    color: #fff;
}

.role-badge.role-user {
    background: #e9ecef;
    color: #555;
}

.logout-link {
    font-size: 0.8rem;
    color: var(--danger-color) !important;
    text-decoration: underline;
    cursor: pointer;
    margin-left: 0.5rem;
}

.logout-link:hover {
    opacity: 0.8;
}

/* === Progress steps === */
.progress-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
}

.progress-step .step-icon {
    width: 1.2rem;
    text-align: center;
}

.progress-step.done .step-icon {
    color: var(--success-color);
}

.progress-step.running .step-icon {
    color: var(--primary-color);
}

.progress-step.pending .step-icon {
    color: var(--muted-color);
}

/* === Formula Editor Modal === */
.formula-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.formula-modal-overlay[hidden] {
    display: none;
}

.formula-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.formula-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.formula-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-color);
    border-radius: 0.3rem;
}

.formula-modal-close:hover {
    background: #e9ecef;
    color: var(--danger-color);
}

.formula-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.formula-modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.formula-modal-footer button {
    padding: 0.4rem 1.2rem;
    font-size: 0.9rem;
}

.formula-expr-input {
    width: 100%;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 0.4rem;
    resize: vertical;
    min-height: 3rem;
    margin-bottom: 0.5rem;
}

.formula-expr-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.formula-validation {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.3rem;
    margin-bottom: 0.5rem;
}

.formula-valid {
    color: #0f5132;
    background: #d1e7dd;
}

.formula-invalid {
    color: #842029;
    background: #f8d7da;
}

.formula-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.formula-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border: 1px solid #dee2e6;
    border-radius: 0.3rem;
    background: #f8f9fa;
    cursor: pointer;
    color: #333;
}

.formula-toolbar-btn:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.formula-sub-panel {
    border: 1px solid #dee2e6;
    border-radius: 0.4rem;
    margin-bottom: 0.5rem;
    background: #fafbfc;
    max-height: 12rem;
    overflow-y: auto;
}

.formula-sub-panel[hidden] {
    display: none;
}

.formula-sub-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: #f0f1f3;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.8rem;
}

.formula-fn-list {
    padding: 0.25rem;
}

.formula-fn-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.2rem;
    font-size: 0.78rem;
}

.formula-fn-row:hover {
    background: #e9ecef;
}

.formula-fn-name {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 5rem;
}

.formula-fn-syntax {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.72rem;
    color: #555;
    background: #e9ecef;
    padding: 0.1rem 0.3rem;
    border-radius: 0.15rem;
    min-width: 10rem;
}

.formula-fn-desc {
    color: var(--muted-color);
    flex: 1;
    font-size: 0.72rem;
}

.formula-fn-insert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    font-size: 0.75rem;
    font-weight: bold;
    border: 1px solid var(--primary-color);
    border-radius: 0.2rem;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.formula-fn-insert:hover {
    background: var(--primary-color);
    color: #fff;
}

.formula-mapping-list {
    padding: 0.25rem;
}

.formula-mapping-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.4rem;
    border-radius: 0.2rem;
    font-size: 0.8rem;
}

.formula-mapping-row:hover {
    background: #e9ecef;
}

.formula-help p {
    margin: 0.2rem 0;
}

.formula-help code {
    font-size: 0.75rem;
    background: #e9ecef;
    padding: 0.1rem 0.3rem;
    border-radius: 0.15rem;
}

/* === Generic Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.modal-header h4 {
    margin: 0;
    font-size: 1rem;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-color);
    border-radius: 0.3rem;
}

.modal-close:hover {
    background: #e9ecef;
    color: var(--danger-color);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    margin: 0;
    font-size: 0.95rem;
}

.modal-form-group {
    margin-bottom: 0.75rem;
}

.modal-form-group:last-child {
    margin-bottom: 0;
}

.modal-form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.modal-form-group input,
.modal-form-group select {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0;
}

.modal-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-checkbox-row input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* === Sections repliables (Format de sortie) === */
.collapsible-section .section-toggle {
    cursor: pointer; user-select: none; margin: 0 0 0.5rem 0;
    display: flex; align-items: center; gap: 0.45rem; font-size: 1.05rem; font-weight: 600;
}
.collapsible-section .section-toggle:hover { color: var(--primary-color); }
.collapsible-section .chevron {
    display: inline-block; font-size: 0.7em; transition: transform 0.2s ease; flex-shrink: 0;
}
.collapsible-section.collapsed .chevron { transform: rotate(-90deg); }
.collapsible-section.collapsed .section-content { display: none; }
.collapsible-section.collapsed .section-toggle { margin-bottom: 0; }

/* === Table compacte (Format de sortie — façon Mapping syntheses) === */
.fs-compact { font-size: 0.78rem; }
.fs-compact th, .fs-compact td { padding: 0.2rem 0.35rem; vertical-align: middle; }
.fs-compact textarea, .fs-compact select, .fs-compact input[type="text"] {
    font-size: 0.78rem; padding: 0.15rem 0.3rem; margin: 0; min-height: 0; line-height: 1.3;
}
.fs-compact textarea { resize: vertical; }
.fs-compact tr.row-inter { background: #f0f0f0; }
.fs-compact .btn-sm { padding: 0.1rem 0.35rem; font-size: 0.7rem; }
.fs-compact .color-combo .color-swatch { width: 1.3rem; height: 1.3rem; }
.fs-numero-cell { display: inline-flex; align-items: center; gap: 0.25rem; vertical-align: middle; line-height: 1; }
.fs-compact .fs-numero-input {
    width: 3rem !important; height: 1.7rem !important; box-sizing: border-box !important;
    padding: 0 0.2rem !important; margin: 0 !important; line-height: 1.7rem !important;
    text-align: center; text-transform: uppercase; vertical-align: middle;
}
.fs-numero-input:disabled { background: #f1f3f5; color: #555; }
.fs-numero-input.invalid { border-color: var(--danger-color); background: #fff0f0; }
.fs-lock-btn {
    border: 1px solid #ccc; border-radius: 0.25rem; background: #fff; cursor: pointer;
    width: 1.7rem; height: 1.7rem; box-sizing: border-box; line-height: 1; padding: 0; margin: 0;
    font-size: 0.8rem; flex-shrink: 0; vertical-align: middle;
}
.fs-lock-btn.locked { background: #eef4fb; border-color: var(--primary-color); }
.fs-lock-btn:hover { background: #f1f3f5; }

/* === Bouton Enregistrer flottant (éditeurs format entrée/sortie) === */
.btn-save-floating {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: opacity 0.2s, transform 0.2s;
}
.btn-save-floating:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-save-floating[hidden] { display: none; }

/* Champs multi-lignes dans les modales : police plus petite */
.modal-body textarea,
.modal-form-group textarea {
    width: 100%;
    font-size: 0.8rem;
    line-height: 1.4;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0;
}

/* === Éditeur de texte riche (Caractéristiques de l'opération) === */
.rte-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.rte-toolbar button {
    min-width: 1.9rem;
    height: 1.7rem;
    padding: 0 0.45rem;
    font-size: 0.8rem;
    line-height: 1;
    border: 1px solid #ccc;
    border-radius: 0.25rem;
    background: #fff;
    cursor: pointer;
    color: #333;
}

.rte-toolbar button:hover {
    background: #f1f3f5;
}

.rte-toolbar input[type="color"] {
    width: 1.9rem;
    height: 1.7rem;
    padding: 0;
    margin: 0;
    border: 1px solid #ccc;
    border-radius: 0.25rem;
    cursor: pointer;
    background: #fff;
    vertical-align: middle;
    align-self: center;
}

.rte-editor {
    border: 1px solid #ccc;
    border-radius: 0.25rem;
    min-height: 70px;
    max-height: 180px;
    overflow-y: auto;
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
    line-height: 1.4;
    background: #fff;
    color: #000;
}

.rte-editor:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -1px;
}

.rte-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--muted-color);
}

.modal-checkbox-row label {
    display: inline;
    font-weight: normal;
    margin-bottom: 0;
}

.field-error {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.45) !important;
    background-color: #fff5f5 !important;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.modal-footer button {
    padding: 0.4rem 1.2rem;
    font-size: 0.9rem;
}

/* === Collapsible Sections === */
.collapsible-section .section-toggle {
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
}

.collapsible-section .section-toggle:hover {
    color: var(--primary-color);
}

.collapsible-section .chevron {
    display: inline-block;
    font-size: 0.7em;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

.collapsible-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.collapsible-section.collapsed .section-content {
    display: none;
}

.collapsible-section:not(.collapsed) .section-toggle {
    margin-bottom: 0.5rem;
}

/* === Floating Save Button === */
.btn-save-floating {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: opacity 0.2s, transform 0.2s;
}

.btn-save-floating:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-save-floating[hidden] {
    display: none;
}

/* === Inline progress in history === */
.inline-progress {
    margin-top: 0.25rem;
}

.mini-progress {
    width: 100%;
    height: 0.35rem;
    border-radius: 0.2rem;
    appearance: none;
    -webkit-appearance: none;
}

.mini-progress::-webkit-progress-bar {
    background: #e9ecef;
    border-radius: 0.2rem;
}

.mini-progress::-webkit-progress-value {
    background: #3b82f6;
    border-radius: 0.2rem;
    transition: width 0.3s;
}

.mini-progress::-moz-progress-bar {
    background: #3b82f6;
    border-radius: 0.2rem;
}

.mini-step {
    display: block;
    font-size: 0.68rem;
    color: #6c757d;
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Icon buttons in actions === */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.35rem;
    line-height: 1;
    border: 1px solid #dee2e6;
    background: #fff;
    cursor: pointer;
    border-radius: 0.25rem;
    text-decoration: none;
    color: inherit;
    margin-right: 0.2rem;
}

.btn-icon:hover {
    background: #f8f9fa;
}

.btn-icon svg {
    vertical-align: middle;
}

.btn-cancel {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-cancel:hover {
    background: rgba(220, 53, 69, 0.1);
}

.btn-sp {
    color: #0078d4;
    border-color: #0078d4;
}

.btn-sp:hover {
    background: rgba(0, 120, 212, 0.1);
}

.btn-sp-done {
    color: #198754;
    border-color: #198754;
    cursor: default;
    font-weight: bold;
}

/* === Cancelled status badge === */
.status-badge.cancelled {
    background: #e2e3e5;
    color: #6c757d;
}

/* === Responsive === */
@media (max-width: 768px) {
    #nav-links {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .actions {
        flex-direction: column;
    }

    .mapping-editor table {
        min-width: unset;
    }
}

.app-version {
    font-size: 0.65em;
    opacity: 0.45;
    font-weight: normal;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

/* === Surlignage des lignes verrouillees (jobs KPI) === */
/* Cible les td pour surcharger le striping de Pico CSS */
tr.row-locked > td {
    background-color: #e6f4ea !important;
}

/* === Éditeur de formules (modale, porté de syntheses-pncee) === */
.formula-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.formula-modal-overlay[hidden] {
    display: none;
}

.formula-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.formula-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.formula-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-color);
    border-radius: 0.3rem;
}

.formula-modal-close:hover {
    background: #e9ecef;
    color: var(--danger-color);
}

.formula-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.formula-modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.formula-modal-footer button {
    padding: 0.4rem 1.2rem;
    font-size: 0.9rem;
}

.formula-expr-input {
    width: 100%;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 0.4rem;
    resize: vertical;
    min-height: 3rem;
    margin-bottom: 0.5rem;
}

.formula-expr-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.formula-validation {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.3rem;
    margin-bottom: 0.5rem;
}

.formula-valid {
    color: #0f5132;
    background: #d1e7dd;
}

.formula-invalid {
    color: #842029;
    background: #f8d7da;
}

.formula-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.formula-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border: 1px solid #dee2e6;
    border-radius: 0.3rem;
    background: #f8f9fa;
    cursor: pointer;
    color: #333;
}

.formula-toolbar-btn:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.formula-sub-panel {
    border: 1px solid #dee2e6;
    border-radius: 0.4rem;
    margin-bottom: 0.5rem;
    background: #fafbfc;
    max-height: 12rem;
    overflow-y: auto;
}

.formula-sub-panel[hidden] {
    display: none;
}

.formula-sub-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: #f0f1f3;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.8rem;
}

.formula-fn-list {
    padding: 0.25rem;
}

.formula-fn-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.2rem;
    font-size: 0.78rem;
}

.formula-fn-row:hover {
    background: #e9ecef;
}

.formula-fn-name {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 5rem;
}

.formula-fn-syntax {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.72rem;
    color: #555;
    background: #e9ecef;
    padding: 0.1rem 0.3rem;
    border-radius: 0.15rem;
    min-width: 10rem;
}

.formula-fn-desc {
    color: var(--muted-color);
    flex: 1;
    font-size: 0.72rem;
}

.formula-fn-insert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    font-size: 0.75rem;
    font-weight: bold;
    border: 1px solid var(--primary-color);
    border-radius: 0.2rem;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.formula-fn-insert:hover {
    background: var(--primary-color);
    color: #fff;
}

.formula-mapping-list {
    padding: 0.25rem;
}

.formula-mapping-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.4rem;
    border-radius: 0.2rem;
    font-size: 0.8rem;
}

.formula-mapping-row:hover {
    background: #e9ecef;
}

.formula-help p {
    margin: 0.2rem 0;
}

.formula-help code {
    font-size: 0.75rem;
    background: #e9ecef;
    padding: 0.1rem 0.3rem;
    border-radius: 0.15rem;
}


/* ---- P5 — Page Intégrer un lot ---- */
.integ-dropzone {
    border: 2px dashed #6c8aae;
    border-radius: 0.5rem;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: background 0.15s, border-color 0.15s;
}
.integ-dropzone:hover,
.integ-dropzone:focus,
.integ-dz-active {
    border-color: #0d6efd;
    background: #e7f1ff;
}
.integ-dropzone .integ-dz-icon {
    font-size: 2.2em;
    color: #0d6efd;
    line-height: 1;
    margin-bottom: 0.5rem;
}
.integ-dropzone .integ-dz-main {
    font-size: 1.15em;
    color: #1c2733;
    margin: 0 0 0.35rem 0;
}
.integ-dropzone .integ-dz-main strong {
    color: #0d6efd;
    font-weight: 700;
}
.integ-dropzone .integ-dz-sub {
    color: #5a6b7d;
    margin: 0;
    font-size: 0.95em;
}

/* L'helper sous le champ "Référence lot client" doit etre en block sous l'input. */
#integ-step2 .modal-form-group small {
    display: block;
    margin-top: 0.35rem;
    line-height: 1.4;
}

/* ---- P5.D — Modale d'intégration ---- */
.integ-modal { max-width: 1100px; width: 95vw; }
.integ-modal-body { max-height: 75vh; overflow-y: auto; }
.integ-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.integ-block {
    background: #f8fafc;
    border: 1px solid #e3e8ef;
    border-radius: 0.4rem;
    padding: 0.75rem 1rem;
}
.integ-block h5 { margin: 0 0 0.5rem 0; }
.integ-block-full { grid-column: 1 / -1; }
.integ-block-taux { background: #e7f3fb; border-color: #b6d7e8; }
.integ-row {
    display: flex; align-items: center; gap: 0.5rem;
    margin: 0.25rem 0;
    flex-wrap: wrap;
}
.integ-row label { margin: 0; }
.integ-modes { margin-top: 0.5rem; font-size: 0.9em; color: #555; }
.integ-modes > div { margin: 0.15rem 0; }
.integ-zen-row {
    display: flex; align-items: center; gap: 1.5rem;
    margin-bottom: 0.5rem;
}
.integ-zen-row label { margin: 0; cursor: pointer; }
.integ-delai-info { margin-left: auto; color: #555; }
.integ-dates-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.integ-dates-row > div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 3em;  /* hauteur commune pour alignement vertical */
}
.integ-dates-row > div small {
    color: var(--muted-color);
    font-size: 0.78em;
    line-height: 1.1;
}
.integ-dates-row > div strong { font-size: 1em; line-height: 1.1; }
/* Les 3 cellules "valeur" ont la meme hauteur ET le contenu est aligne au top
   pour que le strong tombe au meme niveau sur les 3 colonnes. */
.integ-dates-row > div > strong {
    display: inline-flex;
    align-items: center;
    height: 24px;
    line-height: 1.4;
}

/* Container des flèches au milieu (entre Zen/Premium et le délai). */
.integ-arrows-container {
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
}
.integ-arrows-lr {
    display: flex !important;
    flex-direction: row !important;
    flex: 0 0 auto !important;
    gap: 0 !important;
    width: auto !important;
}
.integ-arrows-lr button {
    flex: 0 0 auto !important;
    width: 68px !important;
    height: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    font-size: 1.5em !important;
    font-weight: 700 !important;
    border: 1px solid #0d6efd !important;
    background: #fff !important;
    color: #0d6efd !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}
.integ-arrows-lr button:first-child { border-radius: 0.25rem 0 0 0.25rem; }
.integ-arrows-lr button:last-child { border-radius: 0 0.25rem 0.25rem 0; border-left: 0; }
.integ-arrows-lr button:hover { background: #0d6efd; color: #fff; }
.integ-arrows-lr button:active { background: #0a58ca; }
.integ-delai-info {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    white-space: nowrap;
}
.integ-delai-text { white-space: nowrap; }
.integ-eng-info {
    background: #cce7f5; padding: 0.4rem 0.6rem;
    border-radius: 0.3rem; margin-bottom: 0.5rem;
    font-size: 0.9em;
}

/* ---- P5.D — Modale d'intégration (v2 : compacte, flèches stack, split taux) ---- */
.integ-modal-body { font-size: 0.9rem; }
.integ-modal-body label { font-size: 0.85em; }
.integ-modal-body .modal-form-group { margin: 0.3rem 0; }
.integ-modal-body .modal-form-group > label { display:block; margin-bottom: 0.15rem; font-weight: 600; }
.integ-modal-body input[type="text"],
.integ-modal-body input[type="number"],
.integ-modal-body select,
.integ-modal-body textarea {
    padding: 0.25rem 0.4rem;
    font-size: 0.85em;
    margin: 0;
    height: auto;
    line-height: 1.4;
    min-height: 0;
}
.integ-modal-body textarea { line-height: 1.3; resize: vertical; min-height: 1.8em; }
/* Texte d'aide sous les champs : forcer en block avec marge, sinon picocss l'affiche
   en inline et il "deborde" sous l'input/textarea (bug visuel). */
.integ-modal-body .modal-form-group small {
    display: block;
    margin-top: 0.3rem;
    line-height: 1.3;
    color: var(--muted-color);
}
.integ-modal-grid { gap: 0.6rem; }
.integ-block { padding: 0.5rem 0.7rem; }
.integ-row { margin: 0.15rem 0; }

/* Bloc taux : 2 colonnes (saisie | info réglementaire) */
.integ-taux-split {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 0.8rem;
    align-items: stretch;
}
.integ-info-pane {
    background: #fff;
    border: 1px solid #b6d7e8;
    border-radius: 0.3rem;
    padding: 0.5rem 0.7rem;
    height: 100%;
    font-size: 0.85em;
}
.integ-info-title {
    font-weight: 700;
    color: #0c4a6e;
    border-bottom: 1px solid #d0e6f2;
    padding-bottom: 0.25rem;
    margin-bottom: 0.4rem;
}
.integ-info-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.15rem 0;
}
.integ-info-row > span { color: var(--muted-color); }

/* ---- P6.B — Tableur d'édition ---- */
.tableur-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tableur-actions { display: flex; gap: 0.5rem; }
.tableur-bandeau {
    background: #e7f3fb;
    border: 1px solid #b6d7e8;
    border-radius: 0.3rem;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.7rem;
}
.tableur-bandeau-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.85em;
}
.tableur-bandeau-row > div { display: flex; flex-direction: column; }
.tableur-bandeau-row small { color: var(--muted-color); font-size: 0.85em; }
.tableur-bandeau-row strong { font-size: 1em; }

.tab-wrap {
    max-height: 65vh;
    overflow: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.3rem;
    position: relative;
}
.tab-grid {
    border-collapse: collapse;
    font-size: 0.8em;
    margin: 0;
    width: max-content;
}
.tab-grid thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    border-bottom: 2px solid #cbd5e1;
    z-index: 2;
    padding: 0.15rem 0.4rem;
    text-align: left;
    vertical-align: middle;
    min-width: 110px;
    max-width: 180px;
    height: 26px;
}
.tab-grid thead th.tab-row-num {
    background: #e2e8f0;
    z-index: 3;
    left: 0;
    text-align: center;
    min-width: 130px;
    max-width: 130px;
}
.tab-grid tbody th.tab-row-num {
    position: sticky;
    left: 0;
    background: #f8fafc;
    border-right: 2px solid #cbd5e1;
    z-index: 1;
    font-weight: normal;
    color: var(--muted-color);
    min-width: 130px;
    max-width: 130px;
    padding: 0.25rem 0.4rem;
    /* Flex pour aligner verticalement le numéro et les boutons sur une seule ligne,
       sans débordement de la cellule. */
}
.tab-grid tbody th.tab-row-num .tab-row-num-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    width: 100%;
}
.tab-grid tbody th.tab-row-num .tab-row-num-label {
    min-width: 1.3rem;
    text-align: right;
    flex-shrink: 0;
}
.tab-grid tbody th.tab-row-num .tab-dup-actions {
    display: inline-flex;
    gap: 0.2rem;
    margin-left: 0;
}
.tab-grid tbody th.tab-row-num .tab-grp-btn {
    margin-left: 0;
}
.tab-th-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.1;
}
.tab-lib {
    font-size: 0.85em;
    color: #333;
    font-weight: 600;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tab-edit-btn {
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #0d6efd;
    color: #0d6efd;
    border-radius: 0.15rem;
    padding: 0 0.3rem;
    font-size: 0.85em;
    cursor: pointer;
    line-height: 1.4;
}
.tab-edit-btn:hover { background: #0d6efd; color: #fff; }
.tab-grid td {
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid #eef2f7;
    border-right: 1px solid #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.tab-grid tr:hover td { background: #fafbfc; }
.tab-grid th.tab-interm,
.tab-grid td.tab-interm {
    background: #f4f5f7;
    color: #6b7280;
    font-style: italic;
}
.tab-grid th.tab-editing,
.tab-grid td.tab-editing {
    background: #fff4cd !important;
}
.tab-grid input {
    padding: 0.1rem 0.25rem;
    font-size: 1em;
    border: 1px solid #cbd5e1;
    border-radius: 0.15rem;
    width: 100%;
    background: #fff;
}

/* ---- Barre de progression (génération de lot) ---- */
.progress-track {
    background: #e9ecef;
    border-radius: 0.25rem;
    height: 14px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd 0%, #0a58ca 100%);
    transition: width 0.3s ease;
    border-radius: 0.25rem;
}

/* ---- Mail modal compact + rich text editor ---- */
.mail-modal .modal-form-group { margin: 0.3rem 0; }
.mail-modal .modal-form-group > label { display:block; margin-bottom: 0.15rem; font-weight: 600; font-size: 0.85em; }
.mail-modal input[type="text"] {
    padding: 0.3rem 0.5rem;
    font-size: 0.9em;
    width: 100%;
    margin: 0;
    height: auto;
    min-height: 0;
    line-height: 1.4;
}
.mail-meta {
    background: #f8fafc;
    border: 1px solid #e3e8ef;
    border-radius: 0.3rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.85em;
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}
.mail-meta .mail-lbl {
    color: var(--muted-color);
    font-weight: 600;
    margin-right: 0.25rem;
}
.mail-tos-row {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}
.rt-toolbar {
    border: 1px solid #cbd5e1;
    border-bottom: 0;
    border-radius: 0.25rem 0.25rem 0 0;
    background: #f8fafc;
    padding: 0.2rem 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.15rem;
}
.rt-toolbar button {
    background: #fff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.2rem;
    padding: 0.15rem 0.55rem !important;
    font-size: 0.95em !important;
    font-weight: 600;
    color: #1c2733 !important;
    cursor: pointer;
    min-width: 28px;
    line-height: 1.3 !important;
    height: auto !important;
    margin: 0 !important;
}
.rt-toolbar button:hover {
    background: #0d6efd !important;
    border-color: #0d6efd !important;
    color: #fff !important;
}
.rt-toolbar button b, .rt-toolbar button i, .rt-toolbar button u { color: inherit; }
.rt-sep { width: 1px; height: 22px; background: #cbd5e1; margin: 0 0.25rem; display: inline-block; }
.rt-editor {
    border: 1px solid #cbd5e1;
    border-radius: 0 0 0.25rem 0.25rem;
    padding: 0.4rem 0.6rem;
    min-height: 130px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.9em;
    line-height: 1.4;
    background: #fff;
    outline: none;
}
.rt-editor:focus { border-color: #0d6efd; }

/* ===========================================================================
 * Override Pico CSS : restaurer les checkbox / radio NATIFS partout.
 * Pico v2 stylise input[type=checkbox] avec appearance:none et une apparence
 * custom (switch-like) qui a des bugs visuels (l'etat coche reste affiche
 * apres un decochage). On force le rendu natif du navigateur.
 * =========================================================================== */
input[type="checkbox"],
input[type="radio"] {
    appearance: auto !important;
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
    width: auto !important;
    height: auto !important;
    background: initial !important;
    background-image: none !important;
    background-color: initial !important;
    border: initial !important;
    border-radius: 0 !important;
    margin: 0 0.35em 0 0 !important;
    padding: 0 !important;
    vertical-align: middle !important;
    box-shadow: none !important;
    transition: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    line-height: normal !important;
    display: inline-block !important;
    cursor: pointer;
}
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background: initial !important;
    background-image: none !important;
    background-color: initial !important;
}

/* ---- Sub-tabs (utilises dans Tbase) ---- */
.sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #cbd5e1;
    margin-bottom: 0.8rem;
}
.sub-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 0;
    padding: 0.4rem 1rem;
    font-size: 0.95em;
    cursor: pointer;
    color: #5a6b7d;
    border-radius: 0.3rem 0.3rem 0 0;
    margin-bottom: -1px;
}
.sub-tab:hover { background: #f1f5f9; color: #1c2733; }
.sub-tab.active {
    background: #fff;
    border-color: #cbd5e1;
    border-bottom-color: #fff;
    color: #0d6efd;
    font-weight: 600;
}

/* ---- Tableur : lignes en violation de condition ---- */
.tab-grid tr.tab-row-warning td { background: #fff7e0 !important; }
.tab-grid tr.tab-row-warning th.tab-row-num { background: #ffec99 !important; }
.tab-grid tr.tab-row-blocking td { background: #fbe2e2 !important; }
.tab-grid tr.tab-row-blocking th.tab-row-num { background: #f5b5b5 !important; }

/* ---- Tableur : doublons potentiels (violet) ---- */
.tab-grid tr.tab-row-duplicate td { background: #f5edff !important; }
.tab-grid tr.tab-row-duplicate th.tab-row-num { background: #e0ccff !important; }
/* Si la ligne cumule duplicate + warning/blocking, on garde le warning/blocking
   prioritaire pour les td (sécurité avant doublon), mais on conserve un liseré
   violet à gauche pour signaler la double info. */
.tab-grid tr.tab-row-duplicate th.tab-row-num {
    border-left: 4px solid #7c3aed !important;
}
.tab-dup-actions {
    display: inline-flex;
    gap: 0.15rem;
    margin-left: 0.3rem;
    vertical-align: middle;
}
.tab-dup-trash, .tab-dup-info {
    background: #fff;
    border: 1px solid #7c3aed;
    color: #7c3aed;
    border-radius: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1;
    padding: 0;
    font-size: 0.85em;
    cursor: pointer;
}
.tab-dup-trash:hover { background: #7c3aed; color: #fff; }
.tab-dup-info:hover  { background: #ede0ff; color: #5a1ed1; }

/* Bouton de regroupement (fiche RES-EC-104 uniquement) */
.tab-grp-btn {
    background: #fff;
    border: 1px solid #0d6efd;
    color: #0d6efd;
    border-radius: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1;
    padding: 0;
    font-size: 0.85em;
    cursor: pointer;
    margin-left: 0.3rem;
    vertical-align: middle;
}
.tab-grp-btn:hover { background: #0d6efd; color: #fff; }

#tableur-btn-valider:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Combobox client (modale d'intégration) — input + dropdown filtré */
.im-client-combo {
    position: relative;
    width: 100%;
}
.im-client-combo input[type="text"] {
    width: 100%;
}
.im-client-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    margin: 2px 0 0 0;
    padding: 0;
    list-style: none;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0.3rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.im-client-list .im-cli-item {
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.92em;
    border-bottom: 1px solid #f0f0f0;
}
.im-client-list .im-cli-item:last-child { border-bottom: none; }
.im-client-list .im-cli-item:hover,
.im-client-list .im-cli-item.active {
    background: #e7f1ff;
}
.im-client-list .im-cli-item.selected {
    font-weight: 600;
}
.im-client-list .im-cli-trig {
    color: #777;
    font-size: 0.88em;
}
@keyframes spin { to { transform: rotate(360deg); } }
.im-client-list .im-cli-empty {
    padding: 0.4rem 0.6rem;
    color: var(--muted-color);
    font-style: italic;
    font-size: 0.9em;
}

/* Dropzone bloquee quand le dossier par defaut n'est pas configure */
.integ-dropzone.integ-dz-locked {
    background: #fff5f5;
    border-color: #e0a0a0;
    cursor: not-allowed;
}
.integ-dropzone.integ-dz-locked:hover { background: #fff5f5; border-color: #e0a0a0; }
