/* Console Eolia Tech — thème clair et sombre, couleurs des sites dans l'ordre fixe c1…c8. */
:root {
  color-scheme: light;
  --bg: #f4f4f2; --surface: #fcfcfb; --surface-2: #f0efec; --border: #e2e1dc;
  --text: #0b0b0b; --text-2: #52514e; --muted: #85837d;
  --accent: #2a78d6; --accent-ink: #fff;
  --good: #0a8a0a; --bad: #d03b3b; --warn: #b77a00;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  --sidebar: #15171c; --sidebar-text: #c9cbd1; --sidebar-active: #262a33;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8d8c85;
    --accent: #3987e5; --good: #2fbf2f; --bad: #e66767; --warn: #e0a426;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    --sidebar: #0d0d0c; --sidebar-active: #22221f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8d8c85;
  --accent: #3987e5; --good: #2fbf2f; --bad: #e66767; --warn: #e0a426;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --sidebar: #0d0d0c; --sidebar-active: #22221f;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
h3 { font-size: 14px; margin: 14px 0 8px; }
h4 { font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); font-size: 12px; }
.up { color: var(--good); } .down { color: var(--bad); }
.note { color: var(--text-2); font-size: 13px; margin: 8px 0 0; }
.spacer { flex: 1; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; flex: none; }
.c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); }
.c5 { background: var(--c5); } .c6 { background: var(--c6); } .c7 { background: var(--c7); } .c8 { background: var(--c8); }

