/* Recon Pilote — mobile-first, thème premium noir & or */
:root {
  --bg: #0c0c0e;
  --card: #151517;
  --ink: #f3ede1;
  --muted: #a89c86;
  --primary: #c9a24b;
  --primary-ink: #1a1408;
  --danger: #e5534b;
  --line: #2b261d;
  --input-bg: #101012;
  --hover: #1f1c15;
  --radius: 12px;
  --green: #3fb950; --blue: #5b9dff; --orange: #f0883e; --teal: #39c5cf;
  --red: #e5534b; --purple: #bc8cff; --grey: #8b98ab; --slate: #9aa8bd; --yellow: #d29922;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
h1 { font-size: 1.5rem; margin: 0.6em 0; }
h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
h3 { font-size: 1rem; margin: 1.2em 0 0.5em; }

.topbar {
  background: #0a0a0c; color: #fff; padding: 0.6rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid #3a2f1a;
}
.brand { color: var(--primary); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.nav a { color: #cfd8e3; text-decoration: none; padding: 0.45rem 0.7rem; border-radius: 8px; }
.nav a:hover { background: var(--hover); color: var(--primary); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.userlink { color: #fff; text-decoration: none; }
.logout { color: #9fb0c3; text-decoration: none; }
.logout:hover { color: #fff; }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 1rem 1.1rem;
  margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.5rem 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.text-red { color: var(--red); font-weight: 600; }
.back { display: inline-block; margin-bottom: 0.6rem; color: var(--primary); text-decoration: none; }

.flash { border-radius: 10px; padding: 0.7rem 1rem; margin-bottom: 1rem; font-weight: 500; }
.flash-ok { background: #12341f; color: #7ee2a0; border: 1px solid #1e5c33; }
.flash-error { background: #3d1a17; color: #ff9d94; border: 1px solid #7a2e28; }
.flash-info { background: #16283f; color: #8db8ff; border: 1px solid #274a75; }

/* Boutons et formulaires — cibles tactiles généreuses */
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--input-bg); color: var(--ink);
  border-radius: 10px; padding: 0.7rem 1.1rem; font-size: 1rem; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
label { display: block; margin: 0.7rem 0; font-weight: 500; }
input[type="text"], input[type="password"], input[type="search"], input[type="date"],
input[type="file"], select, textarea {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.7rem;
  border: 1px solid var(--line); border-radius: 10px; font-size: 1rem;
  background: var(--input-bg); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
select option { background: var(--card); color: var(--ink); }
textarea { resize: vertical; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.inline-form label { flex: 1 1 180px; margin: 0; }
form.inline { display: inline; }

.role { font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 20px; color: #fff; }
.role-admin { background: #101820; }
.role-directeur { background: #5b21b6; }
.role-responsable_ventes { background: #0e7490; }
.role-vendeur { background: var(--blue); }
.role-mecanicien { background: var(--orange); }
.role-comptable { background: var(--teal); }

.table tfoot tr.total td { border-top: 2px solid #333; font-size: 1.1rem; }

.badge { font-size: 0.8rem; font-weight: 600; padding: 0.25rem 0.7rem; border-radius: 20px; color: #fff; }
.badge-green { background: var(--green); } .badge-blue { background: var(--blue); }
.badge-orange { background: var(--orange); } .badge-teal { background: var(--teal); }
.badge-red { background: var(--red); } .badge-purple { background: var(--purple); }
.badge-grey { background: var(--grey); } .badge-slate { background: var(--slate); }
.badge-installee { background: var(--green); }
.badge-yellow { background: var(--yellow); }

/* Fiche rouge : badge et bandeau bien visibles */
.fiche-rouge-badge { background: var(--red); animation: pulse-red 1.6s ease-in-out infinite; }
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0); }
}
.fiche-rouge-banner {
  background: #3d1a17; border: 2px solid var(--red); border-radius: var(--radius);
  padding: 0.9rem 1rem; margin-bottom: 1rem; font-size: 1rem;
}
.vehicle-card.fiche-rouge-card { border: 2px solid var(--red); }

/* Gravités des problèmes d'inspection d'achat */
.probleme { border-left: 5px solid var(--grey); padding-left: 0.7rem; }
.gravite-mineur { border-left-color: var(--yellow); }
.gravite-majeur { border-left-color: var(--orange); }
.gravite-critique { border-left-color: var(--red); }
.probleme.resolu { opacity: 0.65; }

/* Alertes du mécanicien */
.flag { border-left: 5px solid var(--grey); padding-left: 0.7rem; }
.flag-majeur { border-left-color: var(--red); }
.flag-surveiller { border-left-color: var(--yellow); }
.flag-pieces { border-left-color: var(--blue); }

/* Divers */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0.4em 0; }
.page-head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.warning {
  background: #2e2410; border: 1px solid var(--yellow); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; margin: 0.7rem 0;
}
.form-error {
  background: #3d1a17; border: 1px solid var(--red); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; margin: 0.7rem 0; color: #ff9d94; font-weight: 600;
}
.grow { flex: 1; }

/* Tableau de bord */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 0.9rem;
  text-decoration: none; color: var(--ink); text-align: center;
  border-top: 5px solid var(--grey); box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.stat-n { display: block; font-size: 1.9rem; font-weight: 700; }
.stat-l { font-size: 0.9rem; color: var(--muted); }
.stat-green { border-color: var(--green); } .stat-blue { border-color: var(--blue); }
.stat-orange { border-color: var(--orange); } .stat-teal { border-color: var(--teal); }
.stat-red { border-color: var(--red); } .stat-purple { border-color: var(--purple); }
.stat-grey { border-color: var(--grey); } .stat-slate { border-color: var(--slate); }
.stat-gold { border-color: var(--primary); }

/* Valeur d'inventaire — carte hero */
.valeur-hero {
  border: 1px solid #3a2f1a;
  background: linear-gradient(135deg, #141210, #1c1712);
  text-align: center; padding: 1.2rem 1rem;
}
.valeur-hero-label { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.3rem; }
.valeur-hero-num { font-size: 2.4rem; font-weight: 800; color: var(--primary); }

.two-col { display: grid; gap: 1rem; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; } }

.good-news { border-left: 6px solid var(--teal); }
.alert-red { border-left: 6px solid var(--red); background: #2a1512; }
.alert-orange { border-left: 6px solid var(--orange); background: #2b1d0e; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.list a { color: var(--primary); }

.kpi div { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.kpi dt { color: var(--muted); }
.kpi dd { margin: 0; font-weight: 700; font-size: 1.1rem; }

.empty { color: var(--muted); font-style: italic; }
.empty-state, .error-card { text-align: center; padding: 2.5rem 1.5rem; }
.empty-big { font-size: 3rem; margin: 0; }

/* Inventaire */
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 2 1 200px; margin: 0; }
.filters select { flex: 1 1 150px; margin: 0; }
.vehicle-grid { display: grid; gap: 0.9rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .vehicle-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .vehicle-grid { grid-template-columns: repeat(3, 1fr); } }
.vehicle-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  text-decoration: none; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.35);
  display: block; position: relative;
}
.vehicle-card-link { text-decoration: none; color: inherit; display: block; }
.vehicle-card.priority { outline: 3px solid var(--red); }
.vehicle-photo { position: relative; aspect-ratio: 16/10; background: #0e1218; }
.vehicle-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vehicle-photo .badge { position: absolute; top: 0.6rem; left: 0.6rem; }
.no-photo { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 2.5rem; color: #9aa7b4; }
.no-photo span { font-size: 0.9rem; }
.vehicle-info { padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.15rem; }
.vehicle-info .price { font-weight: 700; font-size: 1.15rem; color: var(--green); }
.prix-barre { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.price-special { color: #ff6b61; font-weight: 700; }

/* Menu hamburger sur carte véhicule (style ADWS) */
.card-menu { position: absolute; top: 0.5rem; right: 0.5rem; z-index: 5; }
.hamburger-btn {
  width: 2.6rem; height: 2.6rem; border-radius: 0.6rem;
  background: rgba(29,35,48,.95); border: 1px solid var(--line);
  font-size: 1.2rem; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.hamburger-btn:hover { background: var(--hover); }
.card-menu-dropdown {
  display: none; position: absolute; top: 3rem; right: 0;
  min-width: 15rem; background: var(--card); border-radius: 0.8rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); border: 1px solid var(--line);
  overflow: hidden; z-index: 20;
}
.card-menu-dropdown.open { display: block; }
.card-menu-dropdown a, .card-menu-dropdown .menu-danger {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1rem; text-decoration: none; color: var(--ink);
  font-size: 0.95rem; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.card-menu-dropdown a:hover, .card-menu-dropdown .menu-danger:hover { background: var(--hover); }
.card-menu-dropdown form { margin: 0; border-top: 1px solid var(--line); }
.card-menu-dropdown .menu-danger { color: #ff7b72; font-weight: 600; }
/* Formulaire "Changer le statut" dans le menu */
.card-menu-dropdown .menu-statut-form { padding: 0.75rem 1rem; display: grid; gap: 0.5rem; }
.card-menu-dropdown .menu-statut-titre { font-size: 0.95rem; color: var(--ink); }
.card-menu-dropdown .menu-statut-form select,
.card-menu-dropdown .menu-statut-form input {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--line);
  border-radius: 0.5rem; font-size: 0.9rem; font-family: inherit; box-sizing: border-box;
  background: var(--input-bg); color: var(--ink);
}
.card-menu-dropdown .menu-statut-form .btn-small { padding: 0.55rem; font-size: 0.9rem; }

/* Fiche véhicule */
.vehicle-head { display: grid; gap: 1rem; }
@media (min-width: 700px) { .vehicle-head { grid-template-columns: 340px 1fr; } }
.vehicle-photo-lg img { width: 100%; border-radius: 10px; display: block; }
.specs div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; text-align: right; }
.specs .price { color: var(--green); font-size: 1.15rem; }

.check-item { border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem; margin-bottom: 0.6rem; background: var(--card); }
.check-point { font-weight: 600; display: block; margin-bottom: 0.4rem; }
.check-radios { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-bottom: 0.4rem; }
.check-radios label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; font-weight: 400; }
.check-radios input { width: 1.2rem; height: 1.2rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; }

.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
@media (min-width: 700px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; border-radius: 10px; display: block; aspect-ratio: 4/3; object-fit: cover; }
.photo-grid figcaption { font-size: 0.85rem; color: var(--muted); padding: 0.3rem 0; }

.comments li p { margin: 0.3rem 0 0.5rem; }

.verdict-form { border: 1px dashed var(--line); border-radius: 10px; padding: 0.8rem; margin-bottom: 0.8rem; }

/* Connexion */
.login-wrap { display: flex; justify-content: center; padding: 2rem 0; }
.login-card { max-width: 420px; width: 100%; text-align: center; }
.login-card form { text-align: left; }

/* === Layout app : sidebar (v29) === */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0;
  background: #0a0a0c; border-right: 1px solid #3a2f1a;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 1rem 0.8rem; z-index: 50;
}
.sidebar .brand { display: block; padding: 0.4rem 0.6rem 1rem; font-size: 1.25rem; }
.side-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; overflow-y: auto; }
.side-nav a {
  color: #cfc6b4; text-decoration: none; padding: 0.65rem 0.8rem;
  border-radius: 10px; font-weight: 500; white-space: nowrap;
}
.side-nav a:hover { background: var(--hover); color: var(--primary); }
.side-user { border-top: 1px solid var(--line); padding-top: 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main .container { flex: 1; width: 100%; }
.menu-btn {
  display: none; background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font-size: 1.2rem; padding: 0.3rem 0.6rem; cursor: pointer;
}
.brand-top { display: none; }
.sidebar-overlay { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-105%); transition: transform 0.25s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.55);
  }
  .menu-btn { display: inline-block; }
  .brand-top { display: inline; }
}

/* === Hero stats v29 === */
.hero-grid { margin-bottom: 1rem; }
.hero-grid .stat { padding: 1.1rem 0.9rem; }
.hero-grid .stat-n { font-size: 2.1rem; }
.gold-num { color: var(--primary); }

/* === Tableau véhicules du tableau de bord === */
.table-wrap { overflow-x: auto; margin: 0 -0.2rem; }
.table-wrap .table { min-width: 640px; }
td.thumb { width: 64px; }
td.thumb img { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.no-thumb { font-size: 1.6rem; }

@media print {
  .sidebar, .sidebar-overlay, .menu-btn { display: none !important; }
  .app-shell { display: block; }
}
.tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1rem; border-bottom: 2px solid var(--line); padding-bottom: 0.5rem; }
.tabs a { padding: 0.5rem 0.9rem; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 0.95rem; }
.tabs a:hover { background: var(--hover); color: var(--ink); }
.tabs a.active { background: var(--primary); color: var(--primary-ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.2rem 1rem; }
.form-grid label { margin: 0.4rem 0; }
.form-actions { margin-top: 1rem; }
.profit-box { background: #12341f; border: 1px solid #1e5c33; border-radius: 10px; padding: 1rem; margin-top: 1rem; }
.profit-box.negative { background: #3d1a17; border-color: #7a2e28; }
.profit-num { font-size: 1.4rem; font-weight: 700; }
table.data { width: 100%; border-collapse: collapse; margin: 0.8rem 0; font-size: 0.95rem; }
table.data th, table.data td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { background: var(--hover); font-weight: 600; }
table.data tr:hover td { background: var(--hover); }
.expense-cat { font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 12px; color: #fff; }
.expense-achat { background: #7d3c98; } .expense-reconditionnement { background: #e07b00; } .expense-vente { background: #0f8b8d; }

/* === Onglet Coût === */
.cout-groupe { border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem; margin: 0.8rem 0; background: var(--input-bg); }
.cout-groupe h4 { margin: 0 0 0.5rem; font-size: 1rem; }
.cout-groupe.cout-auto { background: #16283f; border-color: #274a75; }
.cout-existant { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); font-size: 0.95rem; }
.cout-ligne { align-items: end; margin: 0.4rem 0; }
.cout-ligne input { width: 100%; }

/* === Contrat imprimable === */
@media print {
  .topbar, .footer, .no-print, .flash { display: none !important; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; font-size: 11pt; }
}
.contract-doc { background: #fff; color: #1a1a1a; }
.contract-doc a { color: #0b5cc0; }
.contract-doc .muted { color: #5a6b82; }
.contract-doc h1 { text-align: center; font-size: 1.3rem; border-bottom: 3px double #333; padding-bottom: 0.5rem; }
.contract-header { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.contract-section { margin-bottom: 1.2rem; }
.contract-section h2 { font-size: 1.05rem; background: var(--card); color: var(--ink); padding: 0.4rem 0.6rem; border-left: 4px solid var(--primary); }
.contract-lines { width: 100%; border-collapse: collapse; }
.contract-lines td { padding: 0.35rem 0.5rem; border-bottom: 1px dotted #ccc; }
.contract-lines td.line-label { width: 55%; }
.contract-lines td.line-amount { text-align: right; font-weight: 600; white-space: nowrap; }
.contract-lines tr.total td { border-top: 2px solid #333; border-bottom: 2px solid #333; font-size: 1.1rem; }
.contract-lines tr.ligne-retournee td { color: #888; }
.contract-lines tr.ligne-retournee td.line-amount { text-decoration: line-through; }
.contract-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 1.5rem; }
.contract-grid div { padding: 0.25rem 0; border-bottom: 1px dotted #ddd; }
.signature-box { display: flex; gap: 2rem; margin-top: 2rem; }
.signature-box > div { flex: 1; border-top: 1px solid #333; padding-top: 0.3rem; text-align: center; }
/* Page 2 — mentions légales du contrat de vente (transcription ADWS) */
.legal-page { page-break-before: always; break-before: page; }
.legal-clause { margin-bottom: 0.9rem; }
.legal-clause p { text-align: justify; font-size: 0.92rem; line-height: 1.45; margin: 0; }
.legal-notice { margin: 1rem 0; }
.legal-notice p { text-align: center; font-size: 0.92rem; line-height: 1.5; margin: 0 0 0.6rem; }
.initials-bar { background: var(--card); color: var(--ink); padding: 0.4rem 0.6rem; margin: 1rem 0 0.6rem; display: flex; align-items: center; gap: 0.6rem; }
.initials-bar strong:first-child { white-space: nowrap; }
.initials-line { flex: 1; border-bottom: 1px solid #333; min-height: 1.2em; display: inline-block; }
.initials-cols { display: flex; gap: 1rem; margin-bottom: 1rem; }
.initials-cols > div { flex: 1; text-align: center; }
.initials-cols .initials-line { display: block; margin-top: 0.2rem; }
.sig-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.8rem 0 1.2rem; }
.sig-line { flex: 1; border-bottom: 1px solid #333; min-height: 1.2em; display: inline-block; }
.date-val { white-space: nowrap; font-weight: 600; }

/* === Impression contrat de vente : mise en page ADWS exacte (2 pages) === */
@page {
  size: letter;
  margin: 0.4in 0.45in;
}
@media print {
  /* Base */
  .contract-doc { max-width: none; font-size: 11px; line-height: 1.25; color: #000; }
  .contract-doc h1 {
    font-size: 22px; font-weight: bold; text-align: center;
    margin: 0 0 6px; padding: 0; border: none;
  }
  /* En-tête société */
  .contract-header { margin-bottom: 6px; font-size: 11px; line-height: 1.3; }
  /* Titres de section : centrés, gras, sur barre grise (style ADWS) */
  .contract-section { margin-bottom: 4px; break-inside: auto; }
  .contract-section h2 {
    font-size: 18px; font-weight: bold; text-align: center;
    background: #e5e5e5 !important; padding: 3px 0; margin: 0 0 4px;
    border: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    break-after: avoid; break-inside: avoid;
  }
  .contract-section p { margin: 0 0 3px; font-size: 11px; }
  /* Grilles d'info */
  .contract-grid { gap: 0 1.2rem; }
  .contract-grid div { padding: 1px 0; margin: 0; font-size: 11px; line-height: 1.3; border-bottom: none; }
  .check-inline { margin-right: 0.6rem; font-size: 11px; }
  .contract-doc input[type="checkbox"] { width: 0.9em; height: 0.9em; margin-right: 0.25em; }
  .blank-line { min-width: 6rem; border-bottom: 1px solid #333; }
  /* Tableau des prix : peut se couper entre page 1 et 2 */
  .contract-lines { break-inside: auto; border-collapse: collapse; width: 100%; }
  .contract-lines td { padding: 2px 4px; font-size: 12px; line-height: 1.3; border-bottom: 1px dotted #aaa; }
  .contract-lines td.line-label { width: 60%; }
  .contract-lines tr { break-inside: avoid; }
  .contract-lines tr.total td { font-size: 12px; font-weight: bold; border-top: 1px solid #333; border-bottom: 1px solid #333; }
  /* Signatures page 1/2 */
  .signature-box { margin-top: 6px; gap: 2rem; break-inside: avoid; }
  .signature-box > div { font-size: 11px; padding-top: 3px; line-height: 1.25; text-align: center; border-top: 1px solid #333; }
  .contract-doc > p.muted.small { display: none !important; }
  /* Logo ADWS bas de page 2 */
  .adws-print-logo { text-align: right; margin-top: 12px; font-size: 16px; font-weight: bold; color: #2a7a2a; break-inside: avoid; }
  /* Page 2 mentions légales (si présentes) */
  .legal-page { break-before: page; }
  .legal-clause { margin-bottom: 5px; break-inside: avoid; }
  .legal-clause p { font-size: 10px; line-height: 1.35; text-align: justify; margin: 0; }
  .legal-notice { margin: 6px 0; break-inside: avoid; }
  .legal-notice p { font-size: 10px; line-height: 1.4; margin: 0 0 5px; }
  .initials-bar {
    padding: 2px 6px; margin: 5px 0 3px; font-size: 11px;
    background: #e5e5e5 !important; text-align: center; font-weight: bold;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    break-inside: avoid;
  }
  .initials-cols { margin-bottom: 5px; break-inside: avoid; }
  .initials-cols > div { font-size: 11px; }
  .sig-row { margin: 4px 0 6px; font-size: 11px; break-inside: avoid; }
}

/* === Bons de commande généraux === */
.search-results { display: grid; gap: 0.25rem; margin-top: 0.4rem; }
.search-result-item {
  text-align: left; padding: 0.5rem 0.75rem; border: 1px solid var(--line);
  border-radius: 0.5rem; background: var(--card); color: var(--ink);
  cursor: pointer; font-size: 0.95rem; width: 100%;
}
.search-result-item:hover { background: var(--hover); }
.facture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.facture-item img { width: 100%; border-radius: 0.5rem; border: 1px solid var(--line); }
.facture-item form { margin-top: 0.4rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media print {
  .facture-grid { grid-template-columns: repeat(3, 1fr); }
  .facture-item { break-inside: avoid; }
}
