/* ==========================================================================
   Bambu Tracker — Apple/iOS UI (refonte août 2026)
   Clair + sombre automatique via prefers-color-scheme.
   Refonte strictement cosmétique : les noms de variables CSS utilisés par le
   JS (--surface, --accent, --muted, --font-mono…) sont CONSERVÉS, seules leurs
   valeurs changent → tout le HTML généré dynamiquement suit le thème.
   Spec : DESIGN.md (linté, contraste AA).
   ========================================================================== */

/* ---------- Police globale : Comfortaa (Google Fonts) ----------
   Importée une seule fois ici → toutes les pages (qui chargent ce CSS)
   héritent de la police. Variable 300..700 ; les font-weight au-delà
   (800 utilisés par quelques KPI) sont clamés par le navigateur.       */
@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@300..700&display=swap');

/* ---------- Tokens : mode clair (défaut) ---------- */
:root {
  color-scheme: light dark;

  /* Noms historiques conservés (référencés par les JS et les styles inline) */
  --bg: #f2f2f7;                 /* fond page iOS grouped */
  --surface: #ffffff;            /* cartes */
  --surface2: #e8e8ed;           /* blocs internes / champs */
  --border: rgba(0, 0, 0, 0.08); /* séparateurs fins */
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;             /* UNIQUE couleur d'interaction */
  --accent-glow: rgba(0, 113, 227, 0.15);
  --accent2: #0071e3;            /* (admin : ancien orange secondaire → bleu) */
  --ok: #34c759;
  --warn: #ff9500;
  --crit: #ff3b30;
  --radius: 16px;
  --font-sans: 'Comfortaa', -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: 'Comfortaa', ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Tokens Apple additionnels */
  --card: #ffffff;
  --field: rgba(118, 118, 128, 0.12);
  --field2: #e8e8ed;
  --text2: #6e6e73;
  --text3: rgba(0, 0, 0, 0.48);
  --link: #0066cc;
  --glass: rgba(255, 255, 255, 0.72);
  --seg-bg: rgba(118, 118, 128, 0.14);
  --seg-on: #ffffff;
  --ring: 0 0 0 3.5px rgba(0, 113, 227, 0.25);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.2);
  --ok-soft: rgba(52, 199, 89, 0.12);
  --warn-soft: rgba(255, 149, 0, 0.14);
  --crit-soft: rgba(255, 59, 48, 0.10);
}

/* ---------- Tokens : mode sombre ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface2: #3a3a3c;
    --border: rgba(255, 255, 255, 0.10);
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --accent: #2997ff;
    --accent-glow: rgba(41, 151, 255, 0.25);
    --accent2: #2997ff;
    --ok: #30d158;
    --warn: #ff9f0a;
    --crit: #ff453a;
    --card: #1c1c1e;
    --field: rgba(118, 118, 128, 0.24);
    --field2: #3a3a3c;
    --text2: #a1a1a6;
    --text3: rgba(235, 235, 245, 0.48);
    --link: #2997ff;
    --glass: rgba(22, 22, 24, 0.78);
    --seg-bg: rgba(118, 118, 128, 0.24);
    --seg-on: #636366;
    --ring: 0 0 0 3.5px rgba(41, 151, 255, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
    --ok-soft: rgba(48, 209, 88, 0.16);
    --warn-soft: rgba(255, 159, 10, 0.18);
    --crit-soft: rgba(255, 69, 58, 0.16);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
  margin: 0; padding: 0;
  overflow-x: hidden;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-glow); }

/* Scrollbar discrète */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--field2); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { letter-spacing: -0.02em; }

