/* Système de design « Newsflow » — transposé de la maquette ihm/newsflow-studio.html.
   Direction : outil éditorial calme et précis, palette chaude neutre, accent
   vert encre, typographie Satoshi. Une seule source de tokens pour tout
   l'admin et les écrans sur-mesure (composer, éditeur de template, exports).

   L'admin Django (5.x) expose son thème via des variables CSS
   (django/contrib/admin/static/admin/css/base.css) : on les branche sur nos
   tokens plutôt que de réécrire ses sélecteurs un par un. Le mode sombre
   suit la bascule native de l'admin (html[data-theme] = auto/light/dark). */

:root,
html[data-theme="light"] {
  --bg: #f3f2ee;
  --surface: #f9f8f5;
  --surface-2: #fffefa;
  --offset: #eceae4;
  --dynamic: #e4e2dc;
  --divider: #dedbd4;
  --border: #d4d0c8;
  --text: #20221e;
  --muted: #666961;
  --faint: #8b8e86;
  --inverse: #fbfcf8;
  --primary: #087b68;
  --primary-hover: #056654;
  --primary-active: #044b3e;
  --primary-soft: #dcece7;
  --danger: #a33b4d;
  --danger-soft: #f4dde1;
  --warning: #a85b18;
  --warning-soft: #f6e6d4;
  --success: #2b7549;
  --success-soft: #dcefe2;
  --shadow-sm: 0 1px 2px rgb(35 39 30 / 0.06);
  --shadow-md: 0 8px 24px rgb(35 39 30 / 0.1);
  --shadow-lg: 0 24px 64px rgb(35 39 30 / 0.16);
  --dot: #d4d0c8;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #161815;
  --surface: #1b1e1a;
  --surface-2: #21241f;
  --offset: #272a25;
  --dynamic: #30342e;
  --divider: #2b2e29;
  --border: #3b3f38;
  --text: #e4e6df;
  --muted: #aeb2a9;
  --faint: #858a80;
  --inverse: #12211c;
  --primary: #79c5b1;
  --primary-hover: #91d4c1;
  --primary-active: #a8dfcf;
  --primary-soft: #263c35;
  --danger: #ed8fa1;
  --danger-soft: #482b33;
  --warning: #e6a265;
  --warning-soft: #45331f;
  --success: #83ca9e;
  --success-soft: #223a2b;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
  --shadow-md: 0 8px 24px rgb(0 0 0 / 0.32);
  --shadow-lg: 0 24px 64px rgb(0 0 0 / 0.45);
  --dot: #30342e;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]),
  html[data-theme="auto"] {
    --bg: #161815;
    --surface: #1b1e1a;
    --surface-2: #21241f;
    --offset: #272a25;
    --dynamic: #30342e;
    --divider: #2b2e29;
    --border: #3b3f38;
    --text: #e4e6df;
    --muted: #aeb2a9;
    --faint: #858a80;
    --inverse: #12211c;
    --primary: #79c5b1;
    --primary-hover: #91d4c1;
    --primary-active: #a8dfcf;
    --primary-soft: #263c35;
    --danger: #ed8fa1;
    --danger-soft: #482b33;
    --warning: #e6a265;
    --warning-soft: #45331f;
    --success: #83ca9e;
    --success-soft: #223a2b;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
    --shadow-md: 0 8px 24px rgb(0 0 0 / 0.32);
    --shadow-lg: 0 24px 64px rgb(0 0 0 / 0.45);
    --dot: #30342e;
    color-scheme: dark;
  }
}

:root {
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 13px;
  --r-xl: 18px;
  --t: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --xs: clamp(0.75rem, 0.72rem + 0.1vw, 0.8125rem);
  --sm: clamp(0.875rem, 0.84rem + 0.12vw, 0.9375rem);
  --base: clamp(1rem, 0.96rem + 0.12vw, 1.0625rem);
  --lg: clamp(1.125rem, 1.05rem + 0.25vw, 1.25rem);
  --xl: clamp(1.5rem, 1.35rem + 0.5vw, 1.875rem);
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.25rem;
  --s6: 1.5rem;
  --s8: 2rem;
  --s10: 2.5rem;
  --s16: 4rem;
  --font: "Satoshi", system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sidebar-w: 232px;
  --topbar-h: 64px;
}

