:root {
  --navy: #1a2744;
  --gold: #c9973a;
  --cream: #faf8f3;
  --warm-gray: #8a8278;
  --light-border: #e8e2d6;
  --text: #2c2820;
  --error: #c0392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Lato', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  background: var(--navy);
  padding: 28px 40px;
  display: flex;
  align-items: center;
  gap: 16px;
}
header .logo {
  width: 42px; height: 42px;
  background: var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif;
  color: white; font-size: 20px; font-weight: 700;
}
header h1 {
  font-family: 'Playfair Display', serif;
  color: white; font-size: 22px; font-weight: 600;
  letter-spacing: 0.5px;
}
header span {
  color: var(--gold); font-size: 13px; font-weight: 300;
  letter-spacing: 2px; text-transform: uppercase; display: block;
}

/* ── MAIN LAYOUT ── */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* STEP TABS */
.steps {
  display: flex;
  gap: 0;
  margin-bottom: 36px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--light-border);
}
.step-btn {
  flex: 1; padding: 14px 10px;
  background: white; border: none; cursor: pointer;
  font-family: 'Lato', sans-serif; font-size: 13px;
  font-weight: 700; color: var(--warm-gray);
  letter-spacing: 1px; text-transform: uppercase;
  border-right: 1px solid var(--light-border);
  transition: all .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.step-btn:last-child { border-right: none; }
.step-btn.active {
  background: var(--navy); color: white;
}
.step-btn.done {
  background: #f0f7f0; color: #2e7d32;
}
.step-btn .num {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,0.15); flex-shrink: 0;
}
.step-btn.active .num { background: var(--gold); }
.step-btn.done .num { background: #2e7d32; color: white; }

/* FORM PANELS */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px; color: var(--navy);
  margin-bottom: 6px;
}
.section-sub {
  color: var(--warm-gray); font-size: 14px; margin-bottom: 28px;
}

.card {
  background: white;
  border: 1px solid var(--light-border);
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 20px;
}
.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px; color: var(--navy);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gold);
  display: flex; align-items: center; gap: 10px;
}
.card-title svg { opacity: 0.7; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.row.full { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: 6px; }
label {
  font-size: 12px; font-weight: 700; color: var(--warm-gray);
  text-transform: uppercase; letter-spacing: 1px;
}
label .req { color: var(--gold); }
input, select {
  border: 1.5px solid var(--light-border);
  border-radius: 8px; padding: 11px 14px;
  font-family: 'Lato', sans-serif; font-size: 15px;
  color: var(--text); background: white;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,39,68,.07);
}
input.error { border-color: var(--error); }
.err-msg { font-size: 12px; color: var(--error); display: none; }
.err-msg.show { display: block; }

.hint { font-size: 12px; color: var(--warm-gray); font-style: italic; }