/* ---------- Header glass sticky ---------- */
header {
  position: sticky; top: 0; z-index: 1000;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  padding: 12px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo h1 {
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em;
  margin: 0; white-space: nowrap;
}
.logo h1 span { color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.last-upd { text-align: right; font-size: 0.62rem; color: var(--text2); line-height: 1.35; margin-right: 4px; }
.last-upd #last-upd-time { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text); font-weight: 600; }

/* ---------- Navigation : chips pilule (segmented control) ---------- */
.nav-tabs {
  display: flex; gap: 6px;
  padding: 10px 32px;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  background: var(--seg-bg);
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  flex-shrink: 0;
}
.nav-tab:hover { background: var(--field); }
.nav-tab.active {
  background: var(--seg-on);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

main { padding: 24px 32px; max-width: 1500px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: tabFade 0.25s ease; }
@keyframes tabFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Boutons pilules ---------- */
button, .hdr-btn, .btn-confirm, .btn-edit, .btn-del, .reset-btn, .btn-queue,
.btn-add-spool, .optimize-btn, .btn-cancel, .detail-btn, .btn-add, .btn-save,
.btn-back, .btn-link, .btn-cancel-form, .submit-btn, .btn {
  background: var(--field);
  border: none;
  color: var(--text) !important;
  padding: 8px 18px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  transition: opacity 0.15s ease, transform 0.1s ease, background 0.15s ease;
  line-height: 1.2;
}
button:hover, .hdr-btn:hover, .btn-confirm:hover, .btn-edit:hover, .btn-del:hover,
.reset-btn:hover, .btn-queue:hover, .btn-add-spool:hover, .optimize-btn:hover,
.btn-cancel:hover, .detail-btn:hover, .btn-add:hover, .btn-save:hover,
.btn-back:hover, .btn-link:hover, .btn-cancel-form:hover, .submit-btn:hover, .btn:hover {
  opacity: 0.85;
}
button:active, .hdr-btn:active, .btn-confirm:active, .btn-edit:active,
.btn-del:active, .reset-btn:active, .btn-queue:active, .btn-add-spool:active,
.optimize-btn:active, .btn-cancel:active, .btn-add:active, .btn-save:active,
.btn-back:active, .btn-link:active, .btn-cancel-form:active, .submit-btn:active, .btn:active {
  transform: scale(0.97);
}

/* Primaire : bleu */
.btn-confirm, .reset-btn, .btn-queue, .btn-add-spool, .optimize-btn,
.btn-add, .btn-save, .submit-btn {
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
}

/* Danger : rouge teinté */
.btn-del {
  background: var(--crit-soft);
  color: var(--crit) !important;
}

/* Ghost / liens */
.btn-edit, .detail-btn, .btn-back {
  background: var(--field);
  color: var(--link) !important;
}

/* Variante accent du header (Refresh) */
.hdr-btn.accent {
  background: var(--accent);
  color: #fff !important;
}
.hdr-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Inputs « filled » ---------- */
.inp-s, select, input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], input[type="color"], input[type="file"],
textarea {
  background: var(--field);
  border: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 10px;
  width: 100%;
  outline: none;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text2) 50%), linear-gradient(135deg, var(--text2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.inp-s:focus, select:focus, input:focus, textarea:focus {
  box-shadow: var(--ring);
  background: var(--card);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
input[type="color"] { padding: 4px 6px; height: 38px; cursor: pointer; }

label, .lbl-s { display: block; font-size: 0.7rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }

/* ---------- Cartes ---------- */
.printer-card, .spool-card, .spare-card, .catalog-card, .failure-card,
.sales-kpi, .env-card, .camera-card, .chart-card, .power-bar-wrap,
.form-card, .form-card-inner, .maint-section, .order-card, .maint-card,
.bed-card, .info-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Titres de section en petites capitales grises */
.stats-section-title, .card h2, .form-section, .env-label {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text2);
}

/* ---------- Grilles ---------- */
.printers-grid, .spool-grid, .spare-grid, .catalog-grid, .bed-grid,
#stats-printers-grid, .maint-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.printers-grid { gap: 12px; }

/* ---------- Skeleton loading ---------- */
.skeleton, .loading-ph {
  background: linear-gradient(100deg, var(--field) 40%, var(--field2) 50%, var(--field) 60%);
  background-size: 200% 100%;
  border-radius: 12px;
  min-height: 90px;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Animations d'état ---------- */
@keyframes blink-border {
  0% { box-shadow: 0 0 0 2px var(--crit), 0 0 8px var(--crit); }
  50% { box-shadow: 0 0 0 2px transparent, 0 0 0 transparent; }
  100% { box-shadow: 0 0 0 2px var(--crit), 0 0 8px var(--crit); }
}
.priority-haute {
  box-shadow: 0 0 0 2px var(--crit);
  animation: blink-border 2s infinite;
  border-radius: 12px;
}

@keyframes pulse-drying {
  0% { opacity: 1; } 50% { opacity: 0.65; } 100% { opacity: 1; }
}
.drying-badge {
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  animation: pulse-drying 2s infinite;
  white-space: nowrap;
}
/* ---------- Éclairage de la chambre (pastille cliquable du dashboard) ---------- */
.light-toggle {
  background: var(--field);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
  padding: 3px 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.light-toggle:hover { border-color: var(--accent); }
.light-toggle.on {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn);
}
/* ---------- Piles de l'AMS (pastille cliquable) ---------- */
.batt-badge {
  background: var(--field);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 3px 8px;
  cursor: pointer;
}
.batt-badge:hover { border-color: var(--accent); }
.batt-badge.low { background: var(--crit-soft, rgba(255,59,48,.12)); color: var(--crit); border-color: var(--crit); }
/* Consigne affichée à droite d'une mesure (ex. « 27° → 60° ») */
.stat-target { color: var(--warn); font-family: var(--font-mono); font-size: 0.72em; }
/* ==========================================================================
   PARTIE 2 — Dashboard, imprimantes, bobines, catalogue, tableaux, modals
   ========================================================================== */

/* ---------- Bandeau flash (ex. code de secours 2FA consommé) ---------- */
.flash-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid rgba(255, 149, 0, 0.28);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---------- Dashboard : bloc environnement ---------- */
.env-block { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.env-card {
  flex: 1; min-width: 150px;
  padding: 9px 14px;
  display: flex; align-items: center; gap: 10px;
}
.env-icon { font-size: 1.05rem; }
.env-label { margin-bottom: 1px; font-size: 0.68rem; }
.env-value { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 700; color: var(--text); }
.env-sub { font-size: 0.7rem; color: var(--text2); font-family: var(--font-mono); }

/* ---------- Dashboard : caméras ----------
   09/2026 : tuile plus compacte (image 104 px au lieu de 130) et ligne d'horodatage
   enfin renseignée par le JS (elle affichait « -- » en permanence = hauteur perdue). */
.cameras-block { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.camera-card { overflow: hidden; padding: 0 !important; }
.camera-header {
  padding: 8px 12px;
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 0.5px solid var(--border);
}
.camera-title { color: var(--text); }
.camera-refresh { background: none; border: none; color: var(--link); font-family: var(--font-sans); font-size: 0.66rem; cursor: pointer; padding: 0; }
.camera-img-wrap { height: 104px; background: #000; overflow: hidden; position: relative; }
.camera-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-ts { padding: 4px 12px; font-family: var(--font-mono); font-size: 0.58rem; color: var(--text2); border-top: 0.5px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camera-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text3); font-size: 0.7rem; gap: 4px;
}

/* ---------- Bannière alertes maintenance ---------- */
.alerts-banner {
  background: var(--warn-soft);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alerts-banner h4 { margin: 0 0 6px; font-size: 0.8rem; font-weight: 700; color: var(--warn); letter-spacing: -0.01em; }
.alerts-banner .alert-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 0; font-size: 0.8rem; color: var(--text);
  border-top: 0.5px solid var(--border);
}
.alerts-banner .alert-item:first-of-type { border-top: none; }

/* ---------- Cartes imprimantes ---------- */
.printer-card { overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.printer-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08); }
.card-header-v18 { padding: 12px 14px 8px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.printer-name { font-size: 1.18rem; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
/* Badge étape actuelle (imprimante) */
.printer-step-badge {
  font-family: var(--font-mono); font-size: 0.6rem; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--field); color: var(--text2); border: 1px solid var(--border);
}
.printer-step-badge.tone-print { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.printer-step-badge.tone-prep { background: rgba(245,158,11,.12); color: var(--warn); border-color: transparent; }
.printer-step-badge.tone-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.printer-step-badge.tone-idle { background: var(--field); color: var(--text2); }
.printer-step-badge.tone-err  { background: rgba(255,59,48,.12); color: var(--crit); border-color: transparent; }
.printer-step-badge.tone-off  { background: rgba(255,59,48,.12); color: var(--crit); border-color: transparent; }
/* Badge mode de connexion (LAN+DEV / Cloud) */
.mode-badge {
  font-family: var(--font-mono); font-size: 0.6rem; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.mode-badge.mode-lan { background: var(--ok-soft); color: var(--ok); border: 1px solid transparent; }
.mode-badge.mode-cloud { background: var(--field); color: var(--text2); border: 1px solid var(--border); }
/* Icône warning nettoyage plateau */
.bed-warn-badge {
  cursor: pointer; font-size: 0.95rem; line-height: 1;
  padding: 2px 5px; border-radius: 6px;
  background: rgba(255,59,48,.12); border: 1px solid rgba(255,59,48,.35);
  animation: bedWarnPulse 2s ease-in-out infinite;
}
@keyframes bedWarnPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.reliability-pill {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--field); color: var(--text2);
}
.reliability-pill[style*="green"], .reliability-pill[style*="lime"] { background: var(--ok-soft); color: var(--ok); }

.printer-body-v18 { display: flex; padding: 0 14px 10px; gap: 10px; flex: 1; align-items: stretch; }
/* L'aperçu remplit la hauteur disponible de la carte (les cartes d'une même ligne
   ont la hauteur de la plus haute) : image plus grande SANS ajouter de hauteur. */
.printer-preview-img {
  width: 112px; min-height: 92px; height: auto; align-self: stretch;
  border-radius: 10px; object-fit: cover;
  flex-shrink: 0; background: var(--field);
}
/* Nom de l'impression en cours : sous le nom de l'imprimante, pleine largeur */
.printer-jobline {
  margin-top: 5px; display: flex; align-items: center; gap: 5px;
  padding: 4px 8px; background: var(--surface2); border-radius: 6px;
  font-weight: 700; font-size: 0.74rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.stats-grid-v18 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 6px; flex: 1; align-content: start; }
.stat-item {
  background: var(--field);
  padding: 5px 8px; border-radius: 10px;
}
.stat-item label { display: block; font-size: 0.58rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-item span { font-family: var(--font-mono); font-weight: 600; font-size: 0.82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.card-footer-v18 {
  padding: 7px 14px;
  background: var(--field);
  border-top: 0.5px solid var(--border);
  margin-top: auto;
}
.ams-row-v18 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
/* Rangée AMS + bobine(s) externe(s) : 5 colonnes (1 emplacement externe) ou
   6 (machine à double buse : EXT + EXT2). Les tuiles se resserrent, jamais de
   retour à la ligne (le label est en ellipsis). */
.ams-row-v18.has-5 { grid-template-columns: repeat(5, 1fr); }
.ams-row-v18.has-6 { grid-template-columns: repeat(6, 1fr); }
.v18-ams-slot {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--border);
  opacity: 0.55;
  font-size: 0.62rem;
  color: var(--text2);
}
.v18-ams-slot.active { opacity: 1; border-color: var(--accent); color: var(--text); }
/* Emplacement externe dont le filament est déclaré mais pas en service :
   lisible sans laisser croire qu'il alimente l'impression en cours. */
.v18-ams-slot.declared { opacity: 0.9; border-style: dashed; }
.ams-row-v18.has-5 .v18-ams-slot, .ams-row-v18.has-6 .v18-ams-slot { padding: 4px 6px; gap: 4px; }
.ams-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.ams-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }

/* ── Déclaration du filament d'un emplacement AMS (Phase 3, 09/2026) ──────────
   Le ✏ n'apparaît que sur les emplacements occupés d'une machine LAN+dev ;
   il reste discret (visible au survol) pour ne pas charger la carte imprimante. */
.v18-ams-slot { position: relative; }
.ams-edit {
  flex-shrink: 0; margin-left: auto;
  border: 0; background: transparent; cursor: pointer;
  font-size: 0.62rem; line-height: 1; padding: 2px 3px;
  border-radius: 5px; color: var(--text2); opacity: 0;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.v18-ams-slot:hover .ams-edit, .ams-edit:focus-visible { opacity: 1; }
.ams-edit:hover { background: var(--field); color: var(--accent); }
@media (hover: none) { .ams-edit { opacity: .75; } }

.ams-current {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 8px 10px; background: var(--field); border-radius: 8px;
  font-size: 0.78rem; color: var(--text2);
}
.ams-current .ams-dot { width: 12px; height: 12px; border: 1px solid var(--border); }
.ams-hint { font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); margin: 6px 0 0; }
.ams-warn { color: var(--warn); }
.ams-color-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.ams-color-row input[type="color"] { width: 52px; height: 36px; padding: 2px; cursor: pointer; flex-shrink: 0; background: var(--field); border: 1px solid var(--border); border-radius: 8px; }
.ams-color-row input[type="text"] { flex: 1; margin-top: 0; text-transform: uppercase; font-family: var(--font-mono); }
#ams-modal select { width: 100%; margin-top: 6px; }
/* Conditions AMS (température + humidité) + heures de fonctionnement machine */
.ams-cond-row {
  margin-top: 6px; padding-top: 5px; border-top: 0.5px solid var(--border);
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--text2);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.ams-cond-row .ams-cond-hours { white-space: nowrap; }
.ams-cond-row .ams-cond-hours b { color: var(--text); font-weight: 700; }

/* Barre de progression */
.v18-progress-section { padding: 8px 14px; border-top: 0.5px solid var(--border); }

/* Actions imprimante (Phase 2 — LAN+dev) */
.printer-actions {
  display: flex; gap: 8px; padding: 4px 14px 10px; flex-wrap: wrap;
}
.printer-act-btn {
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: var(--field); color: var(--text2);
  border: 1px solid var(--border); transition: opacity .15s;
}
.printer-act-btn:hover { opacity: .75; }
.printer-act-btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.printer-act-btn.danger { background: rgba(255,59,48,.12); color: var(--crit); border-color: transparent; }

.progress-bar-container {
  width: 100%; height: 8px;
  background: var(--field);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.8s ease-in-out;
}

/* Badge porte */
.door-badge { font-size: 0.6rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.door-open { background: var(--crit-soft); color: var(--crit); }
.door-closed { background: var(--field); color: var(--text2); }

/* ---------- Consommation électrique ---------- */
.power-bar-wrap { padding: 20px 24px; margin-top: 18px; }
.power-bar-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); margin-bottom: 14px; }
.power-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.power-name { width: 140px; font-weight: 600; font-size: 0.82rem; color: var(--text); }
.power-bar-track { flex: 1; height: 10px; background: var(--field); border-radius: 999px; overflow: hidden; }
.power-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.power-w { width: 90px; text-align: right; font-family: var(--font-mono); font-weight: 700; color: var(--text); font-size: 1rem; }
.power-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  background: var(--accent-glow);
  border-radius: 14px;
  margin-top: 16px;
}
.power-total-label { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.power-total-val { font-size: 1.9rem; font-weight: 700; color: var(--accent); font-family: var(--font-mono); letter-spacing: -0.02em; }

/* ---------- Maintenance ---------- */
.maint-quicknav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.maint-quicknav a {
  font-family: var(--font-mono); font-size: .68rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
  background: var(--field); border-radius: 999px; padding: 6px 14px;
  transition: background 0.15s ease;
}
.maint-quicknav a:hover { background: var(--surface2); }
/* Ancres : compenser le header glass sticky (~110px) pour un scroll précis */
#bed-content, #maintenance-content, #spares-section { scroll-margin-top: 110px; }
html { scroll-behavior: smooth; }
.maint-section { padding: 22px; margin-bottom: 20px; }
.maint-hours-big { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.maint-hours-display { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }
.maint-hours-info { font-size: 0.75rem; color: var(--text2); }
.maint-big-bar { height: 8px; background: var(--field); border-radius: 999px; margin: 12px 0; overflow: hidden; }
.maint-big-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.maint-card { padding: 16px 18px; }
.maint-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.maint-task-name { font-weight: 700; font-size: 0.88rem; }
.maint-task-level { font-size: 0.7rem; color: var(--text2); font-family: var(--font-mono); }
.maint-last-done { font-size: 0.7rem; color: var(--text2); }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
th {
  text-align: left; padding: 12px 16px;
  font-size: 0.7rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--field);
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 0.5px solid var(--border); font-size: 0.82rem; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--field); }
.history-wrap { overflow-x: auto; border-radius: 14px; }

/* ---------- Graphiques ---------- */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { padding: 20px; }
.chart-title { font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 14px; letter-spacing: -0.01em; }
.charts-grid canvas { max-height: 260px; }

/* ---------- Bobines (spools) ---------- */
.spool-grid { grid-template-columns: repeat(4, 1fr); }
.spool-card { overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, box-shadow 0.15s ease; padding: 0; }
.spool-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08); }
.spool-color-strip { height: 7px; width: 100%; display: block; flex-shrink: 0; }
.spool-card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.spool-mat { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); font-family: var(--font-mono); }
.spool-name { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.01em; }
.spool-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }

/* ---------- Catalogue ---------- */
.catalog-card { overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, box-shadow 0.15s ease; padding: 0; }
.catalog-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08); }
.catalog-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; }
.catalog-cat { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); font-family: var(--font-mono); margin-bottom: 4px; }
.catalog-name { font-weight: 700; font-size: 0.88rem; line-height: 1.3; }
.catalog-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Séries multi-plateaux : couleurs par plateau + compatibilité ------ */
/* Bloc compact : 1 ligne par plateau (pastilles couleur + matrice ✓/✗ machines). */
.plates-block { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border); }
.pl-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.pl-count { font-size: 0.62rem; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.pl-swlist { display: inline-flex; gap: 3px; align-items: center; }
.pl-colors { font-size: 0.55rem; color: var(--muted); font-family: var(--font-mono); }
.pl-rows { display: flex; flex-direction: column; gap: 3px; }
.pl-row { display: flex; align-items: center; gap: 6px; padding: 2px 5px; border-radius: 6px; background: var(--surface2); }
.pl-num { font-family: var(--font-mono); font-size: 0.55rem; font-weight: 800; color: var(--muted); min-width: 17px; }
.pl-sws { display: inline-flex; gap: 3px; align-items: center; min-width: 13px; }
.pl-none { font-size: 0.55rem; color: var(--muted); }
.pl-mach { display: inline-flex; gap: 3px; margin-left: auto; }
.pl-sw { display: inline-block; border-radius: 50%; flex-shrink: 0;
         box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--border); }
