/* HACCP ARVI — écran de cuisine (tablette 10–15″) et back-office.
   Gros boutons (≥ 48 px), contrastes forts, code couleur rouge = en retard, orange = à faire, vert = fait. */
:root {
  --bg: #f4f2ed; --panel: #fff; --ink: #1b1a17; --muted: #5e5a52; --line: #dedad1; --line-2: #eeebe4;
  --rail: #1b1a17; --rail-ink: #e9e6df; --accent: #1d4f6e; --accent-2: #123447; --accent-bg: #e4eef4;
  --late: #c2321f; --late-ink: #9b2316; --late-bg: #fbe3df;
  --today: #e8912d; --today-ink: #7a4006; --today-bg: #fcebd3;
  --ok: #1f6b3a; --ok-bg: #e3f0e6; --ok-dot: #3ba55c;
  --radius: 14px; --rail-w: 208px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 16px/1.4 "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
a:hover { color: var(--accent-2); }
h1 { font-size: 1.75rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .right { text-align: right; }
.hidden { display: none !important; }

/* --- cadre --- */
.app { display: flex; min-height: 100vh; }
.rail { width: var(--rail-w); flex: none; background: var(--rail); color: #fff; display: flex; flex-direction: column; padding: 20px 12px; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.rail .brand { font-size: 1.25rem; font-weight: 700; padding: 4px 12px; color: #fff; text-decoration: none; }
.rail .site { font-size: .875rem; color: #b9b4aa; padding: 0 12px 16px; }
.rail .nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 50px; padding: 0 12px; border-radius: 10px; color: var(--rail-ink); text-decoration: none; font-size: 1.06rem; }
.rail .nav:hover { color: #fff; background: #2c2a26; }
.rail .nav.on { background: #fff; color: var(--ink); font-weight: 700; }
.rail .sep { height: 1px; background: #3a3732; margin: 10px 12px; }
.rail .foot { margin-top: auto; font-size: .875rem; color: #b9b4aa; padding: 12px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 5px; margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok-dot); } .dot.ko { background: var(--late); } .dot.off { background: #8a857c; }
.badge { min-width: 26px; height: 26px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; font-size: .875rem; font-weight: 700; padding: 0 8px; }
.badge.late { background: var(--late); color: #fff; } .badge.today { background: var(--today); color: var(--ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.grey { background: var(--line-2); color: var(--muted); }
.badge.big { height: 30px; border-radius: 15px; padding: 0 12px; }
.burger { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 64px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.top .when { font-size: 1.12rem; }
.user-chip { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 7px; border: 1px solid var(--line); border-radius: 22px; background: #fff; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 16px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .875rem; }
.content { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-head .sub { font-size: .94rem; color: var(--muted); margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cols > .grow { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cols > .side { flex: 1 1 340px; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }

.flashes { display: flex; flex-direction: column; gap: 6px; }
.flash { padding: 12px 16px; border-radius: 10px; background: var(--accent-bg); color: var(--accent-2); font-weight: 700; }
.flash-error { background: var(--late-bg); color: var(--late-ink); }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-warning { background: var(--today-bg); color: var(--today-ink); }

/* --- composants --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); font: inherit; font-size: 1.06rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: #f7f5f0; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; min-width: 96px; }
.btn.danger { color: var(--late-ink); border-color: var(--late-ink); }
.btn.big { min-height: 60px; font-size: 1.25rem; padding: 0 28px; }
.btn.small { min-height: 40px; font-size: .94rem; padding: 0 14px; }
.btn.block { width: 100%; }
.btn.ok-state { background: #fff; color: var(--ok); border-color: var(--ok); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: underline; }

.task { display: flex; align-items: center; gap: 16px; min-height: 58px; padding: 6px 10px 6px 18px; border-radius: 12px; }
.task .t { flex: 1; min-width: 0; }
.task .tt { font-size: 1.12rem; font-weight: 700; }
.task .tm { font-size: .875rem; color: var(--muted); }
.task.late { background: var(--late-bg); } .task.today { background: var(--today-bg); }
.task.next { background: #fff; border: 1px solid var(--line); } .task.next .tt { font-weight: 400; }
.task.done { background: var(--ok-bg); } .task.done .tt { font-weight: 400; } .task .donetag { color: var(--ok); font-weight: 700; padding-right: 8px; }
.sec { font-size: .875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 8px 0 0; }
.sec.late { color: var(--late-ink); } .sec.today { color: var(--today-ink); } .sec.next, .sec.done { color: var(--muted); }

.pill { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 0 12px; border-radius: 15px; font-size: .875rem; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--today-bg); color: var(--today-ink); }
.pill.ko { background: var(--late-bg); color: var(--late-ink); } .pill.grey { background: var(--line-2); color: var(--muted); }
.pill.info { background: var(--accent-bg); color: var(--accent-2); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: 0; }
.letter { width: 36px; height: 36px; border-radius: 8px; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.letter.late { background: var(--late); }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf9f6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.table-wrap table { border: 0; }
tr.late td { background: #fdf1ef; } tr.warn td { background: #fff8ee; }

/* --- formulaires --- */
form.stack, .stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .94rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-size: 1rem; }
input, select, textarea { font: inherit; font-size: 1.06rem; min-height: 50px; padding: 0 14px; border: 1.5px solid #bdb8ae; border-radius: 12px; background: #fff; color: var(--ink); }
textarea { padding: 12px 14px; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #b9d3e4; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 26px; height: 26px; min-height: 0; accent-color: var(--accent); }
input.auto { border-color: var(--accent); background: #f2f7fa; font-weight: 700; }
input.temp { font-size: 1.25rem; font-weight: 700; text-align: center; max-width: 140px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 23px; border: 1.5px solid #bdb8ae; background: #fff; font: inherit; font-weight: 700; color: var(--ink); text-decoration: none; cursor: pointer; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.seg label { flex-direction: row; margin: 0; color: var(--ink); font-size: 1rem; font-weight: 700; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; min-height: 46px; padding: 0 16px; cursor: pointer; }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid #b9d3e4; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.choice { display: flex; position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 84px; padding: 0 18px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.choice span b { font-size: 1.12rem; } .choice span small { color: var(--muted); font-size: .875rem; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-bg); }
.choice input:focus-visible + span { outline: 3px solid #b9d3e4; }
.check { display: flex; align-items: center; gap: 14px; min-height: 54px; font-size: 1.06rem; color: var(--ink); border-bottom: 1px solid var(--line-2); flex-direction: row; }

/* --- températures --- */
.enc { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.enc .big { font-size: 2.8rem; font-weight: 700; line-height: 1.05; }
.enc.attention { border: 2px solid var(--today); } .enc.attention .big { color: var(--today-ink); }
.enc.alerte { border: 2px solid var(--late); } .enc.alerte .big { color: var(--late-ink); }
.enc svg { width: 100%; height: 96px; }
.alert-band { background: var(--late); color: #fff; padding: 22px 28px; border-radius: var(--radius); }
.alert-band .k { font-size: .94rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.alert-band .v { font-size: 2rem; font-weight: 700; margin-top: 2px; }
.alert-band.tech { background: var(--today); color: var(--ink); }

/* --- étiquettes --- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.prod { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; min-height: 84px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font: inherit; text-align: left; color: var(--ink); cursor: pointer; }
.prod b { font-size: 1.06rem; } .prod small { color: var(--muted); }
.prod.sel { border-color: var(--accent); background: var(--accent-bg); }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 52px; height: 52px; border-radius: 12px; border: 1.5px solid var(--ink); background: #fff; font: inherit; font-size: 1.6rem; font-weight: 700; cursor: pointer; }
.stepper output { font-size: 1.6rem; font-weight: 700; min-width: 36px; text-align: center; }
.label-preview { align-self: center; border: 1px dashed #9a958b; border-radius: 6px; background: #fff; display: flex; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.08); }

/* étiquette imprimée (aperçu écran et impression) */
.lbl { width: var(--lw, 55mm); height: var(--lh, 29mm); display: flex; overflow: hidden; background: #fff; color: #000; font-family: Arial, Helvetica, sans-serif; break-after: page; page-break-after: always; }
.lbl:last-child { break-after: auto; page-break-after: auto; }
.lbl .day { width: 30%; flex: none; background: #000; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.lbl .day b { font-size: 9.5mm; line-height: 1; }
.lbl .day small { font-size: 2.2mm; margin-top: .8mm; }
.lbl .body { flex: 1; min-width: 0; padding: 1.4mm 2mm; display: flex; flex-direction: column; gap: .3mm; font-size: 2.5mm; line-height: 1.15; }
.lbl .name { font-size: 3.6mm; font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lbl .dlc { font-size: 3.4mm; font-weight: 700; }
.lbl .foot { margin-top: auto; font-size: 2.1mm; }
.print-sheet { display: flex; flex-direction: column; align-items: center; gap: 6mm; padding: 6mm; }

/* --- traçabilité --- */
.camera { background: var(--rail); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; color: #fff; }
.camera .shot { flex: 1; min-height: 360px; border-radius: 12px; background: #3a3732; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.camera .shot img { max-width: 100%; max-height: 520px; display: block; }
.camera .btn { background: transparent; color: #fff; border-color: #fff; }
.camera .btn:hover { background: #2c2a26; }
.camera .status { position: absolute; left: 14px; bottom: 12px; background: var(--accent); color: #fff; font-size: .875rem; font-weight: 700; padding: 6px 12px; border-radius: 14px; }
/* Champ photo transparent posé sur le bouton (display:none rend le bouton muet sur iPhone en appli d'écran d'accueil) */
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; min-height: 0; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* --- nettoyage --- */
.post { display: flex; align-items: center; gap: 16px; min-height: 78px; padding: 8px 14px 8px 20px; border-radius: 14px; }
.post.late { background: var(--late-bg); } .post.today { background: var(--today-bg); } .post.done { background: var(--ok-bg); }
.post.next { background: #fff; border: 1px solid var(--line); }
.post .pt { font-size: 1.15rem; font-weight: 700; }
.ck { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; background: rgba(255,255,255,.8); font-size: .82rem; margin: 2px 6px 2px 0; }

/* --- tablette : code PIN --- */
body.kiosk { background: var(--rail); color: #fff; }
.pin-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; padding: 40px; align-items: center; max-width: 1100px; margin: 0 auto; }
.pin-clock { font-size: 5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.pin-date { font-size: 1.4rem; opacity: .8; margin-top: 8px; }
.pin-panel { background: #fff; color: var(--ink); border-radius: 18px; padding: 26px; }
.pin-display { font-size: 2.4rem; letter-spacing: .6em; text-align: center; height: 3.4rem; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { font: inherit; font-size: 1.9rem; font-weight: 700; padding: 18px 0; border-radius: 14px; border: 1px solid var(--line); background: #f4f2ed; color: var(--ink); cursor: pointer; }
.keypad button:active { background: #e4e0d6; }
.keypad button.go { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- connexion --- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { background: #fff; padding: 32px; border-radius: 18px; width: min(400px, 94vw); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.login-box h1 { text-align: center; margin-bottom: 4px; }

/* --- rapports / impression --- */
.report { background: #fff; padding: 24px; border-radius: var(--radius); border: 1px solid var(--line); }
.report h1 { font-size: 1.5rem; }
.report table { font-size: .9rem; }
.report th, .report td { padding: 6px 8px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .rail { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .rail .site, .rail .foot, .rail .sep { display: none; }
  .rail .nav { min-height: 44px; font-size: .95rem; }
  .top { padding: 0 16px; position: static; }
  .content { padding: 16px; }
  .pin-wrap { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .pin-clock { font-size: 3rem; }
}

@media print {
  .rail, .top, .no-print, .flashes { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card, .report { border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
}
