:root {
  --bg: #f4f6fb;
  --sidebar-start: #081227;
  --sidebar-end: #0f2346;
  --panel: #ffffff;
  --text: #1f2c3e;
  --muted: #7b8798;
  --line: #e5e9f2;
  --line-strong: #d6dce8;
  --accent: #f49b24;
  --accent-soft: #fff2db;
  --accent-dark: #c97a13;
  --nav-active: rgba(255,255,255,0.1);
  --green: #22a464;
  --green-soft: #e8f8ee;
  --blue: #3e6fe5;
  --blue-soft: #eef3ff;
  --red: #d84c4c;
  --red-soft: #fff1f1;
  --yellow: #f3c847;
  --yellow-soft: #fff8df;
  --shadow: 0 18px 36px rgba(15, 35, 70, 0.08);
  --radius-xl: 18px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-start), var(--sidebar-end));
  color: white; padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; margin-bottom: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(180deg, #ff9331, #d95d1e); font-weight: 800;
}
.brand-name { font-size: 20px; font-weight: 800; }
.brand-sub { color: rgba(255,255,255,0.68); font-size: 12px; }
.nav { display: grid; gap: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,0.82); font-size: 14px; border: 1px solid transparent;
}
.nav-item.active, .nav-item:hover { background: var(--nav-active); border-color: rgba(255,255,255,0.08); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.75); }