/* -- Branchement des variables de l'admin Django sur nos tokens ---------- */

:root,
html[data-theme] {
  --primary-fg: var(--inverse);
  --secondary: var(--primary);
  --accent: var(--primary);
  --body-fg: var(--text);
  --body-bg: var(--bg);
  --body-quiet-color: var(--muted);
  --body-medium-color: var(--muted);
  --body-loud-color: var(--text);
  --header-color: var(--muted);
  --header-branding-color: var(--text);
  --header-bg: var(--surface);
  --header-link-color: var(--text);
  --breadcrumbs-fg: var(--muted);
  --breadcrumbs-link-fg: var(--muted);
  --breadcrumbs-bg: transparent;
  --link-fg: var(--primary);
  --link-hover-color: var(--primary-hover);
  --link-selected-fg: var(--primary);
  --hairline-color: var(--divider);
  --border-color: var(--border);
  --error-fg: var(--danger);
  --message-success-bg: var(--success-soft);
  --message-warning-bg: var(--warning-soft);
  --message-error-bg: var(--danger-soft);
  --darkened-bg: var(--offset);
  --selected-bg: var(--primary-soft);
  --selected-row: var(--primary-soft);
  --button-fg: var(--inverse);
  --button-bg: var(--primary);
  --button-hover-bg: var(--primary-hover);
  --default-button-bg: var(--primary);
  --default-button-hover-bg: var(--primary-hover);
  --close-button-bg: var(--muted);
  --close-button-hover-bg: var(--text);
  --delete-button-bg: var(--danger);
  --delete-button-hover-bg: var(--danger);
  --object-tools-fg: var(--inverse);
  --object-tools-bg: var(--primary);
  --object-tools-hover-bg: var(--primary-hover);
  --font-family-primary: var(--font);
  --font-family-monospace: var(--mono);
}

/* -- Base --------------------------------------------------------------- */

/* Les composants en display: flex/grid (.btn, .field…) écraseraient sinon
   l'attribut hidden, que les scripts utilisent pour masquer/afficher. */
[hidden] {
  display: none !important;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--sm);
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

a:link,
a:visited {
  color: var(--primary);
}

a:hover,
a:focus {
  color: var(--primary-hover);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font);
  color: var(--text);
}

#content h1 {
  font-size: var(--xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 var(--s6);
}

#content h2 {
  font-size: var(--lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.help,
p.help,
div.help {
  color: var(--muted);
  font-size: var(--xs);
}

/* -- Topbar ------------------------------------------------------------- */

#header {
  height: var(--topbar-h);
  padding: 0 var(--s5) 0 0;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--divider);
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 40;
}

#branding {
  align-self: stretch;
  display: flex;
  align-items: center;
  width: var(--sidebar-w);
  padding: 0 var(--s5);
  border-right: 1px solid var(--divider);
  background: var(--surface);
  margin: 0;
}

#site-name {
  margin: 0;
  font-size: var(--base);
  font-weight: 700;
  letter-spacing: -0.02em;
}

#site-name a:link,
#site-name a:visited {
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--primary);
  flex-shrink: 0;
}

#user-tools {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--xs);
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin: 0 0 0 auto;
}

#user-tools strong {
  color: var(--text);
}

#user-tools a,
#logout-form button {
  color: var(--muted);
  border-bottom: 0;
  text-decoration: none;
  font-weight: 600;
}

#user-tools a:hover,
#logout-form button:hover {
  color: var(--text);
  text-decoration: none;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  margin-left: var(--s2);
  vertical-align: middle;
}

.theme-toggle:hover {
  background: var(--offset);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: var(--muted);
}

/* -- Fil d'Ariane --------------------------------------------------------- */

div.breadcrumbs {
  background: transparent;
  color: var(--muted);
  padding: var(--s3) var(--s8);
  font-size: var(--xs);
  border-bottom: 1px solid var(--divider);
}

div.breadcrumbs a {
  color: var(--muted);
}

div.breadcrumbs a:hover {
  color: var(--text);
}

/* -- Barre latérale ----------------------------------------------------- */

