.admin-dropdown {
    position: relative;
    display: inline-block;
}

.admin-dropdown-btn {
    background: #dfe8e3;
    border: 1px solid #c7d5cd;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
}

.admin-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: white;
    border: 1px solid #d8e2dc;
    border-radius: 8px;
    padding: 8px 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.admin-dropdown-menu a {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: #1f2937;
}

.admin-dropdown-menu.show {
    display: block;
}

:root {
    --versions-accent: #1a6b5a;
    --versions-accent-dark: #355c52;
    --versions-surface: #f8fbfa;
    --versions-surface-strong: #eef5f2;
    --versions-border: #d9e4df;
    --versions-muted: #5f6f6a;
}

body {
    font-family: Arial, sans-serif;
    background: #f7f9f8;
    color: #2f3f3b;
    margin: 0;
    padding: 0;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 40px auto;
}

h1, h2, h3 {
    color: #2f3f3b;
}

h1 {
    font-size: 1.9rem;
    line-height: 1.2;
    font-weight: 700;
}

h2 {
    font-size: 1.35rem;
    line-height: 1.25;
    font-weight: 700;
}

h3 {
    font-size: 1.05rem;
    line-height: 1.35;
    font-weight: 700;
}

p {
    line-height: 1.6;
}

.page-container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.page-container-wide {
    max-width: none;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.page-header h1,
.page-header h2 {
    margin: 0;
}

.page-header p {
    margin: 0.35rem 0 0;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.content-card,
.search-card,
.table-card {
    background: #ffffff;
    border: 1px solid #d9e4df;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.search-card .search-form {
    margin-bottom: 0;
}

.content-card p + p,
.result-card p + p {
    margin-top: 0.75rem;
}

.result-card p,
.search-card p,
.table-card p {
    margin-bottom: 1rem;
}

.result-card p:last-child,
.search-card p:last-child,
.table-card p:last-child {
    margin-bottom: 0;
}

.section-title {
    margin: 2rem 0 1rem;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.text-muted {
    color: #5f6f6a;
}

a {
    color: #466964;
    text-decoration: none;
}

a:hover {
    color: #2f3f3b;
    text-decoration: underline;
}

.search-form {
    margin-bottom: 30px;
}

.search-input {
    width: 350px;
    padding: 10px;
    font-size: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 10px 14px;
    border: 1px solid #cfdcd7;
    background: #e8efec;
    color: #2f3f3b;
    cursor: pointer;
    border-radius: 6px;
    font: inherit;
    line-height: 1.2;
    min-height: 42px;
    text-decoration: none;
}

.btn:hover {
    background: #d6e4df;
}

.result-card {
    background: white;
    border: 1px solid #d9e3df;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.result-card:hover {
    background-color: #fafbfc;
    border-color: #dbe4ee;
}

.journal-result-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.journal-result-content {
    min-width: 0;
}

.journal-result-actions {
    flex-shrink: 0;
    justify-content: flex-end;
    margin-left: auto;
}

.journal-result-actions .btn {
    white-space: nowrap;
}

.result-title {
    font-size: 18px;
    margin-bottom: 8px;
}

.result-meta {
    color: #555;
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

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

.form-row .search-input {
    flex: 1;
}

.search-field {
    flex: 1;
    min-width: 280px;
}

.search-field label,
.form-row label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #20352f;
}

/* admin/actes - recherche pleine largeur (page admin/actes/index uniquement) */

.search-card--actes .search-field,
.search-card--journaux .search-field {
    min-width: 0;
}

.search-card--actes .search-input,
.search-card--journaux .search-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 760px) {
    .search-card--actes .search-field,
    .search-card--journaux .search-field {
        min-width: 100%;
    }
}

.search-help {
    display: block;
    margin-top: 6px;
    font-size: 0.9rem;
    color: #666;
}

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pdf-viewer-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.pdf-viewer-main {
    flex: 1;
}

.pdf-frame {
    width: 100%;
    height: 90vh;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.pdf-viewer-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cut-success-box {
    margin-top: 20px;
    padding: 15px;
    background: #e8f5e9;
    border-left: 4px solid #28a745;
    border-radius: 6px;
}

.cut-success-box .btn {
    margin-left: 10px;
}

.cut-form {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fafafa;
}

.cut-form-title {
    font-weight: bold;
    margin-bottom: 15px;
}

.cut-form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.cut-input {
    width: 100%;
    padding: 8px;
}

/* =========================
   ALERTES / MESSAGES
========================= */

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
}

.alert-success {
    background: #e6ffed;
    border: 1px solid #8fd19e;
    color: #1e4620;
}

.alert-error {
    background: #fff1f1;
    border: 1px solid #ff8a8a;
    color: #d93025;
}

.alert-info {
    background: #eef7f4;
    border: 1px solid #bdd8ce;
    color: #2f5b51;
}

.alert ul {
    margin-top: 10px;
    margin-bottom: 0;
}

header {
    background: #f3f6f5;
    color: #2f3f3b;
    padding: 18px 28px;
    border-bottom: 1px solid #d9e3df;
}

header h1 {
    margin: 0 0 12px 0;
    font-size: 1.6rem;
    color: #2f3f3b;
}

nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

nav a {
    color: #2f3f3b;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    background: #e8efec;
    transition: background 0.2s ease;
}

nav a:hover {
    background: #d6e4df;
}

.logout-btn {
    background: #d08a77;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s ease;
}

.logout-btn:hover {
    background: #c47a66;
}

.user-badge {
    padding: 8px 14px;
    background: #dfe8e4;
    border-radius: 6px;
    color: #466964;
    font-size: 0.95rem;
}

.search-input,
select,
.cut-input {
    padding: 10px 12px;
    border: 1px solid #cfdcd7;
    border-radius: 6px;
    background: white;
    color: #2f3f3b;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.search-input:focus,
select:focus,
.cut-input:focus {
    outline: none;
    border-color: #7fa39b;
    box-shadow: 0 0 0 2px rgba(127, 163, 155, 0.15);
}


.btn-primary {
    background: #7fa39b;
    color: white;
    border: 1px solid #7fa39b;
}

.btn-primary:hover {
    background: #6f938b;
    color: white;
    text-decoration: none;
}

.btn-secondary {
    background: #e8efec;
    color: #466964;
    border: 1px solid #cfdcd7;
}

.btn-secondary:hover {
    background: #d6e4df;
}

.btn-sm {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.88rem;
}

.btn-danger:hover {
    background: #c47a66;
    color: white;
    text-decoration: none;
}

.btn-danger:hover {
    background: #c47a66;
}

.pdf-viewer-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.viewer-card {
    background: white;
    border: 1px solid #d9e3df;
    border-radius: 10px;
    padding: 20px;
}

.viewer-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2f3f3b;
}

.viewer-meta {
    margin-bottom: 18px;
    line-height: 1.6;
}

.viewer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.import-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.import-table th,
.import-table td {
    border: 1px solid #d9e3df;
    padding: 8px;
    vertical-align: top;
}

.import-table th {
    background: #e8efec;
    color: #2f3f3b;
    text-align: left;
}

.table-input,
.table-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #cfdcd7;
    border-radius: 6px;
    color: #2f3f3b;
    box-sizing: border-box;
}

.table-input.small {
    min-width: 110px;
}

.table-input.xsmall {
    min-width: 70px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.table-textarea {
    min-width: 400px;
    resize: vertical;
}

.auth-page {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 480px;
}

.auth-title {
    margin-top: 0;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: #466964;
    margin-bottom: 28px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfdcd7;
    border-radius: 6px;
    box-sizing: border-box;
}

.auth-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #466964;
}

.auth-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 8px;
}

