/* =====================================================================
   Brasserie Simon — feuille de style
   Mobile-first, pensée pour une tablette d'atelier : grandes cibles
   tactiles, contraste élevé, aucune dépendance externe.
   ===================================================================== */

:root {
  --bg: #f4efe6;
  --surface: #ffffff;
  --surface-2: #faf7f1;
  --ink: #221b14;
  --ink-2: #4a4038;
  --muted: #7a6f63;
  --line: #e4dccd;
  --line-2: #d3c9b6;
  --brand: #b4531a;
  --brand-2: #8f3f10;
  --brand-soft: #fbe9dc;
  --ok: #2e7d4c;
  --ok-soft: #e3f2e8;
  --warn: #b7791f;
  --warn-soft: #fbf0d9;
  --danger: #b3261e;
  --danger-soft: #fbe4e2;
  --info-soft: #e6eef8;
  --dark: #2b2118;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(34, 27, 20, .06), 0 4px 14px rgba(34, 27, 20, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --v1: #b4531a; --v2: #1f5fbf; --v3: #2e7d4c; --v4: #7b3fa0; --v5: #b7791f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 .6rem; }
small { font-size: .85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.grow { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 18px; padding-bottom: 40px; }

/* --- En-tête -------------------------------------------------------- */
.top { background: var(--dark); color: #f4efe6; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.top-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 60px; padding-top: 6px; padding-bottom: 6px; }
.brand { color: inherit; display: flex; align-items: baseline; gap: 0; text-decoration: none !important; line-height: 1; }
.brand-a { font-weight: 300; font-size: 1.25rem; letter-spacing: .02em; opacity: .9; }
.brand-b { font-weight: 800; font-size: 1.25rem; color: #f0b27a; }
.brand-sub { margin-left: 12px; font-size: .8rem; color: rgba(244,239,230,.6); display: none; }
@media (min-width: 640px) { .brand-sub { display: inline; } }
.top-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.18); color: #f4efe6; background: rgba(255,255,255,.06);
  font: inherit; font-size: .95rem; cursor: pointer; text-decoration: none !important;
}
.pill:hover { background: rgba(255,255,255,.14); }
.pill-user { padding-left: 4px; }
.lang-switch { display: inline-flex; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; }
.lang { display: inline-flex; align-items: center; min-height: 38px; padding: 0 10px; color: rgba(244,239,230,.7); font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-decoration: none !important; }
.lang:hover { background: rgba(255,255,255,.1); color: #f4efe6; }
.lang.is-on { background: #f0b27a; color: var(--dark); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .95rem; flex: none;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }

/* --- Pied ------------------------------------------------------------ */
.foot { color: var(--muted); font-size: .85rem; padding: 18px 0 26px; border-top: 1px solid var(--line); }
.foot .wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.foot a { color: inherit; text-decoration: underline; }

/* --- Titres de page ------------------------------------------------- */
.page-head { margin-bottom: 18px; }
.page-head .lead { font-size: 1.05rem; color: var(--ink-2); margin-top: 6px; }
.back { display: inline-block; color: var(--muted); font-size: .95rem; margin-bottom: 6px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.batch-no { font-weight: 600; color: var(--muted); }
.tag {
  display: inline-block; vertical-align: middle; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap;
}
h1 .tag { margin-left: 8px; }
.tag-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.tag-link:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }

/* --- Messages ---------------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-erreur { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--info-soft); color: #1f4a8a; }
.flash a { margin-left: 8px; font-weight: 600; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* --- Cartes -------------------------------------------------------------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-users { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-locations { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-assets { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
  color: inherit; text-decoration: none !important; position: relative;
}
.card-pad { padding: 16px 18px; }
a.card { display: block; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
a.card:hover, a.card:focus-visible { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 6px 20px rgba(34,27,20,.12); outline: none; }
.card-title { display: block; font-size: 1.15rem; font-weight: 700; }
.card-meta { display: block; color: var(--muted); font-size: .9rem; margin-top: 2px; }
.card-icon { display: block; font-size: 1.6rem; margin-bottom: 6px; }
.card-location { padding: 20px 44px 20px 20px; min-height: 92px; }
.card-arrow { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 1.6rem; color: var(--line-2); }
a.card-user, .card-user { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 12px; text-align: center; }
.card-user-name { font-weight: 600; font-size: 1.05rem; }

a.card-asset, .card-asset { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px; border-left: 5px solid var(--line-2); }
.card-asset.is-full { border-left-color: var(--brand); }
.card-asset-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.asset-beer { font-weight: 600; color: var(--ink-2); min-height: 1.4em; }
.asset-figures { display: flex; gap: 18px; align-items: baseline; }
.figure strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.figure small { color: var(--muted); margin-left: 4px; font-weight: 600; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.asset-step { margin: 0; font-size: .95rem; color: var(--ink-2); }
.asset-step em { font-style: normal; color: var(--muted); margin-left: 4px; }
.asset-step small { display: block; color: var(--muted); }
.asset-step-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.asset-step.is-done { color: var(--ok); font-weight: 600; }

/* --- Boutons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-warn { background: var(--warn-soft); border-color: transparent; color: #7a4f0e; }
.btn-warn:hover { background: #f4e2bd; border-color: transparent; }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: #f5cfcb; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-icon { padding: 0 12px; min-width: 46px; }
.btn-block { width: 100%; }
.btn-done { min-height: 52px; padding: 0 26px; font-size: 1.05rem; }
.btn-round { border-radius: 999px; padding: 0 14px 0 12px; }
.btn-round.v1 { border-color: var(--v1); color: var(--v1); }
.btn-round.v2 { border-color: var(--v2); color: var(--v2); }
.btn-round.v3 { border-color: var(--v3); color: var(--v3); }
.btn-round.v4 { border-color: var(--v4); color: var(--v4); }
.btn-round.v5 { border-color: var(--v5); color: var(--v5); }
.btn-round span { font-weight: 500; }

/* --- Champs ------------------------------------------------------------------ */
.input {
  font: inherit; min-height: 46px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); width: 100%; max-width: 100%;
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.input-num { max-width: 150px; font-variant-numeric: tabular-nums; }
select.input { appearance: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; white-space: nowrap; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-row .input { width: auto; flex: 1 1 180px; }
.form-row select.input { flex: 0 1 220px; }
.form-hint { width: 100%; }
.is-inactive { opacity: .55; }
.toggle-line { font-size: .9rem; margin: 10px 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-group { margin: 16px 0 4px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }

/* --- En-tête de rapport ------------------------------------------------------ */
.batch-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; padding: 16px 18px; margin-bottom: 18px; }
.batch-head-fields { flex: 1 1 340px; display: flex; flex-direction: column; gap: 10px; }
.field-inline { display: flex; align-items: center; gap: 12px; }
.field-inline label { flex: 0 0 96px; font-weight: 600; color: var(--ink-2); font-size: .95rem; }
.field-inline-in { flex: 1; display: flex; gap: 8px; align-items: center; }
.field-inline input:disabled { background: var(--surface-2); color: var(--ink-2); }
.batch-volume {
  flex: 0 0 auto; min-width: 150px; display: flex; flex-direction: column; justify-content: center; align-items: flex-end;
  padding: 8px 16px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand-2);
}
.batch-volume-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.batch-volume strong { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.batch-volume small { font-weight: 700; }

/* --- Étapes (timeline) --------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 22px; bottom: 22px; width: 2px; background: var(--line-2); }
.step { position: relative; display: flex; gap: 14px; padding: 6px 0; }
.step-dot {
  position: relative; z-index: 1; flex: none; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; background: var(--surface); border: 2px solid var(--line-2); color: var(--muted);
}
.step-body { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.step-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.step-name { font-weight: 600; font-size: 1.05rem; }
.step-values { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.step-meta { color: var(--muted); font-size: .9rem; margin-left: auto; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem; }
.chip-qty { font-variant-numeric: tabular-nums; font-weight: 600; }
.chip-link { min-height: 40px; padding: 4px 12px; color: inherit; text-decoration: none !important; }
.chip-link:hover { border-color: var(--brand); }
.chip-link small { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.step.is-done .step-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.is-done .step-body { background: var(--surface-2); box-shadow: none; }
.step.is-done .step-name { color: var(--ink-2); }
.step.is-current .step-dot { box-shadow: 0 0 0 4px var(--ok-soft); }
.step.is-todo { opacity: .7; }
.step.is-todo .step-body { box-shadow: none; }
.step.is-next .step-dot { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 5px var(--brand-soft); }
.step.is-next .step-body { border: 2px solid var(--brand); }
.step.is-next .step-name { font-size: 1.2rem; color: var(--brand-2); }
.step-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.step-form .input { width: auto; flex: 1 1 160px; max-width: 260px; min-height: 52px; font-size: 1.05rem; }
.auto-qty { color: var(--ink-2); font-weight: 600; padding: 0 4px; }
.step-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.step-tools .btn { min-height: 40px; font-size: .92rem; }
.complete { margin: 14px 0 0 58px; color: var(--ok); font-weight: 700; }

.batch-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 8px; }
.older { margin-top: 26px; }
.older h2 { margin-bottom: 10px; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; }

/* --- Tableaux ---------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; background: var(--surface-2); }
.table tr.row-sep td { border-top: 2px solid var(--line-2); }
.table td small { display: block; color: var(--muted); }

/* --- Graphique --------------------------------------------------------------------- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; height: auto; max-height: 460px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 13px; }
.chart .axis-sub { font-size: 11px; }
.chart .axis-line { stroke: var(--line-2); }
.chart .line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-prev { stroke-dasharray: 6 6; opacity: .6; stroke-width: 2; }
.chart .dot { stroke: #fff; stroke-width: 2; }
.chart .c1 { stroke: var(--v1); fill: var(--v1); }
.chart .c2 { stroke: var(--v2); fill: var(--v2); }
.swatch.c1 { background: var(--v1); }
.swatch.c2 { background: var(--v2); }
.chart .line.c1, .chart .line.c2 { fill: none; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; font-size: .95rem; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-item small { color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }

/* --- PIN --------------------------------------------------------------------------- */
.pin-box { max-width: 380px; margin: 10px auto 0; text-align: center; }
.pin-who { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 10px 0 18px; }
.pin-who h1 { font-size: 1.35rem; }
.pin-input { font-size: 2rem; letter-spacing: .5em; text-align: center; width: 100%; min-height: 64px; border-radius: var(--radius-sm); border: 2px solid var(--line-2); font-family: var(--font); }
.pin-input:focus { outline: none; border-color: var(--brand); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.key { font: inherit; font-size: 1.6rem; font-weight: 600; min-height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.key:active { background: var(--surface-2); }
.key-soft { color: var(--muted); }
.key-go { background: var(--ok); border-color: var(--ok); color: #fff; }
.pin-submit { display: none; }
@media (hover: hover) and (pointer: fine) { .pinpad { display: none; } .pin-submit { display: inline-flex; } }

/* --- Admin : listes d'étapes ------------------------------------------------------ */
.tpl-row { display: grid; grid-template-columns: 80px 80px minmax(200px, 2fr) 150px 90px; gap: 10px 12px; align-items: end; }
.tpl-row.tpl-new { border: 2px dashed var(--line-2); box-shadow: none; background: var(--surface-2); }
.tpl-row .f { display: flex; flex-direction: column; gap: 4px; }
.tpl-row .f > span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.tpl-row .f-checks { grid-column: 1 / -2; flex-direction: row; flex-wrap: wrap; gap: 4px 18px; }
.tpl-row .f-checks .check { min-height: 40px; font-size: .95rem; }
.tpl-row .f-actions { grid-column: -2 / -1; flex-direction: row; justify-content: flex-end; gap: 8px; }
@media (max-width: 760px) {
  .tpl-row { grid-template-columns: 1fr 1fr; }
  .tpl-row .f-name { grid-column: 1 / -1; }
  .tpl-row .f-checks, .tpl-row .f-actions { grid-column: 1 / -1; }
}

.trace { font-size: .8rem; overflow: auto; background: var(--surface); padding: 12px; border-radius: var(--radius-sm); }

@media (max-width: 720px) {
  .pill-home, .pill-name { display: none; }
  .pill-user { padding-right: 4px; }
  .pill-admin { padding: 0 12px; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 1.45rem; }
  .field-inline { flex-direction: column; align-items: stretch; gap: 4px; }
  .field-inline label { flex: none; }
  .batch-volume { align-items: center; width: 100%; }
  .step-meta { margin-left: 0; white-space: normal; width: 100%; }
  .timeline::before { left: 17px; }
  .step-dot { width: 36px; height: 36px; font-size: .9rem; }
  .complete { margin-left: 50px; }
}