/* SIRET LOOKUP */
.siret-row { display: flex; gap: 8px; }
.siret-row input { flex: 1; }
.btn-siret {
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0 18px;
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
.btn-siret:hover:not(:disabled) { background: #253460; }
.btn-siret:disabled { opacity: 0.5; cursor: wait; }
.siret-status-ok    { color: #2e7d32 !important; font-style: normal !important; font-weight: 600; }
.siret-status-err   { color: var(--error) !important; font-style: normal !important; font-weight: 600; }

/* AUTOCOMPLETE ADRESSE (API BAN) */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--light-border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(26,39,68,.12);
  max-height: 260px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--light-border);
  font-size: 14px;
  transition: background .15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active { background: var(--cream); }
.autocomplete-item strong {
  display: block;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 2px;
}
.autocomplete-item span {
  font-size: 12px;
  color: var(--warm-gray);
}

/* TYPE TOGGLE (personne physique / morale) */
.type-toggle {
  display: flex;
  gap: 12px;
}
.type-toggle label {
  flex: 1;
  border: 2px solid var(--light-border);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: all .2s;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
  background: white;
}
.type-toggle label:hover { border-color: var(--warm-gray); }
.type-toggle label:has(input:checked) {
  border-color: var(--navy);
  background: var(--cream);
  box-shadow: 0 0 0 3px rgba(26,39,68,.06);
}
.type-toggle input { width: auto; margin: 0; flex-shrink: 0; accent-color: var(--navy); }
.type-toggle strong {
  display: block;
  font-size: 14px;
  color: var(--navy);
  margin-bottom: 2px;
}
.type-toggle .hint { display: block; font-style: normal; }
@media (max-width: 600px) {
  .type-toggle { flex-direction: column; }
}

/* BUTTONS */
.btn-row { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }
.btn {
  padding: 13px 28px; border-radius: 8px;
  font-family: 'Lato', sans-serif; font-size: 14px;
  font-weight: 700; cursor: pointer; border: none;
  transition: all .2s; letter-spacing: 0.5px;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: #253460; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(26,39,68,.25); }
.btn-secondary { background: white; color: var(--navy); border: 2px solid var(--navy); }
.btn-secondary:hover { background: var(--cream); }
.btn-gold { background: var(--gold); color: white; }
.btn-gold:hover { background: #b8882e; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(201,151,58,.35); }

/* AMOUNT SUMMARY */
.amount-summary {
  background: var(--navy);
  border-radius: 10px;
  padding: 20px 24px;
  margin-top: 16px;
  color: white;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
}
.amount-summary .label { font-size: 12px; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }
.amount-summary .value { font-family: 'Playfair Display', serif; font-size: 28px; color: var(--gold); }
.amount-summary .words { font-size: 13px; opacity: 0.85; font-style: italic; margin-top: 2px; }

/* PREVIEW */
#preview-panel .card { padding: 0; overflow: hidden; }

.quittance-doc {
  font-family: 'Lato', sans-serif;
  max-width: 700px; margin: 0 auto;
  padding: 50px 56px;
  color: #1a1a1a;
  background: white;
}

.doc-header {
  display: flex; justify-content: space-between;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--navy);
}
.doc-bailleur { font-size: 13px; line-height: 1.8; }
.doc-bailleur strong { font-size: 15px; color: var(--navy); }
.doc-locataire { text-align: right; font-size: 13px; line-height: 1.8; }
.doc-locataire strong { font-size: 15px; color: var(--navy); }

.doc-title {
  text-align: center;
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  color: var(--navy);
  margin-bottom: 6px;
}
.doc-numero {
  text-align: center;
  font-size: 12px; color: var(--gold);
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.doc-mois {
  text-align: center;
  font-size: 14px; color: var(--warm-gray);
  text-transform: uppercase; letter-spacing: 2px;
  margin-bottom: 28px;
}
.doc-adresse {
  text-align: center;
  font-size: 14px; color: var(--text);
  margin-bottom: 24px;
  padding: 12px; background: var(--cream);
  border-radius: 6px;
  border-left: 4px solid var(--gold);
}
.doc-adresse strong { display: block; font-size: 13px; color: var(--warm-gray); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }

.doc-body {
  font-size: 14px; line-height: 1.85;
  margin-bottom: 24px;
  text-align: justify;
}

.doc-detail {
  border: 1px solid var(--light-border);
  border-radius: 8px;
  overflow: hidden;
  margin: 20px 0 24px;
}
.doc-detail-title {
  background: var(--navy); color: white;
  padding: 10px 16px; font-size: 12px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
}
.doc-detail-row {
  display: flex; justify-content: space-between;
  padding: 10px 16px; font-size: 14px;
  border-bottom: 1px solid var(--light-border);
}
.doc-detail-row:last-child { border-bottom: none; }
.doc-detail-total {
  display: flex; justify-content: space-between;
  padding: 12px 16px; font-weight: 700;
  background: var(--cream); font-size: 15px;
}

.doc-date-paiement {
  font-size: 13px; color: var(--warm-gray);
  margin-bottom: 30px;
}

.doc-signature {
  display: flex; justify-content: flex-end;
  margin-bottom: 40px;
}
.doc-sig-box {
  border: 1px solid var(--light-border);
  border-radius: 8px; padding: 16px 24px;
  text-align: center; min-width: 200px;
}
.doc-sig-box .label { font-size: 11px; color: var(--warm-gray); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 40px; display: block; }
.doc-sig-box .sig-name { font-size: 13px; font-weight: 700; color: var(--navy); border-top: 1px solid var(--light-border); padding-top: 10px; }

.doc-footer {
  font-size: 11px; color: var(--warm-gray);
  line-height: 1.7;
  border-top: 1px solid var(--light-border);
  padding-top: 16px;
  font-style: italic;
}

/* FAQ (SEO content) */
.faq-section {
  background: white;
  border-top: 1px solid var(--light-border);
  padding: 64px 20px;
}
.faq-container {
  max-width: 820px;
  margin: 0 auto;
}
.faq-section h2 {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: var(--navy);
  margin-bottom: 28px;
  text-align: center;
  font-weight: 600;
}
.faq-section details {
  border: 1px solid var(--light-border);
  border-radius: 10px;
  padding: 16px 22px;
  margin-bottom: 12px;
  background: var(--cream);
  transition: all .2s;
}
.faq-section details[open] {
  background: white;
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(201,151,58,.08);
}
.faq-section summary {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  color: var(--navy);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary::after {
  content: '+';
  color: var(--gold);
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  transition: transform .2s;
  flex-shrink: 0;
}
.faq-section details[open] summary::after { transform: rotate(45deg); }
.faq-section details p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.75;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--light-border);
}

/* SITE FOOTER */
.site-footer {
  background: var(--navy);
  color: white;
  text-align: center;
  padding: 32px 20px 36px;
  font-size: 13px;
  line-height: 1.6;
}
.site-footer p { margin-bottom: 6px; opacity: 0.85; }
.site-footer .credit {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 4px;
}
.site-footer a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
}
.site-footer a:hover { text-decoration: underline; }

/* PRINT — quittance tenant en 1 page A4 */
@media print {
  @page { size: A4; margin: 0; }

  header, .steps, .btn-row, .section-title, .section-sub, .print-notice,
  .faq-section, .site-footer { display: none !important; }

  html, body {
    background: white;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .container { padding: 0; max-width: 100%; margin: 0; }
  .card { border: none; border-radius: 0; padding: 0; margin: 0; box-shadow: none; }
  #preview-panel { display: block !important; margin: 0; }

  .quittance-doc {
    max-width: 100%;
    padding: 14mm 18mm;
    font-size: 12px;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .doc-header {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom-width: 2px;
  }
  .doc-bailleur, .doc-locataire {
    font-size: 11px;
    line-height: 1.55;
  }
  .doc-bailleur strong, .doc-locataire strong { font-size: 13px; }

  .doc-title { font-size: 22px; margin-bottom: 2px; }
  .doc-mois  { font-size: 12px; margin-bottom: 16px; letter-spacing: 1.5px; }

  .doc-adresse {
    font-size: 12px;
    padding: 8px 10px;
    margin-bottom: 14px;
  }
  .doc-adresse strong { font-size: 11px; margin-bottom: 2px; }

  .doc-body {
    font-size: 12px;
    line-height: 1.65;
    margin-bottom: 14px;
  }

  .doc-detail { margin: 12px 0 16px; }
  .doc-detail-title { padding: 7px 12px; font-size: 11px; }
  .doc-detail-row, .doc-detail-total {
    padding: 7px 12px;
    font-size: 12px;
  }
  .doc-detail-total { font-size: 13px; }

  .doc-date-paiement { font-size: 11px; margin-bottom: 14px; }

  .doc-signature {
    margin-bottom: 14px;
    page-break-inside: avoid;
  }
  .doc-sig-box { padding: 10px 16px; min-width: 160px; }
  .doc-sig-box .label { margin-bottom: 26px; font-size: 10px; }
  .doc-sig-box .sig-name { font-size: 12px; padding-top: 8px; }

  .doc-footer {
    font-size: 9.5px;
    line-height: 1.5;
    padding-top: 10px;
  }
}

.print-notice {
  background: #fffbe6;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px; color: #856404;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}

@media (max-width: 600px) {
  .row, .row.three { grid-template-columns: 1fr; }
  .doc-header { flex-direction: column; gap: 16px; }
  .doc-locataire { text-align: left; }
  .quittance-doc { padding: 28px 20px; }
  .step-btn span:not(.num) { display: none; }
}
