:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface2: #1e2230;
  --border: #2a3042;
  --text: #e8eaef;
  --muted: #8b92a8;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --ed: #818cf8;
  --font: 'DM Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; flex-shrink: 0;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; padding: 0 6px; }
.logo {
  width: 42px; height: 42px; background: linear-gradient(135deg, var(--ed), #4f46e5);
  border-radius: 10px; color: #fff; font-size: 0.72rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.brand strong { display: block; font-size: 0.88rem; }
.brand span { font-size: 0.68rem; color: var(--muted); }

.nav {
  display: block; width: 100%; text-align: left; padding: 10px 14px; margin-bottom: 4px;
  border: none; background: none; border-radius: 8px; color: var(--muted);
  font-family: inherit; font-size: 0.88rem; cursor: pointer;
}
.nav:hover { background: var(--surface2); color: var(--text); }
.nav.on { background: var(--accent-soft); color: var(--ed); font-weight: 600; }

.back-portail {
  margin-top: auto; padding: 12px 14px; font-size: 0.8rem; color: var(--muted);
  text-decoration: none; border-top: 1px solid var(--border); padding-top: 20px;
}
.back-portail:hover { color: var(--ed); }

.login-screen { display: flex; min-height: 100vh; align-items: center; justify-content: center; width: 100%; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: min(400px, 92vw); }
.login-box h1 { font-size: 1.2rem; }
.login-box label { display: block; font-size: 0.72rem; color: var(--muted); margin: 12px 0 4px; }
.login-box input { width: 100%; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; }
.login-box .btn { width: 100%; margin-top: 16px; }
.err { color: #f87171; font-size: 0.85rem; margin-top: 8px; }

.main { flex: 1; overflow: auto; }
.top {
  padding: 24px 28px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px;
}
.top h1 { font-size: 1.3rem; }
.top p { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.access-badge {
  font-size: 0.72rem; padding: 6px 12px; border-radius: 99px;
  background: var(--accent-soft); color: var(--ed); font-weight: 600;
}

.panel { display: none; padding: 24px 28px 40px; }
.panel.on { display: block; }
.intro { margin-bottom: 16px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.btn {
  padding: 8px 16px; background: var(--ed); color: #fff; border: none;
  border-radius: 8px; font-family: inherit; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.btn-ghost { padding: 8px 16px; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-family: inherit; cursor: pointer; }
.search { padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; }

.split { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } body { flex-direction: column; } .sidebar { width: 100%; } }

.list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.row {
  padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; gap: 10px; align-items: center;
}
.row:hover, .row.on { background: var(--accent-soft); }
.av { width: 32px; height: 32px; border-radius: 8px; background: #4f46e5; font-size: 0.65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.row strong { display: block; font-size: 0.85rem; }
.row span { font-size: 0.72rem; color: var(--muted); }

.detail { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.detail h2 { font-size: 1.1rem; }
.sub { font-size: 0.88rem; margin: 20px 0 8px; color: var(--text); }
.muted { color: var(--muted); font-size: 0.85rem; }
.muted.small { font-size: 0.78rem; margin-bottom: 12px; }

/* Ma fiche */
.profil-card { max-width: 1100px; }
.profil-hero {
  display: flex; gap: 16px; align-items: center; margin-bottom: 22px;
  padding: 18px; border-radius: 12px; border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(30,34,48,0.8));
}
.profil-avatar {
  width: 56px; height: 56px; border-radius: 14px; background: var(--accent-soft);
  color: var(--ed); font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.profil-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px;
}
.profil-block {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.profil-block h3 { margin: 0 0 4px; font-size: 1rem; color: var(--ed); }
.profil-block label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); }
.profil-block input, .profil-block select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
.profil-block .chk { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.profil-block .msg { font-size: 0.85rem; min-height: 1.2em; margin: 0; }
.muted.small { font-size: 0.78rem; margin-bottom: 12px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; margin: 8px 0; cursor: pointer; }
.actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }

.perm, .data { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.perm th, .perm td, .data th, .data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: center; }
.perm th:first-child, .perm td:first-child, .data th:first-child, .data td:first-child { text-align: left; }
.perm th, .data th { font-size: 0.68rem; text-transform: uppercase; color: var(--muted); background: var(--surface2); }
.data { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.data.compact td { padding: 8px 12px; }

/* Matrices postes / autorisations — toutes les apps visibles (scroll horizontal) */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
.table-scroll .data { border: none; border-radius: 0; min-width: max-content; }
.perm-wrap { overflow-x: auto; margin-bottom: 8px; }
.perm-wrap .perm { min-width: 720px; }
.positions-matrix th, .positions-matrix td { white-space: nowrap; font-size: 0.75rem; padding: 8px 10px; }
.positions-matrix th.app-col { writing-mode: horizontal-tb; max-width: 90px; white-space: normal; line-height: 1.15; vertical-align: bottom; }
.positions-matrix .lvl { font-weight: 600; }
.positions-matrix .lvl-0 { color: var(--muted); }
.positions-matrix .lvl-1 { color: #60a5fa; }
.positions-matrix .lvl-2 { color: #4ade80; }
.positions-matrix .lvl-3 { color: #fbbf24; }
.position-editor {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
}
.position-editor h3 { margin: 0 0 12px; font-size: 1rem; }
.position-editor .pe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.position-editor label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.78rem; color: var(--muted);
}
.position-editor select, .position-editor input[type="text"] {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
.position-editor .pe-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.staff-table img.staff-thumb { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--surface2); }
.tiny { font-size: 0.78rem; }
.nowrap { white-space: nowrap; }
.ok-text { color: #4ade80; }
.warn-text { color: #fbbf24; }
.err-inline { color: #f87171; padding: 12px 0; }
.btn-xs { padding: 5px 10px; font-size: 0.75rem; }
.btn-danger { border-color: #ef4444 !important; color: #f87171 !important; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin: 0; }
.modal-box--staff { max-width: 720px; padding: 0; overflow: hidden; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-foot {
  padding: 14px 20px 18px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.modal-foot .actions { margin-top: 0; justify-content: flex-end; }
.modal-box input, .modal-box select, .modal-box textarea {
  width: 100%; padding: 9px 11px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: inherit; margin-top: 4px;
}
.lbl { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0; }
.field { margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.staff-form {
  display: grid; grid-template-columns: 180px 1fr; gap: 0;
  max-height: min(70vh, 640px); overflow-y: auto;
}
@media (max-width: 640px) {
  .staff-form { grid-template-columns: 1fr; }
}
.staff-form-photo {
  padding: 20px 16px; background: var(--surface2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.staff-photo-frame {
  width: 120px; height: 120px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--border); background: var(--bg);
}
.staff-photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.staff-photo-btn { cursor: pointer; }
.photo-hint { line-height: 1.35; }
.staff-form-fields { padding: 16px 20px 8px; }
.form-section {
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; }
.form-section-title {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ed); margin: 0 0 12px; font-weight: 700;
}
.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-check {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; font-size: 0.85rem;
}
.opt-check:hover { border-color: var(--ed); }
.opt-check input { margin-top: 3px; width: auto; flex-shrink: 0; accent-color: var(--ed); }
.opt-check span { display: flex; flex-direction: column; gap: 2px; }
.opt-check strong { font-weight: 600; color: var(--text); }
.opt-check small { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
.zones-grid .opt-check { min-width: 140px; }
.email-preview {
  margin-top: 6px; padding: 10px 12px; background: var(--bg); border-radius: 8px;
  font-family: ui-monospace, monospace; font-size: 0.88rem; color: var(--muted);
  border: 1px solid var(--border);
}
.email-preview.ok { color: #4ade80; border-color: rgba(74, 222, 128, 0.35); }
.row-flex { display: flex; gap: 8px; align-items: center; }
.modal-msg { margin-top: 0; font-size: 0.88rem; min-height: 1.2em; }
.modal-msg.tiny { font-size: 0.78rem; }