/* =====================================================================
   AgriLink — Plateforme web institutionnelle
   Design System AgriLink (déclinaison web : back-office & espace acteur)
   Sobriété, hiérarchie typographique, grille structurée, vert institutionnel.
   ===================================================================== */

/* ---------- 1. Jetons ---------- */
:root {
  --green-900: #0F3D22;
  --green-800: #14502B;
  --green-700: #1B6B3A;   /* couleur principale */
  --green-600: #25804A;
  --green-500: #3A9A5F;
  --green-400: #63B383;
  --green-300: #9CCFB0;
  --green-200: #BFE0CB;
  --green-100: #DDEFE3;
  --green-50:  #EEF6F0;

  --ink-900: #16201B;
  --ink-800: #263029;
  --ink-700: #3C4A42;
  --ink-500: #6B7A72;
  --ink-400: #8C9992;
  --ink-300: #B8C3BD;
  --ink-200: #DCE3DF;
  --ink-150: #E7ECE9;
  --ink-100: #EEF1EF;
  --ink-50:  #F6F8F7;
  --surface: #FFFFFF;

  --amber-700: #9A6512;
  --amber-500: #C27C1A;
  --amber-100: #F6E6C8;
  --amber-50:  #FBF3E4;
  --red-700:   #8F2A24;
  --red-500:   #B3261E;
  --red-50:    #FBEAE8;
  --ochre:     #E4B94A;
  --water:     #9FC5D8;

  --font: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 26px; --fs-3xl: 32px;

  --radius: 8px; --radius-sm: 6px; --radius-lg: 12px;
  --border: 1px solid var(--ink-200);
  --shadow-sm: 0 1px 2px rgba(22,32,27,.05);
  --shadow-md: 0 4px 16px rgba(22,32,27,.08);
  --shadow-lg: 0 16px 48px rgba(22,32,27,.16);
  --sidebar-w: 248px;
  --header-h: 60px;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: 1.5; color: var(--ink-900); background: var(--ink-50); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; display: block; }
