/* ==========================================================================
   Espace chiffrage — CapDurence Project
   Charte : DM Sans / DM Serif Display, bleu #2745A5 → violet #9C3F9E
   ========================================================================== */

:root {
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --surface-alt: #F8F9FC;

  --ink: #1D2340;
  --ink-2: #3B4260;
  --ink-3: #4A5170;
  --muted: #6A7090;
  --faint: #9AA1BE;

  --line: #E3E5F0;
  --line-2: #F0F1F7;
  --line-3: #F5F6FA;
  --dash: #C9CEE4;
  --chip: #EDEFF6;

  --navy: #17204A;
  --navy-2: #232E63;
  --navy-3: #2A3573;
  --navy-4: #1F2A5C;
  --nav-ink: #B7BEE2;
  --nav-dim: #8F98C6;
  --nav-icon: #5A639B;

  --blue: #2745A5;
  --blue-dark: #1E3585;
  --blue-soft: #E5EAF8;
  --blue-bg: #EDF0FA;

  --purple: #9C3F9E;
  --purple-dark: #7C2F7E;
  --purple-soft: #F2E5F2;
  --purple-bg: #F6EBF6;

  --green: #2E7D50;
  --green-dark: #245B3B;
  --green-soft: #E2F0E7;
  --green-line: #C2DCCB;

  --red: #8C2B3A;
  --red-soft: #F9E3E6;
  --red-line: #ECC2C9;

  --amber: #8A5B1E;
  --amber-soft: #F6ECD3;

  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --serif: 'DM Serif Display', Georgia, serif;

  --grad: linear-gradient(90deg, var(--blue), var(--purple));
  --grad-hover: linear-gradient(90deg, var(--blue-dark), var(--purple-dark));

  --r-sm: 7px;
  --r: 10px;
  --r-md: 12px;
  --r-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  font-family: var(--sans);
  color: var(--ink);
}

a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--purple-dark); text-decoration: underline; }

input, select, textarea, button { font-family: var(--sans); }
::placeholder { color: var(--faint); }

