/* =====================================================================
   KoraCAD - Dashboard admin. Style autonome (aucun CDN).
   Accent terracotta #C75B12, interface claire et sobre, libellés FR.
   ===================================================================== */

:root {
  --accent: #C75B12;
  --accent-fonce: #A3480C;
  --accent-clair: #F6E7DC;
  --fond: #F5F3F0;
  --carte: #FFFFFF;
  --texte: #1E1B18;
  --texte-doux: #6B635C;
  --bordure: #E4DED7;
  --ok: #2E7D32;
  --alerte: #B71C1C;
  --suspendu: #B26A00;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--police);
  color: var(--texte);
  background: var(--fond);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2 { margin: 0; font-weight: 650; }

/* ------------------------- Marque / logo ------------------------- */
.marque { display: flex; align-items: center; gap: 10px; }
.logo-pastille {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-fonce));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
  flex: none;
}

/* ------------------------- Écran de connexion ------------------------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #fff, var(--fond));
  padding: 20px;
}
.login-carte {
  background: var(--carte); border: 1px solid var(--bordure);
  border-radius: 14px; box-shadow: var(--ombre);
  padding: 34px; width: 100%; max-width: 380px;
}
.login-carte h1 { font-size: 24px; }
.login .sous-titre { color: var(--texte-doux); margin: 6px 0 22px; }
.login label { display: block; font-weight: 600; margin-bottom: 6px; }
.login input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--bordure);
  border-radius: 8px; font-size: 14px; margin-bottom: 16px;
}
.login input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ------------------------- Boutons ------------------------- */
.btn-principal {
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 11px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  width: 100%;
}
.btn-principal:hover { background: var(--accent-fonce); }
.btn-secondaire {
  background: #fff; color: var(--texte); border: 1px solid var(--bordure);
  cursor: pointer; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.btn-secondaire:hover { border-color: var(--accent); color: var(--accent); }
.form-actions .btn-principal { width: auto; }

/* ------------------------- Topbar ------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--carte); border-bottom: 1px solid var(--bordure);
  padding: 12px 22px; position: sticky; top: 0; z-index: 5;
}
.topbar-sep { color: var(--texte-doux); }
.topbar span { color: var(--texte-doux); }
.topbar strong { color: var(--texte); }
.topbar-actions { display: flex; gap: 8px; }

/* ------------------------- Contenu ------------------------- */
.contenu { max-width: 1100px; margin: 0 auto; padding: 22px; display: grid; gap: 18px; }

.panneau {
  background: var(--carte); border: 1px solid var(--bordure);
  border-radius: var(--radius); box-shadow: var(--ombre); padding: 20px;
}
.panneau h2 { font-size: 16px; margin-bottom: 14px; }
.panneau-entete { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.panneau-outils { display: flex; gap: 8px; align-items: center; }
.panneau-outils input[type="search"] {
  padding: 8px 12px; border: 1px solid var(--bordure); border-radius: 8px; font-size: 13px;
}

/* ------------------------- Cartes statistiques ------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat-carte {
  background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--radius);
  box-shadow: var(--ombre); padding: 16px 18px;
}
.stat-carte .valeur { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-carte .label { color: var(--texte-doux); font-size: 13px; margin-top: 2px; }

/* ------------------------- Graphique ------------------------- */
.graphique { width: 100%; overflow-x: auto; }
.graphique svg { display: block; }
.bar { fill: var(--accent); }
.bar:hover { fill: var(--accent-fonce); }
.axe { stroke: var(--bordure); }
.axe-texte { fill: var(--texte-doux); font-size: 10px; }

/* ------------------------- Formulaire génération ------------------------- */
.grille-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; align-items: end;
}
.grille-form label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.grille-form input, .grille-form select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--bordure); border-radius: 8px; font-size: 14px;
}
.grille-form input:focus, .grille-form select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.resultat {
  margin-top: 14px; padding: 12px 14px; border-radius: 8px;
  background: var(--accent-clair); color: var(--accent-fonce); font-weight: 600;
}

/* ------------------------- Tableau ------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 12px; color: var(--texte-doux);
  border-bottom: 2px solid var(--bordure); font-weight: 600; white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--bordure); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #FAF7F4; }
.cle-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Badges statut */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.active { background: #E6F4EA; color: var(--ok); }
.badge.suspendue { background: #FFF3E0; color: var(--suspendu); }
.badge.expiree { background: #FDECEA; color: var(--alerte); }

/* ------------------------- Modale détail ------------------------- */
.modale {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px;
}
.modale-carte {
  background: var(--carte); border-radius: 14px; width: 100%; max-width: 640px;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modale-entete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--bordure); position: sticky; top: 0; background: var(--carte);
}
.modale-entete h2 { font-size: 17px; }
.btn-fermer { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--texte-doux); line-height: 1; }
#detail-contenu { padding: 22px; }
.detail-ligne { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--bordure); gap: 12px; }
.detail-ligne .k { color: var(--texte-doux); }
.detail-ligne .v { font-weight: 600; text-align: right; word-break: break-all; }
.detail-machine { font-size: 12px; color: var(--texte-doux); padding: 2px 0 8px; border-bottom: 1px dashed var(--bordure); word-break: break-word; }

