:root {
  --bg: #0A0A0C;
  --bg-side: #07070A;
  --card: #131317;
  --input: #0F0F13;
  --pill: #1B1B22;
  --pill-alt: #121218;
  --border: #26262E;
  --border-light: #2E2E38;
  --divider: #1D1D24;

  --text: #F2F2F4;
  --text-2: #B9B9C4;
  --text-3: #8C8C99;
  --text-4: #7C7C88;
  --text-5: #6B6B78;
  --text-6: #5C5C68;

  --blue: #174BD0;
  --blue-hover: #2A5DE0;
  --blue-border: #3D6BFF;
  --blue-link: #6E93FF;
  --blue-link-hover: #9DB6FF;

  --yellow: #FFEC01;
  --yellow-hover: #FFF35C;
  --green: #4FD164;
  --red: #FF6B6B;
  --red-bg: rgba(218,5,5,.12);
  --red-border: #5A1418;

  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

input, button, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-link); text-decoration: none; }
a:hover { color: var(--blue-link-hover); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* L'attribut hidden doit gagner sur les display: flex des composants. */
[hidden] { display: none !important; }

@keyframes evxpulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes evxsweep { 0% { transform: translateY(-100%); } 100% { transform: translateY(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell (sidebar + content) ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 216px;
  flex: none;
  background: var(--bg-side);
  border-right: 1px solid #1B1B22;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar .brand {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .04em;
  color: var(--text);
  padding: 4px 6px;
}
.sidebar .brand:hover { color: var(--blue-link); }

.sidebar .event-name {
  font-size: 12px;
  color: var(--text-3);
  padding: 0 6px;
  margin-top: -10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 10px;
  padding: 10px 11px;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  color: var(--text-4);
}
.nav-link:hover { background: #14141A; color: var(--text); }
/* color-mix : suit la couleur principale choisie (Paramètres) ; la ligne rgba sert aux vieux navigateurs. */
.nav-link.active { background: rgba(23,75,208,.18); background: color-mix(in srgb, var(--blue) 18%, transparent); color: #DCE4FF; color: color-mix(in srgb, var(--blue-link-hover) 45%, #fff); }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid #1B1B22;
  padding-top: 12px;
  font-size: 12px;
  color: var(--text-5);
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid #1B1B22;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-5);
  margin-top: 3px;
}
.topbar .spacer { flex: 1; }

.net-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--pill-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-2);
}
.net-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--green); animation: evxpulse 2.4s infinite; }

main.content {
  flex: 1;
  padding: 20px 24px 40px;
  overflow: auto;
  max-width: 1200px;
  width: 100%;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    gap: 10px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid #1B1B22;
  }
  .sidebar .brand { padding: 0; }
  .sidebar .event-name { display: none; }
  .sidebar .brand-org { display: none; }
  .nav-links { flex-direction: row; }
  .nav-link { white-space: nowrap; padding: 8px 10px; }
  .sidebar-footer { display: none; }
  main.content { padding: 16px; }
  .topbar { padding: 12px 16px; }

  #caisseGrid { grid-template-columns: 1fr !important; }
  #dashGrid { grid-template-columns: 1fr !important; }
  #newForm { grid-template-columns: 1fr !important; }
  .cart-panel { position: static !important; }
}

/* ---------- Cards / KPIs ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.kpi-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-4);
}
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; }
.kpi-note { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- Tableau de bord en direct ---------- */

#kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { #kpis { grid-template-columns: 1fr; } }
.live-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.live-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.live-chart { width: 100%; overflow: hidden; }
.live-chart svg { display: block; }
.live-chart text { font-family: 'JetBrains Mono', monospace; font-size: 10px; fill: var(--text-5); }
.live-chart .grid { stroke: var(--divider); stroke-width: 1; }
.live-chart .bar-in { fill: var(--green); }
.live-chart .bar-sold { fill: var(--blue-border); }
.live-chart g:hover rect[fill="transparent"] { fill: rgba(255,255,255,.04); }

