:root {
  --bg: #EFEAE2; --header: #0B1B2B; --accent: #F5B700; --accent-dark: #C99600;
  --mine: #DCF8C6; --card: #fff; --text: #111B21; --muted: #667781; --border: #E3E3E3;
  --danger: #D93025; --success: #1E8E3E; --waze: #0A6E91; --waze-bg: #E8F7FD;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--header); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: #027EB5; text-decoration: none; font-weight: 600; }
.hidden { display: none !important; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; background: var(--bg); }
header.top { background: var(--header); color: #fff; padding: calc(12px + var(--safe-top)) 16px 12px; display: flex; align-items: center; gap: 10px; }
header.top h1 { font-size: 19px; margin: 0; font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .back { color: #fff; font-size: 22px; padding: 0 6px 0 0; }
.conn { font-size: 12px; color: #C9D3DC; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.dot.on { background: #3DDC84; }
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
nav.tabs { display: flex; background: #fff; border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom); }
nav.tabs a { flex: 1; text-align: center; padding: 8px 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
nav.tabs a .ic { display: block; font-size: 20px; opacity: .55; }
nav.tabs a.on { color: var(--header); }
nav.tabs a.on .ic { opacity: 1; }
nav.tabs .badge { position: absolute; top: 3px; left: 54%; background: var(--accent); color: var(--header); border-radius: 9px; font-size: 11px; padding: 0 6px; font-weight: 800; }

/* Barre de filtres */
.bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: #F7F5F2; border-bottom: 1px solid var(--border); flex-wrap: wrap; position: sticky; top: 0; z-index: 2; }
.chip { padding: 6px 12px; border-radius: 16px; background: #fff; border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.chip.on { background: var(--header); border-color: var(--header); color: #fff; }
.chip.y { background: #FFF4CC; border-color: #FFF4CC; color: #7A5B00; }

/* Fil façon WhatsApp */
.feed { display: flex; flex-direction: column-reverse; padding: 8px 0 90px; min-height: 100%; }
.row { padding: 0 10px; margin: 4px 0; display: flex; }
.row.mine { justify-content: flex-end; }
.bubble { width: 88%; background: var(--card); border-radius: 12px; padding: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.row.mine .bubble { background: var(--mine); }
.bubble.closed { opacity: .6; }
.bubble.plain { width: 100%; }
.author { color: var(--accent-dark); font-weight: 700; margin-bottom: 4px; }
.place { font-weight: 600; font-size: 16px; }
.arrow { color: var(--muted); margin: 1px 0 1px 6px; }
.meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.price { font-weight: 800; font-size: 17px; color: var(--header); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #F0F2F5; }
.st-open { background: #FFF4CC; color: #7A5B00; } .st-taken { background: #E1E6EA; color: #3B4A54; }
.st-done { background: #D9F2E0; color: var(--success); } .st-cancelled { background: #FCE3E1; color: var(--danger); }
.notes { margin-top: 6px; font-style: italic; }
.client { margin-top: 8px; padding: 8px; border-radius: 8px; background: rgba(11,27,43,.06); }
.client small { color: var(--muted); text-transform: uppercase; font-weight: 700; font-size: 11px; display: block; }
.taken { margin-top: 8px; color: var(--muted); font-weight: 600; }
.waze-row { display: flex; gap: 8px; margin-top: 8px; }
.waze { flex: 1; text-align: center; background: var(--waze-bg); border: 1px solid #BDE8F8; color: var(--waze); border-radius: 16px; padding: 7px 4px; font-size: 13px; font-weight: 700; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn { background: var(--accent); color: var(--header); font-weight: 800; border-radius: 22px; padding: 10px 16px; text-align: center; }
.btn.block { display: block; width: 100%; border-radius: 12px; padding: 14px; font-size: 16px; }
.btn.grow { flex: 1; }
.btn.ok { background: var(--success); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.time { text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; }
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(66px + var(--safe-bottom)); width: min(620px, calc(100% - 20px)); z-index: 5; box-shadow: 0 3px 10px rgba(0,0,0,.18); border-radius: 26px; padding: 15px; }
.empty { text-align: center; color: var(--muted); padding: 40px 30px; }

/* Formulaires */
.pad { padding: 14px; }
.card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 10px; }
label.l { display: block; font-weight: 700; margin: 10px 0 6px; }
.input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 16px; background: #fff; margin-bottom: 8px; }
textarea.input { min-height: 70px; resize: vertical; }
.two { display: flex; gap: 10px; } .two > * { flex: 1; }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent-dark); }
.hint { font-size: 12px; color: var(--muted); }
.ac { position: relative; }
.ac .pin { position: absolute; right: 12px; top: 12px; }
.ac-list { border: 1px solid var(--border); border-radius: 10px; background: #fff; margin: -4px 0 8px; overflow: hidden; }
.ac-list button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ac-list button small { display: block; color: var(--muted); font-size: 12px; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px; background: var(--header); }
.logo { font-size: 42px; font-weight: 900; color: var(--accent); text-align: center; }
.subtitle { color: #C9D3DC; text-align: center; margin: 4px 0 24px; }

/* Restos */
.resto { display: flex; gap: 12px; background: #fff; border-radius: 12px; padding: 10px; margin: 0 10px 10px; }
.thumb { width: 92px; height: 92px; border-radius: 10px; object-fit: cover; background: #FFF4CC; display: flex; align-items: center; justify-content: center; font-size: 30px; flex-shrink: 0; }
.resto h3 { margin: 0; font-size: 16px; font-weight: 800; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stars { color: #D0D5D9; letter-spacing: 1px; white-space: nowrap; }
.stars .on { color: #F5B700; }
.stars.input-stars button { font-size: 34px; padding: 0 3px; color: #D0D5D9; }
.stars.input-stars button.on { color: #F5B700; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: #000; }
.gallery img { width: 100%; flex-shrink: 0; aspect-ratio: 3/2; object-fit: cover; scroll-snap-align: start; }
.nophoto { height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #FFF4CC; font-size: 50px; }
.review { padding: 10px 0; border-bottom: 1px solid var(--border); }
.section-t { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 12px; margin: 14px 4px 8px; }

/* Modal + toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(20px + var(--safe-bottom)); }
.sheet h2 { margin: 0 0 6px; font-size: 19px; display: flex; justify-content: space-between; }
.sheet h2 button { font-size: 22px; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: calc(140px + var(--safe-bottom)); transform: translateX(-50%); background: var(--header); color: #fff; padding: 10px 16px; border-radius: 20px; font-weight: 600; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }
.banner { margin: 10px; padding: 12px; border-radius: 12px; background: #FFF4CC; color: #5c4500; font-size: 14px; }
.banner .btn { margin-top: 8px; display: inline-block; }

/* Transferts + historique */
.bubble.offered { outline: 2px solid var(--accent); }
.offer-box { margin-top: 10px; padding: 10px; border-radius: 10px; background: #FFF4CC; border: 1px solid var(--accent); color: #5C4500; }
.pending-box { margin-top: 10px; padding: 10px; border-radius: 10px; background: #F0F2F5; font-size: 14px; }
.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; }
.foot .time { margin: 0; }
.drv { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 16px; color: var(--muted); }
.drv b { color: var(--text); }
.av { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--header); font-weight: 900; display: flex; align-items: center; justify-content: center; }
.timeline { padding: 6px 0; }
.tl { display: flex; gap: 12px; padding: 0 0 16px; position: relative; }
.tl::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.tl:last-child::before { display: none; }
.tl-ic { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }

/* Catégories, client, bon de transport */
.tag.cat { background: #EEF2FF; color: #3730A3; }
.tag.cat-secu { background: #E0F2FE; color: #075985; font-weight: 700; }
.tag.cat-pay { background: #F3E8FF; color: #6B21A8; font-weight: 700; }
.segc { display: flex; background: #F0F2F5; border-radius: 10px; padding: 3px; }
.segc button { flex: 1; padding: 10px 4px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.segc button.on { background: var(--header); color: #fff; }
.dropbox { display: block; width: 100%; margin-top: 8px; padding: 14px; border: 1.5px dashed var(--muted); border-radius: 12px; text-align: center; font-weight: 800; color: var(--header); cursor: pointer; background: #fff; }
.dropbox.drag { background: #FFF4CC; border-color: var(--accent); }
.client-pick { display: flex; align-items: center; gap: 10px; border: 1px solid var(--accent); background: #FFFBEA; border-radius: 12px; padding: 12px; }
.cp-row { display: block; width: 100%; text-align: left; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.cp-row small { display: block; color: var(--muted); }
.cp-dup { padding: 8px 0; border-top: 1px solid var(--border); }
.cp-dup .btn { margin-top: 6px; padding: 6px 12px; font-size: 13px; }
.warn { margin: 6px 0 10px; padding: 10px; border-radius: 10px; background: #FFF4CC; border: 1px solid var(--accent); }
.warn-t { color: #9A3412; font-weight: 700; margin-bottom: 4px; }
.block-sm { display: block; width: 100%; margin-top: 8px; padding: 9px; }
.tag.grp { background: #E8F5E9; color: #1B5E20; font-weight: 700; }
.chip input { accent-color: var(--accent-dark); }

/* Avatars, stats */
.av.sm { width: 22px; height: 22px; font-size: 12px; vertical-align: -5px; margin-right: 2px; }
.av.xl { width: 72px; height: 72px; font-size: 36px; }
.av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.av { overflow: hidden; }
.av-edit { position: absolute; right: -2px; bottom: -2px; background: #fff; border-radius: 50%; font-size: 13px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.author { display: flex; align-items: center; gap: 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
.emoji-grid button { font-size: 28px; padding: 8px 0; border-radius: 10px; background: #F0F2F5; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #F7F5F2; border-radius: 10px; padding: 10px; }
.stat .sv { font-size: 20px; font-weight: 800; color: var(--header); }
.stat .sk { font-size: 12px; color: var(--muted); }
.ch-grid { stroke: #ECEAE5; stroke-width: 1; }
.ch-axis { fill: var(--muted); font-size: 10px; }
.ch-bar { fill: #1F4E79; }
.ch-hit { fill: transparent; }
.ch-hit.on { fill: rgba(11, 27, 43, .05); }
.tip { position: fixed; z-index: 50; background: var(--header); color: #fff; padding: 6px 9px; border-radius: 8px; font-size: 12px; pointer-events: none; white-space: nowrap; }

/* Conventionnement & inscription */
.convline { display: flex; gap: 10px; align-items: center; margin: 14px 0 4px; cursor: pointer; }
.convline input { width: 22px; height: 22px; accent-color: var(--accent-dark); flex-shrink: 0; }
.login .btn.ghost#backLogin { margin-top: 12px; background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

.locked { display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px; border-radius: 12px; background: #F0F2F5; color: var(--muted); font-weight: 700; font-size: 14px; }
.share-txt { white-space: pre-wrap; background: #F7F7F5; border-radius: 10px; padding: 10px; font: 14px/1.4 inherit; font-family: inherit; }

/* Enchaînements */
.bundle-card { background: #FFF8E1; border: 2px solid var(--accent); border-radius: 14px; padding: 10px; max-width: 92%; width: 100%; }
.row.mine .bundle-card { background: #F1FBEA; }
.bundle-h { padding: 2px 4px 8px; }
.bundle-card .leg { position: relative; margin-bottom: 8px; }
.bundle-card .leg .row { padding: 0; }
.bundle-card .leg .bubble { max-width: 100%; }
.leg-n { position: absolute; z-index: 1; left: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--header); color: var(--accent); font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.tag.bundle-t { background: #FFF4CC; color: #7A5B00; font-weight: 700; }
.pick-line { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; }
.pick-line input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent-dark); }

/* Planning */
.plan-nav { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; }
.plan-nav b { flex: 1; text-align: center; text-transform: capitalize; }
.plan-sum { display: flex; gap: 8px; padding: 0 12px 8px; overflow-x: auto; }
.plan-sum > div { background: #fff; border-radius: 12px; padding: 8px 12px; min-width: 80px; }
.plan-sum b { display: block; font-size: 18px; }
.plan-sum span { color: var(--muted); font-size: 12px; }
.plan-day { background: #fff; border-radius: 12px; margin: 0 12px 8px; padding: 6px 8px; }
.plan-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.plan-dh { display: flex; justify-content: space-between; width: 100%; padding: 6px 4px; text-transform: capitalize; }
.plan-dh span { color: var(--muted); font-size: 13px; text-transform: none; }
.plan-it { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px 4px; border-top: 1px solid var(--border); }
.plan-it .pt { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 44px; }
.plan-it .pc { flex: 1; min-width: 0; font-size: 14px; }
.plan-it .pc small { display: block; color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 0 12px 10px; }
.cal-h { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.cal-d { aspect-ratio: 1; background: #fff; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 14px; }
.cal-d.out { opacity: .35; }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-d b { background: var(--header); color: var(--accent); border-radius: 9px; font-size: 11px; padding: 0 6px; }
.plan-nav b, .plan-dh b { text-transform: none; }
.plan-nav b::first-letter, .plan-dh b::first-letter { text-transform: uppercase; }
