:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --ink: #1b2226;
  --ink-2: #434d53;
  --muted: #6a747a;
  --line: #e2ded4;
  --brand: #0b5d4b;
  --brand-deep: #08463a;
  --brand-ink: #ffffff;
  --brand-soft: #e2efeb;
  --accent: #b3262d;
  --accent-soft: #f8e6e6;
  --gold: #946a12;
  --gold-soft: #f6eedb;
  --ok: #1d7443;
  --ok-soft: #e3f3e9;
  --warn: #8f5b00;
  --warn-soft: #fbf0d9;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .06);
  --radius: 12px;
  --font: system-ui, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Hiragino Sans GB", Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513; --surface: #191e1c; --surface-2: #212725; --ink: #e7ecea; --ink-2: #c3cbc7; --muted: #8e9894;
    --line: #2d3431; --brand: #3fa78b; --brand-deep: #0d2f27; --brand-ink: #08130f; --brand-soft: #16302a;
    --accent: #e4767a; --accent-soft: #3a2022; --gold: #d8ab4c; --gold-soft: #332a18;
    --ok: #5cc48a; --ok-soft: #173023; --warn: #e0b04f; --warn-soft: #33290f; --bad: #f08a80; --bad-soft: #3a1d1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.55; overflow-x: hidden;
}
a { color: var(--brand); }
:lang(zh) body, body:lang(zh) { line-height: 1.7; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- En-tête ------------------------------------------------------------- */
.masthead { background: var(--brand-deep); color: #fff; padding: 18px 0 72px; position: relative; }
.masthead::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0); background-size: 22px 22px;
}
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  flex: none; width: 52px; height: 52px; border-radius: 12px; background: #fff; color: var(--accent);
  display: grid; place-items: center; font-weight: 800; line-height: 1; box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.brand-mark span:first-child { font-size: 22px; }
.brand-mark span:last-child { font-size: 11px; letter-spacing: .12em; color: #0b5d4b; margin-top: 2px; }
.brand h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.subtitle { margin: 3px 0 0; font-size: 13.5px; opacity: .85; }
.lang-switch { display: flex; background: rgba(255,255,255,.12); border-radius: 999px; padding: 3px; flex: none; }
.lang-switch button {
  border: 0; background: transparent; color: #fff; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.lang-switch button[aria-pressed="true"] { background: #fff; color: var(--brand-deep); }

/* --- Barre de recherche principale --------------------------------------- */
.search-card {
  position: relative; z-index: 2; margin-top: -54px; background: var(--surface); border-radius: 16px;
  box-shadow: 0 8px 30px rgba(10, 40, 30, .14); padding: 20px; border: 1px solid var(--line);
}
.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; font-size: 18px; font-weight: 600; }
.sentence select {
  font-size: 16px; font-weight: 600; padding: 9px 36px 9px 12px; border-radius: 10px; border: 1.5px solid var(--brand);
  background: var(--brand-soft); color: var(--ink); max-width: 100%; min-width: 0; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--brand) 50%), linear-gradient(135deg, var(--brand) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat;
}
#est { flex: 1 1 320px; }
.search-row { display: flex; gap: 10px; margin-top: 14px; }
.search-row input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 15px;
}
.search-row input:focus, .sentence select:focus, textarea:focus, input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn-primary {
  border: 0; background: var(--brand); color: var(--brand-ink); padding: 11px 22px; border-radius: 10px; font-weight: 700; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost:disabled { opacity: .55; cursor: progress; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); padding: 4px 11px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; color: var(--ink-2); }
.toggle input { accent-color: var(--brand); width: 16px; height: 16px; }

