:root {
  --bg-0: #0a0b0c; --bg-1: #0e0f11; --bg-2: #121417; --bg-3: #181b1f;
  --line: #262a2f; --line-strong: #343a41;
  --gold: #c9a24b; --gold-hi: #ecd398; --gold-lo: #9e7a31;
  --gold-soft: rgba(201, 162, 75, 0.14);
  --gold-grad: linear-gradient(135deg, #ecd398 0%, #c9a24b 46%, #9e7a31 100%);
  --text: #f3f0ea; --text-soft: #cbc6bd; --text-mute: #9a958c;
  --ok: #63a67a; --warn: #cf8f45; --bad: #c05f50;
  --font-display: "Oswald", "Bahnschrift SemiCondensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mo: #c9a24b; --mat: #8fa3b8; --mtl: #9a8fb8; --st: #7fae9e; --fr: #b8988f;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg-0); color: var(--text); font-family: var(--font-body); font-size: 15px; }
body { display: flex; min-height: 100vh; }
::selection { background: var(--gold-soft); }

/* ---------- sidebar ---------- */
aside {
  width: 218px; flex: none; background: var(--bg-1); border-right: 1px solid var(--line);
  padding: 1.4rem 0; display: flex; flex-direction: column; gap: 1.6rem;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 0 1.3rem; }
.brand .mark { font-family: var(--font-display); text-transform: uppercase; font-size: 1.22rem; letter-spacing: 0.06em; line-height: 1.1; }
.brand .mark b { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 600; }
.brand .sub { font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-mute); margin-top: 0.35rem; }
nav { display: flex; flex-direction: column; }
nav button {
  all: unset; cursor: pointer; padding: 0.72rem 1.3rem; font-size: 0.78rem; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--text-mute); border-left: 2px solid transparent;
  transition: color 0.2s, background 0.2s;
}
nav button:hover { color: var(--text-soft); background: var(--bg-2); }
nav button.on { color: var(--gold-hi); border-left-color: var(--gold); background: var(--bg-2); }
nav button:focus-visible { outline: 1px solid var(--gold); outline-offset: -1px; }
.side-foot { margin-top: auto; padding: 0 1.3rem; font-size: 0.68rem; color: var(--text-mute); line-height: 1.7; }
.side-foot b { color: var(--text-soft); font-weight: 600; }

/* ---------- main ---------- */
main { flex: 1; min-width: 0; padding: clamp(1.4rem, 3vw, 2.6rem); }
.view { display: none; max-width: 1120px; }
.view.on { display: block; }
h1 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.015em; font-weight: 600; font-size: clamp(1.5rem, 3.4vw, 2.15rem); line-height: 1.05; text-wrap: balance; }
h2.section { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.95rem; color: var(--gold); font-weight: 500; margin: 1.6rem 0 0.8rem; }
.crumb { font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.55rem; }
.lede { color: var(--text-soft); max-width: 640px; line-height: 1.7; margin-top: 0.7rem; font-size: 0.93rem; }

.panel { border: 1px solid var(--line); background: var(--bg-2); padding: 1.25rem 1.35rem; margin-bottom: 1rem; }
.panel h2 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.98rem; color: var(--gold); font-weight: 500; margin-bottom: 1rem; }

label.f, label { display: block; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 0.4rem; margin-top: 0.7rem; }
input, select {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--text);
  padding: 0.55rem 0.6rem; font-family: var(--font-body); font-size: 0.92rem; border-radius: 2px;
  font-variant-numeric: tabular-nums;
}
input:focus-visible, select:focus-visible { outline: 1px solid var(--gold); }
.num { font-variant-numeric: tabular-nums; }

.btn { all: unset; cursor: pointer; font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; padding: 0.6rem 1.1rem; border: 1px solid var(--gold-lo); color: var(--gold-hi); transition: background 0.2s; border-radius: 2px; display: inline-block; text-align: center; }
.btn:hover { background: var(--gold-soft); }
.btn:focus-visible { outline: 1px solid var(--gold); }
.btn.ghost { border-color: var(--line-strong); color: var(--text-mute); }
.btn.ghost:hover { color: var(--text-soft); background: var(--bg-3); }
.btn.bad { border-color: var(--bad); color: var(--bad); }
.btn.block { display: block; width: 100%; margin-top: 1rem; }

