:root {
	--bg: #f4f6f9;
	--box: #ffffff;
	--text: #1a1d24;
	--muted: #6b7280;
	--border: #e5e7eb;
	--accent: #0d9488;
	--neg: #dc2626;
	--pos: #059669;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1216;
		--box: #1a1e26;
		--text: #f0f2f5;
		--muted: #9ca3af;
		--border: #2a3140;
		--accent: #2dd4bf;
		--neg: #f87171;
		--pos: #34d399;
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
code { font-size: .9em; }
h1 { font-size: 1.4rem; margin: 1.2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
small { display: block; color: var(--muted); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.carte-cats { border: 0; margin: .6rem 0; padding: 0; }
.carte-cats legend { font-weight: 600; margin-bottom: .3rem; }
.carte-cats .switch { display: block; margin: .25rem 0; }
.card.sub { margin: .6rem 0; padding: .75rem; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }

header.top {
	background: var(--box);
	border-bottom: 1px solid var(--border);
	padding: .5rem 1rem;
	display: flex;
	flex-wrap: wrap;
	gap: .5rem 1rem;
	align-items: center;
}
header .brand { font-weight: 700; text-decoration: none; color: var(--text); }
header nav { display: flex; flex-wrap: wrap; gap: .35rem .85rem; align-items: center; }
header nav a { text-decoration: none; padding: .2rem 0; }
header nav a.active { font-weight: 700; border-bottom: 2px solid var(--accent); }
/* Ordinateur : groupes de menu en ligne, libellés discrets. */
header nav .nav-group {
	display: inline-flex;
	flex-wrap: wrap;
	gap: .25rem .75rem;
	align-items: center;
	padding-right: .75rem;
	border-right: 1px solid var(--border);
}
header nav .nav-group:last-of-type { border-right: 0; padding-right: 0; }
header nav .nav-group-label {
	display: none;
	font-size: .7rem;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--muted);
	font-weight: 600;
}
header nav .nav-logout { margin-left: .25rem; }

main { max-width: 1000px; margin: 0 auto; padding: 0 1rem 3rem; }
main.wide { max-width: none; }

.page-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: .75rem;
	margin: 1rem 0 .6rem;
	flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head .lede { margin: .2rem 0 0; color: var(--muted); font-size: .95rem; max-width: 36rem; }
.hint { margin: .2rem 0 .7rem; color: var(--muted); font-size: .9rem; }
.empty-state {
	text-align: center;
	padding: 1.5rem 1rem;
	color: var(--muted);
}
.empty-state a { font-weight: 600; }
.scan-result-head { margin-bottom: .6rem; }
.scan-result-head h2 { margin: 0 0 .25rem; }
.stock-line { margin: 0; color: var(--muted); }
.scan-tools { margin-top: .2rem; }
.scan-fast-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: .35rem .6rem;
}
.scan-fast #fast-body { margin-top: .7rem; }

.card {
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 1rem;
	margin: .75rem 0;
}
.card.sub { margin: 0; }
.card.narrow { max-width: 380px; margin: 3rem auto; }
.grid2 { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

label { display: block; margin: 0 0 .7rem; }
label.mini { display: inline-flex; align-items: center; gap: .3rem; margin: 0 .5rem .3rem 0; }
input, select, button {
	font: inherit;
	padding: .55rem .6rem;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
}
label > input, label > select { display: block; width: 100%; margin-top: .2rem; }
label.mini input { width: 5rem; margin: 0; }
button {
	background: var(--accent);
	color: #fff;
	border: 0;
	cursor: pointer;
	font-weight: 600;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; text-decoration: underline; }
form.inline { display: inline; }
.colruyt-summary {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem 1.25rem;
	margin: 0 0 1rem;
	padding: .75rem 1rem;
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 10px;
}
.colruyt-summary li { margin: 0; color: var(--muted); }
.colruyt-summary strong { color: var(--text); }
.colruyt-actions { margin: 0 0 .75rem; }
.card > h2 { margin-top: 0; }

.scan-form .row { display: flex; gap: .5rem; margin: .2rem 0 .6rem; }
.scan-form .row input { flex: 1; font-size: 1.2rem; }
#camera-box video { width: 100%; max-height: 50vh; border-radius: 8px; background: #000; margin: .5rem 0; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }

.flash {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: .6rem;
	padding: .65rem .8rem;
	border-radius: 8px;
	margin: .8rem 0;
	transition: opacity .25s ease, transform .25s ease;
}
.flash.ok { background: rgba(5, 150, 105, .12); border: 1px solid var(--pos); }
.flash.error { background: rgba(220, 38, 38, .12); border: 1px solid var(--neg); }
.flash.flash-out { opacity: 0; transform: translateY(-4px); }
.flash-close {
	flex: none;
	background: transparent;
	color: inherit;
	border: 0;
	padding: 0 .15rem;
	font-size: 1.25rem;
	line-height: 1;
	opacity: .6;
	cursor: pointer;
}
.flash-close:hover { opacity: 1; }

.notice {
	padding: .65rem .8rem;
	border-radius: 8px;
	margin: .8rem 0;
	line-height: 1.45;
}
.notice.error { background: rgba(220, 38, 38, .12); border: 1px solid var(--neg); }
.notice.ok { background: rgba(5, 150, 105, .12); border: 1px solid var(--pos); }

.tiles { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tile {
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: .8rem 1rem;
	text-decoration: none;
	color: var(--text);
	display: flex;
	flex-direction: column;
}
.tile strong { font-size: 1.4rem; }
.balance strong { font-size: 1.5rem; }

.table-wrap { overflow-x: auto; background: var(--box); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
th.check, td.check { width: 2rem; text-align: center; vertical-align: middle; }
th.check input, td.check input { transform: scale(1.2); }
tr.empty td, tr.inactive td, li.inactive { color: var(--muted); }
tr.reversed td { text-decoration: line-through; color: var(--muted); }
tr.reversed td:last-child { text-decoration: none; }
tr.type-correction td:nth-child(3) { color: var(--accent); font-weight: 600; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { padding: .3rem 0; border-bottom: 1px solid var(--border); }

/* --- Scanner, bascules, liste de courses (20/11/2026) --- */
.segmented { display: flex; gap: 0; margin: 0 0 .8rem; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.segmented label { flex: 1; margin: 0; text-align: center; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent); color: #fff; font-weight: 600; }
.segmented label { padding: .6rem .4rem; }
.segmented label:has(input[value=count]) { font-size: .95em; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -4px; }
label.switch { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin: 0; cursor: pointer; }
label.switch input { width: auto; transform: scale(1.3); }
label.switch small { flex-basis: 100%; }
#fast.active { border-color: var(--neg); border-width: 2px; }
#fast.active.dir-in { border-color: var(--pos); }
#fast-options { margin-top: .8rem; }
.fast-status { min-height: 1.5em; font-weight: 600; margin: .3rem 0; }
.fast-status.ok { color: var(--pos); }
.fast-status.error { color: var(--neg); }
.mode-form button[type=submit] { width: 100%; font-size: 1.1rem; padding: .75rem; }
.mode-form .cancel { display: block; text-align: center; margin-top: .6rem; }
.scan-form .row button.secondary { flex: 1; }
.badge { display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 1em; background: var(--neg); color: #fff; font-size: .75rem; text-align: center; }
tr.low td:first-child a { color: var(--neg); font-weight: 600; }
td.actions { white-space: nowrap; }
td.actions form { margin-left: .5rem; }
ul.shopping li { display: flex; align-items: center; gap: .6rem; }
ul.shopping li .what { flex: 1; }
ul.shopping li.done .what { text-decoration: line-through; color: var(--muted); }
button.check { width: 1.8rem; height: 1.8rem; padding: 0; background: transparent; border: 2px solid var(--accent); color: var(--accent); border-radius: 6px; }

/* Tickets de caisse */
textarea { display: block; width: 100%; margin-top: .2rem; font: inherit; padding: .5rem; border: 1px solid var(--border, #ccc); border-radius: 6px; background: inherit; color: inherit; box-sizing: border-box; }
.warn { color: #b45309; }
.notice { border-left: 4px solid var(--accent); padding: .4rem .7rem; margin: .5rem 0; }
details.link-box summary { cursor: pointer; color: var(--accent); }
details.link-box form { margin: .5rem 0; min-width: 16rem; }
table.ticket td { vertical-align: top; }
.article-picker { margin: 0 0 .7rem; }
.article-picker input[type=search] { margin-bottom: .3rem; }
.picker-hint { margin: -.4rem 0 .7rem; font-size: .9rem; }

/* Consigne des bouteilles */
.pill { display: inline-block; font-size: .75rem; line-height: 1.4; padding: 0 .45rem; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle; white-space: nowrap; font-weight: 500; }
.pill.deposit { color: #2563eb; }
.grid2.tight { gap: 0 .75rem; }
h1 .pill, h2 .pill { font-size: .8rem; }

/* --- PWA / téléphone ---------------------------------------------------------------------
   viewport-fit=cover : on respecte les bords arrondis et l'encoche (safe-area). */
header.top { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-top: max(.5rem, env(safe-area-inset-top)); }
main { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: max(3rem, calc(env(safe-area-inset-bottom) + 2rem)); }

/* Éléments du menu compact : invisibles sur ordinateur. */
header.top .quick-scan, header.top .current, header.top .menu-toggle { display: none; }

/* Écrans tactiles : 16 px minimum dans les champs, sinon Safari iOS zoome à la saisie. */
@media (pointer: coarse) {
	input, select, textarea { font-size: max(16px, 1em); }
}

/* Menu compact (téléphone) : en-tête fin et collant = marque, raccourci Scanner, page en cours,
   bouton Menu. La liste complète s'ouvre en panneau sous l'en-tête (app.js gère l'ouverture). */
@media (max-width: 720px) {
	header.top.has-menu {
		position: sticky;
		top: 0;
		z-index: 20;
		flex-wrap: nowrap;
		gap: .6rem;
		padding-top: max(.35rem, env(safe-area-inset-top));
		padding-bottom: .35rem;
	}
	header.top.has-menu .brand { flex: none; }
	header.top.has-menu .quick-scan {
		display: inline-block;
		flex: none;
		text-decoration: none;
		font-weight: 600;
		padding: .3rem .7rem;
		border: 1px solid var(--accent);
		border-radius: 999px;
	}
	header.top.has-menu .quick-scan.active { background: var(--accent); color: #fff; }
	header.top.has-menu .current {
		display: block;
		flex: 1;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		color: var(--muted);
		font-size: .9rem;
	}
	header.top.has-menu .menu-toggle {
		display: inline-flex;
		align-items: center;
		gap: .35rem;
		flex: none;
		margin-left: auto;
		min-width: 44px;
		min-height: 40px;
		justify-content: center;
		padding: .4rem .6rem;
		background: transparent;
		border: 1px solid var(--border);
		color: var(--text);
	}
	.burger, .burger::before, .burger::after {
		display: block;
		width: 18px;
		height: 2px;
		background: currentColor;
		border-radius: 1px;
		position: relative;
		transition: transform .2s, background-color .2s;
	}
	.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
	.burger::before { top: -6px; }
	.burger::after { top: 6px; }
	header.top.open .burger { background: transparent; }
	header.top.open .burger::before { transform: translateY(6px) rotate(45deg); }
	header.top.open .burger::after { transform: translateY(-6px) rotate(-45deg); }

	header.top.has-menu nav {
		display: none;
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		background: var(--box);
		border-bottom: 1px solid var(--border);
		box-shadow: 0 8px 16px rgba(0, 0, 0, .15);
		padding: .6rem max(1rem, env(safe-area-inset-right)) .9rem max(1rem, env(safe-area-inset-left));
		max-height: calc(100vh - 4rem);
		overflow-y: auto;
	}
	header.top.open nav { display: flex; flex-direction: column; gap: .65rem; }
	header.top.has-menu nav .nav-group {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: .35rem;
		width: 100%;
		padding-right: 0;
		border-right: 0;
	}
	header.top.has-menu nav .nav-group-label {
		display: block;
		grid-column: 1 / -1;
		padding: .15rem .1rem 0;
	}
	header.top.has-menu nav a {
		padding: .7rem .5rem;
		border: 1px solid var(--border);
		border-radius: 8px;
		text-align: center;
		min-height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: .25rem;
	}
	header.top.has-menu nav a.active { border: 1px solid var(--accent); background: rgba(13, 148, 136, .12); }
	header.top.has-menu nav .nav-logout {
		width: 100%;
		text-align: center;
		padding-top: .2rem;
		margin: 0;
	}
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
	.burger, .burger::before, .burger::after { transition: none; }
}
form.sending button[type=submit] { opacity: .6; cursor: progress; } /* anti double envoi (app.js) */

/* Carte : produits par catégorie, pleine largeur ; colonnes ajoutées s'il y a un scroll vertical. */
.carte { --carte-scale: 1; --carte-img: 1; }
.carte.hide-images .carte-row .who .thumb { display: none; }
.carte-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .75rem;
	margin: .2rem 0 1rem;
	flex-wrap: wrap;
}
.carte-head h1 { margin: 0; font-size: calc(1.4rem * var(--carte-scale)); margin-right: auto; }
.carte-menu { position: relative; }
.carte-menu > summary {
	list-style: none;
	cursor: pointer;
	user-select: none;
	font-size: .85rem;
	font-weight: 600;
	color: var(--muted);
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: .35rem .7rem;
}
.carte-menu > summary::-webkit-details-marker { display: none; }
.carte-menu[open] > summary { color: var(--text); border-color: var(--accent); }
.carte-menu-panel {
	position: absolute;
	right: 0;
	top: calc(100% + .35rem);
	z-index: 15;
	min-width: 15rem;
	display: flex;
	flex-direction: column;
	gap: .75rem;
	padding: .85rem;
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: 0 10px 24px rgba(0, 0, 0, .12);
}
.carte-menu-panel > label { margin: 0; }
.carte-size { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.carte-size span { color: var(--muted); font-size: .9rem; margin-right: .15rem; }
.carte-size button { min-width: 2.4rem; padding: .35rem .5rem; }

.carte-balance {
	display: flex;
	align-items: baseline;
	gap: .45rem;
	text-decoration: none;
	color: var(--text);
}
.carte-balance span { color: var(--muted); font-size: .9rem; }
.carte-balance strong { font-size: calc(1.45rem * var(--carte-scale)); font-variant-numeric: tabular-nums; }

.carte-board {
	--carte-col-max: calc(22rem * var(--carte-scale)); /* plafond d'une colonne de produits */
	display: flex;
	flex-wrap: wrap;
	gap: .8rem;
	align-items: start;
	justify-content: center;
	font-size: calc(1rem * var(--carte-scale));
}
.carte-cat {
	--product-cols: 1;
	width: min(100%, calc(var(--product-cols) * var(--carte-col-max) + (var(--product-cols) - 1) * .6rem));
	flex: 0 1 auto;
	margin: 0;
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 12px;
	overflow: hidden;
}
.carte-cat:nth-child(4n+1) { --cat: #0d9488; }
.carte-cat:nth-child(4n+2) { --cat: #2563eb; }
.carte-cat:nth-child(4n+3) { --cat: #d97706; }
.carte-cat:nth-child(4n) { --cat: #7c3aed; }
.carte-cat h2 {
	margin: 0;
	padding: .65em .8em .55em;
	border-top: 3px solid var(--cat, var(--accent));
	border-bottom: 1px solid var(--border);
	background: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--box));
	display: flex;
	flex-direction: column;
	gap: .2em;
	font-size: 1em; /* suit --carte-scale via .carte-board (sinon h2 reste en rem fixe) */
}
.carte-cat h2 .name { font-size: 1.05em; font-weight: 700; }
.carte-cat h2 .stats {
	display: flex;
	flex-wrap: wrap;
	gap: .15rem .85rem;
	font-size: .82em;
	font-weight: 600;
	color: var(--text);
}
.carte-cat h2 .k {
	font-weight: 600;
	font-size: .72em;
	letter-spacing: .02em;
	text-transform: uppercase;
	color: var(--muted);
	margin-right: .25rem;
}
.carte-cols {
	display: none;
	grid-template-columns: minmax(0, 1fr) auto auto;
	gap: .35em .6em;
	padding: .35em .75em;
	font-size: .72em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--muted);
	border-bottom: 1px solid var(--border);
}
.carte-cat[data-product-cols="1"] .carte-cols { display: grid; }
.carte-cols .num { text-align: right; }
.carte-products {
	column-count: var(--product-cols);
	column-gap: .6rem;
	padding: .15rem .35rem .35rem;
}
.carte-row {
	break-inside: avoid;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	gap: .35em .6em;
	align-items: baseline;
	padding: .38em .4em;
	border-bottom: 1px solid var(--border);
}
.carte-products .carte-row:last-child { border-bottom: 0; }
.carte-row .who {
	display: flex;
	align-items: center;
	gap: .45em;
	color: inherit;
	text-decoration: none;
	font-weight: 600;
	min-width: 0;
}
.carte-row .who .label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.carte-row .who .thumb {
	flex: none;
	width: calc(1.7em * var(--carte-img));
	height: calc(2.15em * var(--carte-img));
	object-fit: contain;
	object-position: center bottom;
}
.carte-row.low .who { color: inherit; }
.carte-row .who:hover { color: var(--accent); }
.carte-row .price {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	text-align: right;
}
.carte-row .qty {
	display: inline-block;
	min-width: 1.7em;
	padding: .05em .4em;
	border-radius: 999px;
	text-align: center;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	background: color-mix(in srgb, var(--pos) 16%, var(--box));
	color: var(--pos);
	justify-self: end;
}
.product-photo {
	display: block;
	width: 7.5rem;
	height: auto;
	max-height: 10rem;
	object-fit: contain;
	object-position: center bottom;
	background: transparent;
}
.carte-row.empty { color: var(--muted); }
.carte-row.empty .qty { background: var(--bg); color: var(--muted); font-weight: 600; }
.carte-row.low .qty { background: color-mix(in srgb, var(--neg) 16%, var(--box)); color: var(--neg); }

/* --- Connexion / invitation / reset --- */
body.auth-page {
	min-height: 100vh;
	background:
		radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
		linear-gradient(165deg, var(--bg) 0%, color-mix(in srgb, var(--accent) 6%, var(--bg)) 100%);
}
main.auth-main {
	max-width: 440px;
	padding-top: 2.5rem;
}
.auth-card {
	background: var(--box);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 1.5rem 1.35rem 1.35rem;
	box-shadow: 0 12px 40px color-mix(in srgb, var(--text) 6%, transparent);
}
.auth-brand { margin-bottom: 1.1rem; }
.auth-eyebrow {
	margin: 0 0 .35rem;
	font-size: .75rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--accent);
}
.auth-brand h1 {
	margin: 0 0 .4rem;
	font-size: 1.75rem;
	letter-spacing: -.02em;
}
.auth-lede {
	margin: 0;
	color: var(--muted);
	font-size: .95rem;
}
.auth-form button { width: 100%; margin-top: .35rem; padding: .7rem .8rem; }
.auth-form small { display: block; margin-top: .25rem; color: var(--muted); font-size: .85rem; }
.auth-links {
	margin: 1rem 0 0;
	text-align: center;
	font-size: .95rem;
}
.auth-links a { text-decoration: none; font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form.inline { margin-left: .5rem; }

