:root {
  --navy: #071321;
  --blue: #2f80ed;
  --green: #27ae60;
  --gold: #f4c95d;
  --ink: #13243b;
  --muted: #667385;
  --line: #d9e6f2;
  --surface: #f7fbff;
  --white: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 10%, rgba(244, 201, 93, 0.22), transparent 24%),
    radial-gradient(circle at 12% 86%, rgba(39, 174, 96, 0.28), transparent 28%),
    linear-gradient(135deg, var(--navy), #12345a 58%, var(--green));
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: var(--white);
  cursor: pointer;
  font-weight: 900;
  padding: 14px 18px;
}

button.secondary {
  background: #eaf2fb;
  color: var(--blue);
}

button.danger {
  background: #c9584d;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--white);
  color: var(--ink);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.gate {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 28px;
}

.gate-card,
.panel,
.topbar {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(7, 19, 33, 0.28);
}

.gate-card {
  max-width: 1120px;
  padding: 34px;
  width: 100%;
}

body.gate-kiosk-mode {
  background: #020812;
}

body.gate-kiosk-mode .gate {
  align-items: stretch;
  padding: 0;
}

body.gate-kiosk-mode .gate-card {
  align-content: center;
  background:
    radial-gradient(circle at 72% 12%, rgba(244, 201, 93, 0.18), transparent 24%),
    linear-gradient(135deg, #071321 0%, #020812 100%);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--white);
  display: grid;
  min-height: 100vh;
  max-width: none;
  padding: 28px;
}

body.gate-kiosk-mode .brand-logo,
body.gate-kiosk-mode .gate-card > .eyebrow,
body.gate-kiosk-mode .gate-card > h1,
body.gate-kiosk-mode .stage-title,
body.gate-kiosk-mode .lead,
body.gate-kiosk-mode .role-grid {
  display: none;
}

body.gate-kiosk-mode .access-panel {
  border-top: 0;
  margin: 0 auto;
  max-width: 1180px;
  width: 100%;
}

body.gate-kiosk-mode .access-panel .panel-header {
  align-items: center;
}

body.gate-kiosk-mode .access-panel h2 {
  color: var(--white);
  font-size: clamp(2rem, 5vw, 4.4rem);
}

body.gate-kiosk-mode .access-panel label,
body.gate-kiosk-mode .access-panel .eyebrow {
  color: #b9c8dc;
}

body.gate-kiosk-mode .access-panel input {
  background: #101f34;
  border-color: rgba(244, 201, 93, 0.35);
  color: var(--white);
}

body.gate-kiosk-mode .access-panel .message {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(244, 201, 93, 0.32);
  border-radius: 8px;
  color: var(--white);
  font-size: 1.05rem;
  padding: 14px 16px;
}

body.gate-kiosk-mode .access-panel .message.success {
  background: rgba(18, 104, 58, 0.92);
  border-color: var(--green);
  color: var(--white);
}

body.gate-kiosk-mode .access-panel .message.error {
  background: rgba(180, 35, 24, 0.94);
  border-color: #d92d20;
  color: var(--white);
}

body.gate-kiosk-mode .camera-box {
  background: #050c16;
  border: 2px solid rgba(244, 201, 93, 0.45);
  justify-self: center;
  max-width: min(42vw, 280px);
  min-height: 0;
  width: 100%;
}

body.gate-kiosk-mode .access-grid {
  align-items: center;
  grid-template-columns: minmax(220px, 300px) minmax(280px, 1fr);
}

body.gate-kiosk-mode .gate-kiosk-button {
  background: var(--gold);
  bottom: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  color: var(--navy);
  position: fixed;
  right: 18px;
  z-index: 60;
}

.brand-logo {
  display: block;
  max-width: 430px;
  width: 72%;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.gate-card h1 {
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 1;
  margin: 24px 0 8px;
}

.stage-title,
.stage-word {
  color: var(--gold);
  font-weight: 1000;
  letter-spacing: 0;
}

.stage-title {
  font-size: clamp(2rem, 7vw, 5.6rem);
  line-height: 1;
  margin: 0 0 16px;
}

.lead {
  color: #dceaf6;
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 760px;
}

.role-grid,
.dashboard,
.nav,
.grid-form,
.access-grid,
.scan-layout {
  display: grid;
  gap: 14px;
}

.role-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 24px;
}

.role-grid button {
  min-height: 150px;
  text-align: left;
}

.role-grid strong {
  display: block;
  font-size: 1.25rem;
  margin-bottom: 12px;
}

.role-grid span {
  display: block;
  font-weight: 700;
  line-height: 1.35;
}

.gate-kiosk-button {
  background: #071321;
  border: 2px solid var(--gold);
  color: var(--gold);
  margin-top: 18px;
  min-width: 180px;
}

.gate-kiosk-button.is-on {
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(244, 201, 93, 0.22);
  color: var(--navy);
}

.access-panel {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 24px;
}

.panel-header,
.topbar,
.brand-line,
.top-actions,
.inline-actions,
.form-actions,
.dashboard-actions {
  align-items: center;
  display: flex;
  gap: 14px;
}

.panel-header,
.topbar {
  justify-content: space-between;
}

.software-meta {
  align-items: flex-end;
  background: var(--navy);
  border: 1px solid rgba(244, 201, 93, 0.55);
  border-radius: 8px;
  color: var(--white);
  display: grid;
  font-size: 0.78rem;
  font-weight: 900;
  gap: 2px;
  line-height: 1.1;
  min-width: 190px;
  padding: 9px 12px;
  text-align: right;
}

.software-meta span {
  color: var(--gold);
}

.software-meta strong {
  color: var(--white);
  font-size: 0.9rem;
}

.gate-meta-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.gate-software-meta {
  margin: 0;
  width: fit-content;
}

.access-grid,
.scan-layout {
  grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1.1fr);
}

.camera-box {
  aspect-ratio: 4 / 3;
  background: var(--navy);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.camera-box video {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.scan-frame {
  border: 4px solid var(--gold);
  border-radius: 18px;
  inset: 20%;
  position: absolute;
}

.message,
.status-message {
  color: var(--muted);
  font-weight: 800;
}

.message.success {
  color: #12683a;
}

.message.error {
  color: #b42318;
}

.scan-controls {
  background: rgba(2, 8, 18, 0.86);
  border: 2px solid rgba(244, 201, 93, 0.38);
  border-radius: 8px;
  color: var(--white);
  padding: 12px;
}

.scan-controls.is-success {
  background: rgba(18, 104, 58, 0.92);
  border-color: var(--green);
}

.scan-controls.is-error {
  background: rgba(180, 35, 24, 0.94);
  border-color: #d92d20;
}

.scan-controls .message,
.scan-controls .message.success,
.scan-controls .message.error {
  color: var(--white);
}

.app {
  margin: 0 auto;
  max-width: 1440px;
  padding: 24px;
}

.topbar {
  margin-bottom: 18px;
  padding: 18px 22px;
}

.app-logo {
  width: min(320px, 30vw);
}

.topbar h1 {
  margin: 0;
}

.topbar h1 small {
  color: var(--ink);
  display: block;
  font-size: 1rem;
}

.clock {
  background: var(--navy);
  border-radius: 8px;
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 1000;
  padding: 12px 18px;
}

.gate-clock {
  border: 1px solid rgba(244, 201, 93, 0.55);
  font-size: 1rem;
  padding: 9px 12px;
}

.status-message {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px 18px;
}

.dashboard {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
}

.wide-dashboard {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.direction-center-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 16px;
}

.dashboard article {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  padding: 22px;
}

.direction-overview-card,
.ai-alerts-summary {
  grid-column: 1 / -1;
}

.dashboard span {
  color: var(--muted);
  display: block;
  font-weight: 900;
}

.dashboard strong {
  display: block;
  font-size: 3rem;
}

.nav {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.90);
  color: var(--blue);
}

.nav-btn.is-active {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: var(--white);
}

.panel {
  display: none;
  margin-bottom: 18px;
  padding: 24px;
}

.panel.is-active {
  display: block;
}

.legacy-direction-center,
.legacy-search-nav,
body.role-direction .nav-btn[data-section="scan"],
body.role-direction [data-app-section="scan"] {
  display: none !important;
}

[data-app-section="scan"] {
  background:
    linear-gradient(135deg, rgba(7, 19, 33, 0.98), rgba(2, 8, 18, 0.98)),
    #071321;
  border-color: rgba(244, 201, 93, 0.34);
  color: var(--white);
}

[data-app-section="scan"] .eyebrow,
[data-app-section="scan"] label {
  color: #b9c8dc;
}

[data-app-section="scan"] h2 {
  color: var(--white);
}

[data-app-section="scan"] input,
[data-app-section="scan"] select {
  background: #101f34;
  border-color: rgba(244, 201, 93, 0.35);
  color: var(--white);
}

.kiosk-button {
  background: linear-gradient(135deg, #071321, #13243b);
  border: 2px solid var(--gold);
  bottom: 18px;
  box-shadow: 0 18px 50px rgba(7, 19, 33, 0.42);
  color: var(--gold);
  position: fixed;
  right: 18px;
  z-index: 30;
}

.week-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 4px;
}

.week-hints .eyebrow {
  flex-basis: 100%;
}

.week-chip {
  background: #e8eef7;
  border: 1px dashed #9fb3c8;
  color: #34465f;
  padding: 10px 12px;
}

body.kiosk-mode {
  background: #020812;
}

body.kiosk-mode .topbar,
body.kiosk-mode .dashboard,
body.kiosk-mode .direction-center-panel,
body.kiosk-mode .nav {
  display: none !important;
}

body.kiosk-mode .app {
  max-width: none;
  min-height: 100vh;
  padding: 0;
}

body.kiosk-mode [data-app-section="scan"] {
  border-radius: 0;
  display: block;
  margin: 0;
  min-height: 100vh;
  padding: 28px;
}

body.kiosk-mode .scan-layout {
  align-items: center;
  grid-template-columns: minmax(220px, 0.54fr) minmax(300px, 1fr);
  margin: 0 auto;
  max-width: 1120px;
  min-height: calc(100vh - 160px);
}

body.kiosk-mode .camera-box {
  justify-self: center;
  max-width: min(36vw, 240px);
  width: 100%;
}

.grid-form {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.child-profile-form,
.planning-card-form {
  display: grid;
  gap: 16px;
}

.form-section {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.form-section-title {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 10px;
  font-size: 1.02rem;
}

.form-section-title span {
  align-items: center;
  background: linear-gradient(135deg, var(--blue), var(--green));
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 950;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.registration-simple {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 16px;
}

.registration-summary {
  background: #071321;
  border-radius: 8px;
  color: #f7fbff;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 14px;
}

.registration-summary span {
  color: #c8d4e3;
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.registration-summary strong {
  display: block;
  margin-top: 4px;
}

.quick-child-results {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 44px;
}

.quick-child-results button {
  background: #eaf2fb;
  color: var(--blue);
  padding: 10px 12px;
}

.quick-child-results button.is-selected {
  background: var(--blue);
  color: white;
}

.registration-days-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  width: 100%;
}

.inline-form {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

.check-row {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 10px;
  text-transform: none;
}

.check-row input {
  width: auto;
}

.is-hidden {
  display: none !important;
}

.form-note {
  background: #eef6ff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 12px;
}

.form-actions {
  align-self: end;
  flex-wrap: wrap;
}

.compact-label {
  min-width: min(100%, 280px);
  text-align: left;
}

.cards-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

#aiAlertsList {
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(201, 88, 77, 0.24);
  border-radius: 8px;
  padding: 14px;
}

.ai-alert-card {
  border-left: 6px solid #c9584d;
}

.ai-alert-card header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.icon-button {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 1.25rem;
  height: 34px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 34px;
}

.pdf-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  overflow: hidden;
}

.pdf-preview iframe {
  border: 0;
  display: block;
  height: 420px;
  width: 100%;
}

.pdf-preview.compact iframe {
  height: 260px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.highlight-card {
  background: #fff7df;
  border-color: var(--gold);
}

.document-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 12px 0;
}

.document-row:first-of-type {
  border-top: 0;
}

.document-row p {
  color: var(--muted);
  margin: 4px 0 0;
}

.planning-selector-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 14px 0;
}

.planning-card-form {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-top: 14px;
  padding: 16px;
}

.planning-card-form .form-actions {
  align-self: end;
}

.planning-board {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
  padding: 12px;
}

.planning-table th,
.planning-table td {
  vertical-align: top;
}

.download-link {
  background: #eaf2fb;
  border-radius: 8px;
  color: var(--blue);
  font-weight: 900;
  padding: 10px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.small-button {
  padding: 9px 11px;
  font-size: 0.82rem;
}

.info-card header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.info-card h3 {
  margin: 0;
}

.section-subtitle {
  color: var(--ink);
  margin: 18px 0 8px;
}

.info-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 12px;
}

.info-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.badge {
  background: rgba(244, 201, 93, 0.22);
  border: 1px solid rgba(244, 201, 93, 0.9);
  border-radius: 999px;
  color: #745500;
  font-weight: 900;
  padding: 8px 12px;
}

.muted {
  color: var(--muted);
}

.feature-hidden {
  display: none !important;
}

.full-row,
.permission-box {
  grid-column: 1 / -1;
}

.permission-box {
  background: rgba(232, 238, 248, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

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

.presence-table {
  border-collapse: collapse;
  min-width: 640px;
  width: 100%;
}

.presence-table th,
.presence-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
}

.presence-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.presence-table .presence-status-col {
  text-align: right;
  width: 170px;
}

.checkmark {
  color: var(--green);
  font-size: 1.35rem;
  font-weight: 1000;
}

#aiPopupAnswer {
  min-height: 130px;
  resize: vertical;
  width: 100%;
}

.qr-card {
  min-width: min(680px, 90vw);
  padding: 28px;
}

.qr-box {
  display: grid;
  justify-content: center;
  margin: 18px 0;
}

body.role-moniteur .coordinator-only:not(.monitor-only),
body.role-moniteur .maintenance-only,
body.role-moniteur .management-only,
body.role-moniteur .direction-only:not(.monitor-only),
body.role-coordinateur .maintenance-only,
body.role-coordinateur .direction-only:not(.coordinator-only),
body.role-maintenance .monitor-only,
body.role-maintenance .coordinator-only,
body.role-maintenance .direction-only:not(.management-only),
body.role-direction .monitor-only:not(.direction-only),
body.role-direction .coordinator-only:not(.direction-only),
body.role-direction .maintenance-only {
  display: none !important;
}

body.role-admin .nav-btn.maintenance-only,
body.role-admin .app-section.maintenance-only.is-active,
body.role-admin .app-section.maintenance-only.is-active .maintenance-only {
  display: block !important;
}

body.role-admin .nav-btn.maintenance-only {
  display: inline-flex !important;
}

@media (max-width: 820px) {
  .gate,
  .app {
    padding: 12px;
  }

  .role-grid,
  .access-grid,
  .scan-layout,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .topbar,
  .brand-line,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-logo,
  .brand-logo {
    width: 100%;
  }
}
