/* ---------- Fonts (self-hosted, SIL OFL) ---------- */
@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/poppins-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/poppins-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/poppins-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --alto: #ffa118;
  --alto-dark: #e08c00;
  --link: #a86800;
  --on-accent: #0e0e0e;
  --dark: #0e0e0e;
  --ink: #1c1c1c;
  --ink-soft: #4a4a4a;
  --muted: #8a8a8a;
  --line: #e7e7e7;
  --paper: #f6f6f6;
  --white: #fff;
  --ok: #2f7d4f;
  --alert: #b3301f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.05);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
h1,
h2,
h3 {
  font-family: "Space Grotesk", "Poppins", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}
h1 {
  font-size: 1.55rem;
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
.muted {
  color: var(--muted);
}
.ok {
  color: var(--ok);
}
.error {
  color: var(--alert);
}

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.65rem clamp(1rem, 3vw, 2rem);
  background: var(--dark);
  border-bottom: 3px solid var(--alto);
}
.brand {
  display: flex;
  align-items: center;
}
.brand img {
  height: 38px;
  width: auto;
  display: block;
}
nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
}
nav a {
  color: #ededed;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}
nav a:hover {
  color: var(--alto);
  text-decoration: none;
}
nav a.active {
  color: var(--alto);
  border-bottom-color: var(--alto);
}
nav form {
  margin: 0;
}
button.link {
  background: none;
  border: 0;
  padding: 0.3rem 0;
  font: inherit;
  color: #bdbdbd;
  cursor: pointer;
}
button.link:hover {
  color: var(--alto);
}

/* ---------- Layout ---------- */
main {
  width: min(100% - 2rem, 72rem);
  margin: 0 auto;
  padding: 2rem 0 3rem;
}
/* ---------- Table ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  padding: 0.7rem 1rem;
  background: #fafafa;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fffaf0;
}
td a {
  color: var(--ink);
}
td a:hover {
  color: var(--link);
}
.date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Badges / tags ---------- */
.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  background: #f0f0f0;
  color: var(--muted);
}
.badge.ok {
  background: #e9f4ed;
  color: var(--ok);
}
.badge.failed {
  background: #fdf1e3;
  color: #8a5a12;
}
.badge.blocked {
  background: #fbe9e6;
  color: var(--alert);
}
.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.68rem;
  color: var(--muted);
}

/* ---------- Cards (Paramètres) ---------- */
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}
.cards a {
  display: block;
  padding: 1.1rem 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}
