/* Gestion Achats & Stock — écran « Nouvel achat » (maquette V1 validée, mobile-first). */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("inter-latin-wght-normal.woff2") format("woff2");
}

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --line: #E3E8EE;
  --line-input: #D8E0E8;
  --ink: #18243A;
  --ink-2: #3B4B61;
  --ink-3: #4B5E72;
  --muted: #697589;
  --meta: #718092;
  --placeholder: #A0A9B5;
  --navy: #152D49;
  --navy-2: #284B6C;
  --accent: #E77A31;
  --accent-ring: #FBECDF;
  --accent-ink: #99511B;
  --accent-ink-2: #A95114;
  --badge-ink: #AB5B23;
  --peach: #FFF1E6;
  --peach-line: #EFCBAF;
  --peach-line-2: #F1D5BF;
  --eyebrow: #9A5B31;
  --green-bg: #ECF5F1;
  --green-line: #D4E6DD;
  --green-ink: #315847;
  --danger: #BD3030;
  --danger-bg: #FDEEEE;
  --danger-line: #F3C9C9;
  --chip: #E8EDF2;
  --chip-ink: #516072;
  --band: #FBFCFD;
  --tile: #F8FAFC;
  --tile-dash: #BFCAD6;
  --step-idle: #E9EDF2;
  --step-line: #D6DCE4;
  --overlay: rgba(24, 36, 58, 0.6);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, .photo-tile:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* ---------- En-tête ---------- */
.topbar {
  height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo {
  flex: none;
  width: 37px; height: 37px;
  border-radius: 10px;
  background: var(--navy);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.logo .amp { color: #F7A267; }
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.env-pill {
  flex: none;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--peach-line-2);
  background: var(--peach);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}

/* ---------- Page ---------- */
.page { max-width: 480px; margin: 0 auto; padding: 0 15px 150px; }
.boot { color: var(--muted); padding: 40px 3px; margin: 0; }

.hero { padding: 29px 3px 0; }
.eyebrow {
  margin: 0;
  color: var(--eyebrow);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.21em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 8px 0 0;
  font-size: 25px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.05em;
}
.lead { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 21px; }

.stepper { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.step .num {
  width: 25px; height: 25px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--step-idle);
  color: var(--muted);
  font-size: 12px; font-weight: 700;
}
.step.current { color: var(--navy); font-weight: 700; }
.step.current .num { background: var(--navy); color: #FFFFFF; }
.step-line { flex: 1 1 auto; min-width: 10px; height: 1px; background: var(--step-line); margin: 0 2px; }

.notice {
  display: flex;
  gap: 10px;
  margin-top: 19px;
  padding: 12px 16px 12px 13px;
  border: 1px solid var(--green-line);
  border-radius: 16px;
  background: var(--green-bg);
  color: var(--green-ink);
  font-size: 12px;
  line-height: 17.5px;
}
.notice svg { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.notice p { margin: 0; }

/* ---------- Cartes ---------- */
.card {
  margin-top: 20px;
  padding: 21px 17px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(24, 36, 58, 0.04);
}
.card-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 19px; }
.badge-num {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--peach);
  color: var(--badge-ink);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
}
.card-head h2 { margin: 0; font-size: 16.5px; font-weight: 700; line-height: 1.25; letter-spacing: 0; }
.card-head p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }

/* ---------- Champs ---------- */
.field { margin-top: 15px; }
.card-head + .field, .item-body > .field:first-child, .modal-body .field:first-child { margin-top: 0; }
.label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}
.req { color: var(--accent); }
.opt { color: var(--muted); font-weight: 600; }

.input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-input);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--placeholder); opacity: 1; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input.invalid { border-color: var(--danger); }
.input.invalid:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
input[type="date"].input { min-height: 46px; line-height: 44px; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }
textarea.input { height: 76px; min-height: 76px; padding: 12px 14px; line-height: 1.4; resize: vertical; }

