/* =====================================================================
   Portail de reporting Cogilog — feuille de style
   ===================================================================== */
:root {
  --fond: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #EEF0F3;
  --bord: #E1E4E8;
  --bord-fort: #C9CED5;
  --texte: #16191D;
  --texte-2: #4A525C;
  --texte-3: #7A828C;
  --accent: #1D5D4A;
  --accent-texte: #FFFFFF;
  --accent-doux: #E3EFE9;
  --danger: #A23B34;
  --danger-doux: #F7E6E4;
  --compta: #2A5A87;  --compta-doux: #E4EDF6;
  --gestion: #7A5A16; --gestion-doux: #F5EEDC;
  --barre-fond: #14181D;
  --barre-texte: #C9D1DA;
  --barre-texte-2: #8B95A1;
  --barre-actif: #1F2730;
  --barre-accent: #6FBFA1;
  --ombre: 0 1px 2px rgba(22,25,29,.05), 0 4px 16px -8px rgba(22,25,29,.12);
  --rayon: 10px;
  --largeur-barre: 260px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0F1216;
    --surface: #171B21;
    --surface-2: #1F252D;
    --bord: #2A323C;
    --bord-fort: #3A4450;
    --texte: #E6EAEF;
    --texte-2: #B3BCC7;
    --texte-3: #7F8994;
    --accent: #6FBFA1;
    --accent-texte: #0F1216;
    --accent-doux: #1A2E27;
    --danger: #E38B82;
    --danger-doux: #33201E;
    --compta: #8FB6DF; --compta-doux: #16222E;
    --gestion: #D9B565; --gestion-doux: #2B2416;
    --barre-fond: #0B0E12;
    --barre-actif: #1A2028;
    --ombre: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px -10px rgba(0,0,0,.8);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 14.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; color: var(--texte-2); margin: 16px 0 8px; }
p { margin: 0 0 10px; }
code, .mono, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.gris { color: var(--texte-3); }
.saut { position: absolute; left: -9999px; }
.saut:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 100; }

/* ---------- Icônes ---------- */
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: var(--largeur-barre) 1fr; min-height: 100vh; }