/* --- Onglets --------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 11px 14px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px; font-size: 14.5px;
}
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { font-size: 12px; background: var(--surface-2); color: var(--ink-2); padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
main { padding-top: 20px; padding-bottom: 48px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 19px; }
.intro { color: var(--ink-2); margin: 0 0 16px; max-width: 820px; }
.notice { background: var(--gold-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.notice.error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice.success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 12px; font-weight: 700; }

/* --- Cartes d'opportunités ------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.card.match { border-left: 4px solid var(--brand); }
.card h3 { margin: 0; font-size: 16.5px; line-height: 1.35; }
.card-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.type { background: var(--brand-soft); color: var(--brand); }
.badge.scale { background: var(--gold-soft); color: var(--gold); }
.badge.cn { background: var(--accent-soft); color: var(--accent); }
.badge.st-ouvert { background: var(--ok-soft); color: var(--ok); }
.badge.st-récurrent { background: var(--brand-soft); color: var(--brand); }
.badge.st-à-confirmer { background: var(--warn-soft); color: var(--warn); }
.badge.st-clos, .badge.st-expired { background: var(--surface-2); color: var(--muted); }
.deadline { margin-left: auto; font-size: 12.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.deadline.later { color: var(--ink-2); }
.zh-line { margin: -4px 0 0; color: var(--muted); font-size: 13.5px; }
.provider { margin: 0; font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.summary { margin: 0; color: var(--ink-2); font-size: 14px; }
.facts { margin: 2px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.pchips { display: flex; flex-wrap: wrap; gap: 4px; }
.pchip { font-size: 11.5px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.pchip.hit { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line); }
.src-link { font-weight: 700; font-size: 13.5px; text-decoration: none; }
.src-link:hover { text-decoration: underline; }
.linkstat { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.linkstat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.linkstat.ok::before { background: var(--ok); }
.linkstat.bad { color: var(--bad); }
.linkstat.bad::before { background: var(--bad); }
.linkstat.warn { color: var(--warn); }
.linkstat.warn::before { background: var(--warn); }
.match-why { font-size: 12px; color: var(--brand); font-weight: 700; }
.more-btn { display: block; margin: 18px auto 0; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* --- Veille ---------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input[type="search"] {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; min-width: 0; max-width: 100%;
}
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: start; }
.item:first-child { border-top: 0; }
.item.st-ignore { opacity: .55; }
.item-date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.item-title { font-weight: 650; text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.item-title:hover { color: var(--brand); text-decoration: underline; }
.item-orig { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.item-actions .btn-ghost { padding: 4px 9px; font-size: 12.5px; }
.item-actions .btn-ghost[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
details.sources-state { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
details.sources-state summary { cursor: pointer; font-weight: 650; }
.state-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.state-table td, .state-table th { padding: 6px 8px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.state-table th { color: var(--muted); font-weight: 600; border-top: 0; }
.table-scroll { overflow-x: auto; }

/* --- Annuaire -------------------------------------------------------------- */
.dir-group { margin-bottom: 26px; }
.dir-group h3 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.dir-group h3 .n { font-size: 12px; color: var(--muted); font-weight: 600; }
.src-card h4 { margin: 0; font-size: 15px; line-height: 1.35; }
.src-card .zh { color: var(--accent); font-size: 14px; margin: 0; font-weight: 600; }
.url { font-size: 13px; overflow-wrap: anywhere; }