.main { padding: 18px 20px 28px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 4px 0 0; font-size: 34px; font-weight: 800; }
.form-title { cursor: default; pointer-events: none; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.live-badge, .reference-pill {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: white; border-radius: 999px; padding: 10px 14px; color: var(--muted); font-size: 13px;
}
.reference-pill strong, .live-badge strong { color: var(--text); }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 11px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .2s ease;
}
.btn-primary { background: linear-gradient(180deg, #ffa73b, var(--accent)); color: white; box-shadow: 0 12px 22px rgba(244, 155, 36, 0.28); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost, .btn-secondary { background: white; border-color: var(--line); color: var(--text); }
.inline-btn { margin-top: 12px; }

.flash-stack { display: grid; gap: 10px; margin-bottom: 14px; }
.flash { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.flash.success { background: #edf9f0; border-color: #cfe8d5; color: #157543; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card, .panel, .form-card, .soft-card {
  background: var(--panel); border: 1px solid #edf0f6; border-radius: var(--radius-xl); box-shadow: var(--shadow);
}
.stat-card { padding: 18px 18px 14px; }
.stat-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 18px; }
.stat-card strong { display: block; font-size: 42px; line-height: 1; margin-bottom: 8px; }
.stat-card small { color: var(--muted); font-size: 13px; }
.stat-card.alert { background: linear-gradient(180deg, #fff6f5, #fff); }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.bottom-grid { display: grid; grid-template-columns: 1.1fr 1.15fr 1fr; gap: 16px; }
.panel { padding: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-head h2, .section-title h2 { margin: 0; font-size: 18px; }
.panel-head span { color: var(--muted); font-size: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700;
}
.status-pill.pause { background: var(--blue-soft); color: var(--blue); }
.alert-list, .incident-list, .bars-list { display: grid; gap: 10px; }
.alert-item {
  display: grid; gap: 4px; padding: 14px; border-radius: 14px; border: 1px solid var(--line);
  background: #fff;
}
.alert-item.danger { background: var(--red-soft); border-color: #f1d6d6; }
.alert-item.warning { background: var(--yellow-soft); border-color: #efe0a2; }
.alert-item.notice { background: #fff7ec; border-color: #f2d9b2; }
.alert-item strong { font-size: 14px; }
.alert-item span, .alert-item small { color: var(--muted); }
.alert-item small { font-weight: 700; }

.donut-wrap { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 12px; }
.donut {
  width: 150px; height: 150px; margin: 8px auto; border-radius: 50%;
  background: conic-gradient(var(--yellow) 0 var(--jour), #3f379f var(--jour) 100%);
  position: relative;
}
.donut::after {
  content: ""; position: absolute; inset: 24px; background: white; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line);
}
.donut-legend { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.legend-dot.day { background: var(--yellow); }
.legend-dot.night { background: #3f379f; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 34px; align-items: center; gap: 10px; }
.bar-label { font-size: 13px; color: #455468; }
.bar-track { background: #f1f3f8; border-radius: 999px; height: 12px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: linear-gradient(90deg, #ffbb52, #f49b24); border-radius: inherit; }
.bar-value { text-align: right; color: var(--muted); font-size: 12px; }
.incident-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: white;
}
.incident-item.mineur { background: #f7f9fd; }
.incident-item.critique { background: var(--red-soft); }
.incident-item.majeur { background: #fff7eb; }
.incident-item p { margin: 4px 0; font-size: 14px; }
.incident-item small, .incident-item span { color: var(--muted); }

.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0 0 16px; }
.step {
  display: flex; align-items: center; gap: 10px; background: white; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: var(--muted); font-size: 13px; font-weight: 700;
}
.step::before {
  content: ""; width: 28px; height: 28px; border-radius: 50%; background: #edf1f8; color: #5a687f;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.step.done::before, .step.active::before { background: var(--accent); color: white; }
.step span { display: block; }

.agent-form { display: grid; gap: 16px; }
.form-section { padding: 18px; }
.section-title { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; }
.section-title > span {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark);
  display: grid; place-items: center; font-weight: 800; margin-top: 2px;
}
.section-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.identity-grid { display: grid; grid-template-columns: 170px 1fr; gap: 18px; }
.photo-uploader { display: grid; gap: 8px; }
.mini-label { color: #6f7b8d; font-size: 12px; font-weight: 700; }
.photo-dropzone {
  border: 1px dashed var(--line-strong); border-radius: 16px; min-height: 220px; background: #fafbfd;
  display: grid; place-items: center; text-align: center; padding: 16px; position: relative; overflow: hidden;
}
.photo-dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-icon { font-size: 22px; }
.photo-dropzone p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: #506074; font-weight: 700; }
.field label b { color: #ef8a15; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: white;
  padding: 11px 13px; color: var(--text);
}
.field input:focus, .field select:focus, textarea:focus {
  outline: none; border-color: #f2ae4f; box-shadow: 0 0 0 4px rgba(244, 155, 36, 0.13);
}
.subcard { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcff; margin-top: 16px; }
.subcard h3 { margin: 0 0 14px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.chips label, .doc-item, .checkline {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: white; padding: 10px 12px; color: #334255;
}
.license-chips label { background: #fff4da; border-color: #f6d28d; }
.qualifications-grid label, .compact-chips label { justify-content: flex-start; }
.language-block { margin-top: 16px; }
.top-inline-fields { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.experience-head, .experience-row {
  display: grid; grid-template-columns: 1fr 1.3fr 1fr 1fr 40px; gap: 10px; align-items: center;
}
.experience-head { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.experience-list { display: grid; gap: 10px; }
.experience-row input {
  min-height: 42px; border-radius: 10px; border: 1px solid var(--line); padding: 10px 12px;
}
.remove-row {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: white; cursor: pointer;
}
.link-add { border: 0; background: transparent; color: #da7f0c; font-weight: 700; padding: 0; cursor: pointer; justify-self: start; }
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.doc-item {
  justify-content: space-between; align-items: center; width: 100%; position: relative; padding: 14px; cursor: pointer;
}
.doc-item span { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.doc-item small { font-size: 11px; color: var(--muted); font-weight: 500; }
.doc-item button {
  border: 0; background: transparent; color: #d9820d; font-weight: 700; cursor: pointer;
}
.doc-item.verified { background: #eefaf2; border-color: #bfe4c8; }
.doc-item.verified button { color: #1c9c58; }
.doc-item input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.checkline {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; width: 100%; font-size: 13px; line-height: 1.5;
}
.declaration-grid { margin-top: 12px; }
.signature-block { margin-top: 14px; text-align: center; }
.signature-wrap {
  margin-top: 10px; border: 1px dashed var(--line-strong); border-radius: 14px; overflow: hidden; background: white;
}
#signaturePad {
  width: 100%; display: block; touch-action: none; background: linear-gradient(180deg, transparent 0, transparent 95%, #f2f4f8 96%, #f2f4f8 100%);
}
.signature-hint { color: #b69148; font-size: 13px; padding-top: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
.sticky-head { position: sticky; top: 0; z-index: 5; }

[data-modal-kind] { cursor: pointer; }
[data-modal-kind]:hover { filter: brightness(0.99); }

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 18, 39, 0.58);
  backdrop-filter: blur(4px);
  z-index: 60;
}
.modal-overlay.is-open { display: flex; }
.modal-card {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(88vh, 920px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  background: white;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 28px 70px rgba(10, 20, 40, 0.25);
}
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  z-index: 2;
}
.modal-body {
  overflow: auto;
  padding: 20px;
}
.modal-agent, .modal-simple { display: grid; gap: 16px; }
.modal-hero {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}
.modal-photo {
  width: 140px;
  height: 180px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f5f7fb;
}
.modal-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.modal-subline { margin: 8px 0 0; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.modal-grid, .modal-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.detail-block {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
}
.detail-block > strong { font-size: 14px; }
.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.detail-line:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-line span, .detail-line small { color: var(--muted); }
.detail-line strong { font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #f6dbab;
  font-size: 12px;
  font-weight: 700;
}
.empty-inline { color: var(--muted); font-size: 13px; }

.agent-detail-head { align-items: flex-start; }
.detail-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.agent-detail-actions { flex-wrap: wrap; }
.detail-hero {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 16px;
}
.detail-photo-card {
  width: 100%;
  min-height: 280px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f5f7fb;
}
.detail-photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-hero-copy { display: grid; gap: 16px; min-width: 0; }
.detail-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fbfcff;
  display: grid;
  gap: 6px;
}
.kpi-card span { color: var(--muted); font-size: 12px; }
.kpi-card strong { font-size: 15px; line-height: 1.3; }
.detail-summary-grid, .detail-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.detail-sections { display: grid; gap: 16px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-grid, .dashboard-grid, .bottom-grid, .chips-grid, .grid.two, .grid.three, .doc-grid, .stepper { grid-template-columns: 1fr; }
  .identity-grid { grid-template-columns: 1fr; }
  .experience-head { display: none; }
  .experience-row { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; }
  .modal-hero, .modal-grid, .modal-columns { grid-template-columns: 1fr; }
  .modal-photo { width: 100%; max-width: 220px; height: 220px; }
  .detail-hero, .detail-summary-grid, .detail-grid-2, .detail-kpis { grid-template-columns: 1fr; }
  .detail-photo-card { min-height: 220px; max-width: 320px; }
}

@media (max-width: 720px) {
  .main { padding: 14px; }
  .page-head, .head-actions, .form-actions { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 26px; }
  .modal-overlay { padding: 10px; }
  .modal-body { padding: 16px; }
  .modal-card { max-height: 92vh; }
  .detail-line { flex-direction: column; align-items: flex-start; }
  .modal-actions { flex-direction: column; }
  .detail-photo-card { max-width: 100%; }
  .detail-kpis { gap: 10px; }
}
