/* Lettres de mission — styles PROPRES AU MODULE.
 * La charte (tokens, base, fenêtre, navigation, primitives) vient de
 * shared/charte.css, chargée avant ce fichier. Ne pas y redéfinir les tokens.
 */
/* ═══ HEADER ═══ */
.kb-mega-header { background: white; border-bottom: 1px solid var(--kb-border); box-shadow: 0 1px 3px rgba(0,0,0,0.04); position: sticky; top: 0; z-index: 100; }
.mega-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 24px; gap: 12px; flex-wrap: wrap; }
.mega-row-top { border-bottom: 1px solid var(--kb-border); }
.mega-left, .mega-right { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo-img { width: 32px; height: 32px; background: linear-gradient(135deg, var(--kb-primary), var(--kb-primary-dark)); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }
.logo-text { font-weight: 800; font-size: 14px; letter-spacing: 0.3px; }
.logo-text small { display: block; font-size: 9px; color: var(--kb-muted); font-weight: 600; letter-spacing: 0.5px; }
.section-divider { color: var(--kb-muted); font-weight: 300; }
.section-title { font-weight: 700; font-size: 15px; color: var(--kb-primary-dark); }
.cabinet-selector select { border: 1px solid var(--kb-border); border-radius: 6px; padding: 5px 8px; font-size: 12px; background: white; }
.cabinet-selector label { font-size: 12px; color: var(--kb-muted); font-weight: 600; }
.vsep { width: 1px; height: 20px; background: var(--kb-border); }
.cross-nav a { color: var(--kb-muted); font-size: 12px; text-decoration: none; padding: 4px 10px; border-radius: 6px; }
.cross-nav a:hover { background: #f0f0f2; color: var(--kb-text); }
.user-info { font-size: 12px; color: var(--kb-muted); font-weight: 600; }
.logout-link { text-decoration: none; color: var(--kb-danger); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.logout-link:hover { background: #fdeceb; }
.mega-row-bottom { padding: 10px 24px; font-size: 12px; color: var(--kb-muted); background: #fbfbfc; align-items: center; }

/* ═══ TOOLBAR (nouveau LM, filtres, bulk) ═══ */
.kb-lm-toolbar { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
.kb-lm-btn-primary { background: var(--kb-primary); color: white; border: none; border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.kb-lm-btn-primary:hover { background: var(--kb-primary-dark); }
.kb-lm-btn-primary-sm { background: var(--kb-primary); color: white; border: none; border-radius: 5px; padding: 4px 10px; font-size: 11px; font-weight: 700; cursor: pointer; }
.kb-lm-btn-primary-sm:hover { background: var(--kb-primary-dark); }
.kb-lm-btn-secondary { background: white; color: var(--kb-text); border: 1px solid var(--kb-border); border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.kb-lm-btn-secondary:hover { background: #fbfbfc; border-color: var(--kb-primary); color: var(--kb-primary); }
.kb-lm-btn-secondary-sm { background: white; color: var(--kb-primary); border: 1px dashed var(--kb-primary); border-radius: 5px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 6px; }
.kb-lm-btn-icon { background: transparent; border: none; cursor: pointer; padding: 4px 6px; font-size: 15px; border-radius: 4px; }
.kb-lm-btn-icon:hover { background: var(--kb-primary-light); }

/* Bulk dropdown */
.kb-lm-bulk-wrap { position: relative; }
.kb-lm-bulk-menu { position: absolute; top: 100%; right: 0; margin-top: 4px; background: white; border: 1px solid var(--kb-border); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 220px; padding: 6px; z-index: 200; display: none; }
.kb-lm-bulk-menu.open { display: block; }
.kb-lm-bulk-menu button { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 8px 12px; font-size: 13px; cursor: pointer; border-radius: 5px; color: var(--kb-text); }
.kb-lm-bulk-menu button:hover { background: var(--kb-primary-light); color: var(--kb-primary-dark); }

.kb-lm-search { border: 1px solid var(--kb-border); border-radius: 6px; padding: 6px 10px; font-size: 13px; width: 260px; background: white; }
.kb-lm-select { border: 1px solid var(--kb-border); border-radius: 6px; padding: 6px 8px; font-size: 12px; background: white; }
.kb-lm-select-label { font-size: 11px; color: var(--kb-muted); font-weight: 600; margin-right: 4px; }

/* ═══ KPI BANDEAU (compact) ═══ */
main { padding: 14px 20px; max-width: 1400px; margin: 0 auto; }
#kb-lm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kb-lm-kpi { background: var(--kb-surface); border: 1px solid var(--kb-border); border-left: 4px solid var(--kb-primary); border-radius: 8px; padding: 8px 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.kb-lm-kpi-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--kb-muted); font-weight: 700; margin-bottom: 2px; }
.kb-lm-kpi-value { font-size: 22px; font-weight: 800; margin-bottom: 1px; line-height: 1.15; }
.kb-lm-kpi-sub { font-size: 10.5px; color: var(--kb-muted); line-height: 1.2; }

/* ═══ MATRICE (compacte) ═══ */
#kb-lm-matrix { background: var(--kb-surface); border: 1px solid var(--kb-border); border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.kb-lm-table { width: 100%; border-collapse: collapse; font-size: 12.5px; line-height: 1.25; }
.kb-lm-table thead th { background: #fbfbfc; text-align: left; padding: 6px 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--kb-muted); border-bottom: 1px solid var(--kb-border); font-weight: 700; }
.kb-lm-table tbody td { padding: 5px 10px; border-bottom: 1px solid #ededf0; vertical-align: middle; }
.kb-lm-table tbody tr:hover { background: #f5f8ff; }
.kb-lm-table tbody tr:last-child td { border-bottom: none; }
.kb-lm-name { font-weight: 600; line-height: 1.2; }
.kb-lm-sub { font-size: 10.5px; color: var(--kb-muted); line-height: 1.2; margin-top: 1px; }
.kb-lm-code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; color: var(--kb-primary-dark); font-weight: 700; }

.kb-lm-badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 10.5px; font-weight: 700; }

/* ═══ DOSSIERS NUS ═══ */
.kb-lm-nus { padding: 16px; border-top: 2px solid var(--kb-warn); background: #fef8ef; }
.kb-lm-nus-head { font-weight: 700; color: #c77700; font-size: 13px; margin-bottom: 12px; }
.kb-lm-nus-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; }
.kb-lm-nu { display: flex; justify-content: space-between; align-items: center; background: white; padding: 10px 12px; border-radius: 6px; border: 1px solid #f5d9a8; }

/* ═══ MODAL (mov = overlay, mp = panel) ═══ */
.kb-lm-mov { position: fixed; inset: 0; background: rgba(0,0,0,0.45); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.kb-lm-mp { background: var(--kb-surface); width: 100%; max-width: 640px; max-height: 92vh; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 25px 50px rgba(0,0,0,0.3); }
.kb-lm-mp-head { background: linear-gradient(135deg, var(--kb-primary), var(--kb-primary-dark)); color: white; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.kb-lm-mp-head .kb-lm-close { background: rgba(255,255,255,0.2); border: none; color: white; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.kb-lm-mp-body { padding: 20px; overflow-y: auto; flex: 1; }
.kb-lm-mp-foot { padding: 12px 20px; border-top: 1px solid var(--kb-border); display: flex; gap: 10px; justify-content: flex-end; align-items: center; background: #fbfbfc; }
.kb-lm-input { width: 100%; border: 1px solid var(--kb-border); border-radius: 6px; padding: 7px 10px; font-size: 13px; box-sizing: border-box; }

.kb-lm-select-list { max-height: 400px; overflow-y: auto; border: 1px solid var(--kb-border); border-radius: 6px; margin-top: 10px; }
.kb-lm-select-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--kb-border); cursor: pointer; }
.kb-lm-select-row:hover { background: var(--kb-primary-light); }
.kb-lm-select-row:last-child { border-bottom: none; }

.kb-lm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.kb-lm-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.kb-lm-field { display: flex; flex-direction: column; }
.kb-lm-field label { font-size: 11px; font-weight: 600; color: #3a3a3c; margin-bottom: 4px; }
.kb-lm-field input, .kb-lm-field select { border: 1px solid var(--kb-border); border-radius: 5px; padding: 7px 9px; font-size: 13px; background: white; }
.kb-lm-section { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--kb-primary-dark); margin: 18px 0 10px; font-weight: 800; }

.kb-lm-prestations { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.kb-lm-chk { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 8px; background: #fbfbfc; border-radius: 5px; cursor: pointer; }
.kb-lm-chk input { margin: 0; }

/* Bloc SCI dans le modal */
.kb-lm-sci-block { margin-top: 12px; padding: 10px 12px; background: #f2f7ff; border: 1px solid #cfe3ff; border-radius: 6px; }
.kb-lm-sci-title { font-size: 11px; font-weight: 800; color: #1d1d1f; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
.kb-lm-sci-block .kb-lm-chk { background: white; }

/* Badge forme juridique — unifié pour toutes les formes */
.kb-lm-form-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap; }

/* Badge TVA compact (M/T/A/S/—) */
.kb-lm-tva-badge { display: inline-block; width: 22px; text-align: center; padding: 2px 0; border-radius: 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.3px; cursor: help; }

/* Bloc info TVA readonly en tête de modal LM */
.kb-lm-tva-info { background: #f2f7ff; border-left: 3px solid #0a84ff; padding: 8px 12px; border-radius: 0 6px 6px 0; margin-bottom: 14px; font-size: 12px; color: #1d1d1f; }
.kb-lm-tva-info strong { color: #0060df; }

.kb-lm-actions-cell { display: flex; align-items: center; gap: 2px; white-space: nowrap; }

/* Cellule + badges d'alerte (flags) */
.kb-lm-flags-cell { white-space: nowrap; text-align: center; }
.kb-lm-flag { display: inline-block; padding: 2px 6px; margin: 0 1px; border-radius: 4px; font-size: 11px; cursor: help; line-height: 1; }
.kb-lm-flag:hover { transform: scale(1.15); transition: transform 0.1s; }

/* Badge période (Mois/Trimestre/Année) */
.kb-lm-period-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; }

/* Ligne de filtres par colonne */
.kb-lm-table thead th[data-sort] { user-select: none; }
.kb-lm-table thead th[data-sort]:hover { background: #e6f0ff; }
.kb-lm-filter-row th { padding: 4px 6px !important; background: #fbfbfc; }
.kb-lm-col-filter { width: 100%; box-sizing: border-box; border: 1px solid var(--kb-border); border-radius: 4px; padding: 3px 6px; font-size: 11px; background: white; font-family: inherit; }
.kb-lm-col-filter:focus { outline: none; border-color: var(--kb-primary); box-shadow: 0 0 0 2px rgba(30,64,175,0.08); }
select.kb-lm-col-filter { padding: 2px 4px; }

/* Menu contextuel (clic droit) */
.kb-lm-ctx { position: fixed; z-index: 2000; min-width: 200px; background: white; border: 1px solid var(--kb-border); border-radius: 8px; box-shadow: 0 10px 24px rgba(15,23,42,0.14); padding: 4px; user-select: none; }
.kb-lm-ctx-item { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 7px 12px; font-size: 12.5px; cursor: pointer; border-radius: 5px; color: var(--kb-text); font-family: inherit; }
.kb-lm-ctx-item:hover { background: var(--kb-primary-light); color: var(--kb-primary-dark); }
.kb-lm-ctx-item.danger { color: var(--kb-danger); }
.kb-lm-ctx-item.danger:hover { background: #fdeceb; color: var(--kb-danger); }
.kb-lm-ctx-sep { height: 1px; background: var(--kb-border); margin: 4px 6px; }

.lmf-tarif-row { display: grid; grid-template-columns: 1fr 130px 40px; gap: 6px; margin-bottom: 6px; align-items: center; }
.lmf-tarif-row input { border: 1px solid var(--kb-border); border-radius: 5px; padding: 6px 9px; font-size: 12px; }

@media (max-width: 640px) {
  .kb-lm-grid-2, .kb-lm-grid-3 { grid-template-columns: 1fr; }
  .kb-lm-search { width: 100%; }
}
