/* ============================================================================
   reseda — charte web TEWA Solar (skill tewa-ems-ui, variante « SCADA assoupli »)
   Tokens : miroir du bloc @theme de EMS/apps/portail/src/index.css (valeurs HSL).
   Aucune couleur brute hors de ce bloc :root.
   ========================================================================== */
:root {
  --background: hsl(213 20% 93%);
  --foreground: hsl(213 30% 16%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(213 30% 16%);
  --primary: hsl(214 67% 25%);
  --primary-foreground: hsl(0 0% 100%);
  --primary-10: hsl(214 67% 25% / 0.10);
  --primary-90: hsl(214 67% 25% / 0.90);
  --secondary: hsl(213 22% 91%);
  --secondary-foreground: hsl(214 55% 22%);
  --muted: hsl(213 20% 92%);
  --muted-foreground: hsl(214 14% 40%);
  --muted-foreground-10: hsl(214 14% 40% / 0.10);
  --accent: hsl(213 28% 88%);
  --accent-foreground: hsl(214 67% 25%);
  --destructive: hsl(0 60% 46%);
  --border: hsl(214 17% 84%);
  --input: hsl(214 17% 84%);
  --ring: hsl(214 67% 25%);

  --success: hsl(145 45% 38%);
  --info: hsl(213 45% 45%);
  --bess: hsl(265 35% 52%);
  --grid: hsl(30 60% 45%);
  --warning: hsl(38 70% 48%);
  --danger: hsl(2 60% 48%);
  --success-10: hsl(145 45% 38% / 0.10);
  --info-10: hsl(213 45% 45% / 0.10);
  --grid-10: hsl(30 60% 45% / 0.10);
  --warning-10: hsl(38 70% 48% / 0.10);
  --danger-10: hsl(2 60% 48% / 0.10);
  --success-25: hsl(145 45% 38% / 0.25);
  --danger-25: hsl(2 60% 48% / 0.25);
  --warning-25: hsl(38 70% 48% / 0.25);
  --info-25: hsl(213 45% 45% / 0.25);
  --danger-30: hsl(2 60% 48% / 0.30);
  --warning-30: hsl(38 70% 48% / 0.30);

  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;

  --shadow-card: 0 1px 2px 0 hsl(213 30% 18% / 0.06);
  --shadow-card-hover: 0 2px 6px -1px hsl(213 30% 18% / 0.10);
  --shadow-sm: 0 1px 2px 0 hsl(213 30% 18% / 0.05);
  --shadow-lg: 0 10px 15px -3px hsl(213 30% 18% / 0.10), 0 4px 6px -4px hsl(213 30% 18% / 0.10);

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --rail: 15rem;   /* w-60 */
  --entete: 4rem;  /* h-16 */
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; border-color: var(--border); }
html, body { height: 100%; }
body { margin: 0; background: var(--background); color: var(--foreground); font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a.lien-fort { font-weight: 500; }
a.lien-fort:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code, .mono, pre { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code { font-size: 0.85em; background: var(--muted); padding: 0.05em 0.35em; border-radius: var(--radius-sm); }
.icone { width: 1rem; height: 1rem; flex-shrink: 0; }
.texte-discret { color: var(--muted-foreground); font-size: 12px; }
.texte-danger { color: var(--danger); font-weight: 600; }
.nowrap { white-space: nowrap; }
.valeur-forte { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ── Coquille : rail fixe (≥ lg), header global, main à défilement ────────── */
.coquille { display: flex; height: 100vh; background: var(--background); }
.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--rail);
  display: none; flex-direction: column; background: var(--card); border-right: 1px solid var(--border);
}
.rail-tete { display: flex; align-items: center; height: var(--entete); padding: 0 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo { display: block; height: 2rem; width: auto; }
.logo-lien { display: inline-flex; }
.rail-nav { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-groupe { padding: 0 0.75rem 0.25rem; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); }
.nav-lien {
  position: relative; display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md); font-size: 14px; font-weight: 500; color: var(--muted-foreground);
  transition: background-color 0.15s, color 0.15s;
}
.nav-lien:hover { background: var(--accent); color: var(--accent-foreground); }
.nav-lien.actif { background: var(--primary-10); color: var(--primary); font-weight: 600; }
.nav-accent { position: absolute; left: 0; top: 0.375rem; bottom: 0.375rem; width: 3px; border-radius: 0 999px 999px 0; background: var(--primary); }
.nav-libelle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-pied { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-top: 1px solid var(--border); }
.rail-service { font-weight: 600; font-size: 13px; color: var(--foreground); }

.colonne { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.entete {
  display: flex; align-items: center; gap: 0.5rem; height: var(--entete); flex-shrink: 0;
  padding: 0 1rem; background: var(--card); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.entete-titre { display: flex; min-width: 0; flex: 1; align-items: center; gap: 0.625rem; }
.entete-icone { display: none; width: 1.25rem; height: 1.25rem; color: var(--primary); }
.entete h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entete-controles { display: flex; flex-shrink: 0; align-items: center; gap: 0.5rem; }
.principal { flex: 1; min-height: 0; overflow-y: auto; }
.contenu { max-width: 80rem; margin: 0 auto; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.25rem; }

@media (min-width: 640px) {
  .entete { gap: 0.75rem; padding: 0 1.5rem; }
  .entete h1 { font-size: 18px; }
  .entete-icone { display: block; }
  .entete-controles { gap: 0.75rem; }
  .contenu { padding: 1.25rem 1.5rem; }
}
@media (min-width: 768px) { .contenu { padding: 1.5rem; } }
@media (min-width: 1024px) {
  .rail { display: flex; }
  .colonne { padding-left: var(--rail); }
  .contenu { padding: 1.5rem 2rem; }
  .selecteur-vue { display: none; }
}

/* ── Menus déroulants (details) : sélecteur de vue et compte ─────────────── */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 40; }
.menu-panneau {
  position: absolute; right: 0; top: 100%; z-index: 50; margin-top: 0.5rem; width: 15rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 0.25rem;
}
.menu-panneau-compte { width: 16rem; padding: 0.75rem; }
.chevron { color: var(--muted-foreground); transition: transform 0.15s; }
.menu[open] .chevron { transform: rotate(180deg); }
.bouton-contour.selecteur-vue > summary, summary.bouton-contour {
  display: flex; height: 2.25rem; align-items: center; gap: 0.25rem; padding: 0 0.5rem;
  border: 1px solid var(--input); border-radius: var(--radius-md); color: var(--muted-foreground); background: var(--card);
}
summary.bouton-contour:hover { background: var(--accent); color: var(--accent-foreground); }
.compte-bouton { display: flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.375rem; border-radius: var(--radius-md); }
.compte-bouton:hover { background: var(--accent); }
.compte-pastille { display: flex; width: 2rem; height: 2rem; align-items: center; justify-content: center; border-radius: 999px; background: var(--primary-10); color: var(--primary); }
.compte-chevron { display: none; }
@media (min-width: 640px) { .compte-chevron { display: block; } }
.compte-infos { padding-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.125rem; }
.compte-nom { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compte-deconnexion { border-top: 1px solid var(--border); padding-top: 0.75rem; margin: 0; }

/* ── Cartes ───────────────────────────────────────────────────────────────── */
.surface-card { min-width: 0; background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.carte { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.carte-entete { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.carte-graphe { padding: 1rem; }
@media (min-width: 640px) { .carte-graphe { padding: 1.25rem; } }
.badges { display: flex; gap: 0.375rem; flex-wrap: wrap; }

/* ── Section : en-tête compact (le titre de PAGE est dans le header) ─────── */
.section { display: flex; flex-direction: column; gap: 0.75rem; }
.section-entete { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.section-entete-gauche { display: flex; min-width: 0; align-items: center; gap: 0.625rem; }
.section-icone { display: flex; width: 2rem; height: 2rem; flex-shrink: 0; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--primary-10); color: var(--primary); }
.section h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.section-sous-titre { margin-top: 0.125rem; font-size: 14px; color: var(--muted-foreground); }
.section-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* ── StatCard : barre d'accent, pastille d'icône, valeur monospacée ─────── */
.grille-kpi, .grille-sante { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) { .grille-kpi, .grille-sante { grid-template-columns: repeat(2, 1fr); gap: 1rem; } }
@media (min-width: 1024px) { .grille-kpi { grid-template-columns: repeat(4, 1fr); } .grille-sante { grid-template-columns: repeat(3, 1fr); } }
.stat-card { position: relative; overflow: hidden; padding: 1rem; transition: box-shadow 0.15s; }
.stat-card:hover { box-shadow: var(--shadow-card-hover); }
.stat-barre { position: absolute; left: 0; top: 0; bottom: 0; width: 0.25rem; }
.stat-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.stat-libelle { min-width: 0; overflow-wrap: anywhere; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em; line-height: 1.25; color: var(--muted-foreground); }
.stat-pastille { display: flex; width: 2rem; height: 2rem; flex-shrink: 0; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.stat-valeur-ligne { margin-top: 0.625rem; display: flex; align-items: baseline; gap: 0.375rem; flex-wrap: wrap; }
.stat-valeur { font-family: var(--font-mono); font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-valeur-texte { font-size: 16px; overflow-wrap: anywhere; }
.stat-unite { font-size: 14px; font-weight: 500; color: var(--muted-foreground); }
.stat-sous-titre { margin-top: 0.375rem; font-size: 12px; line-height: 1.4; color: var(--muted-foreground); }
.barre-primary { background: var(--primary); } .pastille-primary { background: var(--primary-10); color: var(--primary); }
.barre-success { background: var(--success); } .pastille-success { background: var(--success-10); color: var(--success); }
.barre-info { background: var(--info); }       .pastille-info { background: var(--info-10); color: var(--info); }
.barre-grid { background: var(--grid); }       .pastille-grid { background: var(--grid-10); color: var(--grid); }
.barre-warning { background: var(--warning); } .pastille-warning { background: var(--warning-10); color: var(--warning); }
.barre-danger { background: var(--danger); }   .pastille-danger { background: var(--danger-10); color: var(--danger); }
.barre-neutral { background: var(--muted-foreground); } .pastille-neutral { background: var(--muted-foreground-10); color: var(--muted-foreground); }

/* Panneau à plat (une valeur mise en avant) */
.panneau-plat { position: relative; overflow: hidden; padding: 1.25rem; }
.panneau-plat-ligne { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.panneau-plat-gauche { display: flex; align-items: center; gap: 0.75rem; }

/* ── LED d'état : carrée, cerclée d'un ring de sa couleur ────────────────── */
.led-groupe { display: inline-flex; align-items: center; gap: 0.5rem; }
.led { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: var(--radius-sm); }
.led-ok { background: var(--success); box-shadow: 0 0 0 2px var(--success-25); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.led-ko { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-25); }
.led-attention { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-25); }
.led-info { background: var(--info); box-shadow: 0 0 0 2px var(--info-25); }
.led-neutre { background: var(--muted-foreground); box-shadow: 0 0 0 2px var(--muted-foreground-10); }
.led-libelle { font-size: 14px; font-weight: 600; }
.led-libelle-ok { color: var(--success); } .led-libelle-ko { color: var(--danger); } .led-libelle-attention { color: var(--warning); }
.led-libelle-info { color: var(--info); } .led-libelle-neutre { color: var(--muted-foreground); }
@keyframes pulse { 50% { opacity: 0.5; } }
.aide-sante { text-align: center; }

/* ── Badges : capitales, coins serrés, jamais arrondis ───────────────────── */
.badge { display: inline-flex; align-items: center; white-space: nowrap; border-radius: var(--radius-sm); border: 1px solid transparent; padding: 0.125rem 0.5rem; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em; color: #fff; }
.badge-succes { background: var(--success); }
.badge-echec, .badge-refus { background: var(--danger); }
.badge-simulation { background: var(--info); }
.badge-partiel { background: var(--warning); }
.badge-secondaire { background: var(--secondary); color: var(--secondary-foreground); }

/* ── Bandeaux d'alerte ────────────────────────────────────────────────────── */
.bandeau { display: flex; width: 100%; align-items: flex-start; gap: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.75rem 1rem; font-size: 14px; }
.bandeau-icone { margin-top: 0.125rem; }
.bandeau-danger { border-color: var(--danger-30); background: var(--danger-10); color: var(--danger); }
.bandeau-warning { border-color: var(--warning-30); background: var(--warning-10); color: var(--foreground); }
.bandeau-info { background: var(--muted); color: var(--muted-foreground); }

/* ── Tableaux ─────────────────────────────────────────────────────────────── */
.table-conteneur { position: relative; width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { height: 2.5rem; padding: 0 0.75rem; text-align: left; vertical-align: middle; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em; color: var(--muted-foreground); }
td { padding: 0.625rem 0.75rem; vertical-align: middle; }
tbody tr { border-top: 1px solid var(--border); transition: background-color 0.15s; }
tbody tr:hover { background: var(--muted); }
th.num, td.num { text-align: right; white-space: nowrap; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.vide { text-align: center; padding: 2rem; color: var(--muted-foreground); }
.surface-card.vide { padding: 2rem; text-align: center; color: var(--muted-foreground); }
.liste-cartes { display: none; flex-direction: column; gap: 0.5rem; }
.carte-depot { display: flex; flex-direction: column; gap: 0.375rem; padding: 1rem; color: var(--foreground); }
.carte-depot:hover { box-shadow: var(--shadow-card-hover); }
.carte-depot-ligne { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.carte-depot-titre { font-size: 14px; font-weight: 500; }
.carte-depot-meta { font-size: 12px; color: var(--muted-foreground); }
@media (max-width: 767px) { .table-conteneur.surface-card { display: none; } .liste-cartes { display: flex; } }

/* ── Méta (dl) ────────────────────────────────────────────────────────────── */
.meta { display: grid; grid-template-columns: 1fr; gap: 0.25rem 1.25rem; margin: 0; font-size: 14px; }
.meta dt { color: var(--muted-foreground); font-size: 12px; }
.meta dd { margin: 0 0 0.375rem; overflow-wrap: anywhere; }
@media (min-width: 640px) { .meta { grid-template-columns: max-content 1fr; gap: 0.5rem 1.25rem; } .meta dt { font-size: 14px; } .meta dd { margin: 0; } }

/* ── Formulaires ──────────────────────────────────────────────────────────── */
.grille-actions { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 768px) { .grille-actions { grid-template-columns: repeat(2, 1fr); gap: 1rem; } }
.formulaire { display: flex; flex-wrap: wrap; align-items: flex-end; align-content: flex-start; gap: 0.75rem; padding: 1rem; }
.champ { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.champ label, .case { font-size: 14px; font-weight: 500; line-height: 1; }
input[type="text"], input[type="password"], input[type="date"], input[type="email"] {
  display: flex; height: 2.5rem; width: 100%; border: 1px solid var(--input); border-radius: var(--radius-md);
  background: var(--background); padding: 0.5rem 0.75rem; font: inherit; font-size: 14px; color: var(--foreground);
}
input:focus-visible { outline: 2px solid var(--ring); outline-offset: 0; }
.case { display: flex; align-items: center; gap: 0.5rem; height: 2.5rem; }
.case input { width: 1rem; height: 1rem; accent-color: var(--primary); }

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; height: 2.5rem; padding: 0 1rem; border-radius: var(--radius-md); border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background-color 0.15s, color 0.15s; white-space: nowrap; }
.bouton-primaire { background: var(--primary); color: var(--primary-foreground); }
.bouton-primaire:hover { background: var(--primary-90); }
.bouton-contour { background: var(--background); color: var(--foreground); border-color: var(--input); }
.bouton-contour:hover { background: var(--accent); color: var(--accent-foreground); }
.bouton-sm { height: 2.25rem; padding: 0 0.75rem; }
.bouton-pleine-largeur { width: 100%; }
.bouton-icone { display: flex; width: 2rem; height: 2rem; flex-shrink: 0; align-items: center; justify-content: center; border-radius: var(--radius-md); border: 1px solid var(--input); color: var(--muted-foreground); }
.bouton-icone:hover { background: var(--accent); color: var(--accent-foreground); }
@media (max-width: 639px) { .formulaire .bouton { width: 100%; } .formulaire .champ { width: 100%; } .entete .badge-secondaire { display: none; } }

/* ── Graphe, XML ──────────────────────────────────────────────────────────── */
.graphe { width: 100%; height: auto; display: block; font-family: var(--font-sans); }
pre.xml { margin: 0; padding: 0.75rem; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 11.5px; line-height: 1.4; overflow: auto; max-height: 520px; }

/* ── Page de connexion (même écran que le portail EMS) ───────────────────── */
.page-connexion { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.connexion-colonne { width: 100%; max-width: 24rem; display: flex; flex-direction: column; gap: 1rem; }
.connexion-tete { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem; text-align: center; }
.logo-connexion { height: 3.5rem; margin: 0 auto; }
.connexion-titre { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.connexion-sous-titre { margin-top: 0.25rem; font-size: 14px; color: var(--muted-foreground); }
.connexion-corps { padding: 0 1.25rem 1.25rem; }
.formulaire-connexion { display: flex; flex-direction: column; gap: 1rem; }
.connexion-invitation { text-align: center; font-size: 12px; color: var(--muted-foreground); }
