/* =====================================================================
   Bibliothèque communale — feuille de style unique (aucune dépendance)
   ===================================================================== */

:root {
  color-scheme: light;

  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #22303a;
  --muted: #6b7883;
  --line: #e4e0d7;
  --line-soft: #f0ede6;

  --primary: #1f4e6e;
  --primary-ink: #ffffff;
  --primary-soft: #e9f1f7;

  --accent: #c96f2e;

  --ok: #2f7d4f;
  --ok-bg: #e7f4ec;
  --warn: #9a6209;
  --warn-bg: #fcf1dd;
  --danger: #b3392f;
  --danger-bg: #fbe9e7;
  --info: #2a6f97;
  --info-bg: #e7f1f8;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .05), 0 6px 18px rgba(20, 30, 40, .05);

  /* Hauteur d'une boîte de champ (ligne 1,5 × corps .97rem + interlignes
     + bordures) : sert à aligner <select> et boutons sur les <input>. */
  --field-h: calc(1.5 * 0.97rem + 1.1rem + 2px);
}

/* --------------------------------------------------------- Mode sombre --
   Bascule instantanée (bouton ☀/☾) : le choix est mémorisé dans le
   navigateur (localStorage) et appliqué avant le premier rendu par le
   script en tête de base.html — aucun clignotement. Sans choix explicite,
   le thème suit le réglage du système.
   Le tout reste réservé à l'affichage à l'écran : à l'impression, le
   thème clair s'applique toujours (texte sombre sur papier blanc). */