.auth-link {
    color: #466964;
    font-size: 0.9rem;
}

.pagination-wrapper {
    margin-top: 1rem;
}

.pagination-wrapper nav > div:first-child {
    display: none;
}

.pagination-wrapper nav > div:last-child {
    display: flex;
    justify-content: center;
}

.pagination-wrapper nav > div:last-child > div {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pagination-wrapper a,
.pagination-wrapper span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.75rem;
    border-radius: 0.45rem;
    text-decoration: none;
    color: #1f2937;
    background: #eef5f2;
}

.pagination-wrapper span[aria-current="page"] span {
    background: #dbece6;
    font-weight: 600;
}

.pagination-wrapper svg {
    width: 1rem;
    height: 1rem;
}

@media (max-width: 760px) {
    .pagination-wrapper nav > div:last-child {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .pagination-wrapper nav > div:last-child > div {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination-wrapper nav > div:last-child > div:first-child p {
        text-align: center;
        margin: 0;
    }

    .pagination-wrapper nav > div:last-child > div > span {
        height: auto;
        flex-wrap: wrap;
        justify-content: center;
    }
}

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

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.dashboard-stat-card {
    background: #f5f8f7;
    border: 1px solid #d9e4df;
    border-radius: 8px;
    padding: 1.25rem;
}

.dashboard-stat-card strong {
    display: block;
    font-size: 2rem;
    color: #20384a;
    margin-bottom: 0.5rem;
}

.dashboard-stat-card span {
    color: #4b5563;
}

/* =========================
   Accueil - cartes d'accès rapide
========================= */

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.home-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f5f8f7;
    border: 1px solid #d9e4df;
    border-radius: 8px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.home-card:hover {
    border-color: #1a6b5a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.home-card svg {
    color: #1a6b5a;
}

.home-card strong {
    color: #20384a;
    font-size: 1rem;
}

.home-card span {
    color: #4b5563;
}

.home-title {
    margin-bottom: 1rem;
}

.home-section-title {
    margin-bottom: 1rem;
}

@media (max-width: 760px) {
    .home-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .home-card {
        padding: 1rem;
    }
}

.dashboard-section {
    background: #ffffff;
    border: 1px solid #d9e4df;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.admin-card {
    background: #ffffff;
    border: 1px solid #d9e4df;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

/* =========================
   Tables administration
========================= */

.admin-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.admin-table th {
    text-align: left;
    padding: 0.75rem;
    background: #eef5f2;
    border-bottom: 1px solid #d9e4df;
    font-weight: 600;
}

.admin-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eef2f0;
}

.admin-table tr:hover {
    background: #f8fbfa;
}

.admin-table td:last-child,
.admin-table th:last-child {
    text-align: center;
    width: 140px;
}

.admin-table .btn {
    min-width: 100px;
}

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-actions .btn {
    min-width: 90px;
    text-align: center;
}

/* tableau admin/users - scroll responsive (scope: .table-scroll uniquement) */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.table-scroll > table {
    min-width: 640px;
}

.table-scroll--import > table {
    min-width: 1120px;
}

.table-scroll--import .btn {
    width: auto;
    white-space: nowrap;
}

.table-scroll--import td:last-child {
    white-space: nowrap;
}

.table-scroll--versions > table {
    min-width: 480px;
}

.table-scroll--versions-public > table {
    min-width: 560px;
}

.table-scroll--versions .table-actions {
    justify-content: center;
}

.table-scroll--dashboard > table {
    min-width: 560px;
}

.table-scroll--dashboard .admin-table th:last-child,
.table-scroll--dashboard .admin-table td:last-child {
    width: auto;
    white-space: nowrap;
}

.table-scroll--journaux > table {
    min-width: 480px;
}

.table-scroll--journaux .table-actions {
    justify-content: center;
}

.table-scroll .admin-table {
    table-layout: auto;
}

.table-scroll .admin-table td:nth-child(2),
.table-scroll .admin-table td:nth-child(3),
.table-scroll .admin-table td:nth-child(4) {
    white-space: nowrap;
}

.table-scroll--logs > table {
    min-width: 720px;
}

.table-scroll--logs .admin-table td:nth-child(4) {
    white-space: normal;
    min-width: 280px;
}

.table-scroll--logs .admin-table th:last-child {
    width: auto;
    text-align: left;
}

.table-scroll--logs .admin-table td:last-child {
    text-align: left;
}

.table-scroll .admin-table th:first-child,
.table-scroll .admin-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #ffffff;
    white-space: nowrap;
}

.table-scroll .admin-table th:first-child {
    background: #eef5f2;
    z-index: 2;
}

.table-scroll .admin-table tr:hover td:first-child {
    background: #f8fbfa;
}

.table-scroll .table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-scroll .table-actions .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    min-width: 0;
}

