/* MyKitchen — feuille de style commune.
   Direction : "passe" de cuisine. Fond sombre, fort contraste, gros boutons
   tactiles. Le chrono est l'élément signature : grands chiffres tabulaires qui
   passent du vert à l'orange puis au rouge. La couleur n'encode qu'une chose :
   l'urgence et l'état. Tout le reste reste calme. */

:root {
  --bg:        #0E1116;
  --panel:     #161B22;
  --card:      #1C222B;
  --card-2:    #232B36;
  --border:    #2A313C;
  --border-2:  #3A434F;

  --text:      #F2F4F7;
  --text-soft: #9AA4B2;
  --text-dim:  #6B7480;

  --fresh:     #34C77B;  --fresh-bg:  #14301F;  --fresh-line: #1E6B45;
  --warn:      #F2A516;  --warn-bg:   #3A2A06;  --warn-line:  #946715;
  --late:      #FF5252;  --late-bg:   #3A1414;  --late-line:  #9A2C2C;
  --ready:     #38BDF8;  --ready-bg:  #0C2A3A;
  --action:    #3B82F6;

  --av-bg:     #2B3442;  /* fond des pastilles avatar/initiales */
  --sunken:    #10151d;  /* fonds enfoncés (debug, given) */
  --on-text:   #0E1116;  /* texte sur fond clair (chip actif) */
  --on-warn:   #211603;  /* texte sur fond orange (boutons) */

  --radius:    14px;
  --tap:       56px;

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Thème clair */
html[data-theme="light"] {
  --bg:        #F4F6F9;
  --panel:     #FFFFFF;
  --card:      #FFFFFF;
  --card-2:    #EEF1F5;
  --border:    #E2E6EC;
  --border-2:  #CBD2DB;

  --text:      #1A1F26;
  --text-soft: #5A6573;
  --text-dim:  #8A94A2;

  --fresh:     #1E9E5A;  --fresh-bg:  #E3F5EA;  --fresh-line: #57C088;
  --warn:      #B7791F;  --warn-bg:   #FBF1DA;  --warn-line:  #E2B45A;
  --late:      #D43C3C;  --late-bg:   #FBE4E4;  --late-line:  #ECA0A0;
  --ready:     #1E7FB8;  --ready-bg:  #E2F0FB;
  --action:    #2563EB;

  --av-bg:     #DCE2EA;
  --sunken:    #EEF1F5;
  --on-text:   #FFFFFF;
  --on-warn:   #FFFFFF;
}

* { box-sizing: border-box; }

/* L'attribut HTML `hidden` doit toujours l'emporter, même sur les éléments
   qui ont un display: flex/grid (sinon le pavé PIN reste affiché). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 0 16px;
  min-height: var(--tap);
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  user-select: none;
}
button:hover { background: #2A3340; }
button:active { transform: scale(.97); }
button:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
button.primary { background: var(--action); border-color: transparent; color: #fff; font-weight: 600; }
button.give    { background: var(--fresh-line); border-color: transparent; color: #fff; font-weight: 600; }
/* Boutons d'action du ticket, couleur selon l'étape */
button.act-prepare { background: var(--warn); border-color: transparent; color: var(--on-warn); font-weight: 700; }
button.act-ready   { background: var(--fresh); border-color: transparent; color: #06210f; font-weight: 700; }
button.act-give    { background: var(--action); border-color: transparent; color: #fff; font-weight: 700; }
html[data-theme="light"] button.act-ready { color: #fff; }
button.ghost   { background: transparent; }

.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------- Écran de connexion ---------------- */

.login {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  gap: 28px;
}
.login h1 {
  font-size: 22px; font-weight: 600; margin: 0; letter-spacing: .2px;
  display: flex; align-items: center; gap: 10px;
}
.login .sub { color: var(--text-soft); margin: -16px 0 0; font-size: 15px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 760px;
}
.tile {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; min-height: 78px;
  cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .06s ease;
}
.tile:hover { border-color: var(--border-2); background: var(--card-2); }
.tile:active { transform: scale(.98); }
.tile .av {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--av-bg); color: var(--text); font-weight: 600; font-size: 16px;
  background-size: cover; background-position: center;
}
.tile .nm { font-size: 17px; font-weight: 500; }

/* Pavé PIN */
.backdrop {
  position: fixed; inset: 0; background: rgba(6,9,13,.78);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 20;
}
.pinpad {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 20px; padding: 22px;
  display: flex; flex-direction: column; gap: 18px; align-items: center;
}
.pinpad .who { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 500; }
.dots { display: flex; gap: 14px; height: 18px; }
.dots i {
  width: 14px; height: 14px; border-radius: 50%; background: transparent;
  border: 2px solid var(--border-2); transition: background .1s ease, border-color .1s ease;
}
.dots i.on { background: var(--text); border-color: var(--text); }
.pinpad.err .dots i { border-color: var(--late); }
.pinpad.err { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
@media (prefers-reduced-motion: reduce) { .pinpad.err { animation: none; } }

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.keys button { min-height: 64px; font-size: 24px; font-weight: 500; }
.msg { color: var(--late); font-size: 14px; min-height: 18px; }

/* ---------------- Écran de production ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; min-width: 0; }
.venture-logo { height: 30px; width: auto; max-width: 130px; object-fit: contain; border-radius: 6px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-txt #ventureName { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.screen-center { flex: 1; display: flex; justify-content: center; min-width: 120px; }
.screen-name {
  font-size: 18px; font-weight: 800; color: var(--text);
  padding: 4px 16px; border-radius: 999px; background: var(--card-2);
  letter-spacing: .3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.text-input {
  width: 100%; min-height: var(--tap); padding: 0 14px; font-size: 16px;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
}
.text-input:focus { outline: none; border-color: var(--action); }
.opt.occupied { opacity: .55; }
.opt.occupied .sub { color: var(--late); }
.counts { display: flex; gap: 10px; align-items: stretch; }
.counts .metric {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; padding: 4px 12px; border-radius: 12px;
  background: var(--card-2); line-height: 1.05;
}
.counts .metric b { font-size: 22px; font-weight: 800; color: var(--text); }
.counts .metric span { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-soft); }
.counts .metric.is-late { background: var(--late-bg); }
.counts .metric.is-late b { color: var(--late); }
.counts .metric.is-ready { background: var(--ready-bg); }
.counts .metric.is-ready b { color: var(--ready); }
.op-wrap { position: relative; }
.op { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft); background: transparent; border: 0; cursor: pointer; padding: 4px 8px; border-radius: 10px; min-height: 40px; }
.op:hover { background: var(--card-2); }
.op:hover .op-out { color: var(--late); opacity: 1; }
.op .av { width: 30px; height: 30px; border-radius: 50%; background: var(--av-bg) center/cover no-repeat; color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: 0 0 auto; overflow: hidden; }
.op .av.has-photo { background-color: transparent; }
.op-out { opacity: .5; flex: 0 0 auto; }
.drawer-logout { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 46px; padding: 0 14px;
  background: transparent; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; }
.drawer-logout:hover { background: var(--card-2); color: var(--late); }
.drawer-logout svg { color: var(--late); flex: 0 0 auto; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 16px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 14px;
  background: var(--card); border: 1px solid var(--border); color: var(--text-soft);
}
.chip.active { background: var(--text); color: var(--on-text); border-color: var(--text); font-weight: 600; }

/* Bouton icône (réglages / fermer) */
.iconbtn {
  min-height: 40px; min-width: 40px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--text-soft);
}
.iconbtn:hover { background: var(--card-2); color: var(--text); }

/* Tiroir Réglages (depuis la droite) */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(6,9,13,.6);
  display: flex; justify-content: flex-end; z-index: 40;
}
.drawer {
  width: 100%; max-width: 380px; height: 100%; background: var(--panel);
  border-left: 1px solid var(--border); padding: 18px 18px 28px;
  display: flex; flex-direction: column; gap: 22px; overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 18px; font-weight: 600; margin: 0; }
.drawer-sec h3 { font-size: 13px; font-weight: 600; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .5px; margin: 0 0 10px; }
.optlist { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; min-height: 0; color: var(--text); font-size: 15px;
}
.opt:hover { border-color: var(--border-2); background: var(--card-2); }
.opt .tick { width: 18px; height: 18px; flex: none; color: var(--action); opacity: 0; }
.opt.sel { border-color: var(--action); }
.opt.sel .tick { opacity: 1; }
.opt .sub { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.hint { color: var(--text-dim); font-size: 14px; margin: 0; }

.board { padding: 14px 16px; }
.empty { padding: 64px 16px; text-align: center; color: var(--text-dim); }

/* Flux unique (écran live) : toutes les commandes, récentes -> anciennes */
.flow { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; align-items: start; }

/* Lanes par statut (écran live) */
.lanes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px; align-items: start;
}
.lane {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; min-width: 0;
}
.lane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 10px; color: var(--text-soft);
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.lane-head b { min-width: 24px; padding: 2px 9px; border-radius: 999px; background: var(--card-2); color: var(--text); text-align: center; }
.lane-body { display: flex; flex-direction: column; gap: 10px; }
.lane:first-child .lane-head { color: var(--fresh); }

/* Historique : liste responsive */
.history { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }

/* Ticket */
.ticket {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.ticket .head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.ticket .order-ident { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ident-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ident-top .part { font-size: 11px; font-weight: 600; color: var(--warn); }
.ticket .num { font-weight: 700; font-size: 20px; line-height: 1.05; }
.ticket .sub { font-size: 12px; color: var(--text-soft); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket .placed { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.ticket .placed svg { opacity: .8; }
.timer { font-size: 26px; font-weight: 800; letter-spacing: .5px; }
.timer.frozen { font-weight: 700; opacity: .8; }
.ticket .meta { font-size: 12px; color: var(--text-soft); padding: 8px 12px 0; display: flex; gap: 8px; align-items: center; }
.ticket .meta .part { color: var(--warn); font-weight: 600; }
.ticket .order-note { margin: 8px 12px 0; padding: 6px 9px; background: var(--warn-bg); color: var(--warn); border-radius: 8px; font-size: 12px; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.lines { list-style: none; margin: 0; padding: 8px 6px 4px; display: flex; flex-direction: column; gap: 2px; }
.line {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  background: transparent; border: none; border-radius: 8px; padding: 10px 8px; min-height: 0;
  color: var(--text);
}
.line:hover { background: var(--card-2); }
.line .q { font-weight: 800; min-width: 28px; font-size: 16px; }
.line .lbl { flex: 1; font-size: 16px; line-height: 1.3; font-weight: 500; }

/* Flash bref à l'arrivée d'une nouvelle commande */
@keyframes mk-flash { 0% { box-shadow: 0 0 0 0 var(--fresh); } 100% { box-shadow: 0 0 0 8px transparent; } }
.ticket.isnew { animation: mk-flash 1.1s ease-out 2; }
@media (prefers-reduced-motion: reduce) { .ticket.isnew { animation: none; } }
.line .comp { display: block; font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.line .note { display: block; font-size: 12px; color: var(--warn); margin-top: 2px; }
.line.preparing, .line.part-staged { background: var(--warn-bg); }
.line.preparing .lbl, .line.preparing .q, .line.preparing .at, .line.part-staged .lbl, .line.part-staged .q, .line.part-staged .at { color: var(--warn); }
.line.staged { background: var(--fresh-bg); }
.line.staged .lbl, .line.staged .q, .line.staged .at { color: var(--fresh); }
.line.part-given { background: var(--ready-bg); }
.line.part-given .lbl, .line.part-given .q, .line.part-given .at { color: var(--ready); }
.line.done .lbl, .line.done .q { color: var(--text-dim); text-decoration: line-through; }
.line .at { font-size: 11px; font-weight: 600; color: var(--text-soft); white-space: nowrap; align-self: center; }
.line.done .at { color: var(--text-dim); text-decoration: none; }
.screen-tag { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--card-2); color: var(--text-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 12px; }
.actions button { flex: 1 1 90px; min-height: 48px; font-size: 14px; }

/* Couleurs d'urgence appliquées au ticket */
.ticket.fresh { border-color: var(--fresh-line); }
.ticket.fresh .head { background: var(--fresh-bg); }
.ticket.fresh .timer { color: var(--fresh); }
.ticket.warn  { border-color: var(--warn-line); }
.ticket.warn .head { background: var(--warn-bg); }
.ticket.warn .timer { color: var(--warn); }
.ticket.late  { border-color: var(--late-line); }
.ticket.late .head { background: var(--late-bg); }
.ticket.late .timer { color: var(--late); }

.badge.b-prep  { background: var(--warn-bg);  color: var(--warn); }
.badge.b-ready { background: var(--ready-bg); color: var(--ready); }
.badge.b-given { background: var(--fresh-bg); color: var(--fresh); }

.ticket.given { opacity: .55; border-color: var(--border); }
.ticket.given .head { background: var(--sunken); }
.ticket.given .timer { color: var(--text-dim); }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--late-bg); color: var(--late); border: 1px solid var(--late-line);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 30;
  max-width: 90vw;
}

.debugbox {
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.45;
}
.debugbox b { color: var(--text); }
.debugbox .bad { color: var(--late); }
.debugbox .ok { color: var(--fresh); }
.debugbox .warn { color: var(--warn); }
.debugbox code { color: var(--text); white-space: normal; }

.group-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 -2px;
  padding: 8px 4px 2px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.group-title b {
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--text);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Animations & pop-up détail (ajouts)                                 */
/* ------------------------------------------------------------------ */

.ticket { transition: opacity .25s ease, border-color .2s ease, box-shadow .2s ease; }
.ticket .head { cursor: pointer; }
.ticket .head:hover { filter: brightness(1.06); }

@keyframes mk-enter { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mk-glow { 0% { box-shadow: 0 0 0 0 var(--fresh); } 100% { box-shadow: 0 0 0 12px transparent; } }
.ticket.isnew { animation: mk-enter .28s ease-out both, mk-glow 1.1s ease-out .1s 2; }

/* Retour tactile sur les lignes et boutons */
.line { transition: background .15s ease, transform .07s ease; }
.line:active { transform: scale(.99); }
@keyframes mk-pop { 0% { transform: scale(.97); } 60% { transform: scale(1.015); } 100% { transform: scale(1); } }
.line.preparing, .line.staged, .line.part-staged, .line.part-given, .line.done { animation: mk-pop .18s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .ticket.isnew, .line.preparing, .line.staged, .line.part-staged, .line.part-given, .line.done { animation: none; }
  .ticket, .line { transition: none; }
}

/* Toast avec action (annuler) */
.toast { display: flex; align-items: center; gap: 14px; }
.toast .undo {
  min-height: 0; padding: 6px 12px; font-size: 13px; font-weight: 600;
  background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 8px;
}
.toast.info { background: var(--card); color: var(--text); border-color: var(--border-2); }

/* Pop-up détail */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 9, 13, .66);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50;
  animation: mk-fade .15s ease-out;
}
@keyframes mk-fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 540px; max-height: 90vh; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  display: flex; flex-direction: column;
  animation: mk-enter .2s ease-out both;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-sec h4 {
  margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .5px;
}
.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.dl dt { color: var(--text-soft); }
.dl dd { margin: 0; text-align: right; }
.rows { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.row .l { display: flex; gap: 8px; min-width: 0; }
.row .l .q { font-weight: 700; color: var(--text-soft); min-width: 26px; }
.row.child .l { padding-left: 22px; color: var(--text-soft); font-size: 13px; }
.row .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--card-2); color: var(--text-soft); }
.total-row { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; font-weight: 700; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; }
.tl .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; margin-top: 4px; background: var(--border-2); }
.tl.done .dot { background: var(--fresh); }
.tl .when { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 86px; }
.tl .who { color: var(--text-soft); font-size: 13px; }
.tl .lbl { flex: 1; }
.chip-pay { display: inline-flex; align-items: center; gap: 6px; }
.modal-note { background: var(--warn-bg); color: var(--warn); padding: 8px 10px; border-radius: 8px; font-size: 13px; }

/* ------------------------------------------------------------------ */
/* Historique en bas d'écran + page historique en lignes (ajouts)      */
/* ------------------------------------------------------------------ */

.section-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 4px 14px; color: var(--text-soft);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
}
.section-divider::before, .section-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.flow-history .ticket, .ticket.is-history { opacity: .72; }
.flow-history .ticket:hover, .ticket.is-history:hover { opacity: 1; }

.hist-rows { display: flex; flex-direction: column; gap: 2px; max-width: 720px; margin: 0 auto; }
.hist-row {
  display: grid; grid-template-columns: 64px 1fr auto auto; gap: 12px; align-items: center;
  width: 100%; text-align: left; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
}
.hist-row:hover { background: var(--card-2); }
.hist-row .hr-num { font-weight: 800; }
.hist-row .hr-name { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row .hr-status { font-size: 12px; color: var(--text-soft); }
.hist-row .hr-time { font-variant-numeric: tabular-nums; color: var(--text-soft); }

.screen-name.conflict { color: var(--late); }

/* ------------------------------------------------------------------ */
/* Appairage (terminal) + back-office /admin                           */
/* ------------------------------------------------------------------ */

.pairing { max-width: 520px; margin: 0 auto; padding: 64px 20px; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.pairing h1 { display: inline-flex; align-items: center; gap: 10px; font-size: 24px; }
.pair-code {
  font-size: 56px; font-weight: 800; letter-spacing: 12px; padding: 18px 28px 18px 40px;
  background: var(--card); border: 2px dashed var(--border-2); border-radius: 18px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pair-wait { color: var(--text-soft); font-size: 14px; }

.admin-wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; display: flex; flex-direction: column; gap: 18px; }
.admin-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.admin-card h2 { margin: 0 0 8px; font-size: 18px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.login-card { max-width: 420px; margin: 60px auto 0; display: flex; flex-direction: column; gap: 12px; }
.login-card .primary { min-height: var(--tap); }
.msg { color: var(--late); font-size: 13px; min-height: 18px; margin: 4px 0 0; }

.pair-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pair-form .text-input { flex: 1 1 140px; }
.pair-form .primary { min-height: var(--tap); padding: 0 18px; }
.code-input { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; max-width: 160px; }

.screens-list { display: flex; flex-direction: column; gap: 14px; }
.screen-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; background: var(--card); }
.screen-card.unpaired { border-style: dashed; border-color: var(--action); background: var(--card-2); }
.muted-count { font-weight: 500; font-size: 13px; color: var(--text-soft); text-transform: none; letter-spacing: 0; }

.sc-top { display: flex; gap: 12px; align-items: center; }
.sc-top .sc-name { flex: 1; font-weight: 600; font-size: 16px; }
.sc-id { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sc-sub { font-size: 12px; color: var(--text-soft); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.sc-code { letter-spacing: 5px; font-size: 24px; font-weight: 800; padding: 6px 12px 6px 17px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border-2); }

.dot-on, .dot-off { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot-on { background: var(--fresh); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fresh) 25%, transparent); }
.dot-off { background: var(--border-2); }

.sc-adv { border-top: 1px solid var(--border); padding-top: 4px; }
.sc-board { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; }
.sc-board-lbl { font-size: 12px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; }
.sc-board-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; font-weight: 800; letter-spacing: 4px; color: var(--text); padding: 2px 8px; background: var(--card-2); border-radius: 6px; }
.sc-copy { min-height: 36px; padding: 0 12px; }
.sc-adv > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-soft); padding: 6px 0; list-style: none; user-select: none; }
.sc-adv > summary::-webkit-details-marker { display: none; }
.sc-adv > summary::before { content: '▸ '; display: inline-block; transition: transform .15s; }
.sc-adv[open] > summary::before { content: '▾ '; }
.sc-adv > *:not(summary) { margin-top: 10px; }

.fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-soft); }
.fld > span, .fld-lbl { font-size: 12px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.sc-pos { display: flex; flex-direction: column; gap: 8px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.chk input { width: 18px; height: 18px; }
.sc-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.sc-actions button { min-height: 44px; padding: 0 18px; }
select.text-input { min-height: var(--tap); }

/* Section "Réimprimer" dans la popup de commande */
.print-sec .print-printer { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 12px; }
.print-sec .print-printer select { font-size: 15px; }
.print-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.print-actions button { flex: 1 1 140px; min-height: var(--tap); padding: 0 16px; }
.print-actions button.alt { background: transparent; color: var(--action); border: 1.5px solid var(--action); }
html[data-theme="light"] .print-actions button.alt { color: var(--action); }
.print-sec .msg { min-height: 18px; margin-top: 8px; font-size: 13px; }
.print-sec .msg.ok { color: var(--fresh); }
.print-sec .msg.err { color: var(--late); }

/* Bouton "Étiquettes produits" dans la popup */
.print-sec .print-actions + .print-actions { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.print-actions .label-btn { background: var(--brown, #553421); background: var(--warn); color: var(--on-warn); display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-basis: 100%; }
.print-actions .label-btn svg { flex: 0 0 auto; }

/* Sous-lignes de menus : indépendantes et visuellement rattachées au parent. */
.lines .component-row { margin: -1px 0 -1px 1.35rem; position: relative; }
.lines .component-row::before { content: "↳"; position: absolute; left: -.9rem; top: 50%; transform: translateY(-50%); color: var(--text-soft); font-size: 11px; }
.line.component-line { padding: 4px 7px; border-radius: 6px; gap: 7px; }
.line.component-line .q { min-width: 22px; font-size: 12px; font-weight: 700; }
.line.component-line .lbl { font-size: 13px; line-height: 1.15; font-weight: 400; color: var(--text-soft); }
.line.component-line .at { font-size: 10px; }


/* Journal détaillé des actions par ligne */
.event-log { display:flex; flex-direction:column; gap:6px; }
.event-row { display:grid; grid-template-columns:56px minmax(0,1fr) auto; gap:10px; align-items:center; padding:8px 10px; border:1px solid var(--border); border-radius:9px; background:var(--card-2); font-size:13px; }
.event-time { color:var(--text-soft); font-weight:700; }
.event-main { min-width:0; }
.event-main strong { color:var(--text); }
.event-meta { color:var(--text-dim); font-size:12px; text-align:right; }
@media (max-width:620px) { .event-row { grid-template-columns:48px 1fr; } .event-meta { grid-column:2; text-align:left; } }

/* v8 — détail de commande en deux volets et journal enrichi */
#detail .modal { max-width: 1180px; width: min(1180px, calc(100vw - 36px)); height: min(820px, calc(100vh - 36px)); }
#detail .modal-body { padding: 0; overflow: hidden; display: block; flex: 1; min-height: 0; }
.detail-split { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(380px, .92fr); height: 100%; min-height: 0; }
.detail-order-pane, .detail-log-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.detail-order-pane { border-right: 1px solid var(--border); }
.detail-log-pane { background: color-mix(in srgb, var(--card) 55%, var(--panel)); }
.detail-pane-head { min-height: 50px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); color: var(--text-soft); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .65px; }
.detail-pane-scroll { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.order-summary { padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); }
.status-pill { display: inline-flex; padding: 3px 9px; border-radius: 999px; background: var(--card-2); font-size: 12px; font-weight: 700; }
.status-in_progress { background: var(--warn-bg); color: var(--warn); }
.status-ready { background: var(--fresh-bg); color: var(--fresh); }
.event-count { min-width: 24px; height: 24px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--card-2); color: var(--text); }
.detail-log-pane .event-log { padding: 16px; overflow-y: auto; gap: 10px; }
.event-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 11px; align-items: start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: 0 1px 0 rgba(0,0,0,.05); }
.event-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--card-2); color: var(--text-soft); font-size: 17px; font-weight: 800; }
.event-preparing .event-icon, .event-order_started .event-icon { background: var(--warn-bg); color: var(--warn); }
.event-ready .event-icon, .event-order_ready .event-icon { background: var(--fresh-bg); color: var(--fresh); }
.event-given .event-icon, .event-order_given .event-icon { background: rgba(67,126,247,.14); color: #6da0ff; }
.event-title { font-size: 13px; font-weight: 800; color: var(--text); }
.event-line { margin-top: 2px; font-size: 13px; line-height: 1.3; color: var(--text-soft); }
.event-meta { margin-top: 5px; font-size: 11px; color: var(--text-dim); }
.event-card .event-time { max-width: 112px; text-align: right; font-size: 11px; line-height: 1.35; color: var(--text-soft); white-space: normal; }
.event-empty { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--text-soft); text-align: center; }
.event-empty strong { color: var(--text); }
.print-actions .receipt-btn { flex-basis: 100%; background: var(--fresh); color: #fff; }
@media (max-width: 880px) {
  #detail .modal { height: min(94vh, 900px); }
  .detail-split { grid-template-columns: 1fr; overflow-y: auto; }
  .detail-order-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .detail-pane-scroll, .detail-log-pane .event-log { overflow: visible; }
  .detail-log-pane { min-height: 360px; }
}
@media (max-width: 560px) {
  #detail .modal { width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .event-card { grid-template-columns: 34px 1fr; }
  .event-card .event-time { grid-column: 2; max-width: none; text-align: left; }
}
