.gestperm-page {
  --gp-accent: #c41e3a;
  --gp-border: #ddd;
  --gp-bg: #f7f7f9;
}

.gestperm-wrap {
  max-width: 1280px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}

.gestperm-public-header {
  background: linear-gradient(135deg, #c41e3a 0%, #001aff 100%);
  color: #fff;
  padding: 1.5rem 0;
  margin-bottom: 1.5rem;
}

.gestperm-public-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.gestperm-public-header p {
  margin: 0;
  opacity: 0.9;
}

.gestperm-card {
  background: #fff;
  border: 1px solid var(--gp-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.gestperm-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.gestperm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.gestperm-toolbar .gp-label-short {
  display: none;
}

.gestperm-hint {
  color: #666;
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.gestperm-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.gestperm-form-row input[type="email"],
.gestperm-form-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gp-border);
  border-radius: 6px;
}

.gestperm-stack label {
  display: block;
  margin-bottom: 0.75rem;
}

.gestperm-stack input,
.gestperm-stack select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gp-border);
  border-radius: 6px;
}

.gestperm-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gestperm-item {
  border: 1px solid var(--gp-border);
  border-radius: 6px;
  padding: 0.75rem;
  background: var(--gp-bg);
}

.gestperm-item-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.gestperm-time {
  margin-left: 0.5rem;
  color: #555;
}

.gestperm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.gestperm-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e5e5e5;
}

