/* public/css/app.css */

:root {
    --color-primary: #007bff;
    --color-secondary: #6c757d;
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning: #ffc107;
    --color-info: #17a2b8;
    --color-light: #f8f9fa;
    --color-dark: #343a40;

    --sidebar-width: 220px;
    --table-row-height: 34px;
    --sticky-header-height: 38px;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --border-radius: 4px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    background-color: white;
    border-right: 1px solid #dee2e6;
    padding: 20px 0;
    transition: transform 0.25s ease;
}

.sidebar h2 {
    margin: 0 20px 20px;
    font-size: 18px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin: 5px 0;
}

.sidebar a {
    display: block;
    padding: 10px 20px;
    color: #495057;
    text-decoration: none;
}

.sidebar a:hover,
.sidebar a.active {
    background-color: var(--color-light);
    color: var(--color-primary);
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left 0.25s ease;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
}

tr:hover {
    background-color: #f8f9fa;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}
/* ===== Sidebar — Sections & Accordéons ===== */

.sidebar-section {
    margin-bottom: 12px;
    padding: 0 0 6px;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section-title {
    display: block;
    padding: 6px 12px;
    margin: 0 10px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-dark);
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: var(--border-radius);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-bank-group {
    margin-bottom: 4px;
}

.sidebar-bank-name {
    padding: 4px 20px 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-dark);
}

.sidebar-empty-state {
    display: block;
    padding: 6px 20px 6px 28px;
    font-size: 12px;
    font-style: italic;
    color: var(--color-secondary);
}

.sidebar-account-link,
.sidebar-link {
    display: block;
    padding: 6px 20px 6px 28px;
    color: #495057;
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-account-link:hover,
.sidebar-account-link.active,
.sidebar-link:hover,
.sidebar-link.active {
    background-color: var(--color-light);
    color: var(--color-primary);
}

/* ===== Accordéons sidebar ===== */

.sidebar-section--accordion {
    padding-bottom: 0;
}

.sidebar-accordion__toggle {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.sidebar-accordion__toggle:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--color-primary);
}

.sidebar-accordion__toggle::-webkit-details-marker {
    display: none;
}

.sidebar-accordion__toggle::marker {
    display: none;
}

.sidebar-accordion__toggle::after {
    content: '▸';
    font-size: 10px;
    color: var(--color-secondary);
    transition: transform 0.15s ease;
    display: inline-block;
}

.sidebar-accordion[open] > .sidebar-accordion__toggle::after {
    transform: rotate(90deg);
}

/* ===== Flash messages ===== */

.flash-message {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ===== Boutons — variantes ===== */

.btn-secondary {
    background-color: var(--color-secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background-color: #bd2130;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-icon-fav {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 4px;
    transition: transform 0.1s;
}
.btn-icon-fav:hover {
    transform: scale(1.25);
}

.btn-outline {
    background: none;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    display: inline-block;
}
.btn-outline:hover {
    background: #f3f4f6;
}

.balance-start-row td {
    background-color: #f8f9fa;
    font-size: 12px;
    font-style: italic;
    color: #555;
    border-bottom: 2px solid #dee2e6;
}
.balance-start-row .col-balance,
.balance-start-row .col-rappro {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    font-style: normal;
    font-weight: 600;
}
.balance-start-row:hover td {
    background-color: #f8f9fa;
}

.btn-copy-date-val {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    font-size: 11px;
    line-height: 1;
    vertical-align: middle;
    background: none;
    border: 1px solid var(--color-border, #ccc);
    border-radius: 3px;
    cursor: pointer;
    color: var(--color-text-muted, #666);
    margin-left: 4px;
}
.btn-copy-date-val:hover {
    background-color: var(--color-primary, #4a90d9);
    border-color: var(--color-primary, #4a90d9);
    color: #fff;
}

/* ===== Card ===== */

.card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 24px;
    margin-top: 20px;
    max-width: 1000px;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 16px;
}

/* ===== Dashboard ===== */

.dashboard-accounts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 640px;
    margin-top: 20px;
}

.dashboard-account-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.dashboard-account-name a {
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    color: var(--color-primary, #4a90d9);
}

.dashboard-account-name a:hover {
    text-decoration: underline;
}

.dashboard-account-balances {
    display: flex;
    gap: 32px;
}

.dashboard-balance {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.dashboard-balance-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-balance-value {
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ===== Page header ===== */

.page-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 16px;
    gap: 8px;
}

.page-header h1 {
    margin: 0;
}

.page-header-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Page Statistiques ===== */
.stats-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.875rem;
}
.stats-table th,
.stats-table td {
    border: 1px solid #e5e7eb;
    padding: 6px 10px;
    white-space: nowrap;
}
.stats-table thead th {
    background: #f3f4f6;
    font-weight: 600;
    text-align: center;
}
.stats-cat-col {
    min-width: 160px;
    text-align: left !important;
}
.stats-month-col {
    min-width: 80px;
}
.stats-cat-name {
    text-align: left;
}
.stats-cat-name a {
    text-decoration: none;
    color: inherit;
}
.stats-cat-name a:hover {
    text-decoration: underline;
}
.stats-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.stats-debit  { color: #dc2626; }
.stats-credit { color: #16a34a; }
.stats-empty  { color: #9ca3af; text-align: center; }

/* Lignes hiérarchiques */
.stats-row-parent td {
    background: #f8f9fa;
    font-weight: 600;
}
.stats-row-parent[data-has-children] {
    cursor: pointer;
}
.stats-row-parent[data-has-children]:hover td {
    background: #f0f2f5;
}
.stats-cat-parent {
    font-weight: 700;
}
.stats-expand-icon {
    display: inline-block;
    width: 1em;
    font-size: 0.7em;
    color: #6b7280;
    user-select: none;
}
.stats-row-child td {
    background: #fff;
}
.stats-cat-child {
    padding-left: 1.5rem !important;
    font-size: 0.9em;
    color: #374151;
}
.stats-child-indent {
    color: #9ca3af;
    margin-right: 4px;
}

/* Bouton histogramme inline */
.stats-chart-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    padding: 1px 3px;
    margin-left: 4px;
    border-radius: 3px;
    opacity: 0.4;
    vertical-align: middle;
    line-height: 1;
    transition: opacity 0.15s, background 0.15s;
}
.stats-chart-btn:hover,
.stats-chart-btn.active {
    opacity: 1;
}
.stats-chart-btn.active {
    background: #e0e7ff;
}

/* Panel histogramme */
#stats-chart-panel {
    /* modif laurent */
    width: 600px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem 1.25rem 1.25rem;
    max-width: 900px;
}

/* Récurrence : badge + bouton Détails */
.recurrence-header-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.recurrence-badge {
    font-size: 0.85em;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 3px 8px;
}

.recurrence-details-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 100;
    min-width: 470px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    padding: 10px 14px;
}

.recurrence-details-loading {
    color: #6b7280;
    font-style: italic;
}

.recurrence-stats-table {
    border-collapse: collapse;
    width: auto;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9em;
}

.recurrence-stats-table th,
.recurrence-stats-table td {
    padding: 4px 12px;
    text-align: right;
    border-bottom: 1px solid #e5e7eb;
}

.recurrence-stats-table thead th {
    font-weight: 600;
    color: #374151;
    text-align: right;
}

.recurrence-stats-table thead th:first-child,
.recurrence-stats-table tbody th {
    text-align: left;
}

.recurrence-stats-table tbody tr:last-child td,
.recurrence-stats-table tbody tr:last-child th {
    border-bottom: none;
}

.recurrence-stats-dates {
    color: #6b7280;
    font-size: 0.85em;
    padding-top: 6px;
    text-align: left !important;
}
/* ===== Table actions ===== */

td.actions {
    white-space: nowrap;
}

td.actions .btn + .btn {
    margin-left: 6px;
}

/* ===== Dialog confirmation ===== */

dialog {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    padding: 24px;
    max-width: 420px;
}

dialog p {
    margin-top: 0;
    line-height: 1.5;
}

dialog form {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

/* ===== Required field marker ===== */

.required {
    color: var(--color-danger);
}

/* ===== Vue mensuelle — Tableau des transactions ===== */

.transactions-table {
    font-size: larger;
    width: 100%;
    border-collapse: collapse;
    overflow: visible; /* Fix Chrome : overflow:hidden bloque position:sticky sur thead */
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.transactions-table tr {
    height: var(--table-row-height);
}

.transactions-table th,
.transactions-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.transactions-table thead tr:first-child th {
    position: sticky;
    top: var(--sticky-header-height);
    background: white;
    z-index: 10;
}

.transactions-table thead tr.balance-start-row td {
    position: sticky;
    top: calc(var(--sticky-header-height) + var(--table-row-height));
    background: white;
    z-index: 9;
}

.transactions-table th a {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.transactions-table th a:hover {
    color: var(--color-primary);
}

.transactions-table .col-id {
    color: #6c757d;
    font-size: 0.8rem;
    white-space: nowrap;
    text-align: center;
    width: 45px;
}

.transactions-table .col-amount {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.transactions-table .col-date {
    white-space: nowrap;
}

.transactions-table .col-commentaire {
    max-width: 250px;
}
.transactions-table .col-commentaire .truncate-text {
    display: block;
    /* max-width: 250px; */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #666;
    font-style: italic;
    cursor: help;
}

.transactions-table .col-reconciled {
    text-align: center;
    width: 50px;
    cursor: pointer;
    user-select: none;
}

@keyframes reconcile-flash {
    0%   { background-color: var(--color-primary); color: white; transform: scale(1.3); }
    100% { background-color: transparent; color: inherit; transform: scale(1); }
}

.reconcile-feedback {
    animation: reconcile-flash 0.4s ease-out;
}

.amount-debit {
    color: var(--color-danger);
}

.amount-credit {
    color: var(--color-success);
}

.transaction-row.is-reconciled {
    background-color: var(--highlight-color, #f0fff4);
}

.libelle-recurrent {
    color: var(--color-primary);
}

.transaction-row.split-group {
    border-left: 4px solid #6b83d4;
}
.transaction-row.split-group:hover {
    border-left-color: #5a70c0;
}

.split-indicator {
    display: inline-block;
    #font-size: 0.85rem;
    color: #6b83d4;
    opacity: 0.7;
    margin-right: 0.3rem;
}

.split-indicator svg {
    display: block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.file-indicator {
    display: inline-block;
    font-size: 1rem;
    color: #444;
    margin-right: 0.3rem;
}

.file-indicator svg {
    display: block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.btn-split {
    padding: 0.15rem 0.4rem;
    font-size: 0.8rem;
}

.split-siblings {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: #f0f4ff;
    border-left: 3px solid #6b83d4;
    border-radius: 4px;
}
.split-siblings h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    color: #3b4fa0;
}
.split-siblings ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.split-siblings li {
    padding: 0.2rem 0;
    font-size: 0.9rem;
}

.alert-info {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    border-radius: 4px;
    color: #1e40af;
}

.split-action-box {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: #f0f4ff;
    border-left: 3px solid #6b83d4;
    border-radius: 4px;
}
.split-action-box p {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #3b4fa0;
}

.transaction-row.keyboard-focus td {
    box-shadow: inset 0 2px 0 #3b82f6, inset 0 -2px 0 #3b82f6;
}
.transaction-row.keyboard-focus td:first-child {
    box-shadow: inset 2px 2px 0 #3b82f6, inset 0 -2px 0 #3b82f6;
}
.transaction-row.keyboard-focus td:last-child {
    box-shadow: inset 0 2px 0 #3b82f6, inset -2px -2px 0 #3b82f6;
}

@keyframes newly-added-fade {
    0%, 35% {
        box-shadow: inset 0 4px 0 var(--color-danger), inset 0 -4px 0 var(--color-danger);
    }
    100% { box-shadow: none; }
}
@keyframes newly-added-fade-first {
    0%, 35% {
        box-shadow: inset 4px 4px 0 var(--color-danger), inset 0 -4px 0 var(--color-danger);
    }
    100% { box-shadow: none; }
}
@keyframes newly-added-fade-last {
    0%, 35% {
        box-shadow: inset 0 4px 0 var(--color-danger), inset -4px -4px 0 var(--color-danger);
    }
    100% { box-shadow: none; }
}

.transaction-row.newly-added td {
    animation: newly-added-fade var(--highlight-duration, 4s) ease-out forwards;
}
.transaction-row.newly-added td:first-child {
    animation: newly-added-fade-first var(--highlight-duration, 4s) ease-out forwards;
}
.transaction-row.newly-added td:last-child {
    animation: newly-added-fade-last var(--highlight-duration, 4s) ease-out forwards;
}

.transactions-table tr.empty-row td {
    text-align: center;
    color: var(--color-secondary);
    font-style: italic;
    padding: 24px;
    height: auto;
}

/* ===== Navigation mois ===== */

.month-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.month-nav-btn {
    min-width: 36px;
    text-align: center;
    font-size: 16px;
    line-height: 1;
}

.month-nav-label {
    font-size: 16px;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

.month-picker-form {
    display: inline-flex;
    align-items: center;
}

.month-picker-input {
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    font-size: 13px;
}

/* ===== Pied de tableau ===== */

.table-footer td {
    border-top: 2px solid #dee2e6;
    font-weight: 600;
    background-color: #f8f9fa;
    height: auto;
    padding: 8px;
}

.footer-totals-cell {
    text-align: center;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    gap: 6px;
}

.footer-label {
    font-family: var(--font-family);
    color: var(--color-secondary);
    font-size: 12px;
    font-weight: 500;
}

.footer-sep {
    color: #dee2e6;
}

/* ===== Colonne Solde cumulatif ===== */

.col-balance {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    color: #000;
    min-width: 90px;
}

/* ===== Colonne Rappro (rapprochement bancaire) ===== */

.col-rappro {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    min-width: 90px;
}

/* ===== Zone sticky supérieure complète ===== */

#sticky-top-wrapper {
    position: sticky;
    top: 0;
    z-index: 150;
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

/* ===== En-tête sticky ===== */

.sticky-header {
    background: var(--color-bg, #fff);
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid #dee2e6;
    font-size: 13px;
}

.sticky-balance {
    font-size: 15px;
    font-weight: 700;
}

.sticky-sep {
    color: #dee2e6;
}

/* ===== État vide (aucun compte) ===== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-secondary);
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* =========================================
   Import preview — statuts des lignes
   ========================================= */
tr.status-doublon { background-color: #fff3f3; }
tr.status-correspondance { background-color: #fff8e1; }
tr.status-nouveau { background-color: #f0fff4; }
.status-doublon td:last-child { color: #c0392b; font-weight: 500; }
.status-correspondance td:last-child { color: #e67e22; font-weight: 500; }
.status-nouveau td:last-child { color: #27ae60; font-weight: 500; }
.status-hint { display: block; font-size: 0.8em; font-style: italic; color: #666; }

.preview-headline { margin-bottom: 12px; }
.badge-nouveau { color: #27ae60; font-weight: 600; }
.badge-doublon { color: #c0392b; font-weight: 600; }
.badge-correspondance { color: #e67e22; font-weight: 600; }

.preview-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.95em;
}

.preview-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.preview-table th, .preview-table td { padding: 6px 10px; border: 1px solid #dee2e6; }
.preview-table thead th { background: #f1f3f5; font-weight: 600; }
.preview-table td.amount { text-align: right; font-variant-numeric: tabular-nums; }
.preview-table td.debit { color: #c0392b; }
.preview-table td.credit { color: #27ae60; }

.table-responsive { overflow-x: auto; margin-bottom: 16px; }

/* ===== Settings Layout (2 columns) ===== */
.settings-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

.settings-list-col {
    /* La colonne de gauche prendra le reste de l'espace */
}

.settings-form-col {
    /* Formulaire en sidebar droite fixe */
    position: sticky;
    top: 24px;
}

/* ===== Formulaire transaction — mise en page grille ===== */

.form-transaction {
    max-width: 900px;
}

.form-scope {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 16px 0 8px;
    font-size: 14px;
}

.form-scope-label {
    font-weight: 600;
    color: var(--color-secondary);
}

.form-scope label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
}

.danger-separator {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 24px 0 16px;
    max-width: 900px;
}

.form-actions-delete {
    max-width: 900px;
}

.btn-outline-danger {
    background: none;
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    border-radius: var(--border-radius);
    padding: 6px 14px;
    cursor: pointer;
    font-size: inherit;
}

.btn-outline-danger:hover {
    background-color: var(--color-danger);
    color: white;
}

/* --- Ligne 1 : dates côte à côte --- */
.form-row-dates {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.form-row-dates .form-group {
    flex: 0 0 auto;
}

.form-row-dates input[type="date"] {
    width: 160px;
}

/* --- Ligne 2 : libellé + montant --- */
.form-row-libelle-montant {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 16px;
    align-items: start;
}

/* --- Ligne 3 : Type + Fournisseur + Catégorie --- */
.form-row-selects {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 16px;
    align-items: start;
}

/* --- Ligne 4 : cases à cocher --- */
.form-row-checks {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.form-row-checks .form-group {
    margin-bottom: 0;
}

.form-group-recurrence-mode {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.recurrence-mode-label {
    font-weight: 600;
    white-space: nowrap;
    color: var(--color-text, #333);
}

.form-group-recurrence-mode label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
    white-space: nowrap;
}

.form-group-recurrence-mode input[type="radio"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.input-ope-rec-id {
    width: 80px;
    margin-left: 6px;
    padding: 2px 6px;
    font-size: inherit;
}

.btn-lookup-rec {
    margin-left: 4px;
    padding: 1px 7px;
    font-size: 0.85em;
    cursor: pointer;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: #f5f5f5;
    line-height: 1.4;
    vertical-align: middle;
}
.btn-lookup-rec:hover { background: #e0e0e0; }

.lookup-rec-status {
    margin-left: 6px;
    font-size: 0.85em;
    vertical-align: middle;
}
.lookup-rec-ok    { color: #2a7a2a; }
.lookup-rec-error { color: #c0392b; }

/* === Recurring operations — barre de progression timeline === */
.rec-progress-wrap {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.rec-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: .8rem;
}
.rec-progress-title {
    font-weight: 600;
    font-size: .95rem;
    color: #334155;
    letter-spacing: .01em;
}
.rec-progress-meta {
    font-size: .82rem;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}
.rec-progress-track {
    display: flex;
    gap: 3px;
    height: 20px;
    border-radius: .4rem;
    overflow: hidden;
}
.rec-seg {
    flex: 1;
    border-radius: 2px;
    transition: opacity .15s, transform .1s;
    cursor: default;
    min-width: 2px;
}
.rec-seg:hover {
    opacity: .7;
    transform: scaleY(1.08);
}
.rec-seg--ok     { background: #22c55e; }
.rec-seg--missed { background: #f87171; }
.rec-seg--today  { background: #3b82f6; box-shadow: 0 0 0 2px #bfdbfe; }
.rec-seg--future { background: #e2e8f0; }
.rec-progress-dates {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: #94a3b8;
    margin-top: .35rem;
    letter-spacing: .01em;
}
.rec-progress-legend {
    display: flex;
    gap: 1.2rem;
    margin-top: .9rem;
    flex-wrap: wrap;
    border-top: 1px solid #f1f5f9;
    padding-top: .75rem;
}
.rec-legend-item {
    font-size: .78rem;
    display: flex;
    align-items: center;
    gap: .3rem;
    color: #475569;
}
.rec-legend-item::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.rec-legend--ok::before     { background: #22c55e; }
.rec-legend--missed::before { background: #f87171; }
.rec-legend--today::before  { background: #3b82f6; }
.rec-legend--future::before { background: #e2e8f0; border: 1px solid #cbd5e1; }

/* --- Montant + débit/crédit --- */
.form-group-montant {
    min-width: 250px;
}

.montant-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group-montant input[type="number"] {
    width: 110px;
    flex-shrink: 0;
}

.debit-credit-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
}

.debit-credit-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.debit-credit-group input[type="radio"] {
    width: auto;
    margin: 0;
}

/* ===== Column visibility toggle ===== */
.transactions-table.hide-id .col-id,
.transactions-table.hide-date-operation .col-date-operation,
.transactions-table.hide-fournisseur .col-fournisseur,
.transactions-table.hide-categorie .col-categorie,
.transactions-table.hide-commentaire .col-commentaire,
.transactions-table.hide-type .col-type {
    display: none;
}

.col-visibility-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.col-visibility-bar::before {
    content: 'Colonnes :';
    font-size: 11px;
    color: var(--color-secondary);
    margin-right: 2px;
}

.col-toggle-active {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ===== Sidebar toggle ===== */
#sidebar-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: none;
    border: 1px solid #dee2e6;
    cursor: pointer;
    font-size: 16px;
    color: #495057;
    padding: 3px 8px;
    border-radius: 4px;
    line-height: 1;
}

#sidebar-toggle:hover {
    background-color: var(--color-light);
    color: var(--color-primary);
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* =========================================================
   Transaction — refonte visuelle (édition / création)
   Classes préfixées "tx-" : scoped à ces pages, ne touchent
   pas les styles génériques .btn / .card / table partagés
   par le reste de l'application.
   ========================================================= */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tx-icon {
    display: inline-block;
    vertical-align: -3px;
    flex-shrink: 0;
}

.tx-page-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.tx-recurrence-actions {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.tx-alert-split {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tx-alert-split .tx-icon {
    margin-top: 2px;
    flex-shrink: 0;
}

/* --- Chevrons (details + bouton "Détails") --- */
.tx-chevron {
    display: inline-flex;
    margin-left: auto;
    color: #94a3b8;
}

.tx-chevron svg {
    transition: transform 0.15s ease;
}

.tx-collapsible[open] > summary .tx-chevron svg,
.tx-btn-details[aria-expanded="true"] .tx-chevron svg {
    transform: rotate(180deg);
}

.tx-btn-details {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* --- Cards --- */
.tx-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 20px 24px;
    margin-bottom: 20px;
    max-width: 900px;
}

.tx-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
}

.tx-card-title .tx-icon {
    color: var(--color-primary);
}

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

.tx-card select,
.tx-card input[type="date"],
.tx-card input[type="text"],
.tx-card input[type="number"] {
    height: 38px;
}

.tx-card select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* --- Disclosure : Commentaire / Fichiers / Autres actions --- */
.tx-collapsible {
    padding: 0;
}

.tx-collapsible > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    user-select: none;
    border-radius: 8px;
}

.tx-collapsible > summary::-webkit-details-marker {
    display: none;
}

.tx-collapsible > summary::marker {
    content: "";
}

.tx-collapsible > summary:hover {
    background: #f8fafc;
}

.tx-collapsible[open] > summary {
    border-bottom: 1px solid #f1f5f9;
    border-radius: 8px 8px 0 0;
}

.tx-summary-title {
    white-space: nowrap;
    flex-shrink: 0;
}

.tx-summary-preview {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: #94a3b8;
}

.tx-collapsible-body {
    padding: 16px 24px 20px;
}

.tx-collapsible-body .form-group:last-child {
    margin-bottom: 0;
}

/* --- Checkbox "Pointé" en chip --- */
.tx-check-pointe {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 7px 14px 0;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.tx-check-pointe input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.tx-check-pointe:has(input:checked) {
    background: #ecfdf5;
    border-color: #34d399;
    color: #047857;
}

/* --- Débit / Crédit : contrôle segmenté --- */
.debit-credit-group {
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    overflow: hidden;
    padding: 0 !important;
}

.debit-credit-group label {
    height: 36px;
    padding: 0 12px !important;
    margin: 0 !important;
    font-weight: 500;
    color: #6b7280;
    position: relative;
}

.debit-credit-group label:first-child {
    border-right: 1px solid #ced4da;
}

.debit-credit-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.debit-credit-group label:first-child:has(input:checked) {
    background: #fef2f2;
    color: #dc2626;
}

.debit-credit-group label:last-child:has(input:checked) {
    background: #f0fdf4;
    color: #16a34a;
}

#montant {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.montant-controls:has(input[value="credit"]:checked) #montant {
    color: #16a34a;
}

.montant-controls:has(input[value="debit"]:checked) #montant {
    color: #dc2626;
}

/* --- Statut : grille de champs --- */
.tx-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 16px;
    margin-bottom: 15px;
    align-items: start;
}

.tx-status-grid .form-group {
    margin-bottom: 0;
}

.form-group-readonly {
    display: flex;
    flex-direction: column;
}

.tx-readonly-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #6b7280;
}

.tx-readonly-value {
    display: flex;
    align-items: center;
    height: 38px;
    padding: 0 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
    font-weight: 600;
    color: #111827;
}

/* --- Pointé placé dans la carte "Informations générales" --- */
.tx-pointe-slot {
    margin-left: auto;
    flex: 0 0 auto;
}

.tx-invisible-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    visibility: hidden;
}

/* --- Récurrence : contrôle segmenté --- */
.form-group-recurrence-mode {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 4px;
}

.form-group-recurrence-mode label {
    padding: 3px 10px;
    border-radius: 4px;
}

.form-group-recurrence-mode label:has(> input:checked) {
    background: #dbeafe;
    color: #1e40af;
}

/* --- Barre de portée (occurrence unique / suivantes) --- */
.tx-scope-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin: 0 0 20px;
    padding: 10px 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 14px;
    max-width: 900px;
}

.tx-scope-bar .form-scope-label {
    color: #1e40af;
    font-weight: 600;
}

.tx-scope-bar label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* --- Barre d'actions du formulaire : toujours visible --- */
.tx-form-footer {
    position: fixed;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    z-index: 40;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 14px 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    transition: left 0.25s ease;
}

body.sidebar-collapsed .tx-form-footer {
    left: 0;
}

.tx-form-footer-inner {
    max-width: 900px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.tx-form-footer .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tx-footer-spacer {
    height: 84px;
}

/* --- Fichiers : recherche + table allégée --- */
.tx-file-associate {
    margin-top: 20px;
}

.tx-file-associate-label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.tx-file-search-wrap {
    position: relative;
    max-width: 480px;
}

.tx-file-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    margin: 0;
    padding: 0;
    list-style: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.tx-hint {
    margin: 4px 0 0;
    font-size: 0.85em;
    color: #6b7280;
}

.tx-muted {
    color: #6c757d;
}

.tx-empty-state {
    padding: 16px 0;
    color: #6b7280;
    font-style: italic;
}

.tx-files-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.tx-files-table th,
.tx-files-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #f1f5f9;
}

.tx-files-table th {
    background: transparent;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #94a3b8;
    font-weight: 600;
}

.tx-files-table tr:hover {
    background: #f8fafc;
}

.tx-files-table .btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* --- Autres actions : lignes --- */
.tx-action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.tx-action-row:last-child {
    border-bottom: none;
}

.tx-action-row .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tx-action-desc {
    color: #6b7280;
    font-size: 13px;
}

/* --- Opérations liées au split --- */
.tx-siblings-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tx-siblings-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 14px;
}

.tx-siblings-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

/* --- Responsive --- */
@media (max-width: 720px) {
    .form-row-dates,
    .form-row-selects,
    .form-row-libelle-montant {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .form-row-dates input[type="date"] {
        width: 100%;
    }

    .tx-pointe-slot {
        margin-left: 0;
    }

    .form-row-checks {
        flex-direction: column;
        align-items: stretch;
    }

    .tx-status-grid {
        grid-template-columns: 1fr;
    }

    .tx-card {
        padding: 16px;
    }

    .tx-collapsible > summary,
    .tx-collapsible-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .tx-form-footer-inner {
        flex-wrap: wrap;
    }

    .tx-form-footer-inner .btn-primary {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .tx-form-footer-inner .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}
