/* Mises en page propres à certains écrans. */

/* Connexion / inscription / foyer */
.brand { text-align: center; margin: var(--s5) 0 var(--s4); }
.brand-logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 4.5rem; height: 4.5rem; border-radius: 50%; background: var(--primary-soft); font-size: 2.4rem;
}
.brand-name { display: block; font-size: 1.7rem; font-weight: 800; margin-top: var(--s2); }
.brand-tagline { color: var(--muted); margin: var(--s1) 0 0; }
.auth-card h1 { font-size: 1.3rem; }
.invite-code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 2rem; font-weight: 800;
    letter-spacing: .3em; text-align: center; background: var(--primary-soft); color: var(--primary-text);
    border-radius: var(--radius-sm); padding: var(--s3) var(--s2); margin-bottom: var(--s3);
}
.member-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.member-list li { display: flex; align-items: center; gap: var(--s3); font-weight: 700; }
.member-list .avatar { font-size: 1.1rem; font-weight: 800; background: var(--primary-soft); color: var(--primary-text); }

/* Scanner */
.viewfinder {
    position: relative; border-radius: var(--radius); overflow: hidden; background: #111;
    min-height: 14rem; margin-bottom: var(--s3);
}
.viewfinder #scanner-reader { width: 100%; border: 0 !important; }
.viewfinder #scanner-reader video { display: block; width: 100%; object-fit: cover; }
.viewfinder-corners { position: absolute; inset: 1rem; pointer-events: none; }
.viewfinder-corners span { position: absolute; width: 2rem; height: 2rem; border: 4px solid var(--peach); animation: pulse-corner 1.8s ease-in-out infinite; }
.viewfinder-corners span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 1rem; }
.viewfinder-corners span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 1rem; }
.viewfinder-corners span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 1rem; }
.viewfinder-corners span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 1rem; }
@keyframes pulse-corner { 0%, 100% { opacity: .55; transform: scale(.96); } 50% { opacity: 1; transform: scale(1); } }
.viewfinder .torch { position: absolute; top: var(--s3); right: var(--s3); background: rgb(255 255 255 / .85); color: #222; z-index: 2; }
.viewfinder .torch[hidden] { display: none; }
.scan-status { text-align: center; margin-bottom: var(--s3); }
.scan-status .chip { white-space: normal; font-size: .9rem; }
.scan-status:empty { display: none; }
#scanner-reader { color: #ddd; }
#scanner-reader button { margin: .3rem; }

/* Ajout rapide */
.sticky-search { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: var(--s2) 0; margin: 0 0 var(--s2); }
.sticky-search input { margin: 0; }
.quick-hint { display: flex; justify-content: center; margin-bottom: var(--s3); }
.quick-hint[hidden] { display: none; }
.quick-hint .chip { gap: var(--s2); white-space: normal; text-align: center; }
.quick-hint button { display: inline-flex; border: 0; background: none; color: inherit; padding: .1rem; cursor: pointer; }
.tiles.quick-tiles { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 480px) { .tiles.quick-tiles { grid-template-columns: repeat(4, 1fr); } }
.quick-tiles .tile { min-height: 5.6rem; }
.quick-tiles .tile:active { transform: scale(.9); background: var(--primary-soft); }

/* Courses */
.shopping-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: var(--s2) 0 var(--s3); margin-bottom: var(--s2); }
.shopping-add-fields { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); align-items: start; }
.shopping-add-fields > :first-child { grid-column: 1 / -1; }
.shopping-add-fields input { margin: 0; }
.shopping-add-fields .btn-icon { margin-top: .05rem; }
.aisle { padding: var(--s3); }
.aisle .card-title { font-size: 1rem; margin-bottom: var(--s2); }
.shopping-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s1) 0; border-top: 1px solid var(--line); }
.aisle .shopping-row:first-of-type { border-top: 0; }
.shopping-check { margin: 0; flex: none; }
.check-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; border-radius: 50%; padding: 0;
    border: 2px solid var(--primary); background: transparent; color: transparent; cursor: pointer;
    transition: background-color .2s ease-out, color .2s ease-out, transform .2s ease-out;
}
.check-btn:active { transform: scale(.9); }
.shopping-row.done .check-btn { background: var(--primary); color: var(--on-primary); animation: pop .25s ease-out; }
@keyframes pop { 0% { transform: scale(.7); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.shopping-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.shopping-label .row-chips { margin: 0; }
.shopping-row.done .shopping-label strong { text-decoration: line-through; }
.shopping-row.done { opacity: .55; }
.shopping-more { flex: none; position: relative; }
.shopping-more > summary { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; color: var(--muted); }
.shopping-more[open] > summary { background: var(--surface-2); }
.shopping-more-body {
    position: absolute; right: 0; top: 100%; z-index: 4; min-width: 14rem; display: grid; gap: var(--s1);
    padding: var(--s2); background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.shopping-more-body form { margin: 0; }
.shopping-more-body .btn { width: 100%; justify-content: flex-start; min-height: 2.6rem; }
.cart-section > summary { display: flex; align-items: center; gap: var(--s2); font-weight: 800; font-size: 1.05rem; min-height: 2.75rem; }

/* Inventaire */
.inv-progress { margin-bottom: var(--s4); }
.inv-progress small { display: block; margin-top: var(--s1); color: var(--muted); font-weight: 700; }
.inv-line { flex-wrap: wrap; align-items: flex-start; }
.inv-line .row-main { flex-basis: calc(100% - 4rem); }
.inv-line.inv-present { --stripe: var(--primary); background: var(--primary-soft); }
.inv-line.inv-missing { --stripe: var(--danger); background: var(--danger-soft); }
.inv-line.inv-adjusted { --stripe: var(--frost); background: var(--frost-soft); }
.inv-line.inv-added { --stripe: var(--primary); background: var(--primary-soft); }
.inv-line.inv-stale { opacity: .55; }
.inv-state { width: 100%; margin: 0; font-weight: 700; font-size: .9rem; }
.inv-choices { width: 100%; display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.inv-choices form { margin: 0; }
.inv-choices .inline-form input { width: 6.5rem; min-height: 2.4rem; padding: .3rem .7rem; }
.inv-actions { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.inv-actions form { margin: 0; }
#inv-scan-status:empty { display: none; }
.inv-location-card { display: flex; align-items: center; gap: var(--s3); }
.inv-location-card form { margin: 0; flex: none; }

/* Statistiques */
.period { margin-bottom: var(--s3); }
.hero-stat { display: flex; align-items: center; gap: var(--s4); }
.ring {
    flex: none; width: 6.5rem; height: 6.5rem; border-radius: 50%;
    background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--danger-soft) 0);
    display: flex; align-items: center; justify-content: center; position: relative;
}
.ring::before { content: ""; position: absolute; inset: .7rem; border-radius: 50%; background: var(--surface); }
.ring strong { position: relative; font-size: 1.6rem; }
.hero-stat p { margin: 0 0 var(--s1); }
.stat-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.stat { margin: 0; display: flex; flex-direction: column; gap: .1rem; }
.stat strong { font-size: 1.8rem; line-height: 1.1; }
.stat small { color: var(--muted); }
.bars { display: flex; align-items: stretch; gap: .25rem; height: 10rem; margin-bottom: var(--s1); }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-align: center; }
.bar-total { font-size: .7rem; }
.bar-stack { width: 100%; max-width: 2.5rem; display: flex; flex-direction: column; min-height: 0; border-radius: .5rem; overflow: hidden; }
.bar-consumed { background: var(--primary); }
.bar-discarded { background: var(--danger); }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; vertical-align: middle; }
.legend { text-align: center; color: var(--muted); }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.rank-list li { display: flex; align-items: center; gap: var(--s3); }
.rank-list .row-main { flex: 1; }
.stat-table td.num { text-align: right; font-weight: 800; }

/* Listes simples (produits, emplacements) */
.list-card { padding: var(--s2) var(--s3); }
.list-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .row-link { padding: 0; }
.location-tile { display: flex; align-items: center; gap: var(--s3); }
.location-tile .tile-emoji { font-size: 1.8rem; }
.location-actions { display: flex; gap: var(--s1); align-items: center; flex: none; }
.location-actions form { margin: 0; }

/* Grand écran : colonne centrale déjà limitée par main ; la feuille et la nav suivent. */
@media (min-width: 640px) {
    .bottom-nav { left: 50%; right: auto; width: 40rem; transform: translateX(-50%); border-radius: var(--radius) var(--radius) 0 0; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.product-line { display: flex; align-items: center; gap: var(--s3); font-size: 1.1rem; }
.product-photo { border-radius: var(--radius-sm); }
.page-end { margin-top: var(--s4); }
.page-end.stack-actions { margin-top: var(--s4); }
.location-row { flex-wrap: wrap; }
@media (max-width: 420px) { .location-row .location-actions { width: 100%; justify-content: flex-end; } }

/* ---- Planches d'étiquettes (grille en mm : --u vaut 1 mm, ou une fraction de la largeur pour les miniatures) ---- */
.sheet-grid {
    --u: 1mm;
    display: grid; align-content: start; justify-content: start;
    width: calc(210 * var(--u)); height: calc(297 * var(--u));
    grid-template-columns: repeat(var(--cols), calc(var(--w) * var(--u)));
    grid-template-rows: repeat(var(--rows), calc(var(--h) * var(--u)));
    column-gap: calc(var(--gx) * var(--u)); row-gap: calc(var(--gy) * var(--u));
    padding: calc(var(--mt) * var(--u)) calc(var(--ms) * var(--u)) calc(var(--mb) * var(--u));
}
.mini-wrap { width: 5.2rem; flex: none; aspect-ratio: 210 / 297; container-type: size; background: #fff; border-radius: .25rem; box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.mini-sheet { --u: calc(100cqw / 210); }
.mini-sheet .cell { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); border-radius: 1px; }
.mini-sheet.mini-invalid .cell { background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }
.sheet-row { align-items: flex-start; }
.sheet-row .mini-wrap { margin: var(--s1) 0; }
.sheet-default { margin: var(--s2) 0 0; }
.sheet-preview { display: flex; gap: var(--s4); align-items: center; margin-bottom: var(--s4); }
.sheet-summary { font-size: 1.15rem; font-weight: 800; margin-bottom: var(--s1); }
.small { font-size: .85rem; }

/* Page d'impression des étiquettes : l'aperçu est la planche elle-même (réduite à l'écran, à 100 % à l'impression). */
.a4-frame { width: 100%; overflow-x: auto; margin: 0 0 var(--s4); }
.a4 { background: #fff; color: #000; box-shadow: var(--shadow); }
.etq {
    container-type: size; container-name: etq; display: block; position: relative; overflow: hidden;
    color: #000; text-decoration: none; background: #fff;
    outline: .2mm dashed #c4c4c4; outline-offset: -.2mm;
}
.etq-empty { background: #f5f5f2; }
.etq-empty:hover, .etq[data-start] { outline: .5mm solid var(--primary); outline-offset: -.5mm; background: #eaf4e8; }
.etq-body { display: flex; flex-direction: column; gap: .4mm; height: 100%; padding: 1.2mm 1.8mm; line-height: 1.15; font-family: var(--font); }
.etq-head { display: none; align-items: center; gap: 1.5mm; min-width: 0; }
.etq-emoji { font-size: min(6mm, 14cqh); line-height: 1; }
.etq-name { font-size: min(4.8mm, 12cqh); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etq-dates { display: flex; flex-direction: column; font-size: min(3.3mm, 10cqh); }
.etq-until { font-weight: 800; }
.etq-meta { display: none; font-size: 2.7mm; }
.etq-code { flex: 1 1 0; min-height: 0; display: flex; align-items: flex-end; justify-content: center; }
.etq-code svg { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; }
@container etq (min-width: 30mm) and (min-height: 21mm) { .etq-head { display: flex; } }
@container etq (min-height: 30mm) { .etq-meta { display: block; } }
.etq-empty .etq-body { display: none; }

@media print {
    .no-print, .bottom-nav, .side-nav, .topbar, #toasts, dialog.sheet { display: none !important; }
    html, body { background: #fff !important; }
    body { padding: 0 !important; }
    main { max-width: none; margin: 0; padding: 0; }
    .a4-frame { overflow: visible; margin: 0; height: auto !important; }
    .a4 { transform: none !important; box-shadow: none; break-inside: avoid; }
    .etq { outline: none; }
    .etq-empty { background: none; }
    .etq[data-start] { outline: none; background: #fff; }
    .a4 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.sheet-warning { color: var(--danger-text); font-weight: 700; font-size: .9rem; margin-bottom: var(--s1); }
.sheet-warning[hidden] { display: none; }
.sheet-row .row-sub { white-space: nowrap; }

/* Codes QR associés à un produit */
.code-preview { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem; overflow-wrap: anywhere; word-break: break-all; }
.code-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.code-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.code-list form { margin: 0; flex: none; }

/* Inventaire : dernière ligne pointée à la scanette */
.inv-just { outline: 3px solid var(--peach); outline-offset: -3px; }
.scan-count { text-align: center; margin: 0 0 var(--s2); }

/* Page Scanette */
.wedge-ready { text-align: center; }
.wedge-icon { color: var(--primary); margin: 0 0 var(--s2); }
.wedge-ready .facts { text-align: left; }
.wedge-key { font-size: .85rem; margin-bottom: 0; }
