:root {
  /* Charte TEEPTRAK : corail #e32b1f + anthracite #2b2723 */
  --bg: #f6f4f2; --fg: #2b2723; --card: #fff; --border: #e2ddd8;
  --coral: #e32b1f; --coral-dark: #c31f14; --ink: #2b2723;
  --accent: #e32b1f; --ok: #1a7f37; --warn: #b45309; --danger: #b91c1c; --muted: #7c736b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.05rem; margin-top: 1.8rem; }
code { background: #f0ece8; padding: 0 .3em; border-radius: 3px; font-size: .9em; }
code.wrap { word-break: break-all; }
pre { background: var(--ink); color: #e9e2db; padding: .8rem 1rem; border-radius: 6px; overflow-x: auto; font-size: .85em; }

nav { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem 1.1rem; background: var(--ink); color: #fff; padding: .55rem 1.2rem; }
nav .brand { display: inline-flex; align-items: center; gap: .5rem; margin-right: .8rem; text-decoration: none; }
nav .brand-logo { height: 20px; display: block; }
nav .brand-tag { font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: #fff; background: var(--coral); padding: .1rem .4rem; border-radius: 4px; }
/* Liens de nav = boutons-pastilles (cibles tactiles plus larges que du texte). */
nav a:not(.brand), nav form button {
  color: #d8d1ca; text-decoration: none; font: inherit;
  padding: .42rem .8rem; border-radius: 7px; line-height: 1;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
nav a:not(.brand):hover, nav form button:hover { background: rgba(255,255,255,.09); color: #fff; }
nav a.active { background: var(--coral); color: #fff; border-color: var(--coral); }
nav form { margin: 0; }
nav form button { border-color: rgba(255,255,255,.18); }
nav .spacer { flex: 1; }
nav .user { color: #9a8f85; font-size: .9em; margin-right: .2rem; }

/* Sélecteur de langue : dropdown avec drapeaux */
.flag { width: 21px; height: 14px; border-radius: 2px; display: inline-block; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.langdd { position: relative; display: inline-block; }
.langdd summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .45rem;
  padding: .42rem .7rem; border-radius: 7px; line-height: 1; user-select: none;
}
.langdd summary::-webkit-details-marker { display: none; }
.langdd .caret { font-size: .7em; opacity: .7; }
.langdd ul {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  margin: 0; padding: .3rem; list-style: none; min-width: 10.5rem;
  background: #fff; color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(43,39,35,.18);
}
.langdd ul a {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border-radius: 6px; text-decoration: none;
  color: var(--ink); font-size: .92rem; white-space: nowrap;
}
.langdd ul a:hover { background: #f0ece8; }
.langdd ul a.active { background: var(--coral); color: #fff; }
/* Variante navbar (fond anthracite) */
nav .langdd summary { color: #d8d1ca; border: 1px solid transparent; }
nav .langdd summary:hover, nav .langdd[open] summary { background: rgba(255,255,255,.09); color: #fff; }
/* Variante écran de connexion */
.login-lang { margin-top: 1.4rem; display: flex; justify-content: center; }
.login-lang .langdd summary { color: var(--muted); border: 1px solid var(--border); }
.login-lang .langdd summary:hover, .login-lang .langdd[open] summary { color: var(--fg); border-color: #c9c0b8; }
.login-lang .langdd ul { right: auto; left: 50%; transform: translateX(-50%); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 6px; background: var(--card); }
.table-wrap table { border: none; border-radius: 0; min-width: 100%; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
th, td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--border); }
th { background: #f0ece8; font-weight: 600; font-size: .85em; }
tr:last-child td { border-bottom: none; }
table.kv th { width: 9rem; background: none; vertical-align: top; }

.cards { display: flex; gap: .8rem; flex-wrap: wrap; margin: 1rem 0; }
.card { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--coral); border-radius: 8px; padding: .7rem 1.1rem; font-size: .85em; color: var(--muted); }
.card .num { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

form label { display: block; margin: .6rem 0; }
input, select, textarea { font: inherit; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 5px; background: #fff; width: 100%; max-width: 28rem; }
.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin: 0; }
.inline-form input, .inline-form select { width: auto; }
input[type=range] { width: 14rem; vertical-align: middle; }
label.check { display: flex; gap: .5rem; align-items: center; }
form.inline { display: inline; }
label.check input { width: auto; }

.btn { display: inline-block; font: inherit; padding: .4rem 1rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; text-decoration: none; color: var(--fg); margin-top: .4rem; }
.btn:hover { border-color: #c9c0b8; }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { display: block; text-align: center; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
button.link.danger { color: var(--danger); }

.tag { display: inline-block; font-size: .75em; padding: .1rem .5rem; border-radius: 99px; background: #e2e8f0; color: #334155; }
.tag.on { background: #dcfce7; color: var(--ok); }
.tag.warn { background: #fef3c7; color: var(--warn); }
.tag.danger { background: #fee2e2; color: var(--danger); }

.flash { padding: .5rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: #dcfce7; color: var(--ok); }
.flash.err { background: #fee2e2; color: var(--danger); }
.muted { color: var(--muted); }
.danger { color: var(--danger); }

.login-box { max-width: 23rem; margin: 5rem auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 2.2rem 2rem; text-align: center; box-shadow: 0 8px 30px rgba(43,39,35,.08); border-top: 4px solid var(--coral); }
.login-logo { width: 190px; max-width: 80%; height: auto; margin: .3rem auto .8rem; display: block; }
.login-sub { color: var(--muted); font-size: .9em; margin: 0 0 1.4rem; }
.login-box form { text-align: left; }
.login-box details { margin-top: 1.2rem; text-align: left; }
.pill { display: inline-block; font-size: .72em; font-weight: 700; letter-spacing: .06em; color: #fff; background: var(--coral); padding: .05rem .4rem; border-radius: 4px; vertical-align: middle; }

progress { width: 100%; max-width: 28rem; height: .9rem; margin-top: .6rem; }
.upload-form { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.2rem; }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  main { margin: 1rem auto; padding: 0 .7rem; }
  h1 { font-size: 1.2rem; }

  nav { padding: .5rem .7rem; gap: .35rem; font-size: .95em; }
  nav .brand { width: 100%; margin-right: 0; margin-bottom: .15rem; }
  nav .user { display: none; } /* le nom complet encombre — le logout suffit */
  /* Boutons de nav plus hauts au doigt ; ils s'enroulent sur plusieurs lignes. */
  nav a:not(.brand), nav form button { padding: .5rem .85rem; }
  nav .spacer { display: none; } /* pas de poussée à droite : on laisse enrouler */
  /* Dropdown langue : drapeau seul, menu ancré à gauche pour rester à l'écran */
  nav .langdd summary { padding: .5rem .6rem; }
  nav .langdd .langdd-label { display: none; }
  nav .langdd ul { right: auto; left: 0; }

  /* Tableaux : jamais de débordement de page, scroll horizontal interne */
  .table-wrap { margin: 0 -.2rem; }
  th, td { padding: .4rem .5rem; white-space: nowrap; }
  table.kv th, table.kv td { white-space: normal; } /* fiche détail : le sha256 doit pouvoir se couper */

  /* Formulaires : tout empilé, pleine largeur, cibles tactiles confortables */
  .inline-form { flex-direction: column; align-items: stretch; gap: .4rem; }
  .inline-form label { display: block; }
  .inline-form input, .inline-form select { width: 100%; }
  input, select, textarea { max-width: none; font-size: 16px; } /* 16px : évite le zoom auto iOS */
  input[type=range] { width: 100%; }
  .btn { padding: .55rem 1rem; width: 100%; text-align: center; }
  button.link { padding: .3rem 0; }

  .cards { gap: .5rem; }
  .card { flex: 1 1 40%; padding: .55rem .8rem; }
  .card .num { font-size: 1.3rem; }

  .login-box { margin: 2rem auto; padding: 1.4rem; }
  pre { font-size: .75em; }
}

/* ═══ Graphiques perfmon (générés côté serveur) ═══ */

/* Graduation de couleur commune (l0..l4), façon calendrier de contributions */
.cal-cell, .heatmap td { --l0:#ebedf0; --l1:#c6e48b; --l2:#7bc96f; --l3:#239a3b; --l4:#196127; }
.l0 { background: var(--l0); }
.l1 { background: var(--l1); }
.l2 { background: var(--l2); }
.l3 { background: var(--l3); }
.l4 { background: var(--l4); color: #fff; }

.chart-block { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.2rem; margin: 1rem 0; }
.chart-block h2 { margin: 0 0 .8rem; font-size: 1rem; }

/* Calendrier de contributions */
.cal-scroll, .hm-scroll, .chart-scroll { overflow-x: auto; }
.cal { display: inline-block; }
.cal-months { display: flex; gap: 2px; margin-left: 0; font-size: .7em; color: var(--muted); }
.cal-months span { width: 13px; overflow: visible; white-space: nowrap; }
.cal-grid { display: flex; gap: 2px; }
.cal-week { display: flex; flex-direction: column; gap: 2px; }
.cal-cell { width: 13px; height: 13px; border-radius: 2px; }
.cal-cell.empty { background: transparent; }
.cal-legend { display: flex; align-items: center; gap: 3px; font-size: .75em; color: var(--muted); margin-top: .5rem; }
.cal-legend .cal-cell { display: inline-block; }

/* Heatmap heure × jour */
table.heatmap { border: none; width: auto; }
table.heatmap th { background: none; font-size: .7em; color: var(--muted); padding: .15rem .25rem; text-align: center; }
table.heatmap td { border: none; width: 26px; height: 22px; text-align: center; font-size: .68em; padding: 0; border-radius: 3px; }

/* Barres divergentes +/− */
svg.diverging .add { fill: #239a3b; }
svg.diverging .del { fill: #d73a49; }
svg.diverging .axis { stroke: var(--border); stroke-width: 1; }
svg.diverging .lbl { font-size: 9px; fill: var(--muted); }

/* Sparkline équipe */
svg.spark polyline { fill: none; stroke: var(--coral); stroke-width: 1.5; }

/* Barres de classement */
.rankbar { position: relative; background: #f0ece8; border-radius: 4px; height: 1.15rem; min-width: 90px; }
.rankbar-fill { background: var(--coral); opacity: .75; border-radius: 4px; height: 100%; }
.rankbar span { position: absolute; inset: 0; font-size: .75em; padding-left: .35rem; line-height: 1.15rem; }

/* Profils barres (jour de semaine, histogramme, pipelines) */
.wd-bars { display: flex; align-items: flex-end; gap: 8px; height: 85px; padding-top: 4px; }
.wd-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .7em; color: var(--muted); }
.wd-bar { width: 26px; background: var(--coral); opacity: .8; border-radius: 3px 3px 0 0; min-height: 1px; }
.wd-bar.hist { background: #2b6cb0; }
.wd-bar.ok { background: #239a3b; }
.wd-bar.mid { background: #b45309; }
.wd-bar.bad { background: #d73a49; }

/* Tableau journalier */
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: #1a7f37; }
.neg { color: #d73a49; }
tr.day-muted td { color: #c4bcb4; }
tr.day-sep td { border-top: 2px solid var(--border); }
tr.day-weekend td:first-child { color: var(--warn); }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }

.avatar { width: 22px; height: 22px; border-radius: 50%; vertical-align: -5px; margin-right: .35rem; }
.period-form { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.period-form .btn { margin-top: 0; padding: .3rem .8rem; font-size: .9em; }
.period-form .btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.period-form input[type=date] { width: auto; }