.cards a:hover {
  border-color: var(--alto);
  transform: translateY(-1px);
  text-decoration: none;
}
.cards strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.02rem;
  margin-bottom: 0.15rem;
}
.cards span {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Forms ---------- */
form.stack {
  display: grid;
  gap: 0.8rem;
  max-width: 34rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
form.stack label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}
form.stack input,
form.stack select,
form.stack textarea {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
form.stack input:focus,
form.stack select:focus,
form.stack textarea:focus {
  outline: 2px solid rgba(255, 161, 24, 0.35);
  border-color: var(--alto);
}
form.stack button {
  justify-self: start;
  margin-top: 0.2rem;
  padding: 0.6rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--alto);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
form.stack button:hover {
  background: var(--alto-dark);
}

/* ---------- Login ---------- */
body.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(255, 161, 24, 0.18), transparent 65%),
    var(--dark);
}
body.login main {
  width: min(100%, 380px);
  margin: 0;
  padding: 0;
}
.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.login-brand img {
  width: 168px;
  height: auto;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.6rem 1.5rem 1.75rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  border-top: 4px solid var(--alto);
}
.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 0.15rem;
}
.login-card .muted {
  margin: 0 0 1.3rem;
  font-size: 0.88rem;
}
body.login form {
  display: grid;
  gap: 0.55rem;
}
body.login label {
  font-size: 0.8rem;
  color: var(--muted);
}
body.login input {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
body.login input:focus {
  outline: 2px solid rgba(255, 161, 24, 0.35);
  border-color: var(--alto);
}
body.login button {
  margin-top: 0.5rem;
  padding: 0.65rem;
  border: 0;
  border-radius: 8px;
  background: var(--alto);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
body.login button:hover {
  background: var(--alto-dark);
}
.login-card .error {
  color: var(--alert);
  font-size: 0.88rem;
  margin: 0.25rem 0 0;
}

/* ---------- Responsive ---------- */
.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nav-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0 10px;
  cursor: pointer;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
}

.nav-burger span {
  display: block;
  height: 2px;
  background: #ededed;
  border-radius: 1px;
}

.row-meta-mobile {
  display: none;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

@media (max-width: 720px) {
  .top {
    position: sticky;
    flex-wrap: nowrap;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
  }
  .brand img {
    height: 32px;
  }
  .nav-burger {
    display: flex;
  }
  .top nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.35rem 1rem 0.9rem;
    background: var(--dark);
    border-bottom: 3px solid var(--alto);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  }
  .nav-toggle:checked ~ nav {
    display: flex;
  }
  .top nav a,
  .top nav form,
  .top nav button {
    width: 100%;
    padding: 0.6rem 0;
    text-align: left;
    font-size: 0.95rem;
  }
  .notice-nav {
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
  }
  .notice-nav-pager {
    flex-wrap: wrap;
  }
  .tenders .col-date,
  .tenders .col-buyer,
  .tenders .num,
  .sources th:nth-child(3),
  .sources td:nth-child(3),
  .buyers .col-open {
    display: none;
  }
  .row-meta-mobile {
    display: block;
  }
  main {
    padding-top: 1.25rem;
  }
}

/* ---------- Sources (compact) ---------- */
.sources th,
.sources td {
  padding: 0.5rem 0.8rem;
}
.sources td {
  font-size: 0.88rem;
}
.sources .src-name {
  font-weight: 500;
}
.sources .dot-col {
  width: 26px;
  padding-right: 0;
}
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c9c9c9;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.03);
}
.dot.ok {
  background: #27a35b;
}
.dot.failed {
  background: #f0a020;
}
.dot.blocked {
  background: #d93a2b;
}
.dot.never {
  background: #c9c9c9;
}
.sources tr.is-disabled {
  opacity: 0.55;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Relevance ---------- */
.reason {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}
.score {
  display: inline-block;
  min-width: 1.6rem;
  text-align: center;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: #f0f0f0;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

/* ---------- Tender detail & state ---------- */
.tenders tr.seen {
  opacity: 0.55;
}
.tenders tr.seen:hover {
  opacity: 1;
}
.notice-meta {
  color: var(--muted);
  margin: 0 0 1rem;
}
.notice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 1.4rem 0;
}
.verdict {
  display: flex;
  gap: 0.4rem;
}
.verdict button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.verdict button:hover {
  border-color: var(--alto);
}
.verdict button.active {
  border-color: var(--alto);
  background: #fff7e8;
  font-weight: 600;
}
.verdict button[value="non_pertinent"].active {
  border-color: #d93a2b;
  background: #fbe9e6;
  color: #8b2a1e;
}
.verdict button.ghost {
  border-style: dashed;
  color: var(--muted);
}
.button {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: var(--alto);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}
.button:hover {
  background: var(--alto-dark);
  text-decoration: none;
}
.lots td,
.lots th {
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
}

/* ---------- Views, pagination, families ---------- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.pagination a {
  color: var(--link);
}
.family,
.combo {
  display: inline-block;
  margin-right: 0.3rem;
  margin-top: 0.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
}
.family {
  background: #f2f2f2;
  color: var(--ink-soft);
}
.combo {
  background: #fff1d6;
  color: #8a5a12;
  border: 1px solid #ecd3a6;
  font-weight: 600;
}
.families {
  margin: 0.2rem 0 1rem;
}

/* ---------- Lot highlighting ---------- */
.lots tr.relevant {
  background: #fff8e8;
}
.lots tr.relevant td:first-child {
  border-left: 3px solid var(--alto);
}
.lots tr.relevant .lot-title {
  font-weight: 600;
}
.lot-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #fff1d6;
  border: 1px solid #ecd3a6;
  color: #8a5a12;
  font-size: 0.68rem;
  font-weight: 600;
}

