
:root, [data-theme="clair"] {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f1f3f6; --border: #e4e7ec;
  --text: #101828; --muted: #667085;
  --accent: #4f46e5; --accent-ink: #ffffff; --accent-text: #4338ca;
  --side-bg: #ffffff; --side-text: #475467; --side-border: #e4e7ec;
  --ok: #12805c; --warn: #b54708; --bad: #c0362c; --star: #f5a400;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
[data-theme="nuit"] {
  --bg: #0f1218; --surface: #181c25; --surface-2: #212633; --border: #2b3140;
  --text: #eef0f4; --muted: #98a2b3;
  --accent: #7c83ff; --accent-ink: #0f1218; --accent-text: #a5abff;
  --side-bg: #131720; --side-text: #b3bccb; --side-border: #232836;
  --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --star: #fbbf24;
  --shadow: none;
}
[data-theme="chantier"] {
  --bg: #f4f1ea; --surface: #ffffff; --surface-2: #f3efe5; --border: #e2dccd;
  --text: #1c1a17; --muted: #6f6a5f;
  --accent: #f5b400; --accent-ink: #1c1a17; --accent-text: #8a6100;
  --side-bg: #1c1a17; --side-text: #cfc8b8; --side-border: #1c1a17;
  --ok: #12805c; --warn: #b54708; --bad: #c0362c; --star: #f5a400;
  --shadow: 0 1px 2px rgba(28,26,23,.06);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.stack, .grid > * { min-width: 0; }
.card { overflow-x: auto; }

/* Barre latérale */
aside {
  background: var(--side-bg); border-right: 1px solid var(--side-border); color: var(--side-text);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; padding: 0 8px 18px; color: var(--side-text); }
[data-theme="clair"] .brand { color: var(--text); }
[data-theme="nuit"] .brand, [data-theme="chantier"] .brand { color: #fff; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }
.nav {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; color: inherit; font: inherit; font-weight: 500;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
}
.nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.nav.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); font-weight: 600; }
[data-theme="chantier"] .nav.active { color: var(--accent); }
.count { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 0 7px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid color-mix(in srgb, var(--side-text) 18%, transparent); }
.side-foot .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 8px; }
.themes { display: flex; gap: 8px; margin-bottom: 14px; }
.themes button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; outline: 1px solid color-mix(in srgb, var(--side-text) 35%, transparent); }
.themes button.on { border-color: var(--side-bg); outline: 2px solid var(--accent); }
.who-box { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
[data-theme="chantier"] .avatar { color: var(--accent); }
.who-box small { display: block; opacity: .7; font-size: 12px; }

/* Contenu */
main { padding: 28px 32px 60px; max-width: 1120px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; }
.sub { color: var(--muted); margin: 2px 0 0; }
.demo-tag { font-size: 12px; font-weight: 600; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); padding: 4px 10px; border-radius: 999px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; }
.stat .hint { font-size: 12.5px; color: var(--ok); font-weight: 500; }

.grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 15.5px; margin: 0 0 4px; letter-spacing: -.01em; }
.card .desc { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.card h2 + table, .card h2 + form, .card h2 + div { margin-top: 12px; }

label.f { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: var(--surface); color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
::placeholder { color: var(--muted); opacity: .75; }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(.94); }
.btn.full { width: 100%; margin-top: 16px; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.btn.no { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.linkbtn { background: none; border: 0; color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }

.preview { margin-top: 16px; background: var(--surface-2); border-radius: 12px; padding: 12px; }
.cap { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.bubble { background: var(--surface); border-radius: 14px 14px 14px 4px; padding: 10px 12px; border: 1px solid var(--border); font-size: 13.5px; }
.bubble a { color: var(--accent-text); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.who { font-weight: 600; }
.small:not(.btn) { font-size: 12.5px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.wait, .pill.late { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.pill.sent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); }
.pill.done { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill.lost { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.stars { color: var(--star); letter-spacing: 1px; }
.stars i { color: var(--border); font-style: normal; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions.left { justify-content: flex-start; }
.amount { font-weight: 700; white-space: nowrap; }
.seen { font-size: 12px; color: var(--ok); font-weight: 600; }
.unseen { font-size: 12px; color: var(--muted); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.row.first { border-top: 0; }
.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 20px; }

.qr { display: flex; gap: 16px; align-items: center; }
.qr svg { width: 108px; height: 108px; flex: none; border-radius: 10px; padding: 7px; background: #fff; border: 1px solid var(--border); }
.qr p { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }

.review { border-bottom: 1px solid var(--border); padding: 16px 0; }
.review:first-child { padding-top: 4px; }
.review:last-child { border-bottom: 0; padding-bottom: 0; }
.review .head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.review .txt { margin: 6px 0 10px; }
.review textarea { margin-bottom: 8px; }
.reply { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.reply b { font-size: 12px; color: var(--muted); display: block; }

/* Import de devis */
.step { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.step.first { border-top: 0; padding-top: 0; }
.num { width: 24px; height: 24px; border-radius: 50%; flex: none; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; margin-top: 1px; }
.step b { display: block; }
.step p { margin: 2px 0 10px; color: var(--muted); font-size: 13.5px; }
.addr { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 8px 8px 12px; margin-bottom: 8px; }
.addr code { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.drop { display: block; border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--border)); border-radius: 12px; padding: 18px 12px; text-align: center; cursor: pointer; color: var(--muted); font-size: 13.5px; }
.drop:hover, .drop.over { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop strong { color: var(--accent-text); display: block; }
.drop input { display: none; }
.pending { border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); border-radius: 12px; padding: 14px; margin-top: 12px; }
.pending .src { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.pending .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.pending .fields label { font-size: 12px; font-weight: 600; color: var(--muted); display: block; }
.pending .fields input { padding: 7px 10px; margin-top: 3px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #101828; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.note { margin-top: 26px; font-size: 12.5px; color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; border-right: 0; border-bottom: 1px solid var(--side-border); }
  .brand { padding: 0 8px 0 4px; }
  .nav { width: auto; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .side-foot .lbl, .who-box { display: none; }
  .themes { margin: 0; }
  main { padding: 20px 16px 50px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  th.opt, td.opt { display: none; }
}

/* --- Ajouts pour la vraie app --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { color: var(--text) !important; padding: 0 0 14px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.auth-tabs button { flex: 1; padding: 8px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.auth-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.err { color: var(--bad); font-size: 13.5px; margin-top: 10px; min-height: 20px; }
.qr img { width: 120px; height: 120px; flex: none; border-radius: 10px; background: #fff; border: 1px solid var(--border); }
.mini { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; width: auto; }
.del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 6px; }
.del:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.soon { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.logout { margin-top: 10px; }
input[type=password], input[type=tel] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: var(--surface); color: var(--text);
}
a.btn { display: inline-block; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); border-radius: 12px; padding: 10px 14px; margin-bottom: 18px; font-weight: 500; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 13.5px; }
.check input { margin-top: 3px; }
a { color: var(--accent-text); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: .5; }
