:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #16221a;
  --ink-soft: #5b6b5f;
  --line: #e2e7df;
  --brand: #1f7a44;
  --brand-dark: #175c34;
  --brand-soft: #e8f4ec;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warn: #a35c00;
  --warn-soft: #fff4e0;
  --info: #0b5aa1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(18, 38, 24, .06), 0 8px 24px rgba(18, 38, 24, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--brand); text-decoration: none; }

.fa-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; min-height: 100vh; color: var(--ink-soft); font-size: .95rem;
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid var(--brand-soft); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Layout ---------------- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: -.02em; font-size: 1.05rem; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, #2f9c5a, #14663a); color: #fff; font-size: 1rem;
}
.brand small { display: block; font-weight: 500; font-size: .68rem; color: var(--ink-soft); letter-spacing: .04em; text-transform: uppercase; }
/* Logo image televerse : elle remplit le carre en restant nette et arrondie. */
.brand .logo .logo-img,
.login-card .logo-lg .logo-img {
  width: 100%; height: 100%; object-fit: contain; border-radius: inherit; display: block;
}
.topbar-spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: .55rem;
  background: var(--brand-soft); border: 1px solid #cfe6d8;
  padding: .35rem .6rem .35rem .4rem; border-radius: 999px; font-size: .82rem;
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700;
}
.user-chip .role { color: var(--ink-soft); font-size: .7rem; }

.main { flex: 1; padding: 1.1rem 1.1rem 8.5rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------------- Dock permanent ---------------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(18, 38, 24, .07);
  padding: .5rem .4rem .4rem;
}
.dock-scroll {
  display: flex; gap: .35rem; overflow-x: auto; padding: .1rem .3rem .25rem;
  scrollbar-width: thin; justify-content: center;
}
.dock-item {
  flex: 0 0 auto; width: 92px; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .45rem .2rem .35rem; border-radius: 14px; color: var(--ink-soft);
  transition: background .15s ease, transform .15s ease;
}
.dock-item:hover { background: var(--bg); }
.dock-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.dock-icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.15rem; color: #fff; background: var(--ink-soft);
  box-shadow: 0 4px 10px rgba(18, 38, 24, .14);
}
.dock-item .label { font-size: .68rem; font-weight: 600; text-align: center; line-height: 1.15; }
.dock-item .lock { font-size: .6rem; color: var(--ink-soft); opacity: .8; }
/* Point 2 : un pole non attribue au profil est grise et non cliquable */
.dock-item.locked { cursor: not-allowed; opacity: .55; }
.dock-item.locked:hover { background: transparent; }
.dock-item.locked .dock-icon { filter: grayscale(1); box-shadow: none; }
.dock-item.locked .lock { color: #b23b3b; opacity: 1; }

/* ---------------- Cards / grids ---------------- */
.grid { display: grid; gap: .85rem; }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }

/* Les poles de la ferme : TROIS tuiles par ligne sur grand ecran. La ferme en
   compte sept, donc 3 + 3 + 1 se lit mieux qu'une repartition automatique qui
   en alignait jusqu'a six et laissait des trous. Les paliers plus bas
   (tablette, mobile) sont definis dans les media queries, avec la MEME
   specificite — un selecteur d'id (#pole-cards) l'emporte sinon sur
   `.grid.cols-auto` et la regle mobile ne s'appliquerait jamais.
   `minmax(0, 1fr)` et non `1fr` : la colonne peut descendre sous la largeur
   naturelle de son contenu au lieu de deborder. */
#pole-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Les cartes d'« Infos du jour » contiennent des tableaux. Un enfant de grille
   a par defaut `min-width: auto` : la largeur mini de la TABLE (8 colonnes,
   en-tetes en nowrap) imposait donc sa loi a la colonne, la grille s'elargissait
   et TOUTE LA PAGE defilait horizontalement. `min-width: 0` rend la main au
   `.table-wrap`, qui defile alors a l'interieur de la carte.
   Plafonnees a deux colonnes : au-dela, deux tableaux cote a cote ne se lisent
   plus. Les paliers mobile sont dans les media queries. */
#infos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#infos > * { min-width: 0; }

/* Meme cause ailleurs : toute carte posee dans une grille ou un flex peut etre
   elargie par un tableau qu'elle contient. On la laisse toujours se resserrer. */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin: 0 0 .55rem; font-size: .95rem; display: flex; align-items: center; gap: .45rem; }
.card h3 i { color: var(--brand); }
.muted { color: var(--ink-soft); }
.small { font-size: .78rem; }
.tiny { font-size: .7rem; }

