/* Leestee · Suivi du scraping
   Toutes les couleurs sont des variables : à adapter à la charte si besoin. */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --ink: #12151C;
  --ink-2: #3B4250;
  --muted: #5B6372;
  --line: #E3E6EB;
  --line-2: #EEF0F3;
  --accent: #2340D8;
  --accent-hover: #1A2FA3;
  --accent-soft: #E5ECFF;
  --danger: #B42318;

  --ok-bg: #E3F4EA;    --ok-fg: #0F5A35;    --ok-dot: #1E9E5A;
  --late-bg: #FFF0D9;  --late-fg: #7A4100;  --late-dot: #E07B00;
  --fail-bg: #FDE7E5;  --fail-fg: #9A1C12;  --fail-dot: #D92D20;
  --pause-bg: #ECEEF2; --pause-fg: #454C5A; --pause-dot: #8A92A1;
  --run-bg: #E5ECFF;   --run-fg: #1A33B0;   --run-dot: #2340D8;
  --drop-bg: #F1E9FF;  --drop-fg: #5B2BB0;  --drop-dot: #7A45D6;

  --radius: 12px;
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Barre du haut */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text small { font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 8px; color: #4A5160; font-weight: 500; text-decoration: none; }
.tab:hover { background: #F0F2F5; color: var(--ink); }
.tab[aria-current="page"] { background: var(--ink); color: #fff; }
.topbar-right { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; }

/* Mise en page */
.layout { display: flex; flex-wrap: wrap; align-items: flex-start; }
.sidebar { flex: 1 1 280px; padding: 20px 14px 32px 20px; display: flex; flex-direction: column; gap: 14px; }
.main { flex: 999 1 560px; min-width: 0; padding: 24px 24px 48px; display: flex; flex-direction: column; gap: 24px; outline: none; }
.page { display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.row-between { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }

/* Champs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.input, .field input, select { height: 42px; padding: 0 12px; border: 1px solid #D9DDE3; border-radius: 8px; background: var(--surface); }

/* Puces et statuts */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip-demo { background: #FFF7E0; color: #6B4A00; }
.dot { width: 8px; height: 8px; border-radius: 999px; flex: none; display: inline-block; }
.st-ok { background: var(--ok-bg); color: var(--ok-fg); }           .st-ok .dot, .d-ok { background: var(--ok-dot); }
.st-not_scraped { background: var(--late-bg); color: var(--late-fg); } .st-not_scraped .dot, .d-not_scraped { background: var(--late-dot); }
.st-failed { background: var(--fail-bg); color: var(--fail-fg); }   .st-failed .dot, .d-failed { background: var(--fail-dot); }
.st-paused { background: var(--pause-bg); color: var(--pause-fg); } .st-paused .dot, .d-paused { background: var(--pause-dot); }
.st-running { background: var(--run-bg); color: var(--run-fg); }    .st-running .dot, .d-running { background: var(--run-dot); }
.st-volume_drop { background: var(--drop-bg); color: var(--drop-fg); } .st-volume_drop .dot, .d-volume_drop { background: var(--drop-dot); }
.d-neutral { background: var(--run-dot); }
.d-muted { background: var(--pause-dot); }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #D9DDE3; background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.filter:hover { border-color: #9AA2AF; }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Liste des pays */
.country-list { display: flex; flex-direction: column; gap: 14px; }
.region { display: flex; flex-direction: column; gap: 2px; }
.region-title { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 0 10px 4px; }
.crow { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 10px; border-radius: 8px; color: inherit; text-decoration: none; }
.crow:hover { background: #EEF0F4; color: inherit; }
.crow[aria-current="page"] { background: var(--accent-soft); }
.crow-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crow-name strong { font-weight: 500; }
.crow-name small { font-size: 12px; color: var(--muted); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ccard { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; text-align: left; }
.ccard:hover { border-color: #9AA2AF; box-shadow: 0 2px 10px rgba(18,21,28,.06); color: inherit; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; }
.kpi { gap: 6px; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #4A5160; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 500; letter-spacing: -.02em; }
.kpi-hint { font-size: 12.5px; color: var(--muted); }
.grid-countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 12px; }
.grid-sites { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.cc-name { display: flex; flex-direction: column; }
.cc-name strong { font-size: 15px; }
.cc-name small { font-size: 12px; color: var(--muted); }
.cc-sites { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.cc-site { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cc-site .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-site .ago { color: var(--muted); font-size: 12px; }

/* Sections avec en-tête */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.list-row .what { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; }
.list-row .what strong span { font-weight: 400; color: var(--muted); }
.list-row .what small { font-size: 13px; color: #4A5160; }
.empty-ok { padding: 24px 18px; color: var(--ok-fg); font-weight: 500; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid #D9DDE3; background: var(--surface); font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #9AA2AF; background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #EEF0F4; border-color: transparent; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px; }
.lnk { border: 0; background: transparent; padding: 0; color: var(--accent); font-weight: 500; min-height: 32px; text-decoration: none; }
.lnk:hover { color: var(--accent-hover); text-decoration: underline; }

/* Carte d'un site */
.site { display: flex; flex-direction: column; gap: 16px; padding: 18px; }
.site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.site-id { display: flex; gap: 12px; min-width: 0; }
.rank { flex: none; width: 30px; height: 30px; border-radius: 8px; background: #F0F2F5; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink-2); }
.site-name { display: flex; flex-direction: column; min-width: 0; }
.site-name strong { font-size: 16px; }
.site-name a { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problem { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.bar { width: 100%; height: 6px; border-radius: 999px; background: #ECEEF2; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 32px; }
.spark span { flex: 1; border-radius: 2px; background: #C3CDF5; min-height: 2px; }
.spark span.today { background: var(--accent); }
.spark span.zero { background: #F0B4AE; }
.footnote { font-size: 12.5px; color: var(--muted); }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--ink); font-weight: 500; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

/* Règles */
.rules { max-width: 860px; }
.rule { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 18px; }
.rule + .rule { border-top: 1px solid var(--line-2); }
.rule-text { flex: 1 1 260px; display: flex; flex-direction: column; }
.rule-text strong { font-weight: 600; }
.rule-text small { font-size: 13px; color: #4A5160; }
.toggle { position: relative; width: 46px; height: 28px; border-radius: 999px; border: 0; background: #C9CED6; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px; background: #fff; transition: left .15s; }
.toggle[aria-pressed="true"] { background: var(--accent); }
.toggle[aria-pressed="true"]::after { left: 21px; }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* Journal (panneau latéral) */
.scrim { position: fixed; inset: 0; background: rgba(18,21,28,.32); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 21; overflow-y: auto; box-shadow: -8px 0 30px rgba(18,21,28,.12); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.drawer-head .who { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.drawer-head .who strong { font-size: 20px; }
.drawer-body { display: flex; flex-direction: column; gap: 18px; padding: 18px 20px 28px; }
.error-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); }
.error-box code { font-family: var(--mono); font-size: 12px; color: #4A5160; white-space: pre-wrap; }
.icon-btn { width: 44px; padding: 0; }

/* Notification */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(18,21,28,.25); }
.toast.error { background: var(--danger); }

@media (max-width: 860px) {
  /* Sur téléphone, le contenu passe avant la liste des pays */
  .main { order: -1; }
}
@media (max-width: 640px) {
  .topbar, .main { padding-left: 16px; padding-right: 16px; }
  .sidebar { padding-left: 16px; padding-right: 16px; }
}
