:root {
  --red: #E5241D;
  --red-dark: #c81e18;
  --navy: #14213D;
  --text: #1A1A1A;
  --muted: #6B6B6B;
  --bg: #FFFFFF;
  --sidebar-bg: #F5F5F5;
  --item-hover: #EDEDED;
  --item-active: #FDE7E6;
  --border: #E0E0E0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { text-decoration: none; color: inherit; }

/* ---------- Écran de connexion ---------- */

.login-hero {
  width: 100%;
  height: 50vh;
  min-height: 340px;
  max-height: 620px;
  overflow: hidden;
}

.login-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.login-tagline {
  text-align: center;
  padding: 28px 20px 4px;
}

.login-tagline-en {
  color: var(--red);
  font-weight: 800;
  font-size: 32px;
  line-height: 1.15;
  margin: 0 0 8px;
}

.login-tagline-fr {
  color: var(--navy);
  font-weight: 700;
  font-size: 24px;
  margin: 0;
}

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.login-logo {
  height: 170px;
  width: auto;
  margin-bottom: 28px;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 20px;
  cursor: pointer;
}

.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: var(--red-dark); }

.btn-secondary { background: var(--item-hover); color: var(--text); font-weight: 600; }

.btn:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-google {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

.dev-login { margin-top: 20px; }
.or-sep { color: var(--muted); font-size: 12px; margin: 16px 0 8px; }

.dev-login-form {
  display: flex;
  gap: 8px;
}

.dev-login-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.flash-list { margin: 0 0 16px; }
.flash { font-size: 13px; margin: 4px 0; }
.flash-error { color: var(--red); }

/* ---------- Coquille applicative (menu + contenu) ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 22px 0 10px;
}

.edition-block {
  padding: 0 20px 12px;
  display: block;
  cursor: pointer;
}

.edition-logo { height: 64px; width: auto; display: block; }

.edition-reminder {
  font-weight: 700;
  font-size: 13px;
  margin-top: 6px;
}

.edition-hint {
  font-size: 8px;
  color: var(--muted);
  margin-top: 1px;
}

.sidebar-sep {
  height: 1px;
  background: #DDDDDD;
  margin: 0 20px 10px;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  padding: 0 20px 4px;
}

.user-email {
  font-size: 10px;
  color: var(--muted);
  padding: 0 20px 16px;
}

.menu { display: flex; flex-direction: column; flex: 1; }

.menu-item {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text);
}

.menu-item:hover { background: var(--item-hover); }

.menu-item.active {
  background: var(--item-active);
  color: var(--red);
  font-weight: 600;
}

.menu-subitem {
  padding-left: 36px;
  font-size: 11px;
  color: var(--muted);
}

.logout-link {
  padding: 14px 20px;
  color: var(--red);
  font-size: 11px;
}

.content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.centered-content { text-align: center; max-width: 560px; }
.centered-content h1 { font-size: 22px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ---------- Sélecteur d'édition ---------- */

.edition-picker-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.edition-picker-card {
  max-width: 420px;
  width: 100%;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
}

.edition-picker-card h2 { margin: 0 0 4px; font-size: 18px; }

.edition-option {
  display: block;
  padding: 10px 4px;
  font-size: 13px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.actions-top {
  justify-content: flex-start;
  margin-top: 0;
  margin-bottom: 20px;
}

/* ---------- Pages de contenu (catégories / participants) ---------- */

.page-block {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 40px;
  text-align: left;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title { font-size: 20px; margin: 0; font-weight: 700; }
.page-subtitle { color: var(--muted); font-size: 12px; margin: 4px 0 20px; }

.btn-add-link { text-decoration: none; }

.table-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.table-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.table-row:last-child { border-bottom: none; }

.table-header {
  background: #FAFAFA;
  font-weight: 700;
  font-size: 12px;
}

.table-row.editing { background: #FFF6E5; }

.table-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.col { padding: 0 6px; font-size: 13px; }
.col-check { flex: 0 0 40px; }
.col-cat-name, .col-part-name { flex: 1 1 26%; }
.col-cat-display, .col-part-cat { flex: 1 1 30%; }
.col-cat-code, .col-part-code { flex: 0 0 70px; }
.col-part-act { flex: 0 0 70px; }
.col-report-name { flex: 1 1 55%; }
.col-report-date { flex: 0 0 140px; }
.col-report-dl { flex: 0 0 120px; }
.col-scenario-tpl-name { flex: 1 1 45%; }
.col-scenario-tpl-kind { flex: 0 0 160px; }
.col-scenario-tpl-lang { flex: 0 0 100px; }
.col-scenario-tpl-date { flex: 0 0 140px; }

.table-card-scroll {
  max-height: 480px;
  overflow-y: auto;
}

.table-card-scroll .table-header {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-row input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.inline-toggle-form { margin: 0; }

.error-list { list-style: none; padding: 0; margin: 0 0 14px; }
.error-list li { margin: 2px 0; }

/* ---------- Formulaire participant ---------- */

.form-page { max-width: 780px; }

.participant-form label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}

.participant-form input[type="text"],
.participant-form input[type="email"],
.participant-form select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  color: var(--text);
  background: white;
}

.participant-form input[readonly] {
  background: #F0F0F0;
  color: var(--muted);
}

.participant-form select.locked {
  pointer-events: none;
  background: #F0F0F0;
  color: var(--muted);
}

.form-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px 4px;
  margin-bottom: 16px;
}

.form-section legend {
  font-size: 12px;
  font-weight: 700;
  padding: 0 6px;
}

.addresses-row {
  display: flex;
  gap: 16px;
}

.address-section { flex: 1; }

.same-address-label {
  background: #FAFAFA;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 11px;
}
.same-address-label input { width: auto; display: inline; margin-right: 6px; }

.channels-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 14px;
}

.channel-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.channel-checkbox input { width: auto; margin: 0; }

/* ---------- Chargement fichier résultat ---------- */

.upload-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}