.select-wrap { position: relative; }
.select-wrap select.input { padding-right: 42px; cursor: pointer; }
.select-wrap svg {
  position: absolute; right: 16px; top: 50%;
  width: 14px; height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink);
}
.select-wrap.compact select.input {
  height: 34px;
  padding: 0 30px 0 11px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.select-wrap.compact svg { right: 11px; width: 12px; height: 12px; }

.with-plus { display: flex; gap: 7px; }
.with-plus > .combo { flex: 1 1 auto; min-width: 0; }
.plus-btn {
  flex: none;
  width: 46px; height: 46px;
  border: 1px solid var(--peach-line);
  border-radius: 14px;
  background: var(--peach);
  color: var(--accent-ink-2);
  display: grid; place-items: center;
}
.plus-btn svg { width: 18px; height: 18px; }

.hint { margin: 6px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.err { margin: 6px 0 0; color: var(--danger); font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.err[hidden] { display: none; }

/* ---------- Recherche dans les référentiels ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0; right: 0;
  max-height: 264px;
  margin: 0;
  padding: 6px;
  overflow: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 36px -18px rgba(24, 36, 58, 0.38);
}
.combo-list[hidden] { display: none; }
.combo-opt, .combo-create, .combo-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.3;
}
.combo-opt, .combo-create { cursor: pointer; }
.combo-opt.active, .combo-opt:hover, .combo-create.active, .combo-create:hover { background: #F2F5F8; }
.combo-opt small { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.combo-create { color: var(--accent-ink); font-weight: 700; }
.combo-create svg { flex: none; width: 15px; height: 15px; }
.combo-empty { color: var(--muted); font-size: 13.5px; }
.swatch { flex: none; width: 16px; height: 16px; border-radius: 5px; border: 1px solid rgba(24, 36, 58, 0.18); }
.swatch.none { background: linear-gradient(135deg, #FFFFFF 45%, #D8E0E8 45%, #D8E0E8 55%, #FFFFFF 55%); }

/* ---------- Articles ---------- */
.items-head { margin: 23px 0 0; }
.items-sub { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 7px; }
.items-head h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.027em; line-height: 1.2; }
.items-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 17px; }
.chip {
  flex: none;
  margin-top: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.item-card {
  margin-top: 15px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(24, 36, 58, 0.04);
}
.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 8px 14px 8px 17px;
  border-bottom: 1px solid var(--line);
  border-radius: 21px 21px 0 0;
  background: var(--band);
}
.item-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: 0; white-space: nowrap; }
.item-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item-body { padding: 17px 17px 18px; }

.link-danger, .link-accent, .link-plain {
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 700;
}
.link-danger { color: var(--danger); font-size: 12.5px; }
.link-accent { color: var(--accent-ink); font-size: 13px; }
.link-plain { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Photos ---------- */
.photo-row { display: flex; align-items: center; gap: 12px; }
.photo-tile {
  position: relative;
  flex: none;
  width: 103px; height: 84px;
  border: 1.5px dashed var(--tile-dash);
  border-radius: 14px;
  background: var(--tile);
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.photo-tile .cam { font-size: 20px; line-height: 1; }
.photo-tile.sm { width: 86px; height: 56px; gap: 2px; font-size: 11px; }
.photo-tile.sm .cam { font-size: 17px; }
.photo-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 16.5px; }
.photo-row.sm { margin-top: 11px; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.thumbs::-webkit-scrollbar { display: none; }
.thumb {
  position: relative;
  flex: none;
  width: 84px; height: 84px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--tile);
}
.thumb.sm { width: 56px; height: 56px; border-radius: 12px; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb .tag {
  position: absolute; left: 5px; bottom: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(24, 36, 58, 0.78);
  color: #FFFFFF;
  font-size: 10px; font-weight: 700;
}
.thumb .del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--danger);
  display: grid; place-items: center;
  font-size: 17px; line-height: 1;
  box-shadow: 0 1px 3px rgba(24, 36, 58, 0.2);
}

/* ---------- Couleurs & variantes ---------- */
.variants-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 23px; }
.variants-head h4 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 0; }
.variants-head p { margin: 3px 0 0; max-width: 190px; color: var(--muted); font-size: 11px; line-height: 16px; }
.btn-soft {
  flex: none;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #F4D5BC;
  border-radius: 12px;
  background: var(--peach);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.color-card {
  margin-top: 12px;
  padding: 13px 14px 14px;
  border: 1px solid #E1E6EB;
  border-radius: 18px;
  background: #FDFEFE;
}
.color-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.color-head h5 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0; }

