:root {
  --brand: #1d4ed8;
  --brand-ink: #fff;
  --bg: #f5f6f8;
  --card: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f3f4f6;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.pad-sm { padding: 14px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; min-height: 42px; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .88rem; }
.btn.lg { padding: 14px 22px; font-size: 1.05rem; min-height: 52px; }
.btn.block { width: 100%; }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }

/* Formulaires */
label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: .83rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.field { margin-bottom: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }

/* Choix en tuiles (simulateur) */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice {
  position: relative; display: flex; flex-direction: column; gap: 2px; margin: 0;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: #fff;
  font-weight: 600; transition: border-color .15s, background .15s;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .price { font-weight: 500; font-size: .83rem; color: var(--muted); }
.choice .desc { font-weight: 400; font-size: .8rem; color: var(--muted); }
.choice:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, #fff); }
.choice:has(input:checked)::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--brand); font-weight: 800; }
.choice:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

.stepper { display: flex; align-items: stretch; max-width: 320px; }
.stepper button { width: 46px; border: 1px solid #d1d5db; background: var(--soft); font-size: 1.2rem; cursor: pointer; }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper input { border-radius: 0; text-align: center; border-left: 0; border-right: 0; font-weight: 700; }
.stepper .unit { display: flex; align-items: center; padding: 0 10px; border: 1px solid #d1d5db; border-left: 0; background: #fff; color: var(--muted); white-space: nowrap; }
.stepper .unit + button { border-left: 0; }
input[type=range] { width: 100%; max-width: 320px; accent-color: var(--brand); margin-top: 8px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; margin: 0; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 99px; background: #d1d5db; position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: var(--shadow); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 23px; }

/* Récapitulatif chiffré */
.summary .line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.summary .line span:first-child { color: #374151; }
.summary .line span:last-child { white-space: nowrap; font-weight: 600; }
.summary .tot { display: flex; justify-content: space-between; padding: 4px 0; }
.summary .grand { font-size: 1.6rem; font-weight: 800; color: var(--brand); letter-spacing: -.01em; }
.summary .range { background: var(--soft); border-radius: 8px; padding: 8px 10px; font-size: .85rem; color: #374151; margin-top: 8px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 700; background: var(--soft); color: #374151; white-space: nowrap; }
.badge.estimate { background: #eff6ff; color: #1d4ed8; }
.badge.validated { background: var(--ok-bg); color: var(--ok); }
.badge.confirmed { background: #f0fdf4; color: #15803d; }
.badge.done { background: #f5f3ff; color: #6d28d9; }
.badge.rejected, .badge.cancelled { background: var(--bad-bg); color: var(--bad); }
.badge.plan { background: #111827; color: #fff; }
.badge.lock { background: var(--warn-bg); color: var(--warn); }

.alert { padding: 12px 14px; border-radius: 10px; background: var(--soft); border: 1px solid var(--line); font-size: .92rem; }
.alert.warn { background: var(--warn-bg); border-color: #fde68a; color: #78350f; }
.alert.ok { background: var(--ok-bg); border-color: #a7f3d0; color: #064e3b; }
.alert.bad { background: var(--bad-bg); border-color: #fecaca; color: #7f1d1d; }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #fafafa; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Modales & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(17, 24, 39, .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); padding: 22px; position: relative; margin: auto 0; }
.modal.wide { max-width: 820px; }
.modal .x { position: absolute; top: 10px; right: 10px; border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--muted); width: 40px; height: 40px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 99; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); }

.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.photos:empty { display: none; }
.thumb { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(17,24,39,.75); color: #fff; cursor: pointer; font-size: 1rem; line-height: 1; }
a.thumb { display: block; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.review { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.sig-pad { border: 1.5px dashed #9ca3af; border-radius: 10px; background: #fff; width: 100%; height: 160px; touch-action: none; display: block; cursor: crosshair; }

.spinner { width: 20px; height: 20px; border: 3px solid rgba(0,0,0,.12); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { padding: 60px 0; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  .modal { padding: 18px 16px; }
  .choices { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) { .choices { grid-template-columns: 1fr; } }