.barre {
  background: var(--barre-fond); color: var(--barre-texte);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.marque { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.marque-nom { font-weight: 600; font-size: 15px; color: #fff; letter-spacing: -.01em; }
.marque-client { font-size: 12px; color: var(--barre-texte-2); margin-top: 2px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-titre { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--barre-texte-2); padding: 18px 10px 6px; }
.nav-lien {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--barre-texte); text-decoration: none; font-size: 13.5px; margin-bottom: 1px;
}
.nav-lien:hover { background: var(--barre-actif); color: #fff; }
.nav-lien.actif { background: var(--barre-actif); color: #fff; box-shadow: inset 3px 0 0 var(--barre-accent); }
.nav-lien .ic { opacity: .75; }
.nav-lien.actif .ic { opacity: 1; color: var(--barre-accent); }
.nav-table span.mono { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.nav-n { margin-left: auto; font-size: 11px; color: var(--barre-texte-2); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }

.barre-pied { padding: 14px 20px 18px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: var(--barre-texte-2); }
.pied-synchro { margin-bottom: 12px; line-height: 1.4; }
.pied-synchro strong { color: var(--barre-texte); font-weight: 500; }
.pied-user { display: flex; align-items: center; gap: 8px; }
.pied-nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--barre-texte); }
.pied-sortie { color: var(--barre-texte-2); display: inline-flex; padding: 4px; border-radius: 6px; }
.pied-sortie:hover { color: #fff; background: var(--barre-actif); }

.principal { min-width: 0; display: flex; flex-direction: column; }
.haut {
  display: flex; align-items: center; gap: 14px; padding: 18px 32px 14px;
  background: var(--fond); position: sticky; top: 0; z-index: 5;
}
.haut-menu { display: none; background: none; border: 1px solid var(--bord); border-radius: 8px; padding: 6px; color: var(--texte); cursor: pointer; }
.haut-titre { font-size: 21px; }
.haut-sous { color: var(--texte-3); font-size: 13px; margin: 2px 0 0; }
.contenu { padding: 4px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.voile { display: none; }

/* ---------- Cartes et sections ---------- */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 20px 22px; box-shadow: var(--ombre); }
.carte-tete, .section-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-tete h2 { font-size: 15px; }
.carte-texte { color: var(--texte-2); max-width: 78ch; margin: 8px 0 0; }
.lien { font-size: 13px; text-decoration: none; }
.lien:hover { text-decoration: underline; }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px 18px; box-shadow: var(--ombre); }
.stat-n { display: block; font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-l { display: block; font-size: 12px; color: var(--texte-3); margin-top: 6px; }

.conn { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--bord); border: 1px solid var(--bord); border-radius: 8px; overflow: hidden; margin-top: 12px; }
.conn div { background: var(--surface-2); padding: 11px 14px; }
.conn .l { display: block; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--texte-3); margin-bottom: 3px; }
.conn .v { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; word-break: break-all; }

.grille-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tuile { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px 18px; text-decoration: none; color: inherit; box-shadow: var(--ombre); transition: border-color .12s, transform .12s; }
.tuile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tuile-nom { color: var(--accent); font-size: 13.5px; font-weight: 500; }
.tuile-desc { color: var(--texte-2); font-size: 13px; line-height: 1.45; flex: 1; }
.tuile-pied { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.tuile-n { font-size: 12px; color: var(--texte-3); font-variant-numeric: tabular-nums; }

.etiquette { display: inline-block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.etiquette-compta { background: var(--compta-doux); color: var(--compta); }
.etiquette-gestion { background: var(--gestion-doux); color: var(--gestion); }

/* ---------- Boutons et champs ---------- */
.bouton {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte);
  font: inherit; font-size: 13.5px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.bouton:hover { border-color: var(--accent); color: var(--accent); }
.bouton-plein { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); font-weight: 500; }
.bouton-plein:hover { filter: brightness(1.08); color: var(--accent-texte); }
.bouton-discret { border-color: transparent; background: transparent; color: var(--texte-2); }
.bouton-discret:hover { background: var(--surface-2); color: var(--texte); border-color: transparent; }
.bouton.inactif { opacity: .35; pointer-events: none; }
.bouton-icone { padding: 6px; }
.bouton-icone.copie { color: var(--accent); border-color: var(--accent); }
.raccourci { font-size: 11px; opacity: .7; margin-left: 2px; }

.champ { display: block; margin-bottom: 14px; }
.champ span { display: block; font-size: 12.5px; color: var(--texte-2); margin-bottom: 5px; font-weight: 500; }
.champ input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--bord-fort); border-radius: 8px;
  background: var(--surface); color: var(--texte); font: inherit; font-size: 14.5px;
}
.champ input:focus, .recherche input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.alerte { background: var(--danger-doux); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 8px; padding: 10px 14px; font-size: 13.5px; }
.vide { padding: 40px; text-align: center; color: var(--texte-3); background: var(--surface); border: 1px dashed var(--bord-fort); border-radius: var(--rayon); }

/* ---------- Copiable / code ---------- */
.copiable { position: relative; margin-bottom: 10px; }
.copiable .bouton-icone { position: absolute; top: 8px; right: 8px; }
.code { margin: 0; background: var(--surface-2); border: 1px solid var(--bord); border-radius: 8px; padding: 12px 44px 12px 14px; font-size: 12.5px; line-height: 1.55; overflow-x: auto; white-space: pre; }
.exemples { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.etapes { margin: 8px 0 0; padding-left: 20px; color: var(--texte-2); }
.etapes li { margin-bottom: 6px; }

/* ---------- Tableaux ---------- */
.tw { overflow-x: auto; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); }
.grille { max-height: calc(100vh - 290px); overflow: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--bord); white-space: nowrap; vertical-align: top; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--texte-3);
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; border-bottom: 1px solid var(--bord-fort);
}
thead th a { color: inherit; text-decoration: none; }
thead th a:hover { color: var(--accent); }
thead th.trie { color: var(--accent); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nul { color: var(--texte-3); }
td { max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.structure td.type { color: var(--texte-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.structure td { white-space: normal; }

/* ---------- Page table ---------- */
.table-tete { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.onglets { display: inline-flex; background: var(--surface-2); border: 1px solid var(--bord); border-radius: 9px; padding: 3px; }
.onglet { padding: 6px 14px; border-radius: 6px; text-decoration: none; color: var(--texte-2); font-size: 13.5px; font-weight: 500; }
.onglet.actif { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); }
.onglet-n { font-size: 11px; color: var(--texte-3); margin-left: 4px; }
.table-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.outils { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recherche { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 240px; max-width: 520px; background: var(--surface); border: 1px solid var(--bord-fort); border-radius: 8px; padding: 0 10px; color: var(--texte-3); }
.recherche input { flex: 1; border: 0; background: transparent; padding: 8px 0; font: inherit; color: var(--texte); min-width: 0; }
.recherche input:focus { outline: none; }
.recherche:focus-within { border-color: var(--accent); }
.outils-etat { color: var(--texte-3); font-size: 13px; margin-left: auto; font-variant-numeric: tabular-nums; }
.outils-etat strong { color: var(--texte); font-weight: 600; }
.resultat-etat { margin-left: 0; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.pagination-saut { display: flex; align-items: center; gap: 6px; margin: 0 10px; font-size: 13px; color: var(--texte-2); }
.pagination-saut input { width: 70px; padding: 6px 8px; border: 1px solid var(--bord-fort); border-radius: 6px; background: var(--surface); color: var(--texte); font: inherit; text-align: center; }

/* ---------- Console ---------- */
.console-editeur textarea {
  width: 100%; min-height: 160px; resize: vertical; padding: 14px 16px; border: 1px solid var(--bord-fort); border-radius: var(--rayon);
  background: var(--surface); color: var(--texte); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6;
  box-shadow: var(--ombre); tab-size: 2;
}
.console-barre { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.console-aide { color: var(--texte-3); font-size: 12.5px; }
.console-tables { margin-left: auto; font-size: 13px; position: relative; }
.console-tables > summary { cursor: pointer; color: var(--accent); list-style: none; padding: 6px 10px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); }
.console-tables > summary::-webkit-details-marker { display: none; }
.console-tables-liste { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 380px; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 8px; }
.console-tables-liste details { border-bottom: 1px solid var(--bord); }
.console-tables-liste details:last-child { border-bottom: none; }
.console-tables-liste summary { cursor: pointer; padding: 7px 8px; font-size: 12.5px; }
.console-tables-liste ul { list-style: none; margin: 0; padding: 0 8px 8px 24px; }
.console-tables-liste li { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 2px 0; }
.console-tables-liste .type { color: var(--texte-3); font-size: 11px; }

/* ---------- Connexion ---------- */
body.nue { display: grid; place-items: center; min-height: 100vh; background: var(--fond); }
.connexion { width: 100%; max-width: 400px; padding: 24px; }
.connexion-carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 32px 30px 26px; box-shadow: 0 10px 40px -20px rgba(22,25,29,.35); }
.connexion-marque { text-align: center; margin-bottom: 24px; }
.connexion-cadenas { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 12px; background: var(--accent-doux); color: var(--accent); display: grid; place-items: center; }
.connexion-cadenas .ic { width: 22px; height: 22px; }
.connexion-marque h1 { font-size: 20px; }
.connexion-marque p { color: var(--texte-3); font-size: 13px; margin: 4px 0 0; }
.connexion .bouton-plein { width: 100%; justify-content: center; padding: 11px; font-size: 14.5px; margin-top: 4px; }
.connexion .alerte { margin-bottom: 16px; }
.connexion-note { text-align: center; color: var(--texte-3); font-size: 12px; margin: 18px 0 0; }

/* ---------- Petit écran ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .barre { position: fixed; left: 0; top: 0; width: var(--largeur-barre); transform: translateX(-100%); transition: transform .18s; z-index: 30; }
  body.menu-ouvert .barre { transform: none; }
  .voile { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 25; }
  body.menu-ouvert .voile { opacity: 1; pointer-events: auto; }
  .haut-menu { display: inline-flex; }
  .haut, .contenu { padding-left: 16px; padding-right: 16px; }
  .deux-colonnes { grid-template-columns: 1fr; }
  .outils-etat { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Page Power BI ---------- */
.sql-api { width: 100%; padding: 12px 14px; border: 1px solid var(--bord-fort); border-radius: 8px; background: var(--surface); color: var(--texte); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; line-height: 1.55; resize: vertical; }
