/* ChantierPilot — direction « chantier premium » : ivoire chaud, noir profond, ambre sécurité, rouge pour les alertes. */
:root {
  --navy: #15181D; --navy-2: #1F232A; --amber: #F5A300; --amber-2: #B37400; --amber-bg: #FFF1C9; --amber-ink: #7A5200;
  --bg: #F4F1EA; --card: #fff; --ink: #15181D; --muted: #6E6A62; --line: #E4DFD4; --line-2: #F0ECE3;
  --red: #D7263D; --red-bg: #FDE3E7; --red-ink: #9E1526; --orange: #C25E00; --orange-bg: #FFE6CC;
  --yellow: #B37400; --yellow-bg: #FFF1C9; --green: #1E6B3A; --green-bg: #DFF3E6;
  --radius: 18px; --shadow: none;
  --display: 'Barlow Condensed', Impact, 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 100px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

/* Barre haute */
.top { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #F4F1EA; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: .5px; text-transform: uppercase; line-height: 1; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand b { color: var(--amber); font-weight: 800; }
.brand small { font-family: Inter, sans-serif; font-size: 11px; font-weight: 600; opacity: .6; margin-left: 6px; letter-spacing: 1.5px; }
.roles { display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 3px; border-radius: 12px; }
.roles a { padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: #CFC9BD; }
.roles a.on { background: var(--amber); color: var(--navy); font-weight: 700; }
@media (max-width: 480px) { .brand small { display: none; } .roles a { padding: 6px 8px; font-size: 12px; } }

/* Onglets bas (mobile) */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--navy); border-top: 1px solid #2A2F37; padding-bottom: env(safe-area-inset-bottom); }
.tabs:empty { display: none; }
.tabs a { flex: 1; text-align: center; padding: 8px 2px 9px; font-size: 10.5px; font-weight: 500; color: #9AA0A8; display: flex; flex-direction: column; gap: 2px; }
.tabs a i { font-style: normal; font-size: 19px; }
.tabs a.on { color: var(--amber); font-weight: 700; }

/* Titres et blocs */
h1 { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: .95; letter-spacing: -.3px; margin: 8px 0 4px; }
h1 .accent { color: var(--amber-2); }
h2 { font-family: var(--display); font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: .5px; margin: 26px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.sub { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.link { display: block; transition: transform .1s; }
.card.link:active { transform: scale(.985); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px; }
.kpi b { display: block; font-family: var(--display); font-weight: 800; font-size: 44px; line-height: .9; }
.kpi span { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-top: 6px; }
.kpi.red { background: var(--red); border-color: var(--red); color: #fff; } .kpi.red b, .kpi.red span { color: #fff; }
.kpi.orange { background: var(--amber); border-color: var(--amber); } .kpi.orange b { color: var(--navy); } .kpi.orange span { color: #5E4200; }
.kpi.green b { color: var(--ink); }
@media (max-width: 520px) { .kpis { grid-template-columns: repeat(2, 1fr); } .kpi b { font-size: 36px; } h1 { font-size: 34px; } }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #EEEAE1; color: #4A463F; white-space: nowrap; }
.badge.red { background: var(--red-bg); color: var(--red-ink); } .badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.yellow { background: var(--yellow-bg); color: var(--amber-ink); } .badge.green { background: var(--green-bg); color: var(--green); }
.badge.navy { background: var(--navy); color: #fff; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

.bar { height: 10px; background: #EEEAE1; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }

/* Alertes */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; margin-bottom: 8px; font-size: 14px; background: #fff; border: 1px solid var(--line); }
.alert.rouge { background: var(--red-bg); border-color: #F5B8C0; }
.alert.orange { background: var(--amber-bg); border-color: #F0D58A; }
.alert.jaune { background: #fff; }
.alert .ico { font-size: 18px; line-height: 1.2; }
.alert .who { font-weight: 700; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.alert .act { margin-left: auto; align-self: center; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 16px; background: var(--navy); color: #F4F1EA; font-weight: 700; font-size: 14px; min-height: 44px; }
.btn.amber { background: var(--amber); color: var(--navy); }
.btn.ghost { background: transparent; border: 1.5px solid #D9D3C6; color: var(--ink); }
.btn.green { background: var(--green); color: #fff; } .btn.red { background: var(--red); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 13px; min-height: 36px; border-radius: 9px; }
.btn.big { width: 100%; padding: 17px; font-size: 17px; border-radius: 14px; min-height: 56px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Listes */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; display: flex; gap: 12px; align-items: center; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; }
.item .m { color: var(--muted); font-size: 13px; }
.item.done { opacity: .55; } .item.done .t { text-decoration: line-through; }
.item.blocked { border-color: var(--amber); border-width: 2px; }

/* Timeline phases */
.phases { display: flex; flex-direction: column; }
.phase { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.phase:last-child { border-bottom: 0; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #D9D3C6; background: #fff; margin-top: 2px; }
.dot.termine { background: var(--navy); border-color: var(--navy); }
.dot.en_cours { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-bg); }
.dot.retard { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 4px var(--red-bg); }
.phase .mat { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.chip.retard { background: var(--red-bg); border-color: #F5B8C0; color: var(--red-ink); font-weight: 600; }
.chip.urgent { background: var(--amber-bg); border-color: #F0D58A; color: var(--amber-ink); font-weight: 600; }
.chip.bientot { background: var(--yellow-bg); border-color: #F0D58A; }
.chip.livraison_tardive { background: var(--orange-bg); border-color: #F5C89A; }
.chip.livre { background: var(--green-bg); border-color: #BFE6CD; color: var(--green); }
.chip.commande { background: #E8EEF6; border-color: #C4D2E6; color: #2A4B7A; }

/* Tableau commandes */
.cmd { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; margin-bottom: 8px; }
.cmd.retard { border-color: var(--red); border-width: 2px; } .cmd.urgent { border-color: var(--amber); border-width: 2px; }
.cmd .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.cmd .lim { font-weight: 700; }
.cmd .lim.retard { color: var(--red); } .cmd .lim.urgent { color: var(--amber-2); }
.cmd .foot { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 7px 14px; font-size: 13px; font-weight: 600; }
.filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Journal */
.jl { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.jl:last-child { border-bottom: 0; }
.jl .ph { width: 48px; height: 48px; border-radius: 12px; background: #D9D3C6; display: grid; place-items: center; font-size: 22px; flex: none; }
.jl .who { font-size: 12px; color: var(--muted); }
.jl .int { font-size: 10px; background: #EEEAE1; border-radius: 4px; padding: 1px 5px; margin-left: 4px; }

/* Photo de chantier (carte) */
.photo { height: 120px; background: #D9D3C6; border-radius: 14px 14px 0 0; margin: -16px -16px 14px; display: flex; align-items: flex-end; padding: 12px; }
.photo span { background: var(--navy); color: #F4F1EA; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 99px; }
.photo.retard span { background: var(--red); }
.card .pct { font-family: var(--display); font-weight: 800; font-size: 22px; }
.card .name { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1; }

/* Terrain (employé) */
.hero { background: var(--navy); color: #F4F1EA; border-radius: 20px; padding: 22px; margin-bottom: 16px; }
.hero h1 { margin: 0 0 6px; font-size: 36px; color: #F4F1EA; }
.hero h1 .accent { color: var(--amber); }
.hero .muted { color: #B9B3A8; }
.hero .btn.amber { margin-top: 14px; }
.pointed { display: inline-block; background: rgba(255,255,255,.1); border-radius: 12px; padding: 10px 14px; margin-top: 12px; font-size: 14px; font-weight: 600; }
.task { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 10px; }
.task.en_cours { border: 2px solid var(--amber); }
.task .t { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1.05; }
.task .matl { margin: 10px 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; background: var(--green-bg); color: var(--green); font-weight: 600; }
.task .matl.depot { background: var(--amber-bg); color: var(--amber-ink); }
.task .matl.livraison { background: #E8EEF6; color: #2A4B7A; }
.task .acts { display: flex; gap: 8px; margin-top: 8px; }
.task .acts .btn { flex: 1; }
.task.fait { opacity: .55; } .task.fait .t { text-decoration: line-through; }
.select { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.select button { flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 13px; font-size: 13px; text-align: left; font-weight: 600; }
.select button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.select button small { display: block; font-size: 11px; opacity: .7; font-weight: 500; }

/* Client */
.client-hero { background: var(--amber); color: var(--navy); border-radius: 20px; padding: 22px; margin-bottom: 14px; }
.client-hero h1 { margin: 0; font-size: 30px; }
.client-hero .big { font-family: var(--display); font-size: 88px; font-weight: 800; line-height: .85; margin: 10px 0 4px; }
.client-hero .big small { font-size: 40px; }
.client-hero .muted { color: #5E4200; }
.steps { display: flex; gap: 4px; margin: 14px 0; }
.steps i { flex: 1; height: 8px; border-radius: 4px; background: rgba(21,24,29,.18); }
.steps i.termine { background: var(--navy); } .steps i.en_cours { background: #fff; }
input, textarea, select { font: inherit; width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
.form { display: flex; flex-direction: column; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 50; pointer-events: none; font-size: 14px; font-weight: 600; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.demo-note { font-size: 12px; color: var(--muted); text-align: center; margin: 28px 0 0; }
.demo-note button { background: none; border: 0; color: var(--ink); text-decoration: underline; padding: 0; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* ---------- IA ---------- */
.fab { position: fixed; right: 16px; bottom: 80px; z-index: 30; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--navy); color: var(--amber); font-size: 26px; box-shadow: 0 8px 24px rgba(21,24,29,.35); }
.fab::after { content: 'IA'; position: absolute; top: -4px; right: -4px; background: var(--amber); color: var(--navy); font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 99px; }
.hidden { display: none !important; }
.panel { position: fixed; z-index: 40; right: 16px; bottom: 80px; width: min(420px, calc(100vw - 32px)); height: min(600px, calc(100vh - 130px)); background: #fff; border-radius: 20px; box-shadow: 0 16px 48px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; background: var(--navy); color: #F4F1EA; font-family: var(--display); font-size: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.panel-head .muted { color: #B9B3A8; flex: 1; font-family: Inter, sans-serif; text-transform: none; font-weight: 500; letter-spacing: 0; }
.panel-head .x { background: none; border: 0; color: #fff; font-size: 18px; }
.panel-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; line-height: 1.45; }
.msg.bot { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.wait { color: var(--muted); font-style: italic; }
.msg .acts { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.msg .acts span { font-size: 11px; background: var(--green-bg); color: var(--green); border-radius: 6px; padding: 2px 6px; font-weight: 600; }
.panel-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.panel-form input { flex: 1; }
.modal { position: fixed; inset: 0; z-index: 45; background: rgba(21,24,29,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 20px 18px 26px; }
@media (min-width: 700px) { .modal { align-items: center; } .modal-box { border-radius: 22px; } }
.modal-box h2 { margin-top: 0; }
.brief { background: var(--navy); color: #F4F1EA; border-radius: 20px; padding: 22px; margin-bottom: 16px; }
.brief h2 { margin: 0 0 8px; color: var(--amber); font-size: 14px; letter-spacing: 1.5px; font-family: Inter, sans-serif; font-weight: 700; }
.brief .muted { color: #B9B3A8; }
.brief .resume { font-size: 17px; line-height: 1.5; margin: 6px 0 14px; font-weight: 500; }
.prio { display: flex; gap: 12px; padding: 12px; background: var(--navy-2); border-radius: 14px; margin-bottom: 8px; align-items: flex-start; }
.prio .n { width: 30px; height: 30px; border-radius: 50%; background: var(--amber); color: var(--navy); font-family: var(--display); font-weight: 800; font-size: 18px; display: grid; place-items: center; flex: none; }
.prio .n.critique { background: var(--red); color: #fff; }
.prio .why { color: #B9B3A8; font-size: 13px; }
.risques { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.risque { flex: 1; min-width: 140px; background: var(--navy-2); border-radius: 14px; padding: 10px 12px; font-size: 13px; }
.risque b { font-family: var(--display); font-size: 36px; font-weight: 800; display: block; line-height: 1; }
.risque .r-haut b { color: #FF6B7D; } .risque .r-moyen b { color: var(--amber); } .risque .r-bas b { color: #7EDB9C; }
.wa { display: flex; gap: 10px; align-items: flex-start; background: #fff; color: var(--ink); border-radius: 14px; padding: 12px; margin-top: 8px; }
.wa .txt { flex: 1; font-size: 13px; white-space: pre-wrap; }
.wa .btn { flex: none; }
details.ia-more summary { cursor: pointer; color: #F4F1EA; font-size: 13px; font-weight: 600; margin-top: 10px; }
.mic { background: var(--red); color: #fff; }
.mic.on { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.plan-phase { border-left: 3px solid var(--amber); padding: 6px 12px; margin-bottom: 8px; }
.photo-prev { max-width: 100%; max-height: 180px; border-radius: 12px; margin-top: 6px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.cr-block { background: var(--bg); border-radius: 12px; padding: 12px; margin-bottom: 8px; font-size: 14px; }
.cr-block b { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