.main > #nav-sidebar,
.main.shifted > #nav-sidebar {
  visibility: visible;
  margin-left: 0;
  left: 0;
}

#nav-sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  max-height: none;
  background: var(--surface);
  border-right: 1px solid var(--divider);
  border-top: 0;
  padding: var(--s4) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  overflow-y: auto;
}

#nav-sidebar .nav-label {
  font-size: var(--xs);
  font-weight: 700;
  color: var(--faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--s3) var(--s3) var(--s2);
}

#nav-sidebar .nav-btn:link,
#nav-sidebar .nav-btn:visited {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--sm);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--t), color var(--t);
}

#nav-sidebar .nav-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#nav-sidebar .nav-btn:hover {
  background: var(--offset);
  color: var(--text);
}

#nav-sidebar .nav-btn[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
}

#nav-sidebar .nav-add {
  margin-left: auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--faint);
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--t), background var(--t);
}

#nav-sidebar .nav-add svg {
  width: 15px;
  height: 15px;
}

#nav-sidebar .nav-btn:hover .nav-add,
#nav-sidebar .nav-add:focus-visible {
  opacity: 1;
}

#nav-sidebar .nav-add:hover {
  background: var(--dynamic);
  color: var(--text);
}

#nav-sidebar .sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--divider);
  padding-top: var(--s3);
}

/* Barre réduite aux icônes sur écran moyen (comme la maquette à 1180px) :
   le composer a besoin de la largeur pour ses trois panneaux. */
@media (max-width: 1279px) {
  :root {
    --sidebar-w: 76px;
  }

  #site-name .brand-name,
  #nav-sidebar .nav-label,
  #nav-sidebar .nav-text,
  #nav-sidebar .nav-add {
    display: none;
  }

  #branding {
    justify-content: center;
    padding: 0;
  }

  #nav-sidebar .nav-btn:link,
  #nav-sidebar .nav-btn:visited {
    justify-content: center;
    padding: 0;
  }
}

/* -- Contenu ------------------------------------------------------------ */

.main {
  background: var(--bg);
}

#content {
  padding: var(--s8);
  max-width: 1600px;
}

#footer {
  display: none;
}

/* -- Cartes / modules --------------------------------------------------- */

.module,
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card {
  padding: var(--s5);
  overflow: visible;
}

.module h2,
.module caption,
.inline-group h2 {
  background: transparent;
  color: var(--muted);
  font-size: var(--xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--s4) var(--s5) var(--s2);
}

.module caption a.section:link,
.module caption a.section:visited {
  color: var(--muted);
}

fieldset.module {
  padding: 0;
}

/* Tableau de bord (accounts/templates/admin/index.html). base.css fige
   .dashboard #content à 600px. */
.dashboard #content {
  width: auto;
}

.kpi strong.kpi-alerte {
  color: var(--danger);
}

.tdb-grille {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--s4);
  align-items: start;
}

@media (max-width: 1100px) {
  .tdb-grille {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tdb-carte .card-top {
  align-items: center;
  margin-bottom: var(--s2);
}

.tdb-liste {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tdb-liste li {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-top: 1px solid var(--divider);
}

.tdb-liste li.vide {
  display: block;
  padding: var(--s5) 0;
}

.tdb-texte {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

a.tdb-titre:link,
a.tdb-titre:visited {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.tdb-titre:hover {
  color: var(--primary);
}

.tdb-meta {
  font-size: var(--xs);
  color: var(--muted);
}

.tdb-vignette {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--offset);
  flex-shrink: 0;
}

.raccourcis {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

a.raccourci:link,
a.raccourci:visited {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 38px;
  padding: 0 var(--s4);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--t), color var(--t);
}

a.raccourci svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

a.raccourci:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.section-label-gauche {
  justify-content: flex-start;
}

/* -- Tableaux ----------------------------------------------------------- */

table {
  border-color: var(--divider);
}

thead th,
tfoot td {
  background: transparent;
  color: var(--muted);
  font-size: var(--xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--divider);
}

thead th a:link,
thead th a:visited {
  color: var(--muted);
}

td,
th {
  border-bottom: 1px solid var(--divider);
  padding: var(--s3) var(--s4);
  font-size: var(--sm);
  vertical-align: middle;
}

tr:last-child > td,
tr:last-child > th {
  border-bottom: 0;
}

#result_list tbody tr:hover {
  background: var(--offset);
}

tr.selected {
  background: var(--primary-soft);
}

/* Préfixe body : changelists.css est chargé après cette feuille. */
body #changelist .results,
body #changelist .paginator {
  background: var(--surface-2);
}

body #changelist .results {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
}

body #changelist .paginator {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: var(--s3) 0;
}

