*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #15161A; --yellow: #F5B700; --muted: #6B6C72; --border: #E3E3E6;
  --panel: #FAFAFB; --green: #1F8A53; --red: #C5343A;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, 'Segoe UI', sans-serif;
  color: #2A2B30; background: #F6F6F8;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}

/* HEADER */
.topbar {
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 4px solid var(--yellow);
  position: sticky; top: 0; z-index: 10;
}
.brand-left .group {
  font-size: 10px; letter-spacing: 3px; font-weight: 700; color: var(--yellow);
}
.brand-left .dealer { font-size: 19px; font-weight: 700; margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .rlogo { height: 38px; width: auto; display: block; }
.install-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--yellow);
  border: 1.5px solid var(--yellow); border-radius: 6px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: background .15s, color .15s;
}
.install-btn:hover { background: var(--yellow); color: var(--ink); }

/* MAIN */
main {
  flex: 1; width: 100%; max-width: 760px;
  margin: 0 auto; padding: 32px 24px 24px;
}
.eyebrow {
  font-size: 11px; letter-spacing: 2.6px; font-weight: 700; color: #9A8A3C;
}
h1 {
  font-size: 30px; font-weight: 700; color: var(--ink);
  margin-top: 2px; letter-spacing: -0.4px;
}
.rule { width: 36px; height: 3px; background: var(--yellow); margin-top: 10px; }
.intro {
  font-size: 14.5px; line-height: 1.55; color: #4A4B52; margin-top: 14px;
}

