*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:      #c0172c;
  --red-dark: #9a1122;
  --red-bg:   #fef2f4;
  --green:    #16a34a;
  --green-bg: #f0fdf4;
  --blue:     #1d4ed8;
  --blue-bg:  #eff6ff;
  --orange:   #d97706;
  --orange-bg:#fffbeb;
  --bg:       #f0f2f5;
  --card:     #ffffff;
  --text:     #1a1a2e;
  --muted:    #6b7280;
  --border:   #e5e7eb;
  --radius:   12px;
  --header-h: 56px;
  --nav-h:    60px;
}

/* ── Base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Header ── */
#appHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--header-h);
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: .75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

#btnMenuToggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .2rem;
  flex-shrink: 0;
  line-height: 1;
}

.header-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.4);
}

#headerTitle {
  flex: 1;
  min-width: 0;
}
#headerGP {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#headerDate {
  font-size: .75rem;
  opacity: .8;
}

#headerUser {
  font-size: .8rem;
  opacity: .85;
  white-space: nowrap;
}

#btnLogout {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: .35rem .6rem;
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
}
#btnLogout:hover { background: rgba(255,255,255,.25); }

/* ── Sidebar overlay ── */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
}
#sidebarOverlay.open { display: block; }

/* ── Sidebar ── */
#appSidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--card);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
  overflow-y: auto;
}
#appSidebar.open { transform: translateX(0); }

.nav-btn {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .85rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text);
  font-size: .95rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.active {
  color: var(--red);
  border-left-color: var(--red);
  background: var(--red-bg);
  font-weight: 700;
}
.nav-btn .icon { font-size: 1.3rem; flex-shrink: 0; }

.nav-separator {
  height: 1px;
  background: var(--border);
  margin: .4rem 0;
}

/* Pied du sidebar — déconnexion */
.nav-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.nav-user {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .6rem;
}

/* ── Pages ── */
.page {
  display: none;
  padding: 1rem;
  max-width: 600px;
  margin: calc(var(--header-h) + .5rem) auto 1rem;
}
.page.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: .75rem;
}

.card-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .6rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.2rem;
  border-radius: 8px;
  border: none;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--red);   color: #fff; }
