/* FLERP Gest — gest.flerp.me. Accent GRANATE #8F3A45 (décision Florian 05-08 :
   « un rouge sans être rouge vif » — le granate se distingue du orange Reco et du
   rouge sémantique d'erreur #B42318 par sa profondeur bordeaux). Le TEXTE et les
   liens accentués utilisent le foncé #6E2530 (contraste AA/AAA sur fond clair —
   le granate vif sert aux accents/boutons/états actifs). Charte suite « iOS »
   2026-07-01 : fond #F2F2F7, cards blanches PLATES radius 12, police système.
   Gabarit copié de CALI/app/static/css/cali.css (parité suite), re-colorié —
   sections spécifiques qualité (QR, temperatura, reglas) NON portées. */
:root {
  --gest: #8F3A45; --gest-d: #6E2530; --gest-soft: #F7E6E8;
  /* GRANATE LISERÉ — 3e ton de la famille (harmonisation suite 25-07) : sur fond
     clair, #8F3A45 en trait de 1 px pèse ~2,9:1 (trop lourd face au vert d'Agro) ;
     #CE939C mesure ~2,3:1 sur --bg — le MÊME poids perçu que #4CAF50 (Agro),
     #007AFF (Com), #FD8000 (Reco) et #C79A00 (Cali), et il reste granate. */
  --gest-linea: #CE939C;
  --bg: #F2F2F7; --panel: #FFFFFF; --ink: #16202E; --muted: #6B7688;
  --line: #E2E2E7; --line-2: #ECECF1;
  --good: #1E9E5A; --ink-2: #0F172A;
  --shadow: none;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.55rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; letter-spacing: -.01em; }

/* ---- Topbar (verre dépoli, charte §2) ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px;
  padding: 0 clamp(16px, 4vw, 34px); height: 62px;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-ic { width: 30px; height: 30px; }
.brand-txt { font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; white-space: nowrap; }
.brand-txt b { color: var(--gest-d); font-weight: 700; }
.topnav { display: flex; gap: 4px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 500;
  white-space: nowrap; transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--line-2); color: var(--ink); }
.topnav a.on { background: var(--gest-soft); color: var(--gest-d); }
.topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.whoami { text-align: right; line-height: 1.2; }
.who-name { display: block; font-weight: 600; font-size: .9rem; }
.who-meta { display: block; font-size: .76rem; color: var(--muted); }
.btn-portal {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid var(--line); color: var(--muted); font-size: 1rem; flex: none;
}
.btn-portal:hover { border-color: var(--gest); color: var(--gest-d); }
.btn-portal img.flerp-mol { width: 22px; height: 22px; display: block; }
.btn-logout {
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: .85rem;
  color: var(--gest-d); background: var(--gest-soft); white-space: nowrap;
}
.btn-logout:hover { background: #F0D6DA; }

/* ---- Layout ---- */
.wrap { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
  padding: clamp(20px, 4vw, 38px) clamp(16px, 4vw, 34px); }