.mchip { font-family: var(--font-mono); font-size: 0.52rem; font-weight: 700; line-height: 1.5;
         padding: 0 4px; border-radius: 4px; white-space: nowrap; }
.mchip.on  { background: var(--ok-soft); color: var(--ok); }
.mchip.off { background: var(--crit-soft); color: var(--crit); opacity: 0.8; }

/* ---------- Pièces détachées ---------- */
.spare-card { padding: 16px 18px; }
.spare-cat { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); font-family: var(--font-mono); }
.spare-name { font-weight: 700; font-size: 0.9rem; margin: 4px 0; }
.spare-qty { font-size: 0.75rem; color: var(--text2); font-family: var(--font-mono); }

/* ---------- Ventes (sales) ---------- */
.sales-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.sales-kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.sales-kpi { padding: 20px; }
.sales-kpi-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); }
.sales-kpi-val { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; margin: 8px 0; font-family: var(--font-mono); }
.sales-kpi-sub { font-size: 0.72rem; color: var(--text2); }
/* KPI compacts (onglet Ventes, 09/2026) : la mention secondaire passe À DROITE de la
   valeur au lieu d'occuper une 3e ligne → tuile nettement moins haute. */
.sales-kpi.compact { padding: 13px 18px; display: flex; flex-direction: column; justify-content: center; }
.sales-kpi.compact .sales-kpi-val { margin: 5px 0 0; }
.sales-kpi-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sales-kpi-line .sales-kpi-sub { text-align: right; margin-left: auto; }