@keyframes pulseDot { 0% { opacity: 1; } 50% { opacity: .25; } 100% { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- primitives ------------------------------------------------- */

.col { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

h1.title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: -.01em;
}

.lede { font-size: 14.5px; color: var(--muted); }
.crumb { font-size: 12.5px; color: var(--faint); }

.label-cap {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.th {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ---------- buttons ---------------------------------------------------- */

.btn {
  border: none;
  border-radius: var(--r);
  padding: 12px 20px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { background: var(--grad-hover); }
.btn-primary:disabled,
.btn-primary[disabled] { background: #DCDFEC; color: var(--faint); cursor: not-allowed; }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 16px;
}
.btn-ghost:hover { border-color: var(--purple); color: var(--purple); }

.btn-dark { background: var(--navy); color: #fff; font-size: 13.5px; padding: 11px 16px; }
.btn-dark:hover { background: var(--navy-2); }

.btn-green { background: var(--green-dark); color: #fff; font-size: 14px; }
.btn-green:hover { background: #1B472E; }

.btn-danger {
  background: var(--surface);
  border: 1px solid var(--red-line);
  color: var(--red);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger:hover { background: var(--red-soft); }

.btn-outline {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  white-space: nowrap;
}
.btn-outline:hover { border-color: var(--blue); background: var(--surface-alt); }

.btn-small {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
}
.btn-small:hover { border-color: var(--purple); color: var(--purple); }

/* ---------- fields ----------------------------------------------------- */

.field {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 15px;
  background: var(--surface-alt);
  color: var(--ink);
  outline: none;
  width: 100%;
}
.field:focus { border-color: var(--purple); }

.select {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.cell-input {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 7px;
  font-size: 12.5px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-input:focus { border-color: var(--purple); }

.cell-select {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 5px;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  cursor: pointer;
  width: 100%;
}

.bare-input {
  border: none;
  background: transparent;
  font-size: 12.8px;
  color: var(--ink);
  font-weight: 500;
  outline: none;
  width: 100%;
  padding: 0;
}
.bare-input:focus { box-shadow: inset 0 -1px 0 var(--purple); }
.bare-input.u { color: var(--muted); font-weight: 400; }

.rate-input {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: 13px;
  width: 64px;
  text-align: right;
  outline: none;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
}

.pct-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
  background: var(--surface);
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

.status-select {
  border: none;
  border-radius: 99px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  text-align: center;
}

/* ---------- cards ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card-flat { border-radius: var(--r-lg); overflow: hidden; padding: 0; gap: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-2);
}
.card-title { font-weight: 700; font-size: 16px; }
.card-note { font-size: 12.5px; color: var(--faint); }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-val { font-family: var(--serif); font-size: 27px; }
.stat-sub { font-size: 12.5px; color: var(--faint); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
}
.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kpi-val { font-family: var(--serif); font-size: 24px; margin-top: 4px; }

.hint {
  background: var(--surface-alt);
  border: 1px dashed var(--dash);
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}
.hint strong { color: var(--ink-3); }

.banner {
  border-radius: var(--r-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.banner-error { background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red); }
.banner-error a { color: var(--red); text-decoration: underline; }
.banner-ok {
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-radius: 14px;
  padding: 18px 22px;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- tags & pills ----------------------------------------------- */

.ext {
  font-size: 10.5px;
  font-weight: 800;
  border-radius: var(--r-sm);
  padding: 5px 8px;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.ext-PDF { background: var(--red-soft); color: var(--red); }
.ext-XLS { background: var(--green-soft); color: var(--green); }
.ext-DOC { background: var(--blue-soft); color: var(--blue); }
.ext-IMG { background: var(--purple-soft); color: var(--purple); }
.ext-ODS { background: var(--green-soft); color: var(--green); }
.ext-other { background: var(--chip); color: var(--muted); }

.tag {
  font-size: 11px;
  font-weight: 800;
  border-radius: var(--r-sm);
  padding: 4px 9px;
  white-space: nowrap;
  align-self: flex-start;
  letter-spacing: .03em;
}
.tag-DELAI { background: var(--red-soft); color: var(--red); }
.tag-TECHNIQUE { background: var(--blue-soft); color: var(--blue); }
.tag-SITE { background: var(--amber-soft); color: var(--amber); }
.tag-ADMIN { background: var(--purple-soft); color: var(--purple); }
.tag-other { background: var(--chip); color: var(--muted); }

.pill {
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 99px;
  padding: 4px 10px;
  flex-shrink: 0;
}
.pill-ok { background: var(--green-soft); color: var(--green-dark); }
.pill-obs { background: var(--red-soft); color: var(--red); }
.pill-cond { background: var(--amber-soft); color: var(--amber); }

.pill-zone {
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-size: 12px;
  font-weight: 700;
  border-radius: 99px;
  padding: 5px 11px;
  white-space: nowrap;
}

.pill-model {
  background: var(--grad);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 99px;
  padding: 5px 12px;
  white-space: nowrap;
}

.pill-live {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 99px;
  padding: 6px 13px;
}
.pill-live .dot {
  width: 7px; height: 7px; border-radius: 99px;
  background: var(--green);
  animation: pulseDot 2s infinite;
}
.pill-live.off { background: var(--amber-soft); color: var(--amber); }
.pill-live.off .dot { background: var(--amber); animation: none; }

.x {
  cursor: pointer;
  color: var(--faint);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  line-height: 1;
}
.x:hover { background: var(--red-soft); color: var(--red); }

/* ---------- login ------------------------------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(900px 520px at 12% -10%, var(--blue-soft) 0%, rgba(227,233,250,0) 60%),
    radial-gradient(760px 520px at 96% 112%, #F0E2F1 0%, rgba(240,226,241,0) 55%),
    var(--bg);
}
.login-col { width: 430px; max-width: 100%; display: flex; flex-direction: column; gap: 22px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px;
  box-shadow: 0 22px 55px rgba(35,45,105,.12);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: slideUp .4s ease;
}
.login-title { font-family: var(--serif); font-size: 24px; }
.login-foot { font-size: 12px; color: var(--faint); text-align: center; }
.login-logo { height: 148px; object-fit: contain; align-self: center; }
.login-error {
  font-size: 13px;
  color: var(--red);
  background: rgba(140,43,58,.08);
  border: 1px solid rgba(140,43,58,.25);
  border-radius: 8px;
  padding: 9px 12px;
}

/* ---------- app shell -------------------------------------------------- */

.shell { display: flex; min-height: 100vh; background: var(--bg); }

.side {
  width: 250px;
  flex-shrink: 0;
  background: var(--navy);
  color: var(--nav-ink);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; }
.brand img { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: 10px; color: var(--nav-dim); letter-spacing: .34em; font-weight: 600; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--nav-ink);
  border: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-item.active { background: var(--navy-3); color: #fff; }
.nav-ico { width: 20px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto;
  background: var(--purple);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 99px;
  padding: 2px 7px;
}

.side-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 10px;
  border-top: 1px solid var(--navy-2);
}
.avatar {
  width: 32px; height: 32px; border-radius: 99px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.side-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.side-user-role { font-size: 11px; color: var(--nav-dim); }
.link-muted {
  cursor: pointer; font-size: 11px; color: var(--nav-dim);
  padding: 0; background: none; border: none;
}
.link-muted:hover { color: #fff; text-decoration: underline; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.page {
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
/* L'animation d'entrée ne joue qu'au changement d'écran : le rendu se répète
   à chaque frappe et à chaque tick de progression, elle repartirait sans fin. */
.page.enter { animation: slideUp .35s ease; }
.page-narrow { max-width: 980px; }
.page-mid { max-width: 1080px; }
.page-slim { max-width: 860px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- dashboard -------------------------------------------------- */

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.dossier-grid { grid-template-columns: 2.2fr 1fr .75fr 1.25fr .9fr 34px; }
.dossier-head, .dossier-row {
  display: grid;
  gap: 12px;
  align-items: center;
}
.dossier-head { padding: 10px 22px; border-bottom: 1px solid var(--line-2); }
.dossier-row {
  padding: 13px 22px;
  border-bottom: 1px solid var(--line-3);
  cursor: pointer;
}
.dossier-row:hover { background: var(--surface-alt); }
.dossier-name { font-weight: 600; font-size: 14px; }
.dossier-moa { font-size: 12px; color: var(--faint); }
.dossier-cell { font-size: 13px; color: var(--muted); }
.dossier-amount { text-align: right; font-weight: 700; font-size: 14px; }

/* ---------- dropzone --------------------------------------------------- */

.drop {
  border: 2px dashed var(--dash);
  border-radius: var(--r-lg);
  background: var(--surface-alt);
  padding: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: center;
}
.drop:hover, .drop.over { border-color: var(--purple); background: #FBF7FC; }
.drop-ico {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--blue-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.drop-title { font-weight: 700; font-size: 16px; }
.drop-sub { font-size: 13px; color: var(--muted); }
.drop-link { font-size: 12.5px; color: var(--purple); font-weight: 600; background: none; border: none; cursor: pointer; }
.drop-link:hover { text-decoration: underline; }

.drop-row {
  border: 2px dashed var(--dash);
  border-radius: var(--r-lg);
  background: var(--surface-alt);
  padding: 30px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
}
.drop-row:hover, .drop-row.over { border-color: var(--purple); background: #FBF7FC; }
.drop-row-ico {
  width: 46px; height: 46px; border-radius: var(--r-md);
  background: var(--blue-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; flex-shrink: 0;
}

/* ---------- exemples de démonstration ---------------------------------- */

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 2px 4px;
}
.demo-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.demo-card:hover { border-color: var(--purple); background: #FBF7FC; }
.demo-card.active { border-color: var(--purple); background: var(--purple-bg); }
.demo-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.demo-card-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.demo-card-lot { font-size: 12.5px; font-weight: 600; color: var(--blue); }
.demo-card-moa { font-size: 12px; color: var(--faint); }
.demo-card-pitch { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.demo-card-cta { font-size: 12.5px; font-weight: 700; color: var(--purple); margin-top: 6px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line-3);
}
.file-name { font-weight: 600; font-size: 14px; }
.file-meta { font-size: 12px; color: var(--faint); }

/* ---------- run -------------------------------------------------------- */

.tasks { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.task-title { font-weight: 700; font-size: 16.5px; }
.task-sub { font-size: 12.5px; color: var(--muted); }
.task-step { color: var(--muted); display: flex; align-items: center; gap: 7px; }
.task-dot { width: 8px; height: 8px; border-radius: 99px; flex-shrink: 0; animation: pulseDot 1.2s infinite; }
.task-dot.done { animation: none; background: var(--green); }
.bar { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; transition: width .2s linear; }
.log {
  background: var(--surface-alt);
  border: 1px solid var(--chip);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 96px;
}
.log-line { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; font-variant-numeric: tabular-nums; }
.log-line .ok { color: var(--green); }

/* ---------- results ---------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  background: #EAECF4;
  border-radius: var(--r-md);
  padding: 5px;
  width: fit-content;
}
.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.tab.on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px rgba(35,45,105,.14); }

.syn-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.info-box { background: var(--surface-alt); border-radius: var(--r); padding: 12px 14px; }
.info-label {
  font-size: 11.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .05em;
}
.info-val { font-weight: 700; font-size: 15px; margin-top: 3px; }

.body-text { font-size: 14px; line-height: 1.65; color: var(--ink-2); }

.exig { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-3); }
.exig-txt { font-size: 13.5px; line-height: 1.55; color: var(--ink-2); flex: 1; }
.exig-ref { font-size: 12px; color: var(--faint); white-space: nowrap; }

.risk {
  display: flex; gap: 9px;
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
  padding: 7px 0; border-top: 1px solid var(--line-3);
}

.gng-card {
  background: linear-gradient(135deg, var(--navy), #3A2350);
  color: #EDEFF8;
  border-radius: var(--r-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gng-verdict { font-family: var(--serif); font-size: 38px; }
.gng-score { font-family: var(--serif); font-size: 21px; }
.gng-meta { font-size: 12px; color: #AEB6DC; }
.gng-note { font-size: 12.5px; color: #AEB6DC; line-height: 1.55; }
.gng-bar { height: 8px; background: var(--navy-3); border-radius: 99px; overflow: hidden; }
.gng-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #5C7BE0, #C173C2); border-radius: 99px; }

.gng-grid { grid-template-columns: 2fr .8fr .8fr 1.4fr 2.2fr; }
.gng-head, .gng-row { display: grid; gap: 10px; align-items: center; }
.gng-head { padding: 10px 22px; border-bottom: 1px solid var(--line-2); }
.gng-row { padding: 12px 22px; border-bottom: 1px solid var(--line-3); font-size: 13.5px; }
.gng-crit { font-weight: 600; }
.gng-com { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.gng-mini { display: block; height: 7px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.gng-mini > i { display: block; height: 100%; border-radius: 99px; }
.gng-total {
  display: flex; justify-content: flex-end; align-items: center; gap: 24px;
  padding: 14px 22px; background: var(--surface-alt);
}

/* ---------- bordereau -------------------------------------------------- */

/* Repère · Désignation · Réf · Unité · Qté · PU · Fourniture ·
   Intervenant · Ratio · Taux · MO totale · Pose · Montant · Contexte · Justification
   Repère et Désignation en largeur fixe (plutôt que fr) : c'est ce qui permet de
   calculer leur décalage `left` pour les figer pendant le défilement horizontal. */
.bd-grid {
  grid-template-columns:
    52px 210px .85fr .38fr .55fr .62fr .8fr
    1.2fr .55fr .6fr .6fr .8fr .85fr 1.4fr 1.6fr 56px;
}
/* Vue resserrée : masque Contexte et Justification, les deux colonnes les
   plus larges — le bordereau tient alors sur un écran de portable. */
.bd-grid.compact {
  grid-template-columns:
    52px 210px .85fr .38fr .55fr .62fr .8fr
    1.2fr .55fr .6fr .6fr .8fr .85fr 56px;
}
.bd-grid.compact .bd-ctx, .bd-grid.compact .justif { display: none; }

/* Actions de ligne : ajout d'un sous-poste et suppression. */
.bd-actions { display: flex; gap: 4px; justify-content: flex-end; }
.bd-x {
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--faint); border-radius: 7px;
  width: 22px; height: 22px; line-height: 1;
  font-size: 12px; cursor: pointer;
}
.bd-x:hover { color: var(--red); border-color: var(--red); }
.bd-x.add:hover { color: var(--blue); border-color: var(--blue); }
/* Sous-poste : rattaché visuellement au poste parent. */
.bd-row.sub .bd-des { padding-left: 14px; font-style: italic; }
.bd-row.sub .bd-rep { color: var(--muted); font-size: 11.5px; }
.band-x, .subband-x {
  border: 1px solid rgba(255, 255, 255, .5); background: transparent; color: #fff;
  border-radius: 7px; width: 22px; height: 22px; line-height: 1;
  font-size: 12px; cursor: pointer;
}
.band-x:hover { background: rgba(255, 255, 255, .18); }
.subband-x { border-color: currentColor; color: inherit; }
.subband-x:hover { background: rgba(255, 255, 255, .55); }
.bd-head, .bd-row { display: grid; gap: 8px; align-items: center; }
.bd-head {
  padding: 10px 22px;
  border-bottom: 1px solid var(--line-2);
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.bd-row { padding: 9px 22px; border-bottom: 1px solid var(--line-3); font-size: 12.8px; }
.bd-row:hover { background: var(--surface-alt); }
.bd-row:hover .bd-rep, .bd-row:hover .bd-des { background: var(--surface-alt); }
.bd-rep { color: var(--faint); font-variant-numeric: tabular-nums; font-weight: 600; }
/* Repère et Désignation restent visibles pendant le défilement horizontal —
   15 colonnes ne tiennent pas sur un écran de portable, mais on garde au
   moins de quoi identifier chaque ligne sans faire d'aller-retour. */
.bd-rep, .bd-des {
  position: sticky;
  background: var(--surface);
  z-index: 1;
}
.bd-rep { left: 0; }
.bd-des {
  left: 52px;
  box-shadow: 4px 0 6px -4px rgba(20, 21, 26, .12);
}
.bd-head .bd-rep, .bd-head .bd-des { z-index: 2; }
.bd-derived { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); }
/* PU piloté par la base de prix : verrouillé, mais visiblement rattaché. */
.bd-derived.locked { color: var(--blue); cursor: help; }
.cell-input.ref { text-align: left; font-size: 11.5px; font-variant-numeric: normal; }
.bd-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bd-ctx { font-size: 11.8px; line-height: 1.4; color: var(--faint); }
.bd-ctx.warn { color: var(--red); }
.bare-input.justif { font-size: 11.8px; line-height: 1.4; color: var(--ink-3); }
.bare-input.justif::placeholder { color: var(--faint); }

.band {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 22px; color: #fff;
}
/* Lots principaux (A, B, C…) : la couleur tourne sur une palette de 4 teintes. */
.band-0 { background: var(--blue); }
.band-1 { background: var(--purple); }
.band-2 { background: var(--green); }
.band-3 { background: var(--amber); }
.band-title, .band-total { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.band input {
  border: none; background: transparent; color: #fff;
  font-weight: 700; font-size: 14px; outline: none; flex: 1; min-width: 100px;
}
.band input::placeholder { color: rgba(255,255,255,.7); }

.subband {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 22px; border-bottom: 1px solid var(--line-2);
}
.subband-0 { background: var(--blue-bg); color: var(--blue); }
.subband-1 { background: var(--purple-bg); color: var(--purple-dark); }
.subband-2 { background: var(--green-soft); color: var(--green-dark); }
.subband-3 { background: var(--amber-soft); color: var(--amber); }
.subband-id { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.subband input {
  border: none; background: transparent;
  font-weight: 700; font-size: 12.5px; color: inherit;
  outline: none; flex: 1; min-width: 80px;
}
.subband-total { font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }

.lot-vide {
  padding: 12px 22px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--faint);
  border-bottom: 1px solid var(--line-3);
}

.add-line {
  padding: 8px 22px;
  font-size: 12.5px;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--line-3);
  background: none;
  border-left: none; border-right: none; border-top: none;
  width: 100%;
  text-align: left;
}
.add-line:hover { background: var(--surface-alt); }
.add-lot-btn { color: var(--purple-dark); border-top: 1px solid var(--line-2); }

.bd-foot {
  display: flex; justify-content: flex-end; gap: 30px;
  padding: 15px 22px; background: var(--surface-alt); font-size: 14px;
}
.bd-foot-total { font-family: var(--serif); font-size: 17px; font-variant-numeric: tabular-nums; }

.recap-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: start; }
.recap-line {
  display: flex; justify-content: space-between;
  font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid var(--line-3);
}
.recap-line-sub {
  padding: 4px 0 4px 16px;
  font-size: 12px;
  border-bottom: none;
}
.pct-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 4px 0; }
.pct-label { font-size: 11.5px; color: var(--faint); font-weight: 600; }
.pct-label span { color: var(--dash); }
.total-line {
  display: flex; justify-content: space-between;
  font-size: 14px; padding: 9px 0; border-top: 1px solid var(--line-2);
}
.tva-line { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.ttc-line {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; padding: 10px 14px;
  background: linear-gradient(90deg, var(--blue-bg), var(--purple-bg));
  border-radius: var(--r);
}
.ttc-val { font-family: var(--serif); font-size: 18px; font-variant-numeric: tabular-nums; }

.rate-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 13px; padding: 5px 0; border-top: 1px solid var(--line-3);
}
.rate-eff { font-size: 11.8px; color: var(--faint); white-space: nowrap; width: 92px; text-align: right; }
.rate-head {
  font-size: 10.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .04em;
  width: 64px; text-align: center;
}

/* ---------- base de prix ------------------------------------------------ */

.prix-grid { grid-template-columns: 1fr 2.6fr .5fr .8fr .3fr; }
/* Famille « tâches » : colonnes en plus pour la fourniture et l'intervenant. */
.tache-grid { grid-template-columns: 1fr 1.8fr .4fr .9fr .5fr 1fr .3fr; }
.prix-head, .prix-row { display: grid; gap: 10px; align-items: center; }
.prix-head { padding: 10px 20px; border-bottom: 1px solid var(--line-2); }
.prix-row { padding: 8px 20px; border-bottom: 1px solid var(--line-3); font-size: 13px; }
.prix-row:hover { background: var(--surface-alt); }

.famille-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 4px;
}
.famille-label-input {
  font-size: 15px; font-weight: 700; border: none; background: none;
  padding: 2px 4px; border-radius: 6px; color: var(--ink);
}
.famille-label-input:focus { background: var(--surface-alt); outline: none; }

/* Sélecteur d'affaire(s) historique(s) de référence — liste défilante à
   cases à cocher, plusieurs choix possibles. */
.affaire-ref-list {
  max-height: 220px; overflow-y: auto; display: flex; flex-direction: column;
  border: 1px solid var(--line-2); border-radius: 10px;
}
.affaire-ref-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--line-3); cursor: pointer; font-size: 13px;
}
.affaire-ref-row:last-child { border-bottom: none; }
.affaire-ref-row:hover { background: var(--surface-alt); }
.affaire-ref-row input { flex-shrink: 0; }

.map-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px) { .map-grid { grid-template-columns: repeat(2, 1fr); } }

.empty-state {
  padding: 40px; text-align: center;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.empty-state .t { font-weight: 700; font-size: 15px; }
.empty-state .s { font-size: 13.5px; color: var(--muted); max-width: 420px; line-height: 1.55; }

.pending {
  background: #FBF7FC;
  border: 1px solid #E4CDE4;
  border-radius: 14px;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.pending-title { font-weight: 700; font-size: 14px; color: var(--purple-dark); }
.pending-row { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }

/* ---------- clés API --------------------------------------------------- */

.agent-box {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--chip);
  border-radius: var(--r-md);
}
.agent-task { font-weight: 700; font-size: 14px; }
.agent-desc { font-size: 12.5px; color: var(--muted); }
.agent-note { font-size: 11.8px; color: var(--faint); }
.key-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 13px;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.key-input:focus { border-color: var(--purple); }
.provider-ico {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.inline-note {
  font-size: 12.5px; color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--chip);
  border-radius: var(--r);
  padding: 10px 14px;
}
.switch {
  width: 46px; height: 26px; border-radius: 99px;
  background: var(--dash); padding: 3px; cursor: pointer;
  transition: background .2s; flex-shrink: 0; border: none;
}
.switch.on { background: var(--purple); }
.switch > i {
  display: block; width: 20px; height: 20px; border-radius: 99px;
  background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.on > i { transform: translateX(20px); }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--chip); border-radius: var(--r-md);
}
/* Statut d'enregistrement (barre latérale) — réglages et dossier en cours. */
.save-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600;
  padding: 2px 2px;
}
.save-status.ok { color: var(--green); }
.save-status.saving { color: var(--faint); font-weight: 500; }
.save-status.err { color: var(--red); }

/* ---------- responsive ------------------------------------------------- */

@media (max-width: 1200px) {
  .syn-grid, .recap-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .tasks { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .map-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tablette : la barre latérale se réduit aux icônes, les en-têtes de
   tableaux disparaissent (les lignes restent lisibles seules). */
@media (max-width: 900px) {
  .page { padding: 24px 20px; }
  .side { width: 68px; padding: 18px 8px; }
  .side .brand-text, .side .nav-item span:not(.nav-ico):not(.nav-badge),
  .side .side-user .grow,
  .side .save-status span:last-child { display: none; }
  .side .brand, .side .nav-item, .side .side-user { justify-content: center; }
  .side .nav-badge { margin-left: 0; }
  /* Les liens légaux n'ont plus de place dans le rail d'icônes : ils restent
     accessibles depuis la navigation. */
  .side > .col > .row:last-child { display: none; }

  .dossier-head, .gng-head, .bd-head { display: none; }
  h1.title { font-size: 25px; }
  .card { padding: 18px; }
  .drop { padding: 28px 18px; }
}

/* Mobile : la navigation passe en barre horizontale défilante au-dessus du
   contenu, et les grilles de tableaux se replient en fiches empilées. */
@media (max-width: 700px) {
  .shell { flex-direction: column; }
  .side {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    z-index: 20;
  }
  .side .brand { padding: 0 6px 0 0; }
  .side .nav-item { width: auto; flex-shrink: 0; padding: 10px; min-height: 44px; }
  .side > .col { margin-top: 0 !important; flex-direction: row; align-items: center; gap: 8px; }
  .side .side-user { border-top: none; padding: 0 4px; flex-shrink: 0; }
  .side .row:last-child, .side .save-status { display: none; }

  .page { padding: 18px 14px; gap: 20px; }
  h1.title { font-size: 22px; }
  .lede { font-size: 13.5px; }
  .page-head { align-items: stretch; }
  .page-head .btn { justify-content: center; width: 100%; }

  .stats-grid { grid-template-columns: 1fr; }
  .info-grid, .pct-grid { grid-template-columns: 1fr; }

  /* Les tabs restent atteignables par défilement horizontal. */
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tab { flex-shrink: 0; padding: 10px 14px; }





  .card-head { padding: 12px 16px; }
  .file-row { padding: 12px 14px; gap: 10px; }
  .drop-row { flex-direction: column; text-align: center; padding: 22px 16px; }
  .demo-grid { grid-template-columns: 1fr; }
  .banner { flex-direction: column; align-items: flex-start; }
  .banner-ok { padding: 16px; }
  .gng-verdict { font-size: 30px; }
  .gng-row { grid-template-columns: 1fr; gap: 6px; padding: 12px 16px; }
  .gng-total { flex-wrap: wrap; gap: 12px; justify-content: space-between; }
  .bd-foot { flex-wrap: wrap; gap: 10px; justify-content: space-between; }
  .exig { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; }
  .exig-ref { grid-column: 1 / -1; text-align: right; }

  .rate-row { flex-wrap: wrap; }

  /* Confort tactile : cibles d'au moins 44px de haut. */
  .btn, .btn-ghost, .btn-dark, .btn-green, .btn-small { min-height: 44px; }
  .field { font-size: 16px; }

  .login-wrap { padding: 20px 16px; }
  .login-card { padding: 24px 20px; }
  .login-logo { height: 96px; }
}

/* Wide tables scroll inside their own container, never the page body. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x > * { min-width: 900px; }

/* Historique des dossiers : sous 900px, une ligne devient une fiche empilée
   plutôt qu'un tableau à faire défiler latéralement. */
@media (max-width: 900px) {
  .scroll-x:has(.dossier-grid) { overflow-x: visible; }
  .scroll-x:has(.dossier-grid) > * { min-width: 0; }
  .dossier-row.dossier-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 14px 18px;
  }
  .dossier-row .dossier-cell { font-size: 12.5px; text-align: right; align-self: start; }
  .dossier-row .dossier-amount { grid-column: 1 / -1; text-align: right; font-size: 15px; }
  .dossier-row [data-stop="1"] { justify-self: end; }
  .status-select { width: auto; }
}




/* Impression : la synthèse DCE et le préchiffrage n'impriment pas l'écran
   interactif (cartes, pastilles de couleur, colonnes de travail) mais un
   document dédié — voir `.print-only`/`.print-doc` ci-dessous et
   js/views.js `printSyntheseDoc`/`printBordereauDoc`. Toujours en portrait :
   un bordereau à 6 colonnes (repère, désignation, unité, qté, PU, montant)
   y tient sans réduire le texte à l'illisible. */
@page { size: portrait; margin: 16mm 14mm; }

@media print {
  .side, .tabs, .btn, .btn-outline, .no-print, .add-line, .drop, .drop-row, .page-head, .crumb { display: none !important; }
  .page { padding: 0; }
  .print-only { display: block !important; }
}

/* ---------- documents imprimés (synthèse DCE, préchiffrage) ------------- */

.print-only { display: none; }

.print-doc {
  font-family: "DM Sans", system-ui, sans-serif;
  color: #14182C;
  font-size: 12px;
  line-height: 1.5;
}
.print-head { margin-bottom: 16px; border-bottom: 2px solid #14182C; padding-bottom: 8px; }
.print-eyebrow { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #5A639B; font-weight: 700; }
.print-doc h1 { font-family: var(--serif); font-weight: 400; font-size: 21px; margin: 3px 0 2px; }
.print-date { font-size: 10.5px; color: #6A7090; }

.print-doc h2 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
  border-bottom: 1px solid #D6D9E8; padding-bottom: 4px; margin: 18px 0 8px;
}
.print-body { font-size: 12px; line-height: 1.6; margin: 0 0 10px; }

.print-meta-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 2px; }
.print-meta-table th { text-align: left; color: #6A7090; font-weight: 600; width: 38%; padding: 3px 0; vertical-align: top; }
.print-meta-table td { padding: 3px 0; }

.print-exig { margin-bottom: 7px; font-size: 11.5px; break-inside: avoid; }
.print-exig-head { display: flex; justify-content: space-between; gap: 10px; }
.print-exig-head .print-ref { color: #6A7090; font-size: 10px; white-space: nowrap; }
.print-exig-txt { color: #3B4260; margin-top: 1px; }

.print-list { margin: 0; padding-left: 18px; font-size: 11.5px; line-height: 1.6; }
.print-list li { margin-bottom: 4px; }

.print-verdict { font-size: 12.5px; margin: 4px 0 10px; }

.print-table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-top: 4px; }
.print-table th {
  text-align: left; border-bottom: 1.5px solid #14182C; padding: 4px 6px;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .03em;
}
.print-table td { padding: 4px 6px; border-bottom: 1px solid #E3E5F0; vertical-align: top; }
.print-table .right { text-align: right; font-variant-numeric: tabular-nums; }
.print-table tfoot td { border-top: 1.5px solid #14182C; border-bottom: none; font-weight: 700; }

.print-foot { margin-top: 14px; font-size: 10px; color: #6A7090; font-style: italic; }

/* Bordereau imprimé — groupé par lot, sous-totaux inclus. */
.print-bordereau tr.print-chap td {
  padding-top: 12px; padding-bottom: 3px; font-size: 11px; font-weight: 700;
  border-bottom: 1.5px solid #14182C; break-after: avoid;
}
.print-bordereau tr.print-souslot td {
  font-weight: 700; color: #2745A5; border-bottom: 1px solid #D6D9E8;
  background: #F5F6FA; break-after: avoid;
}
.print-bordereau tr.print-chap-total td { font-weight: 700; border-top: 1px solid #14182C; border-bottom: 2px solid #14182C; }
.print-bordereau tr.print-sub td:nth-child(2) { padding-left: 16px; font-style: italic; color: #6A7090; }
.print-bordereau tr { break-inside: avoid; }

.print-recap-table { width: 62%; margin-left: auto; margin-top: 18px; border-collapse: collapse; font-size: 11.5px; }
.print-recap-table td { padding: 4px 0; }
.print-recap-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.print-recap-table tr.print-total td { font-weight: 700; border-top: 1px solid #14182C; padding-top: 6px; }