.wrap.centered { display: grid; place-items: center; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 22px; }
@media (min-width: 900px) {
  .foot { padding: 8px 12px 12px; font-size: .7rem; }
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.eyebrow { color: var(--gest-d); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.lead { color: var(--muted); margin-top: 4px; }
.section-h { margin: 30px 0 14px; }
.page-new { flex: none; white-space: nowrap; align-self: center; }
.head-actions { display: flex; gap: 10px; flex: none; align-self: center; flex-wrap: wrap; }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; max-width: 560px; margin: 0 0 16px; }
.kpi { background: var(--panel); border: 1px solid transparent; border-radius: var(--radius);
  padding: 18px 16px; }
.kpi-n { display: block; font-size: 2rem; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1; }
.kpi-n.acc { color: var(--gest-d); }
.kpi-n.ok { color: var(--good); }
.kpi-n.bad { color: #B42318; }
.kpi-l { display: flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: .82rem; margin-top: 6px; }
.kpis.kpis-dash { max-width: none; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpis.kpis-dash .kpi-n { font-size: 1.65rem; white-space: nowrap; }
.dash-block { margin-top: 20px; }

/* ---- Modules (tuiles inicio) ---- */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.mod {
  position: relative; background: var(--panel); border: 1px solid transparent;
  border-radius: var(--radius); padding: 22px;
  transition: transform .18s, border-color .18s, box-shadow .25s; display: block;
}
a.mod:hover { transform: translateY(-3px); border-color: rgba(143,58,69,.55);
  box-shadow: 0 18px 40px -20px rgba(110,37,48,.5); }
.mod-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--gest-soft); font-size: 1.5rem; margin-bottom: 14px; }
.mod h3 { font-size: 1.05rem; margin-bottom: 6px; }
.mod p { color: var(--muted); font-size: .88rem; }
.tag { position: absolute; top: 18px; right: 18px; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding: 4px 9px; border-radius: 999px;
  background: var(--line-2); color: var(--muted); }
.tag.ok { background: #E4F6EC; color: var(--good); }
.tag.soon { background: var(--gest-soft); color: var(--gest-d); }

/* ---- Tables ---- */
.table-wrap { background: var(--panel); border: 1px solid transparent; border-radius: var(--radius);
  overflow: auto; }
.table-wrap.flat { border: 1px solid var(--line-2); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; padding: 13px 16px; color: var(--muted); font-weight: 600;
  font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #FAFBFD; }
table.data.compact th, table.data.compact td { padding: 8px 10px; font-size: .8rem; }
table.data th.num { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.pill { display: inline-block; font-size: .74rem; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; background: var(--line-2); color: var(--muted); }
.pill.on { background: #E4F6EC; color: var(--good); }
.pill.off { background: #FDECEC; color: #B42318; }
.pill.warn { background: #FFF3E6; color: #B45309; }
.pill.info { background: #E8F1FF; color: #1D63D8; }
.pill.acc { background: var(--gest-soft); color: var(--gest-d); }
.pill.big { font-size: .85rem; padding: 6px 14px; align-self: center; }
.cell-link { color: var(--gest-d); font-weight: 600; }
.cell-link.plain { color: var(--ink); font-weight: 500; }
.cell-link:hover { text-decoration: underline; }

/* ---- Cards / formulaires ---- */
.card { background: var(--panel); border: 1px solid transparent; border-radius: var(--radius);
  overflow: auto; margin-bottom: 16px; }
.card-h { padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 1rem; }
.card-h.bare { border: none; padding: 14px 0 10px; }
.card-h-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pad { padding: 16px 18px; }
.form-card { padding: 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: .84rem;
  font-weight: 600; color: var(--muted); }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label.chk { flex-direction: row; align-items: center; gap: 8px; }
.form-grid label.chk input { width: 17px; height: 17px; accent-color: var(--gest-d); }
.form-grid input:not([type=checkbox]), .form-grid select, .form-grid textarea,
.inline-row input, .inline-row select, .search-row input, .search-row select {
  height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 16px; color: var(--ink); background: #fff; }
.form-grid textarea { height: auto; min-height: 84px; padding: 10px 12px; }
.form-grid input[type=file] { padding: 8px 12px; height: auto; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.inline-row input:focus, .search-row input:focus {
  outline: 2px solid rgba(143,58,69,.45); outline-offset: 1px; border-color: var(--gest); }
.form-grid input:disabled { background: var(--line-2); color: var(--muted); }
.form-actions { display: flex; gap: 14px; align-items: center; margin-top: 20px; }
.inline-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
.inline-row label { display: flex; flex-direction: column; gap: 6px; font-size: .84rem;
  font-weight: 600; color: var(--muted); }
.estado-row { padding-top: 14px; margin-top: 18px; border-top: 1px solid var(--line-2); }
.acciones { display: flex; gap: 6px; align-items: center; }
.acciones form { display: inline-flex; margin: 0; }

/* ---- Boutons (min 44px tactile, charte §2) ---- */
.btn-gest { display: inline-flex; align-items: center; justify-content: center; width: 100%;
  height: 50px; border-radius: 13px; font-weight: 700; font-size: 1rem; color: #fff;
  border: 0; cursor: pointer;
  background: linear-gradient(135deg, #A54A56, #7C2F3A);
  box-shadow: 0 10px 24px -8px rgba(110,37,48,.55);
  transition: transform .15s, box-shadow .2s; }
.btn-gest:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -10px rgba(110,37,48,.65); }
.btn-gest.ghost { background: none; color: var(--gest-d); border: 1.5px solid var(--gest); box-shadow: none; }
.btn-gest.slim { width: auto; height: 44px; padding: 0 20px; font-size: .92rem; border-radius: 11px; }
.btn-sec { display: inline-flex; align-items: center; height: 44px; padding: 0 18px; border-radius: 11px;
  font-weight: 600; font-size: .92rem; color: var(--gest-d); border: 1.5px solid var(--gest);
  background: #fff; cursor: pointer; font-family: inherit; transition: background .15s; }
.btn-sec:hover { background: var(--gest-soft); }
.btn-sec.slim-h { height: 42px; }
.btn-cancel { display: inline-flex; align-items: center; height: 44px; padding: 0 16px;
  color: var(--muted); font-weight: 600; font-size: .92rem; }
.btn-cancel:hover { color: var(--ink); }
.btn-danger { display: inline-flex; align-items: center; height: 42px; padding: 0 18px;
  border-radius: 11px; border: 1.5px solid #E05B5B; background: none; color: #B42318;
  font: inherit; font-weight: 600; cursor: pointer; }
.btn-danger:hover { background: #FDECEC; }
.mini-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  height: 34px; width: 38px; cursor: pointer; font-size: .9rem; }
.mini-btn:hover { border-color: var(--gest); background: var(--gest-soft); }
a.mini-btn { display: inline-flex; align-items: center; justify-content: center; }
button.mini-btn { white-space: nowrap; display: inline-flex; align-items: center;
  justify-content: center; gap: 4px; width: auto; min-width: 38px; padding: 0 10px; }
.acciones input[name=motivo], .acciones input[name=prueba_doc_id] { height: 34px;
  width: 150px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .8rem;
  color: var(--ink); background: #fff; }
.acciones input[name=prueba_doc_id] { width: 84px; }
.acciones input[name=motivo]:focus, .acciones input[name=prueba_doc_id]:focus {
  outline: 2px solid rgba(143,58,69,.45);
  outline-offset: 1px; border-color: var(--gest); }
.inline-form { display: inline; margin: 0 0 0 4px; }

/* ---- Login ---- */
.login-card { background: var(--panel); border: 1px solid transparent; border-radius: 22px;
  padding: 44px 40px; max-width: 400px; text-align: center; }
.login-ic { width: 66px; height: 66px; margin: 0 auto 18px; display: block; }
.login-card h1 { font-size: 1.7rem; } .login-card h1 b { color: var(--gest-d); }
.login-sub { color: var(--muted); margin: 8px 0 26px; }
.login-note { color: var(--muted); font-size: .84rem; margin-top: 16px; }

/* ---- Bannières / flash ---- */
.banner-error { background: #FDECEC; color: #B42318; border-radius: 12px; padding: 12px 16px;
  font-weight: 600; margin-bottom: 14px; }
.banner-ok { background: #E4F6EC; color: var(--good); border-radius: 12px; padding: 12px 16px; font-weight: 600; margin-bottom: 14px; }
.banner-info { background: var(--gest-soft); color: var(--gest-d); border-radius: 12px; padding: 12px 16px; font-weight: 600; margin-bottom: 14px; }
.banner-warn { background: #FFF3E6; color: #B45309; border-radius: 12px; padding: 12px 16px; font-weight: 600; margin-bottom: 14px; }
.flash-ok { color: var(--good); font-weight: 600; margin: 0 0 14px; }

/* ---- Onglets de page (souligné accent, charte §3.4) ---- */
.rtabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line);
  margin: 4px 0 18px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-x; scrollbar-width: none; }
.rtabs::-webkit-scrollbar { display: none; }
.rtabs a { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 9px 2px 11px; color: var(--muted); font-weight: 650; text-decoration: none;
  border-bottom: 2.5px solid transparent; white-space: nowrap; }
.rtabs a:hover { color: var(--ink); }
.rtabs a.on { color: var(--gest-d); border-bottom-color: var(--gest); }

/* ---- Recherche liste ---- */
.search-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-row input[type=search] { flex: 1; min-width: 200px; }

/* ---- Fiche / méta ---- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px 24px; margin: 6px 0 4px; }
.meta-grid dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.meta-grid dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.meta-grid dd.sha { font-weight: 500; font-size: .78rem; }
.nv-row label { min-width: 220px; }
.hist { margin-top: 14px; }
.hist > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .88rem; }
.hist-list { list-style: none; margin: 10px 0 4px; display: flex; flex-direction: column; gap: 6px; }
.hist-list li { font-size: .86rem; padding: 6px 0; border-bottom: 1px solid var(--line-2); }

/* ---- États colorés (échéances/alertes — la classe est posée par le SERVEUR) ---- */
.resp-ok { color: var(--good); font-weight: 700; }
.resp-warn { color: #B45309; font-weight: 700; }
.resp-bad { color: #B42318; font-weight: 700; }
.firma-line { display: flex; gap: 8px; align-items: center; font-size: .86rem; padding: 6px 0; }
@media print {
  .topbar, .sidebar, .foot, .bbar-m, .no-print { display: none !important; }
  body, body.with-side { display: block; background: #fff; }
}

/* ---- Usuarios / roles / audit (même grammaire que Reco/Agro/Fact/Cali) ---- */
tr.u-nuevo td { background: var(--gest-soft); }
.u-nuevo-badge { font-size: .82rem; }
details.usr-card { border: 1px solid var(--line); border-radius: 12px; padding: 0;
  margin: 10px 0; background: var(--panel); }
details.usr-card summary { cursor: pointer; padding: 12px 14px; border-radius: 12px; }
details.usr-card summary:hover { background: var(--line-2); }
details.usr-card[open] summary { border-bottom: 1px solid var(--line-2); }
details.usr-card > form, details.usr-card > p { padding: 14px; }
details.usr-card.u-nuevo { border-color: var(--gest); background: var(--gest-soft); }
.rol-inline { display: inline-flex; gap: 6px; align-items: center; }
.rol-inline select { height: 34px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: .84rem; }
.rol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px 16px; margin-top: 12px; }
.rol-grid .chk { display: flex; gap: 8px; align-items: center; font-size: .88rem; }
.rol-grid .chk input { width: 17px; height: 17px; accent-color: var(--gest-d); }
.usr-nota { margin-bottom: 16px; }
.aud-filtros { grid-template-columns: repeat(3, 1fr); }

/* ---- Pages-squelettes G2+ (futuro.html) ---- */
.ciclo { display: flex; align-items: center; gap: 8px; list-style: none;
  overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 2px 10px;
  margin: 4px 0 8px; scrollbar-width: none; }
.ciclo::-webkit-scrollbar { display: none; }
.ciclo li { flex: none; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.ciclo li + li::before { content: "→"; color: var(--muted); font-weight: 400; }
.ciclo .chip { font-size: .82rem; font-weight: 600; color: var(--gest-d);
  background: var(--gest-soft); border-radius: 999px; padding: 5px 12px; }
.spec-h { margin: 18px 0 6px; font-size: .95rem; }
.spec-list { margin: 4px 0; padding-left: 1.25em; }
.spec-list li { margin: 5px 0; }

/* ---- Configuración divers ---- */
.lang-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-sec.lang-on { background: var(--gest-soft); box-shadow: 0 0 0 2px rgba(143,58,69,.3); }
.guia .guia-steps { margin: 8px 0 4px; padding-left: 1.25em; }
.guia .guia-steps li { margin: 10px 0; }
.disp-form { display: flex; gap: 10px; align-items: center; margin-top: 10px; max-width: 460px; }
.disp-form select { flex: 1; min-width: 0; height: 42px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; font: inherit;
  font-size: 16px; color: var(--ink); }
.disp-form select:focus { outline: 2px solid rgba(143,58,69,.45); outline-offset: 1px;
  border-color: var(--gest); }

/* ---- Sidebar hybride (bureau ≥ 900 px) — patron suite, DISPOSITION PAR DÉFAUT ---- */
.sidebar { display: none; }
body.with-side { display: grid; grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; }
body.with-side > .sidebar { display: flex; flex-direction: column; gap: 2px;
  grid-column: 1; grid-row: 1 / span 3;
  padding: 16px 12px; background: var(--panel); border-right: 1px solid var(--line-2);
  overflow-y: auto; }
body.with-side > .topbar { grid-column: 2; grid-row: 1; }
body.with-side > .wrap { grid-column: 2; grid-row: 2; overflow-y: auto; max-width: none; }
body.with-side > .foot { grid-column: 2; grid-row: 3; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 10px; font-size: .92rem; font-weight: 500; color: var(--muted);
  white-space: nowrap; }
.side-nav a:hover { background: var(--line-2); color: var(--ink); }
.side-nav a.on { background: var(--gest-soft); color: var(--gest-d); font-weight: 600; }
.side-nav a .ne { width: 20px; font-size: 15px; }
.side-nav .nav-ne { width: 18px; display: inline-flex; justify-content: center; flex: none; }
@media (min-width: 900px) {
  body.with-side .topbar .topnav { display: none; }
  body.with-side .topbar > .brand { display: none; }
}
@media (max-width: 899px) {
  body.with-side { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
  body.with-side > .sidebar { display: none; }
  body.with-side > .wrap { overflow-y: visible; max-width: 1180px; }
}

/* ---- Confort bureau : carte 🖥️ de Mi perfil en sections ---- */
.aj-sec { padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--line-2); }
.aj-sec.first { padding-top: 0; margin-top: 0; border-top: 0; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 10px;
  font-weight: 500; color: var(--ink); }
label.check input { width: 17px; height: 17px; accent-color: var(--gest-d); }
.check.inline { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Buscador de menús (tablero — patron Agro #menu-q/#menu-sug) ---- */
.menu-search { position: relative; }
.dash-search { margin: 14px 0 0; }
.menu-search input { height: 38px; width: 230px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; font-size: .88rem; background: var(--panel);
  color: var(--ink); transition: width .15s; }
.menu-search input:focus { outline: none; border-color: var(--gest); width: 290px; }
.menu-sug { position: absolute; top: 44px; left: 0; min-width: 250px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px -20px rgba(22,32,46,.35);
  padding: 6px; display: flex; flex-direction: column; gap: 2px; z-index: 40; }
.menu-sug[hidden] { display: none; }
.menu-sug-it { text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px;
  font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink); }
.menu-sug-it:hover, .menu-sug-it.on { background: var(--gest-soft); color: var(--gest-d); }
@media (max-width: 900px) { .dash-search .menu-search input { width: 100%; } }

/* ---- Filtre par colonne (filter.js — patron Reco .filter-row) ---- */
.filter-row { display: flex; gap: 8px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line-2); background: var(--bg); position: sticky; left: 0; }
.filter-sel { height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); font: inherit; font-size: .85rem; color: var(--muted); max-width: 45%; }
.filter-q { flex: 1; min-width: 120px; height: 36px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; font-size: .9rem; background: var(--panel); color: var(--ink); }
.filter-q:focus { outline: none; border-color: var(--gest); }
.filter-count { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; }

/* ---- Tablero : alertas + grille v2 (patron CALI, sans temperatura) ---- */
.dash-v2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px; margin: 4px 0 20px; }
.dash-v2 .card { margin-bottom: 0; }
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert-list li { padding: 9px 12px; border-radius: 10px; background: var(--line-2); font-size: .9rem; }
.alert-list li.al-aviso { background: #FFF3E6; }
.alert-list li.al-rojo, .alert-list li.al-caducado { background: #FDECEC; }
.venc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }

/* =====================================================================
   MODE NOCTURNE (patron suite) : palette « granate sur brun-vin très sombre »,
   PAS une inversion. theme.js pose data-theme="dark" sur <html> AVANT le
   premier paint (clé localStorage `gest_theme`, sinon prefers-color-scheme).
   ===================================================================== */
#theme-toggle { width: 34px; height: 34px; display: grid; place-items: center; padding: 0;
  border-radius: 9px; border: 1px solid var(--line); background: none;
  color: var(--muted); font-size: 1.02rem; line-height: 1; cursor: pointer; flex: none; }
#theme-toggle:hover { border-color: var(--gest); }
#theme-toggle .tt-sun { display: none; }
html[data-theme="dark"] #theme-toggle .tt-sun { display: block; }
html[data-theme="dark"] #theme-toggle .tt-moon { display: none; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1D1113; --panel: #251517;
  --ink: #F0E4E6; --ink-2: #F8ECEE; --muted: #B39AA0;
  --line: #43262B; --line-2: #381F24;
  --gest: #D98E9A;                       /* bordures/focus : granate éclairci */
  --gest-d: #E8A8B2;                     /* accent texte clair (AA sur fond sombre) */
  --gest-soft: #43242B;                  /* OPAQUE : fonds actifs */
  --good: #4FC382;
}
@media (prefers-reduced-motion: no-preference) {
  html[data-theme="dark"] body, html[data-theme="dark"] .topbar,
  html[data-theme="dark"] .sidebar, html[data-theme="dark"] .card,
  html[data-theme="dark"] .kpi, html[data-theme="dark"] .mod {
    transition: background-color .2s ease, color .2s ease, border-color .2s ease; }
}
html[data-theme="dark"] .topbar { background: rgba(29, 17, 19, .86); }
html[data-theme="dark"] .btn-logout:hover { background: rgba(217, 142, 154, .28); }
html[data-theme="dark"] .btn-logout:not(:hover) { background: var(--gest-soft); }
html[data-theme="dark"] a.mod:hover { border-color: rgba(217,142,154,.5);
  box-shadow: 0 18px 40px -20px rgba(0,0,0,.8); }
html[data-theme="dark"] .menu-sug { box-shadow: 0 18px 40px -20px rgba(0,0,0,.8); }
html[data-theme="dark"] .form-grid input:not([type=checkbox]),
html[data-theme="dark"] .form-grid select, html[data-theme="dark"] .form-grid textarea,
html[data-theme="dark"] .inline-row input, html[data-theme="dark"] .inline-row select,
html[data-theme="dark"] .search-row input, html[data-theme="dark"] .search-row select,
html[data-theme="dark"] .disp-form select,
html[data-theme="dark"] .acciones input[name=motivo] { background-color: #3A2126; color: var(--ink); }
html[data-theme="dark"] .form-grid input:disabled { background: var(--line-2); color: var(--muted); }
html[data-theme="dark"] ::placeholder { color: #9C8288; }
html[data-theme="dark"] .btn-sec { background: transparent; }
html[data-theme="dark"] .btn-sec:hover { background: var(--gest-soft); }
html[data-theme="dark"] .btn-sec.lang-on { background: var(--gest-soft); }
html[data-theme="dark"] .btn-danger:hover { background: #3D2223; }
html[data-theme="dark"] table.data tbody tr:hover { background: #33191E; }
html[data-theme="dark"] .tag.ok, html[data-theme="dark"] .pill.on { background: #1D3A2A; color: var(--good); }
html[data-theme="dark"] .pill.off { background: #3D2223; color: #F1968E; }
html[data-theme="dark"] .pill.warn { background: #3B2E1B; color: #E5A54E; }
html[data-theme="dark"] .pill.info { background: #1B2C4A; color: #6EA8FE; }
html[data-theme="dark"] .pill.acc { background: var(--gest-soft); color: var(--gest-d); }
html[data-theme="dark"] .banner-error { background: #3D2223; color: #F1968E; }
html[data-theme="dark"] .banner-ok { background: #1D3A2A; color: var(--good); }
html[data-theme="dark"] .banner-info { background: var(--gest-soft); color: var(--gest-d); }
html[data-theme="dark"] .banner-warn { background: #3B2E1B; color: #E5A54E; }
html[data-theme="dark"] .filter-row { background: #2F181C; }
html[data-theme="dark"] tr.u-nuevo td { background: var(--gest-soft); }
html[data-theme="dark"] details.usr-card.u-nuevo { background: var(--gest-soft); }
html[data-theme="dark"] .resp-warn { color: #E5A54E; }
html[data-theme="dark"] .resp-bad { color: #F1968E; }
html[data-theme="dark"] .alert-list li { background: var(--line-2); }
html[data-theme="dark"] .alert-list li.al-aviso { background: #3B2E1B; }
html[data-theme="dark"] .alert-list li.al-rojo, html[data-theme="dark"] .alert-list li.al-caducado { background: #3D2223; }

/* ---- Responsive (mobile-first suite : cibles 44px, font 16px inputs) ---- */
@media (max-width: 1000px) {
  .modules { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .topnav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; gap: 4px; padding-bottom: 6px; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { white-space: nowrap; flex: 0 0 auto; }
  .whoami { display: none; }
  .modules { grid-template-columns: 1fr; }
  .form-grid, .aud-filtros { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-new { width: 100%; text-align: center; margin-top: 6px; }
  table.data { font-size: .82rem; min-width: 430px; }
  table.data th, table.data td { padding: 10px 10px; white-space: nowrap; }
  .card, .table-wrap { -webkit-overflow-scrolling: touch; }
  .wrap { padding-left: 12px; padding-right: 12px; }
}

/* ══════════ Bottom bar MOBILE (modèle AGRO, parité suite — palette granate) ══════════ */
.bbar-m { display: none; }
.bsheet { display: none; }
@media (max-width: 899px) {
  .bbar-m { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: rgba(255,255,255,.96);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    backdrop-filter: saturate(160%) blur(12px);
    border-top: 1px solid var(--line);
    padding: 4px 20px calc(12px + env(safe-area-inset-bottom)); }
  .bbar-m a { display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px 4px; min-height: 48px; color: var(--muted); border-radius: 10px;
    text-decoration: none; min-width: 0; }
  .bbar-m .ne { font-size: 20px; height: 22px; line-height: 22px; flex: none;
    font-style: normal; }
  .bbar-m a > span:last-child { font-size: .6rem; font-weight: 600; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bbar-m a.on { color: var(--gest-d); }
  main.wrap { padding-bottom: 100px; }
  .foot { padding-bottom: 92px; }
  .bbar-m a.blink { color: var(--gest-d); }
  .bbar-m a.blink .ne, .bbar-m a.blink span { animation: bblink .55s step-end infinite; }
  @keyframes bblink { 50% { opacity: .25; } }
  .bsheet { display: flex; position: fixed; inset: 0; z-index: 50;
    flex-direction: column; justify-content: flex-end; background: rgba(30,14,17,.38); }
  .bsheet[hidden] { display: none; }
  .bsheet-in { background: var(--bg); border-radius: 20px 20px 0 0; max-height: 78vh;
    overflow-y: auto; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); }
  .bsheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .bsheet-h b { font-size: 1.02rem; }
  .bsheet-h button { appearance: none; border: 0; background: var(--line-2); color: var(--muted);
    width: 30px; height: 30px; border-radius: 50%; font-size: .9rem; cursor: pointer; }
  .bsheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .bsheet-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
    padding: 12px 6px 10px; font-size: .66rem; font-weight: 600; color: var(--ink);
    text-align: center; min-width: 0; }
  .bsheet-grid a .ne { font-size: 20px; font-style: normal; }
  .bsheet-grid a.on { border-color: var(--gest); background: var(--gest-soft); color: var(--gest-d); }
  .bsheet-grid a .nl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
}
.bbar-m a, .bbar-m a * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.bbar-m a { -webkit-tap-highlight-color: transparent; }
html[data-theme="dark"] .bbar-m { background: rgba(29, 17, 19, .97); }
html[data-theme="dark"] .bsheet { background: rgba(0, 0, 0, .6); }

/* ---- tri par colonne (sort.js) : en-têtes cliquables + flèche du sens ---- */
table.data thead th { cursor: pointer; user-select: none; }
table.data thead th.sort-asc::after { content: " ▲"; font-size: .7em; color: var(--gest-d); }
table.data thead th.sort-desc::after { content: " ▼"; font-size: .7em; color: var(--gest-d); }

/* ---- logos société (mapping whitelisté base.html, fail-soft — patron suite) ---- */
.soc-logo { object-fit: contain; background: #fff; border-radius: 8px; }
.top-soc { height: 30px; max-width: 96px; padding: 2px 6px; border: 1px solid var(--line-2); flex: none; }
.side-soc { display: block; margin: 0 auto 12px; max-width: 150px; max-height: 46px; padding: 4px 8px; border: 1px solid var(--line-2); }
html[data-theme="dark"] .soc-logo { background: #F4F4F6; border-color: var(--line); }
@media (max-width: 680px) { .top-soc { display: none; } }
.dash-head { position: relative; }
.dash-head-mid { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  pointer-events: none; display: flex; }
.dash-head-mid .mid-soc { height: 76px; background: none; border: 0; padding: 0; border-radius: 0; }
@media (max-width: 899px) { .dash-head-mid { display: none; } }

/* ═══ LISERÉ EXTÉRIEUR DES TABLEAUX — MODE CLAIR SEUL (harmonisation suite 25-07,
   même doctrine que CALI : UNE seule règle, spécificité 0,2,1 > .table-wrap.flat ;
   mode sombre intouché par construction — theme.js RETIRE l'attribut en clair). ═══ */
html:not([data-theme="dark"]) .table-wrap { border: 1px solid var(--gest-linea); }

/* ═══ couche de polissage nav (AGRO 27-07, parité suite) ═══ */
.rtabs a .ne { font-size: 14px; margin-right: 3px; }
.topnav a .ne { width: 20px; font-size: 15px; }
.side-nav a, .topnav a { min-width: 0; }
.side-nav a .nl, .topnav a .nl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtabs-sub { margin-top: -8px; }
.rtabs-sub a { font-size: .85rem; padding: 6px 2px 8px; }

/* ═══ densité bureau ALIGNÉE SUR AGRO (parité suite) : 90 % desktop, jamais mobile ═══ */
@media (min-width: 900px) {
  html { zoom: 0.9; }
  body { min-height: calc(100vh / 0.9); }
  body.with-side { height: calc(100vh / 0.9); }
}

/* ═══ champ FICHIER habillé (patron AGRO, les 6 apps — couleur de l'app) ═══ */
input[type="file"] {
  padding: 6px 8px; border: 1px dashed var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink);
  font: inherit; font-size: .85rem; max-width: 100%; cursor: pointer;
}
input[type="file"]:hover { border-color: var(--gest); }
input[type="file"]:focus-visible { outline: 2px solid var(--gest); outline-offset: 1px; }
input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 6px 12px; border: 1px solid var(--gest);
  border-radius: 8px; background: var(--gest-soft); color: var(--gest-d);
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
input[type="file"]::file-selector-button:hover { background: var(--gest); color: #fff; }
html[data-theme="dark"] input[type="file"] { background-color: #2E191D;
  color: var(--ink); border-color: #4E2A31; }
html[data-theme="dark"] input[type="file"]::file-selector-button {
  background: rgba(217, 142, 154, .15); color: #D98E9A; border-color: #6E3A44; }
html[data-theme="dark"] input[type="file"]::file-selector-button:hover {
  background: #8F3A45; color: #fff; }

/* ═══ bottom bar iOS FLOTTANTE (parité suite) ═══ */
@media (max-width: 899px) {
  .bbar-m { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    border-radius: 24px; border: 1px solid rgba(0, 0, 0, .08); border-top-width: 1px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
    background: rgba(255, 255, 255, .78);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
    padding: 6px 8px; gap: 2px; }
  html[data-theme="dark"] .bbar-m { background: rgba(33, 20, 23, .78);
    border-color: rgba(255, 255, 255, .08); }
}