/* STEPS */
.step {
  margin-top: 22px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; display: flex; gap: 16px; align-items: flex-start;
}
.step[hidden] { display: none; }
.step-num {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  background: var(--yellow); color: var(--ink);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.step-body { flex: 1; min-width: 0; }
.step-title { font-size: 14.5px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.step-hint { font-weight: 400; color: var(--muted); font-size: 13px; }

/* COVER STATUS */
.cover-status {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
}
.cover-status .check {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.cover-status .cover-info { flex: 1; min-width: 0; }
.cover-status .filename { font-size: 13px; font-weight: 700; color: var(--ink); }
.cover-status .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* DROPZONE */
.dropzone {
  position: relative; border: 2px dashed #C7C8CE; border-radius: 10px;
  background: var(--panel); padding: 28px 20px;
  text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--yellow); background: #FFFBEC;
}
.dropzone.has-file { cursor: default; padding: 14px; text-align: left; }
.dz-empty .cloud { width: 38px; height: 38px; color: #9A9BA2; margin-bottom: 8px; }
.dz-text { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.dz-text span { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.dz-filled { display: none; }
.dropzone.has-file .dz-empty { display: none; }
.dropzone.has-file .dz-filled { display: block; }
.file-card {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px;
}
.file-card .pdf-ic {
  width: 36px; height: 36px; flex-shrink: 0;
  background: #E64545; color: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: 0.4px;
}
.file-card .fi { flex: 1; min-width: 0; }
.file-card .fname {
  font-size: 13.5px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-card .fmeta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.file-card .rmbtn {
  border: none; background: #EEEEF0; color: #6B6C72;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 16px; cursor: pointer; line-height: 1;
  flex-shrink: 0;
}
.file-card .rmbtn:hover { background: #DEDFE3; color: var(--ink); }

/* FIELDS */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-full { grid-column: 1 / -1; }
.field .lbl { font-size: 12px; font-weight: 700; color: var(--ink); letter-spacing: 0.2px; }
.field .lbl .opt { color: var(--muted); font-weight: 400; }
.field input {
  font: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: 7px;
  padding: 9px 11px; background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus {
  outline: none; border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(245,183,0,0.18);
}
.field .detected { font-size: 11.5px; color: var(--muted); }

/* CTA */
.cta {
  margin-top: 24px; width: 100%;
  background: var(--yellow); color: var(--ink); border: none;
  padding: 16px 20px; border-radius: 10px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.2px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s, background .15s, box-shadow .15s;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.cta:not(:disabled):hover { background: #FFC824; box-shadow: 0 4px 14px rgba(245,183,0,0.35); }
.cta:not(:disabled):active { transform: translateY(1px); }
.cta:disabled { background: #E3E3E6; color: #9A9BA2; cursor: not-allowed; box-shadow: none; }
.cta svg { width: 18px; height: 18px; }
.cta.loading .icon-default { display: none; }
.cta .spinner { display: none; width: 18px; height: 18px; border: 2px solid currentColor;
                border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.cta.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* STATUS */
.status { margin-top: 14px; font-size: 13px; min-height: 20px; text-align: center; }
.status.pending { color: var(--muted); }
.status.error {
  background: #FDEDEE; border: 1px solid #F5C2C5; color: var(--red);
  padding: 12px 14px; border-radius: 8px; font-weight: 600; text-align: left;
}
.status.success {
  background: #ECF8F1; border: 1px solid #C8E8D4;
  color: #1F8A53; padding: 14px 16px; border-radius: 8px;
  font-weight: 600; text-align: left;
  display: flex; align-items: center; gap: 12px;
}
.status.success .check {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.status.success .info { flex: 1; min-width: 0; }
.status.success .info strong {
  display: block; color: var(--ink); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status.success .info span { font-weight: 400; color: var(--muted); font-size: 12px; }
.status.success .again {
  background: #fff; border: 1px solid #B7DCC4; color: #1F8A53;
  padding: 7px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.status.success .again:hover { background: #F6FBF8; }

/* FOOTER */
footer {
  border-top: 1px solid var(--border); padding: 12px 24px;
  color: var(--muted); font-size: 12px;
  background: #fff;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
footer .version { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
#swState.ready { color: var(--green); }
#swState.offline { color: var(--yellow); }

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .brand-left .dealer { font-size: 16px; }
  main { padding: 22px 16px; }
  h1 { font-size: 24px; }
  .step { padding: 14px 14px; gap: 12px; }
  .fields { grid-template-columns: 1fr; }
}

/* ===== v1.2 : file d'attente, aperçu, préférences ===== */
.pref-toggle {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; font-size: 13px; color: #4A4B52; cursor: pointer;
  user-select: none;
}
.pref-toggle input { accent-color: var(--yellow); width: 16px; height: 16px; cursor: pointer; }

.dropzone.compact { padding: 14px 16px; }
.dropzone.compact .cloud { width: 24px; height: 24px; margin-bottom: 2px; }
.dropzone.compact .dz-text { font-size: 13px; }
.dropzone.compact .dz-text span { display: inline; margin-left: 4px; }

.queue { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.fcard {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px;
}
.fcard-head { display: flex; align-items: center; gap: 12px; }
.fcard-head .pdf-ic {
  width: 34px; height: 34px; flex-shrink: 0;
  background: #E64545; color: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}
.fcard-head .fi { flex: 1; min-width: 0; }
.fcard-head .fname {
  font-size: 13.5px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fcard-head .fmeta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.fcard-head .previewBtn {
  border: 1px solid var(--border); background: var(--panel); color: #4A4B52;
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: border-color .12s, color .12s;
}
.fcard-head .previewBtn:hover { border-color: var(--yellow); color: var(--ink); }
.fcard-head .previewBtn:disabled { opacity: .5; cursor: wait; }
.fcard-head .rmbtn {
  border: none; background: #EEEEF0; color: #6B6C72;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 16px; cursor: pointer; line-height: 1; flex-shrink: 0;
}
.fcard-head .rmbtn:hover { background: #DEDFE3; color: var(--ink); }

.fcard-warn {
  margin-top: 10px; background: #FFF6E5; border: 1px solid #F2DBA6;
  color: #8A6D1B; border-radius: 8px; padding: 10px 12px;
  font-size: 12.5px; line-height: 1.5;
}
.fcard-fields { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fcard-preview { margin-top: 12px; text-align: center; }
.fcard-preview canvas {
  max-width: 100%; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.fcard-preview .preview-note { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.fcard-done {
  margin-top: 10px; background: #ECF8F1; border: 1px solid #C8E8D4;
  color: #1F8A53; border-radius: 8px; padding: 9px 12px;
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 560px) {
  .fcard-fields { grid-template-columns: 1fr; }
}

/* ===== v1.3 : sélecteur de format ===== */
.fcard-format {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px;
}
.fcard-format .fmt-lbl { font-size: 12px; font-weight: 700; color: var(--ink); }
.fmt-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.fmt-opt {
  border: none; background: #fff; color: #4A4B52;
  padding: 6px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
  border-right: 1px solid var(--border); transition: background .12s, color .12s;
  white-space: nowrap;
}
.fmt-opt:last-child { border-right: none; }
.fmt-opt:hover { background: var(--panel); }
.fmt-opt.active { background: var(--ink); color: #fff; }
.fmt-opt.active:hover { background: #2A2B30; }

@media (max-width: 560px) {
  .fcard-format { gap: 6px; }
  .fmt-opt { padding: 6px 8px; font-size: 11px; }
}

/* ===== v1.5 : sélecteur de marque ===== */
.brd-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.brd-opt {
  border: none; background: #fff; color: #4A4B52;
  padding: 6px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
  border-right: 1px solid var(--border); transition: background .12s, color .12s;
  white-space: nowrap;
}
.brd-opt:last-child { border-right: none; }
.brd-opt:hover { background: var(--panel); }
.brd-opt.active { background: var(--ink); color: #fff; }
.brd-opt.active:hover { background: #2A2B30; }
/* Bouton Dacia actif → vert charte Dacia */
.brd-opt.dacia.active { background: #646b52; color: #fff; }
.brd-opt.dacia.active:hover { background: #555b46; }

@media (max-width: 560px) {
  .brd-opt { padding: 6px 9px; font-size: 11px; }
}

/* ===== v1.8 : profil vendeur ===== */
.vendor { margin-top: 22px; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.vendor-head { width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; background: none; border: none; cursor: pointer; text-align: left; }
.vendor-head-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vendor-ic { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
  background: #EEEEF0; color: #9A9BA2; }
.vendor-ic.set { background: var(--yellow); color: var(--ink); }
.vendor-title { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.vendor-sub { font-size: 12px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.vendor-head .chev { color: var(--muted); transition: transform .15s; flex-shrink: 0; }
.vendor-head.open .chev { transform: rotate(180deg); }
.vendor-body { padding: 4px 18px 18px; border-top: 1px solid var(--border); }
.vendor-note { font-size: 12.5px; color: #4A4B52; line-height: 1.5; margin: 12px 0 14px; }
.vfields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vfields .field-full { grid-column: 1 / -1; }
.vphoto-row { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.vphoto-prev { width: 64px; height: 64px; border-radius: 8px; flex-shrink: 0;
  border: 1px dashed #C7C8CE; background: var(--panel) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; }
.vphoto-prev span { font-size: 10px; color: var(--muted); }
.vphoto-prev.has { border-style: solid; border-color: var(--border); }
.vphoto-prev.has span { display: none; }
.vphoto-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.vphoto-hint { font-size: 11.5px; color: var(--muted); }
.vbtn { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--border);
  background: #fff; color: var(--ink); border-radius: 7px; padding: 8px 14px; cursor: pointer; }
.vbtn:hover { background: var(--panel); }
.vbtn.primary { background: var(--yellow); border-color: var(--yellow); }
.vbtn.primary:hover { background: #FFC824; }
.vbtn.ghost { border: none; color: var(--muted); }
.vbtn.ghost:hover { color: var(--ink); background: var(--panel); }
.vendor-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.vendor-saved { font-size: 12.5px; font-weight: 600; color: var(--green); }
@media (max-width: 560px) { .vfields { grid-template-columns: 1fr; } .vendor-sub { max-width: 48vw; } }

/* select profil (secrétaire) */
.field select {
  font: inherit; font-size: 14px; color: var(--ink); background: #fff;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%;
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B6C72' stroke-width='2.4' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field select:focus { outline: none; border-color: var(--yellow); }