/* ---------- Pannes ---------- */
.failure-card { padding: 16px 18px; }
.failure-card h4 { margin: 0 0 6px; font-size: 0.9rem; font-weight: 700; }

/* ---------- File d'attente ---------- */
.queue-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--card);
  border-radius: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.queue-item:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1); }
.queue-drag { cursor: grab; color: var(--text3); user-select: none; }
.queue-drag:active { cursor: grabbing; }
.done-item { opacity: 0.6; }

/* Badges génériques */
.status-badge, .task-badge, .badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.62rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--field); color: var(--text2);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-crit { background: var(--crit-soft); color: var(--crit); }

/* Étiquettes / divers */
.font-mono { font-family: var(--font-mono); }
.error { color: var(--crit); font-size: 0.8rem; }
.full { grid-column: 1 / -1; }
.info-section { padding: 18px; margin-bottom: 16px; }
.stat-cell { padding: 10px 14px; background: var(--field); border-radius: 12px; }
.stat-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); }
.stat-value { font-family: var(--font-mono); font-weight: 700; font-size: 0.95rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }

/* ---------- Modals ---------- */
.modal-overlay, .cam-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open, .cam-modal.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 28px;
  width: 520px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.modal h3 { margin: 0 0 10px; font-size: 1.1rem; font-weight: 700; }
