:root {
    --primary-color: #0d5f40;
    --primary-dark: #094730;
    --secondary-color: #1a8f64;
    --accent-color: #fca311;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-light: #e5e7eb;
    --sidebar-width: 280px;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-lg: 1rem;
    --radius-md: 0.5rem;
    --radius-sm: 0.375rem;

    --color-success: #16a34a;
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-warning: #f59e0b;
    --color-warning-bg: #fef9c3;
    --color-warning-text: #854d0e;
    --color-danger: #ef4444;
    --color-danger-bg: #fee2e2;
    --color-danger-text: #991b1b;
    --color-info: #0284c7;
    --color-info-bg: #e0f2fe;
    --color-info-text: #075985;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

/* root-shell est le conteneur qui reçoit soit l'écran d'auth (auth-shell)
   soit le shell complet de l'app QHSE (sidebar + main). Il doit se
   comporter comme un flex row plein écran pour que sidebar et main-content
   s'affichent côte à côte quand l'app QHSE est chargée. */
#root-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-color) 0%, #084a32 100%);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    z-index: 10;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0.5rem;
}

.brand-logo {
    height: 50px;
    width: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.brand-text {
    line-height: 1.2;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.7rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    padding: 1rem 0.75rem 0.5rem;
    font-weight: 600;
}

.nav-item {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    opacity: 0.85;
    color: white;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.18);
    opacity: 1;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent-color);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Sidebar footer / data controls */
.sidebar-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.data-controls-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.btn-data {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    transition: background 0.2s;
}

.btn-data:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-data-warn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.autosave-indicator {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
}

.autosave-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 6px var(--color-success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
    position: relative;
}

header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.02em;
}

.breadcrumb {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.header-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.date-badge {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    box-shadow: var(--shadow-soft);
}

/* ===================== KPI / DASHBOARD ===================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--secondary-color);
}

.kpi-card.kpi-warning::before { background: var(--color-warning); }
.kpi-card.kpi-danger::before { background: var(--color-danger); }
.kpi-card.kpi-info::before { background: var(--color-info); }

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.kpi-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
    line-height: 1;
}

.kpi-unit {
    font-size: 1rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
    font-weight: 500;
}

.trend {
    font-size: 0.8rem;
    margin-top: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

.trend.positive { color: var(--color-success); }
.trend.negative { color: var(--color-danger); }
.trend.neutral { color: var(--text-muted); }

/* Dashboard charts grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.chart-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 280px;
}

/* Alerts */
.alert-card {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    border-left: 4px solid;
}

.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-left-color: var(--color-warning);
}

.alert-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-left-color: var(--color-danger);
}

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-info-text);
    border-left-color: var(--color-info);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-left-color: var(--color-success);
}

/* ===================== SECTIONS / GENERIC ===================== */
.section-container {
    background: white;
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

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

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.info-banner {
    background: var(--color-info-bg);
    color: var(--color-info-text);
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border-left: 3px solid var(--color-info);
}

/* ===================== FORMS / INPUTS ===================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
    color: var(--text-main);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(26, 143, 100, 0.1);
}

/* ===================== BUTTONS ===================== */
.btn {
    background: var(--primary-color);
    color: white;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    font-size: 0.875rem;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--secondary-color);
}

.btn-icon {
    padding: 0.4rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: #f3f4f6;
    color: var(--primary-color);
}