@media screen {
  [data-theme="dark"] {
    color-scheme: dark;

    --bg: #14181d;
    --surface: #1c2128;
    --ink: #e6eaee;
    --muted: #97a2ad;
    --line: #2d343d;
    --line-soft: #242a31;

    /* Bleu clair : lisible comme texte sur fond sombre ; le texte des
       boutons primaires devient sombre pour rester contrasté dessus. */
    --primary: #6aa9dd;
    --primary-ink: #0d2133;
    --primary-soft: #22374a;

    --accent: #e0925a;

    --ok: #7fca9f;      --ok-bg: #16301f;
    --warn: #e0b054;    --warn-bg: #322a10;
    --danger: #e87568;  --danger-bg: #3a1a17;
    --info: #79b6e0;    --info-bg: #1b2c38;

    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .35);
  }

  /* Contrastes du thème sombre : les couleurs « en dur » du thème clair
     (bordures, textes de messages, survols…) ont des équivalents sombres. */
  [data-theme="dark"] .stat.is-danger { border-color: #5a2a24; }
  [data-theme="dark"] .stat.is-warn { border-color: #57461f; }

  [data-theme="dark"] .flash-success { border-color: #2c5540; color: #9ed4b4; }
  [data-theme="dark"] .flash-error   { border-color: #5c2b26; color: #f0a79e; }
  [data-theme="dark"] .flash-info    { border-color: #2c4a5e; color: #9cc6e4; }
  [data-theme="dark"] .hint-box { border-color: #2e4a61; }
  [data-theme="dark"] .error-list { border-color: #5c2b26; color: #f0a79e; }

  /* Badge gris par défaut (les variantes couleur restent pilotées par les
     variables, déjà recalées ci-dessus). */
  [data-theme="dark"] .badge { background: #29323b; color: #b7c1ca; }
  [data-theme="dark"] .badge-ok      { background: var(--ok-bg); color: var(--ok); }
  [data-theme="dark"] .badge-danger  { background: var(--danger-bg); color: var(--danger); }
  [data-theme="dark"] .badge-warn    { background: var(--warn-bg); color: var(--warn); }
  [data-theme="dark"] .badge-info    { background: var(--info-bg); color: var(--info); }
  [data-theme="dark"] .badge-admin   { background: var(--primary-soft); color: var(--primary); }
  [data-theme="dark"] .badge-muted   { background: var(--line-soft); color: var(--muted); }

  [data-theme="dark"] .btn:focus-visible { outline: 3px solid rgba(140, 190, 235, .55); }
  [data-theme="dark"] .btn-primary:hover { background: #82b7e4; }
  [data-theme="dark"] .btn-danger { color: #26100d; }
  [data-theme="dark"] .btn-danger:hover { background: #f08a7e; }
  [data-theme="dark"] input:focus,
  [data-theme="dark"] select:focus,
  [data-theme="dark"] textarea:focus { box-shadow: 0 0 0 3px rgba(140, 190, 235, .28); }

  [data-theme="dark"] .tbl tbody tr:hover td { background: #232a32; }
  [data-theme="dark"] .cover-ph {
    color: #8a949e;
    background: linear-gradient(135deg, #262d35, #1f262d);
  }
  [data-theme="dark"] .pager .current { color: var(--primary-ink); }
  [data-theme="dark"] .selected-box { border-color: #3a5b78; }
  [data-theme="dark"] .desc { color: #c3ccd4; }
  [data-theme="dark"] .card.tint-info { border-color: #2e4a61; }
  [data-theme="dark"] .card.tint-warn { border-color: #57461f; }
} /* @media screen (fin du thème sombre) */

/* ------------------------------------------------- Bascule clair/sombre --
   Deux icônes dans un même bouton : on propose toujours le thème opposé
   (lune en clair, soleil en sombre). app.js bascule et mémorise le choix. */
.theme-toggle { padding: .45rem .6rem; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6rem; font-weight: 650; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8rem; }

a { color: var(--primary); }

.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------- Menu latéral */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width .15s ease;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  min-height: 54px;
  padding: .6rem .65rem;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand { min-width: 0; }
.sidebar-brand .sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .6rem .55rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .65rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .93rem;
  white-space: nowrap;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
}
.sidebar-nav a .icon { flex: none; }
.sidebar-nav a:hover { background: var(--primary-soft); color: var(--primary); }
.sidebar-nav a.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 650;
}
.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: .55rem .55rem .6rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.sidebar-foot .theme-toggle { justify-content: flex-start; }
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  padding: 0 .25rem;
}
.sidebar-user form { margin: 0; }
.sidebar-user .user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }
/* Fermeture : mobile seulement ; réduction : desktop seulement.
   Préfixé par .btn pour priver la règle .btn { display: inline-flex }
   définie plus bas (même spécificité, dernière gagne). */
.btn.sidebar-close, .btn.sidebar-collapse { display: none; }
.nav-icon-expand { display: none; }

/* Barre mobile (menu en tiroir) — masquée en desktop */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  gap: .55rem;
  padding: .5rem .7rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.mobile-bar .brand { flex: 1; min-width: 0; }
.mobile-bar .brand > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 22, 32, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 35;
}

/* --------------------------------------------------------------- Layout */
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.02rem;
}
.brand-icon { font-size: 1.15rem; line-height: 1; }
.brand-icon.big { font-size: 2.2rem; }
.user-name { font-size: .87rem; color: var(--muted); }

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* Desktop : le contenu épouse la largeur restante à droite du menu ;
   le décalage n'existe que SI le menu est rendu (html.has-nav, posé par
   base.html selon la session) — sinon la page de connexion serait décalée
   dans le vide. Le mode réduit (pictos seuls) est piloté par
   html.nav-collapsed, mémorisé par app.js et appliqué avant rendu. */
@media (min-width: 901px) {
  .has-nav .main-wrap { margin-left: 236px; }
  .btn.sidebar-collapse { display: inline-flex; }
  html.nav-collapsed .sidebar { width: 64px; }
  html.has-nav.nav-collapsed .main-wrap { margin-left: 64px; }
  html.nav-collapsed .sidebar-label { display: none; }
  html.nav-collapsed .sidebar-user .user-name { display: none; }
  html.nav-collapsed .sidebar-head { justify-content: center; padding: .6rem .35rem; }
  html.nav-collapsed .sidebar-brand { justify-content: center; }
  html.nav-collapsed .sidebar-nav a {
    justify-content: center;
    padding: .55rem 0;
    border-left: none;
  }
  html.nav-collapsed .sidebar-user { justify-content: center; padding: 0; }
  html.nav-collapsed .sidebar-foot .theme-toggle,
  html.nav-collapsed .sidebar-foot .sidebar-collapse {
    justify-content: center;
    padding-left: .25rem;
    padding-right: .25rem;
  }
  html.nav-collapsed .nav-icon-collapse { display: none; }
  html.nav-collapsed .nav-icon-expand { display: block; }
}
/* Mobile : le menu devient un tiroir coulissant ouvert par la barre du haut */
@media (max-width: 900px) {
  .sidebar {
    width: 264px;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  html.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 26px rgba(0, 0, 0, .22);
  }
  html.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .btn.sidebar-close { display: inline-flex; }
  .mobile-bar { display: flex; }
}
.container { max-width: 1160px; margin: 0 auto; padding: 1.4rem 20px; width: 100%; }
main.container { flex: 1; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.page-head h1 { margin: 0; }
.page-head .subtitle { color: var(--muted); font-size: .92rem; margin: .15rem 0 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; align-items: start; }
.stack > * + * { margin-top: 1rem; }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- Cartes */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
}
.card > :last-child { margin-bottom: 0; }
/* Encarts teintés de la fiche ouvrage (emprunt en cours, réservation) */
.card.tint-info { background: var(--primary-soft); border-color: #cfe0ee; box-shadow: none; }
.card.tint-warn { background: var(--warn-bg); border-color: #efdfbd; box-shadow: none; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .85rem;
}
.card-title h2, .card-title h3 { margin: 0; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem 1.05rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
}
a.stat:hover { border-color: var(--primary); }
.stat .num { font-size: 1.85rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat .lbl {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-top: .2rem;
}
.stat.is-danger .num { color: var(--danger); }
.stat.is-danger { background: var(--danger-bg); border-color: #f2cdc8; }
.stat.is-warn .num { color: var(--warn); }
.stat.is-warn { background: var(--warn-bg); border-color: #efdfbd; }
.stat.is-ok .num { color: var(--ok); }

/* -------------------------------------------------------------- Messages */
.flashes { margin-bottom: 1rem; }
.flash {
  padding: .72rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: .94rem;
  margin-bottom: .55rem;
}
.flash-success { background: var(--ok-bg); border-color: #bfe3cd; color: #245f3e; }
.flash-error   { background: var(--danger-bg); border-color: #f0c8c3; color: #8f2c24; }
.flash-info    { background: var(--info-bg); border-color: #c5dcef; color: #245a7a; }

.hint-box {
  background: var(--primary-soft);
  border: 1px solid #cfe0ee;
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  font-size: .9rem;
  margin-top: 1.1rem;
}
.hint-box p { margin: .3rem 0 0; color: var(--muted); }

/* --------------------------------------------------------------- Boutons */
/* Icônes SVG au trait (bibliotheque/icons.py) : monochromes, elles héritent
   de la couleur du texte — blanches dans un bouton primaire, bleues dans un
   lien. Taille en em pour suivre la taille de police du conteneur. */
.icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  stroke-width: 1.8;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  padding: .52rem .95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: .93rem;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
  background: var(--surface);
  color: var(--ink);
}
.btn:focus-visible { outline: 3px solid rgba(31, 78, 110, .35); outline-offset: 1px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1a4260; }
.btn-outline { border-color: var(--line); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #972f26; }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- Formes */
.field { display: block; margin-bottom: .95rem; }
.field > span {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .3rem;
}
/* Tous les champs de saisie sauf les cases/boutons/caches : la liste par
   type oubliait « tel » et « url » (téléphone, adresse du site), qui
   s'affichaient alors sans le style commun. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .97rem;
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 78, 110, .14);
}
textarea { min-height: 110px; resize: vertical; }
/* Blink calcule la hauteur d'un <select> avec line-height:normal et ignore
   line-height (40 px contre 42,9 px pour un <input>) : on impose la même
   boîte que les champs de saisie. */
select { min-height: var(--field-h); }
input[disabled] { background: var(--line-soft); color: var(--muted); }

.checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .92rem;
  margin-bottom: .95rem;
  cursor: pointer;
}
.checkbox input { width: auto; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: stretch; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; align-items: stretch; }
@media (max-width: 620px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

/* Dans une ligne de champs, l'étiquette reste en haut et le contrôle est
   calé en bas : les champs restent alignés même quand une étiquette prend
   deux lignes (« Prêts simultanés max / adhérent », etc.). */
.form-row > .field, .form-row-3 > .field {
  display: flex;
  flex-direction: column;
}
.form-row > .field > input,
.form-row > .field > select,
.form-row > .field > textarea,
.form-row-3 > .field > input,
.form-row-3 > .field > select,
.form-row-3 > .field > textarea { margin-top: auto; }
.form-row > .field > .badge,
.form-row-3 > .field > .badge { margin-top: auto; }
/* Bouton posé dans une ligne de champs (ex. « Importer la notice ») :
   même hauteur que les champs voisins pour un alignement net. */
.form-row > .field > .btn,
.form-row-3 > .field > .btn { min-height: var(--field-h); }

.form-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

.error-list {
  background: var(--danger-bg);
  border: 1px solid #f0c8c3;
  color: #8f2c24;
  border-radius: var(--radius-sm);
  padding: .75rem 1rem .75rem 2.2rem;
  font-size: .92rem;
  margin-bottom: 1rem;
}
.error-list li { margin: .15rem 0; }

.searchbar { display: flex; gap: .55rem; flex-wrap: wrap; align-items: flex-end; }
.searchbar .field { margin-bottom: 0; flex: 1; min-width: 190px; }
.searchbar .field-inline { display: flex; flex-direction: column; gap: .3rem; }
.searchbar .field-inline > span { font-size: .85rem; font-weight: 600; color: var(--muted); }

.form-status { font-size: .88rem; color: var(--muted); margin-top: .5rem; min-height: 1.2em; }
.form-status.ok { color: var(--ok); }
.form-status.error { color: var(--danger); }

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  font-size: .76rem;
  font-weight: 650;
  padding: .18rem .55rem;
  border-radius: 999px;
  background: #eef1f4;
  color: #4a5a66;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-admin { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: var(--line-soft); color: var(--muted); }

/* --------------------------------------------------------------- Onglets */
.tabs {
  display: flex;
  gap: .2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: .5rem .85rem;
  font-size: .93rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 650; }
.tabs .count {
  background: var(--line-soft);
  border-radius: 999px;
  padding: 0 .45rem;
  font-size: .78rem;
  margin-left: .3rem;
}
.tabs a.active .count { background: var(--primary-soft); }
/* Onglets des Paramètres : pile de cartes unique et étroite en dessous */
.settings-stack { max-width: 980px; }

/* --------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th {
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 650;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td {
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #fbfaf7; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl a { text-decoration: none; font-weight: 600; }
.tbl a:hover { text-decoration: underline; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.6rem 1rem;
  font-size: .94rem;
}

/* --------------------------------------------------------- Listes d'items */
.item {
  display: flex;
  gap: .85rem;
  align-items: center;
  padding: .6rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.item:last-child { border-bottom: none; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 620; color: var(--ink); text-decoration: none; }
.item-title:hover { text-decoration: underline; }
.item-meta { font-size: .85rem; color: var(--muted); }
.item-actions { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }

.cover {
  width: 44px;
  height: 62px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.cover-lg { width: 150px; height: 212px; border-radius: 6px; }
.cover-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b3ab9c;
  font-weight: 700;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #efece5, #e7e2d7);
}
.cover-ph.lg { font-size: 3rem; width: 150px; height: 212px; border-radius: 6px;
               border: 1px solid var(--line); }

/* ----------------------------------------------------------- Fiche ouvrage */
.book-detail { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 700px) { .book-detail { grid-template-columns: 1fr; } }
.book-detail .cover-lg, .book-detail .cover-ph.lg { margin: 0 auto; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: .35rem .9rem; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.availability {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .92rem;
  font-weight: 600;
  padding: .5rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--ok-bg);
  color: var(--ok);
}
.availability.none { background: var(--warn-bg); color: var(--warn); }
.availability.late { background: var(--danger-bg); color: var(--danger); }

/* ------------------------------------------------------------ Pagination */
.pager { display: flex; gap: .35rem; justify-content: center; margin-top: 1.3rem; flex-wrap: wrap; }
.pager a, .pager span {
  padding: .32rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .88rem;
  text-decoration: none;
  color: var(--ink);
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager .current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 650; }
.pager .ellipsis { border: none; background: transparent; color: var(--muted); }

/* ------------------------------------------------------- Nouveau prêt */
.selected-box {
  border: 2px dashed #cfdce7;
  background: var(--primary-soft);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.selected-box .item { border: none; padding: 0; }

.result-list { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.result-list .item {
  padding: .55rem .75rem;
  margin: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.result-list .item:last-child { border-bottom: none; }

/* ---------------------------------------------------------- Graphique */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: .6rem;
  overflow-x: auto;
}
.chart-col {
  flex: 1;
  min-width: 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.chart-bars { display: flex; gap: 3px; align-items: flex-end; height: 160px; }
.bar { width: 13px; border-radius: 3px 3px 0 0; background: var(--primary); min-height: 2px; }
.bar.returns { background: var(--accent); opacity: .75; }
.chart-lbl { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 1rem; font-size: .83rem; color: var(--muted); margin-top: .7rem; }
.legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: .35rem; background: var(--primary);
}
.legend .dot.accent { background: var(--accent); opacity: .75; }

/* ------------------------------------------------------------- Connexion */
.auth-page { max-width: 780px; margin: 3.5rem auto; }
.auth-card {
  max-width: 400px;
  margin: 0 auto 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 2rem;
}
/* Encarts « Contactez-nous » et horaires sous le formulaire */
.auth-side {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.auth-side .kv { grid-template-columns: 96px 1fr; }
.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .5rem;
  font-size: .93rem;
}
.contact-list li { display: flex; align-items: flex-start; gap: .55rem; }
.contact-list .icon { flex: none; margin-top: 2px; color: var(--muted); }
.contact-list .addr { white-space: pre-line; overflow-wrap: anywhere; }
.contact-list a {
  color: var(--primary);
  font-weight: 550;
  text-decoration: none;
}
.contact-list a:hover { text-decoration: underline; }
/* Formulaire compact (Paramètres → Contact) */
.ta-compact { min-height: 66px; }
.auth-brand { text-align: center; margin-bottom: .4rem; }
.auth-brand h1 { font-size: 1.3rem; margin-top: .5rem; }
.auth-card .btn-block { margin-top: .4rem; }
/* Logo personnalisé et slogan (Paramètres → Page de connexion) */
.auth-logo {
  display: block;
  max-width: 170px;
  max-height: 100px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 8px;
}
/* En mode sombre, une plaque blanche conserve les logos à l'encre sombre
   (les logos transparents sont conçus pour un fond clair). */
[data-theme="dark"] .auth-logo { background: #fff; padding: .5rem .75rem; }
.auth-slogan {
  color: var(--accent);
  font-weight: 650;
  font-size: 1.02rem;
  margin: .35rem 0 .2rem;
  text-align: center;
}
/* Aperçu du logo courant dans les Paramètres */
.logo-preview {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: .9rem;
}
/* Plaque blanche : un logo à fond transparent reste lisible quel que soit
   le thème. */
.logo-preview img {
  max-height: 64px;
  max-width: 170px;
  object-fit: contain;
  background: #fff;
  padding: .35rem .5rem;
  border-radius: 6px;
}

/* --------------------------------------------------------------- Erreurs */
.error-page { text-align: center; padding: 3.5rem 1rem; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--line); margin: 0; line-height: 1; }
.error-page h1 { margin-top: .6rem; }

/* --------------------------------------------------------------- Divers */
.inline-form { display: inline; }
.actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.divider { border: none; border-top: 1px solid var(--line-soft); margin: 1rem 0; }
.desc { white-space: pre-wrap; font-size: .95rem; color: #3d4a54; }

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem 0;
  font-size: .85rem;
  color: var(--muted);
}
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 0; padding-bottom: 0; }
.footer .container { padding-top: 0; padding-bottom: 0; }

/* Bascule de langue (pied de page, i18n) */
.lang-switch { display: inline-flex; align-items: center; gap: .3rem; }
.lang-switch-label { color: var(--muted); font-size: .8rem; }
.lang-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: .1rem .45rem;
  font: inherit;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  cursor: pointer;
}
.lang-btn:hover { color: var(--ink); border-color: var(--muted); }
.lang-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =====================================================================
   Impression : fiches imprimables, cartes d'adhérent, exports
   ===================================================================== */
.print-page {
  background: #eceae4;
  padding-bottom: 3rem;
}
.print-toolbar {
  max-width: 860px;
  margin: 0 auto;
  padding: .9rem 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Feuille imprimable (fiche ouvrage / fiche adhérent) */
.sheet {
  max-width: 860px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.2rem;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.sheet-org {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: .3rem;
}
.sheet-head h1 { margin-bottom: .25rem; }
.sheet-sub { color: var(--muted); margin: 0; }
.sheet-codes { text-align: center; min-width: 150px; }
.sheet-kv { margin-bottom: 1.2rem; }
.sheet section { margin-bottom: 1.3rem; }
.sheet-foot {
  border-top: 1px solid var(--line);
  padding-top: .7rem;
  color: var(--muted);
  font-size: .8rem;
}

/* Codes imprimés */
.qr svg, .barcode svg { display: block; margin: 0 auto; }
.qr { display: flex; justify-content: center; }
.barcode { display: flex; justify-content: center; margin-top: .5rem; }
.qr.sm svg { width: 54px; height: 54px; }
.barcode.sm svg { height: 30px; width: auto; }
.code-label {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .82rem;
  letter-spacing: .06em;
  margin-top: .3rem;
  color: var(--ink);
}

/* Planche de cartes d'adhérent (format carte bancaire 85,6 × 54 mm) */
.cards-grid {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.member-card {
  width: 336px;   /* ≈ 85,6 mm à 100 % */
  height: 212px;  /* ≈ 54 mm */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  break-inside: avoid;
}
.mc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  margin: -14px -16px 10px;
  padding: 8px 16px;
  border-radius: 12px 12px 0 0;
}
.mc-org { font-weight: 700; font-size: .86rem; }
.mc-icon { font-size: 1rem; }
.mc-name { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.mc-num {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .95rem;
  letter-spacing: .1em;
  color: var(--accent);
  font-weight: 700;
  margin-top: 2px;
}
.mc-legal { font-size: .66rem; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.mc-body { flex: 1; }
.mc-codes {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.mc-codes .barcode { margin-top: 0; flex: 1; }
.mc-codes .barcode svg { width: 100%; height: 34px; }
.page-break { flex-basis: 100%; height: 0; }

/* Barre d'export CSV */
.export-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.sent-list { list-style: none; padding: 0; margin: .4rem 0 0; }
.sent-list li {
  padding: .4rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.sent-list li:last-child { border-bottom: none; }

/* Horaires d'ouverture (section des Paramètres) */
.hours-grid {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.hours-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .5rem .8rem;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.hours-row:last-child { border-bottom: none; }
.hours-row.is-today { background: var(--primary-soft); }
.hours-day {
  flex: 1;
  min-width: 9rem;
  font-size: .9rem;
  font-weight: 600;
}
.hours-day em {
  color: var(--muted);
  font-style: normal;
  font-weight: 400;
  font-size: .8rem;
}
.hours-slot {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  color: var(--muted);
}
/* Les deux plages d'un jour forment un bloc indivisible : si la largeur
   ne suffit pas, elles passent ensemble à la ligne et restent alignées,
   colonne de libellés de même largeur (Matin / Après-midi). */
.hours-slots {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.4rem;
}
.hours-slot label { min-width: 5.6rem; white-space: nowrap; }
.hours-slot input[type="time"] {
  width: 5.8rem;
  padding: .3rem .4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: .85rem;
  color: var(--ink);
}
.hours-sep { color: var(--muted); }

/* Jour courant dans la liste des horaires (Mon compte) */
.hours-today { color: var(--ink) !important; font-weight: 600; }
.footer-hours { display: inline-flex; align-items: center; gap: .35rem; }

/* Catégories / genres (section des Paramètres) */
.cat-add { display: flex; gap: .6rem; align-items: flex-end; margin-bottom: .9rem; }
.cat-add .field { margin: 0; flex: 1; }
.cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 340px;
  overflow-y: auto;
}
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .38rem .7rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: .9rem;
}
.cat-row:last-child { border-bottom: none; }
.cat-row form { margin: 0; }
.cat-name { overflow-wrap: anywhere; }

/* Impression : ne garder que le contenu */
@media print {
  .no-print, .print-toolbar, .footer,
  .sidebar, .mobile-bar, .nav-backdrop { display: none !important; }
  .main-wrap { margin-left: 0 !important; display: block !important; }
  body.print-page { background: #fff; padding: 0; display: block; }
  .sheet {
    border: none;
    box-shadow: none;
    border-radius: 0;
    max-width: none;
    padding: 0;
  }
  .member-card {
    border: 1px solid #999;
    box-shadow: none;
    width: 85.6mm;
    height: 54mm;
    page-break-inside: avoid;
  }
  .cards-grid { display: block; max-width: none; }
  .member-card { display: inline-flex; margin: 0 6mm 6mm 0; vertical-align: top; }
  .page-break { display: none; }
  a[href]:after { content: none !important; }
  @page { margin: 12mm; }
}