/* KPI band */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 1.6rem 0; }
.kpi { background: var(--bg-2); padding: 0.95rem 1.05rem; }
.kpi .k { font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-mute); }
.kpi .v { font-family: var(--font-display); font-weight: 500; font-size: 1.45rem; margin-top: 0.3rem; font-variant-numeric: tabular-nums; }
.kpi .v.gold { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi .s { font-size: 0.7rem; color: var(--text-mute); margin-top: 0.15rem; }

.chip { display: inline-block; font-size: 0.62rem; letter-spacing: 0.1em; padding: 0.14rem 0.5rem; border: 1px solid; border-radius: 2px; font-weight: 600; }
.chip.MO { color: var(--mo); border-color: var(--mo); }
.chip.MAT { color: var(--mat); border-color: var(--mat); }
.chip.MTL { color: var(--mtl); border-color: var(--mtl); }
.chip.ST { color: var(--st); border-color: var(--st); }
.chip.FR { color: var(--fr); border-color: var(--fr); }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute); font-weight: 500; text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 0.48rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; }
.scroll { overflow-x: auto; }

/* dossier cards */
.dossier { border: 1px solid var(--line); background: var(--bg-2); padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.dossier .grow { flex: 1 1 260px; min-width: 0; }
.dossier .nm { font-size: 1rem; }
.dossier .meta { font-size: 0.75rem; color: var(--text-mute); margin-top: 0.2rem; }
.dossier .st { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; padding: 0.2rem 0.55rem; border: 1px solid; border-radius: 2px; }
.st.done { color: var(--ok); border-color: var(--ok); }
.st.run { color: var(--gold); border-color: var(--gold); }
.dossier .pv { font-family: var(--font-display); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.bar { height: 3px; background: var(--bg-3); margin-top: 0.5rem; }
.bar i { display: block; height: 100%; background: var(--gold-grad); }
.dossier.click { cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.dossier.click:hover { border-color: var(--gold-lo); background: var(--bg-3); }

/* row list (bibliothèque, etc.) */
.row-item { display: flex; align-items: center; gap: 0.9rem; padding: 0.6rem 0.2rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--bg-3); }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .nm { font-size: 0.9rem; }
.row-item .sub { font-size: 0.74rem; color: var(--text-mute); margin-top: 0.15rem; }
.fam-title { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin: 1rem 0 0.3rem; font-weight: 600; }
.icon-btn { all: unset; cursor: pointer; color: var(--bad); font-size: 1.05rem; padding: 0 0.5rem; }

.foot-note { margin-top: 2rem; font-size: 0.72rem; color: var(--text-mute); line-height: 1.7; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.msg { min-height: 18px; font-size: 0.82rem; margin-top: 0.6rem; color: var(--bad); }
.msg.ok { color: var(--ok); }
.back { all: unset; cursor: pointer; font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-mute); }
.back:hover { color: var(--gold-hi); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; margin-top: 1.4rem; }
.params { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.9rem; }
.hidden { display: none !important; }
.rowline { display: flex; justify-content: space-between; padding: 0.45rem 0.2rem; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.rowline .v { font-variant-numeric: tabular-nums; color: var(--text-soft); }

/* mobile topnav */
.topnav { display: none; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.topnav button { all: unset; cursor: pointer; padding: 0.45rem 0.8rem; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-mute); border: 1px solid var(--line-strong); border-radius: 2px; }
.topnav button.on { color: var(--gold-hi); border-color: var(--gold); }
@media (max-width: 760px) { aside { display: none; } .topnav { display: flex !important; } }
@media (prefers-reduced-motion: no-preference) { .view.on { animation: fade 0.25s ease; } @keyframes fade { from { opacity: 0; transform: translateY(4px); } } }

/* ---------- barre d'onglets du dossier ---------- */
.tabbar { display: flex; gap: 0; border-bottom: 1px solid var(--line-strong); margin: 1.2rem 0 1.6rem; flex-wrap: wrap; }
.tabbar button { all: unset; cursor: pointer; padding: 0.65rem 1.2rem; font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabbar button:hover { color: var(--text-soft); }
.tabbar button.on { color: var(--gold-hi); border-bottom-color: var(--gold); }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

/* ---------- gantt (planning) ---------- */
.gantt-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.45rem; }
.gantt-lab { flex: 0 0 260px; font-size: 0.78rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-track { flex: 1; background: var(--bg-3); height: 22px; position: relative; min-width: 160px; }
.gantt-bar { position: absolute; top: 0; height: 100%; background: var(--gold-grad); display: flex; align-items: center; justify-content: center; font-size: 0.62rem; color: #16130b; font-weight: 600; min-width: 3px; white-space: nowrap; overflow: hidden; }
.vigmemo { border: 1px solid var(--line); border-left: 2px solid var(--warn); background: var(--bg-2); padding: 0.7rem 0.95rem; margin-bottom: 0.6rem; font-size: 0.82rem; color: var(--text-soft); line-height: 1.55; }
.vigmemo .n { color: var(--gold); font-family: var(--font-display); margin-right: 0.5rem; }

/* IA — lecture assistée du CCTP */
.ia-bloc { border: 1px solid var(--line-strong); border-left: 2px solid var(--gold); background: var(--bg-2); padding: 1rem 1.15rem; margin-top: 1.2rem; }
.ia-tete b { color: var(--gold-hi); font-size: 0.9rem; }
.ia-sous { color: var(--text-mute); font-size: 0.78rem; margin-top: 0.3rem; line-height: 1.5; max-width: 560px; }
.ia-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; margin-top: 0.9rem; }
.ia-file { width: auto; flex: 1 1 220px; min-width: 0; padding: 0.45rem 0.6rem; font-size: 0.78rem; }
.ia-file::file-selector-button { background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--text-soft); padding: 0.3rem 0.7rem; margin-right: 0.7rem; border-radius: 2px; cursor: pointer; font-size: 0.72rem; }
.ia-etat { font-size: 0.78rem; color: var(--text-soft); flex-basis: 100%; }
.ia-barre { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin: 1rem 0 0.7rem; flex-wrap: wrap; }
.ia-tout { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute); }
.ia-tout input, .ia-prop input { width: auto; margin: 0; accent-color: var(--gold); }
.ia-liste { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.ia-prop { display: flex; align-items: flex-start; gap: 0.7rem; margin: 0; padding: 0.6rem 0.8rem; background: var(--bg-2); cursor: pointer; text-transform: none; letter-spacing: normal; }
.ia-prop:hover { background: var(--bg-3); }
.ia-prop input { margin-top: 0.2rem; }
.ia-prop-txt { font-size: 0.84rem; color: var(--text-soft); line-height: 1.5; }
.ia-prop-txt .n { color: var(--gold); font-family: var(--font-display); margin-right: 0.5rem; }
.ia-prop-txt b { color: var(--text); font-weight: 500; }
.ia-prop-meta { color: var(--text-mute); font-size: 0.75rem; margin-top: 0.2rem; }

/* Pointages — suivi de chantier */
.pt-chantier { border: 1px solid var(--line); background: var(--bg-2); padding: 0.85rem 1rem; margin-bottom: 0.7rem; }
.pt-ch-tete { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.pt-ch-tete b { color: var(--text); font-size: 0.95rem; }
.pt-statut { font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 2px; border: 1px solid; }
.pt-statut.encours { color: var(--gold-hi); border-color: var(--gold-lo); }
.pt-statut.fini { color: var(--text-mute); border-color: var(--line-strong); }
.pt-montant { color: var(--text-soft); font-size: 0.8rem; font-family: var(--font-display); }
.pt-actions { margin-left: auto; display: flex; gap: 0.9rem; }
.lien { all: unset; cursor: pointer; font-size: 0.72rem; color: var(--text-mute); }
.lien:hover { color: var(--gold-hi); }
.lien.bad:hover { color: var(--bad); }
.pt-barre-wrap { height: 8px; background: var(--bg-3); border: 1px solid var(--line); margin: 0.6rem 0 0.4rem; position: relative; overflow: hidden; }
.pt-barre { height: 100%; background: var(--gold-grad); }
.pt-barre.over { background: linear-gradient(135deg, #e08a5a 0%, var(--bad) 100%); }
.pt-ch-meta { font-size: 0.78rem; color: var(--text-soft); }

/* ---------- cartes de tâches (chiffrage détaillé) ---------- */
details.task { border: 1px solid var(--line); background: var(--bg-2); margin-bottom: 0.85rem; }
details.task > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 1rem; padding: 0.85rem 1.1rem; flex-wrap: wrap; }
details.task > summary::-webkit-details-marker { display: none; }
details.task > summary:hover { background: var(--bg-3); }
.t-num { font-family: var(--font-display); color: var(--gold); font-size: 0.9rem; min-width: 52px; }
.t-name { flex: 1 1 260px; font-size: 0.9rem; }
.t-pv { font-family: var(--font-display); font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-ds { font-size: 0.72rem; color: var(--text-mute); white-space: nowrap; }
.t-body { padding: 0 1.1rem 1.1rem; }
.wf { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 0.4rem 0 1rem; flex-wrap: wrap; }
.wf div { flex: 1 1 110px; background: var(--bg-1); padding: 0.5rem 0.7rem; }
.wf .k { font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-mute); }
.wf .v { font-size: 0.9rem; margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
.qty-in { width: 84px !important; text-align: right; padding: 0.3rem 0.4rem !important; }
details.task.is-option { border-style: dashed; border-color: var(--gold-lo); opacity: 0.85; }
details.task.is-horsrep { border-style: dashed; opacity: 0.5; }
.vig { border-left: 2px solid var(--warn); background: var(--bg-2); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.7rem 0.9rem; margin-bottom: 0.8rem; font-size: 0.82rem; color: var(--text-soft); line-height: 1.5; }

/* ---------- devis papier (récap imprimable) ---------- */
.papier { background: #f6f3ec; color: #1c1a15; padding: 2rem 2.2rem; margin-top: 1rem; font-size: 0.9rem; line-height: 1.6; max-width: 780px; }
.papier .ph { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; font-size: 1.4rem; }
.papier .ent { font-weight: 600; font-size: 1.05rem; }
.papier .meta { color: #6b6353; font-size: 0.82rem; margin-top: 0.2rem; }
.papier table { width: 100%; border-collapse: collapse; font-size: 0.84rem; margin-top: 1.2rem; }
.papier th { color: #6b6353; border-bottom: 1px solid #c9c2b2; text-align: left; padding: 0.4rem 0.5rem; text-transform: uppercase; font-size: 0.66rem; letter-spacing: 0.1em; }
.papier td { border-bottom: 1px solid #e0daca; padding: 0.4rem 0.5rem; vertical-align: top; }
.papier td.r, .papier th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.papier .tot td { border: none; padding: 0.25rem 0.5rem; }
.papier .tot .g { font-weight: 700; font-size: 1.05rem; }
.papier .or { color: #9e7a31; }
.papier .cgu { margin-top: 1.4rem; font-size: 0.72rem; color: #6b6353; border-top: 1px solid #c9c2b2; padding-top: 0.7rem; }
@media print {
  aside, .topnav, #authVoile, .back, .btn, .no-print { display: none !important; }
  body { display: block; }
  main { padding: 0; }
  .view { display: none !important; }
  .view.on { display: block !important; }
  .papier { margin: 0; max-width: none; box-shadow: none; }
}

/* ---------- connexion (voile) ---------- */
#authVoile { position: fixed; inset: 0; background: var(--bg-0); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1.5rem; }
.authBox { width: 100%; max-width: 380px; border: 1px solid var(--line); background: var(--bg-1); padding: 1.8rem 1.6rem; }
.authBox .mark { font-family: var(--font-display); text-transform: uppercase; font-size: 1.35rem; letter-spacing: 0.06em; }
.authBox .mark b { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.authBox .sub { font-size: 0.62rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-mute); margin: 0.35rem 0 1.4rem; }