.upload-form {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.flash-success {
  color: #1F9D55;
  font-weight: 600;
}

.error-report-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  max-height: 420px;
  overflow-y: auto;
}

.error-report-list li {
  font-size: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.error-report-list li:last-child { border-bottom: none; }

.uploaded-files-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 210px; /* ~5 lignes visibles, le reste accessible par défilement */
  overflow-y: auto;
  margin-bottom: 20px;
}

.uploaded-file-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.uploaded-file-row:last-child { border-bottom: none; }

.uploaded-file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uploaded-file-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Liste des tests ---------- */

.tests-total-badge {
  font-size: 12px;
  color: var(--muted);
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  white-space: nowrap;
}

.participant-group {
  margin-bottom: 28px;
}

.participant-group-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--red);
}

.test-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
}

.test-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.test-date { font-weight: 600; }

.test-channel-badge {
  background: var(--item-active);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}

.test-id-tag { color: var(--muted); }

.test-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.code-chip {
  background: #FAFAFA;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.code-chip:hover { background: var(--item-hover); }

.btn-other-data { font-size: 11px; padding: 6px 12px; }

/* ---------- Popups (dialog natif) ---------- */

.app-dialog {
  border: none;
  border-radius: 10px;
  padding: 22px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.app-dialog::backdrop {
  background: rgba(0,0,0,0.4);
}

.app-dialog h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.dialog-field {
  font-size: 13px;
  margin: 8px 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.search-form label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}

.search-form input, .search-form select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
}

.other-data-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 12px;
}

.other-data-key { color: var(--muted); font-weight: 600; }
.other-data-value { word-break: break-word; }

/* La popup JS (tests_list.js) enveloppe chaque paire dans .other-data-row,
   ce qui casse la grille 2 colonnes utilisée par la page de détail (où les
   spans clé/valeur sont des enfants directs de .other-data-grid). On donne
   donc à .other-data-row son propre agencement, avec un espacement net
   entre le nom du champ et sa valeur. */
.other-data-row {
  display: flex;
  gap: 14px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.other-data-row .other-data-key {
  flex: 0 0 220px;
}
.other-data-row .other-data-value {
  flex: 1;
}

.other-data-grid-page {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  max-height: none;
  margin-bottom: 24px;
}

/* ---------- Résultats de recherche ---------- */

.col-search-id { flex: 0 0 110px; }
.col-search-cat, .col-search-part { flex: 1 1 25%; }
.col-search-chan { flex: 0 0 100px; }
.col-search-date { flex: 0 0 110px; }

.search-result-row {
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.search-result-row:hover { background: var(--item-hover); }

/* ---------- Détail d'un test ---------- */

.detail-header-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 24px;
}

.detail-header-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-header-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.detail-header-value { font-size: 14px; font-weight: 600; }

.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  margin: 22px 0 10px;
}