/* ---------------- Bandeau de rappel ---------------- */
/* Rappel hebdomadaire du pole Commercial, affiche avec les « infos du jour ».
   Il vit DANS la grille des cartes : `grid-column: 1/-1` lui donne toute la
   largeur, sinon il n'occuperait qu'une seule case et se lirait comme une
   carte parmi les autres. */
.market-reminder {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .9rem; border-radius: var(--radius);
  border: 1px solid; font-size: .82rem; line-height: 1.35;
}
.market-reminder i { font-size: 1rem; flex: none; }
.market-reminder strong { font-weight: 600; }
/* Releve du : accent sur l'action attendue. */
.market-reminder.due {
  background: #fff6e6; border-color: #f0cf94; color: #7a4a00;
}
.market-reminder.due i { color: var(--warn); }
/* Releve a jour : present, mais discret — il ne doit pas crier. */
.market-reminder.ok {
  background: var(--brand-soft); border-color: #bfe0cc; color: #1c5c37;
}
.market-reminder.ok i { color: var(--brand); }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin: 1.4rem 0 .7rem;
}
.section-title h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.section-title .hint { font-size: .78rem; color: var(--ink-soft); }

/* ---------------- Hero pole ---------------- */
.pole-hero {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  border-radius: 20px; padding: 1.1rem 1.2rem; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.pole-hero .big-icon {
  width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center;
  font-size: 1.6rem; background: rgba(255, 255, 255, .16);
}
.pole-hero h1 { margin: 0; font-size: 1.3rem; letter-spacing: -.02em; }
.pole-hero p { margin: .2rem 0 0; font-size: .82rem; opacity: .9; max-width: 60ch; }
.pole-hero .hero-actions { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------------- KPI ---------------- */
.kpi-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: .75rem .85rem; display: flex; flex-direction: column; gap: .2rem;
}
.kpi .k-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.kpi .k-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -.03em; }
.kpi .k-sub { font-size: .7rem; color: var(--ink-soft); }
.kpi.alert { background: var(--warn-soft); border-color: #f2d9ad; }
.kpi.alert .k-value { color: var(--warn); }

/* ---------------- Action tiles (mode pole) ---------------- */
.actions-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.action-tile {
  border: 1px solid var(--line); background: var(--surface); border-radius: 16px;
  padding: .95rem .7rem; display: flex; flex-direction: column; align-items: center; gap: .45rem;
  cursor: pointer; text-align: center; transition: transform .14s ease, box-shadow .14s ease, border-color .14s;
  box-shadow: var(--shadow);
}
.action-tile:hover { transform: translateY(-2px); border-color: #c9dccd; }
.action-tile .t-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.15rem;
  background: var(--brand-soft); color: var(--brand-dark);
}
.action-tile .t-label { font-size: .8rem; font-weight: 650; line-height: 1.2; }
.action-tile .t-count { font-size: .68rem; color: var(--ink-soft); }

/* ---------------- Modules du pole : deux colonnes ---------------- */
/* Colonne de gauche = modules du quotidien, colonne de droite = les autres.
   Les tuiles gardent leur PRESENTATION D'ORIGINE (icone au-dessus du libelle,
   tuile centree). Seule la largeur des deux colonnes change : elle est
   proportionnelle au nombre de tuiles qu'elles contiennent, donc
   6 tuiles + 5 tuiles donnent 6fr / 5fr. Aucun libelle de colonne : la
   distinction se lit dans le fond (vert a gauche, beige a droite). */
.modules-cols {
  display: grid;
  grid-template-columns: var(--mod-cols, 1fr 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mod-col {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: .8rem .7rem .85rem;
  min-width: 0;
}
/* Colonne du quotidien : tres leger voile vert (meme famille que la marque) */
.mod-col.daily { background: #f4faf6; }
/* Colonne des autres modules : voile beige, meme nuance douce */
.mod-col.others {
  background: #fdf9f0;
  border-left: 1px solid #ece4d4;
}
/* Tuiles : grille identique a la presentation d'origine */
.mod-tiles {
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}
/* Quotidien : fond d'icone vert (couleur de la marque) */
.mod-col.daily .action-tile .t-icon { background: var(--brand-soft); color: var(--brand-dark); }
/* Autres : fond d'icone beige, plus chaud que le vert, meme douceur */
.mod-col.others .action-tile .t-icon { background: #f6ecd8; color: #8a6417; }

/* ---------------- Activity list ---------------- */
.activity-list { display: flex; flex-direction: column; gap: .5rem; }
.activity-row {
  display: flex; align-items: flex-start; gap: .7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: .7rem .8rem;
}
.activity-row.late { border-color: #f0c9c4; background: var(--danger-soft); }
.activity-row.done { opacity: .62; }
.activity-row .check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid #c3d2c7; background: #fff;
  display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; color: transparent; font-size: .75rem;
}
.activity-row.done .check { background: var(--brand); border-color: var(--brand); color: #fff; }
.activity-row .a-title { font-weight: 650; font-size: .87rem; }
.activity-row .a-meta { font-size: .73rem; color: var(--ink-soft); display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .15rem; }
.activity-row .a-body { flex: 1; min-width: 0; }
/* Point 3 : noms des agents affectes a l'action du jour */
.agent-tags { display: inline-flex; align-items: center; gap: .28rem; flex-wrap: wrap; }
.agent-tag {
  display: inline-block; padding: .04rem .4rem; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: .68rem; font-weight: 650; line-height: 1.5; white-space: nowrap;
}
.agent-tag.none { background: #f2f4f2; color: var(--ink-soft); font-weight: 500; }

/* ---------------- Barre d'outils des tableaux ---------------- */
.table-tools {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; flex-wrap: wrap; margin-bottom: .55rem;
}
.table-tools .tb-actions { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Ligne de filtres sous les entetes */
table.data tr.filter-row th { background: #f6f9f4; padding: .3rem .4rem; }
table.data tr.filter-row th input {
  width: 100%; min-width: 72px; padding: .28rem .45rem;
  border: 1px solid #d8e0d6; border-radius: 7px;
  font-size: .74rem; font-weight: 500; text-transform: none; letter-spacing: 0;
  background: #fff; color: var(--ink);
}
table.data tr.filter-row th input:focus {
  outline: 2px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand);
}

/* ---------------- Categorie d'activite ---------------- */
.cat-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .42rem; border-radius: 999px;
  font-size: .68rem; font-weight: 650; white-space: nowrap;
}
.cat-icon {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 9px;
  font-size: .74rem; color: #fff;
}
.activity-row .a-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }

/* ---------------- Note vocale ---------------- */
.audio-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand-soft); color: var(--brand-dark); font-size: .76rem;
  flex: 0 0 auto;
}
.audio-btn:hover { background: var(--brand); color: #fff; }
.audio-btn.playing { background: var(--brand); color: #fff; }

.rec-bar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .5rem .6rem; border: 1px dashed #c9d6c9; border-radius: 10px;
  background: #fafcf8;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #c0392b; flex: 0 0 auto;
}
.rec-dot.live { animation: recpulse 1s infinite; }
@keyframes recpulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .8rem; }
.rec-hint { font-size: .72rem; color: var(--ink-soft); }
.audio-preview { width: 100%; max-width: 320px; height: 34px; }


/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.data th, table.data td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #fafbf8; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbfcfa; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .row-actions { display: flex; gap: .3rem; }
/* Element reserve a l'affichage telephone (badge « Entree / Sortie » du
   tableau des mouvements : sur grand ecran, les colonnes le disent deja). */
table.data .mob-only { display: none; }

/* ---------------- Aide contextuelle dans les tableaux ----------------
   Un petit "i" signale qu'un en-tete porte une explication (attribut title).
   Le texte complementaire reste accessible aux lecteurs d'ecran (.sr-only)
   et une legende visible est affichee sous le tableau : pas de dependance a
   une infobulle au survol, qui serait rognee par le overflow-x de .table-wrap. */
.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;
}

table.data th .th-help {
  font-size: .6rem; opacity: .45; margin-left: .2rem;
  vertical-align: baseline; cursor: help;
}
table.data th:hover .th-help { opacity: .9; }
table.data th[title] { cursor: help; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .68rem; font-weight: 650;
  padding: .16rem .45rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark);
  white-space: nowrap;
}
.badge.gray { background: #eef1ec; color: var(--ink-soft); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: #e5f0fb; color: var(--info); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  padding: .5rem .8rem; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #f7f9f5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f0c9c4; background: var(--danger-soft); }
.btn.sm { padding: .3rem .55rem; font-size: .74rem; border-radius: 8px; }
.btn.icon { padding: .38rem; width: 30px; height: 30px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.field label { font-size: .74rem; font-weight: 650; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1px solid #d8e0d6; border-radius: 10px; padding: .5rem .6rem; background: #fff;
  font-size: .85rem; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(31, 122, 68, .22); border-color: var(--brand);
}
.field textarea { min-height: 62px; resize: vertical; }
/* Variante en ligne : libelle et champ cote a cote. Utilisee sur l'ecran de
   connexion par code pour gagner de la hauteur (le libelle n'occupe plus sa
   propre ligne). Le champ garde toute la largeur restante. */
.field.field-inline { flex-direction: row; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.field.field-inline label { flex: 0 0 auto; white-space: nowrap; font-size: .8rem; }
.field.field-inline input { flex: 1 1 auto; width: auto; min-width: 0; }
.form-grid { display: grid; gap: 0 .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 28, 20, .45); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 720px) { .modal-backdrop { align-items: center; padding: 1.5rem; } }
.modal {
  background: var(--surface); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; box-shadow: 0 24px 60px rgba(10, 24, 15, .3);
  display: flex; flex-direction: column;
}
@media (min-width: 720px) { .modal { border-radius: 18px; } }
.modal-head {
  display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem .7rem;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.modal-body { padding: 1rem 1.1rem; }
.modal-foot {
  display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem 1.1rem;
  border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface);
}

/* ---------------- Login ---------------- */
/* La carte est collee en haut (align-content: start) : la page de connexion
   n'a plus de grande marge vide au-dessus, ce qui laisse toute la hauteur
   disponible au formulaire sur les petits ecrans. */
.login-wrap { display: grid; place-items: center; align-content: start; min-height: 100vh; padding: .5rem 1.2rem 1.2rem; }
.login-card {
  width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 1.7rem 1.6rem; box-shadow: 0 18px 50px rgba(18, 38, 24, .1);
}
.login-card .logo-lg {
  width: 56px; height: 56px; border-radius: 17px; display: grid; place-items: center;
  background: linear-gradient(140deg, #2f9c5a, #14663a); color: #fff; font-size: 1.4rem;
}
.login-card .logo-lg .logo-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* En-tete de la connexion : logo a gauche, nom et slogan a droite */
.login-head {
  display: flex; align-items: center; gap: .85rem; margin-bottom: .9rem;
}
.login-head-text { min-width: 0; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 .15rem; letter-spacing: -.02em; }
.tabs { display: flex; gap: .3rem; background: var(--bg); padding: .3rem; border-radius: 12px; margin: 1rem 0; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: .6rem .4rem; border-radius: 9px;
  font-size: .88rem; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.login-hint { font-size: .72rem; color: var(--ink-soft); margin-top: .9rem; line-height: 1.5; }
.login-submit { width: 100%; padding: .8rem; font-size: .95rem; }

/* ---------------- Meteo de la page de connexion ----------------
   Ajout purement informatif, sous le formulaire. Il ne doit jamais
   prendre la place de la connexion : d'ou une taille modeste et un
   retrait net au-dessus. Quand l'API ne repond pas, le bloc est
   masque (`hidden`) et ne laisse aucun trou dans la carte. */
.login-weather {
  margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line);
}
.login-weather[hidden] { display: none; }
.wx-head {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft);
  display: flex; align-items: center; gap: .4rem; margin-bottom: .5rem;
}
.wx-head i { color: var(--brand); }
/* Releve du moment : temperature ET humidite actuelles. L'humidite
   moyenne d'une journee ne dit pas ce qu'il fait dehors maintenant,
   d'ou cette ligne separee, mise en avant. */
.wx-now {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid #cfe6d8;
  border-radius: 10px; padding: .4rem .55rem; margin-bottom: .4rem;
  font-size: .8rem;
}
.wx-now i { color: var(--brand); font-size: .95rem; flex: 0 0 auto; }
.wx-now > span:first-of-type { font-weight: 600; }
.wx-now-label { color: var(--ink-soft); font-size: .72rem; margin-left: auto; }
.wx-days { display: grid; gap: .3rem; grid-template-columns: 1fr 1fr; }
.wx-day {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .35rem .5rem;
  font-size: .76rem; min-width: 0;
}
.wx-day-name { color: var(--ink-soft); font-size: .7rem; flex: 0 0 auto; }
.wx-icon { color: var(--info); font-size: .95rem; flex: 0 0 auto; }
.wx-temp { font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
/* Metriques (humidite, pluie) : sur leur propre ligne sous le nom du jour,
   pour que deux mesures ne se compriment pas dans une case etroite. */
.wx-metrics { display: flex; align-items: center; gap: .5rem; width: 100%; }
.wx-metric {
  color: var(--info); font-size: .68rem; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .2rem;
  font-variant-numeric: tabular-nums;
}
.wx-metric i { font-size: .62rem; }
.wx-src { font-size: .62rem; color: var(--ink-soft); margin-top: .45rem; }
.pole-picker { display: grid; gap: .55rem; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin-bottom: .9rem; }
.pole-pick {
  border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: .85rem .4rem;
  display: flex; flex-direction: column; align-items: center; gap: .45rem; cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--ink);
}
.pole-pick .pi { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; color: #fff; font-size: 1.5rem; }
.pole-pick.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(31, 122, 68, .18); }

/* Selection des jours de la semaine (frequence multi-jours) */
.day-picker {
  display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .25rem;
}
.day-pick {
  display: flex; align-items: center; gap: .3rem; border: 1px solid var(--line);
  border-radius: 10px; padding: .4rem .55rem; background: #fff; cursor: pointer;
  font-size: .78rem; font-weight: 650; color: var(--muted, #6b7280);
  user-select: none;
}
.day-pick input { accent-color: var(--brand); margin: 0; }
.day-pick:has(input:checked) {
  background: var(--brand-soft, #ecfdf5);
  border-color: var(--brand);
  color: var(--brand);
}

.pin-input {
  text-align: center; letter-spacing: .9em; font-size: 1.6rem; font-weight: 800;
  padding: .5rem 0 .5rem .9em; border-radius: 14px; border: 1px solid #d8e0d6; width: 100%;
}

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; top: 1rem; right: 1rem; z-index: 120; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: #16221a; color: #fff; padding: .6rem .85rem; border-radius: 11px;
  font-size: .82rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 340px;
  animation: toastIn .2s ease;
}
.toast.error { background: #7f1d1d; }
.toast.ok { background: #14532d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------------- Alerte centrale ----------------
   Les erreurs s'affichent au CENTRE de l'ecran, au-dessus de tout (y
   compris des fenetres de saisie, z-index 90, et des bandeaux, 120) :
   elles ne doivent jamais passer inapercues.
   Fermeture par la croix, le bouton, un clic hors de la fenetre ou Echap. */
.alert-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(16, 28, 20, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: alertFade .15s ease;
}
.alert-box {
  background: var(--surface); width: 100%; max-width: 460px;
  border-radius: 18px; overflow: hidden;
  border-top: 5px solid var(--danger);
  box-shadow: 0 24px 60px rgba(10, 24, 15, .42);
  animation: alertPop .18s ease;
}
.alert-head {
  display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1rem .4rem;
}
.alert-icon {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem;
  background: var(--danger-soft); color: var(--danger);
}
.alert-head h2 {
  margin: 0; font-size: 1.02rem; font-weight: 800; color: var(--ink);
  flex: 1; min-width: 0;
}
.alert-close {
  border: 0; background: transparent; color: var(--ink-soft);
  font-size: 1.05rem; line-height: 1; padding: .4rem; border-radius: 9px;
  cursor: pointer; flex: 0 0 auto;
}
.alert-close:hover { background: #f1f3f0; color: var(--ink); }
.alert-body {
  padding: .2rem 1rem 1.1rem;
  font-size: .9rem; line-height: 1.45; color: var(--ink);
  /* Un message long reste lisible sans faire deborder la fenetre. */
  max-height: 45vh; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.alert-foot {
  display: flex; justify-content: flex-end;
  padding: 0 1rem 1rem;
}
@keyframes alertFade { from { opacity: 0; } }
@keyframes alertPop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---------------- Admin ERP ---------------- */
.admin-shell { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 980px) { .admin-shell { grid-template-columns: 230px 1fr; align-items: start; } }
.admin-nav {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .5rem;
  display: flex; gap: .3rem; overflow-x: auto;
}
@media (min-width: 980px) {
  .admin-nav { flex-direction: column; position: sticky; top: 76px; overflow: visible; }
}
.admin-nav button {
  border: 0; background: transparent; text-align: left; padding: .55rem .7rem; border-radius: 10px;
  font-size: .83rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: .55rem;
}
.admin-nav button.active { background: var(--brand-soft); color: var(--brand-dark); }
.admin-nav button i { width: 18px; text-align: center; }

.empty {
  padding: 1.4rem; text-align: center; color: var(--ink-soft); font-size: .84rem;
  border: 1px dashed #d5ded3; border-radius: 13px; background: #fbfcf9;
}
.readonly-note {
  display: flex; align-items: center; gap: .5rem; background: #eef0f7; color: #3b4a63;
  border: 1px solid #d8ddec; border-radius: 11px; padding: .5rem .7rem; font-size: .78rem; margin-bottom: .8rem;
}
.bar { height: 7px; border-radius: 99px; background: #edf1ea; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.flow-line { display: flex; align-items: center; gap: .5rem; font-size: .8rem; padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.flow-line:last-child { border-bottom: 0; }
.flow-line .arrow { color: var(--brand); }

/* ==========================================================
   RESPONSIVE
   Trois paliers : tablette (<= 980px), mobile large (<= 720px),
   petit mobile (<= 420px). Objectif : aucun debordement horizontal
   et des cibles tactiles d'au moins 40px.
   ========================================================== */

/* Ecrans intermediaires : le dock reste lisible, les grilles se resserrent */
@media (max-width: 980px) {
  .main { max-width: 100%; }
  .grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@media (max-width: 720px) {
  /* --- Structure generale --- */
  body { font-size: .95rem; }
  .main { padding: .9rem .8rem 7.5rem; }
  .app-shell { min-height: 100dvh; }

  /* --- Barre du haut : le titre ne doit pas pousser les boutons hors ecran --- */
  .topbar { padding: .55rem .7rem; gap: .5rem; }
  .topbar .brand { min-width: 0; }
  .topbar .brand > span:last-child {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar .brand span:not(.icon) { font-size: .95rem; }
  .topbar-spacer { display: none; }
  .user-chip { margin-left: auto; font-size: .78rem; padding: .3rem .45rem .3rem .35rem; }
  .user-chip .avatar { width: 26px; height: 26px; font-size: .7rem; }
  .topbar .btn.sm { padding: .45rem .55rem; }
  /* Sur mobile, seul le libelle "Accueil" disparait : l'icone reste cliquable */
  .topbar [data-home] { font-size: 0; gap: 0; padding: .45rem .55rem; }
  .topbar [data-home] i { font-size: .95rem; }

  /* --- Dock : defilement horizontal fluide, cibles tactiles --- */
  .dock { padding: .4rem .3rem calc(.35rem + env(safe-area-inset-bottom, 0px)); }
  .dock-scroll { justify-content: flex-start; gap: .2rem; -webkit-overflow-scrolling: touch; }
  .dock-item { width: 76px; padding: .4rem .15rem .3rem; }
  .dock-icon { width: 42px; height: 42px; font-size: 1.05rem; border-radius: 12px; }
  .dock-item .label { font-size: .64rem; }
  .dock-item .lock { display: none; }

  /* --- Grilles : colonnes adaptatives, sans minmax trop large --- */

  /* --- Grilles : une seule colonne sur mobile, sans minmax trop large --- */
  .grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
  .grid.two { grid-template-columns: 1fr; }
  /* Paliers des grilles a selecteur d'id. Ils DOIVENT etre repetes ici : un
     selecteur d'id l'emporte sur une classe quelle que soit l'ordre, donc
     `#pole-cards` / `#infos` ignoreraient silencieusement les deux lignes
     ci-dessus. Sur telephone, « Infos du jour » repasse a UNE colonne et les
     poles a deux tuiles. */
  #pole-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #infos { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .55rem; }
  .actions-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .55rem; }
  /* Deux colonnes trop serrees sur mobile : on empile, et le trait
     separateur devient horizontal. */
  .modules-cols { grid-template-columns: 1fr; }
  .mod-col.others {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .mod-col { padding: .6rem .55rem; }
  /* Trois colonnes de modules meme sur mobile : tuiles compactes */
  .mod-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
  .mod-tiles .action-tile {
    padding: .55rem .25rem .5rem; gap: .3rem; border-radius: 12px;
  }
  .mod-tiles .action-tile .t-icon { width: 34px; height: 34px; font-size: .92rem; border-radius: 10px; }
  .mod-tiles .action-tile .t-label { font-size: .68rem; line-height: 1.15; }
  .mod-tiles .action-tile .t-count { font-size: .6rem; }

  /* --- Titres de section : passent a la ligne au lieu de deborder --- */
  .section-title { flex-wrap: wrap; gap: .25rem; margin: 1.1rem 0 .6rem; }
  .section-title h2 { font-size: 1rem; }
  .section-title .hint { font-size: .72rem; }

  /* --- Hero de pole --- */
  .pole-hero { padding: .9rem .95rem; border-radius: 16px; gap: .75rem; }
  .pole-hero .big-icon { width: 48px; height: 48px; border-radius: 14px; font-size: 1.25rem; }
  .pole-hero h1 { font-size: 1.1rem; }
  .pole-hero p { font-size: .78rem; }
  .pole-hero .hero-actions { margin-left: 0; width: 100%; }

  /* --- Cartes et tuiles --- */
  .card { padding: .85rem; border-radius: 14px; }
  .action-tile { padding: .8rem .5rem; border-radius: 14px; }
  .action-tile .t-icon { width: 42px; height: 42px; font-size: 1.05rem; }

  /* --- Lignes d'activite : le bouton de validation reste accessible --- */
  .activity-row { gap: .55rem; padding: .6rem .65rem; }
  .activity-row .a-title { font-size: .83rem; }
  .activity-row .check { width: 32px; height: 32px; }

  /* --- Tableaux : defilement horizontal + premiere colonne lisible --- */
  .table-wrap { border-radius: 11px; }
  table.data { font-size: .78rem; }
  table.data th, table.data td { padding: .5rem .55rem; }
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* --- Tableau « Mouvements de stock du jour » : format FICHE ---
     Ce tableau a 7 ou 8 colonnes : illisible et defilant sur un telephone.
     On abandonne donc la presentation tabulaire et chaque LIGNE devient une
     fiche : le nom du produit en tete, puis un couple « libelle / valeur »
     par information. Aucun defilement lateral, aucune colonne rognee.

     Le passage se fait uniquement par la presentation (`display`), le
     balisage HTML reste un vrai <table> : sur grand ecran, rien ne change. */
  .wrap-stack { overflow-x: visible; border: 0; background: transparent; }
  table.data.stack { font-size: .82rem; }
  table.data.stack thead { display: none; }
  table.data.stack,
  table.data.stack tbody,
  table.data.stack tr,
  table.data.stack td { display: block; width: 100%; }

  /* Une fiche par mouvement */
  table.data.stack tbody tr {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 13px; padding: .5rem .65rem .55rem; margin-bottom: .5rem;
  }
  table.data.stack tbody tr:last-child { margin-bottom: 0; }
  table.data.stack tbody tr:hover { background: var(--surface); }

  /* Ligne d'information : libelle a gauche, valeur a droite */
  table.data.stack td {
    border: 0; padding: .2rem 0; display: flex; align-items: baseline;
    justify-content: space-between; gap: .75rem; text-align: right;
  }
  table.data.stack td::before {
    content: attr(data-label);
    flex: 0 0 auto; font-size: .68rem; font-weight: 650; text-transform: uppercase;
    letter-spacing: .04em; color: var(--ink-soft); text-align: left;
  }
  /* Les nombres ne sont plus contraints au nowrap : la valeur peut revenir
     a la ligne plutot que d'elargir la fiche. */
  table.data.stack td.num { white-space: normal; }

  /* En-tete de fiche : le produit, souligne, sans son libelle */
  table.data.stack td.cell-main {
    display: block; text-align: left; padding: 0 0 .35rem;
    margin-bottom: .3rem; border-bottom: 1px solid var(--line);
  }
  table.data.stack td.cell-main::before { content: none; }
  table.data.stack td.cell-main strong { font-size: .9rem; }
  /* Le badge « Entree / Sortie » n'a de sens que dans la fiche : sur grand
     ecran, les colonnes Entrees / Sorties le disent deja. */
  table.data .mob-only { display: inline-flex; margin-left: .4rem; }

  /* Colonne inutilisee par ce sens de mouvement (« — ») : inutile dans une
     fiche, elle ne ferait qu'allonger. */
  table.data.stack td.hide-mobile { display: none; }

  /* --- Modales : plein ecran en bas, boutons atteignables --- */
  .modal { max-height: 94dvh; }
  .modal-head { padding: .85rem .9rem .6rem; }
  .modal-body { padding: .85rem .9rem; }
  .modal-foot {
    padding: .7rem .9rem calc(.85rem + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .modal-foot .btn { flex: 1 1 auto; min-height: 42px; }

  /* --- Formulaires : champs plus hauts pour le tactile --- */
  .field input, .field select, .field textarea { padding: .6rem .65rem; font-size: .9rem; }
  .btn { min-height: 38px; }
  .btn.sm { min-height: 30px; }

  /* --- Connexion --- */
  .login-wrap { padding: .3rem .7rem .8rem; align-items: start; align-content: start; }
  .login-card { padding: 1rem .9rem; border-radius: 18px; margin-top: 0; }
  /* Logo a gauche, nom et slogan a droite : on gagne toute la hauteur du bloc */
  .login-head { gap: .6rem; margin-bottom: .7rem; }
  .login-card .logo-lg { width: 44px; height: 44px; border-radius: 13px; font-size: 1.1rem; flex: 0 0 auto; }
  .login-card h1 { font-size: 1.05rem; line-height: 1.15; margin: 0; }
  .login-head-text p { font-size: .72rem; }
  /* Trois colonnes de poles des le mobile */
  .pole-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
  .pole-pick { padding: .45rem .2rem; font-size: .68rem; gap: .3rem; border-radius: 11px; line-height: 1.15; }
  .pole-pick .pi { width: 32px; height: 32px; font-size: .95rem; border-radius: 10px; }
  .tabs button { font-size: .8rem; padding: .55rem .3rem; }
  .login-hint { font-size: .68rem; }

  /* --- Notifications : pleine largeur, jamais hors ecran --- */
  .toasts { left: .6rem; right: .6rem; top: .6rem; }
  .toast { max-width: 100%; font-size: .8rem; }

  /* --- Administration : navigation horizontale defilante --- */
  .admin-nav { padding: .35rem; }
  .admin-nav button { padding: .55rem .6rem; font-size: .8rem; min-height: 40px; }
}

/* Petit mobile : tout en une colonne, texte encore lisible */
@media (max-width: 420px) {
  .main { padding: .7rem .6rem 7rem; }
  .brand small { display: none; }
  .user-chip strong { display: block; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-auto { grid-template-columns: 1fr; }
  /* Meme raison que pour le palier 720px : les selecteurs d'id doivent etre
     repetes ici, sinon `#pole-cards` resterait a deux colonnes sur un petit
     telephone et les tuiles deviendraient illisibles. */
  #pole-cards { grid-template-columns: 1fr; }
  #infos { grid-template-columns: 1fr; }
  .pole-hero { flex-wrap: wrap; }
  .pole-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
  .pole-pick { font-size: .63rem; padding: .4rem .15rem; }
  .pole-pick .pi { width: 28px; height: 28px; font-size: .85rem; }
  .mod-tiles { gap: .35rem; }
  .mod-tiles .action-tile .t-label { font-size: .64rem; }
  .dock-item { width: 68px; }
  .dock-icon { width: 38px; height: 38px; font-size: .95rem; }
  .section-title .hint { width: 100%; }
}

/* Tres petits ecrans / orientation paysage basse : le dock ne mange pas l'ecran */
@media (max-height: 480px) {
  .main { padding-bottom: 5.5rem; }
  .dock-item .label { display: none; }
  .dock { padding: .3rem; }
}

/* Accessibilite : respect de la preference "mouvement reduit" */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Impression : fonds blancs, pas de dock ni de boutons */
@media print {
  .dock, .topbar, .toasts, .modal-backdrop, .alert-backdrop, .btn { display: none !important; }
  .main { padding: 0; max-width: 100%; }
  .card, .table-wrap { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* ---------------- Filtres de colonnes (select / plage de dates) ---------------- */
table.data tr.filter-row th select {
  width: 100%; min-width: 84px; padding: .26rem .3rem;
  border: 1px solid #d8e0d6; border-radius: 7px;
  font-size: .72rem; font-weight: 500; background: #fff; color: var(--ink);
}
table.data tr.filter-row th select:focus {
  outline: 2px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand);
}
table.data tr.filter-row th .flt-range {
  display: grid; gap: .2rem;
}
table.data tr.filter-row th .flt-range input {
  width: 100%; min-width: 92px; padding: .22rem .3rem;
  border: 1px solid #d8e0d6; border-radius: 7px;
  font-size: .7rem; background: #fff; color: var(--ink);
}
table.data tr.filter-row th .flt-range input:focus {
  outline: 2px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand);
}

/* ---------------- Parametres du pole : categories ---------------- */
.cat-manage { display: grid; gap: .45rem; }
.cat-manage-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .55rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff;
}
.cat-manage-row .cat-icon { flex: 0 0 auto; }
.cat-manage-row .cm-label { flex: 1; font-weight: 600; font-size: .86rem; min-width: 0; }
.cat-manage-row .cm-used { font-size: .7rem; color: var(--ink-soft); white-space: nowrap; }
.cat-manage-row.off { opacity: .55; }

/* ---------------- Saisie d'heure par menus (Heure / Minute) ----------------
   Remplace l'horloge native du navigateur, dont la derniere ligne
   (« Clavier / Effacer / Annuler ») est coupee sur smartphone. */
.time-pair {
  display: flex; align-items: center; gap: .3rem; flex-wrap: wrap;
}
.time-pair .tp-tag {
  font-size: .68rem; color: var(--ink-soft); font-weight: 600;
  text-transform: uppercase; letter-spacing: .02em;
}
.time-pair .tp-sep { font-weight: 700; color: var(--ink-soft); }
.time-pair .tp-label { font-size: .72rem; color: var(--ink-soft); font-weight: 600; }
.time-pair select {
  width: auto; min-width: 62px; padding: .34rem .3rem;
  border: 1px solid #d8e0d6; border-radius: 8px;
  background: #fff; color: var(--ink); font-size: .85rem; font-weight: 600;
}
.time-pair select:focus {
  outline: 2px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand);
}