.modal label { margin-top: 14px; }
.modal textarea { min-height: 80px; resize: vertical; }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Visionneuse caméra */
.cam-modal { background: rgba(0, 0, 0, 0.9); }
.cam-modal img, .cam-modal video { max-width: 92vw; max-height: 88vh; border-radius: 14px; }
/* Pastille d'état du flux dans la visionneuse : DIRECT (go2rtc, LAN) ou Photo
   (repli sur le snapshot quand on n'est pas sur le réseau de l'atelier). */
.cam-modal-badge {
  position: absolute; top: 20px; left: 20px;
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em;
  padding: 4px 10px; border-radius: 999px; color: #fff;
  background: rgba(255, 255, 255, 0.14); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.cam-modal-badge.live { background: rgba(52, 199, 89, 0.85); }

/* ---------- Bandeaux KPI génériques (spools/catalog/failures/queue) ---------- */
#spools-kpi, #catalog-kpi, #failures-kpi, #queue-kpi-bar, #availability-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
#spools-kpi > div, #catalog-kpi > div, #failures-kpi > div, #queue-kpi-bar > div, #availability-bar > div {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

/* Bandeaux d'info (stock bas, courbe d'apprentissage, résultat optimiseur) */
#low-stock-banner {
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.78rem;
}
#learning-curve-banner { margin-bottom: 14px; }
#schedule-result { margin-top: 14px; }

/* ---------- Filtres type « time-btn » ---------- */
.time-btn {
  background: var(--field);
  border: none;
  color: var(--text2);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.time-btn:hover { background: var(--field2); color: var(--text); }
.time-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- Divers formulaires ---------- */
.form-card-inner { padding: 20px; max-width: 480px; }
.form-group-s { margin-bottom: 14px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.printer-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-btn { text-decoration: none; }

/* Lignes produits du formulaire commande (ventes multi-produits) */
.ord-line {
  display: grid;
  grid-template-columns: minmax(180px,2fr) 56px 84px 84px 78px 88px 74px 30px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Recherche produit = combobox (champ visible + <select> catalogue caché).
   La liste se déroule sous le champ, sans pousser la mise en page. */
.ord-cat { position: relative; min-width: 0; }
.ord-cat-input { width: 100%; box-sizing: border-box; }
.ord-cat-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.ord-cat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.ord-cat-item:last-child { border-bottom: none; }
.ord-cat-item:hover { background: var(--field); }
.ord-cat-name { font-size: 0.78rem; }
.ord-cat-meta { font-size: 0.62rem; color: var(--muted); font-family: var(--font-mono); }
.ord-cat-empty { padding: 9px 10px; font-size: 0.72rem; color: var(--muted); }

@media (max-width: 720px) {
  .ord-line { grid-template-columns: 1fr 1fr; }
  .ord-line .ord-cat { grid-column: span 2; }
  .ord-line input:nth-child(2) { grid-column: span 2; }
}

/* Notes */
#notes-content .notes-card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow); }

/* ---------- Zone drag & drop image (catalogue) ---------- */
.cat-dropzone {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--field);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
}
.cat-dropzone:hover { border-color: var(--accent); background: var(--card); }
.cat-dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: scale(1.01);
}
.cat-dropzone-icon { display: block; font-size: 1.5rem; margin-bottom: 6px; }
.cat-dropzone-text { font-size: 0.8rem; color: var(--text2); font-weight: 500; }
.cat-dropzone-text small { color: var(--text3); font-size: 0.68rem; }

/* Calendrier */
#calendar-container { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
#cal-legend > span { display: inline-flex; align-items: center; gap: 5px; font-size: 0.7rem; color: var(--text2); }

/* Surcharges FullCalendar (clair/sombre) */
.fc { --fc-border-color: var(--border); --fc-page-bg-color: transparent; --fc-neutral-bg-color: var(--field); --fc-today-bg-color: var(--accent-glow); --fc-event-bg-color: var(--accent); --fc-event-border-color: transparent; --fc-event-text-color: #fff; --fc-list-event-hover-bg-color: var(--field); color: var(--text); font-family: var(--font-sans); }
.fc .fc-toolbar-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.fc .fc-button { background: var(--field); border: none; color: var(--link); font-family: var(--font-sans); font-weight: 600; border-radius: 999px !important; padding: 5px 14px; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--accent); color: #fff; }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: var(--text2); text-decoration: none; }

/* Calendrier : session en cours (pulse doux) + détail au clic */
.fc .cal-running { animation: calPulse 2.2s ease-in-out infinite; }
@keyframes calPulse { 0%, 100% { opacity: 1; } 50% { opacity: .72; } }
.cal-detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 9px 14px; margin-top: 4px; }
.cal-dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); padding-top: 2px; }
.cal-dd { font-size: .86rem; }
.cal-warn { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: .8rem; }
.cal-warn.crit { background: var(--crit-soft); color: var(--crit); }
.fc th { background: transparent; }

