@import url("/static/fonts.css");

/* ══ Instrument de travail, pas page d'accueil ══════════════════
   Fond papier, encre, filets d'un pixel, chiffres tabulaires.
   Aucune ombre portée, aucun arrondi mou, aucun dégradé.        */

:root {
  --paper:    #f5f4f1;
  --sheet:    #ffffff;
  --ink:      #1a1a1a;
  --ink-2:    #5c5c58;
  --ink-3:    #8a8a84;
  --rule:     #d8d6d0;
  --rule-2:   #ebe9e4;
  --accent:   #0f5560;
  --accent-2: #e3edee;

  --ok:    #1c6b45;
  --warn:  #8a5a12;
  --stop:  #9c2f24;

  --r: 2px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:  #191a19;
    --sheet:  #212220;
    --ink:    #e9e8e3;
    --ink-2:  #a7a69f;
    --ink-3:  #7c7b74;
    --rule:   #383934;
    --rule-2: #2b2c29;
    --accent: #6fb3bd;
    --accent-2: #23302f;
    --ok:   #6bbd8f;
    --warn: #d0a256;
    --stop: #dd8177;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 {
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--ink-3);
  margin: 2rem 0 .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule);
}
h2:first-of-type { margin-top: 1.4rem; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-2); }
.dimmer { color: var(--ink-3); }
.small { font-size: .82rem; }
.ok   { color: var(--ok); }
.stop { color: var(--stop); }

/* ── En-tête : filet bas uniquement, pas de bandeau coloré ── */
.top {
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.top-in {
  max-width: 1120px; margin: 0 auto; padding: 0 1rem;
  display: flex; align-items: stretch; gap: 1.5rem; min-height: 46px;
}
.mark {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 600; letter-spacing: -.01em; color: var(--ink);
}
.mark:hover { text-decoration: none; }
.mark i {
  width: 9px; height: 9px; background: var(--accent);
  display: inline-block; font-style: normal;
}
.top nav { display: flex; gap: 0; margin-left: auto; overflow-x: auto; }
.top nav a {
  display: flex; align-items: center; gap: .4rem;
  padding: 0 .7rem; color: var(--ink-2); font-size: .88rem;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.top nav a:hover { color: var(--ink); text-decoration: none; }
.top nav a.on { color: var(--ink); font-weight: 500; border-bottom-color: var(--accent); }
.top nav a var {
  font-family: var(--mono); font-style: normal; font-size: .72rem;
  background: var(--rule-2); color: var(--ink-2); padding: .05rem .3rem;
}
.top nav a.on var { background: var(--accent-2); color: var(--accent); }

main { max-width: 1120px; margin: 0 auto; padding: 1.1rem 1rem 4rem; }

.head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .2rem; }
.head .count { font-size: .82rem; color: var(--ink-3); }

/* ── Chiffres clés : rangée de mesures, pas trois cartes ── */
.figures {
  display: grid; grid-template-columns: repeat(2, 1fr);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r);
  margin-bottom: .4rem;
}
@media (min-width: 700px) { .figures { grid-template-columns: repeat(4, 1fr); } }
.fig {
  padding: .7rem .85rem; color: inherit;
  border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
}
.fig:hover { background: var(--rule-2); text-decoration: none; }
.fig b {
  display: block; font-family: var(--mono); font-size: 1.5rem;
  font-weight: 500; line-height: 1.1; letter-spacing: -.02em;
}
.fig span { font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.fig.lead b { color: var(--accent); }
.fig.win  b { color: var(--ok); }

/* ── Tableau dense ── */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 46px; z-index: 5; background: var(--sheet);
  text-align: left; font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3);
  padding: .5rem .7rem; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
tbody td { padding: .5rem .7rem; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--rule-2); }
th.r, td.r { text-align: right; }
td.nowrap { white-space: nowrap; }

.title { font-weight: 500; color: var(--ink); }
.title:hover { color: var(--accent); }
.sub { display: block; font-size: .8rem; color: var(--ink-3); margin-top: .1rem; }

/* Score : barre pleine, lisible d'un coup d'œil */
.score { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.score em {
  font-family: var(--mono); font-style: normal; font-size: .82rem; color: var(--ink-2);
}
.score i { display: block; height: 3px; width: 34px; background: var(--rule); }
.score i b { display: block; height: 100%; background: var(--accent); }

/* Pastille de statut */
.dot { display: inline-block; width: 7px; height: 7px; margin-right: .4rem; vertical-align: 1px; }
.s-non_contacte .dot { background: var(--rule); }
.s-contacte  .dot, .s-relance .dot { background: var(--warn); }
.s-reponse   .dot, .s-entretien .dot { background: var(--ok); }
.s-acceptee  .dot { background: var(--ok); }
.s-refus     .dot, .s-ignore .dot { background: var(--ink-3); }

.tag {
  display: inline-block; font-family: var(--mono); font-size: .7rem;
  padding: .05rem .35rem; border: 1px solid var(--rule); color: var(--ink-2);
  border-radius: var(--r); white-space: nowrap;
}
.tag.here { border-color: var(--accent); color: var(--accent); background: var(--accent-2); }
.lbl { display: none; }

/* ── Filtres ── */
.filters {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  margin: .8rem 0; padding-bottom: .8rem; border-bottom: 1px solid var(--rule);
}
.filters input[type=search] { flex: 1 1 15rem; min-width: 0; }
input, select, textarea, button {
  font-family: var(--sans); font-size: .88rem; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--r); padding: .38rem .5rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; font-size: .88rem; line-height: 1.5; }
