/* ============================================================
   Matrice de compétences MCO — feuille de style
   ============================================================ */
:root {
    --ink:      #16202b;
    --ink-soft: #4a5b6b;
    --line:     #d5dde4;
    --bg:       #f2f5f7;
    --panel:    #ffffff;
    --brand:    #1f5673;
    --brand-dk: #163f54;
    --green:  #1f8a4c;   --green-bg:  #e4f3ea;
    --orange: #c77d15;   --orange-bg: #fbf0dd;
    --red:    #b23b3b;   --red-bg:    #f8e4e4;
    --crit-forte:   #b23b3b;
    --crit-moyenne: #c77d15;
    --crit-faible:  #6b7a88;
    --radius: 6px;
    --font: "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Barre supérieure ---------- */
.topbar { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; background: var(--brand-dk); color: #fff; padding: 10px 22px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a { color: #cfe0ea; padding: 6px 12px; border-radius: var(--radius); }
.mainnav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.mainnav a.active { background: var(--brand); color: #fff; }
.user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #cfe0ea; }
.btn-logout { background: rgba(255,255,255,.15); color: #fff; padding: 5px 10px; border-radius: var(--radius); }
.btn-logout:hover { background: rgba(255,255,255,.28); text-decoration: none; }

/* ---------- Contenu ---------- */
.content { max-width: 1600px; margin: 24px auto; padding: 0 22px; }
.footer { text-align: center; color: var(--ink-soft); padding: 20px; font-size: 12px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; color: var(--brand-dk); }
.subtitle { color: var(--ink-soft); margin: 0 0 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 22px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { padding: 2px 3px; border: 1px solid var(--line); text-align: center; }
th { background: #eef3f6; color: var(--brand-dk); font-weight: 600; position: sticky; top: 0; z-index: 2; }
td.left, th.left { text-align: left; }
tbody tr:hover td { background: #f7fafb; }
.domaine-cell { font-weight: 600; color: var(--brand-dk); background: #f4f8fa; font-size: 10px !important; }
.comp-cell { text-align: left; font-weight: 500; font-size: 12px !important; }

/* Cellules de niveau (feu tricolore) */
.lvl { font-weight: 700; }
.lvl-green  { background: var(--green-bg);  color: var(--green); }
.lvl-orange { background: var(--orange-bg); color: var(--orange); }
.lvl-red    { background: var(--red-bg);    color: var(--red); }

/* ============================================================
   Matrice des compétences — mise en page dédiée
   ============================================================ */
.matrice { table-layout: fixed; }
.matrice col.col-domaine { width: 88px; }
.matrice col.col-comp    { width: 175px; }
.matrice col.col-membre  { width: 52px; }
.matrice col.col-synth   { width: 62px; }

.matrice thead th { font-size: 11px; padding: 5px 3px; vertical-align: bottom; }

/* Noms de membres : petits, sur 2 lignes si besoin */
.matrice thead th.th-membre {
    white-space: normal;
    line-height: 1.1;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 2px;
    vertical-align: inherit;
}

.matrice td.domaine-rowspan {
    color: var(--brand-dk); font-weight: 700; font-size: 11px;
    text-align: left; vertical-align: middle;
    border-right: 2px solid var(--brand); line-height: 1.25;
    white-space: normal;
}

/* Fonds alternés par domaine : la cellule Domaine ET les cellules Compétence
   du même domaine partagent la même teinte ; le domaine suivant prend l'autre. */
.matrice td.dom-a { background: #eef3f6; }   /* teinte A */
.matrice td.dom-b { background: #ffffff; }   /* teinte B */
/* Le survol de ligne ne doit pas effacer les bandes alternées Domaine/Compétence. */
.matrice tbody tr:hover td.dom-a { background: #e4edf2; }
.matrice tbody tr:hover td.dom-b { background: #f4f7f9; }

/* Colonne Compétence : largeur fixe, libellé sur une ligne, tronqué si trop long.
   Le libellé complet reste accessible au survol (title) et à l'impression. */
.matrice td.comp-cell {
    padding: 2px 6px;
    max-width: 175px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media print {
    .matrice td.comp-cell { white-space: normal; overflow: visible; text-overflow: clip; }
}

/* --- Carte de chaleur (matrice) : 5 teintes --- */
.heat { padding: 0; }
.heat-cell { display: block; width: 100%; height: 100%; min-height: 30px; line-height: 30px; font-size: 0; }
.heat-0 { background: #c0392b; }
.heat-1 { background: #e8836f; }
.heat-2 { background: #f2c14e; }
.heat-3 { background: #7cc47f; }
.heat-4 { background: #2e9e4f; }

/* --- Colonnes de synthèse --- */
.cov { font-weight: 700; color: #fff; }
.cov-0 { background: #c0392b; }
.cov-1 { background: #e08a2e; }
.cov-2 { background: #f2c14e; color: #5c4708; }
.cov-3 { background: #4aa564; }

/* Pastille de criticité métier */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; color: #fff; text-transform: capitalize; }
.badge.forte   { background: var(--crit-forte); }
.badge.moyenne { background: var(--crit-moyenne); }
.badge.faible  { background: var(--crit-faible); }

/* Alertes de risque */
.risk { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.risk-none  { background: var(--green-bg);  color: var(--green); }
.risk-spof  { background: var(--red-bg);    color: var(--red); }
.risk-gap   { background: #37424d;          color: #fff; }
.risk-low   { background: var(--orange-bg); color: var(--orange); }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 13px; }
input[type=text], input[type=number], input[type=date], select, textarea {
    width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius);
    font-family: var(--font); font-size: 14px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 60px; }
.btn { display: inline-block; background: var(--brand); color: #fff; border: none; padding: 9px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-dk); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #8f2e2e; }
.flash { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid transparent; }
.flash-ok  { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.flash-err { background: var(--red-bg);   border-color: var(--red);   color: var(--red); }

/* Grille de saisie compacte */
.grid-saisie th, .grid-saisie td { padding: 5px 6px; }
.grid-saisie input[type=number] { width: 68px; }
.grid-saisie select { width: auto; min-width: 90px; }
.grid-saisie textarea { min-width: 200px; resize: vertical; font-size: 13px; }
.chk { transform: scale(1.15); }

/* Cartes d'indicateurs (accueil) */
.kpis { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi { flex: 1 1 180px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 16px 18px; }
.kpi .num { font-size: 30px; font-weight: 700; color: var(--brand-dk); }
.kpi .lbl { color: var(--ink-soft); font-size: 13px; }
.kpi.alert { border-left-color: var(--red); }
.kpi.alert .num { color: var(--red); }

/* Légende */
.legende { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; margin-top: 12px; color: var(--ink-soft); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dot.green { background: var(--green); }
.dot.orange { background: var(--orange); }
.dot.red { background: var(--red); }

/* Écran de connexion */
.login-box { max-width: 380px; margin: 60px auto; }
.muted { color: var(--ink-soft); font-size: 13px; }

/* Cellule "qui" */
.who { text-align: left; font-size: 13px; }
.who .none { color: var(--red); font-style: italic; }

/* ---------- Sélecteur de périmètre (admin activités) ---------- */
.perimetre { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 6px; }
.perimetre-domaine { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fafcfd; }
.perimetre-entete { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--brand-dk); }
.perimetre-entete .btn { padding: 3px 8px; font-size: 11px; font-weight: 600; }
.perimetre-item { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; font-size: 13px; cursor: pointer; }
.perimetre-item input { width: auto; transform: scale(1.1); }

/* ---------- Profil texte du membre (page saisie) ---------- */
.profil-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
@media (max-width: 800px) { .profil-grid { grid-template-columns: 1fr; } }

/* ---------- Récapitulatif des profils (page Équipe) ---------- */
.profil-recap { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 22px; margin-top: 12px; }
@media (max-width: 800px) { .profil-recap { grid-template-columns: 1fr; } }
.recap-label { font-size: 12px; font-weight: 700; color: var(--brand-dk); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 3px; }
.recap-val { font-size: 14px; line-height: 1.5; }

/* ============================================================
   Page super admin — cartes d'équipes et chips
   ============================================================ */
.equipe-card { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 18px 20px; margin-bottom: 16px; background: var(--panel); }
.equipe-inactive { border-left-color: var(--crit-faible); opacity: .6; }
.equipe-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 2px solid var(--brand); }
.equipe-head h2 { margin: 0; font-size: 18px; }
.badge-inactif { display: inline-block; font-size: 11px; font-weight: 700; background: var(--red-bg); color: var(--red); padding: 2px 8px; border-radius: 20px; margin-left: 8px; text-transform: uppercase; letter-spacing: .3px; vertical-align: middle; }
.equipe-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 26px; }
@media (max-width: 820px) { .equipe-cols { grid-template-columns: 1fr; } }
.equipe-section .recap-label { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--brand-dk); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.equipe-section .recap-label .count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; background: var(--brand); color: #fff; border-radius: 20px; font-size: 11px; font-weight: 700; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eef3f6; border: 1px solid var(--line); border-radius: 20px; padding: 4px 6px 4px 12px; font-size: 13px; color: var(--ink); line-height: 1.4; }
.chip.chip-admin { background: #e5edf2; border-color: #bcd0dc; font-weight: 600; }
.chip form { margin: 0; display: inline-flex; }
.chip .chip-x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: none; border-radius: 50%; background: transparent; color: var(--ink-soft); font-size: 15px; line-height: 1; cursor: pointer; padding: 0; transition: background .12s, color .12s; }
.chip .chip-x:hover { background: var(--red); color: #fff; }
.chips-vide { color: var(--ink-soft); font-size: 13px; font-style: italic; margin-bottom: 14px; }
.chip-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.chip-add select { min-width: 200px; }

/* Badge "Nouvelle" (page saisie) */
.badge-nouveau { display: inline-block; font-size: 10px; font-weight: 700; background: var(--brand); color: #fff; padding: 1px 7px; border-radius: 20px; margin-left: 8px; text-transform: uppercase; letter-spacing: .3px; vertical-align: middle; }
tr.ligne-nouveau td { background: #eaf2f8; }
tr.ligne-nouveau:hover td { background: #e0ecf4; }