.section-title { font-size: 15px; font-weight: 600; }

/* ---------- Buttons / inputs ---------- */

.btn {
  border: 1px solid var(--border-light);
  border-radius: 9px;
  background: var(--pill);
  color: var(--text);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: #23232B; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--on-accent, #fff); font-weight: 600; }
.btn-primary:hover { background: var(--blue-hover); }

.btn-cash { background: var(--yellow); border: 0; color: #0A0A0C; font-weight: 700; }
.btn-cash:hover { background: var(--yellow-hover); }

.btn-ghost { background: none; border: 1px solid var(--border-light); color: var(--text-2); }
.btn-ghost:hover { background: var(--pill); }

.btn-danger { background: none; border: 1px solid var(--border-light); color: var(--text-4); }
.btn-danger:hover { color: var(--red); border-color: var(--red-border); }

.field {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 13.5px;
  outline: none;
}
.field:focus { border-color: var(--blue-border); }
label.field-label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 6px; }

.form-row { margin-bottom: 12px; }

.pill-btn {
  border: 1px solid var(--border-light);
  background: var(--pill);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.pill-btn.active { border-color: var(--blue-border); background: rgba(23,75,208,.16); background: color-mix(in srgb, var(--blue) 16%, transparent); color: #DCE4FF; color: color-mix(in srgb, var(--blue-link-hover) 45%, #fff); }

/* ---------- Tiles (tarifs) ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 11px;
}

.tile {
  position: relative;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.tile:hover { border-color: var(--blue-border); }
.tile:disabled, .tile.full { opacity: .45; cursor: not-allowed; }
.tile .tname { display: block; font-size: 15px; font-weight: 600; line-height: 1.25; }
.tile .tstock { display: block; font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-4); margin-top: 5px; }
.tile .tbottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.tile .tprice { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.tile .tqty { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; background: var(--blue); color: var(--on-accent, #fff); border-radius: 8px; padding: 3px 9px; }

/* ---------- Cart ---------- */

.cart-panel { position: sticky; top: 80px; }
.cart-line { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.cart-line .lname { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-line .ltotal { font-family: 'JetBrains Mono', monospace; font-size: 13px; min-width: 60px; text-align: right; color: var(--text-2); }

.stepper-btn:disabled { opacity: .35; cursor: not-allowed; }
.stepper-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--border-light); background: var(--pill);
  font-size: 15px; line-height: 1; cursor: pointer;
}
.stepper-qty { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; min-width: 18px; text-align: center; }

.cart-total-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-top: 14px; border-top: 1px solid var(--border); margin-top: 6px;
}
.cart-total-label { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-4); }
.cart-total-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }

/* ---------- Table / history ---------- */

.table-scroll { overflow-x: auto; }
table.history { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 13px; }
table.history th, table.history td {
  text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--divider);
}
table.history th {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-4); font-weight: 500;
}
table.history td.num { font-family: 'JetBrains Mono', monospace; }

