:root {
  --brand: #0B5E68;
  --brand-dark: #08454D;
  --brand-soft: #E6F2F3;
  --ink: #1B2430;
  --muted: #4A5663;
  --line: #E1E6EB;
  --line-strong: #C9D1D9;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --danger: #B42318;
  --partner: #0B5E68;
  --radius: 12px;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Boutons / champs ---------- */
.btn {
  font: inherit; font-size: 15px; font-weight: 600;
  min-height: 44px; padding: 0 18px;
  border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-light { background: #fff; color: var(--brand); }
.btn-light:hover { background: var(--brand-soft); color: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: #F8FAFB; color: var(--ink); }
.btn-block { width: 100%; min-height: 48px; font-size: 16px; }
.btn:focus-visible, .field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible, .row-btn:focus-visible {
  outline: 3px solid #7FB8BF; outline-offset: 2px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; }
.field .req { color: var(--danger); margin-left: 2px; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 15px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
.field textarea { padding: 10px 12px; resize: vertical; min-height: 88px; }
.field .help { font-size: 12px; color: var(--muted); }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.field.invalid .check { color: var(--danger); }

.msg { font-size: 14px; border-radius: 8px; padding: 10px 12px; }
.msg-error { background: #FDECEA; color: var(--danger); }
.msg-ok { background: #E3F3E8; color: #1E6B3A; }

/* ---------- Connexion / activation ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.auth-head { background: var(--brand); color: #fff; padding: 28px 24px 24px; display: flex; flex-direction: column; gap: 6px; }
.auth-head .eyebrow { color: #CDE7EA; }
.auth-head h1 { margin: 0; font-size: 22px; }
.auth-head p { margin: 0; color: #E6F2F3; font-size: 14px; }
.auth-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- En-tête portail ---------- */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 16px 24px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.topbar .eyebrow { color: #CDE7EA; }
.topbar .partner-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.partner-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--partner); border: 2px solid #fff; flex: none; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.user-chip { font-size: 13px; color: #E6F2F3; }
.btn-logout { background: transparent; border-color: #5E9FA7; color: #fff; font-weight: 500; }
.btn-logout:hover { background: var(--brand-dark); }

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 24px; }

/* ---------- Indicateurs ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 30px; font-weight: 700; }
.stat-value.en_cours { color: #8A4B00; }
.stat-value.installee { color: #1E6B3A; }
.stat-value.abandon { color: #5B6570; }

/* ---------- Liste + détail ---------- */
.layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list-panel { flex: 999 1 560px; min-width: 0; overflow: hidden; }
.detail-panel { flex: 1 1 360px; min-width: 0; padding: 20px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; }
.panel-head { padding: 14px 20px; border-bottom: 1px solid #EDF0F3; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 14px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.search { font: inherit; font-size: 14px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; flex: 1 1 200px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #F8FAFB; }
th { padding: 12px 20px; font-weight: 600; }
td { padding: 0; border-top: 1px solid #EDF0F3; }
tr.selected td { background: #F0F7F8; }
tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.row-btn { all: unset; display: block; padding: 14px 20px; cursor: pointer; width: 100%; box-sizing: border-box; }
.row-btn:hover { background: #F8FAFB; }
.cell-muted { color: var(--muted); }
.cell-strong { font-weight: 600; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.envoyee { background: #ECEEF0; color: #4A5663; }
.badge.recue { background: #E7EEFA; color: #1F4E9C; }
.badge.en_cours { background: #FDF1DC; color: #8A4B00; }
.badge.installee { background: #E3F3E8; color: #1E6B3A; }
.badge.abandon { background: #ECEEF0; color: #4A5663; }

.detail-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 24px 0; }
.detail-head { display: flex; flex-direction: column; gap: 4px; }
.detail-head h2 { margin: 0; font-size: 20px; }
.detail-meta { font-size: 13px; color: var(--muted); }
.detail-close { align-self: flex-start; }

.steps { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.step { display: inline-flex; align-items: center; gap: 6px; color: #5B6570; }
.step-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #A9B3BC; }
.step.done { color: #1E6B3A; } .step.done .step-dot { background: #1E6B3A; border-color: #1E6B3A; }
.step.current { color: #8A4B00; } .step.current .step-dot { background: #C77700; border-color: #C77700; }
.step.stopped { color: #4A5663; } .step.stopped .step-dot { background: #5B6570; border-color: #5B6570; }
.step-line { flex: 1; height: 2px; background: #D5DCE2; min-width: 12px; }
.step-line.done { background: #1E6B3A; }

.section-title { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.answers { margin: 0; display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 6px 12px; font-size: 14px; }
.answers dt { color: var(--muted); }
.answers dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

.timeline { border-left: 2px solid var(--line); padding-left: 14px; display: flex; flex-direction: column; gap: 14px; }
.event { display: flex; flex-direction: column; gap: 2px; }
.event-meta { font-size: 12px; color: var(--muted); }
.event-text { font-size: 14px; white-space: pre-wrap; }
.event.message .event-text { background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; }
.note { font-size: 12px; color: var(--muted); background: #F8FAFB; border-radius: 8px; padding: 10px 12px; }

/* ---------- Formulaire (fenêtre) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; z-index: 20; }
.sheet { width: 100%; max-width: 520px; background: var(--bg); border-radius: 16px; overflow: hidden; }
.sheet-head { background: var(--brand); color: #fff; padding: 22px 20px 20px; display: flex; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 21px; }
.sheet-head p { margin: 4px 0 0; color: #E6F2F3; font-size: 14px; }
.sheet-close { all: unset; cursor: pointer; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: #fff; flex: none; }
.sheet-close:hover { background: var(--brand-dark); }
.sheet form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .topbar-inner, main { padding-left: 16px; padding-right: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 24px; }
  .col-hide-sm { display: none; }
  .detail-panel { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .overlay { padding: 0; }
  .sheet { border-radius: 0; min-height: 100vh; }
  .user-chip { display: none; }
}