body #changelist #toolbar {
  background: transparent;
  border: 0;
  padding: 0 0 var(--s4);
}

body #changelist .actions {
  background: transparent;
  border: 0;
  padding: 0 0 var(--s3);
  color: var(--muted);
}

/* Filtres : barre horizontale de menus déroulants au-dessus du tableau
   (au lieu de la colonne de droite de l'admin, qui volait la largeur du
   tableau et masquait ses dernières colonnes). */
/* La liste elle-même n'est pas une carte (le tableau l'est) ; overflow
   visible pour laisser déborder les menus de filtres. */
body #changelist.module {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

body #changelist.filtered {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

body #changelist .changelist-form-container {
  width: 100%;
  min-width: 0;
}

body #changelist-filter {
  order: -1;
  border: 0;
  border-radius: 0;
  position: static;
  flex: none;
  width: auto;
  margin: 0 0 var(--s4);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}

body #changelist-filter h2 {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0 var(--s2) 0 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: var(--xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

body #changelist-filter-extra-actions {
  order: 99;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: var(--xs);
}

body #changelist-filter-extra-actions h3 {
  margin: 0;
  font-size: var(--xs);
}

body #changelist-filter details {
  position: relative;
  margin: 0;
  border: 0;
}

body #changelist-filter details > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 34px;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--xs);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  white-space: nowrap;
}

body #changelist-filter details > summary::-webkit-details-marker {
  display: none;
}

body #changelist-filter details > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.6;
}

body #changelist-filter details[open] > summary,
body #changelist-filter details.filtre-actif > summary {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

body #changelist-filter .filtre-valeur {
  font-weight: 600;
  color: var(--primary);
}

body #changelist-filter details > ul {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  list-style: none;
}

body #changelist-filter details > ul li {
  list-style: none;
  margin: 0;
  padding: 0;
}

body #changelist-filter details > ul a:link,
body #changelist-filter details > ul a:visited {
  display: block;
  padding: 6px var(--s3);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--sm);
  text-decoration: none;
}

body #changelist-filter details > ul a:hover {
  background: var(--offset);
}

body #changelist-filter details > ul li.selected a {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

/* -- Formulaires -------------------------------------------------------- */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
select,
.vTextField {
  font-family: var(--font);
  font-size: var(--sm);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  transition: border-color var(--t), box-shadow var(--t);
}

select {
  height: auto;
  min-height: 38px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: 0;
}

.form-row {
  border-bottom: 1px solid var(--divider);
  padding: var(--s3) var(--s5);
}

.aligned label,
form .aligned label {
  color: var(--text);
  font-weight: 600;
}

.required label,
label.required {
  font-weight: 700;
}

.errornote,
.errorlist li {
  border-radius: var(--r-md);
}

.errornote {
  background: var(--danger-soft);
  color: var(--danger);
  border: 0;
}

/* -- Boutons ------------------------------------------------------------ */

.btn,
.button,
a.button,
input[type="submit"],
input[type="button"],
.submit-row input,
.submit-row a.deletelink,
.submit-row a.closelink {
  min-height: 38px;
  padding: 0 var(--s4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--sm);
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t);
}

a.button:link,
a.button:visited,
a.btn:link,
a.btn:visited {
  color: var(--text);
}

.btn:hover,
.button:hover,
a.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: var(--offset);
  border-color: color-mix(in oklab, var(--text) 28%, transparent);
  color: var(--text);
}

.btn:active,
.button:active {
  transform: translateY(1px);
}

.btn svg,
.button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:disabled,
.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary,
.button.default,
input[type="submit"].default,
.submit-row input.default {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--inverse);
}

a.btn-primary:link,
a.btn-primary:visited {
  color: var(--inverse);
}

