/* ==========================================================
   MON CHANTIER — styles
   Béton clair + jaune chantier, tampons rouge / vert
   ========================================================== */
:root {
  --bg: #EEEBE4;
  --surface: #FFFFFF;
  --surface-2: #F6F4EF;
  --ink: #16181B;
  --ink-2: #474C54;
  --muted: #80858D;
  --line: #E1DCD2;
  --accent: #FFC21A;
  --accent-deep: #F2A900;
  --accent-ink: #1A1400;
  --red: #D42A3C;
  --red-bg: #FCE7E9;
  --green: #12864A;
  --green-bg: #E1F3E8;
  --blue: #2356D1;
  --blue-bg: #E6EDFC;
  --amber: #A86A00;
  --amber-bg: #FFF1CC;
  --grey: #686D75;
  --grey-bg: #EAE7E1;
  --r: 20px;
  --r-sm: 12px;
  --shadow: 0 1px 0 rgba(22, 24, 27, .04), 0 10px 28px -16px rgba(22, 24, 27, .32);
  --font-d: 'Bricolage Grotesque', system-ui, sans-serif;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --hazard: repeating-linear-gradient(-45deg, var(--accent) 0 12px, #16181B 12px 24px);
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1012;
    --surface: #171A1D;
    --surface-2: #1F2327;
    --ink: #F2F0EB;
    --ink-2: #C3C7CD;
    --muted: #868C94;
    --line: #2A2F35;
    --red: #FF5D6E;
    --red-bg: #3A171D;
    --green: #3CD487;
    --green-bg: #112E1E;
    --blue: #7DA4FF;
    --blue-bg: #172648;
    --amber: #FFC65E;
    --amber-bg: #392B0C;
    --grey: #A2A7AF;
    --grey-bg: #25292E;
    --shadow: 0 1px 0 rgba(0, 0, 0, .5), 0 10px 28px -16px rgba(0, 0, 0, .9);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.noscroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-d); margin: 0; letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.ic { width: 20px; height: 20px; flex: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.txt-red { color: var(--red) !important; }
.txt-green { color: var(--green) !important; }
.pad { padding: 8px 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Structure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--hazard); opacity: .9; }
.topbar-title { flex: 1; font: 700 16px/1.2 var(--font-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 32px; height: 32px; color: var(--muted); }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.round { border-radius: 50%; background: var(--surface-2); }
.icon-btn.wa { background: #25D366; color: #fff; }
.main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.bottomnav a { display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.bottomnav a .ic { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--ink); }
.bottomnav a.active .ic { color: var(--ink); stroke-width: 2.4; }
.bottomnav a.active span { box-shadow: inset 0 -3px 0 var(--accent); }
.fab {
  justify-self: center; width: 60px; height: 60px; margin-top: -26px;
  border: 0; border-radius: 20px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  box-shadow: 0 0 0 5px var(--bg), 0 12px 24px -8px rgba(242, 169, 0, .7);
  transition: transform .15s;
}
.fab .ic { width: 28px; height: 28px; stroke-width: 2.6; }
.fab:active { transform: scale(.94) rotate(90deg); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 14px;
  border: 1.5px solid transparent; font-weight: 650; font-size: 15px; line-height: 1.1;
  background: var(--surface-2); color: var(--ink); white-space: nowrap;
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn .ic { width: 18px; height: 18px; }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 14px; border-radius: 11px; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-dashed { background: transparent; border: 2px dashed var(--line); color: var(--ink-2); margin-top: 12px; }
.btn-danger-ghost { background: var(--red-bg); color: var(--red); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }
label.btn { cursor: pointer; }

/* ---------- Titres de section ---------- */
.sec { display: flex; align-items: center; gap: 8px; font-size: 17px; margin: 26px 2px 10px; }
.sec .ic { width: 18px; height: 18px; color: var(--amber); }
.sub { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin: 18px 2px 8px; color: var(--ink-2); }
.count { font: 700 12px/1 var(--mono); background: var(--ink); color: var(--bg); padding: 4px 7px; border-radius: 99px; }
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec-row .sec { margin-bottom: 10px; }
.eyebrow { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 10px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.timeline, .rlist, .checklist { grid-template-columns: minmax(0, 1fr); }
.stack.tight { gap: 8px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.actions-row.end { justify-content: flex-end; margin-top: 24px; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { font-size: 17px; }
.btns { display: flex; gap: 6px; }

.hello { margin: 6px 2px 14px; }
.hello h1 { font-size: 30px; }

.hero {
  position: relative; display: grid; gap: 4px; overflow: hidden;
  padding: 20px 20px 18px; border-radius: 24px; color: #fff;
  background: var(--red); box-shadow: var(--shadow); isolation: isolate;
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .16;
  background: repeating-linear-gradient(-45deg, #fff 0 2px, transparent 2px 14px);
  mask: linear-gradient(110deg, transparent 45%, #000);
  -webkit-mask: linear-gradient(110deg, transparent 45%, #000);
}
.hero.is-red { background: linear-gradient(135deg, #E23447, #B0182B); }
.hero.is-green { background: linear-gradient(135deg, #17A35A, #0D6F3C); }
.hero-label { font-weight: 650; opacity: .92; }
.hero-num { font-size: clamp(36px, 11vw, 52px); font-weight: 700; line-height: 1.05; letter-spacing: -.04em; }
.hero-sub { display: flex; align-items: center; gap: 4px; font-size: 13px; opacity: .9; }
.hero-sub .ic { width: 16px; height: 16px; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kpis.two { grid-template-columns: 1fr 1fr; }
.kpi { display: grid; gap: 4px; align-content: start; background: var(--surface); padding: 12px; border-radius: 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi span { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.2; }
.kpi b { font: 700 17px/1.1 var(--mono); letter-spacing: -.03em; overflow-wrap: anywhere; }
.kpi.big b { font-size: 22px; }
.kpi.is-red { background: var(--red-bg); } .kpi.is-red b { color: var(--red); }
.kpi.is-green { background: var(--green-bg); } .kpi.is-green b { color: var(--green); }
.kpi.is-amber { background: var(--amber-bg); } .kpi.is-amber b { color: var(--amber); }

/* Anneau d’avancement */
.ring {
  --size: 64px;
  width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background:
    radial-gradient(circle, var(--surface) 0 calc(var(--size) / 2 - 8px), transparent calc(var(--size) / 2 - 7px)),
    conic-gradient(var(--accent-deep) calc(var(--p) * 1%), var(--grey-bg) 0);
}
.ring span { position: absolute; font: 700 16px/1 var(--font-d); }
.ring small { font-size: 10px; margin-left: 1px; }
.ring.lg { --size: 84px; }
.ring.lg span { font-size: 22px; }

/* Bande "ADN" des phases */
.strip { display: flex; gap: 3px; height: 8px; margin-top: 14px; }
.strip.big { height: 12px; }
.strip i { flex: 1; border-radius: 4px; background: linear-gradient(90deg, var(--c) var(--f), var(--grey-bg) var(--f)); }
.s-grey { --c: #9AA0A8; } .s-blue { --c: var(--blue); } .s-red { --c: var(--red); } .s-amber { --c: var(--accent-deep); } .s-green { --c: var(--green); }

/* Carte chantier */
.ccard { display: block; background: var(--surface); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); transition: transform .12s; }
.ccard:active { transform: scale(.99); }
.ccard-top { display: flex; gap: 14px; align-items: center; }
.ccard h3 { font-size: 18px; }
.ccard-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 99px; }
.chip.ghost { color: var(--muted); }
.dot::before { content: '●'; margin-right: 5px; font-size: 10px; vertical-align: 1px; }

/* Badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.b-grey { background: var(--grey-bg); color: var(--grey); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-green { background: var(--green-bg); color: var(--green); }

/* Alertes */
.alerts .sec { margin-top: 22px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px; border-radius: 14px; background: var(--amber-bg); border-left: 4px solid var(--accent-deep); }
.alert b { display: block; font-size: 14px; font-weight: 650; }
.alert small { display: block; font-size: 12px; }
.alert.is-red { background: var(--red-bg); border-color: var(--red); }
.alert .ic { width: 16px; height: 16px; color: var(--muted); }

/* Accueil vide */
.welcome { background: var(--surface); border-radius: 26px; padding: 0 20px 22px; box-shadow: var(--shadow); display: grid; gap: 12px; overflow: hidden; margin-top: 10px; }
.welcome .hazard { margin: 0 -20px 10px; }
.welcome h1 { font-size: 28px; }
.hazard { height: 14px; background: var(--hazard); }
.backup-nudge { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 24px; padding: 12px 14px; border: 1.5px dashed var(--line); border-radius: 14px; background: transparent; font-size: 13px; color: var(--ink-2); text-align: left; }

/* En-tête chantier */
.chead { background: var(--surface); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); }
.chead-main { display: flex; gap: 16px; align-items: center; }
.chead h1 { font-size: 23px; }
.chead p .ic { width: 13px; height: 13px; vertical-align: -2px; }
.chead-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); text-align: center; }
.chead-stats b { display: block; font-size: 15px; font-weight: 700; }
.chead-stats span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.chead-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chead-actions .btn:last-child { margin-left: auto; }

/* Onglets */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 14px -16px 0; padding: 0 16px 2px;
  position: sticky; top: 56px; z-index: 10; background: var(--bg);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 10px 14px; font-weight: 650; font-size: 14px; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabbody { padding-top: 14px; }
.chipbar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 12px -16px 4px; padding: 0 16px; }
.chipbar::-webkit-scrollbar { display: none; }
.fchip { flex: none; border: 1.5px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 99px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.fchip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Carte phase */
.pcard { display: block; background: var(--surface); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.pcard-head { display: flex; gap: 12px; align-items: center; }
.pcard-side { display: flex; align-items: center; gap: 2px; flex: none; }
.edit-btn { color: var(--ink-2); }
.edit-btn:hover { background: var(--surface-2); color: var(--ink); }
.phead-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.phead-top .eyebrow { margin: 0; }
.f-name input { font-weight: 650; font-size: 17px; }
.pico { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 14px; background: var(--surface-2); font-size: 22px; }
.pico.xl { width: 60px; height: 60px; font-size: 32px; border-radius: 18px; }
.pbar { height: 10px; border-radius: 99px; background: var(--grey-bg); margin: 14px 0 8px; overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .3s; }
.pcard-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pcard-row .ic { width: 13px; height: 13px; vertical-align: -2px; }
.big-pct { font: 800 20px/1 var(--font-d); }
.money3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.money3 div { display: grid; gap: 2px; min-width: 0; }
.money3 span { font-size: 11px; font-weight: 600; color: var(--muted); }
.money3 b { font: 700 14px/1.15 var(--mono); letter-spacing: -.03em; overflow-wrap: anywhere; }
.money3.lg b { font-size: 16px; }
.money3 small { font-size: 11px; }
.warn, .ok { display: flex; align-items: flex-start; gap: 6px; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--red); }
.warn .ic, .ok .ic { width: 15px; height: 15px; margin-top: 2px; }
.ok { color: var(--green); }

/* ---------- SEL3A : tickets / reçus ---------- */
.receipt {
  position: relative; cursor: pointer;
  background: var(--surface); border-radius: 16px; padding: 14px 16px 12px;
  box-shadow: var(--shadow);
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 0);
  background-size: 8px 8px;
}
.receipt::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -6px; height: 6px;
  background: radial-gradient(circle at 6px -2px, transparent 5px, var(--surface) 5.5px) 0 0 / 12px 6px repeat-x;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .06));
}
.receipt-top { display: flex; gap: 12px; align-items: flex-start; }
.receipt h4 { font-size: 16px; }
.receipt-amt { font-size: 18px; font-weight: 700; white-space: nowrap; }
.receipt-perf { position: relative; margin: 12px -16px 10px; border-top: 2px dashed var(--line); }
.receipt-perf::before, .receipt-perf::after { content: ''; position: absolute; top: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); }
.receipt-perf::before { left: -8px; } .receipt-perf::after { right: -8px; }
.receipt-bot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.receipt-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nodoc { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; border: 1.5px dashed var(--accent-deep); background: var(--amber-bg); color: var(--amber); font-size: 13px; font-weight: 650; cursor: pointer; }
.nodoc .ic { width: 18px; height: 18px; }

/* Tampons */
.stamp {
  flex: none; font: 700 11.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 7px 10px; border-radius: 6px; border: 2.5px solid currentColor; background: transparent;
  transform: rotate(-5deg); opacity: .92; white-space: nowrap;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 2'/%3E%3C/filter%3E%3Crect width='60' height='60' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 2'/%3E%3C/filter%3E%3Crect width='60' height='60' filter='url(%23n)'/%3E%3C/svg%3E");
  transition: transform .15s;
}
button.stamp:active { transform: rotate(-5deg) scale(.92); }
.stamp.s-red { color: var(--red); }
.stamp.s-green { color: var(--green); }
.stamp.s-blue { color: var(--blue); }
.stamp.s-grey { color: var(--grey); }

/* Liste à acheter */
.blist { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; border-left: 5px solid var(--accent); }
.brow { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 4px; min-height: 56px; }
.brow + .brow { border-top: 1px solid var(--line); }
.brow-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 6px 8px; border: 0; background: none; text-align: left; }
.brow-main b { display: block; font-weight: 650; }
.brow-main small { display: block; font-size: 12px; }
.brow-box { width: 22px; height: 22px; flex: none; border-radius: 7px; border: 2px solid var(--accent-deep); }
.besoins { margin-top: 8px; }

/* Lignes (argent, listes) */
.lrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); cursor: pointer; }
.lrow b { display: block; font-weight: 650; font-size: 14.5px; }
.lrow small { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow > .ic { width: 16px; height: 16px; color: var(--muted); }
.lrow.is-red { box-shadow: var(--shadow), inset 4px 0 0 var(--red); }
.lrow-ico { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--surface-2); font-size: 19px; color: var(--ink-2); }
.lrow-ico .ic { width: 18px; height: 18px; }
.lrow-ico.blue { background: var(--blue-bg); color: var(--blue); }
.lrow-ico.green { background: var(--green-bg); color: var(--green); }
.lrow-end { display: grid; justify-items: end; gap: 6px; flex: none; }
.lrow-end .stamp { font-size: 10px; padding: 5px 7px; border-width: 2px; }

/* Photos */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs.sm { margin-top: 12px; }
.thumb-wrap { position: relative; display: inline-block; }
.thumb { display: block; position: relative; width: 76px; height: 76px; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.thumbs.sm .thumb { width: 60px; height: 60px; border-radius: 10px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb em { position: absolute; left: 4px; bottom: 4px; font: 700 9px/1 var(--font); font-style: normal; text-transform: uppercase; letter-spacing: .04em; padding: 3px 5px; border-radius: 5px; background: rgba(0, 0, 0, .7); color: #fff; }
.thumb em.k-facture { background: var(--accent); color: var(--accent-ink); }
.thumb em.k-bl { background: var(--blue); color: #fff; }
.thumb-del { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); background: var(--ink); color: var(--bg); display: grid; place-items: center; padding: 0; }
.thumb-del .ic { width: 12px; height: 12px; stroke-width: 3; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 8px; }
.grid .thumb-wrap, .grid .thumb { width: 100%; }
.grid .thumb { height: auto; aspect-ratio: 1; }
.grid .empty { grid-column: 1 / -1; }
.grid.docs { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid figure { margin: 0; background: var(--surface); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.grid figcaption { padding: 6px 4px 2px; }
.grid figcaption b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid figcaption small { font-size: 11.5px; }
.pgal + .pgal { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.pgal-head { display: flex; align-items: center; justify-content: space-between; }
.pgal .thumbs.sm { margin-top: 6px; }

/* ---------- Phase : en-tête ---------- */
.phead { background: var(--surface); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); border-top: 6px solid var(--c); }
.phead .eyebrow { color: var(--ink-2); }
.phead-main { display: flex; gap: 14px; align-items: center; }
.phead h1 { font-size: 24px; }
.avance { margin-top: 18px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.avance-top { display: flex; align-items: baseline; gap: 8px; }
.avance-num { font: 800 44px/1 var(--font-d); letter-spacing: -.04em; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; margin: 8px 0 4px; --v: 50%;
}
input[type=range]::-webkit-slider-runnable-track { height: 12px; border-radius: 99px; background: linear-gradient(90deg, var(--accent-deep) var(--v), var(--grey-bg) var(--v)); }
input[type=range]::-moz-range-track { height: 12px; border-radius: 99px; background: var(--grey-bg); }
input[type=range]::-moz-range-progress { height: 12px; border-radius: 99px; background: var(--accent-deep); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -9px; border-radius: 50%; background: var(--ink); border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 4px solid var(--accent); }
.field input[type=range] { padding: 0; border: 0; background: transparent; }
.field input[type=range]::-webkit-slider-runnable-track { background: var(--grey-bg); }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.quick button { border: 0; border-radius: 10px; padding: 8px 0; background: var(--surface); font: 700 13px/1 var(--mono); }
.status-seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.status-seg button { flex: 1 1 auto; border: 1.5px solid var(--line); background: var(--surface); border-radius: 11px; padding: 8px 10px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.status-seg button.on { background: var(--c); border-color: var(--c); color: #fff; }
.status-seg button.on.s-amber { color: var(--accent-ink); }

.person { display: flex; align-items: center; gap: 12px; }
.person b { display: block; }
.person small { display: block; font-size: 12.5px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 800 18px/1 var(--font-d); }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.person-card h1 { font-size: 24px; }
.person-card > p { margin-top: 12px; }
.stars { color: var(--accent-deep); letter-spacing: 2px; }
.dates3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.dates3 span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.dates3 b { font: 700 13px/1.2 var(--mono); }
.paybar { position: relative; height: 12px; margin: 14px 0 4px; border-radius: 99px; background: var(--grey-bg); }
.paybar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.paybar em { position: absolute; top: -5px; width: 4px; height: 22px; margin-left: -2px; border-radius: 2px; background: var(--ink); }

/* Checklists */
.checklist { display: grid; gap: 2px; }
.ckrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.ckrow.done .grow { color: var(--muted); text-decoration: line-through; }
.ckrow.open .ckbox { border-color: var(--red); }
.ckbox { display: grid; place-items: center; width: 28px; height: 28px; flex: none; padding: 0; border-radius: 9px; border: 2px solid var(--line); background: var(--surface); color: #fff; }
.ckrow.done .ckbox { background: var(--green); border-color: var(--green); }
.ckbox .ic { width: 16px; height: 16px; stroke-width: 3; }
.inline-add { display: flex; gap: 6px; margin-top: 8px; }
.inline-add input { flex: 1; min-width: 0; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-2); }

/* Planning (Gantt) */
.gantt { position: relative; background: var(--surface); border-radius: var(--r); padding: 10px 12px 12px; box-shadow: var(--shadow); --gl: 116px; }
.g-row { display: flex; align-items: center; gap: 8px; min-height: 38px; }
.g-label { width: var(--gl); flex: none; font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; flex: 1; height: 22px; background: var(--surface-2); border-radius: 6px; }
.g-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 6px; background: color-mix(in srgb, var(--c) 30%, transparent); overflow: hidden; }
.g-bar i { display: block; height: 100%; background: var(--c); }
.g-bar.late { outline: 2px solid var(--red); outline-offset: 1px; }
.g-head { min-height: 30px; }
.g-ticks { background: none; height: 22px; }
.g-ticks > span { position: absolute; top: 4px; font: 600 10.5px/1 var(--mono); color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.g-today { position: absolute; top: 0 !important; bottom: auto; height: 9999px; width: 2px; background: var(--red); transform: none !important; z-index: 2; pointer-events: none; }
.gantt { overflow: hidden; }
.g-today em { position: absolute; top: -2px; left: 4px; font: 700 10px/1 var(--font); font-style: normal; color: #fff; background: var(--red); padding: 2px 5px; border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
.legend .late-i { background: transparent; outline: 2px solid var(--red); }

/* Journal */
.timeline { display: grid; gap: 12px; margin-top: 16px; }
.tl-item { display: flex; gap: 12px; }
.tl-date { width: 48px; flex: none; text-align: center; padding-top: 10px; }
.tl-date b { display: block; font: 800 24px/1 var(--font-d); }
.tl-date span { font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.tl-body { flex: 1; margin: 0; cursor: pointer; }

/* Vide */
.empty { display: grid; justify-items: center; gap: 12px; padding: 28px 16px; text-align: center; color: var(--muted); }
.empty-art { width: 64px; height: 12px; border-radius: 3px; background: var(--hazard); opacity: .7; }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field > span em { font-style: normal; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 13px;
  border: 1.5px solid var(--line); background: var(--surface-2); font-size: 16px; min-height: 48px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); background: var(--surface); }
.field .invalid, .invalid { border-color: var(--red) !important; background: var(--red-bg) !important; }
.f-money input { font-family: var(--mono); font-weight: 600; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fgroup { border: 0; margin: 6px 0 14px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.fgroup legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font: 700 14px/1 var(--font-d); }
.fgroup legend ~ * { clear: both; }
.fgroup .field:last-child { margin-bottom: 0; }
.fgroup .field input, .fgroup .field select, .fgroup .field textarea { background: var(--surface); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex: 1 1 auto; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 10px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 650; font-size: 14px; cursor: pointer; }
.seg input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
.check-green input { accent-color: var(--green); }
.check-green span { font-weight: 650; color: var(--green); }
.checks { display: grid; gap: 0; }
.calc { font: 700 14px/1 var(--mono); margin: -4px 0 4px; }
.picker + .picker { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.picker-head > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 14px; }
.picker-head > span .ic { width: 18px; height: 18px; }
.rlist { display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.rcheck { padding: 10px; border-radius: 12px; background: var(--surface-2); }
.rcheck b { display: block; font-size: 14px; }
.rcheck small { display: block; font-size: 12px; }
.rlist > .btn { justify-self: start; margin-bottom: 4px; }

/* Affichage conditionnel */
.if-new-art, .if-unit, .if-moi, .if-poche, .if-remb { display: none; }
.show-new-art .if-new-art { display: block; }
.mode-forfait .if-forfait { display: block; }
form:not(.mode-forfait) .if-unit { display: block; }
.mode-forfait .if-unit, form:not(.mode-forfait) .if-forfait { display: none; }
.pay-moi .if-moi { display: block; }
.src-poche .if-poche { display: block; }
.is-besoin .if-paid { display: none; }
.is-remb .if-remb { display: block; }

/* ---------- Bottom sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 11, 12, .5); opacity: 0; transition: opacity .22s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 92dvh;
  display: flex; flex-direction: column; background: var(--surface); border-radius: 26px 26px 0 0;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 10px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 20px; }
.sheet-head h2 { font-size: 20px; }
.sheet-body { overflow-y: auto; padding: 6px 20px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.sheet-foot { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); display: flex; gap: 8px; margin: 10px -20px calc(-20px - env(safe-area-inset-bottom)); padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.sheet-foot .btn-danger-ghost { flex: none; width: 52px; padding: 0; }
.sheet-foot .btn-danger-ghost.btn-block { width: 100%; }

.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 8px; }
.qtile { display: grid; gap: 2px; justify-items: start; text-align: left; padding: 14px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface-2); cursor: pointer; }
.qtile .ic { width: 26px; height: 26px; margin-bottom: 8px; }
.qtile b { font-size: 14.5px; }
.qtile small { font-size: 12px; color: var(--muted); }
.qtile.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.qtile.accent small { color: rgba(26, 20, 0, .7); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: #0B0C0D; color: #fff; display: flex; flex-direction: column; }
.lb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px 16px; font-size: 14px; font-weight: 600; }
.lb-top .icon-btn { color: #fff; }
.lb-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lb-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.lb-actions .btn-ghost { background: #1E2124; border-color: #2E3236; color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 650; font-size: 14px;
  max-width: calc(100vw - 32px); transition: all .22s; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Synchro & connexion ---------- */
.sync-badge { flex: none; border: 0; border-radius: 99px; padding: 6px 10px; font: 700 11.5px/1 var(--font); white-space: nowrap; }
.sync-badge.s-ok { background: var(--green-bg); color: var(--green); }
.sync-badge.s-pending { background: var(--amber-bg); color: var(--amber); }
.sync-badge.s-offline { background: var(--grey-bg); color: var(--grey); }
body.auth .bottomnav, body.auth #gear, body.auth #sync { display: none; }
.authbox { max-width: 440px; margin: 24px auto 0; }
.authbox form { display: grid; gap: 2px; margin-top: 6px; }
.authbox input[name=code] { font: 700 18px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.setup-hint { display: flex; gap: 8px; align-items: flex-start; margin: -4px 0 14px; }
.setup-hint .ic { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.setup-hint code { font-family: var(--mono); font-size: 12px; }
.pwd { margin: 6px 0 14px; }
.pwd summary { cursor: pointer; font-weight: 650; padding: 8px 0; }
.pwd form { margin-top: 8px; }

/* ---------- Dépenses ---------- */
.stat-link { display: block; border-radius: 10px; }
.stat-link span { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.dep-hero {
  position: relative; overflow: hidden; display: grid; gap: 6px;
  padding: 18px; border-radius: 22px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
}
.dep-hero::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--hazard); }
.dep-hero .eyebrow { color: color-mix(in srgb, var(--bg) 70%, transparent); margin: 4px 0 0; }
.dep-hero strong { font-size: clamp(34px, 10vw, 46px); font-weight: 700; letter-spacing: -.04em; line-height: 1.05; }
.dep-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; padding-top: 12px; border-top: 1px dashed color-mix(in srgb, var(--bg) 25%, transparent); }
.dep-split span { display: block; font-size: 11.5px; font-weight: 600; color: color-mix(in srgb, var(--bg) 70%, transparent); }
.dep-split b { font-size: 15px; overflow-wrap: anywhere; }
.dep-budget { margin-top: 10px; }
.dep-budget-bar { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--bg) 18%, transparent); overflow: hidden; }
.dep-budget-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.dep-budget p { margin-top: 8px; color: color-mix(in srgb, var(--bg) 85%, transparent); }
.card.flat { margin-top: 0; padding: 6px 16px; }
.hbars { display: grid; }
.hbar { display: grid; gap: 5px; padding: 12px 0; }
.hbar + .hbar { border-top: 1px solid var(--line); }
a.hbar:active { opacity: .7; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.hbar-label { font-weight: 650; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-top b { font-size: 14px; white-space: nowrap; }
.hbar-track { height: 10px; border-radius: 4px; background: var(--grey-bg); }
.hbar-track i { display: block; height: 100%; border-radius: 4px; background: var(--blue); }
.hbar small { font-size: 12px; }
.vbars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 14px 0 8px; }
.vbar { flex: 1; min-width: 0; height: 100%; display: grid; grid-template-rows: 18px 1fr 18px; justify-items: center; gap: 4px; }
.vbar-val { font-size: 10.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.vbar-col { width: 100%; max-width: 44px; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line); }
.vbar-col i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--blue); }
.vbar-lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: capitalize; }
table.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Lecture seule (architecte) ---------- */
.ro-banner {
  display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; padding: 9px 14px;
  border-radius: 12px; background: var(--blue-bg); color: var(--blue); font-size: 13px; font-weight: 650;
}
.ro-banner .ic { width: 16px; height: 16px; }
body.readonly .fab { visibility: hidden; }
.ro { cursor: default !important; }
button.ro:disabled { cursor: default; }
body.readonly input[type=range]:disabled { opacity: .85; }
body.readonly input[type=range]::-webkit-slider-thumb { display: none; }

/* ---------- Rapport ---------- */
.report { background: #fff; color: #16181B; border-radius: 18px; padding: 0 20px 24px; box-shadow: var(--shadow); overflow: hidden; }
.report header { margin: 0 -20px 16px; padding: 0 20px 14px; border-bottom: 2px solid #16181B; }
.report header .hazard { margin: 0 -20px 16px; }
.report header p { font-size: 13px; margin-top: 4px; }
.report h2 { margin: 22px 0 8px; font-size: 16px; }
.report-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.report-kpis div { border: 1.5px solid #E1DCD2; border-radius: 10px; padding: 8px; }
.report-kpis b { display: block; font: 700 17px/1.1 var(--mono); }
.report-kpis span { font-size: 11px; color: #6b7079; }
.report table { width: 100%; border-collapse: collapse; font-size: 12px; }
.report th, .report td { text-align: left; padding: 6px 6px; border-bottom: 1px solid #E1DCD2; vertical-align: top; }
.report th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6b7079; }
.report .tot td { font-weight: 800; border-top: 2px solid #16181B; }
.report-wrap { overflow-x: auto; }

@media (max-width: 420px) {
  .kpi b { font-size: 15px; }
  .report-kpis { grid-template-columns: 1fr 1fr; }
  .gantt { --gl: 92px; }
  .chead-stats b { font-size: 13px; }
}
@media (min-width: 760px) {
  .main { padding-top: 24px; }
  .stack.cards2 { grid-template-columns: 1fr 1fr; }
}
@media print {
  body { background: #fff; }
  .topbar, .bottomnav, .noprint, .toast { display: none !important; }
  .main { padding: 0; max-width: none; }
  .report { box-shadow: none; border-radius: 0; padding: 0; }
  .report header .hazard { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