svg { display: inline-block; vertical-align: middle; flex: none; }
svg:not([class]) { width: 1.15em; height: 1.15em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--green-500); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-500); }
.small { font-size: var(--fs-sm); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--sidebar { grid-template-columns: 2fr 1fr; }
.grid--main-aside { grid-template-columns: minmax(0, 1fr) 360px; }
.span-2 { grid-column: span 2; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mb-2 { margin-bottom: 16px; }

/* ---------- 3. Page de connexion ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login__brand { background: var(--green-800); color: #fff; padding: 56px 64px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login__brand::after { content: ""; position: absolute; right: -120px; bottom: -160px; width: 520px; height: 520px; border-radius: 50%; border: 80px solid rgba(255,255,255,.05); }
.login__logo { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.login__logo img { width: 40px; height: 40px; }
.login__headline { margin-top: auto; max-width: 480px; }
.login__headline h1 { font-size: 34px; font-weight: 600; line-height: 1.2; margin-bottom: 14px; }
.login__headline p { font-size: 16px; opacity: .85; line-height: 1.6; }
.login__facts { display: flex; gap: 32px; margin-top: 36px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,.18); }
.login__facts b { display: block; font-size: 24px; font-weight: 600; }
.login__facts span { font-size: 13px; opacity: .8; }
.login__foot { margin-top: 40px; font-size: 12px; opacity: .65; }
.login__form { display: flex; align-items: center; justify-content: center; padding: 48px 32px; background: var(--surface); }
.login__card { width: 100%; max-width: 400px; }
.login__card h2 { font-size: 24px; margin-bottom: 6px; }
.login__card > p { color: var(--ink-500); margin-bottom: 28px; }
.login__demo { margin-top: 28px; padding: 16px; border-radius: var(--radius); background: var(--ink-50); border: var(--border); }
.login__demo h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); margin-bottom: 10px; }
.login__demo-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; text-align: left; }
.login__demo-btn:hover { background: #fff; border-color: var(--ink-200); }
.login__demo-btn b { display: block; font-weight: 600; }
.login__demo-btn span { font-size: 12px; color: var(--ink-500); }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login__brand { padding: 32px 24px; min-height: 260px; } .login__headline h1 { font-size: 26px; } .login__facts { display: none; } }

/* ---------- 4. Coque back-office (administrateur) ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 16px; border-bottom: var(--border); }
.sidebar__brand img { width: 32px; height: 32px; }
.sidebar__brand b { font-size: 17px; font-weight: 700; letter-spacing: -.02em; color: var(--green-900); display: block; line-height: 1.1; }
.sidebar__brand span { font-size: 11px; color: var(--ink-500); text-transform: uppercase; letter-spacing: .06em; }
.sidebar__group { padding: 14px 12px 4px; }
.sidebar__label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-400); padding: 0 10px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink-700); font-weight: 500; margin-bottom: 2px; }
.nav-item:hover { background: var(--ink-50); text-decoration: none; color: var(--ink-900); }
.nav-item.is-active { background: var(--green-50); color: var(--green-800); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; color: var(--ink-400); }
.nav-item.is-active svg { color: var(--green-700); }
.nav-item .count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--amber-100); color: var(--amber-700); padding: 1px 7px; border-radius: 999px; }
.sidebar__foot { margin-top: auto; padding: 14px 16px; border-top: var(--border); font-size: 12px; color: var(--ink-500); }
.sidebar__foot b { display: block; color: var(--ink-700); font-weight: 600; }
.sidebar__status { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.sidebar__status i { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); }

.main { min-width: 0; display: flex; flex-direction: column; }
.header { height: var(--header-h); display: flex; align-items: center; gap: 16px; padding: 0 32px; background: var(--surface); border-bottom: var(--border); position: sticky; top: 0; z-index: 20; }
.header__crumb { font-size: var(--fs-sm); color: var(--ink-500); display: flex; align-items: center; gap: 6px; }
.header__crumb b { color: var(--ink-900); font-weight: 600; }
.header__search { margin-left: auto; position: relative; width: 300px; }
.header__search input { width: 100%; height: 36px; padding: 0 12px 0 36px; border: var(--border); border-radius: var(--radius-sm); background: var(--ink-50); font: inherit; }
.header__search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-400); }
.header__search-results { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 6px; z-index: 30; }
.header__search-results a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--ink-900); font-size: var(--fs-sm); }
.header__search-results a:hover { background: var(--ink-50); text-decoration: none; }
.header__search-results .k { font-size: 11px; color: var(--ink-500); margin-left: auto; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--ink-700); position: relative; }
.icon-btn:hover { background: var(--ink-50); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber-500); border: 2px solid #fff; }
.user-menu { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: var(--radius-sm); }
.user-menu:hover { background: var(--ink-50); }
.user-menu__name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; }
.user-menu__role { font-size: 11px; color: var(--ink-500); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--green-700); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.avatar--soft { background: var(--green-100); color: var(--green-800); }
.popover { position: absolute; top: 100%; right: 0; margin-top: 6px; background: #fff; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 300px; z-index: 40; }
.popover__head { padding: 12px 14px; border-bottom: var(--border); font-weight: 600; font-size: var(--fs-sm); display: flex; justify-content: space-between; align-items: center; }
.popover__item { display: flex; gap: 10px; padding: 10px 14px; font-size: var(--fs-sm); border-bottom: 1px solid var(--ink-100); }
.popover__item:last-child { border-bottom: 0; }
.popover__item b { display: block; font-weight: 600; }
.popover__item span { color: var(--ink-500); }
.popover__item svg { width: 16px; height: 16px; color: var(--green-700); margin-top: 2px; }
.popover__menu a, .popover__menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; font-size: var(--fs-sm); color: var(--ink-800); text-align: left; }
.popover__menu a:hover, .popover__menu button:hover { background: var(--ink-50); text-decoration: none; }
.popover__menu svg { width: 16px; height: 16px; color: var(--ink-500); }

.content { padding: 28px 32px 48px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head__text p { color: var(--ink-500); margin-top: 4px; max-width: 720px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- 5. Coque espace acteur (portail) ---------- */
.portal { min-height: 100vh; display: flex; flex-direction: column; background: var(--surface); }
.portal__header { background: var(--surface); border-bottom: var(--border); position: sticky; top: 0; z-index: 20; }
.portal__bar { display: flex; align-items: center; gap: 28px; height: 64px; padding: 0 32px; max-width: 1240px; margin: 0 auto; }
.portal__logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--green-900); letter-spacing: -.02em; }
.portal__logo img { width: 32px; height: 32px; }
.portal__logo small { display: block; font-size: 11px; font-weight: 500; color: var(--ink-500); letter-spacing: .04em; text-transform: uppercase; }
.portal__nav { display: flex; gap: 4px; height: 100%; }
.portal__nav a { display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; height: 100%; white-space: nowrap; color: var(--ink-700); font-weight: 500; border-bottom: 2px solid transparent; }
.portal__nav a:hover { color: var(--ink-900); text-decoration: none; }
.portal__nav a.is-active { color: var(--green-800); border-bottom-color: var(--green-700); font-weight: 600; }
.portal__nav svg { width: 17px; height: 17px; }
.portal__right { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.portal__hero { background: var(--green-800); color: #fff; }
.portal__hero-inner { max-width: 1240px; margin: 0 auto; padding: 36px 32px; display: flex; align-items: flex-end; gap: 32px; }
.portal__hero h1 { font-size: 28px; font-weight: 600; }
.portal__hero p { opacity: .85; margin-top: 6px; max-width: 620px; }
.portal__hero-kpis { margin-left: auto; display: flex; gap: 12px; }
.portal__hero-kpis div { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius); padding: 12px 18px; min-width: 130px; }
.portal__hero-kpis b { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; }
.portal__hero-kpis span { font-size: 12px; opacity: .8; }
.portal__content { max-width: 1240px; margin: 0 auto; width: 100%; padding: 32px 32px 56px; flex: 1; }
.portal__foot { border-top: var(--border); background: var(--ink-50); }
.portal__foot-inner { max-width: 1240px; margin: 0 auto; padding: 20px 32px; font-size: 12px; color: var(--ink-500); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.portal__foot a { color: var(--ink-700); }

/* ---------- 6. Panneaux, KPI ---------- */
.panel { background: var(--surface); border: var(--border); border-radius: var(--radius); }
.panel__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: var(--border); }
.panel__head h3 { font-size: 15px; font-weight: 600; }
.panel__head p { font-size: var(--fs-sm); color: var(--ink-500); margin-top: 2px; }
.panel__head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel__body { padding: 20px; }
.panel__body--flush { padding: 0; }
.panel__foot { padding: 12px 20px; border-top: var(--border); font-size: var(--fs-sm); color: var(--ink-500); display: flex; align-items: center; gap: 12px; }
.panel--soft { background: var(--green-50); border-color: var(--green-200); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-height: 110px; }
.kpi__label { font-size: var(--fs-sm); color: var(--ink-500); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi__label svg { width: 16px; height: 16px; color: var(--green-600); }
.kpi__value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__delta { font-size: var(--fs-xs); color: var(--ink-500); display: flex; align-items: center; gap: 6px; margin-top: auto; }
.kpi__delta b { color: var(--green-700); font-weight: 600; white-space: nowrap; }
.kpi__delta b.down { color: var(--amber-700); }
.kpi__spark { margin-top: 4px; }

/* ---------- 7. Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); font-weight: 500; font-size: var(--fs-md); border: 1px solid transparent; white-space: nowrap; transition: background .12s; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--green-700); color: #fff; }
.btn--primary:hover { background: var(--green-800); }
.btn--secondary { background: var(--surface); color: var(--ink-800); border-color: var(--ink-300); }
.btn--secondary:hover { background: var(--ink-50); }
.btn--ghost { color: var(--green-800); }
.btn--ghost:hover { background: var(--green-50); }
.btn--danger { background: var(--surface); color: var(--red-700); border-color: #F1C9C5; }
.btn--danger:hover { background: var(--red-50); }
.btn--sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn--lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.is-loading { pointer-events: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; flex: none; }
.btn--secondary .spinner, .spinner--dark { border-color: var(--green-200); border-top-color: var(--green-700); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 8. Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-800); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-500); }
.field .error { font-size: var(--fs-xs); color: var(--red-700); display: flex; align-items: center; gap: 4px; }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--ink-300); border-radius: var(--radius-sm); background: var(--surface); font: inherit; color: var(--ink-900); }
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px var(--green-100); }
.input.is-error { border-color: var(--red-500); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7A72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-400); }
.input-icon .input { padding-left: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.check input { width: 16px; height: 16px; accent-color: var(--green-700); }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--ink-300); transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.is-on { background: var(--green-600); }
.switch.is-on::after { transform: translateX(16px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--ink-100); }
.switch-row:last-child { border-bottom: 0; }
.switch-row b { display: block; font-weight: 600; font-size: var(--fs-md); }
.switch-row span { font-size: var(--fs-sm); color: var(--ink-500); }

/* ---------- 9. Filtres, puces, onglets ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: var(--border); flex-wrap: wrap; }
.toolbar .input-icon { width: 280px; }
.toolbar .select { width: auto; min-width: 150px; height: 36px; }
.toolbar__right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.toolbar__count { font-size: var(--fs-sm); color: var(--ink-500); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--ink-300); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; color: var(--ink-700); }
.chip svg { width: 14px; height: 14px; }
.chip:hover { border-color: var(--ink-400); }
.chip.is-active { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: var(--border); margin-bottom: 20px; }
.tab { padding: 10px 14px; font-weight: 500; color: var(--ink-500); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink-900); }
.tab.is-active { color: var(--green-800); border-bottom-color: var(--green-700); font-weight: 600; }
.tab .count { margin-left: 6px; font-size: 11px; background: var(--ink-100); padding: 1px 6px; border-radius: 999px; color: var(--ink-700); }
.segmented { display: inline-flex; border: var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { height: 32px; padding: 0 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-700); border-right: var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button.is-active { background: var(--green-50); color: var(--green-800); font-weight: 600; }

/* ---------- 10. Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--green-100); color: var(--green-800); }
.badge--warn { background: var(--amber-50); color: var(--amber-700); }
.badge--err { background: var(--red-50); color: var(--red-700); }
.badge--neutral { background: var(--ink-100); color: var(--ink-700); }
.badge--info { background: var(--green-50); color: var(--green-700); }
.badge--plain::before { display: none; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--ink-100); color: var(--ink-700); font-size: var(--fs-xs); font-weight: 500; }
.tag--green { background: var(--green-50); color: var(--green-800); }
.crop-icons { display: inline-flex; gap: 3px; }
.crop-icons img { width: 20px; height: 20px; border-radius: 4px; }

/* ---------- 11. Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td { padding: 11px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--ink-100); }
.table th { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); background: var(--ink-50); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink-900); }
.table th .sort { display: inline-block; width: 12px; height: 12px; margin-left: 4px; vertical-align: -1px; opacity: .5; }
.table th.is-sorted .sort { opacity: 1; color: var(--green-700); }
.table tbody tr:hover { background: var(--ink-50); }
.table tbody tr.is-selected { background: var(--green-50); }
.table td.primary { font-weight: 600; }
.table .cell-user > div { min-width: 0; }
.table .cell-user a { display: block; line-height: 1.3; }
.table td .sub { display: block; font-size: var(--fs-xs); color: var(--ink-500); font-weight: 400; }
.table .row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .6; }
.table tbody tr:hover .row-actions { opacity: 1; }
.table .cell-user { display: flex; align-items: center; gap: 10px; }
.table .cell-user .avatar { width: 30px; height: 30px; font-size: 11px; }
.table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--green-700); }
.table--compact th, .table--compact td { padding: 8px 12px; }
.pagination { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.pagination button { min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm); border: var(--border); background: var(--surface); font-size: var(--fs-sm); color: var(--ink-700); }
.pagination button.is-active { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.pagination button[disabled] { opacity: .4; pointer-events: none; }
.bulk { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--green-50); border-bottom: 1px solid var(--green-200); font-size: var(--fs-sm); }
.bulk b { color: var(--green-800); }

/* ---------- 12. Tiroir latéral et modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(22,32,27,.4); z-index: 50; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100%; background: var(--surface); z-index: 51; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px; border-bottom: var(--border); }
.drawer__head h2 { font-size: 18px; }
.drawer__head .close { margin-left: auto; }
.drawer__body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.drawer__foot { padding: 14px 24px; border-top: var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--ink-50); }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: var(--fs-md); }
.dl dt { color: var(--ink-500); font-size: var(--fs-sm); }
.dl dd { margin: 0; font-weight: 500; }
.section-title { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 8px 0; font-size: var(--fs-sm); border-bottom: 1px solid var(--ink-100); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-500); white-space: nowrap; min-width: 118px; font-variant-numeric: tabular-nums; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 560px; max-width: calc(100% - 32px); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 52; animation: pop .15s ease-out; max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
@keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.modal--wide { width: 760px; }
.modal__head { padding: 20px 24px 12px; display: flex; align-items: flex-start; gap: 12px; }
.modal__head h2 { font-size: 18px; }
.modal__head p { color: var(--ink-500); margin-top: 4px; font-size: var(--fs-sm); }
.modal__body { padding: 8px 24px 20px; overflow-y: auto; }
.modal__foot { padding: 14px 24px; border-top: var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal--confirm .modal__body { color: var(--ink-700); }
.steps-indicator { display: flex; gap: 8px; margin-bottom: 20px; }
.steps-indicator span { flex: 1; height: 4px; border-radius: 2px; background: var(--ink-200); }
.steps-indicator span.is-done { background: var(--green-600); }

/* ---------- 13. Toasts & alertes ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; align-items: center; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: var(--radius); background: var(--ink-900); color: #fff; font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; }
.toast svg { width: 18px; height: 18px; color: var(--green-300); }
.toast--warn svg { color: var(--ochre); }
.toast--error svg { color: #F2A29B; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); font-size: var(--fs-md); border: 1px solid; }
.alert svg { width: 18px; height: 18px; margin-top: 2px; }
.alert--info { background: var(--green-50); border-color: var(--green-200); color: var(--green-900); }
.alert--warn { background: var(--amber-50); border-color: var(--amber-100); color: var(--amber-700); }
.alert--error { background: var(--red-50); border-color: #F1C9C5; color: var(--red-700); }
.alert b { font-weight: 600; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-500); }
.empty svg { width: 36px; height: 36px; color: var(--ink-300); margin-bottom: 8px; }

/* ---------- 14. Listes & cartes de contenu ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--ink-100); }
.list li:last-child { border-bottom: 0; }
.list .rank { width: 22px; height: 22px; border-radius: 50%; background: var(--ink-100); color: var(--ink-700); font-size: 11px; font-weight: 600; display: grid; place-items: center; flex: none; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.list .meta { font-size: var(--fs-xs); color: var(--ink-500); display: block; }
.list .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--ink-100); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green-600); border-radius: 3px; }
.bar--amber i { background: var(--amber-500); }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 60px; align-items: center; gap: 12px; font-size: var(--fs-sm); }
.hbar .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.res-card { background: var(--surface); border: var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; text-align: left; transition: box-shadow .12s, border-color .12s; }
.res-card:hover { border-color: var(--green-300); box-shadow: var(--shadow-md); }
.res-card__media { height: 120px; background: var(--green-50); display: grid; place-items: center; position: relative; border-bottom: var(--border); }
.res-card__media img { width: 64px; height: 64px; }
.res-card__media svg { width: 36px; height: 36px; color: var(--green-600); }
.res-card__type { position: absolute; top: 10px; left: 10px; }
.res-card__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.res-card__title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.res-card__meta { font-size: var(--fs-xs); color: var(--ink-500); display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.actor-card { display: flex; gap: 14px; padding: 16px; background: var(--surface); border: var(--border); border-radius: var(--radius); text-align: left; transition: border-color .12s, box-shadow .12s; }
.actor-card:hover { border-color: var(--green-300); box-shadow: var(--shadow-md); }
.actor-card .avatar--soft svg { width: 22px; height: 22px; }
.actor-card__name { font-weight: 600; font-size: 15px; }
.actor-card__meta { font-size: var(--fs-sm); color: var(--ink-500); margin-top: 2px; }
.actor-card__tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- 15. Graphiques (SVG natif) ---------- */
.chart { width: 100%; height: auto; display: block; font-family: inherit; }
.chart text { font-size: 11px; fill: var(--ink-500); }
.chart .grid-line { stroke: var(--ink-150); stroke-width: 1; }
.chart .axis { stroke: var(--ink-300); }
.chart .line { fill: none; stroke: var(--green-700); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line--2 { stroke: var(--green-300); }
.chart .area { fill: var(--green-100); opacity: .7; }
.chart .bar { fill: var(--green-600); }
.chart .bar:hover { fill: var(--green-800); }
.chart .bar--muted { fill: var(--green-200); }
.chart .dot { fill: #fff; stroke: var(--green-700); stroke-width: 2; }
.chart .dot--end { fill: var(--green-700); }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-700); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-tip { position: fixed; pointer-events: none; background: var(--ink-900); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 6px; z-index: 70; white-space: nowrap; box-shadow: var(--shadow-md); }
.chart-tip b { font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-sm); flex: 1; }
.donut-legend div { display: flex; align-items: center; gap: 8px; }
.donut-legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8px; }
.spark { display: block; }
.spark path { fill: none; stroke: var(--green-600); stroke-width: 1.5; }
.spark .fill { fill: var(--green-100); stroke: none; }

/* ---------- 16. Cartographie ---------- */
.map-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 0; border: var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); height: calc(100vh - 220px); min-height: 560px; }
.map-side { border-right: var(--border); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.map-side__head { padding: 14px 16px; border-bottom: var(--border); display: flex; flex-direction: column; gap: 10px; }
.map-side__list { overflow-y: auto; flex: 1; min-height: 0; }
.map-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 16px; border-bottom: 1px solid var(--ink-100); text-align: left; }
.map-item:hover { background: var(--ink-50); }
.map-item.is-active { background: var(--green-50); }
.map-item .avatar { width: 30px; height: 30px; }
.map-item .avatar svg { width: 16px; height: 16px; }
.map-item b { display: block; font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-item span { font-size: var(--fs-xs); color: var(--ink-500); }
.map-stage { position: relative; background: #E9EFE3; overflow: hidden; min-height: 0; }
.map-stage svg.geo { width: 100%; height: 100%; display: block; cursor: grab; }
.map-stage.is-dragging svg.geo { cursor: grabbing; }
.map-controls { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 6px; }
.map-controls button { width: 34px; height: 34px; border-radius: var(--radius-sm); background: #fff; border: var(--border); box-shadow: var(--shadow-sm); display: grid; place-items: center; color: var(--ink-700); font-weight: 600; }
.map-controls button svg { width: 16px; height: 16px; }
.map-layers { position: absolute; top: 14px; left: 14px; background: rgba(255,255,255,.96); border: var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow-sm); font-size: var(--fs-sm); min-width: 190px; }
.map-layers h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); margin-bottom: 8px; }
.map-layers .check { padding: 3px 0; }
.map-legend { position: absolute; left: 14px; bottom: 14px; background: rgba(255,255,255,.96); border: var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: var(--fs-xs); box-shadow: var(--shadow-sm); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--green-700); display: inline-block; }
.map-popup { position: absolute; right: 14px; bottom: 14px; width: 320px; background: #fff; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 14px 16px; }
.map-popup h4 { font-size: 15px; margin-bottom: 2px; }
.map-popup .close { position: absolute; top: 6px; right: 6px; }
.map-popup p { font-size: var(--fs-sm); color: var(--ink-700); margin-top: 6px; }
.map-popup .actions { display: flex; gap: 8px; margin-top: 12px; }
.map-scale { position: absolute; right: 14px; bottom: 14px; font-size: 10px; color: var(--ink-700); display: flex; flex-direction: column; align-items: center; }
.map-scale i { width: 60px; height: 4px; border: 1px solid var(--ink-700); border-top: 0; display: block; }
.geo .commune-shape { fill: #E4ECDD; stroke: #B9C9B3; stroke-width: .5; transition: fill .12s; }
.geo .commune-shape.is-priority { fill: #DCE8D3; }
.geo .commune-shape:hover, .geo .commune-shape.is-active { fill: #CDE0C5; }
.geo .commune-label { font-size: 3.4px; font-weight: 600; fill: var(--ink-700); text-anchor: middle; pointer-events: none; letter-spacing: .05em; }
.geo .colline-label { font-size: 2.2px; fill: #7E9B8A; text-anchor: middle; pointer-events: none; }
.geo .province-label { font-size: 4.5px; fill: #8C9992; text-anchor: middle; pointer-events: none; letter-spacing: .2em; font-weight: 600; opacity: .7; }
.geo .river { fill: none; stroke: var(--water); stroke-width: 1; stroke-linecap: round; }
.geo .road { fill: none; stroke: #fff; stroke-width: 1.4; }
.geo .road-c { fill: none; stroke: #CDBB93; stroke-width: .6; }
.geo .marker { cursor: pointer; }
.geo .marker .halo { fill: rgba(27,107,58,.14); }
.geo .marker .body { fill: var(--green-700); }
.geo .marker.is-active .body { fill: var(--amber-500); }
.geo .marker.is-active .halo { fill: rgba(194,124,26,.25); }
.geo .marker.is-dim { opacity: .2; pointer-events: none; }
.geo .marker.st-attente .body { fill: var(--amber-700); }
.geo .marker.st-inactif .body { fill: var(--ink-400); }
.geo .heat { fill: var(--green-700); opacity: .12; pointer-events: none; }
.geo .filiere-pill { font-size: 2.2px; fill: #fff; font-weight: 600; text-anchor: middle; pointer-events: none; }
.map-zone-panel { position: absolute; right: 14px; top: 14px; width: 280px; background: #fff; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 14px 16px; margin-right: 44px; }
.map-zone-panel h4 { font-size: 15px; }
.map-zone-panel .dl { grid-template-columns: 110px 1fr; margin-top: 10px; font-size: var(--fs-sm); }

/* ---------- 17. Météo (espace acteur) ---------- */
.wx-card { background: var(--green-800); color: #fff; border-radius: var(--radius); padding: 22px 24px; display: flex; align-items: center; gap: 22px; }
.wx-card svg { width: 64px; height: 64px; color: var(--ochre); }
.wx-card .temp { font-size: 44px; font-weight: 600; line-height: 1; }
.wx-card .label { opacity: .9; margin-top: 4px; }
.wx-card .metrics { margin-left: auto; display: flex; gap: 20px; font-size: var(--fs-sm); }
.wx-card .metrics b { display: block; font-size: 18px; }
.wx-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.wx-day { text-align: center; padding: 12px 6px; border: var(--border); border-radius: var(--radius); font-size: var(--fs-sm); }
.wx-day svg { width: 26px; height: 26px; color: var(--green-700); margin: 6px 0; }
.wx-day b { display: block; font-weight: 600; }
.wx-day .rain { color: #3F6E8E; font-size: var(--fs-xs); }

/* ---------- 18. Paramétrage : matrice des permissions ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .dot-ok { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: var(--green-100); color: var(--green-800); line-height: 18px; font-size: 11px; }
.matrix .dot-no { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-100); }

/* ---------- 19. Journal ---------- */
.lvl { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.lvl--info { background: var(--ink-300); } .lvl--ok { background: var(--green-500); } .lvl--warn { background: var(--amber-500); } .lvl--alert { background: var(--red-500); }
.health { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.health div { border: var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: var(--fs-sm); }
.health b { display: block; font-size: 18px; font-weight: 600; margin-top: 2px; }
.health .badge { margin-top: 6px; }

/* ---------- 20. Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
  .grid--main-aside { grid-template-columns: 1fr; }
  .health { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; z-index: 45; }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .header { padding: 0 16px; }
  .header__search { width: 200px; }
  .content { padding: 20px 16px 40px; }
  .grid--2, .grid--sidebar { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; height: auto; }
  .map-side { max-height: 260px; border-right: 0; border-bottom: var(--border); }
  .map-stage { height: 520px; }
  .portal__bar { padding: 0 16px; gap: 12px; overflow-x: auto; }
  .portal__nav a span { display: none; }
  .portal__hero-inner, .portal__content { padding-left: 16px; padding-right: 16px; }
  .portal__hero-kpis { display: none; }
  .wx-days { grid-template-columns: repeat(4, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
@media (max-width: 640px) {
  .kpis, .grid--3, .grid--4, .res-grid, .health { grid-template-columns: 1fr; }
  .toolbar .input-icon { width: 100%; }
  .header__search { display: none; }
  .user-menu__name, .user-menu__role { display: none; }
  .wx-card { flex-wrap: wrap; }
  .wx-card .metrics { margin-left: 0; }
}
.menu-btn { display: none; }
@media (max-width: 1000px) { .menu-btn { display: grid; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .sidebar, .header, .toasts, .page-head__actions { display: none !important; } .app { display: block; } }
