/* FLERP Fact — fact.flerp.me. Accent VIOLET #7B4FE2 (branding du PDF de cadrage FACT,
   même violet que la molécule FLERP). Charte suite « iOS agricole » 2026-07-01 :
   fond #F2F2F7, cards blanches PLATES radius 12, police système, un seul accent. */
:root {
  --fact: #7B4FE2; --fact-d: #5B35BE; --fact-soft: #F5F3FF;
  --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(--fact-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(--fact-soft); color: var(--fact-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(--fact); color: var(--fact-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(--fact-d); background: var(--fact-soft); white-space: nowrap;
}
.btn-logout:hover { background: #EBE4FD; }

/* ---- 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; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.eyebrow { color: var(--fact-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; }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; max-width: 560px; }
.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(--fact-d); }
.kpi-l { display: block; color: var(--muted); font-size: .82rem; margin-top: 6px; }

/* ---- 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(123,79,226,.5);
  box-shadow: 0 18px 40px -20px rgba(123,79,226,.5); }
.mod-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--fact-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(--fact-soft); color: var(--fact-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; }
.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.big { font-size: .85rem; padding: 6px 14px; align-self: center; }
.cell-link { color: var(--fact-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 input:not([type=checkbox]), .form-grid select,
.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 input[type=file] { padding: 8px 12px; height: auto; }
.form-grid input:focus, .form-grid select:focus, .inline-row input:focus,
.search-row input:focus {
  outline: 2px solid rgba(123,79,226,.45); outline-offset: 1px; border-color: var(--fact); }
.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); }

/* ---- Boutons (min 44px tactile, charte §2) ---- */
.btn-fact { 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, #9B76F0, var(--fact-d));
  box-shadow: 0 10px 24px -8px rgba(123,79,226,.6);
  transition: transform .15s, box-shadow .2s; }
.btn-fact:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -10px rgba(123,79,226,.7); }
.btn-fact.ghost { background: none; color: var(--fact-d); border: 1.5px solid var(--fact); box-shadow: none; }
.btn-fact.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(--fact-d); border: 1.5px solid var(--fact);
  background: #fff; cursor: pointer; font-family: inherit; transition: background .15s; }
.btn-sec:hover { background: var(--fact-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(--fact); background: var(--fact-soft); }

/* ---- 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(--fact-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: #F5F3FF; color: var(--fact-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(--fact); border-bottom-color: var(--fact); }

/* ---- 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 fournisseur ---- */
.com-actual { margin: 6px 0 10px; }
.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); }
.contact-line { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.contact-line:last-of-type { border-bottom: none; }

/* ---- Fiche document ---- */
.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; }
.verif-resumen { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }

/* ---- Usuarios / roles / audit (même grammaire que Reco/Agro) ---- */
tr.u-nuevo td { background: var(--fact-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(--fact); background: var(--fact-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(--fact-d); }
.usr-nota { margin-bottom: 16px; }
.aud-filtros { grid-template-columns: repeat(3, 1fr); }

/* ---- Pages-squelettes du plan F2+ (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(--fact-d);
  background: var(--fact-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(--fact-soft); box-shadow: 0 0 0 2px rgba(123,79,226,.25); }
.guia .guia-steps { margin: 8px 0 4px; padding-left: 1.25em; }
.guia .guia-steps li { margin: 10px 0; }
/* carte « Disposición del escritorio » (⚙️ Mi perfil — patron .aj-disp-form de Reco) */
.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(123,79,226,.45); outline-offset: 1px;
  border-color: var(--fact); }

/* ---- Sidebar hybride (bureau ≥ 900 px) — patron Reco (reco.css) adapté au violet FACT.
       DISPOSITION PAR DÉFAUT de la suite (décision 06-07) ; « barra » (topnav seule) =
       option PAR COMPTE via ⚙️ Mi perfil. body.with-side est posé CÔTÉ SERVEUR par
       base.html — aucun JS, aucun flash de mise en page. ---- */
.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; }
/* le CONTENU scrolle dans .wrap → topbar et sidebar restent visibles (leçon Reco 06-07) ;
   écrans larges : le bureau UTILISE l'écran (max-width levé, comme Reco) */
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(--fact-soft); color: var(--fact-d); font-weight: 600; }
.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; }   /* la sidebar EST la nav */
  body.with-side .topbar > .brand { display: none; }  /* la marque vit dans la sidebar */
}
@media (max-width: 899px) {
  /* petit écran : gabarit classique de FACT (topnav, puis règles ≤ 680 px plus bas) —
     la sidebar est une affaire de BUREAU, le mobile ne change pas (comportement Reco) */
  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; }
}

/* ---- Responsive (mobile-first suite : cibles 44px, font 16px inputs) ---- */
@media (max-width: 1000px) {
  .modules { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  /* mobile/PWA (16-07) : la topnav reste VISIBLE et défile horizontalement — sans elle,
     aucun lien de navigation sur téléphone (sidebar = bureau seulement) */
  .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; }
}
