:root {
  --bg: #0f1720;
  --card-bg: #1a2530;
  --text: #e8edf2;
  --muted: #8fa2b3;
  --accent: #ff7a1a;
  --green: #35c264;
  --red: #e6544a;
  --border: #2a3947;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 22px;
  background: linear-gradient(135deg, #1a2530 0%, #0f1720 100%);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.status .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px rgba(230,84,74,0.6);
}

.status-on .dot { background: var(--green); box-shadow: 0 0 6px rgba(53,194,100,0.6); }

main {
  padding: 16px;
  max-width: 700px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.card h2 { margin-top: 0; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { margin: 0; }

form label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1720;
  color: var(--text);
  font-size: 14px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

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

.buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}

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

th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable.sort-asc::after { content: ' \25B2'; font-size: 9px; }
th.sortable.sort-desc::after { content: ' \25BC'; font-size: 9px; }

/* Actions de tableau (Démarrer / Terminer / Supprimer / Désassigner)
   sous forme de vrais boutons, plus faciles à toucher sur mobile. */
td .row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

td button.link {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  min-height: 36px;
  cursor: pointer;
}

td button.link:active { opacity: 0.85; }

/* Le bouton "Démarrer" une session reste dans le même style que les autres
   actions de la table mais en vert pour le distinguer visuellement des
   actions destructives (Supprimer / Désassigner / Terminer). */
td button.link.action-start {
  background: var(--green);
}

#passings-table-body tr:first-child { color: var(--accent); font-weight: 600; }

/* ===== Onglets ===== */
#tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 999px;
  white-space: nowrap;
}

.tab-btn.active {
  color: #fff;
  background: var(--accent);
}

/* ===== Menus déroulants (groupes d'onglets) ===== */
.tab-dropdown { position: relative; }

.dropdown-toggle::after {
  content: ' \25BE';
  font-size: 11px;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  flex-direction: column;
  gap: 2px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 190px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 20;
}

.dropdown-menu.open { display: flex; }

.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.dropdown-item:hover { background: rgba(255,255,255,0.06); }

.dropdown-item.active {
  color: #fff;
  background: var(--accent);
}

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.date-field input[type="date"] {
  flex: 0 0 auto;
  min-width: 0;
}

.tab-panel { display: none; flex-direction: column; gap: 16px; }
.tab-panel.active { display: flex; }

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input, .inline-form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1720;
  color: var(--text);
  font-size: 14px;
  flex: 1;
  min-width: 140px;
}

select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1720;
  color: var(--text);
  font-size: 14px;
}

.raw-log {
  max-height: 260px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  background: #0f1720;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.raw-log .entry { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.raw-log .entry .tag-transponder { color: var(--accent); }
.raw-log .entry .tag-gate { color: var(--green); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-active { background: rgba(53,194,100,0.15); color: var(--green); }
.badge-closed { background: rgba(143,162,179,0.15); color: var(--muted); }

.session-row { cursor: pointer; }
.session-row:hover { background: rgba(255,255,255,0.02); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-label input { width: auto; margin: 0; }

.code-block {
  background: #0f1720;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}

/* ===== Bouton "lien" générique (hors tableaux : déconnexion, jetons, etc.) ===== */
button.link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 2px;
  font-size: 13px;
  min-height: auto;
  cursor: pointer;
  text-decoration: underline;
}

/* ===== Barre de piste / utilisateur ===== */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.site-select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.site-select-label select {
  min-width: 160px;
  font-weight: 600;
  color: var(--text);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* ===== Page de connexion ===== */
body.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 360px;
  margin: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
}

.login-card h1 {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.login-card form { text-align: left; margin-top: 20px; }
.login-card .buttons { justify-content: center; margin-top: 4px; }
.login-card button[type="submit"] { width: 100%; }

.error-text {
  color: var(--red);
  font-size: 13px;
  margin: 8px 0 0;
}

/* ===== Administration ===== */
.token-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: #0f1720;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  word-break: break-all;
}