/* AdminBot Web — feuille unique.
 *
 * Mobile d'abord : l'essentiel de l'usage se fait au téléphone, donc les
 * tableaux n'existent qu'à partir de 768 px et cèdent la place à des cartes
 * en dessous. La navigation suit le même principe — barre basse au doigt,
 * colonne latérale au clavier.
 *
 * Palette reprise de VPN Manager pour que les deux applications internes se
 * ressemblent. Thème clair ET sombre : la valeur système est le défaut, un
 * choix explicite se pose en data-theme sur <html> et prime.
 */

:root {
  --bg: #ffffff;
  --surface: #f7f7f7;
  --surface-2: #ededed;
  --fg: #121212;
  --muted: #5e5e5e;
  --muted-2: #8a8a8a;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #1db954;
  --accent-fg: #ffffff;
  --ok: #1aa64b;
  --warn: #c77d18;
  --bad: #c0392b;
  --info: #4a6fb5;

  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tile: 6px;
  /* Marge basse réservée à la barre de navigation mobile + encoche iOS. */
  --nav-h: calc(58px + env(safe-area-inset-bottom, 0px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #181818;
    --surface-2: #242424;
    --fg: #ffffff;
    --muted: #b3b3b3;
    --muted-2: #7a7a7a;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #1ed760;
    --accent-fg: #04130a;
    --ok: #1ed760;
    --warn: #e8a23c;
    --bad: #e8643c;
    --info: #6f8fd6;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #181818;
  --surface-2: #242424;
  --fg: #ffffff;
  --muted: #b3b3b3;
  --muted-2: #7a7a7a;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #1ed760;
  --accent-fg: #04130a;
  --ok: #1ed760;
  --warn: #e8a23c;
  --bad: #e8643c;
  --info: #6f8fd6;
}

* { box-sizing: border-box; border-color: var(--border); }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { filter: brightness(1.15); }

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; }
p { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.tabular { font-variant-numeric: tabular-nums; }

/* ─── Ossature ─────────────────────────────────────────────────────────── */

#app { min-height: 100dvh; }

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

.side { display: none; }

.main {
  flex: 1;
  min-width: 0;
  padding-bottom: var(--nav-h);
}

.wrap { padding: 0 16px; }

.head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 18px 16px 12px;
}
.head h1 { font-size: 21px; }
.head .sub { margin-top: 2px; font-size: 12px; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 9px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand span { font-size: 16px; font-weight: 500; letter-spacing: -0.02em; }

/* Barre basse — au doigt, cibles 44 px minimum. */
.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  font-size: 9.5px;
  color: var(--muted);
  position: relative;
}
.nav a.on { color: var(--fg); }
.nav a.on svg { stroke-width: 2.3; }
.nav .dot {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(6px);
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bad);
  color: var(--bg);
  font-size: 10px; font-weight: 600;
  display: grid; place-items: center;
}

/* ─── Blocs ────────────────────────────────────────────────────────────── */

.tile {
  border: 1px solid var(--border);
  border-radius: var(--tile);
  background: var(--surface);
}

.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; }

.stat { padding: 14px; }
.stat .k { font-size: 11px; color: var(--muted-2); }
.stat .v { margin-top: 7px; font-size: 24px; font-weight: 500; line-height: 1; }
.stat .v small { font-size: 13px; color: var(--muted-2); font-weight: 400; }
.stat .n { margin-top: 8px; font-size: 11px; color: var(--muted); }

.bar { height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.pill .d { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.row {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  min-height: 44px;
  color: inherit;
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 14px; font-weight: 500; }
.row .s { margin-top: 2px; font-size: 11.5px; color: var(--muted); }

.kv {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}
.kv:first-child { border-top: 0; }
.kv > span:first-child { color: var(--muted); flex-shrink: 0; }
.kv > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }

.sect { margin-top: 22px; }
.sect > h2 {
  font-size: 12px; font-weight: 500;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 9px;
}

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  min-height: 34px;
}
.chip.on { background: var(--surface-2); color: var(--fg); font-weight: 500; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 0 18px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; color: var(--muted-2); }
.field input {
  min-height: 48px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--fg);
  font-family: var(--mono); font-size: 16px; /* 16px : empêche le zoom iOS */
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.msg { padding: 12px 14px; border-radius: var(--tile); font-size: 12.5px; line-height: 1.5; }
.msg-bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.msg-info { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

.spin {
  width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 999px;
  animation: sp 0.7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* Cases du calendrier de sauvegarde. Elles vivent sous le nom de chaque
   configuration et s'étirent à la largeur disponible : plus de défilement
   horizontal pour atteindre les jours récents sur téléphone. */
.cell { min-width: 6px; height: 15px; border-radius: 3px; background: var(--surface-2); }
.cell-ok { background: var(--ok); }
.cell-ko { background: var(--bad); }
.cell-part { background: var(--warn); }

/* ─── Tablette / bureau ────────────────────────────────────────────────── */

@media (min-width: 768px) {
  .main { padding-bottom: 0; }
  .nav { display: none; }

  .side {
    position: sticky; top: 0;
    display: flex; flex-direction: column;
    width: 232px; flex-shrink: 0;
    height: 100dvh;
    padding: 20px 12px;
    border-right: 1px solid var(--border);
  }
  .side nav { display: flex; flex-direction: column; gap: 4px; margin-top: 22px; }
  .side nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 8px;
    font-size: 14px; color: var(--muted);
  }
  .side nav a.on { background: var(--surface-2); color: var(--fg); font-weight: 500; }
  .side nav a .dot {
    position: static; transform: none;
    margin-left: auto;
  }

  .wrap, .head { padding-left: 24px; padding-right: 24px; }
  .head h1 { font-size: 22px; }
  .inner { max-width: 1180px; }

  .grid-2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }

  /* Le tableau ne remplace les cartes qu'ici : au téléphone il serait illisible. */
  .only-wide { display: block; }
  .only-narrow { display: none; }

  table.data { width: 100%; border-collapse: collapse; }
  table.data th {
    font-size: 10.5px; font-weight: 400; color: var(--muted-2);
    text-align: left; padding: 11px 12px 9px;
    background: var(--bg);
  }
  table.data td { padding: 11px 12px; font-size: 13px; border-top: 1px solid var(--border); }
}

@media (max-width: 767px) {
  .only-wide { display: none; }
  .only-narrow { display: block; }
}