.rows {
  margin-top: 12px;
  padding: 12px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.rows-labels, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr) minmax(0, 1fr) 22px;
  gap: 7px;
  align-items: center;
}
.rows-labels span { color: #323E51; font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-wrap { margin-top: 8px; }
.input.sm { height: 40px; padding: 0 11px; border-radius: 12px; font-size: 15px; }
.row-del {
  width: 22px; height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 23px;
  line-height: 1;
}
.row-del[disabled] { visibility: hidden; }
.rows .link-accent { margin-top: 6px; }

.btn-add-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  margin-top: 16px;
  border: 1.5px dashed #E8B48D;
  border-radius: 16px;
  background: #FFF8F2;
  color: var(--accent-ink);
  font-size: 14.5px;
  font-weight: 700;
}
.btn-add-item svg { width: 16px; height: 16px; }

.session-line { margin: 28px 0 0; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---------- Barre de total ---------- */
.totalbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 11.5px 15px calc(11px + env(safe-area-inset-bottom, 0px));
}
.totalbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 450px; margin: 0 auto; }
.totals { min-width: 0; }
.totals p { margin: 0; }
.totals-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.01em; text-transform: uppercase; }
.totals-main { margin-top: 2.5px !important; color: var(--ink); font-size: 21px; font-weight: 800; letter-spacing: -0.022em; line-height: 1.15; white-space: nowrap; }
.totals-more { margin-top: 1px !important; color: var(--ink-2); font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.totals-more[hidden] { display: none; }
.totals-meta { margin-top: 4px !important; color: var(--meta); font-size: 11px; }
.btn-save {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 49px;
  padding: 0 17px;
  border: 0;
  border-radius: 16px;
  background: var(--navy);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 18px -10px rgba(21, 45, 73, 0.7);
}
.btn-save svg { width: 16px; height: 16px; stroke-width: 2.4; }
.btn-save[disabled] { opacity: 0.7; cursor: progress; }
.btn-save.wide { width: 100%; margin-top: 22px; }

.banner {
  position: fixed;
  left: 15px; right: 15px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  max-width: 450px;
  margin: 0 auto;
  padding: 12px 40px 12px 14px;
  border: 1px solid var(--danger-line);
  border-radius: 14px;
  background: var(--danger-bg);
  color: #8F2323;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 10px 24px -14px rgba(24, 36, 58, 0.4);
}
.banner button {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 18px;
}

/* ---------- Fenêtres ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--overlay);
}
.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.5);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 19px 21px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.icon-btn {
  flex: none;
  width: 32px; height: 32px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #F4F6F8;
  color: #6A798B;
  display: grid; place-items: center;
}
.icon-btn svg { width: 15px; height: 15px; }
.modal-body { padding: 20px 20px 20px; overflow: auto; }
.modal .req, .modal .opt { color: inherit; font-weight: inherit; }
.modal-body .input { height: 44px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: var(--band);
}
.btn-ghost, .btn-primary { height: 49px; padding: 0 17px; border-radius: 14px; font-size: 15px; font-weight: 700; }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); color: #465973; }
.btn-primary { border: 1px solid var(--navy); background: var(--navy-2); color: #FFFFFF; padding: 0 18px; }
.btn-primary[disabled] { opacity: 0.7; cursor: progress; }

.color-input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 5px 15px;
  border: 1px solid var(--line-input);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 1px solid #6B6B6B; border-radius: 1px; }
.color-input::-moz-color-swatch { border: 1px solid #6B6B6B; border-radius: 1px; }
.color-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.success-ref { margin: 4px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.success-list { margin: 14px 0 0; padding: 0; list-style: none; }
.success-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.success-list li strong { font-weight: 800; }
.success-note { margin: 14px 0 0; color: var(--green-ink); font-size: 13px; line-height: 1.4; }