/* ---------- Read state & favourites ---------- */
.star {
  color: var(--alto);
  font-size: 1rem;
  margin-right: 0.15rem;
}
.state {
  display: flex;
  gap: 0.4rem;
  margin: 0.4rem 0 1rem;
}
.state button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.state button:hover {
  border-color: var(--alto);
}
.state button.active {
  border-color: var(--alto);
  background: #fff7e8;
  font-weight: 600;
}

.fav-col {
  width: 30px;
  text-align: center;
  padding-left: 0.6rem;
  padding-right: 0.2rem;
}

/* ---------- View picker ---------- */
.list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.list-head h1 {
  margin-bottom: 0.15rem;
}
.view-picker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.view-picker select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.review-link {
  margin: -0.4rem 0 1rem;
  font-size: 0.82rem;
}
@media (max-width: 720px) {
  .list-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .view-picker {
    width: 100%;
  }
  .view-picker select {
    flex: 1;
  }
}

.state-label {
  margin: 1rem 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.notice-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.notice-nav a.muted {
  text-decoration: none;
}

.notice-nav-pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-weight: 500;
}

.button.ghost:hover {
  background: #fff7e8;
  border-color: var(--alto);
}

.ai-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #eef1f5;
  color: #5a6675;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

.triage-note {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid #9aa7b6;
  background: #f7f9fb;
  border-radius: 0 8px 8px 0;
}

.triage-note p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.triage-note button {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.triage-note button:hover {
  border-color: var(--alto);
}

.verdict-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Statistiques ---------- */
.stats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.stats-head h1 {
  margin-bottom: 0.2rem;
}
.headline {
  margin: 0 0 1.2rem;
  padding: 0.9rem 1.1rem;
  border-left: 4px solid var(--alto);
  background: #fff7e8;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
}
.headline strong {
  font-size: 1.45rem;
  color: var(--alto-dark);
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.kpi.accent {
  border-color: var(--alto);
  background: #fff7e8;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.card {
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-width: 0;
}
.card.wide {
  grid-column: 1 / -1;
}
.card h2 {
  margin: 0 0 0.9rem;
  font-size: 0.98rem;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.legend-split {
  flex-direction: column;
  gap: 0.3rem;
}
.legend-split li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.legend-split strong {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
}
.chart-note {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
}
.mini {
  width: 100%;
  margin-top: 0.8rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.mini th,
.mini td {
  padding: 0.25rem 0.3rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.mini .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 760px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* HTML bar lists — used instead of SVG when labels can be long. */
.bar-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.bar-list li {
  display: grid;
  grid-template-columns: minmax(0, 210px) minmax(0, 1fr) 3ch;
  align-items: center;
  gap: 0.55rem;
  padding: 0.16rem 0;
}
.bar-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.8rem;
  color: var(--ink);
}
.bar-track {
  position: relative;
  height: 14px;
  background: #f7f7f7;
  border-radius: 3px;
  overflow: hidden;
}
.bar-total,
.bar-sub {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 3px;
}
.bar-total {
  background: #ededed;
}
.bar-sub {
  background: var(--alto);
}
.bar-value {
  text-align: right;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.buyers {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.buyers th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
.buyers td {
  padding: 0.32rem 0.4rem;
  border-bottom: 1px solid #f2f2f2;
  vertical-align: top;
}
.buyers .rank {
  width: 2.2rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.buyers .buyer {
  line-height: 1.35;
}
.buyers .num {
  width: 6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.buyers .num.accent {
  color: var(--alto-dark);
  font-weight: 600;
}

.chart-sub {
  margin: 1.1rem 0 0.2rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}


.buyers a {
  color: var(--link);
  text-decoration: none;
}
.buyers a:hover {
  text-decoration: underline;
}

/* Mobile: stack the selector pairs (Période, Métier) instead of one long row. */
@media (max-width: 720px) {
  .view-picker {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.4rem 0.6rem;
    width: 100%;
  }
  .view-picker select {
    width: 100%;
    min-width: 0;
  }
}