.btn-primary:hover,
.button.default:hover,
input[type="submit"].default:hover,
.submit-row input.default:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--inverse);
}

.btn-danger,
.submit-row a.deletelink:link,
.submit-row a.deletelink:visited {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover,
.submit-row a.deletelink:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--inverse);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--offset);
  border-color: transparent;
}

.btn-sm {
  min-height: 30px;
  padding: 0 var(--s3);
  font-size: var(--xs);
}

.icon-btn {
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
}

.submit-row {
  background: transparent;
  border: 0;
  padding: var(--s4) 0;
  gap: var(--s2);
}

/* Bouton « Ajouter » de la liste : primaire, comme dans la maquette. */
.object-tools a:link,
.object-tools a:visited {
  border-radius: var(--r-md);
  padding: 10px 16px;
  font-size: var(--xs);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: var(--shadow-sm);
}

/* -- Badges / pastilles ------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
  line-height: 1.5;
}

.badge-neutre {
  background: var(--offset);
  color: var(--muted);
}

.badge-alerte {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.alerte {
  background: var(--warning);
}

/* -- Mise en page des écrans sur-mesure --------------------------------- */

.view-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--s4);
  margin-bottom: var(--s6);
}

.view-head h1 {
  margin: 0 !important;
}

.view-head p {
  color: var(--muted);
  font-size: var(--sm);
  margin: var(--s2) 0 0;
  max-width: 62ch;
}

.view-head .actions-tete {
  margin-left: auto;
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s6);
}

.kpi {
  padding: var(--s5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.kpi span {
  font-size: var(--xs);
  color: var(--muted);
  font-weight: 700;
}

.kpi strong {
  display: block;
  font-size: var(--xl);
  font-variant-numeric: tabular-nums;
  margin-top: var(--s1);
  line-height: 1.2;
}

.kpi strong.kpi-texte {
  font-size: var(--lg);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s4);
}

.card h2 {
  font-size: var(--base) !important;
  margin: 0;
}

.card > p {
  font-size: var(--sm);
  color: var(--muted);
  margin: var(--s2) 0 0;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}

.field {
  display: grid;
  gap: var(--s2);
  margin-top: var(--s4);
}

.field > label,
.field > .field-label {
  font-size: var(--xs);
  font-weight: 700;
  color: var(--text);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  box-sizing: border-box;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.liste-controles {
  list-style: none;
  margin: var(--s4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--s2);
}

.liste-controles li {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-md);
  background: var(--offset);
  font-size: var(--sm);
  list-style: none;
}

.liste-controles li svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.liste-controles li.ok svg {
  color: var(--success);
}

.liste-controles li.alerte {
  background: var(--warning-soft);
}

.liste-controles li.alerte svg {
  color: var(--warning);
}

.table-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--offset);
  padding: var(--s1);
  border-radius: var(--r-md);
}

.tab {
  min-height: 34px;
  border: 0;
  background: none;
  border-radius: calc(var(--r-md) - var(--s1));
  font-family: var(--font);
  font-size: var(--xs);
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  color: var(--muted);
  font-size: var(--xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: var(--s4) 0 var(--s2);
}

.vide {
  padding: var(--s8) var(--s5);
  text-align: center;
  color: var(--muted);
}

.vide svg {
  width: 32px;
  height: 32px;
  margin: 0 auto var(--s3);
  color: var(--faint);
  display: block;
}

.vide h3 {
  font-size: var(--base);
  color: var(--text);
  margin: 0;
}

.vide p {
  font-size: var(--sm);
  margin: var(--s2) 0 0;
}

/* -- Lien secondaire ---------------------------------------------------- */

.lien-discret:link,
.lien-discret:visited {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--xs);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.lien-discret:hover {
  color: var(--primary);
}

.lien-discret svg {
  width: 13px;
  height: 13px;
}

/* -- Messages Django → toasts (maquette) -------------------------------- */

ul.messagelist {
  position: fixed;
  right: var(--s5);
  bottom: var(--s5);
  z-index: 100;
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  max-width: min(440px, calc(100vw - 2 * var(--s5)));
}

ul.messagelist li,
.toast {
  background: var(--text);
  color: var(--inverse);
  padding: 12px 16px 12px 40px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--sm);
  font-weight: 700;
  margin: 0;
  background-position: 14px 50%;
  animation: toast-entree var(--t) both;
  transition: opacity var(--t), transform var(--t);
}

