/* HACCP Pixel de Guérande : palette « bistrot de plage » reprise de l'app d'origine */
:root {
  --bg: #fdfbf7; --card: #fdfbf7; --surface: #ffffff; --ink: #1a1a1a; --muted: #666; --line: #e3dccf;
  --secondary: #f1ebe0; --soft: #ebe5da;
  --primary: #e65100; --primary-ink: #fff;
  --success: #065f46; --success-bg: rgba(6, 95, 70, .07);
  --danger: #dc2626; --danger-bg: rgba(220, 38, 38, .06);
  --warning: #f59e0b; --warning-ink: #1a1a1a; --warning-bg: rgba(245, 158, 11, .08);
  --radius: 12px; --shadow: 0 4px 14px -2px rgba(0,0,0,.1), 0 2px 6px -1px rgba(0,0,0,.06);
  --slab: "Roboto Slab", "Rockwell", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --card: #1e1e1e; --surface: #1e1e1e; --ink: #fbf9f4; --muted: #a6a6a6; --line: #333;
    --secondary: #2e2e2e; --soft: #2a2a2a;
    --primary: #ff6a1a; --success: #10b981; --success-bg: rgba(16,185,129,.1);
    --danger: #ef4444; --danger-bg: rgba(239,68,68,.1); --warning-bg: rgba(245,158,11,.12);
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
h1, h2, h3, .slab { font-family: var(--slab); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.hidden { display: none !important; }

/* ---- structure ---- */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-in { max-width: 32rem; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 8px; }
.top h1 { font-size: 20px; margin: 0; color: var(--primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { max-width: 32rem; margin: 0 auto; padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 60rem; }
.hello { margin-bottom: 24px; }
.hello p { margin: 0; color: var(--muted); font-size: 18px; }
.hello h2 { margin: 0; font-size: 24px; }
section.block { margin-bottom: 24px; }
.block-title { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.block-title svg { color: var(--primary); }
.block-title .count { margin-left: auto; font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.block-title .count.done { background: var(--success-bg); color: var(--success); }
.icon { width: 20px; height: 20px; flex: none; }

/* ---- boutons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 16px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 14px; border-width: 1px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 18px; text-transform: uppercase; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--secondary); border: 0; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink); text-decoration: none; white-space: nowrap; }
.sync { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 0; cursor: pointer; white-space: nowrap; }
.sync.synced { background: var(--success-bg); color: var(--success); }
.sync.pending, .sync.offline, .sync.syncing { background: var(--warning-bg); color: #9a6200; }
.sync.error, .sync.suspended, .sync.expired { background: var(--danger-bg); color: var(--danger); }
@media (prefers-color-scheme: dark) { .sync.pending, .sync.offline, .sync.syncing { color: var(--warning); } }
.sync .lbl { display: none; }
@media (min-width: 380px) { .sync .lbl { display: inline; } }

/* ---- cartes de saisie ---- */
.tile { width: 100%; min-height: 80px; padding: 14px 16px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.tile:active { transform: scale(.98); }
.tile.ok { background: var(--success-bg); border-color: var(--success); }
.tile.bad { background: var(--danger-bg); border-color: var(--danger); }
.tile.warn { background: var(--warning-bg); border-color: var(--warning); }
.tile .emoji { font-size: 26px; }
.tile .grow { flex: 1; min-width: 0; }
.tile .name { font-weight: 700; }
.tile .sub { font-size: 14px; font-weight: 600; color: var(--muted); }
.tile .val { text-align: right; }
.tile .val b { display: block; font-size: 22px; font-weight: 900; }
.tile .val small { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile.ok .val b { color: var(--success); } .tile.bad .val b { color: var(--danger); }
.badge-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.badge-ico.ok { background: var(--success); } .badge-ico.bad { background: var(--danger); } .badge-ico.warn { background: var(--warning); color: #1a1a1a; }
.stack { display: grid; gap: 12px; }
.panel { padding: 16px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); }
.panel.ok { background: var(--success-bg); border-color: var(--success); }
.panel.bad { background: var(--danger-bg); border-color: var(--danger); }
.panel.warn { background: var(--warning-bg); border-color: var(--warning); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.empty-note { padding: 16px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* nettoyage */
.task { width: 100%; min-height: 72px; display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 10px; border: 0; background: var(--secondary); cursor: pointer; text-align: left; }
.task.done { background: var(--success-bg); }
.task .check { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--line); background: var(--soft); color: var(--muted); }
.task.done .check { background: var(--success); border-color: var(--success); color: #fff; }
.task .tname { flex: 1; font-weight: 700; }
.task.done .tname { color: var(--success); text-decoration: line-through; }
.task .ttime { font-size: 14px; font-weight: 700; color: var(--success); }

/* huile */
.oil-btns { display: grid; gap: 8px; margin-top: 12px; }
.oil-btns .btn { min-height: 72px; font-size: 18px; text-transform: uppercase; border: 0; box-shadow: var(--shadow); }
.oil-ok { background: var(--success); color: #fff; }
.oil-moy { background: var(--warning); color: #1a1a1a; }
.oil-bad { background: var(--danger); color: #fff; }

/* photos */
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot { display: grid; gap: 6px; }
.slot-box { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 2px solid var(--line); background: var(--soft); }
.slot-add { aspect-ratio: 1; border-radius: 10px; border: 2px dashed var(--line); background: var(--secondary); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.slot-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; display: grid; place-items: center; cursor: pointer; }
.slot select { font-size: 12px; font-weight: 700; padding: 4px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); width: 100%; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.thumb { position: relative; width: 64px; height: 64px; flex: none; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--soft); padding: 0; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 9px; font-weight: 700; text-align: center; }

/* ---- formulaires ---- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.input, input.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); }
.input:focus { outline: none; border-color: var(--primary); }
textarea.input { min-height: 96px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.form-msg { color: var(--danger); font-weight: 600; font-size: 14px; margin: 0 0 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px; }
.list > * + * { border-top: 1px solid var(--line); }
.li { padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.li .grow { flex: 1; min-width: 0; }
.li .name { font-weight: 700; }
h3.sec { font-size: 15px; margin: 24px 0 8px; color: var(--muted); }

/* ---- écrans pleins ---- */
.overlay { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 97%, transparent); display: flex; flex-direction: column; overflow-y: auto; padding-top: env(safe-area-inset-top); }
.ov-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ov-head h2 { margin: 0; font-size: 18px; }
.ov-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.ov-foot { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.display { font-family: var(--slab); font-size: 72px; font-weight: 700; line-height: 1; }
.display small { font-size: 36px; color: var(--muted); margin-left: 6px; }
.display.out { color: var(--danger); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 24rem; margin: 0 auto; }
.key { height: 64px; border-radius: 12px; border: 0; background: var(--secondary); font-size: 28px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.key.alt { background: var(--soft); color: var(--muted); box-shadow: none; }
.key:active { transform: scale(.95); }
.keys + .btn { max-width: 24rem; margin: 20px auto 0; display: flex; }
.alert-box { background: var(--danger); color: #fff; border-radius: 12px; padding: 24px; text-align: center; margin-bottom: 20px; }
.alert-box h2 { margin: 8px 0; font-size: 24px; }
.flash { position: fixed; inset: 0; z-index: 60; background: var(--danger); color: #fff; display: grid; place-items: center; text-align: center; padding: 24px; animation: flash .8s ease-in-out infinite; cursor: pointer; }
.flash h1 { font-size: 36px; margin: 16px 0; }
@keyframes flash { 50% { background: color-mix(in srgb, var(--danger) 80%, #000); } }
.lightbox { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; color: #fff; }
.lightbox .lb-img { flex: 1; display: grid; place-items: center; overflow: auto; touch-action: pinch-zoom; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb-head, .lightbox .lb-foot { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.lb-foot { justify-content: center !important; padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important; }
.lb-tag { background: rgba(255,255,255,.12); border-radius: 99px; padding: 4px 12px; font-size: 14px; font-weight: 700; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; cursor: pointer; }

/* ---- bas de page, connexion, bandeaux ---- */
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 28px; }
.auth { max-width: 24rem; margin: 10vh auto 0; padding: 0 16px 40px; }
.auth h1 { color: var(--primary); margin: 0 0 4px; }
.banner { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: var(--warning-bg); border: 1px solid var(--warning); }
.banner.bad { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 90; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }
.spin { width: 20px; height: 20px; border: 3px solid var(--primary); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-screen { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 24px; }

/* ---- registre ---- */
.reg-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.reg-tools .field { margin: 0; }
table.reg { width: 100%; border-collapse: collapse; font-size: 14px; }
table.reg th, table.reg td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.reg th { border-bottom: 2px solid var(--ink); font-weight: 700; }
table.reg td.alert { color: var(--danger); font-weight: 700; }
.table-scroll { overflow-x: auto; }
.reg-thumb { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); cursor: pointer; display: block; }
.print-only { display: none; }
.visa-col { display: none; }

@media print {
  @page { size: A4 portrait; margin: 14mm; }
  body { background: #fff !important; color: #000 !important; font-size: 10pt; }
  .top, .no-print, .toast, .reg-tools { display: none !important; }
  .print-only { display: block !important; }
  .wrap { max-width: none; padding: 0; }
  table.reg { font-size: 9pt; }
  table.reg th, table.reg td { border: 1px solid #333; padding: 4px 6px; color: #000; }
  table.reg th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { page-break-inside: avoid; }
  .page-break { page-break-before: always; }
  .reg-thumb { width: 24mm; height: 24mm; border: .5pt solid #333; border-radius: 0; }
  .no-photos .reg-thumb { display: none; }
  .no-photos .photo-ph { display: inline !important; }
  .visa-col { display: table-cell !important; width: 18mm; }
}

/* liens de soutien (repris de l'app d'origine) */
.support { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; text-decoration: none; }
.support:hover { opacity: .9; }
.support.kofi { background: hsl(200, 80%, 55%); color: #fff; }
.support.bmc { background: hsl(45, 100%, 50%); color: hsl(0, 0%, 10%); }
