/* JEFE BARBER — noir, blanc, gris, acier.
   L'accent unique est l'acier brossé : touches du pavé, bouton Valider, monogramme. */

:root {
  --black: #000000;
  --carbon: #141517;
  --carbon-2: #1C1D20;
  --graphite: #2B2D31;
  --graphite-2: #3A3D42;
  --steel: #8B9097;
  --silver: #C8CCD1;
  --paper: #F4F5F6;
  --white: #FFFFFF;
  --danger: #F2555A;
  --danger-bg: #2A1213;
  --warn: #E8B44A;
  --warn-bg: #2A2110;
  --ok: #7FD8A6;

  --chrome: linear-gradient(180deg, #F3F5F7 0%, #D4D8DC 46%, #A8AEB5 54%, #DDE0E3 100%);
  --chrome-pressed: linear-gradient(180deg, #B9BEC4 0%, #D9DCE0 100%);

  --display: 'Bahnschrift SemiCondensed', 'Bahnschrift', 'DIN Condensed', 'DIN Alternate', 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --text: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --r-key: 14px;
  --r-panel: 10px;
  --r-field: 8px;
  --gap: 12px;
  --tap: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--black);
  color: var(--paper);
  font: 16px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--silver); outline-offset: 2px; }
.num, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--steel); }
.small { font-size: 14px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Monogramme ---------- */
.wordmark {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: .02em;
  line-height: .9;
  background: var(--chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark small {
  display: block;
  font-size: .32em;
  letter-spacing: .5em;
  margin-top: .35em;
  padding-left: .5em;
}

/* ---------- Écrans plein cadre (installation, code, appareil) ---------- */
.gate {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 48px;
  align-items: center;
  padding: 32px clamp(24px, 6vw, 96px);
}
.gate-brand .wordmark { font-size: clamp(88px, 14vw, 190px); }
.gate-brand p { margin: 28px 0 0; color: var(--steel); max-width: 34ch; }
.gate-panel { width: 100%; }
.gate-panel h1 { font: 600 28px/1.15 var(--display); margin: 0 0 6px; letter-spacing: .01em; }
.gate-panel .lead { color: var(--steel); margin: 0 0 24px; }
.clock { font: 600 22px var(--display); color: var(--silver); font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .gate { grid-template-columns: 1fr; gap: 28px; align-content: center; justify-items: center; text-align: center; }
  .gate-brand .wordmark { font-size: 84px; }
  .gate-brand p { display: none; }
  .gate-panel { max-width: 400px; }
}

/* ---------- Pavé numérique ---------- */
.pin-dots { display: flex; gap: 14px; justify-content: center; height: 22px; margin: 6px 0 22px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--graphite-2); transition: background .12s, border-color .12s; }
.pin-dots span.on { background: var(--silver); border-color: var(--silver); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key {
  height: 76px;
  border: 0;
  border-radius: var(--r-key);
  background: var(--chrome);
  color: #121314;
  font: 600 34px/1 var(--display);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), inset 0 -2px 0 rgba(0,0,0,.25), 0 2px 0 #000;
  touch-action: manipulation;
  user-select: none;
}
.key:active { background: var(--chrome-pressed); transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(0,0,0,.35); }
.key.ghost { background: var(--carbon-2); color: var(--silver); font-size: 18px; font-family: var(--text); box-shadow: none; border: 1px solid var(--graphite); }
.key.ghost:active { background: var(--graphite); }
.key:disabled { opacity: .35; }
.pin-msg { min-height: 24px; text-align: center; margin-top: 16px; color: var(--danger); }
.pin-msg.info { color: var(--steel); }

/* ---------- Champs ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; color: var(--steel); }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--carbon);
  border: 1px solid var(--graphite-2);
  border-radius: var(--r-field);
  outline: none;
}
.input:focus { border-color: var(--silver); }
textarea.input { min-height: 72px; resize: vertical; }
.input.code { letter-spacing: .4em; font-family: var(--display); font-size: 22px; }
.row { display: flex; gap: var(--gap); align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.stack { display: grid; gap: var(--gap); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--silver); }

/* ---------- Boutons ---------- */
.btn {
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--r-field);
  border: 1px solid var(--graphite-2);
  background: var(--carbon-2);
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--steel); }
.btn:active { background: var(--graphite); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: var(--chrome);
  color: #0E0F10;
  border: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 0 #000;
}
.btn.primary:active { background: var(--chrome-pressed); }
.btn.danger { border-color: #5A2326; color: var(--danger); }
.btn.link { background: none; border: 0; padding: 0 4px; min-height: 36px; color: var(--silver); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }

/* ---------- Application ---------- */
.shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); }
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--graphite);
  background: var(--black);
  position: sticky; top: 0; z-index: 10;
}
.topbar .wordmark { font-size: 30px; }
.who { display: grid; line-height: 1.15; }
.who b { font-size: 17px; }
.who span { color: var(--steel); font-size: 13px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 22px;
  background: transparent; color: var(--steel);
  font-weight: 600; white-space: nowrap;
}
.tab[aria-current="page"] { background: var(--paper); color: var(--black); }
.tab:not([aria-current="page"]):hover { color: var(--paper); }
.lock-btn { margin-left: auto; }
.view { padding: 20px; min-width: 0; }
.view-head { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1 { font: 600 32px/1 var(--display); margin: 0; letter-spacing: .01em; }
.view-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* Beaucoup d'onglets (directeur) : la barre passe sur deux lignes plutôt que de cacher des onglets. */
@media (max-width: 1300px) {
  .topbar.many { flex-wrap: wrap; row-gap: 8px; }
  .topbar.many .tabs { order: 3; flex-basis: 100%; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; }
  .view { padding: 14px; }
}

/* ---------- Caisse ---------- */
.register {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
  height: calc(100dvh - 65px);
}
.topbar.many ~ * .register { height: calc(100dvh - 65px); }
@media (max-width: 1300px) { .topbar.many ~ * .register { height: calc(100dvh - 117px); } }
.catalog-pane { display: grid; grid-template-rows: auto auto 1fr; min-height: 0; padding: 16px 16px 0; }
.kind-switch { display: flex; gap: 8px; margin-bottom: 12px; }
.kind-switch button {
  flex: 1; min-height: 52px; border-radius: var(--r-field);
  border: 1px solid var(--graphite-2); background: var(--carbon);
  font: 600 20px var(--display); letter-spacing: .02em; color: var(--steel);
}
.kind-switch button[aria-pressed="true"] { background: var(--paper); color: var(--black); border-color: var(--paper); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 20px;
  border: 1px solid var(--graphite-2); background: transparent; color: var(--silver); white-space: nowrap;
}
.chip[aria-pressed="true"] { border-color: var(--silver); color: var(--white); background: var(--carbon-2); }
.items { overflow-y: auto; padding-bottom: 16px; align-content: start; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.item {
  min-height: 112px;
  display: grid; align-content: space-between; gap: 10px;
  padding: 14px 16px; text-align: left;
  border-radius: var(--r-panel);
  border: 1px solid var(--graphite);
  background: var(--carbon);
  touch-action: manipulation;
  position: relative;
}
.item:active { background: var(--graphite); }
.item .name { font: 600 21px/1.1 var(--display); letter-spacing: .01em; }
.item .price { font: 600 20px var(--display); color: var(--silver); font-variant-numeric: tabular-nums; }
.item .meta { font-size: 13px; color: var(--steel); }
.item.low .meta { color: var(--warn); }
.item:disabled { opacity: .38; cursor: not-allowed; }
.item .count {
  position: absolute; top: 10px; right: 10px;
  min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px;
  background: var(--paper); color: var(--black); font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
}
.empty { padding: 48px 16px; text-align: center; color: var(--steel); }
.empty b { display: block; color: var(--paper); font-size: 18px; margin-bottom: 6px; }

.ticket {
  border-left: 1px solid var(--graphite);
  background: var(--carbon);
  display: grid; grid-template-rows: auto 1fr auto;
  min-height: 0;
}
.ticket-section { padding: 14px 16px; border-bottom: 1px solid var(--graphite); }
.ticket-lines { overflow-y: auto; padding: 4px 16px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 0; border-bottom: 1px solid var(--graphite); }
.line:last-child { border-bottom: 0; }
.line .l-name { font-weight: 600; }
.line .l-total { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.line .l-sub { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--steel); font-size: 14px; }
.line .l-sub s { color: var(--steel); }
.line .custom-tag { color: var(--paper); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--graphite-2); border-radius: 18px; }
.qty button { width: 36px; height: 34px; border: 0; background: none; font-size: 18px; color: var(--silver); }
.qty span { min-width: 22px; text-align: center; color: var(--paper); font-variant-numeric: tabular-nums; }
.l-actions { margin-left: auto; display: flex; gap: 2px; }
.icon-btn { min-width: 40px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--steel); font-size: 14px; }
.icon-btn:hover { color: var(--paper); background: var(--carbon-2); }