/* Surcharges Chart.js : légendes lisibles */
.chart-card canvas { color: var(--text2); }
/* ==========================================================================
   PARTIE 3 — Plateaux, file d'attente, ventes + pages secondaires
   (login, admin, atelier, imports)
   ========================================================================== */

/* ---------- Nettoyage plateaux ---------- */
.bed-grid { grid-template-columns: repeat(4, 1fr); }
.bed-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease;
}
.bed-card.urgent { box-shadow: 0 0 0 2px var(--crit); }
.bed-prints-big { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.bed-bar { border-radius: 999px; }
.bed-bar-fill { border-radius: 999px; transition: width 0.6s ease; }

/* ---------- Plateau à vider (pièces encore sur le plateau) ---------- */
/* Bloc ambre : la machine ne reçoit plus aucun lancement automatique tant que
   l'acquittement « Pièces retirées » n'est pas fait. */
.bed-unload {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 10px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--warn);
}
.bed-unload b { display: block; font-size: 0.72rem; letter-spacing: 0.02em; }
.bed-unload small { color: var(--muted); font-family: var(--font-mono); font-size: 0.6rem; }
.bed-lock { font-size: 0.6rem; color: var(--crit); margin-top: 8px; font-family: var(--font-mono); }
.bed-btn-cleared {
  background: var(--warn);
  color: #14161a;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 6px;
}
.bed-btn-cleared:active { opacity: 0.75; }
.bed-btn-cleared:disabled { opacity: 0.5; cursor: default; }

/* ---------- File d'attente : barre de charge + KPIs ---------- */
#availability-bar > div { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 600; }
#availability-bar .avail-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
#queue-kpi-bar > div { display: flex; flex-direction: column; gap: 2px; }
#queue-kpi-bar b { font-size: 1.15rem; font-family: var(--font-mono); letter-spacing: -0.01em; }
#queue-kpi-bar span { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); }
.queue-list { margin-top: 6px; }

/* ---------- Ventes : cartes commandes ---------- */
.order-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.order-card:hover { transform: translateY(-1px); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08); }

/* ==========================================================================
   PAGE LOGIN
   ========================================================================== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  width: 400px;
  max-width: 100%;
  background: var(--card);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-logo {
  width: 64px; height: 64px;
  background: var(--field);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: var(--shadow);
}
.login-logo img { width: 38px; height: 38px; object-fit: contain; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-header h1 span { color: var(--accent); }
.login-header p { font-size: 0.72rem; color: var(--text2); letter-spacing: 0.06em; text-transform: uppercase; margin: 0; }
.login-card .form-group { margin-bottom: 16px; }
.login-card input[type="text"], .login-card input[type="password"] { font-size: 0.95rem; padding: 12px 16px; }
.login-card .submit-btn { width: 100%; justify-content: center; padding: 12px; font-size: 0.88rem; margin-top: 6px; }
/* « Rester connecté » + aide 2FA (09/2026) */
.login-remember {
  display: flex; align-items: center; gap: 9px;
  margin: 2px 0 4px; cursor: pointer;
  font-size: 0.76rem; font-weight: 500; color: var(--text2);
  text-transform: none; letter-spacing: 0;
}
.login-remember input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.login-hint { font-size: 0.7rem; line-height: 1.5; color: var(--text2); margin-top: 14px; }
.login-card .login-footer a { text-decoration: none; }
.login-card .error-msg {
  background: var(--crit-soft);
  color: var(--crit);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  animation: shake 0.3s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.login-footer { text-align: center; margin-top: 26px; font-size: 0.62rem; color: var(--text3); letter-spacing: 0.04em; }

/* ==========================================================================
   PAGE ADMIN
   ========================================================================== */
.admin-body { background: var(--bg); color: var(--text); min-height: 100vh; }
.page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.page-sub { font-size: 0.8rem; color: var(--text2); margin: 0 0 26px; }
.btn-link {
  background: var(--field);
  border: none;
  color: var(--link);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: opacity 0.15s ease;
}
.btn-link:hover { opacity: 0.85; text-decoration: none; }

.printers-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.printer-row {
  background: var(--card);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.printer-color-dot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; }
.printer-row-info { flex: 1; min-width: 0; }
.printer-row-name { font-weight: 700; font-size: 0.95rem; }
.printer-row-model { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text2); margin-top: 2px; }
.printer-row-actions { display: flex; gap: 8px; }