ul.messagelist li.toast-sortie {
  opacity: 0;
  transform: translateY(12px);
}

ul.messagelist li.success {
  background-color: var(--text);
}

ul.messagelist li.warning {
  background-color: var(--warning);
  color: #fff;
}

ul.messagelist li.error {
  background-color: var(--danger);
  color: #fff;
}

@keyframes toast-entree {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -- Connexion ---------------------------------------------------------- */

body.login {
  background: var(--bg);
}

.login #container {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.login #header {
  position: static;
  height: auto;
  padding: var(--s5);
}

.login #branding {
  width: auto;
  border: 0;
  background: transparent;
  padding: 0;
}

.login #content {
  padding: var(--s6);
}

/* Pages de compte hors admin (accounts/base.html : connexion, mot de passe). */
body.page-compte {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s4);
  margin: 0;
  box-sizing: border-box;
}

.carte-compte {
  width: min(420px, 100%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--s8) var(--s6);
  box-sizing: border-box;
}

.marque-compte {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-weight: 700;
  font-size: var(--lg);
  letter-spacing: -0.02em;
  margin-bottom: var(--s6);
}

.carte-compte h1 {
  font-size: var(--xl);
  letter-spacing: -0.02em;
  margin: 0 0 var(--s4);
}

.carte-compte p {
  margin: var(--s3) 0;
}

.carte-compte label {
  display: block;
  font-size: var(--xs);
  font-weight: 700;
  margin-bottom: var(--s2);
}

.carte-compte input:not([type="checkbox"]):not([type="hidden"]) {
  width: 100%;
  box-sizing: border-box;
}

.carte-compte button[type="submit"] {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--inverse);
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  margin-top: var(--s2);
}

.carte-compte button[type="submit"]:hover {
  background: var(--primary-hover);
}

/* -- Écrans Export / Brevo / bibliothèque -------------------------------- */

.actions-tete form {
  margin: 0;
}

.actions-carte {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s4);
}

.card .titre-secondaire {
  margin-top: var(--s6) !important;
  padding-top: var(--s4);
  border-top: 1px solid var(--divider);
}

.section-label-page {
  margin-top: var(--s8);
}

.choix-listes {
  display: grid;
  gap: var(--s2);
  margin-top: var(--s4);
}

.choix {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.choix:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choix input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  margin: 0;
}

.card.vide {
  padding: var(--s10) var(--s5);
}

.filtres {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s6);
}

.filtres input[type="search"] {
  flex: 1 1 260px;
}

.carte-article-biblio {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.carte-article-biblio img,
.carte-article-biblio .image-vide {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: var(--offset);
  display: grid;
  place-items: center;
  color: var(--faint);
}

.carte-article-biblio .corps {
  padding: var(--s4) var(--s5) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  flex: 1;
}

.carte-article-biblio h2 a:link,
.carte-article-biblio h2 a:visited {
  color: var(--text);
  text-decoration: none;
}

.carte-article-biblio h2 a:hover {
  color: var(--primary);
}

.carte-article-biblio .extrait {
  font-size: var(--sm);
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-stats {
  display: flex;
  gap: var(--s4);
  margin-top: auto;
  padding-top: var(--s3);
  border-top: 1px solid var(--divider);
  font-size: var(--xs);
  color: var(--muted);
}

.source-name {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-weight: 700;
}

.source-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--r-md);
  flex-shrink: 0;
}

.source-icon svg {
  width: 16px;
  height: 16px;
}

.formulaire-carte {
  max-width: 720px;
}

.formulaire-carte .field:first-of-type {
  margin-top: 0;
}

.liste-controles-page {
  max-width: 720px;
  margin: 0 0 var(--s4);
}

.bandeau-alerte {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 600;
}

.vignette-liste {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--offset);
  display: block;
}