.col-detail-code { flex: 0 0 90px; font-weight: 600; }
.col-detail-value { flex: 0 0 120px; }
.col-detail-obs { flex: 1 1 auto; }

/* ---------- Administration ---------- */

.env-email-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  font-size: 12px;
}
.env-email-list li { padding: 3px 0; }

.col-user-email { flex: 1 1 40%; }
.col-user-added { flex: 0 0 110px; }
.col-user-by { flex: 1 1 25%; color: var(--muted); }
.col-user-edition { flex: 0 0 180px; }

.dialog-input-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.dialog-input-label input, .dialog-input-label select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
}

/* ---------- Facturation ---------- */

.product-group {
  margin-bottom: 18px;
}

.product-group-title {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
}

.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }

.product-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin: 0;
  flex: 1;
}
.product-checkbox-label input { width: auto; margin: 0; }

.product-label-en {
  color: var(--muted);
  font-size: 11px;
}

.product-price-input {
  width: 180px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
}
.product-price-input:disabled {
  background: #F0F0F0;
  color: var(--muted);
}

.product-qty-input {
  width: 70px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  text-align: center;
}
.product-qty-input:disabled {
  background: #F0F0F0;
  color: var(--muted);
}

.product-row-vcsoy { border-bottom: none; padding-bottom: 4px; }

.app-dialog-catalog {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}

.col-catalog-title { flex: 1 1 auto; }
.col-catalog-lang { flex: 0 0 90px; }
.col-catalog-price { flex: 0 0 100px; text-align: right; }

.product-bullets {
  margin: 0 0 10px;
  padding-left: 32px;
  font-size: 12px;
  color: var(--text);
}
.product-bullets li { margin-bottom: 3px; }

.product-group-note {
  padding-left: 32px;
  font-size: 11px;
  margin: 0 0 10px;
}

.col-invoice-desc { flex: 1 1 auto; }
.col-invoice-amount { flex: 0 0 130px; text-align: right; }
.invoice-heading { font-weight: 700; }
.invoice-bullet { padding-left: 28px; }

.invoice-totals-grid {
  max-width: 320px;
  margin-left: auto;
  grid-template-columns: 1fr auto;
}

.edit-invoice-dialog {
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}

.edit-invoice-form .form-section {
  text-align: left;
}

/* ---------- Compilation des résultats ---------- */

.compilation-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.compilation-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  white-space: nowrap;
}

.compilation-table th, .compilation-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

.compilation-table thead th {
  background: var(--sidebar-bg);
  font-weight: 700;
}

.compilation-table tbody td:first-child {
  text-align: left;
}

.invoice-order-controls {
  white-space: nowrap;
  width: 1%;
}

.btn-order-move {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  margin: 0 2px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text);
}
.btn-order-move:hover:not(:disabled) { background: var(--item-hover); }
.btn-order-move:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.4;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--red);
  font-weight: 600;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.link-button:hover { color: var(--red-dark); }

.table-sort-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.table-sort-btn:hover { text-decoration: underline; }

.app-dialog-wide {
  max-width: 640px;
}

.participant-tests-list {
  max-height: 60vh;
  overflow-y: auto;
}

.participant-tests-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.participant-tests-table th, .participant-tests-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.participant-tests-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
}

/* ---------- Liste des résultats ---------- */

.results-summary-line {
  background: var(--item-hover);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 12px;
  font-size: 13px;
}

.results-filter-row {
  display: flex;
  gap: 16px;
}
.results-filter-row .dialog-input-label {
  flex: 1;
}

.results-winners-table td:nth-child(2) {
  text-align: left;
}

/* ---------- Liste des lauréats ---------- */

.winners-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.winner-row {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 20px;
}

.winner-trophy {
  height: 44px;
  width: auto;
  flex: 0 0 auto;
}

.winner-category {
  flex: 0 0 260px;
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}

.winner-name {
  font-size: 16px;
  font-weight: 700;
}

.winner-score {
  margin-left: auto;
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
}

.inline-form { display: inline; }
.btn-compact { font-size: 11px; padding: 6px 10px; }

.back-link {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--red); }

.confirm-delete-box {
  border: 1px solid var(--red);
  background: #FDF2F2;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 13px;
}
.confirm-delete-box p { margin: 0 0 10px; }

.confirm-delete-actions {
  display: flex;
  gap: 10px;
}