.client-pick { position: relative; }
.client-chosen {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 6px 6px 14px;
  border: 1px solid var(--silver); border-radius: var(--r-field);
}
.client-chosen .grow { line-height: 1.2; }
.client-chosen .grow span { display: block; font-size: 13px; color: var(--steel); }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--carbon-2); border: 1px solid var(--graphite-2); border-radius: var(--r-field);
  box-shadow: 0 16px 40px rgba(0,0,0,.6); overflow: hidden;
}
.suggest button { display: grid; width: 100%; text-align: left; padding: 10px 14px; border: 0; background: none; border-bottom: 1px solid var(--graphite); min-height: 52px; }
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover, .suggest button.active { background: var(--graphite); }
.suggest button span { font-size: 13px; color: var(--steel); }
.client-quick { display: flex; gap: 8px; margin-top: 8px; }
.client-quick .btn { flex: 1; }
.client-quick .btn[aria-pressed="true"] { border-color: var(--silver); color: var(--white); }

.ticket-foot { padding: 14px 16px 16px; border-top: 1px solid var(--graphite); display: grid; gap: 12px; }
.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total-row .label { color: var(--steel); }
.total-row .value { font: 700 40px/1 var(--display); font-variant-numeric: tabular-nums; }
.pay-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-modes button {
  min-height: 52px; border-radius: var(--r-field); border: 1px solid var(--graphite-2);
  background: var(--black); font-weight: 600; color: var(--silver);
}
.pay-modes button[aria-pressed="true"] { background: var(--paper); color: var(--black); border-color: var(--paper); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.validate { min-height: 64px; font-size: 20px; font-family: var(--display); letter-spacing: .02em; }
.note-toggle { justify-self: start; }

.cooldown {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: var(--r-field);
  background: var(--warn-bg); color: var(--warn); border: 1px solid #4A3A16;
  margin-bottom: 12px;
}
.cooldown b { font: 700 24px var(--display); font-variant-numeric: tabular-nums; color: var(--warn); }

@media (max-width: 900px) {
  .register { grid-template-columns: 1fr; height: auto; }
  .catalog-pane { min-height: 0; }
  .items { max-height: 56dvh; }
  .items { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .ticket { border-left: 0; border-top: 1px solid var(--graphite); }
}

/* ---------- Confirmation de vente ---------- */
.confirm {
  position: fixed; inset: 0; z-index: 100;
  background: var(--black);
  display: grid; place-items: center; text-align: center;
  animation: fade .18s ease-out;
}
.confirm .mark {
  width: 112px; height: 112px; border-radius: 50%;
  background: var(--chrome); color: #0E0F10;
  display: grid; place-items: center; margin: 0 auto 26px;
  font: 700 58px/1 var(--display);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.9);
}
.confirm h2 { font: 700 46px/1 var(--display); margin: 0 0 10px; }
.confirm p { color: var(--steel); margin: 0; font-size: 18px; }
.confirm .bar { width: 220px; height: 3px; background: var(--graphite); margin: 30px auto 0; border-radius: 2px; overflow: hidden; }
.confirm .bar i { display: block; height: 100%; background: var(--silver); animation: drain linear forwards; }
@keyframes drain { from { width: 100%; } to { width: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Fenêtres ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72);
  display: grid; place-items: center; padding: 16px;
  animation: fade .12s;
}
.modal {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--carbon); border: 1px solid var(--graphite-2); border-radius: 14px;
  padding: 22px;
}
.modal h2 { font: 600 26px/1.1 var(--display); margin: 0 0 6px; }
.modal .lead { color: var(--steel); margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal .big-code { font: 700 52px var(--display); letter-spacing: .12em; text-align: center; margin: 12px 0; font-variant-numeric: tabular-nums; }
.dup-list { display: grid; gap: 8px; margin: 12px 0; }
.dup-list button { text-align: left; padding: 12px 14px; border-radius: var(--r-field); border: 1px solid var(--graphite-2); background: var(--black); }
.dup-list button span { display: block; font-size: 13px; color: var(--steel); }

/* ---------- Messages ---------- */
#toast-root { position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(520px, calc(100% - 32px)); }
.toast {
  padding: 14px 18px; border-radius: var(--r-field);
  background: var(--paper); color: var(--black); font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  animation: fade .15s;
}
.toast.error { background: var(--danger-bg); color: #FFD6D7; border: 1px solid #5A2326; }
.alert { padding: 12px 14px; border-radius: var(--r-field); border: 1px solid #5A2326; background: var(--danger-bg); color: #FFD6D7; margin-bottom: 14px; }
.alert.warn { border-color: #4A3A16; background: var(--warn-bg); color: var(--warn); }
.alert.info { border-color: var(--graphite-2); background: var(--carbon-2); color: var(--silver); }

/* ---------- Tableaux et chiffres ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--carbon); border: 1px solid var(--graphite); border-radius: var(--r-panel); overflow: hidden; margin-bottom: 22px; }
.kpi { background: var(--carbon); padding: 16px 18px; box-shadow: inset -1px -1px 0 var(--graphite); }
.kpi .k-label { color: var(--steel); font-size: 14px; }
.kpi .k-value { font: 700 34px/1.1 var(--display); font-variant-numeric: tabular-nums; margin-top: 6px; }
.kpi .k-sub { color: var(--steel); font-size: 13px; margin-top: 2px; }
.kpi.hero { grid-column: span 2; background: var(--black); }
.kpi.hero .k-value { font-size: 56px; }
@media (max-width: 560px) { .kpi.hero { grid-column: auto; } }

.panel { background: var(--carbon); border: 1px solid var(--graphite); border-radius: var(--r-panel); margin-bottom: 20px; }
.panel > h2 { font: 600 20px var(--display); margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--graphite); letter-spacing: .01em; }
.panel-body { padding: 16px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th { text-align: left; font-weight: 500; color: var(--steel); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--graphite); white-space: nowrap; }
table.data td { padding: 12px; border-bottom: 1px solid var(--graphite); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.cancelled td { color: var(--steel); }
table.data tr.cancelled td.money { text-decoration: line-through; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--carbon-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--graphite-2); color: var(--silver); white-space: nowrap; }
.tag.off { color: var(--steel); }
.tag.danger { border-color: #5A2326; color: var(--danger); }
.tag.warn { border-color: #4A3A16; color: var(--warn); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters .input { min-height: 44px; }

.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--carbon); border: 1px solid var(--graphite); border-radius: var(--r-panel); padding: 16px; display: grid; gap: 10px; align-content: start; }
.card.off { opacity: .6; }
.card h3 { margin: 0; font: 600 22px var(--display); }
.card .row { flex-wrap: wrap; }

.diff { font-size: 13px; color: var(--steel); }
.diff b { color: var(--paper); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
table.data input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--silver); }