.tree-edit-row .btn-icon {
    width: 36px;
    height: 36px;
    min-height: 36px;
    min-width: 0;
    padding: 0;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* tableau admin/consolidations */

.col-type {
    width: 90px;
}

.col-ref {
    width: 250px;
}

.col-titre {
    width: 500px;
}

.col-categorie {
    width: 140px;
}

.col-etat {
    width: 90px;
}

.col-versions {
    width: 70px;
    text-align: center;
}

.col-actions {
    width: 160px;
}

.table-scroll--fixed > table {
    min-width: 980px;
}

.table-scroll--fixed .admin-table {
    table-layout: fixed;
}

.table-scroll--fixed .admin-table td:nth-child(2),
.table-scroll--fixed .admin-table td:nth-child(3),
.table-scroll--fixed .admin-table td:nth-child(4) {
    white-space: normal;
}

.table-scroll--fixed .col-actions {
    width: 90px;
}

.table-scroll--fixed .table-actions {
    justify-content: center;
}

.table-scroll--fixed .admin-table th:last-child {
    width: 90px;
}

/* *********************************** */

.pdf-link {
    font-weight: 600;
}

.pdf-link:hover {
    text-decoration: underline;
}

.consolidation-tree {
    margin-bottom: 0.75rem;
    margin-left: calc(var(--level, 0) * 28px);
}

.consolidation-title {
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 1rem;
}

.consolidation-subtitle {
    font-weight: 600;
}

.consolidation-chapter {
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.consolidation-chapter:hover {
    color: #355c52;
}

.consolidation-toggle-icon {
    display: inline-block;
    width: 18px;
    color: var(--versions-accent);
}

/* Espacement au-dessus de chaque niveau de structure, sauf en tout premier
   enfant de son parent (pas de marge excessive juste sous le niveau parent). */
.consolidation-tree.consolidation-node-partie:not(:first-child),
.consolidation-tree.consolidation-node-livre:not(:first-child),
.consolidation-tree.consolidation-node-titre:not(:first-child) {
    margin-top: 3rem;
}

.consolidation-tree.consolidation-node-chapitre:not(:first-child) {
    margin-top: 2.25rem;
}

.consolidation-tree.consolidation-node-section:not(:first-child) {
    margin-top: 1.75rem;
}

.consolidation-tree.consolidation-node-sous-section:not(:first-child),
.consolidation-tree.consolidation-node-sous-sous-section:not(:first-child) {
    margin-top: 1.25rem;
}

/* Hiérarchie visuelle des niveaux de structure. */
.consolidation-tree.consolidation-node-partie .consolidation-title,
.consolidation-tree.consolidation-node-livre .consolidation-title,
.consolidation-tree.consolidation-node-titre .consolidation-title {
    display: block;
    padding: 0.6rem 1rem;
    background: var(--versions-surface-strong);
    border-left: 6px solid var(--versions-accent);
    border-radius: 4px;
    font-size: 1.15rem;
}

/* Quand un intitulé suit, le bandeau se poursuit dans le même bloc visuel :
   le titre perd ses coins bas arrondis, l'intitulé les reprend juste dessous. */
.consolidation-tree.consolidation-node-partie .consolidation-title:has(+ .consolidation-subtitle),
.consolidation-tree.consolidation-node-livre .consolidation-title:has(+ .consolidation-subtitle),
.consolidation-tree.consolidation-node-titre .consolidation-title:has(+ .consolidation-subtitle) {
    padding-bottom: 0.3rem;
    border-radius: 4px 4px 0 0;
}

.consolidation-tree.consolidation-node-partie .consolidation-subtitle,
.consolidation-tree.consolidation-node-livre .consolidation-subtitle,
.consolidation-tree.consolidation-node-titre .consolidation-subtitle {
    display: block;
    margin-top: 0;
    padding: 0 1rem 0.6rem 1rem;
    background: var(--versions-surface-strong);
    border-left: 6px solid var(--versions-accent);
    border-radius: 0 0 4px 4px;
}

/* Livre : plus marque que Titre (fond un peu plus soutenu, texte plus gras). */
.consolidation-tree.consolidation-node-livre .consolidation-title,
.consolidation-tree.consolidation-node-livre .consolidation-subtitle {
    background: var(--versions-border);
    border-left-width: 8px;
    font-weight: 700;
}

.consolidation-tree.consolidation-node-livre .consolidation-title {
    font-size: 1.22rem;
}

/* Partie : le plus marque (fond plein, texte clair). */
.consolidation-tree.consolidation-node-partie .consolidation-title,
.consolidation-tree.consolidation-node-partie .consolidation-subtitle {
    background: var(--versions-accent);
    border-left-width: 8px;
    border-left-color: var(--versions-accent-dark);
    color: var(--versions-surface);
    font-weight: 700;
}

.consolidation-tree.consolidation-node-partie .consolidation-title {
    font-size: 1.3rem;
}

/* Contraste de la plage d'articles sur les bandeaux Partie/Livre (desktop
   et mobile - une seule regle, non dupliquee dans les media queries). */
.consolidation-tree.consolidation-node-partie .consolidation-article-range {
    color: var(--versions-surface);
    opacity: 0.85;
}

.consolidation-tree.consolidation-node-livre .consolidation-article-range {
    color: var(--versions-accent-dark);
}

.consolidation-tree.consolidation-node-chapitre .consolidation-chapter {
    padding: 8px 10px;
    background: var(--versions-surface);
    border-left: 3px solid var(--versions-accent);
    border-radius: 4px;
    font-weight: 600;
}

.consolidation-tree.consolidation-node-section .consolidation-chapter {
    padding: 6px 2px;
    border-bottom: 2px solid var(--versions-accent);
    font-weight: 600;
    font-size: 0.97rem;
}

.consolidation-tree.consolidation-node-sous-section .consolidation-chapter,
.consolidation-tree.consolidation-node-sous-sous-section .consolidation-chapter {
    padding: 4px 6px;
    border-left: 2px solid var(--versions-border);
    font-weight: 400;
    color: var(--versions-muted);
}

@media (max-width: 760px) {
    .consolidation-tree.consolidation-node-partie .consolidation-title,
    .consolidation-tree.consolidation-node-livre .consolidation-title,
    .consolidation-tree.consolidation-node-titre .consolidation-title {
        padding: 0.5rem 0.75rem;
        font-size: 1.05rem;
    }

    .consolidation-tree.consolidation-node-partie .consolidation-title:has(+ .consolidation-subtitle),
    .consolidation-tree.consolidation-node-livre .consolidation-title:has(+ .consolidation-subtitle),
    .consolidation-tree.consolidation-node-titre .consolidation-title:has(+ .consolidation-subtitle) {
        padding-bottom: 0.25rem;
    }

    .consolidation-tree.consolidation-node-partie .consolidation-subtitle,
    .consolidation-tree.consolidation-node-livre .consolidation-subtitle,
    .consolidation-tree.consolidation-node-titre .consolidation-subtitle {
        padding: 0 0.75rem 0.5rem 0.75rem;
    }

    .consolidation-tree.consolidation-node-livre .consolidation-title {
        font-size: 1.1rem;
    }

    .consolidation-tree.consolidation-node-partie .consolidation-title {
        font-size: 1.15rem;
    }
}

.consolidation-article {
    font-weight: 700;
    margin-top: 0.8rem;
}

.consolidation-content {
    margin-top: 0.6rem;
    padding-left: 1rem;
    border-left: 3px solid #d9e2e1;

    line-height: 1.8;
    font-size: 0.98rem;
    color: #2f3742;
}

.consolidation-content p {
    margin: 0 0 1rem 0;
}

.consolidation-content br {
    display: block;
    content: "";
    margin-bottom: 0.5rem;
}

.consolidation-content ul,
.consolidation-content ol {
    margin: 0.75rem 0 1rem 1.5rem;
}

.consolidation-content li {
    margin-bottom: 0.4rem;
}

.consolidation-content table {
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.consolidation-content th,
.consolidation-content td {
    border: 1px solid #c3ccd6;
    padding: 0.35rem 0.6rem;
}

.consolidation-content strong,
.consolidation-content b {
    font-weight: 700;
}

.consolidation-article-title {
    font-style: italic;
}

.consolidation-generic {
    font-weight: 700;
    padding: 4px 10px;
    border-left: 3px solid var(--versions-border);
}

/* Pas de marge excessive quand ce noeud de secours est le premier de son
   parent (meme logique que les autres niveaux). */
.consolidation-tree:not(:first-child) .consolidation-generic {
    margin-top: 1.5rem;
}

.modification-badge {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: normal;
    color: #5f6f6a;
}

.consolidation-article-range {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: normal;
    text-transform: none;
    color: #8a8f98;
}

.modification-commentaire {
    margin-top: 4px;
    color: #55625d;
}

.article-versions-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding: 4px 12px;
    border: 1px solid var(--versions-border);
    border-radius: 999px;
    background: var(--versions-surface);
    color: var(--versions-accent-dark);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.article-versions-toggle:hover {
    background: var(--versions-surface-strong);
}

.article-versions-toggle[aria-expanded="true"] {
    background: var(--versions-surface-strong);
    border-color: var(--versions-accent);
}

.article-versions-toggle-icon {
    display: inline-block;
    width: 10px;
}

.article-versions-panel {
    position: relative;
    margin-top: 0.6rem;
    padding: 1rem 1.25rem;
    background: var(--versions-surface);
    border: 1px solid var(--versions-border);
    border-left: 4px solid var(--versions-accent);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.article-versions-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.article-versions-panel-title {
    font-size: 0.95rem;
    color: var(--versions-accent-dark);
}

.article-versions-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--versions-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.article-versions-close:hover,
.article-versions-close:focus-visible {
    background: var(--versions-surface-strong);
    color: var(--versions-accent-dark);
}

.version-timeline-year + .version-timeline-year {
    margin-top: 1.25rem;
}

.version-timeline-year-label {
    font-weight: 700;
    color: var(--versions-accent-dark);
    margin-bottom: 0.6rem;
}

.version-timeline-items {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.version-timeline-items::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: 1px;
    background: var(--versions-border);
}

.version-timeline-item {
    position: relative;
    padding: 0 0 1rem 1.5rem;
}

.version-timeline-item:last-child {
    padding-bottom: 0;
}

.version-timeline-item::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--versions-accent);
    border: 2px solid var(--versions-surface);
}

.version-timeline-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.version-timeline-type {
    font-weight: 700;
}

.version-timeline-date {
    color: var(--versions-muted);
    font-size: 0.9rem;
}

.modification-texte {
    margin-top: 0.4rem;
}

.article-separator {
    margin: 28px 0;
    border: none;
    border-top: 1px solid var(--versions-border);
}

.tree-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (max-width: 760px) {
    .consolidation-tree {
        margin-left: calc(var(--level, 0) * 8px);
    }

    .consolidation-content {
        padding-left: 0.5rem;
        border-left-width: 2px;
    }

    /* Page de version consolidee : gagne la largeur laissee par le conteneur
       a 90% et le padding des cartes, comme sur la page de recherche. */
    .container.version-page {
        width: auto;
        margin-left: 12px;
        margin-right: 12px;
    }

    .version-page .result-card {
        padding: 12px;
    }

    .version-page h1 {
        font-size: 1.5rem;
        line-height: 1.15;
        overflow-wrap: break-word;
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
}

.page-header p {
    margin: 0.35rem 0 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 2rem;
}

.detail-grid strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #20352f;
}

.detail-grid span {
    color: #334155;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 760px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .section-header .btn {
        width: 100%;
    }
}

.form-field {
    margin-bottom: 1rem;
    max-width: 620px;
}

.form-field label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #20352f;
}