.gestperm-badge--active,
.gestperm-badge--reactive { background: #d4edda; color: #155724; }
.gestperm-badge--planifie { background: #fff3cd; color: #856404; }
.gestperm-badge--cloture,
.gestperm-badge--termine { background: #d6d8db; color: #383d41; }
.gestperm-badge--annule { background: #f8d7da; color: #721c24; }

.gestperm-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.gestperm-table th,
.gestperm-table td {
  border-bottom: 1px solid var(--gp-border);
  padding: 0.4rem 0.35rem;
  text-align: left;
  vertical-align: middle;
}

.gestperm-table--sortable th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.gestperm-table--sortable th[data-sort]::after {
  content: ' ↕';
  opacity: 0.35;
  font-size: 0.75em;
}

.gestperm-table--sortable th.is-sorted-asc::after {
  content: ' ↑';
  opacity: 0.9;
}

.gestperm-table--sortable th.is-sorted-desc::after {
  content: ' ↓';
  opacity: 0.9;
}

.gestperm-scan-qr {
  font-size: 1.15rem;
  line-height: 1;
  vertical-align: middle;
}

.gestperm-scan-qr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}

.gestperm-scan-qr-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.gestperm-scan-qr-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.gestperm-qr-dialog {
  text-align: center;
  max-width: 320px;
}

.gestperm-qr-preview {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0 1rem;
}

.gestperm-qr-preview img {
  width: 240px;
  height: 240px;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--gp-border, #dde1e6);
  border-radius: 8px;
  padding: 0.5rem;
}

.gestperm-scan-qr--yellow {
  color: #e6b800;
}

.gestperm-scan-qr--green {
  color: #28a745;
}

.gestperm-valider-cell {
  text-align: center;
  white-space: nowrap;
}

.gestperm-valider-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid #198754;
  border-radius: 6px;
  background: #e8f7ee;
  color: #198754;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.gestperm-valider-btn:hover:not(:disabled) {
  background: #198754;
  color: #fff;
}

.gestperm-valider-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.gestperm-valider-done {
  color: #198754;
  font-size: 1.15rem;
}

.gestperm-valider-na {
  color: #999;
}

.gestperm-empty { color: #777; margin: 0.5rem 0; }

.gestperm-msg {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  background: #eef;
}

.gestperm-msg.is-error { background: #f8d7da; color: #721c24; }
.gestperm-msg.is-ok { background: #d4edda; color: #155724; }

.gestperm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.gestperm-modal[hidden] { display: none !important; }

.gestperm-modal-dialog {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  width: min(420px, 100%);
  max-height: 90vh;
  overflow: auto;
}

.gestperm-modal-dialog label {
  display: block;
  margin-bottom: 0.75rem;
}

.gestperm-modal-dialog input,
.gestperm-modal-dialog select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gp-border);
  border-radius: 6px;
}

.gestperm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.gestperm-userbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.gestperm-planning-card {
  border: 1px solid var(--gp-border);
  border-radius: 6px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  background: var(--gp-bg);
  cursor: pointer;
}

.gestperm-planning-card:hover { border-color: var(--gp-accent); }

.gestperm-planning-card.is-inscrit {
  cursor: default;
  border-color: #28a745;
}

.gestperm-reader {
  max-width: 420px;
  margin: 0 auto 1rem;
  min-height: 280px;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
}

.gestperm-reader video {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 0 auto;
  object-fit: cover;
}

.gestperm-reader img {
  max-width: 100%;
}

.gestperm-center { text-align: center; }
.gestperm-icon-ok { font-size: 3rem; color: #28a745; }
.gestperm-icon-ko { font-size: 3rem; color: #dc3545; }

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn-warning { background: #f0ad4e; color: #111; border: none; }
.btn-danger { background: #dc3545; color: #fff; border: none; }

/* Layout PC : calendrier + stats | fiche perm */
.gestperm-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.gestperm-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 4.5rem;
}

.gestperm-detail-title {
  margin: 0 0 0.75rem;
}

.gestperm-stats-sub {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  color: #444;
}

.gestperm-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0;
}

.gestperm-stat {
  background: var(--gp-bg);
  border: 1px solid var(--gp-border);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
}

.gestperm-stat dt {
  margin: 0;
  font-size: 0.75rem;
  color: #666;
  font-weight: 600;
}

.gestperm-stat dd {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #222;
  line-height: 1.2;
}

.gestperm-list.is-select-mode .gestperm-item {
  display: none;
}

.gestperm-list.is-select-mode .gestperm-item.is-day-selected {
  display: block;
}

@media (min-width: 769px) {
  .gestperm-list.is-select-mode .gestperm-item.is-day-selected .gestperm-insc > summary {
    pointer-events: none;
  }

  .gestperm-list.is-select-mode .gestperm-item.is-day-selected .gestperm-inscrits-cue {
    display: none;
  }
}

/* Calendrier */
.gestperm-calendar {
  display: block;
}

.gestperm-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.gestperm-cal-nav strong {
  font-size: 1rem;
  text-transform: capitalize;
}

.gestperm-cal-weekdays,
.gestperm-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.gestperm-cal-weekdays {
  margin-bottom: 0.35rem;
}

.gestperm-cal-weekdays span {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
}

.gestperm-cal-day {
  appearance: none;
  border: 1px solid transparent;
  background: var(--gp-bg);
  border-radius: 8px;
  min-height: 2.6rem;
  padding: 0.25rem 0.15rem 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.15rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.gestperm-cal-day.is-other {
  opacity: 0.35;
}

.gestperm-cal-day.is-today {
  border-color: #001aff;
}

.gestperm-cal-day.is-selected {
  border-color: var(--gp-accent);
  background: #fff5f6;
  box-shadow: inset 0 0 0 1px var(--gp-accent);
}

.gestperm-cal-day.has-perm {
  font-weight: 600;
}

.gestperm-cal-day-num {
  font-size: 0.9rem;
  line-height: 1.2;
}

.gestperm-cal-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #999;
}

.gestperm-cal-dot--planifie { background: #6c757d; }
.gestperm-cal-dot--active,
.gestperm-cal-dot--reactive { background: #28a745; }
.gestperm-cal-dot--cloture { background: #f0ad4e; }
.gestperm-cal-dot--termine { background: #17a2b8; }
.gestperm-cal-dot--annule { background: #dc3545; }

.gestperm-cal-empty {
  margin: 0.75rem 0 0;
  color: #666;
  font-size: 0.95rem;
}

.gestperm-inscrits-cue {
  display: none;
}

.gestperm-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
}

.gestperm-pager[hidden] {
  display: none !important;
}

.gestperm-pager-info {
  font-size: 0.85rem;
  color: #555;
  min-width: 7rem;
  text-align: center;
}

@media (max-width: 768px) {
  .gestperm-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .gestperm-aside {
    position: static;
  }

  .gestperm-stats {
    order: 3;
  }

  .gestperm-detail {
    order: 2;
  }

  .gestperm-toolbar {
    flex-wrap: nowrap;
    align-items: stretch;
  }

  .gestperm-toolbar .btn {
    flex: 1 1 0;
    justify-content: center;
    white-space: nowrap;
    font-size: 0.9rem;
    padding: 0.55rem 0.65rem;
  }

  .gestperm-toolbar .gp-label-full {
    display: none;
  }

  .gestperm-toolbar .gp-label-short {
    display: inline;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-day-selected {
    cursor: pointer;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-day-selected:not(.is-insc-open) .gestperm-actions {
    display: none;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-day-selected:not(.is-insc-open) .gestperm-insc {
    display: none;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-insc-open {
    cursor: default;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-insc-open .gestperm-insc > summary {
    display: none;
  }

  .gestperm-list.is-mobile-cal .gestperm-inscrits-cue {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.45rem;
    color: var(--gp-accent);
    font-size: 0.85rem;
    font-weight: 600;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-insc-open .gestperm-inscrits-cue {
    display: none;
  }

  .gestperm-list.is-mobile-cal .gestperm-item.is-insc-open .gestperm-actions {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--gp-border);
  }

  .gestperm-item-head {
    flex-direction: column;
    align-items: stretch;
  }

  .gestperm-actions {
    flex-wrap: wrap;
  }

  .gestperm-table {
    font-size: 0.8rem;
  }

  .gestperm-table th,
  .gestperm-table td {
    padding: 0.35rem 0.25rem;
  }

  /* Smartphone : colonne Statut masquée (Scan suffit) */
  .gestperm-table .gp-statut-col,
  .gestperm-table .gp-statut-cell {
    display: none;
  }
}
