:root {
  --accent: #E0265A;
  --night: #7A1238;
  --dot: #FFC9B9;
  --rose: #E04A78;
  --bg: #FBF1EE;
  --card: #FFFFFF;
  --soft: #FDEDEA;
  --brown: #5B2E2E;
  --brown-soft: #8C6D6E;
  --line: #F2D5D9;
  --danger: #D93025;
  --success: #2E9D5B;
  --warn: #E08A00;
  --blue: #2F6FDE;
  --radius: 20px;
  --shadow: 0 3px 10px rgba(122, 18, 56, 0.07);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--brown); }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--accent); }

/* ---------- Structure ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--night), var(--accent));
  color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
.wordmark { font-weight: 900; letter-spacing: -0.02em; line-height: 1; }
.wordmark .dot { color: var(--dot); }
.header .wordmark { font-size: 30px; }
.header .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; }
.header .icon-btn { color: #fff; }
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 14px calc(110px + env(safe-area-inset-bottom)); }
.main.wide { max-width: 1200px; }

.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; gap: 2px; padding: 6px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(16px);
  border-radius: 999px; box-shadow: 0 6px 24px rgba(91, 46, 46, .16); width: min(560px, calc(100% - 20px));
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--brown); position: relative; }
.tab .ico { font-size: 20px; line-height: 1; }
.tab.on { background: var(--soft); color: var(--accent); }
.badge { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #FF3B30; color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }

/* ---------- Titres ---------- */
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 14px; }
.page-title h1 { margin: 0; font-size: 28px; font-weight: 900; }
.page-title .sub { color: var(--brown-soft); font-weight: 600; margin-top: 2px; }
.section-title { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 16px; margin: 0 0 12px; }
.section-title .ico { color: var(--accent); }
h2.group { font-size: 19px; font-weight: 900; margin: 22px 2px 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.top { align-items: flex-start; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--brown-soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 800; }
.heavy { font-weight: 900; }
.accent { color: var(--accent); }
.danger { color: var(--danger); }
.success { color: var(--success); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cards-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 900px) { .cards-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Champs ---------- */
label.lbl { display: block; font-size: 13px; font-weight: 700; color: rgba(91, 46, 46, .85); margin: 0 0 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px; border-radius: 14px; border: 1px solid rgba(91, 46, 46, .08); background: var(--soft); outline: none;
}
.input:focus { border-color: var(--accent); background: #fff; }
textarea.input { resize: vertical; min-height: 64px; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 16px; font-weight: 800; font-size: 16px; background: var(--accent); color: #fff; width: 100%; }
.btn:active { transform: scale(.98); }
.btn.brown { background: var(--brown); }
.btn.blue { background: var(--blue); }
.btn.white { background: #fff; color: var(--accent); }
.btn.ghost { background: var(--soft); color: var(--brown); }
.btn.auto { width: auto; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; background: var(--soft); font-weight: 800; font-size: 14px; color: var(--brown); }
.link { color: var(--accent); font-weight: 800; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: rgba(224, 38, 90, .12); color: var(--accent); white-space: nowrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chip { padding: 8px 14px; border-radius: 999px; background: #fff; font-weight: 800; box-shadow: 0 1px 3px rgba(122, 18, 56, .06); white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; }

.segmented { display: flex; padding: 4px; border-radius: 14px; background: var(--soft); }
.segmented button { flex: 1; padding: 9px 6px; border-radius: 11px; font-weight: 800; color: var(--brown); }
.segmented button.on { background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.segmented.lead button.on.instagram { background: #E1306C; color: #fff; }
.segmented.lead button.on.snapchat { background: #FFFC00; color: #000; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #E3D6D6; border-radius: 30px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::before { transform: translateX(20px); }

.amount { display: flex; justify-content: space-between; font-weight: 700; }
.amount.big { font-weight: 900; font-size: 17px; }

.stepper { display: inline-flex; align-items: center; background: var(--soft); border-radius: 999px; }
.stepper button { width: 40px; height: 36px; font-size: 18px; font-weight: 800; }
.stepper span { min-width: 40px; text-align: center; font-weight: 900; }

.banner { border-radius: 16px; padding: 14px; background: rgba(224, 138, 0, .12); border: 1px solid rgba(224, 138, 0, .35); margin-bottom: 14px; font-weight: 700; }
.banner.ok { background: rgba(46, 157, 91, .12); border-color: rgba(46, 157, 91, .35); }

.empty { text-align: center; padding: 30px 10px; }
.empty .big { font-size: 38px; }
.empty .t { font-weight: 900; font-size: 17px; margin-top: 6px; }

/* ---------- Articles ---------- */
.item-row { background: var(--soft); border-radius: 16px; padding: 12px; }
.item-title { font-weight: 900; }
.item-detail { font-size: 13px; color: rgba(91, 46, 46, .75); font-weight: 600; }
.option-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.option { padding: 9px 12px; border-radius: 999px; background: var(--soft); font-weight: 800; font-size: 14px; color: var(--brown); }
.option.on { background: var(--accent); color: #fff; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.product { position: relative; text-align: left; background: #fff; border-radius: 16px; padding: 12px; min-height: 110px; box-shadow: 0 2px 6px rgba(122, 18, 56, .06); display: flex; flex-direction: column; gap: 6px; }
.product .price { margin-top: auto; color: var(--accent); font-weight: 900; }
.product.out { opacity: .45; filter: grayscale(1); }
.product .more { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--soft); font-weight: 900; }

/* ---------- Cuisine ---------- */
.kpi { border-radius: 16px; padding: 12px 6px; text-align: center; font-weight: 700; font-size: 12px; background: var(--accent); color: #fff; }
.kpi.light { background: #F1ECEC; color: var(--brown); }
.kpi b { display: block; font-size: 28px; font-weight: 900; }
.check-row { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 10px; border-radius: 12px; background: rgba(224, 38, 90, .07); }
.check-row.done { background: transparent; }
.check-row.done .what { opacity: .45; }
.check-row.done .item-title { text-decoration: line-through; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--brown-soft); flex: none; display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 900; }
.check-row.done .check { background: var(--success); border-color: var(--success); }
.qty { font-weight: 900; font-size: 18px; color: var(--brown-soft); }
.qty.multi { color: var(--accent); }
.note { background: #FFF1C2; border-radius: 12px; padding: 10px; font-weight: 700; }

/* ---------- Historique ---------- */
.year-head { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 10px 4px; }
.year-head .y { font-size: 26px; font-weight: 900; }
.day-head { display: flex; justify-content: space-between; font-weight: 900; color: var(--accent); padding: 10px 14px; background: var(--soft); border-radius: 14px; margin: 8px 0; }
.timeline { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--soft); border-radius: 12px; padding: 8px; text-align: center; }
.timeline .l { font-size: 11px; font-weight: 700; color: var(--brown-soft); }
.timeline .v { font-weight: 900; }
.cancelled { opacity: .5; filter: grayscale(1); }

/* ---------- Tournée ---------- */
#map { height: 42dvh; min-height: 240px; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 14px; z-index: 1; }
.map-wrap { position: relative; }
.map-tools { position: absolute; right: 10px; bottom: 24px; z-index: 5; display: flex; flex-direction: column; gap: 8px; }
.map-tools button { width: 42px; height: 42px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); font-size: 18px; }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 14px; flex: none; }
.num.sel { background: var(--brown); }
.pin { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 900; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.pin.sel { background: var(--brown); transform: scale(1.2); }
.pin.start { background: var(--brown); }

/* ---------- Stats ---------- */
.tile { display: flex; gap: 10px; align-items: center; background: var(--soft); border-radius: 14px; padding: 10px; min-height: 64px; }
.tile .ic { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--rose)); color: #fff; display: grid; place-items: center; flex: none; }
.tile .v { font-weight: 900; font-size: 15px; }
.arrow { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 18px; font-weight: 900; }
.arrow:disabled { background: var(--soft); color: var(--brown-soft); opacity: 1; }
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.sel { fill: var(--brown); }
.chart text { font-size: 10px; fill: var(--brown-soft); font-family: inherit; }

/* ---------- Modales & barres ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(40, 10, 20, .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 760px; max-height: 94dvh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .25s ease-out; }
@media (min-width: 800px) { .overlay { align-items: center; } .sheet { border-radius: 22px; max-height: 88dvh; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { margin: 0; flex: 1; text-align: center; font-size: 17px; font-weight: 900; }
.sheet-body { overflow-y: auto; padding: 16px; flex: 1; }
.sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .9); }
.footer-bar { position: fixed; left: 0; right: 0; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 25; display: flex; justify-content: center; padding: 0 10px; }
.footer-bar > div { width: min(740px, 100%); display: flex; gap: 12px; align-items: center; background: rgba(255, 255, 255, .95); backdrop-filter: blur(14px); border-radius: 20px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(91, 46, 46, .16); }
.total-big { font-size: 22px; font-weight: 900; }

.toast { position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60; background: rgba(0, 0, 0, .78); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 800; }
.error-banner { position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 60; background: var(--danger); color: #fff; border-radius: 14px; padding: 12px; display: flex; gap: 10px; align-items: flex-start; font-weight: 700; max-width: 740px; margin: 0 auto; user-select: text; }
.undo { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 40; background: var(--brown); color: #fff; padding: 12px 16px; border-radius: 999px; display: flex; gap: 14px; align-items: center; font-weight: 700; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); width: min(520px, calc(100% - 32px)); }
.undo button { color: var(--dot); font-weight: 900; margin-left: auto; }

/* ---------- Démarrage ---------- */
.splash, .gate { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: linear-gradient(135deg, var(--night), var(--accent)); color: #fff; padding: 28px; text-align: center; }
.splash .wordmark { font-size: 64px; animation: pulse 1.6s ease-in-out infinite; }
.gate .wordmark { font-size: 56px; }
.gate .box { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; }
.gate input { text-align: center; font-size: 22px; font-weight: 900; padding: 14px; border-radius: 16px; border: 0; color: var(--brown); text-transform: uppercase; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(224, 38, 90, .2); border-top-color: var(--accent); width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