.etat-ok,
.etat-erreur {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.etat-ok {
  background: var(--success-soft);
  color: var(--success);
}

.etat-erreur {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* -- Ajustements des listes de l'admin ----------------------------------- */

thead th.sorted {
  background: transparent;
}

thead th.sorted .text a,
thead th.sorted .text {
  color: var(--text);
}

#result_list td a.button {
  min-height: 30px;
  padding: 0 var(--s3);
  font-size: var(--xs);
  margin: 2px 0;
}

#result_list td.field-actions_rapides,
#result_list td.field-synchroniser_bouton {
  white-space: nowrap;
}

#result_list td.field-actions_rapides a.button + a.button {
  margin-left: var(--s1);
}

.kpis-liste {
  clear: both;
}

/* Deux ou trois cartes qui se partagent la largeur (Export, Brevo). */
.cards.cards-larges {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  max-width: 1100px;
}

/* -- Widgets de formulaire de l'admin -------------------------------------- */

/* Sélecteur à deux listes (filter_horizontal) : le titre de la liste
   « choisie » utilise --secondary/--header-link-color, pensés pour un
   bandeau sombre texte clair — illisible avec notre en-tête clair.
   Préfixe body : widgets.css est chargé après cette feuille. */
body .selector-available-title,
body .selector-chosen-title {
  border-color: var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0;
}

body .selector-chosen-title,
body .selector-chosen .list-footer-display {
  background: var(--primary-soft);
  color: var(--primary);
}

body .selector-chosen-title label,
body .selector-chosen-title .helptext {
  color: var(--primary);
}

body .selector-available-title {
  background: var(--offset);
  color: var(--muted);
}

body .selector-available-title label {
  color: var(--text);
}

body .selector-chosen .list-footer-display {
  border-color: var(--border);
  border-radius: 0 0 var(--r-md) var(--r-md);
}

body .selector select {
  background: var(--surface-2);
  color: var(--text);
  border-radius: 0;
}

body .selector .selector-filter {
  background: var(--surface-2);
  border-color: var(--border);
}

body .selector-chooser {
  background: var(--offset);
}

/* Inlines tabulaires (ex. éléments d'une newsletter). */
body .inline-group .tabular fieldset.module {
  overflow-x: auto;
}

/* Le libellé de l'objet (positionné en absolu par l'admin) se superposait
   au titre de l'inline ; il répète les colonnes, on le masque. */
body .inline-group .tabular tr.has_original td {
  padding-top: var(--s3);
}

body .inline-group .tabular td.original p {
  display: none;
}

body .inline-group .tabular td {
  vertical-align: top;
}

body .inline-group .tabular select,
body .inline-group .tabular input[type="text"] {
  max-width: 240px;
}

body .inline-group .tabular .field-zone input {
  max-width: 150px;
}

body .inline-group .tabular .field-position input {
  width: 4em;
}

body .inline-group .tabular textarea {
  height: 4.5em;
  min-height: 0;
  width: 16em;
  font-family: var(--mono);
  font-size: var(--xs);
}

body .inline-group .tabular tr.add-row td {
  padding: var(--s3) var(--s4);
}

/* Écran « Nettoyage de la bibliothèque ». */
.choix-ligne {
  margin-top: var(--s4);
}

.kpi .tdb-meta {
  display: block;
  margin-top: 2px;
}

.confirmation-purge {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--divider);
}

/* -- Pagination ----------------------------------------------------------
   .pager : écrans sur-mesure (accounts/templates/newsflow/pager.html) ;
   .paginator : listes de l'admin, mêmes pastilles. */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-top: var(--s6);
}

.pager-info {
  font-size: var(--xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pager-pages {
  display: flex;
  align-items: center;
  gap: var(--s1);
}

.pager-lien,
body #changelist .paginator a,
body #changelist .paginator .this-page {
  min-width: 34px;
  height: 34px;
  padding: 0 var(--s2);
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  box-sizing: border-box;
}

a.pager-lien:hover,
body #changelist .paginator a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pager-lien.actif,
body #changelist .paginator .this-page {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--inverse);
}

.pager-lien.desactive {
  opacity: 0.4;
}

.pager-lien svg {
  width: 16px;
  height: 16px;
}

.pager-ellipse {
  padding: 0 var(--s1);
  color: var(--faint);
}

body #changelist .paginator {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s1);
  font-size: var(--xs);
  line-height: 1;
}

body #changelist .paginator .end {
  margin-right: var(--s3);
}
