:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #dfe2e8;
  --text: #1c2230;
  --text-muted: #6b7280;
  --primary: #2d3a8c;
  --primary-hover: #232d6e;
  --danger: #b3261e;
  --success: #1c7c3d;
  --warning: #8a5a00;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  background: var(--primary);
  color: white;
  padding: 14px 20px;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar-sub { font-weight: 400; opacity: 0.8; font-size: 14px; }

.layout { display: flex; min-height: calc(100vh - 52px); }

.sidebar {
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.investigation-list { list-style: none; margin: 16px 0 0; padding: 0; }
.investigation-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
}
.investigation-item:hover { background: #f0f1f5; }
.investigation-item.active { background: #e8eaf9; border-color: var(--primary); }
.investigation-item .inv-name { font-weight: 600; font-size: 14px; }
.investigation-item .inv-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: #e5e7eb; color: var(--text-muted); margin-left: 6px; vertical-align: middle;
}
.badge.published { background: #dcf5e3; color: var(--success); }

.main { flex: 1; padding: 24px 32px; overflow-y: auto; }
.empty-state { color: var(--text-muted); text-align: center; margin-top: 80px; }

.panel-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; }
.panel-header h2 { margin: 0 0 4px; }
.panel-header .status-line { color: var(--text-muted); font-size: 13px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  background: none; border: none; padding: 10px 16px; cursor: pointer; font-size: 14px;
  color: var(--text-muted); border-bottom: 2px solid transparent; font-weight: 500;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; }
.form-grid.full { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
.field-hint { font-size: 11.5px; color: var(--text-muted); }

.btn {
  border: 1px solid var(--border); background: white; padding: 8px 14px; border-radius: 6px;
  cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text);
}
.btn:hover { background: #f4f5f7; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #f2c9c6; }
.btn-danger:hover { background: #fdf0ef; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.data-table td.actions-cell { white-space: nowrap; text-align: right; }
table.data-table tr.is-solution { background: #fff8e1; }

.weapon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.weapon-check {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13.5px; cursor: pointer;
}
.weapon-check.is-solution { border-color: #e0b400; background: #fffaf0; }
.weapon-check input { margin: 0; }
.weapon-meta { font-size: 11.5px; color: var(--text-muted); }

.validation-box { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.validation-box.ok { background: #e9f8ee; border: 1px solid #b7e4c7; }
.validation-box.ko { background: #fdeeed; border: 1px solid #f2c9c6; }
.validation-box h4 { margin: 0 0 8px; font-size: 14px; }
.validation-box ul { margin: 4px 0 0; padding-left: 20px; font-size: 13.5px; }
.validation-box .warn-list { color: var(--warning); }
.validation-box .err-list { color: var(--danger); }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: #1c2230; color: white;
  padding: 10px 16px; border-radius: 6px; font-size: 13.5px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.toast.error { background: var(--danger); }

.grid-table th, .grid-table td { white-space: nowrap; }
.grid-table select { font-size: 13px; padding: 4px 6px; }
.clue-picker { display: flex; flex-direction: column; gap: 6px; padding: 8px 4px; }
.clue-pick-item { display: block; font-size: 13px; white-space: normal; }
.clue-pick-item input { margin-right: 6px; }

/* ── Carte interactive (Grille / cases) ──────────────────────────────── */
#grille-map { height: 440px; border-radius: 6px; border: 1px solid var(--border); z-index: 0; }
.pin-shape {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
}
.pin-label { transform: rotate(45deg); color: white; font-size: 11px; font-weight: 700; line-height: 1; }
.dot-shape { width: 18px; height: 18px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 2px rgba(0,0,0,.5); }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.legend-flag { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: inline-block; border: 1px solid rgba(0,0,0,.15); margin-left: 2px; }
.legend-flag-start { background: #1c7c3d; }
.legend-flag-end { background: #b3261e; }
.map-click-hint {
  background: white; padding: 4px 10px; border-radius: 6px; font-size: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); color: var(--text);
}
