:root {
    --navy: #111d35;
    --navy-soft: #1c2b49;
    --blue: #246bfd;
    --bg: #f4f7fb;
    --text: #172033;
    --muted: #718096;
    --line: #e7ebf2;
    --white: #fff;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.guest-body {
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(circle at 15% 20%, rgba(36, 107, 253, .22), transparent 30%),
        linear-gradient(135deg, #0d1830, #17294b);
}

.guest-shell { width: min(100%, 1040px); }
.login-card {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    min-height: 610px;
    overflow: hidden;
    border-radius: 26px;
    background: var(--white);
    box-shadow: 0 28px 80px rgba(0, 0, 0, .28);
}

.login-visual {
    display: flex;
    align-items: flex-end;
    padding: 58px;
    color: white;
    background:
        linear-gradient(160deg, rgba(20, 45, 89, .2), rgba(8, 23, 50, .94)),
        radial-gradient(circle at 70% 20%, #2c72ff 0, #17386f 35%, #101d37 75%);
}
.login-visual-content { max-width: 430px; }
.eyebrow { display: block; margin-bottom: 12px; color: #6f9cff; font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.login-visual h1 { margin: 0 0 18px; font-size: clamp(36px, 4vw, 54px); line-height: 1.05; letter-spacing: -.04em; }
.login-visual p { max-width: 390px; margin: 0; color: #c8d5eb; font-size: 17px; line-height: 1.65; }
.login-form-panel { display: flex; flex-direction: column; justify-content: center; padding: 68px; }
.login-heading { display: flex; align-items: center; gap: 16px; margin-bottom: 42px; }
.brand-mark {
    display: grid;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 13px;
    color: white;
    background: linear-gradient(135deg, #377cff, #1756d8);
    box-shadow: 0 8px 18px rgba(36, 107, 253, .3);
    font-weight: 900;
}
.login-heading h2 { margin: 0 0 5px; font-size: 28px; }
.login-heading p, .form-note { margin: 0; color: var(--muted); }
.form { display: grid; gap: 22px; }
.form label { display: grid; gap: 8px; color: #3a465d; font-size: 13px; font-weight: 700; }
.form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #dce2eb;
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: #fbfcfe;
}
.form input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36, 107, 253, .1); }
.button { padding: 11px 18px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; }
.button-primary { color: white; background: var(--blue); box-shadow: 0 9px 20px rgba(36, 107, 253, .22); }
.button-secondary { color: #334155; background: #eef2f7; }
.button-block { width: 100%; margin-top: 6px; padding: 15px; }
.form-note { margin-top: 26px; font-size: 12px; text-align: center; }
.alert { margin-bottom: 22px; padding: 13px 15px; border-radius: 10px; font-size: 14px; }
.alert-error { color: #9f2736; border: 1px solid #f4c9d0; background: #fff0f2; }
.alert-success { color: #126b4d; border: 1px solid #bce8d8; background: #ebfaf5; }

.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    padding: 28px 18px 20px;
    color: #d9e2f2;
    background: var(--navy);
    overflow: hidden;
}
.brand {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 13px;
    padding: 0 9px 24px;
    color: white;
    font-size: 18px;
    font-weight: 850;
    text-decoration: none;
}
.brand-logo {
    display: block;
    height: 44px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}
.login-logo {
    display: block;
    height: 52px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
}
.nav {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { border-radius: 3px; background: rgba(255, 255, 255, .22); }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 10px; color: #aebbd0; font-size: 14px; font-weight: 650; }
.nav-link.active { color: white; background: var(--navy-soft); }
.nav-icon { display: grid; width: 24px; place-items: center; font-size: 19px; }
.sidebar-user { display: flex; flex-shrink: 0; align-items: center; gap: 11px; padding: 17px 10px 2px; border-top: 1px solid rgba(255, 255, 255, .09); }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: white; background: #335b9f; font-weight: 800; }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user strong { max-width: 145px; overflow: hidden; color: white; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { margin-top: 3px; color: #91a1bc; font-size: 11px; }
.page { min-width: 0; }
.topbar {
    display: flex;
    height: 78px;
    align-items: center;
    justify-content: space-between;
    padding: 0 34px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .9);
}
.topbar small, .topbar strong { display: block; }
.topbar small { margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.topbar strong { font-size: 15px; }
.content { max-width: 1600px; margin: 0 auto; padding: 34px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 22px; }
.kpi-card {
    position: relative;
    display: flex;
    min-height: 128px;
    align-items: center;
    gap: 17px;
    overflow: hidden;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
    box-shadow: 0 7px 22px rgba(24, 40, 72, .04);
}
.kpi-card::before { position: absolute; top: 0; right: 0; left: 0; height: 3px; content: ""; background: var(--accent); }
.kpi-icon { display: grid; width: 46px; height: 46px; flex: 0 0 46px; place-items: center; border-radius: 13px; color: var(--accent); background: var(--accent-soft); font-size: 20px; font-weight: 900; }
.kpi-card small, .kpi-card strong { display: block; }
.kpi-card small { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-card strong { font-size: 28px; letter-spacing: -.03em; }
.accent-blue { --accent: #246bfd; --accent-soft: #eaf1ff; }
.accent-violet { --accent: #7559e8; --accent-soft: #f0edff; }
.accent-green { --accent: #19a974; --accent-soft: #e8f8f2; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 7px 22px rgba(24, 40, 72, .04); }

/* Panneau « Recherche et Filtres » du tableau de bord */
.search-panel { margin-bottom: 22px; }
.search-panel-header { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.search-panel-header h2 { margin: 0; font-size: 16px; }
.search-form { padding: 18px 22px 22px; }
.search-form-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 26px; }
.search-form-col { display: flex; flex-direction: column; gap: 12px; }
.search-form .form-group { display: flex; flex-direction: column; gap: 5px; }
.search-form .form-group[hidden] { display: none !important; }
.search-form .form-group label { color: #3a465d; font-size: 12px; font-weight: 700; }
.search-form .form-group input[type="text"],
.search-form .form-group input[type="datetime-local"],
.search-form .form-group select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #dce2eb;
    border-radius: 8px;
    outline: none;
    color: var(--text);
    background: #fbfcfe;
    font-size: 13px;
}
.search-form .form-group input:focus,
.search-form .form-group select:focus { border-color: var(--blue); }
.search-form .form-group-inline { flex-direction: row; align-items: center; gap: 8px; }
.search-form .form-group-inline label { margin: 0; }
.date-input-with-now { display: flex; align-items: center; gap: 8px; }
.date-input-with-now input { flex: 1; }
.btn-now {
    padding: 8px 10px;
    border: 1px solid #dce2eb;
    border-radius: 8px;
    background: #f1f5fb;
    color: #2756a8;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.btn-now:hover { background: #e3ecf9; }
.search-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.btn-search {
    padding: 11px 22px;
    border: 0;
    border-radius: 9px;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
    cursor: pointer;
}
.btn-search:hover { filter: brightness(1.08); }
.btn-reset {
    padding: 11px 18px;
    border: 1px solid #dce2eb;
    border-radius: 9px;
    background: #fff;
    color: #3a465d;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.btn-reset:hover { background: #f1f3f7; }

/* Recherche rapide + compteur de résultats */
.quick-search-container { position: relative; display: flex; align-items: center; margin: 18px 22px 0; }
.quick-search-icon { position: absolute; left: 12px; color: #666; pointer-events: none; }
.quick-search-input {
    width: 100%;
    padding: 10px 38px 10px 36px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}
.quick-search-input:focus { border-color: var(--blue); }
.quick-search-clear {
    position: absolute;
    right: 8px;
    padding: 4px;
    border: 0;
    background: transparent;
    color: #666;
    cursor: pointer;
}
.results-header { padding: 14px 22px 4px; }
.results-header h2 { margin: 0; font-size: 16px; }
.page-header { display: flex; justify-content: space-between; margin-bottom: 24px; }
.page-header .eyebrow { margin: 0 0 8px; }
.page-header h1 { margin: 0 0 7px; font-size: 27px; }
.page-header p { margin: 0; color: var(--muted); }
.profile-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 17px; }
.badge { padding: 5px 9px; border-radius: 999px; color: #2756a8; background: #ebf2ff; font-size: 11px; font-weight: 750; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 22px; }
.form-stack { display: grid; gap: 18px; padding: 22px; }
.form-grid label, .form-stack label { display: grid; gap: 7px; color: #3a465d; font-size: 12px; font-weight: 700; }
.form-grid input, .form-grid select, .form-stack input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #dce2eb;
    border-radius: 9px;
    outline: none;
    color: var(--text);
    background: #fbfcfe;
}
.form-grid input:focus, .form-grid select:focus, .form-stack input:focus { border-color: var(--blue); }
.form-grid input:disabled { color: #7b8495; background: #f1f3f7; }
.form-actions { grid-column: 1 / -1; }
.form-grid .button, .form-stack .button { color: white; background: var(--blue); }
.validation-panel .validation-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.validation-panel label { display: grid; gap: 7px; color: #3a465d; font-size: 12px; font-weight: 700; }
.validation-panel input, .validation-panel select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dce2eb;
    border-radius: 8px;
    background: #fbfcfe;
}
.validation-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.btn-cancel { padding: 10px 14px; border: 0; border-radius: 8px; color: #7f1d1d; background: #fee2e2; cursor: pointer; font-weight: 700; }
.notif-badge {
    display: inline-grid;
    min-width: 18px;
    height: 18px;
    place-items: center;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 999px;
    color: white;
    background: #ef4444;
    font-size: 10px;
    font-weight: 800;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-link { color: #334155; font-size: 13px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 11px 12px; border-bottom: 1px solid rgba(255, 255, 255, .55); text-align: left; font-size: 12px; }
th { color: #566173; background: #fff; border-bottom: 1px solid var(--line); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; }
td { color: #3a4557; }
td strong { color: #1f2a3d; text-transform: uppercase; }
.fiche-row td { border-bottom: 1px solid rgba(0, 0, 0, .05); }
.etat-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.produit-badge {
    display: inline-block;
    min-width: 34px;
    padding: 5px 8px;
    border-radius: 4px;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    text-align: center;
}
.valide-cell, .actions-cell { text-align: center; }
.valide-check { color: #28a745; font-size: 16px; font-weight: 900; }
.valide-empty { color: #9aa4b2; }
.btn-detail {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(36, 107, 253, .28);
}
.btn-detail:hover { filter: brightness(1.08); }
.empty { padding: 34px; color: var(--muted); text-align: center; }

/* Modal détail fiche */
body.fiche-modal-open { overflow: hidden; }
.fiche-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(13, 24, 48, .55);
    overflow: hidden;
}
.fiche-modal-overlay[hidden] { display: none; }
.fiche-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(100%, 980px);
    max-height: min(82dvh, calc(100svh - 48px));
    min-height: 0;
    overflow: hidden;
    border: 8px solid #3498db;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.fiche-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}
.fiche-modal-banner {
    flex: 0 0 auto;
    padding: 16px 24px;
    background: var(--navy);
    color: #fff;
    font-size: 15px;
    font-weight: 850;
    letter-spacing: .12em;
}
.fiche-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.fiche-modal-body {
    padding: 20px;
}

/* Mobile : modal dimensionné sur la zone visible (pinch-zoom), overlay plein écran */
body.fiche-modal-open--viewport-sync {
    overflow: auto !important;
    touch-action: pan-x pan-y pinch-zoom !important;
}

body.fiche-modal-open--viewport-sync .fiche-modal-overlay {
    /* overlay reste inset:0 — seul le modal est repositionné/redimensionné en JS */
    touch-action: pan-x pan-y pinch-zoom !important;
}

.fiche-modal.fiche-modal--viewport-sync {
    width: var(--fiche-modal-width-px, 88%) !important;
    max-width: var(--fiche-modal-width-px, 88%) !important;
    max-height: var(--fiche-modal-height-px, 82%) !important;
}

html.viewport-zoomed body.fiche-modal-open .fiche-modal-overlay {
    z-index: 3000;
}

/* En-tête du détail (badge produit + titre + pill état) — comme FicheDetail */
.fiche-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}
.fiche-detail-header-title { display: flex; align-items: center; gap: 12px; }
.fiche-detail-header h1 { margin: 0; color: #2c3e50; font-size: 21px; }
.fiche-type-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 800;
}
.fiche-detail-etat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12);
}

/* Sections type FicheDetail : titre sombre centré + tableau label/valeur gris */
.fiche-section {
    margin-bottom: 18px;
    padding: 16px;
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
}
.section-title {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px;
    padding: 11px 14px;
    border-bottom: 2px solid #9cbfc8;
    border-radius: 4px;
    background-color: #332e2e;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
}
.fiche-details-table { width: 100%; border-collapse: collapse; white-space: normal; }
.fiche-details-table tr { border-bottom: 1px solid #8a8a8a; background-color: #ebebeb; }
.fiche-details-table tr:last-child { border-bottom: 0; }
.fiche-details-table .field-label {
    width: 34%;
    padding: 10px 12px;
    border-bottom: 0;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    vertical-align: top;
}
.fiche-details-table .field-value {
    padding: 10px 12px;
    border-bottom: 0;
    color: #1c2331;
    font-size: 13px;
    word-break: break-word;
}
.fiche-details-table .field-actions {
    width: 44px;
    padding: 10px 12px;
    text-align: right;
    vertical-align: top;
}

/* Modification rapide des champs */
.field-edit-btn {
    padding: 3px 8px;
    border: 1px solid #b8bcc4;
    border-radius: 5px;
    background: #fff;
    color: #1c2331;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.field-edit-btn:hover { background: #eef1f6; border-color: #8a8f99; }
.field-edit-btn-inline {
    margin-left: 8px;
    vertical-align: middle;
    background: rgba(255, 255, 255, .9);
}
.field-edit-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-edit-input {
    min-width: 140px;
    max-width: 100%;
    padding: 5px 8px;
    border: 1px solid #8a8f99;
    border-radius: 5px;
    font-size: 13px;
}
textarea.field-edit-input { min-width: 220px; resize: vertical; }
.field-edit-save, .field-edit-cancel {
    padding: 4px 9px;
    border: 0;
    border-radius: 5px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
}
.field-edit-save { background: #16a34a; }
.field-edit-cancel { background: #b91c1c; }
.field-edit-save:disabled, .field-edit-cancel:disabled { opacity: .55; cursor: default; }
.field-edit-feedback { font-size: 12px; color: #6b7280; }
.field-edit-feedback.error { color: #b91c1c; }
.etat-actuel-badge-wrap { display: inline-block; }

/* Carte « État actuel » : fond gris foncé + texte blanc gras */
.etat-actuel-card {
    padding: 18px;
    border: 6px solid #000;
    border-radius: 8px;
    background-color: #3a3a3a;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
}
.etat-actuel-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 14px;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}
.etat-actuel-badge-header { margin-bottom: 4px; }
.etat-actuel-cr { margin-right: 4px; }
.etat-actuel-sous-badge {
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .25);
    font-size: 12px;
    font-weight: 800;
    text-transform: none;
}
.etat-actuel-badge-date {
    margin-left: auto;
    font-size: 14px;
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
}
.etat-actuel-details { margin-top: 4px; font-size: 13px; line-height: 1.45; }
.etat-actuel-details-title {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
}
.etat-actuel-details-list { display: flex; flex-direction: column; gap: 10px; }
.etat-actuel-detail-row { color: #fff; font-weight: 700; word-break: break-word; }
.etat-actuel-detail-row--full .etat-detail-val { display: block; margin-top: 4px; white-space: pre-wrap; }
.etat-detail-val--commercial { color: #93c5fd; font-weight: 800; }
.etat-detail-val--confirmateur { color: #fca5a5; font-weight: 800; }
.etat-detail-val--rdv {
    display: inline-block;
    padding: 2px 8px;
    border: 4px solid #15803d;
    border-radius: 6px;
    background: #f0fdf4;
    color: #15803d;
    font-weight: 800;
}
.etat-actuel-lines { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; line-height: 1.45; }
.etat-actuel-date-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 5px;
    background-color: #4a4a4a;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
}
.etat-actuel-validation-badge {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 14px;
    border: 2px solid #16a34a;
    border-radius: 6px;
    background-color: #4a4a4a;
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
}

/* Barre d'onglets du détail fiche (Fiches / Modifica / Affectation / Planning / SMS / PDF) */
.fiche-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--line);
}
.fiche-tab {
    padding: 9px 16px;
    border: 1px solid #d5dbe4;
    border-radius: 6px 6px 0 0;
    background: #eef1f5;
    color: #4a5568;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.fiche-tab:hover { background: #e2e8f0; }
.fiche-tab.active {
    border-color: var(--navy);
    background: var(--navy);
    color: #fff;
}

/* Tableaux des onglets Modifica / SMS / Affectation / Planning */
.tab-table-wrap { overflow-x: auto; }
.tab-table { width: 100%; border-collapse: collapse; white-space: normal; }
.tab-table th {
    padding: 9px 11px;
    border: 1px solid #c9ced6;
    background: #332e2e;
    color: #fff;
    font-size: 11px;
    text-transform: uppercase;
    text-align: left;
}
.tab-table td {
    padding: 8px 11px;
    border: 1px solid #c9ced6;
    background: #f7f8fa;
    color: #2a3345;
    font-size: 12.5px;
    vertical-align: top;
}
.tab-table tr:nth-child(even) td { background: #eef0f4; }
.sms-message { max-width: 380px; white-space: pre-wrap; word-break: break-word; }

/* Onglet Affectation */
.affectation-current { margin: 0 0 6px; color: #333; font-size: 14px; }
.affectation-help { margin: 0 0 16px; color: #666; font-size: 13px; }
.affectation-form { display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.affectation-form label { color: #3a465d; font-size: 13px; font-weight: 700; }
.affectation-form select {
    padding: 10px 12px;
    border: 1px solid #d5dbe4;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
}
.btn-save {
    padding: 11px 18px;
    border: 0;
    border-radius: 8px;
    background: #27ae60;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.btn-save:disabled { opacity: .6; cursor: wait; }
.affectation-feedback { font-size: 13px; font-weight: 700; }
.affectation-feedback.ok { color: #1e8e4e; }
.affectation-feedback.ko { color: #c0392b; }

/* Onglet Planning */
.planning-tab.is-loading { opacity: .55; pointer-events: none; }
.planning-tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}
.planning-tab-header h2 { margin: 0; color: #668994; font-size: 18px; }
.planning-tab-header h2 small { color: #6b7280; font-size: 12px; font-weight: 500; }
.planning-week-navigation { display: flex; align-items: center; gap: 10px; }
.planning-week-navigation strong { color: #303a4d; font-size: 13px; white-space: nowrap; }
.planning-nav-btn {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: var(--navy);
    color: #fff;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}
.planning-day-header { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.planning-day-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px;
    border-radius: 6px;
    background: #fff;
}
.planning-day-input {
    width: 45px;
    height: 27px;
    padding: 0 4px;
    border: 1px solid #cbd2dc;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}
.planning-day-save,
.planning-slot-save {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #4caf50;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
}
.planning-table td { min-width: 128px; }
.planning-edit-cell {
    position: relative;
    height: 118px;
    padding-top: 37px !important;
    vertical-align: top !important;
}
.planning-slot-name { font-weight: 700; white-space: nowrap; }
.planning-cell-free { background: rgba(76, 175, 80, .13) !important; }
.planning-cell-partial { background: rgba(255, 193, 7, .22) !important; }
.planning-cell-full { background: rgba(244, 67, 54, .19) !important; }
.planning-cell-closed { background: rgba(34, 45, 50, .78) !important; color: #fff !important; }
.planning-cell-toolbar {
    position: absolute;
    top: 5px;
    right: 5px;
    left: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.planning-ratio {
    min-width: 38px;
    padding: 3px 7px;
    border-radius: 4px;
    background: #fff;
    color: #111827;
    font-size: 15px;
    font-weight: 900;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}
.planning-toggle-closed {
    width: 25px;
    height: 25px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, .92);
    cursor: pointer;
}
.planning-toggle-closed.is-closed { background: #fee2e2; }
.planning-availability-controls {
    position: absolute;
    top: 6px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 3px;
    transform: translateX(-50%);
}
.planning-slot-input {
    width: 36px;
    height: 25px;
    padding: 0 3px;
    border: 1px solid #cbd2dc;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    text-align: center;
}
.planning-rdv {
    margin-bottom: 5px;
    padding: 5px 7px;
    border-left: 3px solid #00cc00;
    border-radius: 4px;
    background: #fff;
    font-size: 11.5px;
    font-weight: 600;
}
.planning-rdv small { display: block; color: #718096; font-weight: 500; }
.planning-closed-label {
    display: block;
    margin-top: 16px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}
.planning-feedback { min-height: 18px; margin: 10px 0 0; font-size: 12px; font-weight: 700; }
.planning-feedback.ok { color: #1e8e4e; }
.planning-feedback.ko { color: #c0392b; }
.planning-legend { margin: 12px 0 0; color: #718096; font-size: 12px; }

/* Onglet PDF */
.btn-pdf {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    background: #e74c3c;
    color: #fff !important;
    font-size: 13.5px;
    font-weight: 700;
}
.pdf-preview {
    margin-top: 18px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}
.pdf-preview h3 { margin: 0 0 10px; color: #2c3e50; font-size: 14px; }
.pdf-preview p { margin: 0 0 6px; color: #444; font-size: 13px; }

/* Historique des états : barre cliquable + liste repliée */
.historique-title-bar {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 15px;
    border: 1px solid #000;
    border-radius: 6px;
    margin: 0 0 15px;
    background-color: #000;
    color: #fff;
    font-size: 14.5px;
    font-weight: 700;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.historique-title-bar:hover { background-color: #1a1a1a; }
.historique-toggle-icon {
    flex: 0 0 auto;
    font-size: 12px;
    transition: transform .15s ease;
}
.historique-title-bar.is-open .historique-toggle-icon {
    transform: rotate(180deg);
}
.historique-list[hidden] { display: none !important; }
.historique-list { display: flex; flex-direction: column; gap: 12px; }
.historique-item {
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .25);
    border-radius: 8px;
    background-color: #3a3a3a;
    box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
}
.historique-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    font-weight: 700;
}
.historique-etat { font-size: 14px; text-transform: uppercase; }
.historique-sous-etat {
    padding: 3px 9px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .22);
    font-size: 12px;
    font-weight: 700;
}
.historique-date { margin-left: auto; font-size: 12.5px; }
.historique-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}
.historique-detail-row {
    width: 100%;
    line-height: 1.45;
    color: #fff;
}
.historique-detail-row strong { color: #fff; font-weight: 800; }
.historique-detail-row--full .etat-detail-val {
    display: block;
    margin-top: 4px;
    white-space: pre-wrap;
}

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

@media (max-width: 760px) {
    .guest-body { padding: 16px; }
    .login-card { grid-template-columns: 1fr; min-height: auto; }
    .login-visual { display: none; }
    .login-form-panel { padding: 44px 28px; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 15px 18px; flex-direction: row; align-items: center; }
    .sidebar .brand { padding: 0; }
    .sidebar .nav, .sidebar-user { display: none; }
    .topbar { height: 68px; padding: 0 18px; }
    .content { padding: 24px 18px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

/* App mobile : vue desktop, scroll unique sur toute la page */
html.dashboard-page.dashboard-page--table-desktop-view.dashboard-page--extranet-scroll:not([data-desktop-viewport]),
body.dashboard-page.dashboard-page--table-desktop-view.dashboard-page--extranet-scroll:not([data-desktop-viewport]) {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    height: auto;
    min-height: 100%;
    overscroll-behavior: auto !important;
    touch-action: pan-x pan-y pinch-zoom !important;
    -webkit-overflow-scrolling: touch;
}

@supports (-webkit-touch-callout: none) {
    html.dashboard-page.dashboard-page--extranet-scroll,
    body.dashboard-page.dashboard-page--extranet-scroll {
        min-height: -webkit-fill-available;
    }
}

body.dashboard-page--extranet-scroll .app-shell,
body.dashboard-page--extranet-scroll .page,
body.dashboard-page--extranet-scroll .content {
    min-width: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    overscroll-behavior: none !important;
}

body.dashboard-page--extranet-scroll .app-shell {
    min-width: 1648px !important;
    width: max-content !important;
}

body.dashboard-page--extranet-scroll .page {
    min-width: 1400px !important;
    width: auto !important;
}

body.dashboard-page--extranet-scroll .content {
    margin: 0 !important;
    width: auto !important;
}

body.dashboard-page--extranet-scroll .panel,
body.dashboard-page--extranet-scroll .fiche-results-panel,
body.dashboard-page--extranet-scroll .planning-results {
    overflow: visible !important;
}

body.dashboard-page--extranet-scroll .table-wrap,
body.dashboard-page--extranet-scroll .fiche-table-wrap,
body.dashboard-page--extranet-scroll .planning-table-wrap {
    overflow: visible !important;
    width: auto !important;
    max-width: none !important;
}

@media (max-width: 760px) {
    body.dashboard-page--table-desktop-view .app-shell {
        grid-template-columns: 248px 1fr !important;
    }
    body.dashboard-page--table-desktop-view .sidebar {
        position: sticky !important;
        top: 0 !important;
        height: 100vh !important;
        padding: 28px 18px 20px !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    body.dashboard-page--table-desktop-view .sidebar .brand {
        padding: 0 9px 30px !important;
    }
    body.dashboard-page--table-desktop-view .sidebar .nav,
    body.dashboard-page--table-desktop-view .sidebar-user {
        display: flex !important;
    }
    body.dashboard-page--table-desktop-view .sidebar-user {
        flex-direction: row !important;
    }
}

body.dashboard-page--table-desktop-view .fiches-table,
body.dashboard-page--table-desktop-view .fiche-list-table,
body.dashboard-page--table-desktop-view .planning-table {
    min-width: 1400px !important;
    width: max-content !important;
    max-width: none !important;
    table-layout: fixed !important;
}

body.dashboard-page--table-desktop-view .fiches-table th,
body.dashboard-page--table-desktop-view .fiches-table td,
body.dashboard-page--table-desktop-view .fiche-list-table th,
body.dashboard-page--table-desktop-view .fiche-list-table td,
body.dashboard-page--table-desktop-view .planning-table th,
body.dashboard-page--table-desktop-view .planning-table td {
    white-space: nowrap;
}

body.dashboard-page--table-desktop-view .search-form-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

/* iOS : recherche + filtres empilés sur le même côté (gauche) */
@supports (-webkit-touch-callout: none) {
    body.dashboard-page .search-form {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    body.dashboard-page .search-form-columns {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        width: 100%;
        max-width: 420px;
        gap: 12px !important;
        grid-template-columns: none !important;
    }

    body.dashboard-page .search-form-col {
        width: 100%;
        max-width: 420px;
    }

    body.dashboard-page .search-form .form-group {
        width: 100%;
    }

    body.dashboard-page .search-form .form-group input[type="text"],
    body.dashboard-page .search-form .form-group input[type="datetime-local"],
    body.dashboard-page .search-form .form-group select {
        width: 100%;
        max-width: 360px;
    }

    body.dashboard-page .search-form .date-input-with-now {
        width: 100%;
        max-width: 360px;
    }

    body.dashboard-page .search-form-actions {
        justify-content: flex-start;
        width: 100%;
        max-width: 420px;
    }
}
