:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 70px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 15px;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 15px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-area h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Cartes et sections */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-badge {
  background: var(--primary);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.card-body {
  padding: 18px;
}

.section-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 15px;
}

/* Formulaires & Grilles */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.full-width {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.req {
  color: var(--danger);
  font-weight: bold;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: #0f172a;
  background-color: #fff;
  transition: border-color 0.15s ease-in-out;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

/* Uploads Photos */
.photo-upload-block {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fdfdfd;
  margin-top: 10px;
  transition: all 0.2s;
}

.photo-upload-block.ready {
  border-color: var(--success);
  background: var(--success-light);
}

.photo-upload-block.missing {
  border-color: var(--danger);
  background: var(--danger-light);
}

.photo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.status-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: #e2e8f0;
  color: #475569;
}

.photo-upload-block.ready .status-indicator {
  background: #10b981;
  color: #fff;
}

.photo-upload-block.missing .status-indicator {
  background: #ef4444;
  color: #fff;
}

.photo-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.file-input {
  display: block;
  width: 100%;
  font-size: 0.85rem;
  margin-top: 5px;
}

.preview-area {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-img-wrapper {
  position: relative;
  width: 100%;
  max-height: 220px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.preview-img-wrapper img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}

.preview-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}

/* Checkboxes */
.checkbox-options, .checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 10px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* Tableaux */
.table-responsive {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.custom-table th, .custom-table td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.custom-table th {
  background: #f1f5f9;
  font-weight: 600;
}

.table-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Schéma SVG & Dommages */
.car-interactive-area {
  position: relative;
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  touch-action: manipulation;
}

.car-interactive-area svg {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.damage-pin-circle {
  cursor: pointer;
  transition: transform 0.15s;
}

.damage-pin-circle:hover {
  transform: scale(1.2);
}

.damages-list-container {
  margin-top: 15px;
  background: #f8fafc;
  border-radius: 6px;
  padding: 12px;
  border: 1px solid var(--border);
}

.damages-list-container h4 {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.damage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 5px;
  font-size: 0.85rem;
}

.btn-delete-damage {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: bold;
  cursor: pointer;
  padding: 2px 6px;
}

/* Signatures */
.canvas-container {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  margin-top: 6px;
  position: relative;
  touch-action: none;
}

.canvas-container canvas {
  display: block;
  width: 100%;
  height: 160px;
  cursor: crosshair;
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  padding: 9px 16px;
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 20px;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.mt-1 { margin-top: 5px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 15px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1rem;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Spinner & Loading */
.loading-box {
  margin-top: 15px;
  text-align: center;
  background: #f1f5f9;
  padding: 15px;
  border-radius: 8px;
}

.loading-box.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Alertes */
.alert-box {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 0.9rem;
}

.alert-box.hidden {
  display: none;
}

.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #f87171;
}

.alert-success {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #34d399;
}

/* Footer */
.app-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 14px 15px;
  margin-top: 30px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

@media (min-width: 640px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}
