:root{
  --bg:#0b0f14;
  --panel:#111824;
  --panel2:#0f1621;
  --txt:#e8eef6;
  --muted:#9fb0c3;
  --ok:#32d583;
  --warn:#fdb022;
  --err:#f97066;
  --btn:#2563eb;
  --btn2:#1f2937;
  --border:#223044;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background:var(--bg);
  color:var(--txt);
}

a{ color:#93c5fd; text-decoration:none; }
a:hover{ text-decoration:underline; }

.container{
  max-width:1100px;
  margin:0 auto;
  padding:18px;
}

.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px;
}

.row{ display:flex; gap:12px; flex-wrap:wrap; }
.row > *{ flex:1; min-width:220px; }

label{ display:block; font-size:13px; color:var(--muted); margin-bottom:6px; }
input,select{
  width:100%;
  padding:12px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
}

button{
  cursor:pointer;
  border:0;
  border-radius:12px;
  padding:12px 14px;
  font-weight:600;
}
.btn{ background:var(--btn); color:white; }
.btn.secondary{ background:var(--btn2); color:var(--txt); border:1px solid var(--border); }
.btn.danger{ background:#b42318; }
.btn.ok{ background:#027a48; }
.btn:disabled{ opacity:.6; cursor:not-allowed; }

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  background:rgba(17,24,36,.92);
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  z-index:50;
  backdrop-filter: blur(8px);
}

.topbar .left, .topbar .right{ display:flex; gap:8px; align-items:center; }
.badge{
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--border);
  background:rgba(15,22,33,.75);
  color:var(--muted);
  font-size:12px;
}

hr{ border:0; border-top:1px solid var(--border); margin:14px 0; }

.table{
  width:100%;
  border-collapse:collapse;
  overflow:hidden;
  border:1px solid var(--border);
  border-radius:12px;
}
.table th, .table td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  font-size:14px;
  vertical-align:top;
}
.table th{
  color:var(--muted);
  font-weight:600;
  text-align:left;
  background:rgba(15,22,33,.7);
}
.table tr:last-child td{ border-bottom:0; }

.notice{ padding:10px 12px; border-radius:12px; border:1px solid var(--border); background:rgba(15,22,33,.6); color:var(--muted); }
.notice.ok{ border-color:rgba(50,213,131,.35); color:#b7f5d6; }
.notice.err{ border-color:rgba(249,112,102,.35); color:#ffd4d0; }
.notice.warn{ border-color:rgba(253,176,34,.35); color:#ffe4b5; }

.modalBackdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.65);
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:100;
}
.modal{
  width:min(920px, 100%);
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
}
.modalHeader{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.modalHeader h3{ margin:0; font-size:16px; }
.modalBody{ margin-top:10px; }

#viewerContainer{
  height: calc(100vh - 62px);
  overflow:auto;
  background:#0b0f14;
}

.sigCanvasWrap{
  background:#0b0f14;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
}
#sigCanvas{
  width:100%;
  height:260px;
  display:block;
  touch-action:none;
  background:#fff;
}

.small{ font-size:12px; color:var(--muted); }

/* --- PDF.js fix: container must be absolutely positioned --- */
#pdfRoot{
  position: relative;
  height: 100vh;
}
#pdfRoot .topbar{
  position: sticky;
  top: 0;
  z-index: 50;
}
#viewerContainer{
  position: absolute;
  left: 0;
  right: 0;
  top: 62px; /* hauteur approx de la topbar */
  bottom: 0;
  height: auto !important;
}

/* --- PDF.js form alignment fixes --- */
.annotationLayer, .annotationLayer * {
  box-sizing: content-box !important; /* IMPORTANT: sinon champs trop grands/décalés */
}
.annotationLayer section {
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
}
#viewerContainer{
  -webkit-overflow-scrolling: touch;
}

/* --- Contract form layout (clean) --- */
.sectionTitle{
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 10px 0;
  letter-spacing: .2px;
}
.sectionSub{
  margin: -6px 0 12px 0;
  opacity: .85;
}
.formGrid2{
  display: grid;
  grid-template-columns: 1.3fr .9fr;
  gap: 14px;
}
@media (max-width: 900px){
  .formGrid2{ grid-template-columns: 1fr; }
}
.fieldGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px){
  .fieldGrid{ grid-template-columns: 1fr; }
}

.fieldCard{
  padding: 12px;
}
.fieldCard label{
  display:block;
  font-weight: 700;
  margin-bottom: 6px;
}
.reqStar{
  color: rgba(249,112,102,.95);
  margin-left: 4px;
  font-weight: 900;
}
.fieldCard input[type="text"],
.fieldCard input[type="email"],
.fieldCard input[type="tel"],
.fieldCard input[type="date"]{
  width: 100%;
}

.productsTable{
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.productsTable th, .productsTable td{
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.productsTable th{
  text-align: left;
  font-size: 13px;
  opacity: .9;
}
.productsTable td input{
  width: 100%;
}
.productsTable td.qty input{
  max-width: 110px;
}
.productsTable td.price input{
  max-width: 170px;
}
.productsTable tr:last-child td{ border-bottom: 0; }

.smallHint{
  font-size: 12px;
  opacity: .75;
  margin-top: 6px;
}
