:root {
  --bg: #0f1216;
  --panel: #171b21;
  --border: #262b33;
  --text: #e7ebf0;
  --muted: #9aa4b2;
  --accent: #3fa9f5;
  --ok: #35c46f;
  --warn: #f5a623;
  --danger: #f5484a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding: 0 1.5rem 3rem;
}

header {
  padding: 2rem 0 1rem;
}

h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.subtitle { margin: 0; color: var(--muted); }

@media (max-width: 560px) {
  body { padding: 0 1rem 2rem; }
  h1 { font-size: 1.3rem; }
  .panel { padding: 1rem; }
  .person-view-header { flex-direction: column; align-items: flex-start; }
  .personnes-actions { width: 100%; }
  .personnes-actions button { flex: 1; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form label { width: 100%; }
  .inline-form input, .inline-form select { width: 100%; }
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

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

.panel h2 { margin-top: 0; font-size: 1.1rem; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 0.25rem;
}

input, select, button {
  background: #0d1014;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.95rem;
}

button {
  background: var(--accent);
  color: #06121c;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

button:hover { filter: brightness(1.1); }
button.danger { background: var(--danger); color: white; }

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-ok { background: rgba(53, 196, 111, 0.15); color: var(--ok); }
.badge-warn { background: rgba(245, 166, 35, 0.15); color: var(--warn); }
.badge-danger { background: rgba(245, 72, 74, 0.15); color: var(--danger); }

/* Statistiques clés (grille de cartes égales) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: #0d1014;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  text-align: center;
}

.stat-card strong { font-size: 1.5rem; line-height: 1.1; }
.stat-card span { font-size: 0.78rem; color: var(--muted); }

.stat-card-highlight {
  border-color: rgba(63, 169, 245, 0.5);
  background: rgba(63, 169, 245, 0.08);
}
.stat-card-highlight strong { color: var(--accent); }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.summary-chip {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1014;
}

.summary-chip strong { font-size: 1.5rem; line-height: 1.1; }
.summary-chip span { font-size: 0.78rem; color: var(--muted); }

.status-bg-ok { border-color: rgba(53, 196, 111, 0.35); }
.status-bg-ok strong { color: var(--ok); }
.status-bg-warn { border-color: rgba(245, 166, 35, 0.35); }
.status-bg-warn strong { color: var(--warn); }
.status-bg-danger { border-color: rgba(245, 72, 74, 0.35); }
.status-bg-danger strong { color: var(--danger); }

.hidden { display: none !important; }

.personnes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.personnes-toolbar h2 { margin: 0; }

.personnes-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

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

.person-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.person-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #0d1014;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.person-tab.active {
  border-color: var(--accent);
  background: rgba(63, 169, 245, 0.12);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-danger { background: var(--danger); }

.person-view-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.person-view-header h2 { margin: 0; }

/* Cartes des deux fenêtres glissantes, toujours sur la même ligne de base */
#vue-personne-periodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.periode-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #0d1014;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 1rem;
}

.status-border-ok { border-left-color: var(--ok); }
.status-border-warn { border-left-color: var(--warn); }
.status-border-danger { border-left-color: var(--danger); }

.periode-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.periode-titre {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.periode-titre strong { font-size: 0.92rem; }
.periode-plage { font-size: 0.75rem; color: var(--muted); }

.periode-valeur {
  font-size: 1.4rem;
  font-weight: 700;
  white-space: nowrap;
}

.periode-valeur span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.15rem;
}

.periode-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
}

.periode-footer span { color: var(--muted); }
.periode-footer strong { font-size: 0.95rem; }

.alert-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-warn {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.4);
  color: var(--warn);
}

.alert-warn strong { font-size: 1.05rem; }

#panel-vue-personne h3 {
  margin-top: 1.5rem;
  font-size: 1rem;
}


/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
}

.modal-large { max-width: 560px; }

.modal h2 { margin-top: 0; }

.modal-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: -0.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.gestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
}

.gestion-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  background: #0d1014;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.gestion-nom { flex: 1 0 100%; font-weight: 600; }

.gestion-confirm-input { flex: 1; min-width: 160px; }

.gestion-confirm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.status-ok { color: var(--ok); }
.status-warn { color: var(--warn); }
.status-danger { color: var(--danger); }

.bar {
  height: 8px;
  border-radius: 4px;
  background: #262b33;
  overflow: hidden;
  margin: 0.5rem 0 0.75rem;
}

.bar-fill { height: 100%; background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; }

.table-wrap { overflow-x: auto; }

footer {
  max-width: 960px;
  margin: 2rem auto 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.empty { color: var(--muted); font-style: italic; }