/* --- Traduction ------------------------------------------------------------ */
.tr-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.tr-form label { font-weight: 600; font-size: 13.5px; }
.tr-form textarea, .tr-form input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); font-size: 14.5px;
}
.tr-form textarea { min-height: 150px; resize: vertical; }
.tr-result { margin-top: 18px; display: grid; gap: 14px; }
.tr-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.tr-col h3 { margin: 0 0 4px; font-size: 16px; }
.tr-col .lang-tag { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; color: var(--brand); }
.tr-col ul { margin: 4px 0 0; padding-left: 18px; }
.fulltext { white-space: pre-wrap; font-size: 14px; color: var(--ink-2); max-height: 420px; overflow: auto; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
details.fold summary { cursor: pointer; font-weight: 650; padding: 6px 0; }

/* --- Coopération existante -------------------------------------------------- */
.timeline { position: relative; display: grid; gap: 14px; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; }
.tl-item::before { content: ""; position: absolute; left: -21px; top: 20px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.tl-date { font-size: 12.5px; font-weight: 800; color: var(--accent); letter-spacing: .02em; }

/* --- À propos --------------------------------------------------------------- */
.about { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.about .card p { margin: 0 0 10px; color: var(--ink-2); }
.est-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.est-list li { padding: 8px 0; border-top: 1px solid var(--line); }
.est-list li:first-child { border-top: 0; }
.est-list .acr { font-size: 12px; font-weight: 800; color: var(--brand); margin-left: 4px; }
.est-list .zh { display: block; font-size: 13px; color: var(--muted); }
.review { border-left: 4px solid var(--accent); }

/* --- Utilitaires (remplacent les styles en ligne, interdits par la CSP) ------------ */
.flush { margin: 0; }
.flush-top { margin: 6px 0 0; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 16px; }
.card-title { margin: 0 0 10px; font-size: 19px; }
.card-title.small-title { margin-bottom: 6px; font-size: 17px; }

/* --- Pages de présentation (lisibles par les moteurs de recherche) --------------------- */
.lang-links { display: flex; gap: 4px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 3px; flex: none; }
.lang-links a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.lang-links a[aria-current="page"] { background: #fff; color: var(--brand-deep); }
.seo-page { position: relative; z-index: 2; margin-top: -48px; display: grid; gap: 14px; padding-bottom: 40px; }
.seo-page h2 { margin: 0 0 8px; font-size: 18px; }
.seo-page h3 { margin: 14px 0 6px; font-size: 15px; color: var(--brand); }
.seo-page p, .seo-page li { color: var(--ink-2); }
.btn-link { display: inline-block; text-decoration: none; }
a.acct-btn { text-decoration: none; }

/* --- Compte (en-tête) --------------------------------------------------------------- */
.masthead-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.account { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.account .who { opacity: .9; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn { border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; }
.acct-btn:hover { background: rgba(255,255,255,.12); }

/* --- Espace réservé ------------------------------------------------------------------ */
.auth-card { max-width: 520px; }
.auth-card h2 { margin: 0 0 6px; font-size: 19px; }
.stack { display: grid; gap: 10px; }
.stack label, .form-grid label { display: grid; gap: 4px; font-weight: 600; font-size: 13.5px; }
.stack input, .stack textarea, .stack select, .form-grid input, .form-grid select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface); font-size: 14.5px; font-weight: 400;
}
.stack textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px 14px; }
.form-end { display: flex; align-items: flex-end; }
.ws-nav { margin-bottom: 16px; }
.ws-contact { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.contact-line { margin: 12px 0 0; font-weight: 600; }
footer a { color: inherit; }
.card.proposal { cursor: pointer; }
.card.proposal:hover, .card.proposal:focus { border-color: var(--brand); outline: none; }
.ws-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; margin-top: 14px; }
.ws-columns h3 { margin: 0 0 8px; font-size: 16px; }
.comments { display: grid; gap: 10px; margin-bottom: 10px; }
.comment { border-left: 3px solid var(--brand-soft); padding-left: 10px; }
.comment-body { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.link-row { display: flex; gap: 8px; margin-top: 6px; }
.link-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; background: var(--surface); }
.users-table select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.warn-row td { color: var(--bad); }
.form-actions { gap: 8px; flex-wrap: wrap; }
.cms-grid .wide { grid-column: 1 / -1; }
.cms-grid textarea, .cms-grid input, .cms-grid select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface); font-size: 14.5px; font-weight: 400; }
.cms-grid .toggle { align-self: end; padding-bottom: 8px; font-weight: 600; }
.cms-grid .toggle input, fieldset.checks input { width: 16px; }
fieldset.checks { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; }
fieldset.checks legend { font-weight: 600; font-size: 13.5px; padding: 0 4px; }
.badge.pst-brouillon { background: var(--surface-2); color: var(--ink-2); }
.badge.pst-en_discussion { background: var(--warn-soft); color: var(--warn); }
.badge.pst-soumis { background: var(--brand-soft); color: var(--brand); }
.badge.pst-valide { background: var(--ok-soft); color: var(--ok); }
.badge.pst-abandonne { background: var(--bad-soft); color: var(--bad); }

footer { border-top: 1px solid var(--line); padding: 18px 0 28px; color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; }

/* --- Petits écrans ------------------------------------------------------------ */
@media (max-width: 720px) {
  .masthead { padding-bottom: 64px; }
  .masthead-inner { flex-wrap: wrap; }
  .brand h1 { font-size: 18px; }
  .subtitle { font-size: 12.5px; }
  .search-card { padding: 14px; }
  .sentence { font-size: 15px; }
  .sentence label { display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; }
  .sentence select { width: 100%; }
  .search-row { flex-direction: column; }
  .item { grid-template-columns: 1fr; gap: 6px; }
  .item-actions { justify-content: flex-start; }
  .about { grid-template-columns: 1fr; }
}

@media print {
  .masthead, .tabs, .search-card, .toolbar, .item-actions, footer { display: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
