/* Recon Pilote — mobile-first */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2530;
  --muted: #6b7785;
  --primary: #0d6efd;
  --danger: #c0392b;
  --radius: 12px;
  --green: #1e7e34; --blue: #0d6efd; --orange: #e07b00; --teal: #0f8b8d;
  --red: #c0392b; --purple: #7d3c98; --grey: #6b7785; --slate: #475569; --yellow: #b8860b;
}
* { 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: #101820; color: #fff; padding: 0.6rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem;
  position: sticky; top: 0; z-index: 10;
}
.brand { color: #fff; 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: #1d2836; color: #fff; }
.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(16,24,32,.08);
}
.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: #e6f4ea; color: #1e7e34; border: 1px solid #b7e0c2; }
.flash-error { background: #fdecea; color: #a93226; border: 1px solid #f5c6c0; }
.flash-info { background: #e8f0fe; color: #1a56db; border: 1px solid #bcd3fb; }

/* Boutons et formulaires — cibles tactiles généreuses */
.btn {
  display: inline-block; border: 1px solid #cfd6dd; background: #fff; 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: #fff; }
.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 #cfd6dd; border-radius: 10px; font-size: 1rem; background: #fff;
}
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); }

.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-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: #fdeceb; 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; }
.warning {
  background: #fff8e6; border: 1px solid var(--yellow); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; margin: 0.7rem 0;
}
.form-error {
  background: #fdeceb; border: 1px solid var(--red); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; margin: 0.7rem 0; color: var(--red); 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(16,24,32,.08);
}
.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); }

.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: #fff7f6; }
.alert-orange { border-left: 6px solid var(--orange); background: #fffaf2; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 0.55rem 0; border-bottom: 1px solid #eef1f4; }
.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 #eef1f4; }
.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(16,24,32,.08);
  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: #dfe5ea; }
.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); }

/* 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(255,255,255,.95); border: 1px solid #dfe5ea;
  font-size: 1.2rem; cursor: pointer; color: #374151;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(16,24,32,.15);
}
.hamburger-btn:hover { background: #fff; }
.card-menu-dropdown {
  display: none; position: absolute; top: 3rem; right: 0;
  min-width: 15rem; background: #fff; border-radius: 0.8rem;
  box-shadow: 0 8px 24px rgba(16,24,32,.18); border: 1px solid #eef1f4;
  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: #1f2937;
  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: #f3f4f6; }
.card-menu-dropdown form { margin: 0; border-top: 1px solid #f0f0f0; }
.card-menu-dropdown .menu-danger { color: #dc2626; font-weight: 600; }

/* 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 #eef1f4; }
.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 #e6eaee; border-radius: 10px; padding: 0.7rem; margin-bottom: 0.6rem; }
.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 #eef1f4; }
.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 #cfd6dd; 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; }

/* === Module ADWS : onglets fiche véhicule === */
.tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1rem; border-bottom: 2px solid #e2e8f0; 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: #eef2f7; color: var(--ink); }
.tabs a.active { background: var(--primary); color: #fff; }
.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: #f0fdf4; border: 1px solid #b7e0c2; border-radius: 10px; padding: 1rem; margin-top: 1rem; }
.profit-box.negative { background: #fef2f2; border-color: #f5c6c0; }
.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 #e8edf2; text-align: left; }
table.data th { background: #f1f5f9; font-weight: 600; }
table.data tr:hover td { background: #f8fafc; }
.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; }

/* === 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; }
.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: #f1f5f9; 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-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: #f1f5f9; 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; }