/* ---------- structure */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 18px 18px 14px; color: #fff; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: #8e919a; font-size: 12px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2a78d6, #1baf7a); color: #fff; display: grid; place-items: center; font-weight: 700; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 1px; }
.sidebar nav a { color: var(--sidebar-text); padding: 7px 10px; border-radius: 7px; display: flex; align-items: center; }
.sidebar nav a:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar .ico { width: 17px; margin-right: 8px; text-align: center; opacity: .8; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f727b; padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.sidebar-foot a { color: #8e919a; }
.theme-toggle { background: none; border: 1px solid #343842; color: #c9cbd1; border-radius: 6px; padding: 4px 8px; cursor: pointer; font: inherit; font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 0 28px 40px; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 20px 0 16px; flex-wrap: wrap; }
.topbar h1 { font-size: 21px; }
.topbar-meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 7px; padding: 4px 10px; font-size: 18px; color: var(--text); cursor: pointer; }

/* ---------- cartes et grilles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.empty { text-align: center; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 18px; }
.card .grid-2 { margin-top: 6px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpis.inner { margin: 4px 0 8px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpis.inner .kpi { background: var(--surface-2); box-shadow: none; border-color: transparent; }
.kpi span { color: var(--text-2); font-size: 12px; }
.kpi strong { font-size: 22px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: 12px; color: var(--muted); }
.kpi em.up { color: var(--good); } .kpi em.down { color: var(--bad); }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 220px; }
.map { height: 340px; border-radius: 8px; overflow: hidden; background: var(--surface-2); z-index: 0; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }

/* ---------- tableaux */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table.compact td { padding: 5px 8px; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .url { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.table.sortable th { cursor: pointer; }
.table.sortable th:hover { color: var(--text); }
.site-link { display: inline-flex; align-items: center; font-weight: 500; color: var(--text); }
.spark { display: block; width: 120px; height: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--surface-2); border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--text-2); }
.chip b { color: var(--text); font-weight: 600; }
details.ranked { margin-top: 14px; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
details.help { background: var(--surface-2); padding: 8px 12px; border-radius: 8px; margin: 10px 0; }
details.help p { margin: 6px 0 2px; color: var(--text-2); }

/* ---------- boutons et formulaires */
.btn { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 7px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .55; cursor: progress; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.social-table td { font-size: 13px; vertical-align: top; }
details.help ol { margin: 6px 0; padding-left: 20px; color: var(--text-2); }
details.help li { margin-bottom: 4px; }
.link-btn:hover { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 4px 10px; font: inherit; font-size: 12px; color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
input[type=text], input[type=url], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; width: 100%;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
label input, label textarea, label select { margin-top: 3px; }
label.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 12px; font-size: 13px; color: var(--text); }
label.check input { width: auto; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 6px; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 120px; }
.inline-form input[name=amount] { flex: 0 1 110px; }
.settings-form { display: grid; gap: 4px; max-width: 620px; }
.settings-form input[type=number] { width: 70px; display: inline-block; margin: 0 4px; }
.site-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.site-setting { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; }
.site-setting h3 { margin: 0 0 10px; display: flex; align-items: center; }
.cred-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.cred-form { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0 4px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; color: var(--text-2); cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.toolbar .inline-form { margin: 0; }
.site-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.site-url { display: inline-flex; align-items: center; font-weight: 600; color: var(--text); }

/* ---------- posts */
.net { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--text); }
.status { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border); color: var(--text-2); }
.status.s-draft { border-color: var(--warn); color: var(--warn); }
.status.s-approved { border-color: var(--accent); color: var(--accent); }
.status.s-published { border-color: var(--good); color: var(--good); }
.status.s-failed { border-color: var(--bad); color: var(--bad); }
.status.s-skipped { opacity: .6; }
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.post-list li:last-child { border-bottom: 0; }
.post-list p { margin: 2px 0 0; flex-basis: 100%; color: var(--text-2); }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.post-card { border: 1px solid var(--border); border-radius: 9px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.post-card header { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.post-card footer { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.post-card .counter { text-align: right; font-size: 11px; color: var(--muted); margin-top: -2px; }
.post-card .counter.over { color: var(--bad); font-weight: 600; }

.alert { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); color: var(--text); border-radius: 8px; padding: 9px 13px; margin-bottom: 12px; font-size: 13px; }
.alert.ok { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.alert.info { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
[hidden] { display: none !important; }
.seo-hist { max-height: 320px; overflow-y: auto; }
.seo-hist tr.current td { background: var(--surface-2, rgba(127, 127, 127, .08)); font-weight: 600; }
.seo-job { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.spinner { width: 16px; height: 16px; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; z-index: 1000; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--bad); color: #fff; }

/* ---------- connexion */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #1d2a3d, #0e1014 60%); padding: 16px; }
.login-card { background: var(--surface); padding: 28px; border-radius: 14px; width: min(360px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card .brand { margin-bottom: 22px; }
.login-card .brand small { color: var(--muted); }
.login-card input { margin: 4px 0 14px; padding: 10px 12px; font-size: 15px; }
.login-card button { width: 100%; padding: 10px; font: inherit; font-weight: 600; background: var(--accent); color: #fff; border: 0; border-radius: 8px; cursor: pointer; }
.login-card button[disabled] { opacity: .5; }
.login-error { color: var(--bad); font-size: 13px; margin: -6px 0 12px; }

/* ---------- petits écrans */
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: block; }
  .main { padding: 0 16px 32px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .topbar-meta { margin-left: 0; flex-basis: 100%; }
  .chart-box.tall { height: 260px; }
}

/* ---------------------------------------------------------------- newsletters */
.nl-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.nl-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); text-decoration: none; font-size: 13px; }
.nl-tabs a small { font-variant-numeric: tabular-nums; opacity: .75; }
.nl-tabs a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.nl-subs { max-height: 420px; overflow-y: auto; }
.nl-editor { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(360px, 1.15fr); gap: 18px; align-items: start; }
.nl-editor.readonly { grid-template-columns: 1fr; }
.nl-form label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.nl-form input[type=text], .nl-form input[type=url], .nl-form input[type=email], .nl-form select, .nl-form textarea { display: block; width: 100%; margin-top: 4px; }
.nl-form textarea { resize: vertical; font: inherit; line-height: 1.5; }
.nl-form .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nl-form h3 { margin: 18px 0 8px; }
.nl-form .inline-form { margin-bottom: 8px; flex-wrap: wrap; }
.nl-section { margin: 0 0 12px; padding: 10px 12px 2px; border: 1px solid var(--border); border-radius: 8px; }
.nl-section legend { padding: 0 6px; font-size: 13px; font-weight: 600; }
.nl-section legend .link-btn { margin-left: 4px; }
.nl-preview { position: sticky; top: 12px; }
.nl-preview iframe { display: block; width: 100%; height: 78vh; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; background: #f1f1ef; transition: width .2s; }
.status.nl-brouillon { background: var(--surface-2); color: var(--text-2); }
.status.nl-planifiee { background: color-mix(in srgb, var(--c1) 18%, transparent); color: var(--text); }
.status.nl-en_cours { background: color-mix(in srgb, var(--c3) 22%, transparent); color: var(--text); }
.status.nl-envoyee { background: color-mix(in srgb, var(--c2) 20%, transparent); color: var(--text); }
.status.nl-envoyee_partielle { background: color-mix(in srgb, var(--c4) 22%, transparent); color: var(--text); }
@media (max-width: 1100px) { .nl-editor { grid-template-columns: 1fr; } .nl-preview { position: static; } }
.nl-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--c3); box-shadow: 0 0 0 0 color-mix(in srgb, var(--c3) 60%, transparent); animation: nl-pulse 2s infinite; }
@keyframes nl-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c3) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.nl-progress { margin: 4px 0 14px; }
.nl-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.nl-bar span { display: block; height: 100%; border-radius: 999px; background: var(--c1); transition: width .8s ease; }
.nl-flash { animation: nl-flash 1.2s ease; }
@keyframes nl-flash { 0% { color: var(--c3); } 100% { color: inherit; } }
@media (prefers-reduced-motion: reduce) { .dot-live, .nl-flash { animation: none; } .nl-bar span { transition: none; } }