/* Jours restants (badges) + colonne ordinateurs */
.jr { font-weight: 700; padding: 2px 8px; border-radius: 12px; font-size: 12px; white-space: nowrap; }
.jr-ok { color: #1a7f37; background: rgba(26, 127, 55, 0.12); }
.jr-bientot { color: #b45309; background: rgba(180, 83, 9, 0.14); }
.jr-expire { color: #b91c1c; background: rgba(185, 28, 28, 0.14); }
.col-ordi { font-size: 12px; color: var(--texte-doux); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Section crashes */
.crashes-liste { display: flex; flex-direction: column; gap: 8px; }
.crash-ligne { padding: 8px 10px; border-radius: 6px; background: rgba(220, 53, 69, 0.06); border-left: 3px solid #dc3545; }
.crash-type { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #dc3545; margin-right: 6px; }
.crash-resume { font-size: 13px; }
.crash-meta { font-size: 11px; color: var(--texte-doux); margin-top: 3px; }

/* Crashes en accordeon : le conteneur porte le fond/bordure, le <summary> est
   l'en-tete cliquable, le detail (identique au mail admin) se deplie dessous. */
.crash-acc { border-radius: 6px; background: rgba(220, 53, 69, 0.06);
  border-left: 3px solid #dc3545; overflow: hidden; }
.crash-acc > summary.crash-ligne { padding: 8px 10px; cursor: pointer;
  list-style: none; display: flex; flex-wrap: wrap; align-items: center;
  gap: 2px 6px; background: none; border: 0; border-radius: 0; }
.crash-acc > summary.crash-ligne::-webkit-details-marker { display: none; }
.crash-acc > summary:hover { background: rgba(220, 53, 69, 0.10); }
.crash-acc[open] > summary.crash-ligne { border-bottom: 1px solid rgba(220, 53, 69, 0.2); }
.crash-acc .crash-meta { flex-basis: 100%; margin-top: 2px; }
.crash-voir { margin-left: auto; font-size: 11px; font-weight: 600; color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.45); border-radius: 999px;
  padding: 1px 9px; white-space: nowrap; }
.crash-acc[open] .crash-voir { background: #dc3545; color: #fff; }
.crash-detail { padding: 10px 12px; }
.crash-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 8px; }
.crash-table td { padding: 3px 8px; vertical-align: top;
  border-bottom: 1px solid rgba(127, 127, 127, 0.18); }
.crash-table td:first-child { font-weight: 600; white-space: nowrap; width: 130px;
  color: var(--texte-doux); }
.crash-trace { background: rgba(127, 127, 127, 0.10); padding: 10px; border-radius: 6px;
  white-space: pre-wrap; word-break: break-word; font-size: 11px; margin: 0;
  max-height: 320px; overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace; }
.detail-sous-titre { font-size: 14px; font-weight: 650; margin: 18px 0 8px; }

/* ------------------------- Divers ------------------------- */
.erreur { color: var(--alerte); font-weight: 600; margin-top: 10px; }
[hidden] { display: none !important; }
.vide { color: var(--texte-doux); text-align: center; padding: 20px; }

/* ---- Actions du panneau de détail (renouveler, éditions, statut) ---- */
.actions-bloc { border: 1px solid var(--bordure, #33404f); border-radius: 6px;
  padding: .6rem .8rem; margin: .4rem 0 .8rem; }
.action-ligne { display: flex; gap: .8rem; align-items: center;
  padding: .35rem 0; flex-wrap: wrap; }
.action-ligne .k { min-width: 90px; font-weight: 600; }
.action-ligne .v { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.champ-duree { width: 5.5rem; }
.case { display: inline-flex; gap: .3rem; align-items: center;
  margin-right: .6rem; white-space: nowrap; }
.btn-danger { color: #c75b12; border-color: #c75b12; }

/* ---- Choix des éditions dans le formulaire de création ---- */
.pleine-largeur { grid-column: 1 / -1; }
.editions-choix { display: flex; flex-direction: column; gap: .35rem;
  margin-top: .3rem; }
.editions-choix .case { white-space: normal; }
.case-socle { opacity: .8; font-style: italic; }
.equiv { color: var(--sourdine, #6b7684); font-size: .88em; }
.btn-lien { background: none; border: none; color: #15497a; cursor: pointer;
  padding: .3rem 0; font-size: .88rem; text-decoration: underline; }

/* ------------------------- Espace revendeur ------------------------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em; }
.rev-code { display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--accent-clair); color: var(--accent-fonce);
  font-weight: 600; font-size: .85rem; letter-spacing: .02em; }
.note-pied { color: var(--texte-doux); font-size: .85rem; margin: 18px 4px 40px;
  text-align: center; }