.form-field .search-input {
    width: 100%;
}

.form-row-admin {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 1rem;
}

.form-row-admin label {
    width: 90px;
    font-weight: 600;
    flex-shrink: 0;
}

.form-row-admin input {
    width: 400px;
}

.form-row-admin textarea {
    flex: 1;
}

.form-row-admin label {
    padding-top: 10px;
}

@media (max-width: 760px) {
    .form-row-admin {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .form-row-admin label {
        width: auto;
        padding-top: 0;
    }
    .form-row-admin input,
    .form-row-admin textarea {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
}

.change-preview {
    margin-top: 1rem;
}

.change-field {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.change-old,
.change-new {
    margin-bottom: 0.75rem;
}

.change-box {
    margin-top: 0.25rem;
    padding: 0.75rem;
    background: #ffffff;
    border: 1px solid #cfd8d3;
    border-radius: 6px;
    white-space: pre-wrap;
    text-align: left;
    line-height: 1.5;
}

.change-box .consolidation-content {
    white-space: normal;
}

.preview-changed {
    background: #fff8e6;
    border-left: 4px solid #d4a017;
}

.preview-badge-changed {
    background: #fff3cd;
    color: #856404;
}

.preview-added {
    background: #f0fdf4;
    border-left: 4px solid #86efac;
}

.preview-deleted {
    background: #fef2f2;
    border-left: 4px solid #fca5a5;
    color: #7f1d1d;
}

.preview-badge-deleted {
    background: #fee2e2;
    color: #991b1b;
}

.preview-badge-added {
    background: #dcfce7;
    color: #166534;
}

.preview-badge-abrogated {
    background: #e5e7eb;
    color: #374151;
}

.preview-abrogated {
    background: #f3f4f6;
    border-left: 4px solid #9ca3af;
    color: #4b5563;
}

.preview-badge-changed,
.preview-badge-added,
.preview-badge-deleted,
.preview-badge-abrogated {
    margin-left: 0.5rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.preview-changed,
.preview-added,
.preview-deleted,
.preview-abrogated {
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    box-sizing: border-box;
}

@media (max-width: 760px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-actions,
    .form-actions {
        width: 100%;
    }

    .journal-result-card {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .journal-result-actions {
        margin-left: 0;
    }

    .btn {
        width: 100%;
    }

    .search-field {
        min-width: 100%;
    }

    .content-card,
    .search-card,
    .table-card,
    .admin-card,
    .viewer-card {
        padding: 1rem;
    }
}

@media (max-width: 760px) {
    .search-field .search-input,
    .form-row .search-input {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Recherche plein texte des journaux */
.fulltext-search-card label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #20352f;
}

.fulltext-search-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.fulltext-search-row .search-input {
    flex: 1;
    width: auto;
    min-width: 0;
}

.fulltext-results-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.search-duration {
    color: #5f6f6a;
    font-size: 0.9rem;
    white-space: nowrap;
}

.fulltext-result-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.fulltext-result-main {
    min-width: 0;
}

.fulltext-snippet {
    margin: 0.9rem 0 0;
    color: #43534e;
    line-height: 1.55;
}

.fulltext-snippet mark {
    padding: 0.05em 0.18em;
    color: #20352f;
    background: #dcefe8;
    border-radius: 3px;
    font-weight: 700;
}

.fulltext-open-button {
    flex-shrink: 0;
    white-space: nowrap;
}

.field-error {
    margin-top: 0.5rem;
    color: #b42318;
}

.empty-state {
    color: #5f6f6a;
    text-align: center;
}

.journal-viewer-page {
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.journal-viewer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.journal-viewer-toolbar h1 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
}

.journal-viewer-toolbar p {
    margin: 0;
    color: #5f6f6a;
}

.journal-fulltext-frame {
    width: 100%;
    flex: 1;
    min-height: 560px;
    border: 1px solid #cfdcd7;
    border-radius: 8px;
    background: #fff;
}

@media (max-width: 760px) {
    .fulltext-search-row,
    .fulltext-result-card,
    .journal-viewer-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .fulltext-results-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

.mfa-activation-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 420px;
}

.mfa-qr-box {
    display: flex;
    justify-content: center;
    padding: 16px;
    background: #fff;
    border: 1px solid #d9e3df;
    border-radius: 8px;
}

.mfa-qr-box svg {
    max-width: 240px;
    height: auto;
}

.mfa-secret-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mfa-secret-value {
    display: inline-block;
    padding: 8px 10px;
    background: #eef3f1;
    border: 1px solid #d9e3df;
    border-radius: 6px;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    word-break: break-all;
}

.mfa-recovery-codes {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
    margin: 16px 0 0;
    padding: 0;
}

.mfa-recovery-codes code {
    display: block;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #f0d896;
    border-radius: 6px;
    text-align: center;
}

.mfa-manage-forms {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}


@media (max-width: 760px) {
    .pdf-viewer-layout {
        flex-direction: column;
        align-items: stretch;
    }

    .pdf-viewer-main {
        flex: none;
        width: 100%;
    }

    .pdf-frame {
        height: 70vh;
        min-height: 420px;
    }

    .pdf-viewer-sidebar {
        width: 100%;
    }
}

