:root {
  --bg: #f6f4ef;
  --panel: #fff;
  --text: #1c1c1c;
  --muted: #5c5c5c;
  --accent: #2d4a3e;
  --accent-light: #e8f0ec;
  --border: #ddd8ce;
  --error: #8b2e2e;
  --step: #4a6741;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  background: var(--accent);
  color: #fff;
  padding: 1.5rem 2rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

header h1 { margin: 0; font-size: 1.6rem; }

.logout-btn {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
}

.logout-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  transform: none;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 1rem;
}

.login-panel h1 {
  margin: 0 0 0.35rem;
  color: var(--accent);
}

.login-panel .erreur { margin: 0.75rem 0 0; }

main {
  max-width: 920px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.step-panel.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.step-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--step);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.step-badge.done { background: var(--accent); }

/* ── Panneau d'activité ── */
.activity-panel {
  background: linear-gradient(135deg, #1e3329 0%, var(--accent) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(45, 74, 62, 0.25);
}

.activity-label {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.activity-hint {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  opacity: 0.92;
  line-height: 1.4;
}

.activity-hint:empty { display: none; }

.activity-panel.loading .activity-label::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -0.1rem;
}

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

.dossier-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dossier-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.dossier-card:hover,
.dossier-card:focus {
  border-color: var(--accent);
  outline: none;
}

.dossier-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.dossier-card h3 {
  margin: 0 0 0.3rem;
  font-size: 1.02rem;
}

.dossier-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn-delete {
  flex-shrink: 0;
  background: transparent;
  color: var(--error);
  border: 1px solid #e4c4c4;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

.btn-delete:hover:not(:disabled) {
  background: #f8ecec;
  box-shadow: none;
  transform: none;
}

label {
  display: block;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}

label:first-of-type,
.file-label:first-of-type { margin-top: 0; }

.file-label {
  display: block;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  padding: 1.1rem 1rem;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}

.dropzone strong {
  font-size: 1rem;
}

.dropzone span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 400;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: #dce8e2;
}

.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pdf-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pdf-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.pdf-list .pdf-name {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-list .pdf-size {
  color: var(--muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.pdf-list .pdf-remove {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.15rem 0.4rem;
  font-size: 1.1rem;
  line-height: 1;
}

.pdf-list .pdf-remove:hover:not(:disabled) {
  color: var(--error);
  background: #f8ecec;
  box-shadow: none;
  transform: none;
}

select, textarea, input[type="text"], input[type="file"], input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

button {
  font: inherit;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(45, 74, 62, 0.2);
}

button.secondary {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--border);
}

button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.hint { color: var(--muted); font-size: 0.92rem; }
.erreur { color: var(--error); font-weight: 600; }
.hidden { display: none !important; }

.bloc { margin-top: 1.25rem; }
.bloc h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.contenu-text { white-space: pre-wrap; }

.stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.stat-chip {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
}

.stat-chip strong { display: block; font-size: 1.2rem; color: var(--accent); }

/* ── Accordéons cliquables ── */
.accordion {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  text-align: left;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s;
}

.accordion-trigger:hover {
  background: #dce8e2;
  transform: none;
  box-shadow: none;
}

.chevron {
  display: inline-block;
  width: 1rem;
  transition: transform 0.2s;
  font-size: 0.85rem;
}

.accordion-trigger[aria-expanded="true"] .chevron {
  transform: rotate(0deg);
}

.accordion-panel {
  display: none;
  padding: 0.85rem 1rem 1rem;
  background: #fff;
  border-top: 1px solid var(--border);
}

.accordion-panel.open {
  display: block;
}

.item-list { font-size: 0.92rem; }

.contract-item {
  border-left: 3px solid var(--accent);
  padding: 0.55rem 0 0.55rem 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--accent-light);
  border-radius: 0 6px 6px 0;
}

.item-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.item-title.garantie-title {
  font-weight: 700;
  color: var(--accent);
}

.exclusion-item {
  border-left-color: #8b7355;
  background: #f5f0e8;
}

.exclusion-item .item-title {
  font-weight: 400;
  color: var(--text);
}

.justif-item {
  border-left-color: #3d5a80;
  background: #eef3f8;
}

.ref {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.92em;
}

.field-row {
  margin-top: 0.2rem;
  font-size: 0.92rem;
}

.field-row em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
}

.justif-item ul {
  margin: 0.35rem 0 0.5rem 1.1rem;
  padding: 0;
}

.justif-item li { margin-bottom: 0.2rem; }

#raw-output {
  background: #f0eeea;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  border-radius: 6px;
  margin: 0;
  white-space: pre-wrap;
}

.export-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.export-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-right: 0.25rem;
}

.historique-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.historique-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem 1.35rem 1.35rem;
  background: #fff;
}

.historique-item.is-latest {
  border-color: var(--accent);
}

.historique-item > h4 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.historique-item .bloc {
  margin-top: 1rem;
}

.historique-item .bloc:first-of-type {
  margin-top: 0.75rem;
}

.historique-item .contenu-text {
  margin: 0;
}

.historique-item .contract-item:last-child {
  margin-bottom: 0;
}

button.export-btn {
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
}
