:root {
  --orange: #f28322;
  --orange-dark: #d9711a;
  --orange-light: #fff3e8;
  --navy: #1e293b;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-size: 22px;
  vertical-align: middle;
  line-height: 1;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding-inline: 16px;
}

/* Header */
.site-header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-block: 10px;
  min-height: 64px;
}
.brand { display: inline-flex; flex-shrink: 0; }
.brand-logo {
  height: 44px;
  width: auto;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  display: block;
}
.brand-text { flex: 1; min-width: 0; }
.brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
  color: #fff;
}
.brand-subtitle { margin: 0; font-size: 0.8rem; color: #cbd5e1; }
.site-header .menu-toggle { display: none; color: #fff; border-color: rgba(255,255,255,0.3); }

/* Banner */
.banner {
  background: var(--orange-light);
  border-bottom: 1px solid #fcd9b6;
}
.banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
  flex-wrap: wrap;
}
.banner-inner .material-symbols-outlined { color: var(--orange); }
.banner-text { margin: 0; flex: 1; min-width: 200px; font-weight: 500; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding-block: 24px;
  flex: 1;
  align-items: start;
}
.sidebar { position: sticky; top: 80px; }
.sidebar-inner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.sidebar-title {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.steps-list { list-style: none; margin: 0; padding: 0; }
.steps-list li { margin: 0; }
.step-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  background: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.step-link:hover { background: var(--bg); }
.step-link .step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.step-link.is-current { background: var(--orange-light); font-weight: 600; }
.step-link.is-current .step-num { border-color: var(--orange); background: var(--orange); color: #fff; }
.step-link.is-done .step-num { border-color: var(--success); color: var(--success); }
.step-link.has-error .step-num { border-color: var(--error); color: var(--error); }
.sidebar-save { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 35;
}

/* Progress */
.progress-block { margin-bottom: 16px; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.step-counter { font-weight: 600; color: var(--navy); }
.save-indicator {
  font-size: 0.82rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.save-indicator.is-saving { color: var(--orange-dark); }
.save-indicator.is-offline { color: var(--error); }
.save-indicator.is-saved { color: var(--success); }
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Cards / sections */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.section { display: none; }
.section.is-active { display: block; }
.section-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
  color: var(--navy);
  font-weight: 700;
}
.section-intro { margin: 0 0 20px; color: var(--muted); font-size: 0.92rem; }
.group-title {
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--orange-light);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.group-title:first-child { margin-top: 0; }

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field.is-indented { padding-left: 16px; border-left: 3px solid var(--orange-light); }
.field-label {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--navy);
}
.field-label .req { color: var(--error); margin-left: 2px; }
.field-help { font-size: 0.8rem; color: var(--muted); margin: -2px 0 0; }
.field-error { font-size: 0.8rem; color: var(--error); margin: 0; display: none; }
.field.has-error .field-error { display: block; }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 131, 34, 0.2);
}
.field.has-error input, .field.has-error select, .field.has-error textarea,
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-bg);
}
.input-suffix { position: relative; }
.input-suffix input { padding-right: 44px; }
.input-suffix .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* Choice groups */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.is-vertical { flex-direction: column; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.93rem;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--orange); }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--orange); flex-shrink: 0; }
.choice.is-checked { border-color: var(--orange); background: var(--orange-light); }
.field.has-error .choice { border-color: var(--error); }

/* Repeatable (bâtiments, sinistres) */
.repeat-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  background: #fcfcfd;
}
.repeat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.repeat-head h3 { margin: 0; font-size: 1.05rem; color: var(--navy); }
.repeat-add { margin-top: 8px; }
.sinistre-row {
  display: grid;
  grid-template-columns: 160px 160px 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.sinistre-row .field { gap: 4px; }
.sinistre-row .field-label { font-size: 0.82rem; }

/* Files */
.file-drop {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  background: #fff;
}
.file-drop .material-symbols-outlined { font-size: 36px; color: var(--orange); }
.file-drop p { margin: 6px 0 12px; color: var(--muted); font-size: 0.9rem; }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; }
.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
  font-size: 0.9rem;
}
.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-size { color: var(--muted); font-size: 0.8rem; flex-shrink: 0; }
.doc-checklist { margin: 0 0 16px; padding-left: 20px; color: var(--muted); font-size: 0.9rem; columns: 2; column-gap: 24px; }
.doc-checklist li { break-inside: avoid; }