.tag {
  display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  letter-spacing: .1em; text-transform: uppercase; border-radius: 5px; padding: 2px 6px;
}
.tag.paid { color: var(--green); border: 1px solid #1F5C2A; }
.tag.pending { color: var(--yellow); border: 1px solid #4A4520; }
.tag.cancelled { color: var(--red); border: 1px solid var(--red-border); }
.tag.cash { color: var(--yellow); border: 1px solid #4A4520; }
.tag.card { color: var(--blue-link); border: 1px solid #1F2E5C; border-color: color-mix(in srgb, var(--blue) 45%, var(--bg)); }

/* ---------- Generic feedback ---------- */

.banner { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.banner.error { background: var(--red-bg); border: 1px solid var(--red-border); color: #FF9C9C; }
.banner.info { background: rgba(23,75,208,.14); background: color-mix(in srgb, var(--blue) 14%, transparent); border: 1px solid #1F2E5C; border-color: color-mix(in srgb, var(--blue) 45%, var(--bg)); color: #DCE4FF; }
.banner.success { background: rgba(79,209,100,.1); border: 1px solid #1F5C2A; color: #8FE39C; }

.hint { font-size: 12px; color: var(--text-3); }
.center { text-align: center; }
.empty-state { text-align: center; padding: 30px 10px; color: var(--text-5); }
.empty-state img { width: 64px; height: auto; opacity: .5; margin-bottom: 10px; }

.spinner {
  width: 32px; height: 32px; margin: 24px auto;
  border: 3px solid var(--border);
  border-top-color: var(--blue-border);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ---------- Cards grid (events list, connect, generic) ---------- */

.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ticket-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--card); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
/* Boutique : une tuile produit avec ses tailles, stock restant sur le stand. */
.shop-tile { cursor: default; gap: 8px; }
.variant-row { display: flex; flex-wrap: wrap; gap: 6px; }
.variant-chip {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 46px;
  padding: 6px 9px; border-radius: 9px; cursor: pointer;
  background: var(--pill); border: 1px solid var(--border-light); color: var(--text);
  font: inherit; font-size: 13px; line-height: 1.15;
}
.variant-chip span { font-size: 10.5px; color: var(--text-4); font-family: 'JetBrains Mono', monospace; }
.variant-chip:hover:not(:disabled) { border-color: var(--blue-border); }
.variant-chip.is-low span { color: var(--yellow); }
.variant-chip:disabled { opacity: .4; cursor: not-allowed; }
.cash-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border-light); border-radius: 11px; }
.cash-panel[hidden] { display: none; }
.cash-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.cash-change { font-size: 15px; }
.cash-change b { font-size: 20px; color: var(--green); }
.cash-change.is-short { color: var(--red); }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
/* Réappro : demandes des stands (page Réassort) et suivi côté stand. */
.restock-card { display: flex; flex-direction: column; gap: 10px; }
.restock-card.is-open { border-color: var(--blue-border); }
.restock-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.restock-stand { font-size: 18px; font-weight: 700; }
.restock-note { color: var(--text-2); font-style: italic; }
.restock-lines { display: flex; flex-direction: column; gap: 6px; }
.restock-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 90px; gap: 10px; align-items: center; }
.restock-line .field { padding: 7px 9px; }
.restock-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.restock-done { font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--divider); }
.my-requests { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.my-requests:empty { display: none; }
.my-request { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; padding: 7px 10px; border-radius: 9px; background: var(--pill); }
.my-request.is-delivered { opacity: .7; }
.my-request.is-cancelled { opacity: .45; text-decoration: line-through; }
@media (max-width: 520px) { .restock-line { grid-template-columns: minmax(0, 1fr) 80px; } .restock-line .hint { grid-column: 1 / -1; order: 3; } }
/* Accueil : un événement = bouton d'ouverture + actions (archiver, supprimer). */
.event-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.event-row .event-open { flex: 1; min-width: 180px; background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.event-row .event-open .meta { margin-bottom: 0; }
.event-row .event-actions { display: flex; gap: 6px; flex: none; }
.event-row.is-archived { opacity: .75; }
.ticket-card .name { font-weight: 600; font-size: 15px; }
.ticket-card .meta { color: var(--text-3); font-size: 12.5px; margin: 4px 0 12px; }

/* ---------- People chips (equipe / planning / badges) ---------- */

.person-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px;
}
.role-mini {
  display: block; max-width: 100%; margin-top: 6px;
  background: var(--input); color: var(--text-2);
  border: 1px solid var(--border-light); border-radius: 7px;
  padding: 3px 6px; font: inherit; font-size: 11.5px;
}
.person-chip {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border-light);
}
.person-role {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
}

/* ---------- Login / anonymous ---------- */

.anon-wrap {
  position: relative; min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: 34px; background: var(--bg-side);
}
.anon-inner { position: relative; max-width: 420px; width: 100%; margin: 0 auto; }
.wordmark { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 32px; letter-spacing: .06em; color: var(--text); margin-bottom: 4px; }
/* Nom de l'organisation sous le nom du produit (EVENYX · nom de l'association). */
.org-line { font-family: 'JetBrains Mono', monospace; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--yellow); margin-bottom: 26px; min-height: 1em; }
.sidebar .brand-org { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--yellow); margin: -2px 0 10px; display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.sidebar .brand-logo { max-height: 30px; max-width: 64px; object-fit: contain; flex: none; }
/* Logo de l'organisation au-dessus d'EVENYX (accueil, connexion). */
.org-logo { display: block; max-height: 72px; max-width: 180px; object-fit: contain; margin-bottom: 14px; }

/* ---------- Paramètres ---------- */

.settings-tabs { display: flex; align-items: center; gap: 4px; background: var(--pill-alt); border: 1px solid var(--border); border-radius: 11px; padding: 4px; align-self: flex-start; flex-wrap: wrap; }
.settings-tabs .pill-btn { border: 0; }
.settings-section { display: flex; flex-direction: column; gap: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.settings-grid .span-2 { grid-column: span 2; }
@media (max-width: 520px) { .settings-grid .span-2 { grid-column: auto; } }
textarea.field { resize: vertical; min-height: 70px; line-height: 1.45; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.module-tile { display: flex; flex-direction: column; gap: 4px; padding: 13px 14px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--pill-alt); color: var(--text); }
.module-tile:hover { border-color: var(--blue-border); color: var(--text); }
.module-name { font-weight: 600; font-size: 14px; }
.logo-box { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 130px; height: 90px; flex: none; border: 1px dashed var(--border-light); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#16161C 0% 25%, #1D1D24 0% 50%) 0 0 / 16px 16px; }
.logo-preview img { max-width: 118px; max-height: 78px; object-fit: contain; }
.accent-swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.accent-swatch { width: 42px; height: 42px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; position: relative; padding: 0; }
.accent-swatch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.accent-swatch.is-on { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg) inset; }
.accent-preview { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-input { width: 44px; height: 38px; padding: 3px; border: 1px solid var(--border-light); border-radius: 9px; background: var(--input); cursor: pointer; flex: none; }
.role-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-row .field { flex: 1; min-width: 150px; }
.role-chip { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #0A0A0C; border-radius: 6px; padding: 5px 9px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-tools { display: flex; gap: 5px; }
.role-row .role-tpl { flex: 0 1 200px; min-width: 150px; }
.tpl-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
/* Image facultative des produits : tuiles de la caisse boutique et tableau du stock. */
.shop-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 9px; background: #16161C; margin-bottom: 4px; }
.prod-name { display: inline-flex; align-items: center; gap: 8px; }
.prod-thumb { width: 34px; height: 34px; flex: none; object-fit: cover; border-radius: 6px; background: #16161C; }
/* Compteur de sortie (page Sécurité) : gros boutons, utilisables d'un pouce. */
.gate-count { font-family: 'JetBrains Mono', monospace; font-size: 46px; font-weight: 700; line-height: 1; margin-top: 10px; }
.gate-cap { font-size: 18px; font-weight: 500; color: var(--text-4); margin-left: 8px; }
.gate-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.gate-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 100px; border-radius: 16px; border: 1px solid var(--border-light); font-family: 'JetBrains Mono', monospace; font-size: 36px; font-weight: 700; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.gate-btn small { font-family: 'Space Grotesk', system-ui, sans-serif; font-size: 12.5px; font-weight: 500; }
.gate-minus { background: rgba(255, 107, 107, .12); border-color: #5A1418; color: #FF8A8A; }
.gate-plus { background: rgba(79, 209, 100, .12); border-color: #1F5C2A; color: #6FE081; }
.gate-btn:active:not(:disabled) { transform: scale(.97); }
.gate-btn:disabled { opacity: .45; cursor: default; }
.tpl-roles { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.tpl-role { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.tpl-warn { margin-top: 8px; color: var(--red); font-size: 12.5px; }
.tpl-canvas { position: relative; max-width: 640px; line-height: 0; cursor: crosshair; touch-action: none; user-select: none; border-radius: 6px; overflow: hidden; background: repeating-conic-gradient(#16161C 0% 25%, #1D1D24 0% 50%) 0 0 / 16px 16px; }
.tpl-canvas img { display: block; width: 100%; height: auto; pointer-events: none; }
.tpl-rect { position: absolute; display: flex; align-items: center; justify-content: center; border: 2px dashed #FFEC01; background: rgba(23, 75, 208, .22); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); pointer-events: none; }
.tpl-rect span { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; letter-spacing: .1em; line-height: 1.2; color: #fff; background: rgba(0, 0, 0, .6); border-radius: 4px; padding: 3px 6px; }

/* ---------- Plan & stands ---------- */

#planWrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  overflow: hidden;
  background: #0F0F13;
  border: 1px solid var(--border);
  touch-action: none;
}

#planImg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
#planImg:not([src]) { display: none; }

#drawCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#planWrap.drawing #drawCanvas { pointer-events: auto; cursor: crosshair; }
#planWrap.drawing #pins { pointer-events: none; opacity: .55; }
#planWrap.erasing #drawCanvas { cursor: pointer; }

#planEmpty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

#planHint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  background: rgba(7, 7, 10, .7);
  border-radius: 7px;
  padding: 5px 9px;
  pointer-events: none;
}

.draw-bar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 11px 14px; }

/* Largeur réservée dès le départ : sans ça, l'apparition de « enregistré »
   fait passer le groupe à la ligne et le plan se décale de quelques dizaines
   de pixels sous le curseur, en plein tracé. */
#drawStatus { display: inline-block; width: 86px; }
.draw-group { display: flex; align-items: center; gap: 5px; }
.draw-group-label {
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-5);
  margin-right: 3px;
}

.tool-btn {
  border: 1px solid var(--border-light);
  background: var(--pill);
  color: var(--text-2);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12.5px;
  cursor: pointer;
}
.tool-btn:hover { background: #23232B; color: var(--text); }
.tool-btn.active { border-color: var(--blue-border); background: rgba(23, 75, 208, .18); background: color-mix(in srgb, var(--blue) 18%, transparent); color: #DCE4FF; }

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
  cursor: pointer;
  padding: 0;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
/* L'anneau est en outline plutôt qu'en bordure : une bordure rognerait la
   pastille et la couleur sélectionnée paraîtrait plus petite que les autres. */
.swatch.active { outline-color: var(--text); }

/* ---------- Verrou RETEX ---------- */

.retex-lock {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(7, 7, 10, .97);
  overflow-y: auto;
  padding: 24px 16px 48px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.retex-lock-card {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin: auto;
}

.retex-lock-head { border-bottom: 1px solid var(--divider); padding-bottom: 18px; margin-bottom: 18px; }
.retex-lock-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 14px 0 8px; }
.retex-lock-head p { font-size: 13.5px; line-height: 1.6; color: var(--text-3); margin: 0; }

.retex-lock-badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--yellow);
  border: 1px solid #4A4520;
  background: rgba(255, 236, 1, .1);
  border-radius: 999px;
  padding: 4px 10px;
}

.retex-step-label {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-5);
  margin-bottom: 12px;
}

.retex-notme {
  background: none;
  border: 0;
  padding: 0 0 0 8px;
  color: var(--blue-link);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
}
.retex-notme:hover { color: var(--blue-link-hover); }

.retex-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  margin: 10px 0 18px;
}

.retex-person {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  cursor: pointer;
  color: var(--text);
}
.retex-person:hover { border-color: var(--blue-border); background: #16161C; }

.retex-newme { border-top: 1px solid var(--divider); padding-top: 16px; }

.retex-q { margin-bottom: 20px; }
.retex-q-label { font-size: 14px; font-weight: 600; line-height: 1.45; margin-bottom: 9px; }
.retex-q-num { color: var(--blue-link); font-size: 11px; margin-right: 6px; }
.retex-q textarea { resize: vertical; line-height: 1.5; }

.retex-scale { display: flex; gap: 7px; flex-wrap: wrap; }
.retex-scale-opt {
  flex: 1;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--input);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
}
.retex-scale-opt input { position: absolute; opacity: 0; pointer-events: none; }
.retex-scale-opt:hover { border-color: var(--border-light); }
/* .is-checked est posé en JS : :has() n'existe pas sur les navigateurs
   des tablettes un peu anciennes, et l'état sélectionné doit rester visible. */
.retex-scale-opt:has(input:checked),
.retex-scale-opt.is-checked { border-color: var(--blue-border); background: rgba(23, 75, 208, .16); background: color-mix(in srgb, var(--blue) 16%, transparent); }
.retex-scale-n { font-size: 17px; font-weight: 700; }
.retex-scale-l { font-size: 10px; color: var(--text-4); line-height: 1.3; }

/* ---------- Comptes ---------- */

.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 14px; }
.perm-opt { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--text-2); padding: 5px 0; cursor: pointer; }
.perm-opt input { margin-top: 2px; accent-color: var(--blue-border); }
.perm-summary { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.acct-row { border-bottom: 1px solid var(--divider); padding: 11px 0; }
.acct-row.is-off { opacity: .55; }
.acct-head { display: flex; align-items: center; gap: 12px; }
.acct-edit { margin-top: 12px; padding: 14px; border-radius: var(--radius-sm); background: var(--input); border: 1px solid var(--border); }

/* ---------- Sécurité ---------- */

.secu-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.secu-where { display: flex; gap: 10px; flex-wrap: wrap; }
.secu-group-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-4); margin-bottom: 8px; }
.secu-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.hold-btn {
  position: relative; overflow: hidden; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; min-height: 86px; padding: 14px;
  border-radius: 14px; border: 2px solid var(--lvl); background: var(--lvl-bg); color: var(--text);
  font: inherit; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.hold-btn.is-critical { min-height: 104px; grid-column: 1 / -1; }
.hold-fill { position: absolute; inset: 0; width: 0; background: var(--lvl); opacity: .35; pointer-events: none; }
.hold-btn.holding .hold-fill { width: 100%; transition: width var(--hold) linear; }
.hold-btn.sent { animation: evxsent 1.4s ease-out; }
@keyframes evxsent { 0% { box-shadow: 0 0 0 0 var(--lvl); } 100% { box-shadow: 0 0 0 18px transparent; } }
.hold-label { position: relative; font-size: 18px; font-weight: 700; color: var(--lvl); }
.hold-btn.is-critical .hold-label { font-size: 21px; }
.hold-desc { position: relative; font-size: 12px; color: var(--text-2); line-height: 1.35; }

.lvl-badge {
  display: inline-block; padding: 3px 9px; border-radius: 99px; border: 1px solid;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.dir-arrow { display: inline-block; font-weight: 700; color: var(--blue-link); }
.resp-chip { display: inline-block; font-size: 12px; padding: 3px 8px; border-radius: 99px; margin: 2px 4px 2px 0; border: 1px solid var(--border-light); color: var(--text-2); }
.resp-chip.coming { border-color: #4A4520; color: var(--yellow); }
.resp-chip.onsite { border-color: #1F5C2A; color: var(--green); }
.resp-chip.declined { opacity: .6; text-decoration: line-through; }
.alert-notes { margin-top: 8px; padding: 8px 10px; border-radius: 9px; background: var(--input); font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.mine-card { border-width: 2px; }
.feed-item { border-left: 4px solid; padding: 10px 0 12px 12px; margin-bottom: 10px; border-bottom: 1px solid var(--divider); }
.feed-item.is-critical { background: rgba(255,59,59,.06); }

.secu-incoming {
  position: sticky; top: 0; z-index: 30; margin-bottom: 16px; padding: 16px;
  border-radius: var(--radius); border: 2px solid var(--lvl); background: #16161C;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.secu-incoming.is-critical { animation: evxflash 1s steps(2, jump-none) infinite; }
@keyframes evxflash { 0% { background: #16161C; } 100% { background: #3A0D0D; } }
.inc-title { font-size: 22px; font-weight: 800; letter-spacing: .02em; color: var(--lvl); }
.inc-line { margin-top: 6px; font-size: 15px; }

.pc-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.radar-wrap { display: flex; justify-content: center; }
.radar-wrap canvas { max-width: 100%; border-radius: 12px; background: #0D0D11; }
.radar-legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--text-3); }
.radar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 99px; margin-right: 6px; vertical-align: -1px; }
.radar-legend i.ring { background: transparent; border: 2px solid #FF9F0A; }

/* Postes fixes (PC sécurité) */
.post-form { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.3fr) 90px 100px minmax(0, 2fr) auto; gap: 10px; align-items: end; }
.post-form .field-label { margin-top: 0; }
.post-actions { display: flex; gap: 8px; }
@media (max-width: 1100px) {
  .post-form { grid-template-columns: 1fr 1fr; }
  .post-form > div:nth-child(5), .post-form .post-actions { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .post-form { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .secu-layout, .pc-layout { grid-template-columns: 1fr; }
  /* Sur téléphone, un agent voit d'abord les alertes à traiter. */
  .secu-layout.is-responder > div:last-child { order: -1; }
}

/* ---------- Print (badges) ---------- */

/* --- Conditions d'utilisation / confidentialité (accepter.html, legal.html) --- */
.anon-inner.legal-wide { max-width: 760px; width: 100%; }
.legal-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.legal-doc { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: var(--bg); line-height: 1.55; font-size: 13.5px; }
.legal-doc.legal-doc-full { max-height: none; }
.legal-doc h3 { font-size: 14px; margin: 16px 0 6px; }
.legal-doc p { margin: 0 0 8px; }
.legal-doc ul { margin: 0 0 8px; padding-left: 20px; }
.legal-doc li { margin-bottom: 4px; }
.legal-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.legal-title { font-weight: 700; font-size: 16px; }
.legal-hash { margin-top: 14px; font-size: 10.5px; color: var(--muted, #8A8A96); word-break: break-all; }
.legal-check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; line-height: 1.45; }
.legal-check input { margin-top: 3px; flex: none; width: 17px; height: 17px; }
.banner.warn { background: rgba(255,236,1,.08); border: 1px solid #5C5410; color: #FFF3A0; line-height: 1.5; }
.legal-mine { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.legal-links { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 14px; font-size: 12.5px; }
.legal-links a { color: inherit; opacity: .75; }

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  body * { visibility: hidden !important; }
  [data-print="sheet"], [data-print="sheet"] * { visibility: visible !important; }
  [data-print="sheet"] { position: absolute !important; left: 0 !important; top: 0 !important; margin: 0 !important; }
  [data-print="hide"] { display: none !important; }
  /* Bandeaux de couleur et images des modèles imprimés même si « graphiques d'arrière-plan » est décoché. */
  [data-print="sheet"], [data-print="sheet"] * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Bascule sur le serveur de secours ---------- */

.failover-banner { position: sticky; top: 0; z-index: 50; padding: 10px 16px; font-size: 13.5px; font-weight: 600; text-align: center; border-bottom: 1px solid; }
.failover-banner[data-tone="warn"] { background: #3A3208; border-color: #6B5B10; color: var(--yellow); }
.failover-banner[data-tone="error"] { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.failover-banner[data-tone="info"] { background: rgba(23,75,208,.18); background: color-mix(in srgb, var(--blue) 18%, var(--bg)); border-color: var(--blue-border); color: #DCE4FF; }
.failover-sites { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.failover-site { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--pill-alt); }
.failover-qr { width: 150px; height: 150px; background: #fff; border-radius: 10px; padding: 8px; image-rendering: pixelated; }