/* Charte reprise de hatec.fr : prune / magenta / jaune, police Source Sans */
:root {
  --bg: #f7f3f5;
  --card: #fff;
  --text: #212529;
  --muted: #6e6168;
  --line: #e3d9de;
  --primary: #672f4c;       /* prune : boutons, titres */
  --primary-dark: #5c193d;  /* prune foncé : barre, survol */
  --accent: #be2d7a;        /* magenta du logo */
  --accent-soft: #f8e6ef;
  --yellow: #ffce43;
  --danger: #c0392b;
  --ok: #1e8e4e;
  --head: #ece1e7;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 1.5rem; margin: 0; }
h1 small { font-size: .9rem; color: var(--muted); font-weight: 500; margin-left: .4rem; }
h1, h2 { color: var(--primary); }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; font-weight: 700; }
a { color: var(--accent); }

/* Barre du haut */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem; background: var(--primary-dark); color: #fff; border-bottom: 3px solid var(--accent); }
.topbar a { color: #fff; text-decoration: none; }
.topbar nav a:not(.btn):hover { color: var(--yellow); }
.brand { font-weight: 900; font-style: italic; letter-spacing: .04em; font-size: 1.25rem; }
.brand span { font-weight: 400; font-style: normal; opacity: .85; letter-spacing: 0; font-size: .95rem; margin-left: .3rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.topbar .btn { background: var(--yellow); color: #212529; }
.topbar .btn:hover { background: #f5c02a; }

.container { max-width: 1000px; margin: 0 auto; padding: 1rem 16px 6rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 2rem auto; }
.narrow-left { max-width: 480px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }

/* Formulaires */
label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .8rem; }
input, select, textarea { width: 100%; font: inherit; padding: .6rem .7rem; margin-top: .3rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
input:disabled { background: #f0f2f5; }
textarea { resize: vertical; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; margin-right: 1.2rem; }
.check input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--accent); }
.types { margin: .2rem 0 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.input-btn { display: flex; gap: .4rem; align-items: center; }
.input-btn input { flex: 1; }
.input-btn .btn { margin-top: .3rem; }

.btn { display: inline-block; border: 0; border-radius: 999px; padding: .65rem 1.1rem; font: inherit; font-weight: 600;
  background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: .4rem .75rem; font-size: .88rem; }
.btn-light { background: var(--accent-soft); color: var(--primary); }
.btn-light:hover { background: #f0d3e2; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

.actions { display: flex; gap: .6rem; align-items: center; }
.actions .spacer { flex: 1; }
.actions.sticky { position: sticky; bottom: 0; background: rgba(243,245,248,.95); padding: .8rem 0; border-top: 1px solid var(--line); }
.actions-inline { display: flex; gap: .5rem; align-items: center; }
.actions-inline form { margin: 0; }

.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-ok { background: #e3f5ea; color: #145c33; }
.alert-err { background: #fbe7e5; color: #8a2419; }

/* Tableaux de saisie */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.grid-table th { background: var(--head); font-size: .85rem; padding: .4rem; text-align: left; }
.grid-table td { border-bottom: 1px solid var(--line); padding: 2px; }
.grid-table input { margin: 0; border: 0; border-radius: 4px; padding: .5rem; background: transparent; }
.grid-table input:focus { background: var(--accent-soft); }
.grid-table .nr { width: 2.5rem; text-align: center; color: var(--muted); }
.grid-table .q { width: 4.5rem; }
#add-fourniture { margin-top: .6rem; }

/* Liste */
.filters { display: flex; gap: .5rem; }
.filters input, .filters select { margin: 0; }
.list { display: flex; flex-direction: column; gap: .5rem; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; }
.list-item:hover { border-color: var(--accent); }
.li-title { font-weight: 700; }
.li-sub { font-size: .85rem; color: var(--muted); }
.li-ville { font-weight: 400; color: var(--muted); }
.badge { font-size: .78rem; font-weight: 700; padding: .25rem .6rem; border-radius: 99px; white-space: nowrap; }
.badge-brouillon { background: #fff1d6; color: #8a5a00; }
.badge-signe { background: #e3f5ea; color: #145c33; }
.empty { text-align: center; padding: 2.5rem 1rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr.inactive td { color: var(--muted); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
form.inline { display: inline-flex; gap: .3rem; margin: 0; }
form.inline input { margin: 0; width: 11rem; padding: .35rem .5rem; font-size: .85rem; }

.login-brand { text-align: center; font-size: 2.6rem; font-weight: 900; font-style: italic; letter-spacing: .06em; color: var(--accent); }

/* Assistant en étapes */
.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 1rem; gap: 4px; counter-reset: s; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem; cursor: pointer;
  font-size: .78rem; color: var(--muted); position: relative; text-align: center; }
.stepper li a { display: contents; color: inherit; text-decoration: none; }
.stepper li::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper .dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; border: 2px solid var(--line); font-weight: 700; color: var(--muted); }
.stepper li.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper li.done::before, .stepper li.active::before { background: var(--primary); }
.stepper li.active .dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper li.active { color: var(--primary); font-weight: 700; }
.stepper li.last { cursor: default; }

.wizard .step[hidden] { display: none; }
.wizard .step { min-height: 40vh; }
.wizard-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center; }
.wizard-nav #btn-prev { justify-self: start; }
.wizard-nav #btn-next, .wizard-nav #btn-sign { justify-self: end; }
.wizard-nav [hidden] { display: none; }
.btn-link { background: none; color: var(--primary); text-decoration: underline; padding: .5rem .4rem; font-weight: 600; }
.btn-link:hover { background: none; color: var(--accent); }
.danger-zone { margin-top: 1.5rem; }
.btn-text-danger { background: none; border: 0; color: var(--danger); text-decoration: underline; font: inherit; font-size: .9rem; cursor: pointer; }
.save-status.err { color: var(--danger); }
input.invalid { border-color: var(--danger); outline: 2px solid var(--danger); }
.sub-label { font-size: .9rem; font-weight: 600; margin-bottom: .4rem; }

/* Types en « puces » faciles à toucher */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip { margin: 0; font-weight: 600; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: .6rem 1rem; border-radius: 999px; border: 2px solid var(--line); background: #fff; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input:checked + span::before { content: "✓ "; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Matériel / fournitures en cartes */
.items { display: flex; flex-direction: column; gap: .75rem; margin-bottom: .75rem; }
.item { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: .7rem .8rem .1rem; background: #fdfbfc; }
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; font-weight: 700; color: var(--primary); }
.item-del { border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: .2rem .4rem; }
.item-del:hover { color: var(--danger); }
.item .grid-2 { gap: 0 .75rem; }
.grid-cp { display: grid; grid-template-columns: 7rem 1fr; gap: 0 .75rem; }
.sh-adresse { display: block; margin-top: .3rem; color: #444; }
.grid-four { display: grid; grid-template-columns: 5rem 1fr 2fr; gap: 0 .75rem; }
.btn-add { width: 100%; padding: .7rem; }

/* Scan de plaque */
.btn-scan { width: 100%; margin-bottom: .4rem; background: var(--yellow); color: #212529; }
.btn-scan:hover { background: #f5c02a; }
.btn-scan:disabled { opacity: .6; cursor: wait; }
.scan-status { min-height: 1.2em; margin-bottom: .5rem; color: var(--muted); }
.scan-status.ok { color: var(--ok); font-weight: 600; }
.scan-status.err { color: var(--danger); }
.scan-raw { margin-bottom: .6rem; font-size: .85rem; }
.scan-raw summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.scan-raw pre { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .5rem;
  max-height: 10rem; overflow: auto; user-select: text; font-size: .8rem; }
input.scanned { background: #fff7d6; border-color: var(--yellow); transition: background 1s; }
.btn-add[hidden] { display: none; }

/* Liste : avancement des brouillons */
.li-progress { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.li-progress .bar { width: 70px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.li-progress .bar span { display: block; height: 100%; background: var(--accent); }
.sh-bon { font-size: 1.3rem; font-weight: 700; color: var(--primary); }

/* Signature */
.sig-label { font-size: .9rem; font-weight: 600; margin-bottom: .3rem; }
.sig-pad { position: relative; border: 2px dashed var(--line); border-radius: 8px; background: #fff; }
.sig-pad.signed { border-style: solid; border-color: var(--accent); }
.sig-pad.error { border-color: var(--danger); }
.sig-pad canvas { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
.sig-pad::after { content: "Signez ici"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #c3cad4; pointer-events: none; font-size: 1.1rem; }
.sig-pad.signed::after { display: none; }
.sig-clear { position: absolute; right: .4rem; top: .4rem; border: 0; background: #eef1f5; border-radius: 6px;
  padding: .25rem .6rem; font-size: .8rem; cursor: pointer; z-index: 1; }

/* Fiche imprimable (reprend la feuille papier) */
.sheet { background: #fff; border: 2px solid #222; padding: 0; font-size: 14px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet td, .sheet th { border: 1.5px solid #222; padding: .35rem .5rem; vertical-align: top; }
.sheet .hd th, .sheet .hd2 th { background: var(--primary); color: #fff; font-weight: 600; text-align: center; }
.sh-title { background: var(--primary); color: #fff; font-size: 1.6rem; width: 30%; }
.sh-brand { text-align: center; font-size: 1.9rem; font-weight: 900; font-style: italic; letter-spacing: .05em; color: var(--accent); }
.sh-num { width: 30%; text-align: center; color: #444; }
.sh-addr { text-align: center; }
.sh-client .lbl { color: #444; }
.sh-types { padding: 0 !important; }
.sh-types div { display: flex; border-bottom: 1.5px solid #222; }
.sh-types div:last-child { border-bottom: 0; }
.sh-types span { flex: 1; padding: .3rem .5rem; text-align: center; border-right: 1.5px solid #222; }
.sh-types b { width: 2.8rem; text-align: center; padding: .3rem; }
.sh-grid td { height: 1.9em; }
.sh-mat .nr { width: 2.5rem; text-align: center; }
.sh-travaux { min-height: 12em; height: 12em; white-space: normal; }
.sh-four .q { width: 3rem; text-align: center; }
.sh-four .ref { width: 30%; }
.sh-sign td { width: 50%; text-align: center; height: auto; }
.sh-sign img { max-width: 100%; height: 110px; object-fit: contain; }

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .item .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-four { grid-template-columns: 4.5rem 1fr; }
  .grid-four .span-2 { grid-column: 1 / -1; }
  .stepper .lbl { display: none; }
  .stepper li.active .lbl { display: block; position: absolute; top: 38px; white-space: nowrap; }
  .stepper { margin-bottom: 1.8rem; }
  .wizard-nav .btn { padding: .65rem .75rem; white-space: nowrap; font-size: .95rem; }
  .wizard-nav { gap: .25rem; }
  input, select, textarea { font-size: 16px; } /* évite le zoom auto sur iPhone */
  h1 { font-size: 1.25rem; }
  .filters { width: 100%; }
  .filters input { flex: 1; }
  .topbar nav { gap: .7rem; font-size: .88rem; }
  .sheet { font-size: 11px; overflow-x: auto; }
  .sh-title, .sh-brand { font-size: 1.1rem; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .no-print, .topbar { display: none !important; }
  .container { max-width: none; padding: 0; }
  .sheet { font-size: 11.5px; }
  .sheet .hd th, .sh-title { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
