* { box-sizing: border-box; }
:root { color-scheme: dark; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #12151c;
  color: #dde3ee;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------- Navigation ---------------------------- */
nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 20px;
  background: #1a1f2b;
  border-bottom: 1px solid #2a3140;
  position: sticky;
  top: 0;
  z-index: 50;
}
nav .brand { font-weight: 700; margin-right: 8px; font-size: 1.05em; }
.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  flex: 1;
}
nav a {
  color: #9db4d8;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  line-height: 1;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
nav a:hover { color: #fff; background: #232a38; }
nav a.active { color: #fff; background: #2563eb; }
.nav-links .logout { margin-left: auto; color: #f0a0a0; }
.nav-links .logout:hover { background: #3a1a1a; color: #fff; }

/* Bouton burger — masqué sur desktop, visible en mobile */
.nav-toggle {
  display: none;
  margin: 0;
  padding: 6px 12px;
  font-size: 1.4em;
  line-height: 1;
  background: transparent;
  color: #dde3ee;
  border: 1px solid #2a3140;
  border-radius: 8px;
}

main { max-width: 1000px; margin: 0 auto; padding: 24px; }
h1 { font-size: 1.5em; }
a { color: #6ea8fe; }

/* ------------------------------ Cartes ------------------------------ */
.cards { display: flex; flex-wrap: wrap; gap: 16px; }
.card {
  background: #1a1f2b;
  border: 1px solid #2a3140;
  border-radius: 12px;
  padding: 16px 20px;
  margin: 12px 0;
  min-width: 200px;
  flex: 1;
}
.card h3 { margin-top: 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
}
.badge.ok   { background: #12391f; color: #4ade80; }
.badge.err  { background: #3a1a1a; color: #f87171; }
.badge.warn { background: #3a2f12; color: #fbbf24; }
.badge.live { background: #4c0519; color: #fb7185; }

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok    { background: #12391f; color: #4ade80; }
.flash.error { background: #3a1a1a; color: #f87171; }

/* ------------------------------ Formulaires ------------------------- */
label { display: block; margin: 12px 0; font-size: 0.95em; }
label.check { display: flex; gap: 8px; align-items: flex-start; }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  margin-top: 5px;
  border-radius: 8px;
  border: 1px solid #2a3140;
  background: #12151c;
  color: #dde3ee;
  font-size: 16px; /* >=16px : évite le zoom auto au focus sur iOS */
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .25);
}
label.check input { width: auto; margin-top: 3px; }

button {
  padding: 10px 18px;
  margin-top: 10px;
  border: none;
  border-radius: 8px;
  background: #2a3140;
  color: #dde3ee;
  font-size: 1em;
  cursor: pointer;
  touch-action: manipulation;
}
button.primary { background: #2563eb; color: #fff; }
button.danger  { background: #b91c1c; color: #fff; }
button.small   { padding: 7px 12px; font-size: 0.85em; margin: 0; }
button:hover { filter: brightness(1.15); }

a.button {
  display: inline-block;
  padding: 10px 18px;
  margin-top: 10px;
  border-radius: 8px;
  background: #2a3140;
  color: #dde3ee;
  text-decoration: none;
}
a.button.small { padding: 7px 12px; font-size: 0.85em; margin: 0; }
a.button:hover { filter: brightness(1.15); }

/* ------------------------------ Tableaux ---------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #1a1f2b;
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #2a3140; }
th { background: #212736; }
td.center { text-align: center; }

.logbox {
  background: #0b0d12;
  border: 1px solid #2a3140;
  border-radius: 12px;
  padding: 14px;
  height: 320px;
  overflow-y: auto;
  font-family: Consolas, monospace;
  font-size: 0.85em;
  white-space: pre-wrap;
  word-break: break-word;
}
.hint { color: #93a1b8; font-size: 0.92em; }

/* ------------------------------ Mobile ------------------------------ */
@media (max-width: 640px) {
  nav {
    padding: 10px 14px;
    gap: 0;
  }
  nav .brand { flex: 1; font-size: 1em; }
  .nav-toggle { display: block; }   /* le burger apparaît */

  /* Menu déroulant : caché par défaut, s'ouvre au clic sur le burger */
  .nav-links {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .25s ease, opacity .2s ease, margin .25s ease;
    margin-top: 0;
  }
  nav.open .nav-links {
    max-height: 70vh;
    opacity: 1;
    margin-top: 10px;
    overflow-y: auto;
  }
  .nav-links a {
    padding: 13px 14px;
    font-size: 1.02em;
    border-radius: 10px;
    background: #12151c;
  }
  .nav-links a:hover, .nav-links a.active { background: #2563eb; color: #fff; }
  .nav-links .logout { margin-left: 0; margin-top: 4px; }

  main { padding: 14px; }
  h1 { font-size: 1.3em; }
  h2 { font-size: 1.15em; }

  .cards { gap: 12px; }
  .card { margin: 10px 0; padding: 14px 16px; min-width: 100%; }

  /* Rendre TOUS les tableaux défilables horizontalement sans changer le HTML */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
          white-space: nowrap; border-radius: 10px; }
  th, td { padding: 10px; }

  /* Cibles tactiles plus grandes */
  button, a.button { min-height: 42px; }
  button.small, a.button.small { min-height: 38px; padding: 8px 12px; font-size: 0.9em; }

  .logbox { height: 260px; }
}

/* Grands écrans : un peu plus large */
@media (min-width: 1200px) {
  main { max-width: 1120px; }
}
