* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, sans-serif; color: #222; background: #f5f6f8; }
.app { display: flex; height: 100vh; }

.sidebar {
    width: 240px; background: #1f2937; color: #fff; padding: 20px 0;
    display: flex; flex-direction: column;
}
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 20px 8px; border-bottom: 1px solid #374151; padding-bottom: 12px;
}
.sidebar-header h1 { margin: 0; font-size: 18px; }
.sync-form { margin: 0; }
.sync-btn {
    display: flex; align-items: center; gap: 5px;
    background: #374151; border: none; color: #d1d5db;
    padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
    transition: background .15s;
}
.sync-btn:hover { background: #4b5563; color: #fff; }
.sync-btn.loading svg { animation: spin .8s linear infinite; }
.sync-status {
    margin: 0 20px 10px; font-size: 11px; color: #6b7280;
    display: flex; align-items: center; gap: 5px;
}
.sync-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #10b981; display: inline-block; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sidebar nav a {
    display: block; padding: 12px 20px; color: #d1d5db; text-decoration: none;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #374151; color: #fff; }
.sidebar nav a.active { background: #111827; color: #fff; border-left-color: #3b82f6; }
.sidebar .nav-icon { vertical-align: -3px; margin-right: 6px; }
.user-logout svg { display: block; }

.sidebar { display: flex; flex-direction: column; }
.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar-user {
    border-top: 1px solid #374151; padding: 14px 16px;
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: #3b82f6; color: #fff; display: flex;
    align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { color: #9ca3af; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout {
    color: #9ca3af; text-decoration: none; font-size: 18px;
    padding: 4px 8px; border-radius: 4px;
}
.user-logout:hover { background: #374151; color: #ef4444; }

/* Login page */
.login-page {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    min-height: 100vh; margin: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: -apple-system, Segoe UI, Roboto, sans-serif;
}
.login-box {
    background: #fff; padding: 40px; border-radius: 12px;
    width: 100%; max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.login-box h1 { margin: 0 0 8px; font-size: 22px; color: #111827; }
.login-box .muted { margin: 0 0 24px; color: #6b7280; font-size: 14px; }
.login-box label { display: block; margin-bottom: 14px; }
.login-box label span { display: block; font-size: 12px; color: #374151; font-weight: 600; margin-bottom: 4px; }
.login-box input {
    width: 100%; padding: 10px 12px; border: 1px solid #d1d5db;
    border-radius: 6px; font-size: 14px; box-sizing: border-box;
}
.login-box input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.login-box button {
    width: 100%; margin-top: 10px; padding: 10px;
    font-size: 14px; font-weight: 600;
}
.sidebar .label { display: block; font-weight: 600; }
.sidebar .addr { display: block; font-size: 11px; color: #9ca3af; margin-top: 2px; margin-left: 22px; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    padding: 16px 24px; background: #fff; border-bottom: 1px solid #e5e7eb;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.topbar-info { flex: 0 0 auto; }
.search { display: flex; gap: 8px; align-items: center; flex: 1; max-width: 500px; }
.search input[type=search] {
    flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; outline: none;
}
.search input[type=search]:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.search button {
    padding: 8px 16px; background: #3b82f6; color: #fff; border: 0;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.search button:hover { background: #2563eb; }
.search .clear {
    color: #6b7280; text-decoration: none; font-size: 16px;
    width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.search .clear:hover { background: #f3f4f6; }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar .addr-top { font-size: 13px; color: #6b7280; margin-top: 2px; }

.error { margin: 16px 24px; padding: 12px; background: #fee2e2; color: #991b1b; border-radius: 6px; }
.error pre { white-space: pre-wrap; margin: 6px 0 0; font-size: 12px; }

.content { flex: 1; display: flex; overflow: hidden; }
.list { width: 380px; overflow-y: auto; background: #fff; border-right: 1px solid #e5e7eb; }
.item {
    display: block; padding: 12px 16px; border-bottom: 1px solid #f3f4f6;
    text-decoration: none; color: #222;
}
.item:hover { background: #f9fafb; }
.item.active { background: #eff6ff; }
.item.unread { background: #fefce8; }
.item.unread .subject { font-weight: 700; }
.item .row1 { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.item .from { font-weight: 600; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.item .date { color: #6b7280; font-size: 12px; flex-shrink: 0; }
.item .subject { font-size: 14px; margin-bottom: 2px; }
.item .preview { font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .clip { font-size: 12px; }

.viewer { flex: 1; overflow-y: auto; background: #fff; display: flex; flex-direction: column; }
.msg-head { padding: 20px 24px; border-bottom: 1px solid #e5e7eb; }
.msg-head h3 { margin: 0 0 10px; }
.msg-head .meta { font-size: 13px; color: #4b5563; line-height: 1.7; }
.msg-body { flex: 1; padding: 0; }
.msg-body iframe { width: 100%; height: 100%; border: 0; }
.msg-body pre { padding: 20px 24px; white-space: pre-wrap; font-family: inherit; margin: 0; }

.empty { padding: 40px; text-align: center; color: #9ca3af; }

.attachments {
    padding: 12px 24px; background: #f9fafb; border-bottom: 1px solid #e5e7eb;
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px;
}
.attachments strong { margin-right: 8px; color: #374151; }
.att {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: #fff; border: 1px solid #d1d5db;
    border-radius: 6px; text-decoration: none; color: #111827;
}
.att:hover { background: #eff6ff; border-color: #3b82f6; }
.att .size { color: #6b7280; font-size: 12px; }

/* Sidebar separator */
.nav-sep { height: 1px; background: #374151; margin: 12px 20px; }

/* Pages "single column" (dossiers, dossier, email) */
.content-single { padding: 20px 24px; overflow-y: auto; flex: 1; background: #f5f6f8; }

/* Filters bar */
.filters { padding: 12px 24px; background: #fff; border-bottom: 1px solid #e5e7eb; display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 4px 12px; border-radius: 999px; background: #f3f4f6; color: #374151;
    text-decoration: none; font-size: 13px;
}
.chip:hover { background: #e5e7eb; }
.chip.active { background: #3b82f6; color: #fff; }

/* Table */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #f3f4f6; font-size: 14px; }
.table th { background: #f9fafb; color: #6b7280; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:hover td { background: #fafbfc; }
.table tr.row-link { cursor: pointer; }
.table tr.row-link:hover td { background: #eff6ff; }
.table td.muted { color: #9ca3af; font-size: 12px; }
.table .btn-link { color: #3b82f6; text-decoration: none; font-weight: 500; }
.table .btn-link:hover { text-decoration: underline; }

/* PJ presence indicators */
.pj-cell { display: flex; gap: 4px; }
.pj {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 4px; font-size: 11px; font-weight: 700;
}
.pj.on  { background: #10b981; color: #fff; }
.pj.off { background: #e5e7eb; color: #9ca3af; }

/* Status badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.badge-conformite-conforme    { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; font-weight: 600; }
.badge-conformite-non_conforme { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; font-weight: 600; }
.conformite-badge             { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.conformite-conforme          { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.conformite-non_conforme      { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge.status-pending        { background: #fef3c7; color: #92400e; }
.badge.status-sent_odoo      { background: #dbeafe; color: #1e40af; }
.badge.status-attente_trame  { background: #ede9fe; color: #5b21b6; }
.badge.status-complet        { background: #d1fae5; color: #065f46; }
.badge.status-terminé        { background: #a7f3d0; color: #064e3b; font-weight:700; }
.badge.status-error          { background: #fee2e2; color: #991b1b; }
.badge.status-manual         { background: #e5e7eb; color: #374151; }
.badge-warning          { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-box              { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.badge-garde-meuble     { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; font-weight: 600; }
.badge-sm               { font-size: 0.65rem; padding: 1px 5px; vertical-align: middle; }
.badge.class-new        { background: #dbeafe; color: #1e40af; }
.badge.class-existing   { background: #d1fae5; color: #065f46; }
.badge.class-exchange   { background: #fef3c7; color: #92400e; }
.badge.class-manual     { background: #e5e7eb; color: #374151; }
.badge.class-unknown    { background: #f3f4f6; color: #6b7280; }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.pagination a { padding: 6px 12px; background: #fff; border: 1px solid #d1d5db; border-radius: 6px; text-decoration: none; color: #374151; font-size: 13px; }
.pagination a:hover { background: #f3f4f6; }
.pagination a.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

/* Dossier detail */
.back-link { color: #6b7280; text-decoration: none; margin-right: 10px; font-size: 14px; }
.back-link:hover { color: #3b82f6; }
.devis-tag {
    display: inline-block; margin-left: 10px; padding: 3px 10px;
    background: #3b82f6; color: #fff; border-radius: 4px; font-size: 13px; font-weight: 600;
}
.actions { display: flex; gap: 10px; align-items: center; }
.btn-odoo, .btn-secondary {
    padding: 8px 16px; border-radius: 6px; border: 0; cursor: pointer; font-size: 14px;
}
.btn-odoo { background: #8b5cf6; color: #fff; }
.btn-odoo:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #f3f4f6; }

.card {
    background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card h3 { margin: 0 0 16px; font-size: 16px; color: #111827; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h3 { margin: 0; }
.card-warning { background: #fffbeb; border-color: #fef3c0; }
.card-warning h3 { color: #92400e; }
.card-gm-banner { background: #fff7ed; border-color: #fdba74; padding: 12px 16px; }
.gm-banner-content { display: flex; align-items: center; gap: 10px; }
.gm-banner-icon { font-size: 1.4rem; }
.gm-linked-sep { margin: 0 4px; color: #9ca3af; }
.gm-linked-link { font-weight: 600; color: #1d4ed8; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.gm-linked-link:hover { text-decoration: underline; }

/* Spinner dans le bouton */
.btn-primary .btn-spinner,
.btn-odoo .btn-spinner,
.btn-secondary .btn-spinner {
    display: none;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    margin-left: 8px;
    animation: btn-spin 0.7s linear infinite;
    vertical-align: middle;
}
.btn-secondary .btn-spinner {
    border: 2px solid rgba(55,65,81,0.3);
    border-top-color: #374151;
}
.btn-primary.loading .btn-spinner,
.btn-odoo.loading .btn-spinner,
.btn-secondary.loading .btn-spinner { display: inline-block; }
.btn-primary.loading,
.btn-odoo.loading,
.btn-secondary.loading { opacity: 0.85; cursor: wait; }
.btn-primary:disabled,
.btn-odoo:disabled,
.btn-secondary:disabled { cursor: wait; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Tag Odoo dossier number */
.odoo-tag {
    display: inline-block; margin-left: 8px; padding: 3px 10px;
    background: #8b5cf6; color: #fff; border-radius: 4px; font-size: 13px; font-weight: 600;
}
.odoo-tag-sm {
    display: inline-block; padding: 2px 8px;
    background: #8b5cf6; color: #fff; border-radius: 4px; font-size: 12px; font-weight: 600;
    white-space: nowrap;
}

.odoo-resp-meta { font-size: 14px; line-height: 1.8; }
.odoo-resp-meta code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
.json-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.json-pair h4 { font-size: 12px; text-transform: uppercase; color: #6b7280; margin: 0 0 6px; }
.json-box {
    background: #1f2937; color: #e5e7eb; padding: 12px; border-radius: 6px;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
    max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
@media (max-width: 800px) { .json-pair { grid-template-columns: 1fr; } }

.attachments-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.attachment-slot { padding: 14px; border-radius: 8px; border: 2px dashed #e5e7eb; }
.attachment-slot.present { border-style: solid; border-color: #10b981; background: #f0fdf4; }
.attachment-slot.missing { background: #f9fafb; }
.attachment-slot .slot-label { font-size: 11px; text-transform: uppercase; color: #6b7280; margin-bottom: 6px; font-weight: 600; }
.attachment-slot .missing-label { color: #9ca3af; font-style: italic; font-size: 13px; }
.att-link { color: #111827; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.att-link:hover { color: #3b82f6; }
.att-link .size { color: #6b7280; font-size: 11px; }
.att-meta { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; flex-wrap: wrap; }
.att-meta .att-date { color: #6b7280; }
.att-details-link { color: #3b82f6; text-decoration: none; font-weight: 500; }
.att-details-link:hover { text-decoration: underline; }
.kind-tag { font-size: 10px; padding: 2px 6px; border-radius: 3px; margin-left: 6px; background: #dbeafe; color: #1e40af; }

/* Bloc contact (email + téléphone) */
.contact-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px; margin-bottom: 16px;
    padding: 14px 16px; background: #f9fafb; border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.contact-item { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.contact-label { font-size: 11px; text-transform: uppercase; color: #6b7280; letter-spacing: 0.04em; font-weight: 600; }
.contact-value {
    font-size: 14px; color: #111827; text-decoration: none;
    display: inline-block;     /* limite la zone cliquable au texte */
    max-width: 100%;
}
.contact-value:hover { color: #3b82f6; text-decoration: underline; }
.contact-value.muted { color: #9ca3af; }
.small { font-size: 11px; }

/* Adresses */
.addresses-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.distance-row {
    display: flex; align-items: center; gap: 8px;
    margin-top: 14px; padding: 10px 14px;
    background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px;
    font-size: 14px; color: #166534;
}
.distance-icon { font-size: 16px; }
.distance-value { font-weight: 700; font-size: 16px; }
.distance-sep { color: #86efac; }
.distance-label { color: #4ade80; font-size: 12px; margin-left: 4px; }

.enedis-product-row {
    display: flex; align-items: center; gap: 8px;
    margin-top: 10px; padding: 10px 14px;
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
    font-size: 14px; color: #1e40af;
}
.enedis-product-icon { font-size: 16px; }
.enedis-product-label { font-weight: 600; }
.enedis-product-value { font-weight: 700; }
.enedis-product-value.muted { font-weight: normal; color: #9ca3af; }

/* Comparaison documents */
.doc-compare-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-compare-table th { text-align: left; padding: 8px 12px; font-size: 12px; color: #6b7280; border-bottom: 2px solid #e5e7eb; }
.doc-compare-table td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; }
.doc-compare-label { font-weight: 600; color: #374151; width: 160px; }
.doc-compare-row.status-warning td { background: #fffbeb; }
.doc-compare-row.status-danger  td { background: #fef2f2; }
.cmp-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.cmp-ok     { background: #d1fae5; color: #065f46; }
.cmp-warn   { background: #fef3c7; color: #92400e; }
.cmp-danger { background: #fee2e2; color: #991b1b; }

/* Liste objets inventaire manuscrit */
.inventaire-items-list {
    margin: 0; padding: 0 0 4px 0; list-style: none;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px;
}
.inventaire-items-list li {
    padding: 5px 0; font-size: 14px; color: #374151;
    border-bottom: 1px solid #f3f4f6;
}
.inventaire-items-list li::before { content: "•"; color: #9ca3af; margin-right: 6px; }

.classifier-note {
    display: inline-block;
    font-size: 12px;
    color: #374151;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 2px 6px;
    max-width: 260px;
}

.address-block {
    background: #f9fafb; border-radius: 8px; padding: 16px;
    border: 1px solid #e5e7eb;
}
.address-block h4 {
    margin: 0 0 12px; font-size: 13px; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.addr-fields { margin: 0; display: grid; grid-template-columns: 100px 1fr; gap: 6px 12px; font-size: 13px; }
.addr-fields dt { color: #6b7280; font-weight: 500; }
.addr-fields dd { margin: 0; color: #111827; word-break: break-word; }
.empty-small { color: #9ca3af; font-size: 13px; font-style: italic; }

/* Edit mode des Informations Dossier */
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.info-edit input[type=text], .info-edit input[type=email] {
    padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; width: 100%; box-sizing: border-box;
}
.info-edit input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.info-edit .contact-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.info-edit .addresses-grid { margin-top: 14px; }
.info-edit .addr-edit { display: flex; flex-direction: column; gap: 8px; }
.info-edit .addr-edit label { font-size: 12px; color: #374151; display: flex; flex-direction: column; gap: 4px; }
.info-edit-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid #e5e7eb; }
.source-tag.source-manual { background: #fef3c7; color: #92400e; }

/* Sélection déménageur sur la fiche dossier */
.suggest-banner {
    background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px;
    padding: 14px 16px; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.suggest-banner > div:first-child { flex: 1; line-height: 1.5; }
.demenageur-select-form { margin-bottom: 14px; }
.dem-row { display: flex; gap: 10px; align-items: center; }
.dem-select {
    flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; background: #fff;
}
.dem-select:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.dem-card {
    background: #f9fafb; border-radius: 8px; padding: 14px 16px;
    border: 1px solid #e5e7eb;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.dem-card .dem-name { font-size: 15px; }
.dem-card .dem-name .dept-badge { margin-right: 6px; }

/* Déménageurs */
.dept-badge {
    display: inline-block; padding: 3px 8px;
    background: #1f2937; color: #fff; border-radius: 4px;
    font-size: 12px; font-weight: 700; min-width: 28px; text-align: center;
}
.demenageur-form .form-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px;
}
.demenageur-form .form-field { display: flex; flex-direction: column; gap: 4px; }
.demenageur-form .form-field.span-2 { grid-column: span 2; }
.demenageur-form .form-field.span-3 { grid-column: span 3; }
.demenageur-form input[type=text],
.demenageur-form input[type=email],
.demenageur-form textarea {
    padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; box-sizing: border-box; font-family: inherit;
}
.demenageur-form input:focus,
.demenageur-form textarea:focus {
    border-color: #3b82f6; outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
@media (max-width: 800px) {
    .demenageur-form .form-grid { grid-template-columns: 1fr; }
    .demenageur-form .form-field.span-2,
    .demenageur-form .form-field.span-3 { grid-column: span 1; }
}

/* Conformité table */
.conformite { width: 100%; border-collapse: collapse; font-size: 14px; }
.conformite th, .conformite td { padding: 10px 14px; text-align: center; border-bottom: 1px solid #f3f4f6; }
.conformite thead th { background: #f9fafb; font-size: 12px; text-transform: uppercase; color: #6b7280; letter-spacing: 0.04em; }
.conformite tbody td:first-child { text-align: left; color: #374151; }
.conformite td.ok   { color: #059669; font-weight: 600; }
.conformite td.warn { color: #b45309; font-weight: 600; }
.conformite td.muted{ color: #9ca3af; }
.source-tag {
    display: inline-block; padding: 1px 6px; margin-left: 6px;
    border-radius: 3px; font-size: 10px; font-weight: 600; vertical-align: middle;
}
.source-ai       { background: #ede9fe; color: #6d28d9; }
.source-filename { background: #dbeafe; color: #1e40af; }
.source-pdf      { background: #d1fae5; color: #065f46; }

.meta-dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; font-size: 13px; }
.meta-dl dt { color: #6b7280; font-weight: 500; }
.meta-dl dd { margin: 0; color: #111827; word-break: break-word; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item {
    padding: 14px 16px; border-left: 3px solid #e5e7eb; margin-left: 10px;
    margin-bottom: 10px; background: #f9fafb; border-radius: 0 6px 6px 0;
}
.tl-item.role-creation     { border-left-color: #3b82f6; }
.tl-item.role-piece_jointe { border-left-color: #10b981; }
.tl-item.role-echange      { border-left-color: #f59e0b; }
.tl-head { display: flex; gap: 10px; font-size: 12px; color: #6b7280; margin-bottom: 6px; flex-wrap: wrap; }
.role-tag {
    padding: 2px 8px; border-radius: 3px; font-weight: 600; font-size: 11px;
    background: #e5e7eb; color: #374151;
}
.tl-from { font-weight: 600; color: #111827; }
.tl-subject { font-weight: 600; margin-bottom: 4px; }
.tl-preview { font-size: 13px; color: #4b5563; margin-bottom: 6px; }
.tl-link { font-size: 12px; color: #3b82f6; text-decoration: none; cursor: pointer; }
.tl-link:hover { text-decoration: underline; }
.tl-full { margin-top: 10px; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; overflow: hidden; }
.tl-iframe { width: 100%; min-height: 400px; border: 0; display: block; }

/* Sidebar badge */
.nav-badge {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    background: #ef4444; color: #fff; border-radius: 999px;
    font-size: 11px; font-weight: 700;
}

/* Flash messages */
.flash { padding: 12px 24px; font-size: 14px; }
.flash-ok { background: #d1fae5; color: #065f46; }
.flash-err { background: #fee2e2; color: #991b1b; }

/* Flash sync (coin bas-droite) */
.sync-flash {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    background: #1f2937; color: #fff; border-radius: 8px;
    padding: 10px 16px; font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Manual queue items */
.manual-item {
    background: #fff; border-radius: 8px; padding: 18px 20px;
    margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    border-left: 4px solid #f59e0b;
}
.mi-header { display: flex; gap: 20px; align-items: flex-start; }
.mi-info { flex: 1; min-width: 0; }
.mi-from { font-size: 14px; margin-bottom: 4px; }
.mi-from .muted { color: #9ca3af; font-weight: normal; font-size: 12px; }
.mi-subject { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: #111827; }
.mi-subject .clip { font-size: 13px; margin-left: 4px; }
.mi-meta { font-size: 12px; margin-bottom: 6px; }
.muted { color: #9ca3af; }
.mi-reason {
    display: inline-block; padding: 3px 10px; background: #fef3c7; color: #92400e;
    border-radius: 4px; font-size: 12px; margin: 6px 0;
}
.mi-preview { font-size: 13px; color: #4b5563; margin-top: 6px; line-height: 1.5; }

.mi-actions { display: flex; flex-direction: column; gap: 8px; min-width: 260px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input[type=text] {
    flex: 1; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px;
    min-width: 100px;
}
.inline-form input[type=text]:focus { border-color: #3b82f6; outline: none; }
.btn-primary {
    padding: 6px 14px; background: #3b82f6; color: #fff; border: 0;
    border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn-primary:hover { background: #2563eb; }
.btn-link-danger {
    background: transparent; border: 0; color: #dc2626; cursor: pointer;
    font-size: 12px; text-decoration: underline; padding: 4px 0; text-align: left;
}
.btn-link-danger:hover { color: #991b1b; }
.mi-actions .btn-secondary { text-align: center; text-decoration: none; }

/* =========================================================
   Email detail — navigation & améliorations
   ========================================================= */

/* Flèches prev/next */
.email-nav-arrows { display: inline-flex; gap: 2px; }
.nav-arrow {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 5px; border: 1px solid #e5e7eb;
    background: #fff; color: #374151; text-decoration: none; font-size: 14px;
    line-height: 1;
}
.nav-arrow:hover { background: #f3f4f6; border-color: #d1d5db; }
.nav-arrow.disabled { color: #d1d5db; cursor: default; background: #f9fafb; }

/* Dossier chips dans email.php */
.dossier-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: #f9fafb; border: 1px solid #e5e7eb;
    border-radius: 8px; text-decoration: none; color: #111827;
    font-size: 13px; transition: background 0.1s;
}
.dossier-chip:hover { background: #eff6ff; border-color: #3b82f6; }
.dossier-chip-id { font-weight: 700; color: #3b82f6; }
.dossier-chip-devis { font-weight: 600; color: #374151; }

/* Pièces jointes redesign */
.att-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.att-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: #f9fafb; border: 1px solid #e5e7eb;
    border-radius: 8px; text-decoration: none; color: #111827;
    transition: background 0.1s, border-color 0.1s;
}
.att-item:hover { background: #eff6ff; border-color: #3b82f6; }
.att-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.att-info { min-width: 0; }
.att-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { font-size: 11px; color: #6b7280; margin-top: 2px; display: flex; align-items: center; gap: 6px; }

/* Conversation emails */
.conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px; border-radius: 6px; background: #f9fafb;
    border: 1px solid #f3f4f6; text-decoration: none; color: #111827;
    font-size: 13px; transition: background 0.1s;
}
.conv-item:hover { background: #eff6ff; }
.conv-from { font-weight: 600; flex-shrink: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #374151; }
.conv-date { flex-shrink: 0; color: #9ca3af; font-size: 12px; }

/* Corps email (iframe auto-height) */
.email-body-card { padding: 0; overflow: hidden; }
.email-body-iframe { display: block; width: 100%; min-height: 200px; border: 0; }
.email-body-pre { padding: 24px; white-space: pre-wrap; font-family: inherit; margin: 0; font-size: 14px; line-height: 1.6; }

/* =========================================================
   Modaux génériques
   ========================================================= */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-box {
    background: #fff; border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 100%; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-lg  { max-width: 760px; }
.modal-xl  { max-width: 900px; }
.modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
.modal-head strong { font-size: 15px; color: #111827; }
.modal-close {
    background: none; border: 0; font-size: 18px; cursor: pointer;
    color: #9ca3af; padding: 0 4px; line-height: 1; flex-shrink: 0;
}
.modal-close:hover { color: #374151; }
.modal-footer {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-top: 1px solid #e5e7eb; flex-shrink: 0;
}

/* =========================================================
   Formulaire de composition (modal email)
   ========================================================= */
.compose-form { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.compose-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 20px; border-bottom: 1px solid #f3f4f6;
}
.compose-row-body { flex-direction: column; flex: 1; padding-bottom: 16px; }
.compose-label {
    width: 70px; flex-shrink: 0; font-size: 13px; font-weight: 600;
    color: #6b7280; padding-top: 8px;
}
.compose-row-body .compose-label { width: auto; padding-top: 0; }
.compose-input {
    flex: 1; padding: 7px 10px; border: 1px solid transparent;
    border-radius: 6px; font-size: 14px; background: transparent; font-family: inherit;
    outline: none; min-width: 0;
}
.compose-input:focus { background: #fff; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.compose-body-editor {
    width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6;
    resize: vertical; outline: none; box-sizing: border-box;
}
.compose-body-editor:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

/* =========================================================
   Templates email — liste
   ========================================================= */
.tpl-group { margin-bottom: 28px; }
.tpl-group-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: #6b7280; margin: 0 0 12px;
}
.tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.tpl-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 16px; display: flex; flex-direction: column; gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05); transition: box-shadow 0.15s, border-color 0.15s;
}
.tpl-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); border-color: #d1d5db; }
.tpl-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tpl-name { font-size: 14px; font-weight: 600; color: #111827; }
.tpl-cat-badge {
    flex-shrink: 0; font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; padding: 2px 7px; border-radius: 99px;
    background: #dbeafe; color: #1e40af;
}
.tpl-desc { font-size: 12px; color: #6b7280; line-height: 1.4; }
.tpl-subject { font-size: 12px; color: #374151; }
.tpl-subject-label { font-weight: 600; color: #6b7280; }
.tpl-vars { display: flex; flex-wrap: wrap; gap: 4px; }
.var-pill {
    display: inline-block; padding: 2px 7px; background: #f3f4f6; color: #374151;
    border-radius: 4px; font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.tpl-footer {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid #f3f4f6;
}
.tpl-meta { font-size: 11px; color: #9ca3af; }
.tpl-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Carte "nouveau" dans la grille */
.tpl-card-new {
    border-style: dashed; background: transparent; cursor: pointer;
    align-items: center; justify-content: center;
    min-height: 100px; color: #9ca3af; text-align: center;
}
.tpl-card-new:hover { background: #f9fafb; border-color: #9ca3af; color: #6b7280; }

/* =========================================================
   Templates email — formulaire édition
   ========================================================= */
.tpl-edit-layout {
    display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start;
}
@media (max-width: 900px) { .tpl-edit-layout { grid-template-columns: 1fr; } }
.tpl-edit-main { display: flex; flex-direction: column; gap: 0; }
.tpl-edit-side { display: flex; flex-direction: column; gap: 0; position: sticky; top: 20px; }

.tpl-form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
}
@media (max-width: 600px) { .tpl-form-grid { grid-template-columns: 1fr; } }

/* Champs de formulaire génériques */
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: #374151; }
.form-input {
    padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; font-family: inherit; outline: none; background: #fff;
}
.form-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
select.form-input { cursor: pointer; }

/* Éditeur de code (textarea HTML) */
.code-editor-wrap { position: relative; }
.code-editor {
    width: 100%; padding: 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-family: ui-monospace, Menlo, Consolas, 'Courier New', monospace;
    font-size: 12px; line-height: 1.6; resize: vertical; outline: none;
    box-sizing: border-box; background: #1e293b; color: #e2e8f0; tab-size: 2;
}
.code-editor:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

/* Aide variables (panneau latéral) */
.vars-helper-list { display: flex; flex-direction: column; gap: 2px; }
.var-helper-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 5px; cursor: pointer;
    transition: background 0.1s;
}
.var-helper-item:hover { background: #eff6ff; }
.var-code-sm {
    font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace;
    background: #f3f4f6; padding: 2px 5px; border-radius: 3px;
    color: #1e40af; white-space: nowrap; flex-shrink: 0;
}
.var-label-sm { font-size: 12px; color: #6b7280; }

/* ── Mapping Clara ───────────────────────────────────────────────────────── */
.api-tabs { display: flex; gap: 4px; border-bottom: 2px solid #e5e7eb; margin-bottom: 20px; padding: 0; list-style: none; }
.api-tabs li { margin: 0; }
.api-tabs a {
    display: inline-block; padding: 10px 18px; text-decoration: none;
    color: #6b7280; font-size: 14px; font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.api-tabs a:hover { color: #374151; }
.api-tabs a.active {
    color: #1e40af; border-bottom-color: #3b82f6; font-weight: 600;
}
.api-tabs .tab-badge {
    display: inline-block; font-size: 11px; font-weight: 500;
    background: #e5e7eb; color: #6b7280; padding: 1px 6px;
    border-radius: 10px; margin-left: 6px;
}
.api-tabs a.active .tab-badge { background: #dbeafe; color: #1e40af; }
.mapping-table { width:100%; border-collapse:collapse; font-size:13px; }
.mapping-table th { text-align:left; padding:8px 10px; font-size:11px; text-transform:uppercase; color:#6b7280; border-bottom:2px solid #e5e7eb; }
.mapping-section-row td.mapping-section-label { background:#f9fafb; padding:8px 10px; font-size:11px; font-weight:700; text-transform:uppercase; color:#374151; letter-spacing:.04em; border-top:2px solid #e5e7eb; }
.mapping-field-row td { padding:5px 10px; border-bottom:1px solid #f3f4f6; vertical-align:middle; }
.mapping-field-row.mapping-overridden td { background:#fffbeb; }
.mapping-field-name code { font-size:12px; background:#f3f4f6; padding:1px 5px; border-radius:3px; }
.mapping-dot { color:#f59e0b; font-size:10px; margin-left:4px; }
.map-select { width:100%; max-width:400px; font-size:12px; padding:4px 6px; border:1px solid #d1d5db; border-radius:5px; background:#fff; }
.mapping-field-hint { max-width:240px; }
.mapping-overridden .map-select { border-color:#f59e0b; }
.payload-preview { background:#1e1e1e; color:#d4d4d4; padding:16px; border-radius:8px; font-size:12px; overflow:auto; max-height:500px; line-height:1.5; }

/* Form grid (utilisateurs / profil) */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.form-grid label > span { font-weight: 500; }
.form-grid input[type=text],
.form-grid input[type=email],
.form-grid input[type=password],
.form-grid select {
    padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; box-sizing: border-box; font-family: inherit; background: #fff;
}
.form-grid input:focus, .form-grid select:focus {
    border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }
.user-row-edit > td { background: #f9fafb; }
