/*
 * Console d'administration Frugalys.
 *
 * Mêmes jetons visuels que l'app et que la vitrine — même vert, mêmes gris,
 * mêmes rayons — mais une densité tout autre : la vitrine doit convaincre en
 * dix secondes, la console doit tenir quinze chiffres à l'écran sans qu'on
 * ait à faire défiler. D'où les cartes plus serrées, les tailles plus petites,
 * et les nombres en chasse fixe.
 *
 * Aucune police externe, aucune bibliothèque de graphiques : les courbes sont
 * du SVG écrit à la main par console.js. Une bibliothèque de graphiques pèse
 * plus lourd que toute la console, et la politique de sécurité du serveur
 * n'autorise de toute façon que ce qui vient de lui.
 */

:root {
  --accent: #34c759;
  --accent-sombre: #1c9d55;
  --fond: #f6f7f8;
  --carte: #ffffff;
  --texte: #1c1c1e;
  --texte-faible: #6e6e73;
  --texte-tres-faible: #8a8a8e;
  --danger: #ff3b30;
  --alerte: #ff9500;
  --bleu: #0a84ff;
  --separateur: #e9e9ec;

  --rayon: 14px;
  --rayon-carte: 18px;
  --ombre: 0 1px 3px rgba(28, 28, 30, .06), 0 8px 24px -18px rgba(28, 28, 30, .3);

  --police: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --chiffres: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.5;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .82rem; font-weight: 600; color: var(--texte-faible); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 .8rem; }
a { color: var(--accent-sombre); }

[hidden] { display: none !important; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ==========================================================================
   Connexion
   ========================================================================== */
.connexion {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.connexion__carte {
  width: 100%;
  max-width: 390px;
  background: var(--carte);
  border-radius: var(--rayon-carte);
  border: 1px solid var(--separateur);
  box-shadow: var(--ombre);
  padding: 32px 28px;
}

.marque {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.marque__pastille {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent);
  flex: none;
}
.marque__pastille::before {
  content: "";
  position: absolute;
  inset: 6px 8px;
  background: #fff;
  border-radius: 3px;
}
.marque__pastille::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 13px;
  height: 1.4px;
  background: var(--accent);
}
.marque__role {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--texte-tres-faible);
  border: 1px solid var(--separateur);
  border-radius: 999px;
  padding: 2px 8px;
}

.champ { display: grid; gap: 6px; margin-bottom: 16px; }
.champ label { font-size: .8rem; font-weight: 600; color: var(--texte-faible); }
.champ input, .champ select {
  font: inherit;
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--separateur);
  border-radius: 11px;
  padding: 11px 13px;
  width: 100%;
}
.champ input:focus, .champ select:focus { border-color: var(--accent); }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid var(--separateur);
  background: var(--carte);
  color: var(--texte);
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
}
.bouton:hover { background: var(--fond); }
.bouton--principal {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bouton--principal:hover { background: var(--accent-sombre); border-color: var(--accent-sombre); }
.bouton--danger { color: var(--danger); border-color: rgba(255, 59, 48, .35); background: #fff; }
.bouton--danger:hover { background: rgba(255, 59, 48, .06); }
.bouton--large { width: 100%; }
.bouton:disabled { opacity: .5; cursor: default; }
.bouton--petit { min-height: 32px; padding: 0 12px; font-size: .82rem; }

.message {
  border-radius: 11px;
  padding: 11px 14px;
  font-size: .9rem;
  margin: 0 0 16px;
}
.message--erreur { background: rgba(255, 59, 48, .08); color: #b3261e; }
.message--ok { background: rgba(52, 199, 89, .12); color: var(--accent-sombre); }

/* ==========================================================================
   Cadre de la console
   ========================================================================== */
.console { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.lateral {
  background: var(--carte);
  border-right: 1px solid var(--separateur);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.onglets { display: grid; gap: 2px; }
.onglet {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--texte-faible);
  font: inherit;
  font-size: .92rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.onglet:hover { background: var(--fond); color: var(--texte); }
.onglet[aria-current="page"] {
  background: rgba(52, 199, 89, .12);
  color: var(--accent-sombre);
  font-weight: 600;
}

.lateral__pied { margin-top: auto; font-size: .8rem; color: var(--texte-tres-faible); display: grid; gap: 8px; }

.principal { padding: 26px 30px 60px; min-width: 0; }

.entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.entete__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

select.periode {
  font: inherit;
  font-size: .88rem;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--separateur);
  background: var(--carte);
  color: var(--texte);
}

/* ==========================================================================
   Cartes de chiffres
   ========================================================================== */
.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.tuile {
  background: var(--carte);
  border: 1px solid var(--separateur);
  border-radius: var(--rayon);
  padding: 15px 16px;
}
.tuile__intitule {
  font-size: .76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--texte-tres-faible);
  margin: 0 0 6px;
}
.tuile__valeur {
  font-family: var(--chiffres);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0;
  /* Les chiffres doivent avoir la même chasse : sans cela, une valeur qui
     passe de 999 à 1000 fait sauter toute la ligne de tuiles. */
  font-variant-numeric: tabular-nums;
}
.tuile__note { font-size: .8rem; color: var(--texte-faible); margin: 4px 0 0; }
.tuile--accent .tuile__valeur { color: var(--accent-sombre); }
.tuile--danger .tuile__valeur { color: var(--danger); }
.tuile--alerte .tuile__valeur { color: var(--alerte); }

.carte {
  background: var(--carte);
  border: 1px solid var(--separateur);
  border-radius: var(--rayon-carte);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.carte__entete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.carte__note { font-size: .82rem; color: var(--texte-tres-faible); margin: 0; }

/* ==========================================================================
   Graphiques
   ========================================================================== */
.graphique { width: 100%; overflow-x: auto; }
.graphique svg { display: block; width: 100%; height: auto; }

.legende { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: .82rem; color: var(--texte-faible); }
.legende span { display: inline-flex; align-items: center; gap: 7px; }
.legende i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ==========================================================================
   Tableaux
   ========================================================================== */
.defilant { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--separateur);
  white-space: nowrap;
}
th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--texte-tres-faible);
  font-weight: 700;
}
td.nombre, th.nombre { text-align: right; font-family: var(--chiffres); font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--fond); }
td.large { white-space: normal; min-width: 220px; }

.etiquette {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--fond);
  color: var(--texte-faible);
}
.etiquette--premium { background: rgba(52, 199, 89, .14); color: var(--accent-sombre); }
.etiquette--demo { background: rgba(255, 149, 0, .14); color: #a35c00; }
.etiquette--supprime { background: rgba(255, 59, 48, .1); color: #b3261e; }
.etiquette--admin { background: rgba(10, 132, 255, .12); color: #0a5bbf; }

.barre-outils { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.barre-outils input[type="search"] {
  font: inherit;
  font-size: .9rem;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid var(--separateur);
  background: var(--carte);
  min-width: 240px;
}

.vide { color: var(--texte-tres-faible); font-size: .9rem; padding: 22px 4px; text-align: center; }

.chargement { color: var(--texte-tres-faible); font-size: .9rem; padding: 22px 4px; }

/* ==========================================================================
   Écrans étroits
   ========================================================================== */
@media (max-width: 860px) {
  .console { grid-template-columns: 1fr; }
  .lateral {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--separateur);
  }
  .onglets { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .principal { padding: 20px 18px 50px; }
}
