/* ==========================================================================
   Tournées calendriers — feuille de style unique
   Design system Skuyrel : thème clair unique, Figtree, icônes Phosphor
   ========================================================================== */

/* 1. Design tokens --------------------------------------------------------- */
:root {
  color-scheme: light;

  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --primary-soft: rgba(220, 38, 38, 0.16);

  --page: #eceef1;
  --surface: #ffffff;
  --field: #f8f9fa;
  --border: #e2e5e9;
  --text: #111418;
  --muted: #6b7280;
  --danger-bg: #fef2f2;
  --danger-text: #991b1b;

  --radius: 14px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  --sidenav-w: 248px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

a { color: var(--primary); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 2. Icônes ---------------------------------------------------------------- */
.icon { font-size: 20px; line-height: 1; vertical-align: middle; flex-shrink: 0; }

/* 3. Boutons --------------------------------------------------------------- */
.btn {
  display: block; width: 100%; padding: 12px 16px;
  border: 1px solid var(--primary); border-radius: 999px;
  background: var(--primary); color: #fff; font-weight: 600; font-size: .95rem;
  text-align: center; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn .icon { font-size: 16px; }

.btn-sm {
  display: inline-flex; align-items: center; gap: 6px; width: auto;
  padding: 8px 16px; font-size: .88rem; white-space: nowrap;
}
.btn-outline { background: transparent; color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--field); border-color: #cfd4da; }
.btn-danger { background: var(--surface); border-color: #fecaca; color: var(--primary-hover); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--primary); }
.btn-block { width: 100%; justify-content: center; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 8px; background: transparent; color: var(--muted);
  text-decoration: none; transition: background .15s, color .15s, box-shadow .15s;
}
.icon-btn:hover { background: var(--field); color: var(--primary); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn-sm .icon { font-size: 17px; }
.icon-btn-danger:hover { background: var(--danger-bg); color: var(--primary-hover); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.icon-btn.is-confirm { background: var(--danger-bg); color: var(--danger-text); outline: 2px solid var(--primary); }

/* 4. Formulaires ----------------------------------------------------------- */
.field {
  position: relative; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--field);
  text-align: left;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field:focus-within {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field label { display: block; padding: 8px 12px 0; font-size: .72rem; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; height: 33px; padding: 2px 12px 9px;
  border: 0; background: transparent; font: inherit; font-size: .95rem; outline: none;
}
.field textarea { height: auto; min-height: 90px; resize: vertical; }

.field.has-error { border-color: var(--primary); background: var(--danger-bg); }
.field-error { margin: -6px 0 12px; color: var(--danger-text); font-size: .83rem; }
.field-inline { margin: 0; flex: 0 0 auto; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field-eye input, .field-pin input { padding-right: 46px; }
.field-eye .icon-btn, .field-pin .icon-btn { position: absolute; right: 8px; bottom: 6px; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { accent-color: var(--primary); }
.check input:not(.switch) { width: 16px; height: 16px; }

.switch {
  appearance: none; position: relative; flex-shrink: 0; cursor: pointer;
  width: 40px; height: 22px; border-radius: 999px; background: #d1d5db;
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

/* 5. Tableaux -------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  padding: 10px 16px; text-align: left; text-transform: uppercase;
  font-size: .78rem; font-weight: 600; color: var(--muted);
  background: var(--field); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfcfd; }
.table .num { text-align: right; width: 1%; white-space: nowrap; }
.table .actions { width: 1%; text-align: right; white-space: nowrap; }
.table-flat { border: 0; border-radius: 0; }
.dim { color: #b6bcc5; }

.ref-groupe-titre th { background: var(--surface); color: var(--text); text-transform: none; font-size: .9rem; }
.ref-groupe-n { margin-left: 6px; color: var(--muted); font-weight: 500; }
.ref-lib { display: none; color: var(--muted); font-size: .75rem; }

/* 6. Panels, cartes, KPI --------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}
.panel-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 16px; }
.panel-title .icon { color: var(--primary); }

.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; text-decoration: none; transition: border-color .15s;
}
.kpi:hover { border-color: #cfd4da; }
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.kpi-label .icon { color: var(--primary); font-size: 17px; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.kpi-sub { color: var(--muted); font-size: .78rem; }

.card-page {
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.card {
  width: 100%; max-width: 420px; padding: 40px 32px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(17, 20, 24, .18); text-align: center;
}
.card-logo { display: block; width: 100%; height: auto; margin: 0 auto 28px; }
.card h1 { font-size: 1.4rem; font-weight: 700; }
.card .page-sub { margin-bottom: 24px; }
.card form { margin-top: 4px; }
.card .btn { margin-top: 20px; }

/* 7. Statuts, tags --------------------------------------------------------- */
.statut-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 13%, #fff);
  color: color-mix(in srgb, var(--c) 55%, #000);
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.statut-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: var(--field); border: 1px solid var(--border);
  color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tag-muted { background: #f1f2f4; }
.tag-danger { background: var(--danger-bg); border-color: #fecaca; color: var(--danger-text); }
.tag-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* 8. Messages -------------------------------------------------------------- */
.notice { margin-bottom: 20px; padding: 11px 14px; border-radius: 8px; font-size: .9rem; text-align: left; }
.notice-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.notice-error   { background: var(--danger-bg); border: 1px solid #fecaca; color: var(--danger-text); }
.notice-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }

.empty {
  padding: 48px 24px; border: 1px dashed #cfd4da; border-radius: var(--radius);
  background: var(--surface); color: var(--muted); text-align: center;
}
.empty .icon { display: block; margin: 0 auto 10px; font-size: 36px; color: #b6bcc5; }

.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 1100;
  transform: translateX(-50%) translateY(8px);
  background: #111418; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: .9rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--primary-hover); }

/* 9. Fenêtres modales ------------------------------------------------------ */
.dialog {
  width: min(440px, calc(100vw - 32px)); margin: auto; padding: 24px; border: 0;
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 30px 70px -20px rgba(17, 20, 24, .45);
}
.dialog::backdrop { background: rgba(17, 20, 24, .45); }
.dialog-wide { width: min(600px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog h2 { font-size: 1.15rem; margin-bottom: 6px; }
.dialog-head h2 { margin-bottom: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* 10. Onglets, filtres, recherche ------------------------------------------ */
.module-tabs {
  display: flex; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  box-shadow: inset 0 -1px 0 var(--border); margin-bottom: 20px;
}
.module-tabs::-webkit-scrollbar { display: none; } /* défilement horizontal conservé, barre masquée */
.module-tabs a {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  border-bottom: 2px solid transparent; padding: 10px 14px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.module-tabs a:hover { color: var(--text); }
.module-tabs a.active { border-bottom-color: var(--primary); color: var(--text); font-weight: 600; }
.module-tabs .icon { font-size: 18px; }
.module-tabs a.active .icon { color: var(--primary); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters a {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: .88rem; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.filters a:hover { border-color: #cfd4da; color: var(--text); }
.filters a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.gallery-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.search { position: relative; flex: 1; max-width: 340px; }
.search input {
  width: 100%; border-radius: 999px; padding: 10px 12px 10px 38px;
  border: 1px solid var(--border); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }
.search-large { flex: 1 1 360px; max-width: 520px; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px;
  color: var(--muted); font-size: .9rem; text-decoration: none; transition: color .15s;
}
.back-link:hover { color: var(--primary); }
.back-link .icon { font-size: 16px; }

/* 11. En-tête de page ------------------------------------------------------ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.page-head h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.page-sub { color: var(--muted); margin-top: 4px; }

/* 12. Info-bulles ---------------------------------------------------------- */
.tip {
  position: fixed; z-index: 1000; max-width: 260px; padding: 6px 10px; border-radius: 7px;
  background: #16181d; color: #fff; font-size: .78rem; font-weight: 500; line-height: 1.3;
  box-shadow: 0 8px 20px -8px rgba(17, 20, 24, .45);
  pointer-events: none; opacity: 0; transform: translateY(3px);
  transition: opacity .12s ease, transform .12s ease;
}
.tip.is-dessous { transform: translateY(-3px); }
.tip.show { opacity: 1; transform: translateY(0); }

/* 13. Chrome « admin » : sidenav + topbar ---------------------------------- */
.sidenav {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: var(--sidenav-w);
  display: flex; flex-direction: column; padding: 20px 14px 14px;
  background: var(--surface); border-right: 1px solid var(--border);
  transition: transform .2s;
}
.sidenav-brand { display: block; padding: 0 8px; }
.sidenav-brand img { display: block; width: 100%; height: auto; }
.sidenav-app {
  margin: 14px 0 18px; padding: 0 12px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: #9aa1ad; font-weight: 600;
}
.sidenav-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidenav-nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
}
.sidenav-nav a:hover { background: var(--field); color: var(--text); }
.sidenav-nav a.active { background: var(--primary-soft); color: var(--primary-hover); font-weight: 600; }
.sidenav-nav a.active .icon { color: var(--primary); }
.sidenav-section {
  margin: 18px 0 6px; padding: 0 12px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: #9aa1ad;
}
.sidenav-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 4px 0 8px;
  border-top: 1px solid var(--border);
}
.sidenav-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sidenav-user > .icon { font-size: 32px; color: #cfd4da; }
.sidenav-user div { min-width: 0; }
.sidenav-user strong, .sidenav-user span {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidenav-user strong { font-size: .88rem; font-weight: 600; }
.sidenav-user span { font-size: .75rem; color: var(--muted); }

.sidenav-backdrop { display: none; }

.app-body { margin-left: var(--sidenav-w); min-height: 100vh; }
.topbar { display: none; }
.app-main { padding: 32px 32px 48px; }

/* Utilitaires de ligne / formulaire */
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.inline-form { display: inline; }
.switch-row { margin-top: 4px; font-size: .92rem; }

/* Cellule titre d'une ligne : libellé en gras + tag + note éventuelle */
.cell-title strong { margin-right: 6px; }
.cell-notes {
  display: block; max-width: 360px; margin-top: 2px; color: var(--muted); font-size: .82rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* En-tête de page enrichi (détail d'une campagne) */
.page-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }
.page-meta-stat { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .88rem; }
.page-meta-stat .icon { font-size: 17px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.section-head h2 { font-size: 1.15rem; font-weight: 600; }

/* Grille de cartes (campagnes, tournées) */
.tile-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
}
.tile {
  display: flex; flex-direction: column; gap: 10px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
a.tile:hover { border-color: #cfd4da; box-shadow: 0 10px 24px -16px rgba(17, 20, 24, .3); }
a.tile:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* Carte cliquable contenant aussi des boutons : le lien du titre couvre la carte,
   les .row-actions passent au-dessus */
.tile-clickable { position: relative; }
.tile-clickable:hover { border-color: #cfd4da; box-shadow: 0 10px 24px -16px rgba(17, 20, 24, .3); }
.tile-clickable:has(.tile-link:focus-visible) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tile-link { color: inherit; text-decoration: none; outline: none; }
.tile-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.tile-clickable .row-actions { position: relative; z-index: 1; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-title { font-size: 1.1rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tile-head .tile-title { font-size: 1.02rem; }
.tile-notes {
  color: var(--muted); font-size: .88rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-stats {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: .88rem;
}
.tile-stats span, .tile-count { display: inline-flex; align-items: center; gap: 6px; }
.tile-stats .icon, .tile-count .icon { font-size: 17px; color: var(--primary); }
.tile-count { color: var(--muted); font-size: .85rem; }
.tile-empty { font-size: .88rem; }

/* Puces (agents d'une tournée) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.chip {
  padding: 3px 10px; border-radius: 999px; background: var(--field);
  border: 1px solid var(--border); font-size: .82rem; font-weight: 500;
}

/* Champ de saisie en chips (agents d'une tournée) */
.chips-field .chips-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 6px 12px 8px; cursor: text;
}
.chips-box .chips { display: contents; }
.chips-field .chips-box input { flex: 1 1 140px; width: auto; min-width: 120px; height: 28px; padding: 0; }
.chip-removable { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; background: var(--surface); }
.chip-x {
  width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%;
  color: var(--muted); transition: background .15s, color .15s;
}
.chip-x .icon { font-size: 12px; }
.chip-x:hover, .chip-x:focus-visible { outline: none; background: var(--danger-bg); color: var(--primary-hover); }
.field-hint { margin: -6px 0 12px; color: var(--muted); font-size: .8rem; }
kbd {
  padding: 0 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  background: var(--surface); font: inherit; font-size: .75rem;
}

/* Onglet Souches : cartes de 25 feuillets avec saisie des montants */
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-chips .tag { padding: 4px 12px; font-size: .82rem; }
.souche-grid {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
}
.souche {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; scroll-margin-top: 80px;
}
.souche-head {
  display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 8px 12px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.souche-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.souche-id h3 { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.souche-progress {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: .82rem; white-space: nowrap;
}
.souche-progress strong { color: var(--text); }
.progress { flex: 1; min-width: 40px; height: 6px; border-radius: 999px; background: var(--field); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .2s; }

.souche-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.souche-table th, .souche-table td { padding: 3px 12px; text-align: left; }
.souche-table thead th {
  padding-block: 8px; background: var(--field); color: var(--muted);
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.souche-table tbody th { width: 1%; padding-right: 4px; font-weight: 700; white-space: nowrap; }
.souche-table .cb { width: 1%; text-align: center; }
.souche-table .cb input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.souche-table tfoot th, .souche-table tfoot td {
  padding-block: 10px; background: var(--field); border-top: 1px solid var(--border);
  font-weight: 700; white-space: nowrap;
}
.souche-table tfoot th { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.souche-table tfoot td.cb { color: var(--muted); font-size: .78rem; font-weight: 500; }

.montant-input {
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 6px; background: var(--field);
  transition: border-color .15s, background .15s, box-shadow .15s, opacity .15s;
}
.montant-input input {
  width: 100%; min-width: 0; padding: 5px 0; border: 0; background: transparent;
  text-align: right; font: inherit; font-variant-numeric: tabular-nums; outline: none;
}
.montant-input span { color: #b6bcc5; font-size: .85rem; }
.montant-input:focus-within { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
tr.is-rempli .montant-input { background: var(--surface); border-color: var(--border); }
tr.is-rempli .montant-input span { color: #16a34a; }
tr.is-saving .montant-input { opacity: .55; }
tr.is-saved .montant-input { animation: feuillet-ok 1.2s ease-out; }
tr.is-error .montant-input { border-color: var(--primary); background: var(--danger-bg); }
@keyframes feuillet-ok {
  from { border-color: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .25); }
  to   { box-shadow: 0 0 0 3px rgba(22, 163, 74, 0); }
}
.souche-save { padding: 12px 16px; border-top: 1px solid var(--border); text-align: right; }

/* Onglet Amicaweb : trois encarts (CB, espèces / chèque, nombre de calendriers) */
.amicaweb-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .amicaweb-grid { grid-template-columns: 1fr; } }
.amicaweb-bloc { margin-bottom: 0; }
.amicaweb-bloc .panel-title { margin-bottom: 4px; }
.amicaweb-aide { margin: 0 0 16px; font-size: .88rem; }
.amicaweb-valeur { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.amicaweb-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}

/* Onglet Caisse : liste des collectes et bordereau de collecte */
.cell-link { color: var(--text); font-weight: 600; text-decoration: none; }
.cell-link:hover { color: var(--primary); text-decoration: underline; }
.caisse-infos { display: grid; gap: 0 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.caisse-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.caisse-bloc { margin-bottom: 0; }
.caisse-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; margin-bottom: 16px; }
.caisse-table th, .caisse-table td { padding: 3px 8px; text-align: left; }
.caisse-table thead th {
  padding-block: 8px; background: var(--field); color: var(--muted);
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.caisse-table tbody th { font-weight: 600; white-space: nowrap; width: 30%; }
.caisse-table .num { text-align: right; white-space: nowrap; }
.caisse-table tbody td:first-of-type .montant-input { max-width: 160px; }
.caisse-table tfoot th, .caisse-table tfoot td {
  padding-block: 10px; background: var(--field); border-top: 1px solid var(--border); font-weight: 700;
}
.caisse-sep th {
  padding-top: 14px; color: var(--muted); font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.nb-input {
  width: 80px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--field); font: inherit; text-align: right; font-variant-numeric: tabular-nums;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.nb-input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.caisse-sous-total {
  display: flex; justify-content: space-between; padding: 12px 8px 0;
  border-top: 2px solid var(--border); font-weight: 600;
}
.caisse-synthese { margin-top: 14px; }
.caisse-chiffres { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.caisse-chiffres > div:not(.field) { display: flex; flex-direction: column; gap: 4px; }
.caisse-chiffres strong { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.caisse-total strong { font-size: 2rem; color: var(--primary-hover); }
.caisse-complement { margin-bottom: 0; }
.caisse-controle {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  margin-top: 16px; padding: 11px 14px; border-radius: 8px; font-weight: 600;
}
.caisse-controle.is-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.caisse-controle.is-ko { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.caisse-attendu { font-weight: 400; font-size: .85rem; opacity: .85; }
.caisse-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 14px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--page) 70%, transparent);
}
@media (max-width: 1000px) {
  .caisse-grid, .caisse-chiffres { grid-template-columns: 1fr; }
  .caisse-infos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) { .caisse-infos { grid-template-columns: 1fr; } }

/* Onglet Synthèse d'une tournée */
.kpi-grid + .synthese-grid { margin-top: 0; }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.synthese-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.synthese-grid .panel { margin-bottom: 20px; }
.synthese-table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.synthese-table th, .synthese-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.synthese-table tbody th { font-weight: 500; white-space: nowrap; }
.synthese-table tbody th .icon { margin-right: 8px; color: var(--muted); font-size: 17px; }
.synthese-table .num { text-align: right; white-space: nowrap; }
.synthese-table tfoot th, .synthese-table tfoot td { border-bottom: 0; font-weight: 700; }
.synthese-barre { width: 40%; }
.synthese-barre span { display: block; height: 6px; min-width: 0; border-radius: 999px; background: var(--primary); opacity: .75; }
.synthese-note { margin-top: 12px; color: var(--muted); font-size: .85rem; }
.synthese-chiffres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.synthese-chiffres dt { color: var(--muted); font-size: .85rem; }
.synthese-chiffres dd { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 1000px) { .synthese-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .synthese-barre { display: none; } }

/* Onglet Dépôt banque */
.depot-bloc .panel-title { justify-content: flex-start; }
.depot-total { margin-left: auto; font-variant-numeric: tabular-nums; }
.depot-bloc .table-wrap { margin: 0 -24px -24px; border-top: 1px solid var(--border); }
.depot-table td { vertical-align: middle; }
.depot-table .dim { font-size: .82rem; }
.depot-input {
  width: 100%; min-width: 120px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--field); font: inherit; font-size: .88rem;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.depot-input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
a.tag { text-decoration: none; }
@media (max-width: 760px) { .depot-bloc .table-wrap { margin: 0 -24px -24px; } }

/* Page Dépôts banque (toutes les tournées) */
.campagne-select { display: flex; align-items: flex-end; gap: 8px; }
.campagne-select .field { min-width: 200px; }
.kpi-alerte { display: inline-flex; align-items: center; gap: 4px; color: var(--danger-text); font-weight: 600; }
.kpi-alerte .icon { font-size: 14px; }
.panel .table-wrap.table-flat { margin: 0 -24px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.panel .depot-recap-wrap { margin-bottom: -24px; border-bottom: 0; }
.depot-recap-attente td { background: #fffbeb; }
.depot-filtres { align-items: flex-end; }
.depot-filtres-droite { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.depot-filtres .field select { height: 33px; }
.depot-compte { margin-bottom: 10px; color: var(--muted); font-size: .88rem; }
.depot-suivi .sel { width: 1%; }
.depot-suivi .sel input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.depot-suivi tr.is-selected td { background: color-mix(in srgb, var(--primary) 6%, #fff); }
.depot-suivi td .icon { font-size: 16px; color: var(--muted); }
.depot-bulk {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin: 0 -24px -24px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--field); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  transition: background .15s, box-shadow .15s;
}
.depot-bulk.is-active { background: var(--surface); box-shadow: 0 -10px 24px -18px rgba(17, 20, 24, .4); }
.depot-bulk-info { flex: 1 1 100%; color: var(--muted); font-size: .88rem; }
.depot-bulk.is-active .depot-bulk-info { color: var(--text); font-weight: 600; }
.depot-bulk .field { min-width: 160px; }
@media (max-width: 760px) {
  .depot-suivi .sel { grid-column: 2; grid-row: 1; justify-self: end; }
  .campagne-select .field { min-width: 0; flex: 1; }
}

/* Onglet Grands donateurs */
.donateurs-a-saisir { border-color: #fde68a; background: #fffdf5; }
.donateurs-a-saisir .panel-title .icon { color: #d97706; }
.donateurs-a-saisir .page-sub { margin: -8px 0 14px; font-size: .88rem; }
.feuillets-a-saisir { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.feuillet-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 12px;
  border: 1px solid #fde68a; border-radius: 999px; background: var(--surface); font-size: .85rem;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.feuillet-chip span { color: var(--muted); }
.feuillet-chip .icon { font-size: 15px; color: #d97706; }
.feuillet-chip:hover, .feuillet-chip:focus-visible { outline: none; border-color: #d97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, .15); }
.donateur-adresse { display: block; color: var(--muted); font-size: .84rem; }
.donateurs-table td .dim { font-size: .82rem; margin-left: 4px; }
.donateurs-table .tag + .tag { margin-left: 4px; }
.pill-btn { padding: 0; border-radius: 999px; transition: box-shadow .15s; }
.pill-btn:hover, .pill-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.donateur-suites { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 14px; padding: 0; border: 0; }
.donateur-suites legend { width: 100%; margin-bottom: 6px; font-size: .72rem; color: var(--muted); }
.donateur-suites .check { font-size: .92rem; }
.donateur-ville { grid-template-columns: 1fr 2fr; }

/* Historique */
.journal-filtres { align-items: flex-end; }
.journal-selects { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.journal-selects .field select { height: 33px; }
.journal-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.journal-table td .tag { margin-left: 4px; }
.journal-details { margin-top: 4px; font-size: .85rem; }
.journal-details summary { cursor: pointer; color: var(--muted); }
.journal-details table { margin-top: 6px; border-collapse: collapse; }
.journal-details th, .journal-details td { padding: 2px 10px 2px 0; text-align: left; vertical-align: top; }
.journal-details th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.journal-avant { color: var(--muted); text-decoration: line-through; }
.journal-filtre-lien { margin-left: 4px; color: var(--muted); }
.journal-filtre-lien .icon { font-size: 15px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; color: var(--muted); font-size: .9rem; }
.sidenav-nav .sidenav-section:first-child { margin-top: 0; }

/* 14. Responsive ----------------------------------------------------------- */
@media (max-width: 1000px) {
  .app-main { padding: 24px 24px 40px; }
}

@media (max-width: 768px) {
  .sidenav { transform: translateX(-100%); box-shadow: none; }
  .sidenav-open .sidenav { transform: translateX(0); box-shadow: 0 0 40px rgba(17, 20, 24, .25); }
  .sidenav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(17, 20, 24, .45); opacity: 0; pointer-events: none;
    transition: opacity .2s;
  }
  .sidenav-open .sidenav-backdrop { opacity: 1; pointer-events: auto; }
  .sidenav-open { overflow: hidden; }

  .app-body { margin-left: 0; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px; padding: 8px 12px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar-logo { height: 36px; width: auto; }
  .app-main { padding: 20px 16px 32px; }

  .page-head { align-items: flex-start; }
  .dialog { padding: 20px; }
}

@media (max-width: 760px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }

  /* .table-cards : chaque ligne devient une carte empilée, libellés .ref-lib affichés */
  .table-cards thead { display: none; }
  .table-cards tbody tr {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
  }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { padding: 0; border: 0; grid-column: 1; }
  .table-cards td.num { text-align: left; width: auto; }
  .table-cards td.actions { grid-column: 2; grid-row: 1 / span 10; align-self: start; width: auto; }
  .table-cards .ref-lib { display: block; }
  .cell-notes { white-space: normal; }
}

@media (max-width: 480px) {
  .card { padding: 32px 20px; }
}

@media (pointer: coarse) {
  .field input, .field select, .field textarea, .search input, .montant-input input, .nb-input, .depot-input { font-size: 16px !important; }
}

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