/* TechPilot AI — interface applicative (application et Control Center). Sobre, lisible en atelier, tactile. */
:root {
  /* Charte Pilot Group (ORCHESTRATION.md 3 ter). Teintes d'état assombries d'un cran pour le TEXTE (contraste AA sur fond clair). */
  --bleu: #1F5FBF; --bleu-fonce: #194E9E; --nuit: #0F1B2D; --anthracite: #2B2F36;
  --fond: #F5F6F8; --surface: #FFFFFF; --surface-2: #EEF0F3; --bord: #D7DBE1; --texte: #2B2F36; --texte-2: #4A4F57; --texte-3: #626872;
  --ok: #0A7F57; --ok-fond: #E6F4EE; --alerte: #A65A00; --alerte-fond: #FBF0E2; --danger: #C62828; --danger-fond: #FBEAEA; --info-fond: #E8EFF9;
  --ok-trait: #0E9F6E; --alerte-trait: #C26A00; --danger-trait: #C62828;
  --rayon: 6px; --ombre: 0 1px 2px rgba(15, 27, 45, .08);
  --police: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fond: #11161D; --surface: #171D26; --surface-2: #1E2530; --bord: #2C3440; --texte: #E4E7EB; --texte-2: #B4BAC3; --texte-3: #8E959F; --ok-fond: #12302A; --alerte-fond: #33240F; --danger-fond: #3A1A1A; --info-fond: #172539; --ok: #3CC495; --alerte: #E39A3B; --danger: #F07A7A; --bleu: #5B8FDB; color-scheme: dark; } }
:root[data-theme="dark"] { --fond: #11161D; --surface: #171D26; --surface-2: #1E2530; --bord: #2C3440; --texte: #E4E7EB; --texte-2: #B4BAC3; --texte-3: #8E959F; --ok-fond: #12302A; --alerte-fond: #33240F; --danger-fond: #3A1A1A; --info-fond: #172539; --ok: #3CC495; --alerte: #E39A3B; --danger: #F07A7A; --bleu: #5B8FDB; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--police); font-size: 15px; line-height: 1.5; background: var(--fond); color: var(--texte); -webkit-text-size-adjust: 100%; }
a { color: var(--bleu); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- structure */
.coque { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.barre { background: var(--nuit); color: #c9d4ea; display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.barre .marque { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 600; text-decoration: none; }
.barre .marque img { height: 28px; }
.barre nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 4px; color: #c9d4ea; text-decoration: none; font-size: 14px; }
.barre nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.barre nav a.actif { background: rgba(31,95,191,.28); color: #fff; }
.barre .groupe { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7f8db0; padding: 16px 10px 6px; }
.barre .bas { margin-top: auto; font-size: 13px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.principal { min-width: 0; display: flex; flex-direction: column; }
.entete { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 5; }
.entete .titre { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contenu { padding: 24px; max-width: 1200px; width: 100%; }
.onglets-mobile { display: none; }

@media (max-width: 860px) {
  .coque { grid-template-columns: 1fr; }
  .barre { display: none; }
  .entete { padding: 10px 14px; }
  .contenu { padding: 14px 14px 96px; }
  .onglets-mobile { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--bord); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .onglets-mobile a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: 11px; color: var(--texte-2); text-decoration: none; min-height: 56px; justify-content: center; }
  .onglets-mobile a.actif { color: var(--bleu); }
  .onglets-mobile svg.i { width: 22px; height: 22px; }
}

/* ---------- composants */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre); }
.carte + .carte { margin-top: 14px; }
.grille > .carte + .carte, .grille-2 > .carte + .carte { margin-top: 0; }
.grille { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grille-2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) {
  .grille-2 { grid-template-columns: 1fr !important; }
  .grille { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .carte { padding: 14px; }
  .kpi .val { font-size: 1.25rem; }
  #urgence span { display: none; }
}
.ligne { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.espace { flex: 1; }
.muet { color: var(--texte-3); font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: 4px; border: 1px solid var(--bord); background: var(--surface); color: var(--texte); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--bleu); }
.btn.primaire { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.btn.primaire:hover { background: var(--bleu-fonce); }
.btn.danger { color: var(--danger); }
.btn.petit { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-icone { min-width: 44px; min-height: 44px; padding: 0; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--texte-2); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--texte); background: var(--surface); border: 1px solid var(--bord); border-radius: 4px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--texte-2); white-space: nowrap; }
.badge.ok { background: var(--ok-fond); color: var(--ok); box-shadow: inset 3px 0 0 var(--ok-trait); } .badge.alerte { background: var(--alerte-fond); color: var(--alerte); box-shadow: inset 3px 0 0 var(--alerte-trait); } .badge.danger { background: var(--danger-fond); color: var(--danger); box-shadow: inset 3px 0 0 var(--danger-trait); } .badge.info { background: var(--info-fond); color: var(--bleu); }
.bandeau { border-radius: var(--rayon); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.bandeau.info { background: var(--info-fond); } .bandeau.alerte { background: var(--alerte-fond); border-color: rgba(194,106,0,.3); } .bandeau.danger { background: var(--danger-fond); }
table.tab { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tab th { text-align: left; font-size: 12px; color: var(--texte-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--bord); padding: 8px; }
.tab td { border-bottom: 1px solid var(--bord); padding: 10px 8px; vertical-align: top; }
.tab tr:last-child td { border-bottom: 0; }
.defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.vide { text-align: center; padding: 34px 16px; color: var(--texte-3); }
.vide svg.i { width: 34px; height: 34px; margin-bottom: 8px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .val { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .lib { font-size: 13px; color: var(--texte-3); }
.jauge { height: 8px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.jauge > span { display: block; height: 100%; background: var(--bleu); }
.jauge.alerte > span { background: var(--alerte); } .jauge.danger > span { background: var(--danger); }
.chargement { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--bord); border-top-color: var(--bleu); border-radius: 50%; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chargement { animation: none; } }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: 420px; background: var(--anthracite); color: #fff; padding: 12px 16px; border-radius: 6px; box-shadow: var(--ombre); font-size: 14px; }
.toast.erreur { background: var(--danger); }
@media (max-width: 860px) { .toast { left: 12px; right: 12px; bottom: 76px; } }
dialog { border: 1px solid var(--bord); border-radius: 6px; background: var(--surface); color: var(--texte); padding: 20px; width: min(560px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15,27,45,.55); }

/* ---------- conversation */
.conv { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 860px; }
.msg.user { align-self: flex-end; background: var(--bleu); color: #fff; padding: 10px 14px; border-radius: 6px; white-space: pre-wrap; }
.msg.assistant { background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; padding: 14px 16px; }
.msg.assistant h3 { font-size: .95rem; margin: 14px 0 6px; }
.msg.assistant blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--bleu); background: var(--surface-2); border-radius: 0 4px 4px 0; }
.msg .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.sources { margin-top: 10px; border-top: 1px dashed var(--bord); padding-top: 8px; font-size: 13px; }
.sources a { text-decoration: none; }
.saisie { position: sticky; bottom: 0; background: var(--fond); padding: 12px 0 4px; }
@media (max-width: 860px) { .saisie { bottom: 64px; } }
.saisie .boite { display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; padding: 8px; }
.saisie textarea { border: 0; min-height: 44px; max-height: 200px; padding: 10px; }
.saisie textarea:focus { outline: none; }
.enregistre { color: var(--danger) !important; border-color: var(--danger) !important; }

/* ---------- lecteur de documents */
.lecteur { display: grid; grid-template-columns: 1fr 320px; gap: 14px; }
@media (max-width: 1000px) { .lecteur { grid-template-columns: 1fr; } }
.page-pdf { position: relative; display: inline-block; background: #fff; box-shadow: var(--ombre); max-width: 100%; }
.page-pdf canvas { display: block; max-width: 100%; height: auto; }
.page-pdf .calque { position: absolute; inset: 0; }
.surligne { position: absolute; border: 2px solid var(--alerte-trait); background: rgba(194, 106, 0, .16); border-radius: 2px; cursor: pointer; }
.surligne.valide { border-color: var(--ok); background: rgba(14,159,110,.16); }
.surligne.manuel { border-style: dashed; }
.cadre-pdf { overflow: auto; max-height: 78vh; background: var(--surface-2); border-radius: var(--rayon); padding: 12px; text-align: center; }
.liste-reperes { max-height: 60vh; overflow-y: auto; }
.liste-reperes button { display: flex; width: 100%; text-align: left; gap: 8px; align-items: baseline; border: 0; background: none; padding: 7px 6px; border-radius: 6px; color: var(--texte); font: inherit; cursor: pointer; }
.liste-reperes button:hover { background: var(--surface-2); }
code, .mono { font-family: var(--mono); font-size: 13px; }
pre { background: var(--surface-2); padding: 12px; border-radius: 4px; overflow-x: auto; font-size: 13px; }
.zone-depot { border: 2px dashed var(--bord); border-radius: var(--rayon); padding: 22px; text-align: center; color: var(--texte-2); }
.zone-depot.survol { border-color: var(--bleu); background: var(--info-fond); }
.arbo a { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--texte); font-size: 14px; }
.arbo a.actif, .arbo a:hover { background: var(--surface-2); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--nuit); }
.auth .carte { width: min(440px, 100%); }
.auth .logo { display: block; height: 34px; margin: 0 auto 18px; }
.cache { display: none !important; }
.num, td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