.btn-green    { background: var(--green); color: #fff; }
.btn-outline  { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-block    { width: 100%; }
.btn-sm       { padding: .45rem .8rem; font-size: .85rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
}
.badge-pointage  { background: var(--blue-bg);   color: var(--blue); }
.badge-verif     { background: var(--green-bg);  color: var(--green); }
.badge-complete  { background: var(--green-bg);  color: var(--green); }
.badge-radio     { background: var(--orange-bg); color: var(--orange); }
.badge-absent    { background: #fef2f2; color: #991b1b; }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
}

/* ── Status banner ── */
.status-banner {
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .95rem;
  font-weight: 600;
}
.status-ok     { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.status-warn   { background: var(--orange-bg); color: var(--orange); border: 1px solid #fde68a; }
.status-error  { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.status-info   { background: var(--blue-bg); color: var(--blue); border: 1px solid #bfdbfe; }

/* ── Checklist ── */
.checklist { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.checklist li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .6rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: .9rem;
  cursor: pointer;
  user-select: none;
  transition: background .1s;
}
.checklist li:active { background: #e9e9ee; }
.checklist li.checked { color: var(--muted); text-decoration: line-through; }
.checklist li .check-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ── Membre list ── */
.membre-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.membre-row:last-child { border-bottom: none; }
.membre-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.membre-name { font-weight: 600; }
.membre-role { font-size: .78rem; color: var(--muted); }
.membre-status { margin-left: auto; }

/* ── Event list (rapport) ── */
.event-row {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.event-row:last-child { border-bottom: none; }
.event-time { color: var(--muted); font-size: .8rem; min-width: 36px; flex-shrink: 0; padding-top: 2px; }
.event-label { flex: 1; }

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.field label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.field input, .field select {
  padding: .7rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  color: var(--text);
  background: #fafafa;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--red); background: #fff; }

/* ── Loading spinner ── */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: .6rem 1.2rem;
  border-radius: 99px;
  font-size: .9rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Admin-only elements ── */
.admin-only { display: none; }
body.role-admin .admin-only,
body.role-cpi   .admin-only { display: unset; }

/* ── Planning ── */
.planning-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.planning-subtitle {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .1rem;
}
.planning-day-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.plan-tab {
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: .3rem .65rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}
.plan-tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.plan-info {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: .75rem;
}
.plan-info strong { color: var(--text); }

.plan-event {
  background: var(--card);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .9rem;
  margin-bottom: .5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border-left: 4px solid var(--border);
}
.plan-event.imp-high  { border-left-color: var(--red); }
.plan-event.imp-f1    { border-left-color: #2563eb; }
.plan-event.imp-f2    { border-left-color: #7c3aed; }
.plan-event.imp-f3    { border-left-color: #059669; }
.plan-event.imp-psc   { border-left-color: #d97706; }
.plan-event.imp-race  { border-left-color: #f59e0b; }
.plan-event.imp-org   { border-left-color: #9ca3af; }
.plan-event.imp-repas { border-left-color: #f97316; background: #fff7ed; }

.plan-event-time {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 80px;
  flex-shrink: 0;
  line-height: 1.3;
}
.plan-event-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.plan-event-name {
  flex: 1;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.3;
}
.plan-event-name.important { font-weight: 700; }
.plan-event-serie {
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 99px;
  flex-shrink: 0;
}
.serie-f1  { background: #dbeafe; color: #1d4ed8; }
.serie-f2  { background: #ede9fe; color: #6d28d9; }
.serie-f3  { background: #d1fae5; color: #065f46; }
.serie-psc { background: #fef3c7; color: #92400e; }
.serie-org { background: var(--bg); color: var(--muted); }

/* ── Sécurité ── */
.secu-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: .75rem;
}

.secu-card-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.secu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.secu-list li {
  display: flex;
  gap: .75rem;
  font-size: .9rem;
  line-height: 1.45;
  color: var(--text);
}

.secu-list li::before {
  content: '—';
  color: var(--red);
  font-weight: 700;
  flex-shrink: 0;
}

/* Signaux intervention */
.signal-block { display: flex; flex-direction: column; gap: .45rem; }

.signal-dots { display: flex; gap: .6rem; margin-bottom: .2rem; }

.dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.dot-green  { background: #16a34a; }
.dot-blue   { background: #2563eb; }
.dot-red    { background: #dc2626; }
.dot-black  { background: #1f2937; }
.dot-orange { background: #f97316; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.dot-blink { animation: blink 1s step-start infinite; }

.signal-label {
  font-size: .95rem;
  font-weight: 700;
}
.signal-label.ok     { color: #16a34a; }
.signal-label.danger { color: var(--red); }
.signal-label.warn   { color: #d97706; }

.signal-desc { font-size: .88rem; color: var(--muted); line-height: 1.4; }

/* ── Équipe ── */
.equipe-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: .75rem;
}
.equipe-card-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .5rem;
}
.equipe-org-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .5rem;
}
.equipe-contact-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  color: var(--text);
  text-decoration: none;
  padding: .2rem 0;
}
.equipe-contact-row:hover { color: var(--red); }

.equipe-membre-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: .5rem;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
}
.equipe-matricule {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 48px;
  padding-top: .15rem;
}
.equipe-membre-info { flex: 1; min-width: 0; }
.equipe-membre-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .35rem;
}

/* Badges rôle */
.role-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.role-cpi      { background: #fff3cd; color: #854d0e; }
.role-adjoint  { background: #fde8d8; color: #9a3412; }
.role-feu      { background: #fee2e2; color: #991b1b; }
.role-intdist  { background: #d1fae5; color: #065f46; }
.role-int      { background: #dcfce7; color: #166534; }
.role-stagiaire{ background: #e0f2fe; color: #0369a1; }

/* ── Utility ── */
.text-muted  { color: var(--muted); }
.text-sm     { font-size: .85rem; }
.text-center { text-align: center; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.gap-1 { gap: .5rem; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