button {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 500; cursor: pointer; padding: .38rem .8rem;
}
button.ghost { background: var(--sheet); color: var(--ink-2); border-color: var(--rule); }

/* Bascule Ouest : un lien-interrupteur, pas un bouton animé */
.toggle {
  font-size: .82rem; padding: .35rem .6rem; border: 1px solid var(--rule);
  border-radius: var(--r); color: var(--ink-2); background: var(--sheet);
}
.toggle:hover { text-decoration: none; color: var(--ink); }
.toggle { cursor: pointer; user-select: none; }
/* L'état vient de la case elle-même : après un échange HTMX partiel, la classe
   rendue par le serveur serait périmée. */
.toggle.on,
.toggle:has(input:checked) {
  border-color: var(--accent); color: var(--accent); background: var(--accent-2);
}

select.status { padding: .28rem .4rem; font-size: .82rem; width: 100%; max-width: 11rem; }
.pin { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: .1rem .3rem; font-size: 1rem; }
.pin.on { color: var(--accent); }

/* ── Pagination ── */
.pager {
  display: flex; align-items: center; gap: .8rem; justify-content: space-between;
  margin-top: .8rem; font-size: .84rem; color: var(--ink-3);
}
.pager a { padding: .3rem .6rem; border: 1px solid var(--rule); border-radius: var(--r); }
.pager .off { opacity: .35; pointer-events: none; }

/* ── Listes simples ── */
ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li { padding: .5rem 0; border-bottom: 1px solid var(--rule-2); }
ul.rows li:last-child { border-bottom: 0; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-3); font-size: .9rem; }

details summary { cursor: pointer; font-size: .82rem; color: var(--ink-2); }
.desc { white-space: pre-wrap; font-size: .85rem; color: var(--ink-2); margin: .4rem 0 0; }

/* ── Mobile : le tableau devient des lignes empilées ── */
@media (max-width: 719px) {
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr {
    border-bottom: 1px solid var(--rule); padding: .6rem .75rem;
    display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem;
  }
  tbody tr:last-child { border-bottom: 0; }
  tbody td { border: 0; padding: 0; }
  /* Chaque cellule a sa case : sans placement explicite, le nombre d'offres
     et la barre de score se superposaient. */
  td.c-main   { grid-column: 1; grid-row: 1; }
  td.c-score  { grid-column: 2; grid-row: 1; }
  td.c-meta   { grid-column: 1; grid-row: 2; }
  td.c-count, td.c-date {
    grid-column: 2; grid-row: 2; text-align: right; white-space: nowrap;
    font-size: .82rem; color: var(--ink-3);
  }
  .lbl { display: inline; font-family: var(--sans); }
  td.c-status { grid-column: 1 / -1; grid-row: 3; margin-top: .35rem; }
  select.status { max-width: none; }
  thead th { position: static; }
  .top-in { gap: .75rem; }
  .top nav a { padding: 0 .5rem; font-size: .84rem; }
}

/* ── Connexion ── */
body.enter { display: grid; place-items: center; min-height: 100dvh; padding: 1rem; }
.enter form {
  width: min(310px, 100%); background: var(--sheet);
  border: 1px solid var(--rule); border-radius: var(--r); padding: 1.4rem;
}
.enter h1 { margin-bottom: .1rem; }
.enter p { margin: 0 0 1rem; font-size: .84rem; color: var(--ink-3); }
.enter input { width: 100%; margin-bottom: .6rem; }
.enter button { width: 100%; }
.enter .err { color: var(--stop); font-size: .84rem; margin-bottom: .6rem; }

/* ── Notices, aperçu des mails, sélection ── */
.notice {
  background: var(--accent-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--accent); border-radius: var(--r);
  padding: .6rem .8rem; font-size: .86rem; margin: .8rem 0;
}
.notice.stop { border-left-color: var(--stop); background: transparent; }
code {
  font-family: var(--mono); font-size: .84em;
  background: var(--rule-2); padding: .05rem .3rem; border-radius: var(--r);
}
.sheet.mail { margin-bottom: .6rem; }
.sheet.mail.off { opacity: .5; }
.mail-head {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  padding: .55rem .7rem; border-bottom: 1px solid var(--rule-2);
}
.mail-body { padding: .6rem .7rem; }
.mail-body pre.desc {
  margin: .3rem 0 0; white-space: pre-wrap; font-family: var(--sans);
  font-size: .86rem; color: var(--ink-2); max-height: 22rem; overflow-y: auto;
}
.tag.stop { border-color: var(--stop); color: var(--stop); }
td.c-pick { width: 2rem; }
td.c-pick input { width: auto; }
@media (max-width: 719px) {
  td.c-pick { grid-column: 2; grid-row: 1; text-align: right; }
}

/* Champ objet de la lettre : pleine largeur, comme le corps. */
input.wide { width: 100%; }

.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