/* Declarations */
.legal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 0.86rem;
  color: #334155;
  max-height: 360px;
  overflow-y: auto;
  margin-bottom: 20px;
}
.legal p { margin: 0 0 10px; }
.legal p:last-child { margin: 0; }
.certify {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-weight: 500;
}
.certify input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--orange); flex-shrink: 0; }
.field.has-error .certify { border-color: var(--error); background: var(--error-bg); }

/* Recap */
.recap { margin-top: 24px; }
.recap-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.recap-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--bg);
  font-weight: 600;
  color: var(--navy);
  min-height: 44px;
  list-style: none;
}
.recap-section summary::-webkit-details-marker { display: none; }
.recap-section summary .recap-edit {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--orange-dark);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 6px;
}
.recap-section summary .recap-edit:hover { background: var(--orange-light); }
.recap-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.recap-table th, .recap-table td { padding: 8px 16px; border-top: 1px solid var(--border); vertical-align: top; text-align: left; }
.recap-table th { width: 45%; font-weight: 500; color: var(--muted); }
.recap-table td.is-empty { color: #94a3b8; font-style: italic; }
.recap-sub { font-weight: 600; color: var(--navy); background: #fafbfc; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: #cbd5e1; }
.btn-secondary:hover:not(:disabled) { border-color: var(--navy); }
.btn-ghost { background: transparent; color: inherit; border-color: var(--border); }
.btn-danger { background: #fff; color: var(--error); border-color: #fecaca; }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
.btn-icon { padding: 8px; min-width: 44px; }
.btn-block { width: 100%; }
.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.nav-buttons .btn-submit { flex: 1; }
.form-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--error-bg);
  border: 1px solid #fecaca;
  color: var(--error);
  border-radius: 8px;
  font-size: 0.92rem;
}

/* Confirmation */
.confirmation { text-align: center; padding: 40px 24px; }
.confirmation-icon { font-size: 64px; color: var(--success); }
.confirmation h2 { color: var(--navy); margin: 12px 0 8px; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(15,23,42,0.3);
}
.modal-card h2 { margin: 0 0 8px; color: var(--navy); font-size: 1.2rem; }
.link-row { display: flex; gap: 8px; margin-top: 12px; }
.link-row input { flex: 1; font-size: 0.85rem; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

/* Footer */
.site-footer {
  margin-top: 32px;
  padding-block: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.site-footer p { margin: 0; }

/* Home */
.home { padding-block: 40px; flex: 1; }
.home h2 { color: var(--navy); margin: 0 0 20px; font-size: 1.5rem; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.home-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; transition: border-color 0.15s, transform 0.15s; }
.home-card:hover { border-color: var(--orange); transform: translateY(-2px); }
.home-card .material-symbols-outlined { font-size: 36px; color: var(--orange); }
.home-card h3 { margin: 0; color: var(--navy); font-size: 1.1rem; }
.home-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.home-card .cta { margin-top: auto; color: var(--orange-dark); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* Utilities */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .site-header .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 16px;
    background: var(--card);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-inner { border: 0; box-shadow: none; padding: 0; }
}
@media (max-width: 640px) {
  .fields-grid { grid-template-columns: 1fr; }
  .brand-title { font-size: 0.9rem; }
  .brand-subtitle { font-size: 0.75rem; }
  .brand-logo { height: 38px; }
  .card { padding: 16px; }
  .sinistre-row { grid-template-columns: 1fr 1fr; }
  .sinistre-row .field:nth-child(3) { grid-column: 1 / -1; }
  .doc-checklist { columns: 1; }
  .nav-buttons .btn { flex: 1; }
  .link-row { flex-direction: column; }
  .recap-table th { width: 50%; }
  .banner-actions { width: 100%; }
  .banner-actions .btn { flex: 1; }
}