.btn-icon.delete:hover {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

/* ===================== TABLES ===================== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.875rem;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

th {
    font-weight: 600;
    color: var(--text-muted);
    background: #f9fafb;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody tr:hover {
    background: #fafbfc;
}

.crit-cell {
    text-align: center;
    font-weight: 700;
    border-radius: 4px;
}

.crit-low { color: var(--color-success); }
.crit-mid { color: var(--color-warning); }
.crit-high { color: var(--color-danger); }

/* ===================== STATUS BADGES ===================== */
.status-badge {
    padding: 0.25rem 0.65rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.status-valid, .status-success { background: var(--color-success-bg); color: var(--color-success-text); }
.status-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.status-danger { background: var(--color-danger-bg); color: var(--color-danger-text); }
.status-info { background: var(--color-info-bg); color: var(--color-info-text); }
.status-neutral { background: #f3f4f6; color: #475569; }

.tag {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #f3f4f6;
    color: var(--text-muted);
    display: inline-block;
}

.tag-blue { background: #eff6ff; color: #1e40af; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-purple { background: #f3e8ff; color: #6b21a8; }
.tag-orange { background: #ffedd5; color: #9a3412; }
.tag-gray { background: #f3f4f6; color: #374151; }

/* ===================== RISK MATRIX (HEATMAP) ===================== */
.matrix-wrapper {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    margin-top: 1rem;
}

.matrix-y-axis {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.matrix-grid {
    display: grid;
    grid-template-columns: 50px repeat(4, 1fr);
    grid-template-rows: repeat(4, 90px) auto;
    gap: 4px;
    flex: 1;
}

.matrix-cell {
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
    text-align: center;
}

.matrix-cell:hover {
    transform: scale(1.03);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.matrix-cell-count {
    font-size: 1.5rem;
    line-height: 1;
}

.matrix-cell-label {
    font-size: 0.65rem;
    opacity: 0.85;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.matrix-axis-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-x-label {
    grid-column: 2 / -1;
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Risk levels */
.risk-acceptable { background: #16a34a; }
.risk-tolerable { background: #84cc16; color: #1e293b; }
.risk-moderate { background: #f59e0b; color: #1e293b; }
.risk-significant { background: #ea580c; }
.risk-critical { background: #dc2626; }

/* Matrix legend */
.matrix-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.legend-color {
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

/* ===================== CAPA / PROGRESS ===================== */
.capa-card {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s;
}

.capa-card:hover {
    border-color: var(--secondary-color);
}

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

.capa-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.capa-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.progress-bar {
    background: #e5e7eb;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* ===================== OBJECTIVES ===================== */
.objective-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1rem;
}

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

.objective-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.objective-progress-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.objective-progress-bar {
    flex: 1;
    background: #e5e7eb;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.objective-progress-pct {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
    min-width: 50px;
    text-align: right;
}

/* ===================== BINDER / DOCS ===================== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.category-card {
    background: white;
    padding: 1rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.category-card:hover {
    border-color: var(--secondary-color);
    transform: translateY(-2px);
}

.category-card.active {
    border-color: var(--secondary-color);
    background: #f0fdf4;
    box-shadow: 0 0 0 2px rgba(26, 143, 100, 0.15);
}

.category-icon {
    font-size: 1.5rem;
}

.category-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.category-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.doc-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.doc-card {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: all 0.15s;
}

.doc-card:hover {
    box-shadow: var(--shadow-soft);
    border-color: var(--secondary-color);
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.doc-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.doc-icon {
    width: 40px;
    height: 40px;
    background: var(--color-info-bg);
    color: var(--color-info);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.doc-title {
    font-weight: 600;
    font-size: 1rem;
}

.doc-ref {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.15rem;
}

.doc-actions {
    display: flex;
    gap: 0.25rem;
}

.doc-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
    padding: 1rem;
}

.modal-content {
    background: white;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 800px;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 0.25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
    background: #f9fafb;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===================== SEARCH ===================== */
.search-bar {
    width: 100%;
    margin-bottom: 1.25rem;
    position: relative;
}

.search-input {
    padding-left: 2.5rem;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ===================== TOAST ===================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-main);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    animation: toastIn 0.3s, toastOut 0.3s 2.5s forwards;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }

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

@keyframes toastOut {
    to { opacity: 0; transform: translateY(20px); }
}

/* ===================== UTILS ===================== */
.flex-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

@media (max-width: 900px) {
    .sidebar { width: 70px; }
    .brand-text, .nav-item span, .data-controls-title, .autosave-indicator, .nav-section-title, .btn-data span:not(:first-child) { display: none; }
    .main-content { padding: 1rem; }
}

/* ===================== AUTH SHELL (login / blocked) ===================== */
.auth-shell {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(circle at 20% 30%, rgba(26,143,100,0.10) 0, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(13,95,64,0.12) 0, transparent 40%),
        linear-gradient(135deg, #f4f7f6 0%, #e0f2fe 100%);
}
.auth-loading {
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 2rem;
}
.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15), 0 8px 16px -4px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 440px;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}
.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: 0 6px 16px rgba(13,95,64,0.25);
}
.auth-title { font-size: 1.4rem; font-weight: 800; color: var(--text-main); letter-spacing: -0.02em; }
.auth-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.875rem; font-weight: 500; color: var(--text-main); }
.auth-form label span { margin-bottom: 0; }

.btn-auth {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    margin-top: 0.5rem;
}
.btn-auth:hover { transform: translateY(-1px); box-shadow: 0 8px 16px -4px rgba(13,95,64,0.35); }
.btn-auth:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-auth-link {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    padding: 0.25rem;
    text-decoration: underline;
}

.auth-error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border-left: 3px solid var(--color-danger);
}

.auth-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}
.auth-tagline {
    font-size: 0.85rem;
    color: var(--text-main);
    font-style: italic;
    margin-bottom: 0.5rem;
}
.auth-brand-line {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.auth-brand-line a { color: var(--secondary-color); text-decoration: none; font-weight: 600; }
.auth-brand-line a:hover { text-decoration: underline; }

/* ===================== USER BADGE (dans sidebar QHSE) ===================== */
.user-badge {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}
.user-badge-org {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.15rem;
}
.user-badge-email {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
    word-break: break-all;
    margin-bottom: 0.35rem;
}
.user-badge-role {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent-color);
    color: #422006;
}
.user-badge-role[data-role="admin_org"] { background: #38bdf8; color: #082f49; }
.user-badge-role[data-role="editeur"] { background: var(--color-success); color: white; }
.user-badge-role[data-role="lecteur"] { background: rgba(255,255,255,0.15); color: white; }
.user-badge-role[data-role="superadmin"] { background: #ef4444; color: white; }

/* Mode lecture seule : désactive visuellement les boutons d'édition */
body[data-role="lecteur"] .btn-icon:not(.no-lock),
body[data-role="lecteur"] .btn:not(#btn-save):not(#btn-logout):not(.no-lock),
body[data-role="lecteur"] .sst-input {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(60%);
}

/* ===================== SUPERADMIN SHELL ===================== */
.admin-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.admin-sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
}
.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0.25rem;
}
.admin-brand-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(220,38,38,0.35);
}
.admin-brand-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }
.admin-brand-subtitle { font-size: 0.7rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.15rem; }

.admin-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.admin-nav-item {
    display: block;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-md);
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.75;
    transition: all 0.15s;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.06); opacity: 1; }
.admin-nav-item.active { background: rgba(239,68,68,0.15); opacity: 1; box-shadow: inset 3px 0 0 #ef4444; }

.admin-sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.admin-main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
    background: var(--bg-color);
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.admin-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.02em;
}
.admin-loading {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.admin-inline-form {
    background: #f9fafb;
    border: 1px solid var(--border-light);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

/* ============================================================
   DOCUMENT UNIQUE (DUERP) — rendu écran + impression PDF
   ============================================================ */

/* Formulaire Entreprise — champ de formulaire standard */
.form-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-field > span { font-size: 0.82rem; font-weight: 600; color: var(--primary-color); }
.form-field > input, .form-field > select {
    padding: 8px 10px; border: 1px solid var(--border-color);
    border-radius: 6px; font-size: 0.9rem; font-family: inherit;
    background: #fff; transition: border-color .15s;
}
.form-field > input:focus, .form-field > select:focus {
    outline: none; border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}
.form-field > input:disabled, .form-field > select:disabled {
    background: #f4f4f5; color: #6b7280; cursor: not-allowed;
}

/* Document Unique — rendu à l'écran */
.du-doc {
    background: #fff;
    max-width: 210mm;
    margin: 0 auto;
    padding: 20mm 18mm;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    font-family: 'Inter', sans-serif;
    font-size: 11pt;
    line-height: 1.55;
    color: #1f2937;
}
.du-cover {
    text-align: center;
    padding: 30mm 0 20mm;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 20mm;
    page-break-after: always;
}
.du-cover-logo img {
    max-height: 100px; max-width: 300px; object-fit: contain;
    margin: 0 auto 30px; display: block;
}
.du-logo-placeholder {
    display: inline-block; padding: 20px 30px;
    border: 2px dashed #ccc; color: #888; margin-bottom: 30px;
    font-weight: 600; letter-spacing: 1px;
}
.du-cover-title {
    font-size: 28pt; font-weight: 800; letter-spacing: 2px;
    color: var(--primary-color); margin: 0 0 8px;
}
.du-cover-subtitle {
    font-size: 16pt; font-weight: 400; color: #374151;
    margin: 0 0 20px;
}
.du-cover-ref {
    font-size: 9pt; color: #6b7280; font-style: italic;
    margin-bottom: 40px;
}
.du-cover-company {
    background: #f9fafb;
    padding: 20px 30px;
    border-left: 4px solid var(--primary-color);
    text-align: left;
    margin: 0 auto 30px;
    max-width: 80%;
}
.du-cover-name { font-size: 15pt; font-weight: 700; color: var(--primary-color); margin-bottom: 8px; }
.du-cover-company > div { margin: 4px 0; font-size: 10.5pt; }
.du-cover-dates {
    display: inline-block;
    text-align: left;
    background: #fff;
    padding: 15px 25px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 10pt;
}
.du-cover-dates > div { margin: 3px 0; }

.du-section {
    margin-bottom: 18mm;
    page-break-inside: avoid;
}
.du-section h2 {
    font-size: 14pt;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 6px;
    margin: 0 0 12px;
}
.du-section h4 {
    font-size: 11pt;
    font-weight: 600;
    color: #374151;
    margin: 14px 0 6px;
}
.du-edit {
    width: 100%; min-height: 60px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit; font-size: 10.5pt; line-height: 1.6;
    color: #1f2937; background: #fafafa;
    resize: vertical;
    transition: border-color .15s, background .15s;
}
.du-edit:focus {
    outline: none; border-color: var(--accent-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.08);
}
.du-edit:read-only { background: #f4f4f5; cursor: default; }

.du-footer {
    margin-top: 25mm;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
    font-size: 8.5pt; color: #6b7280; text-align: center;
}

/* ============================================================
   IMPRESSION — ne rendre QUE le document unique, propre, sans sidebar
   ============================================================ */
@media print {
    @page { size: A4; margin: 15mm 12mm; }

    /* Lorsqu'on imprime depuis la vue Document Unique */
    body.printing-du .sidebar,
    body.printing-du header,
    body.printing-du .no-print,
    body.printing-du #breadcrumb,
    body.printing-du .user-badge,
    body.printing-du .toast,
    body.printing-du .sidebar-footer {
        display: none !important;
    }
    body.printing-du .main-content {
        margin: 0 !important; padding: 0 !important; width: 100% !important;
    }
    body.printing-du #app-container { padding: 0 !important; }
    body.printing-du .du-doc {
        box-shadow: none !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    body.printing-du .du-edit {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        resize: none !important;
        min-height: 0 !important;
        /* Afficher le texte sans la boîte textarea */
        white-space: pre-wrap;
        overflow: visible;
    }
    body.printing-du .du-section { page-break-inside: avoid; }
    body.printing-du .du-cover { page-break-after: always; }
    body.printing-du table { page-break-inside: auto; font-size: 9pt; }
    body.printing-du tr { page-break-inside: avoid; }
}

/* ============================================================
   DOCUMENT UNIQUE — badges "source", mise en page tableau, auto-resize
   ============================================================ */
.du-section-head {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 6px; margin: 0 0 10px;
}
.du-section-head h2 {
    border: none !important; padding: 0 !important; margin: 0 !important;
    flex: 1; min-width: 200px;
}
.du-source {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 12px;
    font-size: 0.72rem; font-weight: 600;
    white-space: nowrap;
}
.du-source-edit {
    background: #dcfce7; color: #166534;
    border: 1px solid #86efac;
}
.du-source-link { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }
.du-source-link a {
    color: inherit; text-decoration: none; display: inline-flex; align-items: center;
}
.du-source-link:hover { background: #bae6fd; }
.du-help {
    font-size: 0.82rem; color: #6b7280; font-style: italic;
    margin: 4px 0 10px; padding: 8px 12px;
    background: #f9fafb; border-left: 3px solid #d1d5db;
    border-radius: 0 4px 4px 0;
}
.du-help-inline { color: #6b7280; font-size: 0.78rem; font-style: italic; }

/* Tableaux dans document unique : wrapper scrollable à l'écran, respiration en impression */
.du-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 8px 0;
}
.du-table-wrap table {
    min-width: 100%;
    width: max-content;
    font-size: 0.82rem;
    border-collapse: collapse;
}
.du-table-wrap th, .du-table-wrap td {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    vertical-align: top;
    word-break: break-word;
}
.du-table-wrap th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #374151;
    position: sticky; top: 0;
}
.du-plan-table th:first-child, .du-plan-table td:first-child { max-width: 320px; }

/* Textarea Document Unique : plus lisibles à l'écran */
.du-edit {
    overflow: hidden; /* évite la scrollbar interne — hauteur gérée en JS */
}

/* Masquer les badges "source" à l'impression — ils ne concernent que l'édition */
@media print {
    .du-source, .du-help, .du-help-inline { display: none !important; }
    .du-section-head { display: block; border-bottom: 1px solid var(--primary-color); }
    .du-section-head h2 { border: none !important; }
    /* Les tableaux impriment sans scroll — ils passent en pleine largeur avec police réduite */
    body.printing-du .du-table-wrap {
        overflow: visible !important;
    }
    body.printing-du .du-table-wrap table {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 8.5pt;
    }
    body.printing-du .du-table-wrap th,
    body.printing-du .du-table-wrap td {
        padding: 3px 4px;
    }
}


/* ============================================================
   PLAN DE PRÉVENTION (PAPRIPACT / liste d'actions)
   ============================================================ */
.pp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 14px; }
.pp-kpi { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 14px; }
.pp-kpi-val { font-size: 1.4rem; font-weight: 700; color: var(--primary-color); }
.pp-kpi-lbl { font-size: 0.78rem; color: var(--muted-color, #6b7280); margin-top: 2px; }
.pp-kpi-alert { border-color: #fca5a5; background: #fef2f2; }
.pp-kpi-alert .pp-kpi-val { color: #b91c1c; }
.pp-kpi-warn { border-color: #fcd34d; background: #fffbeb; }
.pp-kpi-warn .pp-kpi-val { color: #b45309; }
.pp-table { width: 100%; min-width: 1100px; font-size: 0.82rem; }
.pp-table td { vertical-align: top; }
.pp-missing { margin-top: 4px; font-size: 0.72rem; color: #b45309; font-weight: 600; }
.pp-sub { margin: 12px 0 4px; font-size: 0.9rem; color: var(--primary-color); }
.pp-gantt { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 0.78rem; table-layout: fixed; }
.pp-gantt th, .pp-gantt td { border: 1px solid #e5e7eb; padding: 4px; text-align: center; height: 22px; }
.pp-gantt th { background: #f3f4f6; font-weight: 600; }
.pp-gantt .pp-gantt-label { width: 32%; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-gantt td.pp-bar-plan { background: #0284c7; }
.pp-gantt td.pp-bar-done { background: #16a34a; }
.pp-gantt td.pp-bar-late { background: #dc2626; }
@media print {
    .pp-kpis { display: none !important; }
    .pp-gantt td.pp-bar-plan, .pp-gantt td.pp-bar-done, .pp-gantt td.pp-bar-late {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    body.printing-du .pp-table { min-width: 0 !important; font-size: 8pt; }
    body.printing-du .pp-gantt { min-width: 0 !important; font-size: 7.5pt; }
}

/* PAPRIPACT : impression en A4 paysage (10 colonnes exigées par l'art. L4121-3-1 III) */
@page pp-landscape { size: A4 landscape; margin: 12mm 10mm; }
@media print {
    body.printing-pp, body.printing-pp * { page: pp-landscape; }
    body.printing-pp #papripact-print .du-section { page-break-inside: auto; }
    body.printing-du .pp-table { table-layout: fixed; width: 100% !important; }
    body.printing-du .pp-table th, body.printing-du .pp-table td { word-break: normal; overflow-wrap: anywhere; hyphens: auto; }
    body.printing-du .pp-table th:nth-child(1), body.printing-du .pp-table td:nth-child(1) { width: 4%; }
    body.printing-du .pp-table th:nth-child(3), body.printing-du .pp-table td:nth-child(3) { width: 14%; }
    body.printing-du .pp-table th:nth-child(4), body.printing-du .pp-table td:nth-child(4) { width: 14%; }
    body.printing-du .pp-table th:nth-child(7), body.printing-du .pp-table td:nth-child(7) { width: 8%; }
    body.printing-du .pp-table th:nth-child(8), body.printing-du .pp-table td:nth-child(8) { width: 10%; white-space: normal !important; }
    body.printing-du .pp-table td:nth-child(7) { white-space: normal !important; }
}
@media print {
    body.printing-pp .du-cover { min-height: 0 !important; height: auto !important; padding-top: 6mm !important; padding-bottom: 0 !important; }
    body.printing-pp .du-cover-logo { margin-bottom: 4mm !important; }
    body.printing-pp .pp-table th { white-space: normal !important; overflow-wrap: normal; word-break: normal; font-size: 7pt; }
}

/* Matrice : case sans risque (échelle unique 3 niveaux, 05/11/2026) */
.risk-empty { background: #f1f5f9; color: #94a3b8; }
.matrix-cell.risk-empty .matrix-cell-count { color: #94a3b8; }

/* Document Unique : ne plus couper les mots n'importe où dans les tableaux (05/11/2026).
   Césure française propre (html lang="fr") ; seuls les mots plus longs que la colonne sont coupés. */
.du-table-wrap th, .du-table-wrap td { word-break: normal; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.du-table-wrap td { min-width: 3.2em; }
.du-table-wrap td:first-child, .du-table-wrap td:nth-child(2), .du-table-wrap td:nth-child(3) { min-width: 7.5em; }

/* ===== Forfaits (05/11/2026) ===== */
.nav-item.nav-locked { opacity: 0.62; }
.nav-item.nav-locked:hover { opacity: 0.85; }
.nav-lock { margin-left: auto; font-size: 0.8rem; line-height: 1; }
.user-badge-plan { font-size: 0.7rem; color: rgba(255,255,255,0.8); margin-top: 0.25rem; }
.up-wrap { text-align: left; }
.up-lock { font-size: 2rem; margin-bottom: 6px; }
.up-lead { color: var(--text-muted); margin: 6px 0 18px; max-width: 760px; }
.up-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.up-card { border: 1px solid var(--border-light); border-radius: 12px; padding: 18px; background: #fff; }
.up-card-title { font-weight: 700; margin-bottom: 10px; color: var(--primary-color); }
.up-list { list-style: none; padding: 0; margin: 0; }
.up-list li { padding: 6px 0 6px 24px; position: relative; border-bottom: 1px dashed var(--border-light); font-size: 0.92rem; }
.up-list li::before { content: "✓"; position: absolute; left: 4px; color: var(--secondary-color); font-weight: 800; }
.up-price-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: 0.93rem; }
.up-price-new strong { color: var(--primary-color); }
.up-prorata { margin-top: 12px; background: var(--color-info-bg); color: var(--color-info-text); border-radius: 10px; padding: 12px; font-size: 0.88rem; }
.up-prorata-val { font-size: 1.4rem; font-weight: 800; margin-bottom: 2px; }
.up-btn { display: inline-block; margin-top: 12px; text-decoration: none; }

/* Marque : NUMERICE (au-dessus) / DUERP & QHSE (05/11/2026) */
.brand-kicker { margin: 0 0 0.1rem; }
.brand-text .brand-title { white-space: nowrap; }

/* ===== Bandeau de démonstration (05/11/2026) ===== */
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; border-radius: 12px; padding: 10px 14px; margin-bottom: 1.25rem; font-size: 0.88rem; }
.demo-bar-txt { flex: 1 1 320px; }
.demo-bar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.demo-bar-label { font-weight: 600; }
.demo-plan { text-decoration: none; padding: 4px 10px; border-radius: 999px; border: 1px solid #f59e0b; color: #78350f; background: #fff; font-weight: 600; }
.demo-plan.on { background: #f59e0b; color: #fff; }
.demo-reset { background: none; border: 0; text-decoration: underline; color: #78350f; cursor: pointer; font: inherit; font-weight: 600; }

/* ===== Démonstration : documents marqués (05/11/2026) ===== */
.demo-doc-ribbon { background: #fef3c7; border: 1px dashed #f59e0b; color: #78350f; text-align: center; font-weight: 800; padding: 8px 10px; margin-bottom: 14px; border-radius: 8px; letter-spacing: 0.02em; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
@media print {
    body.is-demo::after {
        content: "DÉMONSTRATION\A DOCUMENT FICTIF SANS VALEUR";
        white-space: pre; line-height: 1.25;
        position: fixed; top: 50%; left: 50%;
        text-align: center; transform: translate(-50%, -50%) rotate(-30deg);
        font-size: 30pt; font-weight: 800; color: rgba(220, 38, 38, 0.22);
        z-index: 99999; pointer-events: none;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
}

/* ===== Sidebar : pied de menu collé sous la navigation + menu fixe au scroll ===== */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: flex-start;
    flex-shrink: 0;
    overflow-y: auto;
}
.nav-links { flex: 0 0 auto; }
@media print { .sidebar { position: static; height: auto; } }

/* ===== Inscription libre-service / abonnement (billing.js) ===== */
.auth-card.auth-card-wide { max-width: 760px; }
.auth-lead { color: #475569; font-size: 0.92rem; line-height: 1.55; margin: 0 0 1rem; }
.auth-section-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary-color); margin: 0.75rem 0 0.25rem; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.auth-grid .span2 { grid-column: 1 / -1; }
.auth-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 500; color: var(--text-main); }
.auth-grid input, .auth-grid select { width: 100%; }
.auth-check { flex-direction: row !important; align-items: flex-start; gap: 0.6rem !important; font-weight: 400 !important; font-size: 0.85rem !important; color: #475569 !important; }
.auth-check input { margin-top: 0.2rem; flex: 0 0 auto; width: auto; }
.auth-alt { margin-top: 1rem; font-size: 0.85rem; color: #475569; text-align: center; }
.auth-alt a, .auth-check a, .auth-fine a { color: var(--primary-color); font-weight: 600; }
.auth-fine { font-size: 0.78rem; color: #64748b; line-height: 1.5; margin: 0.25rem 0 0; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin: 0.5rem 0 1rem; }
.pick-card { display: block; border: 2px solid var(--border-color, #e2e8f0); border-radius: var(--radius-md, 10px); padding: 1rem 1.1rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; background: #fff; }
.pick-card { position: relative; overflow: hidden; }
.pick-card input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.pick-card.on { border-color: var(--primary-color); box-shadow: 0 6px 18px -8px rgba(13,95,64,0.35); background: #f0fdf4; }
.pick-name { font-weight: 800; font-size: 1.05rem; color: var(--text-main); }
.pick-price { margin-top: 0.35rem; font-size: 0.9rem; color: #334155; }
.pick-price strong { font-size: 1.5rem; color: var(--primary-color); }
.pick-sub { font-size: 0.78rem; color: #64748b; margin-bottom: 0.5rem; }
.pick-card ul { margin: 0; padding-left: 1.1rem; font-size: 0.82rem; color: #475569; line-height: 1.5; }
.pick-total { border: 1px solid var(--border-color, #e2e8f0); border-radius: var(--radius-md, 10px); padding: 0.75rem 1rem; font-size: 0.88rem; background: #f8fafc; }
.pick-total > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; color: #334155; }
.pick-total .pick-total-ttc { border-top: 1px solid var(--border-color, #e2e8f0); margin-top: 0.3rem; padding-top: 0.5rem; font-size: 1rem; }
.pick-total .pick-total-ttc strong { color: var(--primary-color); }
@media (max-width: 640px) {
  .auth-grid, .pick-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 1.5rem 1.1rem; }
}
.sub-box { border: 1px solid var(--border-color, #e2e8f0); border-radius: var(--radius-md, 10px); padding: 1rem 1.2rem; margin-top: 1rem; background: #fff; }
.sub-box .sub-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; font-size: 0.9rem; }

/* ===== Super-admin : utilisateurs, octroi d'accès, ressources offertes ===== */
.admin-search { width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--border-color, #e2e8f0); border-radius: var(--radius-md, 10px); margin-bottom: 1rem; font: inherit; }
.btn-link { background: none; border: none; color: var(--primary-color); font-weight: 600; cursor: pointer; padding: 0; font: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-block { display: block; width: 100%; margin-top: 0.6rem; }
.btn.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.sa-box { border: 1px solid var(--border-color, #e2e8f0); border-radius: var(--radius-md, 10px); padding: 1rem 1.1rem; margin-bottom: 1rem; font-size: 0.88rem; line-height: 1.5; }
.sa-box p { margin: 0.35rem 0; }
.sa-box-title { font-weight: 800; font-size: 1rem; margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.sa-grant { border: 2px solid #fcd34d; background: #fffbeb; }
.sa-grant .sa-box-title { color: #92400e; }
.sa-bonus { border: 2px solid #6ee7b7; background: #ecfdf5; }
.sa-bonus .sa-box-title { color: #065f46; }
.sa-tag { margin-left: auto; font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; background: #fde68a; color: #78350f; }
.sa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.6rem; }
.sa-grid label, .sa-full { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #334155; }
.sa-full { margin-top: 0.6rem; }
.sa-grid input, .sa-grid select, .sa-full input { font: inherit; font-size: 0.9rem; text-transform: none; letter-spacing: normal; font-weight: 400; padding: 0.55rem 0.7rem; border: 1px solid var(--border-color, #e2e8f0); border-radius: 8px; background: #fff; }
.sa-hist { margin-top: 0.6rem; font-size: 0.8rem; }
.sa-hist ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }
@media (max-width: 640px) { .sa-grid { grid-template-columns: 1fr; } }
.sa-identity { border: 2px solid #cbd5e1; background: #f8fafc; }
.sa-billing { border: 2px solid #fdba74; background: #fff7ed; }
.sa-billing .sa-box-title { color: #9a3412; }
.sa-pm { border: 2px solid #7dd3fc; background: #f0f9ff; }
.sa-pm .sa-box-title { color: #075985; }
.sa-grid .sa-span2 { grid-column: 1 / -1; }
.sa-box code { font-size: 0.78rem; background: #e2e8f0; padding: 0 0.3rem; border-radius: 4px; }
.sa-delete { border: 2px solid #fca5a5; background: #fef2f2; }
.sa-delete .sa-box-title { color: #991b1b; }
.sa-del-list { margin: 0.3rem 0 0.5rem; padding-left: 1.1rem; font-size: 0.85rem; }