.form-card { background: var(--card); border-radius: 16px; padding: 26px; display: none; box-shadow: var(--shadow); margin-bottom: 20px; }
.form-card.visible { display: block; }
.form-title { font-size: 1rem; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-section { margin: 18px 0 10px; padding-bottom: 8px; border-bottom: 0.5px solid var(--border); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.badge-inactive {
  font-size: 0.62rem; font-weight: 600;
  background: var(--crit-soft); color: var(--crit);
  padding: 2px 9px; border-radius: 999px;
}
.alert { padding: 10px 14px; border-radius: 12px; font-size: 0.78rem; margin-bottom: 14px; display: none; }
.alert.ok { display: block; background: var(--ok-soft); color: var(--ok); }
.alert.err { display: block; background: var(--crit-soft); color: var(--crit); }

/* ==========================================================================
   PAGE ATELIER (écran PIN + vue atelier)
   ========================================================================== */
.atelier-pin-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.pin-card {
  background: var(--card);
  border-radius: 24px;
  padding: 40px 36px;
  width: 380px;
  max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.pin-card img.logo { width: 60px; margin-bottom: 16px; }
.pin-card h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.pin-card h1 span { color: var(--accent); }
.pin-card p { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 24px; }
.pin-card .error { font-size: 0.78rem; margin-bottom: 12px; }
.pin-card button { width: 100%; justify-content: center; padding: 12px; }

/* Vue atelier */
.atelier-body { background: var(--bg); color: var(--text); min-height: 100vh; }
.atelier-header { justify-content: space-between; }
.atelier-body .logo img { height: 30px; }
.clock { font-family: var(--font-mono); font-size: 1rem; font-weight: 600; color: var(--text); }

.room-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.room-tile {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.room-tile-icon { font-size: 1.4rem; }
.room-tile-label { font-size: 0.62rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; }
.room-tile-val { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700; margin-top: 2px; }

.power-block { background: var(--card); border-radius: 14px; padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.power-block-title { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; font-weight: 600; }
.pw-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.pw-name { font-family: var(--font-mono); font-size: 0.72rem; width: 110px; flex-shrink: 0; }
.pw-track { flex: 1; height: 7px; background: var(--field); border-radius: 999px; overflow: hidden; }
.pw-fill { height: 100%; border-radius: 999px; transition: width 0.8s ease; }
.pw-val { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; width: 58px; text-align: right; }
.pw-total { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border); }
.pw-total-label { font-size: 0.75rem; color: var(--text2); font-weight: 600; }
.pw-total-val { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 700; color: var(--accent); }

.cam-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.cam-card { background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.cam-title { padding: 9px 14px; font-size: 0.74rem; font-weight: 600; border-bottom: 0.5px solid var(--border); }
.cam-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--field); }
.cam-placeholder { aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; background: var(--field); color: var(--text2); font-size: 0.75rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.card.printing { box-shadow: 0 0 0 2px var(--ok); }
.card.offline { box-shadow: 0 0 0 2px var(--crit); }
.accent-line { height: 3px; background: var(--field2); }
.card.printing .accent-line { background: var(--ok); }
.card.offline .accent-line { background: var(--crit); }
.card-head { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 0.5px solid var(--border); }
.printer-model { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text2); margin-top: 2px; }
.status-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.66rem; font-weight: 600;
  padding: 4px 11px; border-radius: 999px;
  background: var(--field); color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.dot.printing { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 1.5s infinite; }
.dot.idle { background: var(--warn); }
.dot.offline { background: var(--crit); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.progress-wrap { padding: 12px 18px; border-bottom: 0.5px solid var(--border); }
.prog-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.prog-label { font-size: 0.7rem; color: var(--text2); }
.prog-pct { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--ok); letter-spacing: -0.02em; }
.prog-bar { height: 8px; background: var(--field); border-radius: 999px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.8s ease; }
.job-name { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text2); margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.atelier-body .stat { background: var(--card); padding: 11px 14px; border-top: 0.5px solid var(--border); }
.atelier-body .stat + .stat { border-left: 0.5px solid var(--border); }
.footer-note { padding: 9px 18px; font-size: 0.64rem; color: var(--text2); text-align: center; border-top: 0.5px solid var(--border); }

/* ==========================================================================
   PAGES IMPORT (catalogue / commandes)
   ========================================================================== */
.import-body { background: var(--bg); color: var(--text); padding: 30px; min-height: 100vh; }
.import-body .wrap { max-width: 960px; margin: 0 auto; }
.import-body h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.import-body h1 span { color: var(--accent); }
.import-body .sub { font-size: 0.78rem; color: var(--text2); margin-bottom: 24px; }
.import-body .card { background: var(--card); border-radius: 16px; padding: 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.import-body .card h2 { font-size: 0.85rem; font-weight: 700; margin: 0 0 12px; }
.import-body .btn-back { margin-bottom: 18px; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 0.7rem; overflow-x: auto; display: block; font-family: var(--font-mono); }
.preview-table th { background: var(--field); color: var(--text); padding: 7px 10px; text-align: left; white-space: nowrap; border-bottom: 0.5px solid var(--border); }
.preview-table td { padding: 6px 10px; border-bottom: 0.5px solid var(--border); color: var(--text2); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.tip { font-size: 0.72rem; color: var(--text2); margin-top: 8px; line-height: 1.6; }
.required { color: var(--crit); }
.ok { color: var(--ok); }
.err { color: var(--crit); }
.warn { color: var(--warn); }
.import-body input[type="file"] { font-size: 0.8rem; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  .printers-grid, .spool-grid, .spare-grid, .catalog-grid, #stats-printers-grid, .maint-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .cam-grid { grid-template-columns: repeat(2, 1fr); }
  .cameras-block { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .sales-kpi-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
/* ---- Badge runner (P2) : le Mac dit-il encore quelque chose ? ---- */
#runner-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.68rem; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); white-space: nowrap;
}
#runner-badge .run-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
#runner-badge.run-ok   { color: var(--ok);   border-color: var(--ok)55;   background: var(--ok)11; }
#runner-badge.run-crit { color: var(--crit); border-color: var(--crit)55; background: var(--crit)11;
                         animation: runPulse 2s ease-in-out infinite; }
@keyframes runPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

@media (max-width: 640px) {
  header { padding: 10px 16px; }
  #runner-badge { font-size: 0.6rem; padding: 4px 7px; }
  .nav-tabs { padding: 8px 16px; }
  main { padding: 16px; }
  .printers-grid, .spool-grid, .spare-grid, .catalog-grid, #stats-printers-grid, .maint-cards-grid { grid-template-columns: 1fr; }
  .cameras-block, .cam-grid, .room-bar { grid-template-columns: 1fr; }
  .env-block { flex-direction: column; }
  .env-card { min-width: 100%; }
  .sales-kpi-grid, .sales-kpi-grid.cols-4, .charts-grid { grid-template-columns: 1fr; }
  .header-right .last-upd { display: none; }
  .form-grid, .map-grid, .form-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   COCKPIT « AUJOURD'HUI » (onglet today)
   ------------------------------------------------------------
   Langage iOS : surfaces pleines, pas de bordure sur les cartes,
   une seule couleur d'accent (le bleu), statuts en version « soft ».
   Les couleurs viennent des tokens — donc le mode sombre suit tout seul.
   ============================================================ */
.ck-wrap { display: flex; flex-direction: column; gap: 22px; max-width: 980px; }
.ck-note {
  font-size: 0.78rem; color: var(--text-secondary);
  background: var(--field); border-radius: 12px; padding: 10px 14px;
}
.ck-section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.ck-section-head h2 {
  font-size: 0.86rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-secondary); margin: 0;
}
.ck-count {
  display: inline-block; min-width: 20px; text-align: center;
  font-size: 0.7rem; font-weight: 700; font-family: var(--font-mono);
  color: var(--primary); background: var(--primary-soft);
  border-radius: 980px; padding: 1px 7px;
}
.ck-hint { font-size: 0.72rem; color: var(--text-tertiary); }
.ck-card {
  background: var(--card); border-radius: 14px;
  padding: 12px 15px; margin-bottom: 8px;
}
.ck-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.88rem;
}
.ck-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ck-muted { font-size: 0.76rem; color: var(--text-secondary); }
.ck-detail { font-size: 0.74rem; color: var(--text-secondary); margin-top: 6px; }
.ck-tag {
  font-size: 0.66rem; font-weight: 700; padding: 2px 8px; border-radius: 980px;
  background: var(--field); color: var(--text-secondary); white-space: nowrap;
}
.ck-tag-warn { background: var(--warn-soft); color: var(--warn); }
.ck-tag-crit { background: var(--crit-soft); color: var(--crit-dark-text); }
.ck-tag-ok   { background: var(--ok-soft);   color: var(--ok); }
.ck-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ck-btn {
  font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer;
  padding: 6px 14px; border-radius: 980px; border: none;
  background: var(--field); color: var(--link);
}
.ck-btn-primary { background: var(--primary); color: #fff; }
.ck-btn-danger { background: var(--crit-soft); color: var(--crit-dark-text); }
.ck-btn:active { transform: scale(0.97); }
.ck-input {
  font: inherit; font-size: 0.78rem; padding: 5px 10px; border-radius: 9px;
  border: none; background: var(--field); color: var(--text); width: 150px;
}
.ck-bar {
  height: 5px; border-radius: 980px; background: var(--field);
  margin-top: 9px; overflow: hidden;
}
.ck-bar span { display: block; height: 100%; background: var(--ok); border-radius: 980px; }
.ck-subhead {
  font-size: 0.76rem; font-weight: 600; color: var(--text-secondary);
  margin: 12px 0 8px;
}
.ck-empty {
  font-size: 0.8rem; color: var(--text-tertiary);
  background: var(--field); border-radius: 12px; padding: 14px;
  text-align: center;
}
.ck-foot {
  font-size: 0.7rem; color: var(--text-tertiary); text-align: center;
  font-family: var(--font-mono);
}
@media (max-width: 640px) {
  .ck-input { width: 100%; }
}

/* ============================================================
   OPÉRATIONS ATELIER (modale filament / pièces)
   ============================================================ */
.ops-modal {
  display: none; position: fixed; inset: 0; z-index: 1200;
  background: rgba(0, 0, 0, 0.55);
  align-items: center; justify-content: center; padding: 20px;
}
.ops-box {
  background: var(--card); color: var(--text);
  border-radius: 18px; width: 100%; max-width: 560px; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.ops-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--separator, rgba(0,0,0,0.08));
}
.ops-head h3 { margin: 0; font-size: 1rem; }
.ops-close {
  border: none; background: var(--field); color: var(--text);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 0.9rem;
}
#ops-body { padding: 16px 20px 22px; overflow-y: auto; }
.ops-section { margin-bottom: 14px; }
.ops-label { display: block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); margin-bottom: 6px; }
.ops-input {
  font: inherit; font-size: 0.82rem; padding: 7px 10px; border-radius: 9px;
  border: none; background: var(--field); color: var(--text); width: 110px;
}
.ops-row {
  background: var(--field); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.ops-row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.86rem; }
.ops-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ops-muted { font-size: 0.74rem; color: var(--text-secondary); }
.ops-tag {
  font-size: 0.64rem; font-weight: 700; padding: 2px 7px; border-radius: 980px;
  background: var(--card); color: var(--text-secondary);
}
.ops-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ops-btn {
  font: inherit; font-size: 0.76rem; font-weight: 600; cursor: pointer;
  padding: 6px 12px; border-radius: 980px; border: none;
  background: var(--field); color: var(--link);
}
.ops-btn-primary { background: var(--primary); color: #fff; }
.ops-btn-danger { background: var(--crit-soft); color: var(--crit-dark-text); }
.ops-btn:active { transform: scale(0.97); }
.ops-check {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  background: var(--field); border-radius: 10px; margin-bottom: 6px; font-size: 0.84rem;
}
.ops-check input { width: 16px; height: 16px; }
.ops-empty {
  font-size: 0.82rem; color: var(--text-tertiary); background: var(--field);
  border-radius: 12px; padding: 14px; text-align: center;
}
.ops-hint { font-size: 0.72rem; color: var(--text-tertiary); line-height: 1.45; margin-top: 10px; }

