/* AviTrack — feuille de style unique
   Identité : inox (acier brossé #E8E8E8 → #C0C0C0), vert #2D6A4F et or #FFD700.
   Les matières (panneaux, boutons métal) sont des dégradés CSS : aucune image, compatible CSP. */

:root {
  color-scheme: light;
  --brand-green: #2D6A4F;
  --brand-green-deep: #1B4332;
  --brand-gold: #FFD700;
  --on-gold: #1B4332;

  /* Inox : fond acier #E8E8E8 → #C0C0C0 */
  --bg: #d4d4d4;
  --bg-image:
    radial-gradient(ellipse 80% 55% at 18% -8%, rgb(255 255 255 / 75%), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgb(255 255 255 / 30%), transparent 70%),
    repeating-linear-gradient(90deg, rgb(255 255 255 / 7%) 0 1px, rgb(0 0 0 / 2.5%) 1px 2px, transparent 2px 4px),
    linear-gradient(165deg, #e8e8e8 0%, #d8d8d8 40%, #cacaca 70%, #c0c0c0 100%);
  --surface: #ededed;          /* couleur pleine (champs, contours) */
  --surface-2: #dedede;
  --border: #b4b4b4;
  --text: #151a17;
  --text-2: #3a423d;           /* ≥ 4,5:1 même sur #C0C0C0 */
  --text-3: #555d58;
  --primary: #2d6a4f;
  --primary-hover: #1b4332;
  --primary-strong: #1b4332;   /* texte vert posé directement sur le fond acier */
  --primary-soft: #dcebe2;
  --on-primary: #ffffff;
  --gold-soft: #fff5c2;
  --gold-ink: #6b5200;
  --good: #17703d;
  --good-soft: #d7ecdf;
  --warning: #8a5800;
  --warning-soft: #f8ead0;
  --critical: #b02a27;
  --critical-soft: #f6dcdb;
  --info: #1f5690;
  --info-soft: #d9e6f4;

  /* Matières */
  --hairline: repeating-linear-gradient(90deg, rgb(255 255 255 / 10%) 0 1px, rgb(0 0 0 / 1.8%) 1px 2px, transparent 2px 4px);
  --panel: linear-gradient(180deg, #fbfbfb 0%, #f1f1f1 45%, #e6e6e6 100%);
  --panel-alt: linear-gradient(180deg, #f3f3f3 0%, #e4e4e4 100%);
  --panel-border: #b5b5b5;
  --bevel: inset 0 1px 0 rgb(255 255 255 / 95%), inset 0 -1px 0 rgb(0 0 0 / 6%);
  --shadow: 0 1px 2px rgb(20 24 22 / 14%), 0 6px 18px rgb(20 24 22 / 10%);
  --shadow-lg: 0 18px 50px rgb(10 14 12 / 32%);
  --groove: #c9c9c9;
  --groove-shadow: inset 0 1px 2px rgb(0 0 0 / 22%);
  --steel-btn: linear-gradient(180deg, #fefefe 0%, #ececec 48%, #dadada 52%, #d0d0d0 100%);
  --steel-btn-border: #9e9e9e;
  --green-metal: linear-gradient(180deg, #43916d 0%, #2d6a4f 46%, #245a42 54%, #1b4332 100%);
  --gold-metal: linear-gradient(180deg, #fff6b0 0%, #ffe24d 24%, #ffd700 50%, #e3b400 76%, #c99a00 100%);
  /* Or poli : reflet clair en haut, ligne d'horizon sombre au milieu, retour de lumière en bas */
  --gold-text: linear-gradient(180deg, #fffbe6 0%, #ffe477 20%, #f5c400 40%, #8c6400 49%, #5c4200 52%, #c89600 58%, #ffdb4d 74%, #fff2b0 90%, #d6a600 100%);
  --gold-brush: repeating-linear-gradient(90deg, rgb(255 255 255 / 14%) 0 1px, transparent 1px 3px);
  --topbar-bg:
    repeating-linear-gradient(90deg, rgb(255 255 255 / 3%) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #2f7054 0%, #245a42 50%, #1b4332 100%);
  --radius: 12px;
  --radius-sm: 8px;

  /* Palette catégorielle des graphiques (ordre fixe, validée daltonisme) */
  /* Courbes de la fiche d'un lot : bleu / orange / vert, ≥ 3:1 sur le fond des cartes, distinguables en cas de daltonisme (test tests/chart-colours.test.js) */
  --lot-mort: #0b4fb3; --lot-feed: #bd5a00; --lot-weight: #008670;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --grid: #d3d3d3;
  --axis: #a9a9a9;

  --emboss: 0 1px 0 rgb(255 255 255 / 65%);
  --rule-dark: rgb(0 0 0 / 10%);
  --rule-light: rgb(255 255 255 / 75%);
  --sidebar-bg: linear-gradient(90deg, #f0f0f0 0%, #e2e2e2 100%);
  --sidebar-shadow: inset -1px 0 0 rgb(255 255 255 / 70%), 2px 0 10px rgb(0 0 0 / 8%);
  --nav-active-bg: linear-gradient(180deg, #e3efe8 0%, #cfe2d7 100%);
  --nav-active-shadow: inset 0 1px 2px rgb(0 0 0 / 12%), 0 1px 0 rgb(255 255 255 / 80%);
  --field-bg: #fbfbfb;
  --field-border: #a3a3a3;
  --field-shadow: inset 0 1px 3px rgb(0 0 0 / 12%), 0 1px 0 rgb(255 255 255 / 80%);
  --hover-tint: rgb(0 0 0 / 5%);
  --kpi-bar: var(--green-metal);

  --topbar-h: 60px;
  --bottom-h: 64px;
  --sidebar-w: 240px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #2b2e2d;
    --bg-image:
      radial-gradient(ellipse 80% 55% at 18% -8%, rgb(255 255 255 / 9%), transparent 60%),
      repeating-linear-gradient(90deg, rgb(255 255 255 / 2.5%) 0 1px, rgb(0 0 0 / 6%) 1px 2px, transparent 2px 4px),
      linear-gradient(165deg, #3a3e3c 0%, #2e3130 50%, #232625 100%);
    --surface: #353937;
    --surface-2: #2c302e;
    --border: #555b58;
    --text: #f1f3f2;
    --text-2: #c9d0cc;
    --text-3: #b9c1bc;
    --primary: #80d1a6;
    --primary-hover: #8fd4ae;
    --primary-strong: #8fd4ae;
    --primary-soft: #24382d;
    --on-primary: #ffffff;
    --gold-soft: #3a3418;
    --gold-ink: #ffd700;
    --good: #6fd097;
    --good-soft: #213a2b;
    --warning: #f2bb4b;
    --warning-soft: #40341a;
    --critical: #f28b88;
    --critical-soft: #452625;
    --info: #8dbcf0;
    --info-soft: #1f3044;
    --hairline: repeating-linear-gradient(90deg, rgb(255 255 255 / 2.5%) 0 1px, rgb(0 0 0 / 5%) 1px 2px, transparent 2px 4px);
    --panel: linear-gradient(180deg, #474c4a 0%, #3b3f3d 45%, #323634 100%);
    --panel-alt: linear-gradient(180deg, #3f4341 0%, #333735 100%);
    --panel-border: #5c6260;
    --bevel: inset 0 1px 0 rgb(255 255 255 / 10%), inset 0 -1px 0 rgb(0 0 0 / 30%);
    --shadow: 0 1px 2px rgb(0 0 0 / 45%), 0 6px 18px rgb(0 0 0 / 30%);
    --groove: #232625;
    --groove-shadow: inset 0 1px 2px rgb(0 0 0 / 60%);
    --steel-btn: linear-gradient(180deg, #62676a 0%, #505554 48%, #454a48 52%, #3c403f 100%);
    --steel-btn-border: #2a2d2c;
    --lot-mort: #6ea8ff; --lot-feed: #ff8c1a; --lot-weight: #3ddcae;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --grid: #454a48;
    --axis: #6a706d;
    --emboss: 0 1px 0 rgb(0 0 0 / 45%);
    --rule-dark: rgb(0 0 0 / 35%);
    --rule-light: rgb(255 255 255 / 6%);
    --sidebar-bg: linear-gradient(90deg, #3c403f 0%, #313433 100%);
    --sidebar-shadow: inset -1px 0 0 rgb(255 255 255 / 6%), 2px 0 10px rgb(0 0 0 / 30%);
    --nav-active-bg: linear-gradient(180deg, #2c4336 0%, #22362b 100%);
    --nav-active-shadow: inset 0 1px 2px rgb(0 0 0 / 45%);
    --field-bg: #262928;
    --field-border: #1b1d1c;
    --field-shadow: inset 0 1px 3px rgb(0 0 0 / 50%), 0 1px 0 rgb(255 255 255 / 6%);
    --hover-tint: rgb(255 255 255 / 6%);
    --kpi-bar: linear-gradient(180deg, #9be0bb 0%, #52b788 55%, #2d6a4f 100%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #2b2e2d;
  --bg-image:
    radial-gradient(ellipse 80% 55% at 18% -8%, rgb(255 255 255 / 9%), transparent 60%),
    repeating-linear-gradient(90deg, rgb(255 255 255 / 2.5%) 0 1px, rgb(0 0 0 / 6%) 1px 2px, transparent 2px 4px),
    linear-gradient(165deg, #3a3e3c 0%, #2e3130 50%, #232625 100%);
  --surface: #353937;
  --surface-2: #2c302e;
  --border: #555b58;
  --text: #f1f3f2;
  --text-2: #c9d0cc;
  --text-3: #b9c1bc;
  --primary: #80d1a6;
  --primary-hover: #8fd4ae;
  --primary-strong: #8fd4ae;
  --primary-soft: #24382d;
  --on-primary: #ffffff;
  --gold-soft: #3a3418;
  --gold-ink: #ffd700;
  --good: #6fd097;
  --good-soft: #213a2b;
  --warning: #f2bb4b;
  --warning-soft: #40341a;
  --critical: #f28b88;
  --critical-soft: #452625;
  --info: #8dbcf0;
  --info-soft: #1f3044;
  --hairline: repeating-linear-gradient(90deg, rgb(255 255 255 / 2.5%) 0 1px, rgb(0 0 0 / 5%) 1px 2px, transparent 2px 4px);
  --panel: linear-gradient(180deg, #474c4a 0%, #3b3f3d 45%, #323634 100%);
  --panel-alt: linear-gradient(180deg, #3f4341 0%, #333735 100%);
  --panel-border: #5c6260;
  --bevel: inset 0 1px 0 rgb(255 255 255 / 10%), inset 0 -1px 0 rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 45%), 0 6px 18px rgb(0 0 0 / 30%);
  --groove: #232625;
  --groove-shadow: inset 0 1px 2px rgb(0 0 0 / 60%);
  --steel-btn: linear-gradient(180deg, #62676a 0%, #505554 48%, #454a48 52%, #3c403f 100%);
  --steel-btn-border: #2a2d2c;
  --lot-mort: #6ea8ff; --lot-feed: #ff8c1a; --lot-weight: #3ddcae;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --grid: #454a48;
  --axis: #6a706d;
  --emboss: 0 1px 0 rgb(0 0 0 / 45%);
  --rule-dark: rgb(0 0 0 / 35%);
  --rule-light: rgb(255 255 255 / 6%);
  --sidebar-bg: linear-gradient(90deg, #3c403f 0%, #313433 100%);
  --sidebar-shadow: inset -1px 0 0 rgb(255 255 255 / 6%), 2px 0 10px rgb(0 0 0 / 30%);
  --nav-active-bg: linear-gradient(180deg, #2c4336 0%, #22362b 100%);
  --nav-active-shadow: inset 0 1px 2px rgb(0 0 0 / 45%);
  --field-bg: #262928;
  --field-border: #1b1d1c;
  --field-shadow: inset 0 1px 3px rgb(0 0 0 / 50%), 0 1px 0 rgb(255 255 255 / 6%);
  --hover-tint: rgb(255 255 255 / 6%);
  --kpi-bar: linear-gradient(180deg, #9be0bb 0%, #52b788 55%, #2d6a4f 100%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Fond acier fixe (couche dédiée : background-attachment: fixed est ignoré sur iOS) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--bg-image); background-color: var(--bg);
}
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; }
a { color: var(--primary); }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }
.icon { display: inline-flex; flex-shrink: 0; }
.boot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-height: 100vh; background: var(--topbar-bg); color: #fff; font-size: 1.8rem; font-weight: 750; letter-spacing: -0.02em;
}
/* Lettres « métal » du logo : dégradé or poli + brossage, découpés dans le texte.
   Sans prise en charge du découpage (très vieux navigateurs), repli sur un or uni lisible. */
.boot-name, .brand-name, .auth-name { color: var(--brand-gold); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .boot-name, .brand-name, .auth-name {
    background: var(--gold-brush), var(--gold-text);
    -webkit-background-clip: text; background-clip: text;
    color: transparent; -webkit-text-fill-color: transparent;
    -webkit-text-stroke: .5px rgb(74 52 0 / 60%);
  }
}
.boot b, .brand-gold { color: inherit; -webkit-text-fill-color: inherit; }

/* Bloc logo : nom + sous-titre. Le sous-titre ne compte pas dans la largeur du bloc (width 0) mais
   s'étire sur toute sa largeur (min-width 100 %) : il fait donc exactement la largeur de « AviTrack ».
   La taille de texte est ensuite ajustée par fitTagline (ui.js), 10 px minimum, deux lignes au besoin. */
.lockup { display: inline-flex; flex-direction: column; align-items: stretch; min-width: 0; line-height: 1.1; }
.tagline {
  display: block; width: 0; min-width: 100%; margin-top: 3px;
  font-size: var(--tagline-size, .78rem); font-weight: 600; letter-spacing: .02em;
  text-align: center; white-space: nowrap; color: #e4ece7; line-height: 1.15;
}
/* Deux lignes au besoin, coupées entre les mots (un mot n'est coupé que s'il ne tient pas seul) */
.tagline.wrap { white-space: normal; overflow-wrap: break-word; }
.boot .tagline { --tagline-size: .8rem; }

/* ---------- Matières ---------- */
.card, .kpi, .table-wrap, .modal, .auth-card, .update-bar, .chart-tip, .tabs {
  background: var(--hairline), var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--bevel), var(--shadow);
}

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 20px 0 16px;
  background: var(--topbar-bg);
  color: #fff;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, #8a6d00, #ffd700 30%, #fff3a0 50%, #ffd700 70%, #8a6d00) 1;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 15%), 0 3px 12px rgb(0 0 0 / 25%);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: #fff; text-decoration: none; }
.brand img { flex-shrink: 0; border-radius: 9px; box-shadow: 0 0 0 1px rgb(255 215 0 / 55%), 0 2px 6px rgb(0 0 0 / 35%); }
.brand-name {
  font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap;
  filter: drop-shadow(0 1px 0 rgb(0 0 0 / 45%));
}
.topbar .tagline { --tagline-size: .78rem; margin-top: 2px; }
.topbar-spacer { flex: 1; }
.topbar .btn-ghost { color: #fff; }
.topbar .btn-ghost:hover { background: rgb(255 255 255 / 12%); color: #fff; }
.lang-switch { display: inline-flex; border: 1px solid rgb(0 0 0 / 35%); border-radius: 999px; padding: 2px; background: rgb(0 0 0 / 22%); box-shadow: inset 0 1px 2px rgb(0 0 0 / 35%), 0 1px 0 rgb(255 255 255 / 12%); }
.lang-btn {
  border: 0; background: transparent; color: rgb(255 255 255 / 80%); font: inherit; font-size: .78rem; font-weight: 700;
  padding: 4px 11px; border-radius: 999px; cursor: pointer; min-height: 28px; letter-spacing: .03em;
}
.lang-btn.active { background: var(--gold-metal); color: var(--on-gold); box-shadow: inset 0 1px 0 rgb(255 255 255 / 60%), 0 1px 2px rgb(0 0 0 / 40%); }
.menu-toggle { display: none; }

.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 16px; background: var(--warning-soft); color: var(--warning); font-size: .85rem; font-weight: 600;
}
.offline-banner { text-align: center; }
.offline-banner[hidden] { display: none; }
.offline-banner .pending-count { font-variant-numeric: tabular-nums; }
.offline-banner.pending-only { background: var(--info-soft, var(--warning-soft)); color: var(--info, var(--warning)); }

.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  width: var(--sidebar-w); flex-shrink: 0; height: calc(100vh - var(--topbar-h));
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--panel-border); overflow-y: auto;
  background: var(--hairline), var(--sidebar-bg);
  box-shadow: var(--sidebar-shadow);
}
.sidebar-brand { display: none; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 550;
}
.nav-link:hover { background: var(--hover-tint); color: var(--text); }
.nav-link.active { background: var(--nav-active-bg); color: var(--primary-strong); font-weight: 700; box-shadow: var(--nav-active-shadow); }
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--gold-metal); box-shadow: 0 0 6px rgb(255 215 0 / 55%);
}
.nav-link[data-nav="settings"] { margin-top: auto; }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; outline: none; }
.view { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.bottom-nav { display: none; }
.scrim { display: none; }

/* ---------- En-têtes de page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; }
.page-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-title h1 { position: relative; padding-bottom: 10px; margin-bottom: 2px; }
.page-title h1::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 40px; height: 3px; border-radius: 3px;
  background: var(--gold-metal); box-shadow: 0 1px 0 rgb(255 255 255 / 60%);
}
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; text-decoration: none; color: var(--text-2); }
.title-with-badge { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 1.05rem; margin-top: 8px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
  transition: filter .15s, box-shadow .15s, transform .05s;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible, .tab:focus-visible, .lang-btn:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Métal brossé : dégradé + stries + reflet supérieur */
.btn-primary {
  background: var(--hairline), var(--green-metal); color: #fff; border-color: #123224;
  text-shadow: 0 -1px 0 rgb(0 0 0 / 35%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 28%), 0 1px 2px rgb(0 0 0 / 30%), 0 3px 8px rgb(27 67 50 / 25%);
}
.btn-accent {
  background: var(--hairline), var(--gold-metal); color: var(--on-gold); border-color: #a07800;
  text-shadow: 0 1px 0 rgb(255 255 255 / 45%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%), 0 1px 2px rgb(0 0 0 / 30%), 0 3px 10px rgb(201 154 0 / 35%);
}
.btn-secondary {
  background: var(--hairline), var(--steel-btn); color: var(--text); border-color: var(--steel-btn-border);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 90%), 0 1px 2px rgb(0 0 0 / 18%);
}
.btn-primary:hover, .btn-accent:hover, .btn-secondary:hover, .btn-danger:hover { filter: brightness(1.07) saturate(1.05); }
.btn-primary:active, .btn-accent:active, .btn-secondary:active { box-shadow: inset 0 2px 4px rgb(0 0 0 / 30%); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover-tint); color: var(--text); }
.btn-danger {
  background: var(--hairline), linear-gradient(180deg, #d9534f 0%, #b02a27 50%, #8f1f1c 100%); color: #fff; border-color: #6e1715;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 25%), 0 1px 2px rgb(0 0 0 / 30%);
}
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; }

/* ---------- Cartes & KPI ---------- */
.card { border-radius: var(--radius); padding: 16px 18px; }
.card-title {
  display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--rule-dark); box-shadow: 0 1px 0 var(--rule-light);
}
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi { position: relative; border-radius: var(--radius); padding: 14px 16px 14px 18px; overflow: hidden; }
/* Liseré vert-or à gauche, comme une plaque signalétique */
.kpi::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 3px 3px 0; background: var(--kpi-bar); }
.kpi-label { color: var(--text-2); font-size: .8rem; font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; text-shadow: var(--emboss); }
.kpi-sub { color: var(--text-3); font-size: .8rem; margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; white-space: nowrap;
  border: 1px solid rgb(0 0 0 / 10%); box-shadow: inset 0 1px 0 rgb(255 255 255 / 55%);
}
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-critical { background: var(--critical-soft); color: var(--critical); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* ---------- Alertes ---------- */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); border-left: 4px solid currentColor; box-shadow: inset 0 1px 0 rgb(255 255 255 / 45%); }
.alert > div { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.alert-critical { background: var(--critical-soft); color: var(--critical); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert span { color: var(--text); }
.alert-flock { font-weight: 700; color: inherit; }
.ok-line { display: flex; align-items: center; gap: 8px; color: var(--good); }

/* ---------- Lots de reproducteurs ---------- */
.flock-grid, .module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.flock-card { color: var(--text); text-decoration: none; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s; }
.flock-card:hover, .module-card:hover { border-color: var(--primary); }
.flock-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flock-card-head .muted { font-size: .85rem; flex: 1; }
.flock-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cell-flock { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.mini-stats dt { font-size: .75rem; color: var(--text-2); }
.mini-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.module-card { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.module-card > div:nth-child(2) { flex: 1; }
.module-card.planned { opacity: .75; }
.module-icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--topbar-bg); color: var(--brand-gold);
  flex-shrink: 0; border: 1px solid #123224; box-shadow: inset 0 1px 0 rgb(255 255 255 / 20%), inset 0 0 0 1px rgb(255 215 0 / 22%), 0 2px 5px rgb(0 0 0 / 25%);
}
.module-icon.big { width: 72px; height: 72px; border-radius: 20px; }
.coming-soon { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 32px 18px; }
.feature-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.feature-list li { display: flex; gap: 8px; align-items: center; }
.feature-list .icon { color: var(--good); }
.welcome {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--topbar-bg); color: #fff; border-color: #a07800; padding: 22px 24px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 18%), var(--shadow);
}
.welcome p { font-size: 1.05rem; font-weight: 600; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius); overflow-x: auto; scrollbar-width: none; align-self: flex-start; max-width: 100%; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid transparent; background: none;
  font: inherit; font-weight: 650; color: var(--text-2); cursor: pointer; white-space: nowrap; border-radius: var(--radius-sm); min-height: 40px;
}
.tab:hover { background: var(--hover-tint); color: var(--text); }
.tab.active {
  background: var(--hairline), var(--green-metal); color: #fff; border-color: #123224;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 25%), 0 1px 2px rgb(0 0 0 / 30%); text-shadow: 0 -1px 0 rgb(0 0 0 / 30%);
}
.tab-count { background: rgb(0 0 0 / 10%); color: inherit; border-radius: 999px; padding: 0 8px; font-size: .75rem; }
.tab.active .tab-count { background: rgb(255 255 255 / 22%); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.card .table-wrap { border: 0; border-radius: var(--radius-sm); background: none; box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgb(0 0 0 / 9%); white-space: nowrap; }
.table th {
  background: var(--hairline), var(--panel-alt); color: var(--text-2); font-weight: 700; font-size: .76rem;
  text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; box-shadow: inset 0 -1px 0 rgb(0 0 0 / 14%);
}
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: rgb(45 106 79 / 8%); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.toolbar-spacer { flex: 1; }
.inline-field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--text-2); font-weight: 500; }

/* ---------- Formulaires ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--field-bg);
  border: 1px solid var(--field-border); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 44px; width: 100%;
  box-shadow: var(--field-shadow);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.inline-field input, .inline-field select { width: auto; min-width: 140px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form fieldset { border: 0; padding: 0; margin: 0; }
.form legend { font-weight: 700; font-size: .9rem; margin-bottom: 8px; color: var(--primary); padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-full { grid-column: 1 / -1; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.field-hint { color: var(--text-3); font-size: .75rem; }
.req { color: var(--critical); }
.form-error { color: var(--critical); font-weight: 600; min-height: 1.2em; }
.form-error:empty { display: none; }
.preview-line.form-warning { border-left-color: var(--warning); background: var(--warning-soft, var(--primary-soft)); }
.preview-line { padding: 10px 12px; background: var(--primary-soft); color: var(--text); border-radius: var(--radius-sm); font-weight: 600; font-variant-numeric: tabular-nums; border-left: 4px solid var(--primary); box-shadow: inset 0 1px 2px rgb(0 0 0 / 8%); }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / 45%);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--bevel), var(--shadow-lg) !important;
}
.modal-wide { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 14px 20px;
  border-bottom: 2px solid transparent; border-image: linear-gradient(90deg, #8a6d00, #ffd700 40%, #8a6d00) 1;
}
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ---------- Divers ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 16px; text-align: center; color: var(--text-2); }
.empty .icon { color: var(--primary); }

.toasts { position: fixed; z-index: 200; left: 50%; top: calc(var(--topbar-h) + 12px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600;
  background: var(--hairline), linear-gradient(180deg, #3b403e 0%, #262a28 100%); color: #fff; border: 1px solid #111;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%), var(--shadow); transition: opacity .3s, transform .3s;
}
.toast .icon { color: var(--brand-gold); }
/* Erreurs et avertissements : fonds pleins très contrastés (texte blanc, rapport > 7:1), identiques en thème clair et sombre. */
.toast-sticky { align-items: flex-start; padding-right: 8px; max-width: min(560px, calc(100vw - 32px)); line-height: 1.35; border: 2px solid #fff; }
.toast-sticky .toast-text { padding-top: 2px; }
.toast-error { background: #7a1612; color: #fff; }
.toast-error .icon { color: #fff; }
.toast-warning { background: #5c4300; color: #fff; }
.toast-warning .icon { color: #ffe08a; }
.toast-close {
  flex-shrink: 0; min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px; border: 2px solid #fff; border-radius: 50%; background: rgb(255 255 255 / 15%); color: #fff; cursor: pointer;
}
.toast-close:hover { background: rgb(255 255 255 / 30%); }
.toast-close:focus-visible { outline: 3px solid #ffe08a; outline-offset: 2px; }
.toast.out { opacity: 0; transform: translateY(-8px); }

.update-bar {
  position: fixed; z-index: 150; left: 50%; transform: translateX(-50%); bottom: 24px;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: var(--radius);
  max-width: calc(100vw - 32px);
}

/* ---------- Graphiques ---------- */
.chart-plot { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: .82rem; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: .8rem;
}
.tip-title { font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-name { flex: 1; color: var(--text-2); }
.tip-note { color: var(--text-3); font-size: .75rem; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.chart-empty { padding: 24px 0; text-align: center; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.todo-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.todo-item:last-child { border-bottom: 0; }
.todo-item a { color: var(--text); text-decoration: none; }
.todo-item a:hover { color: var(--primary); }
.todo-item .btn { margin-left: auto; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.chart-grid-wide { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.chart-card .chart-last { margin: 10px 0 0; }

/* ---------- Incubateur ---------- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.section-link { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.section-link .icon { color: var(--primary); }
.section-link:hover { color: var(--primary); }

.agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.agenda-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.agenda-item:last-child { border-bottom: 0; }
.agenda-item > div { flex: 1; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.agenda-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.agenda-date { font-size: .85rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.agenda-item.late .agenda-icon { background: var(--critical-soft); color: var(--critical); }
.agenda-item.late .agenda-date { color: var(--critical); }

.meters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.meter-head { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; }
.meter-value { margin-left: auto; font-variant-numeric: tabular-nums; font-size: .85rem; font-weight: 600; }
.meter-track { height: 10px; border-radius: 999px; background: var(--groove); box-shadow: var(--groove-shadow); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; box-shadow: inset 0 1px 0 rgb(255 255 255 / 30%); }
.meter-good { background: var(--green-metal); }
.meter-warning { background: var(--warning); }
.meter-critical { background: var(--critical); }

.day-line { display: flex; align-items: baseline; gap: 4px; }
.day-big { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; color: var(--primary); }
.progress { padding: 4px 0; }
.progress-track { position: relative; height: 10px; border-radius: 999px; background: var(--groove); box-shadow: var(--groove-shadow); }
.progress-fill { height: 100%; border-radius: 999px; background: var(--green-metal); box-shadow: inset 0 1px 0 rgb(255 255 255 / 30%); }
.progress-fill.done { background: var(--good); }
.progress-mark { position: absolute; top: -3px; width: 3px; height: 14px; margin-left: -1px; border-radius: 2px; background: var(--gold-metal); box-shadow: 0 0 0 1px rgb(0 0 0 / 35%); top: -3px; height: 16px; }

.timeline { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step > div { display: flex; flex-direction: column; gap: 2px; }
.step-dot {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--surface); color: var(--on-primary);
}
.step.done .step-dot { background: var(--green-metal); border-color: #123224; box-shadow: inset 0 1px 0 rgb(255 255 255 / 30%); }
.step.late .step-dot { border-color: var(--critical); }
.step.late .muted { color: var(--critical); font-weight: 600; }

.value-alert { display: inline-flex; align-items: center; gap: 4px; color: var(--critical); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Authentification ---------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse 70% 50% at 20% 0%, rgb(255 255 255 / 14%), transparent 60%), radial-gradient(circle at 85% 110%, rgb(255 215 0 / 12%), transparent 45%), var(--topbar-bg);
}
.auth-lang { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; }
.auth-card {
  width: 100%; max-width: 420px; color: var(--text); position: relative;
  border-radius: 16px; padding: 30px 24px 26px; box-shadow: var(--bevel), var(--shadow-lg) !important;
}
.auth-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; border-radius: 16px 16px 0 0;
  background: var(--gold-metal);
}
.auth-wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-brand {
  padding: 12px 16px; border-radius: 12px; background: var(--topbar-bg); border: 1px solid #123224;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 18%), 0 2px 6px rgb(0 0 0 / 25%);
}
.auth-brand img { border-radius: 12px; box-shadow: 0 0 0 1px rgb(255 215 0 / 55%); }
.auth-name {
  font-size: 1.8rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.1;
  filter: drop-shadow(0 1px 0 rgb(0 0 0 / 45%));
}
.auth-brand .tagline { --tagline-size: .92rem; margin-top: 5px; }
.auth-form h1 { font-size: 1.3rem; }
.auth-form .btn-primary { width: 100%; min-height: 46px; font-size: 1rem; white-space: normal; text-align: center; line-height: 1.3; }
.card > p + .form-grid { margin-top: 14px; }
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; font-size: .88rem; color: var(--primary); cursor: pointer; text-decoration: underline; text-align: center; }
.lock-form { text-align: center; align-items: center; }
.lock-form > * { width: 100%; }
.lock-icon { display: grid; place-items: center; width: 60px !important; height: 60px; margin: 0 auto; border-radius: 16px; background: var(--topbar-bg); color: var(--brand-gold); border: 1px solid #123224; box-shadow: inset 0 1px 0 rgb(255 255 255 / 20%), 0 3px 8px rgb(0 0 0 / 25%); }
.pin-input { text-align: center; font-size: 1.6rem; letter-spacing: .5em; font-variant-numeric: tabular-nums; }
.strength { height: 6px; border-radius: 999px; background: var(--groove); box-shadow: var(--groove-shadow); overflow: hidden; margin-top: 2px; }
.strength-fill { height: 100%; width: 0; border-radius: 999px; transition: width .2s; }
.strength[data-level="0"] .strength-fill { width: 8%; background: var(--critical); }
.strength[data-level="1"] .strength-fill { width: 30%; background: var(--critical); }
.strength[data-level="2"] .strength-fill { width: 55%; background: var(--warning); }
.strength[data-level="3"] .strength-fill { width: 80%; background: var(--good); }
.strength[data-level="4"] .strength-fill { width: 100%; background: var(--good); }
.recovery-key {
  display: block; padding: 14px; border-radius: var(--radius-sm); background: var(--gold-soft); color: var(--text);
  border: 1px dashed var(--warning); font: 700 1.05rem/1.6 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: .06em; text-align: center; word-break: break-all; user-select: all;
}
.warning-box, .info-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .9rem; }
.warning-box { background: var(--warning-soft); color: var(--text); }
.warning-box .icon { color: var(--warning); }
.info-box { background: var(--info-soft); color: var(--text); }
.info-box .icon { color: var(--info); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.busy { cursor: progress; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgb(0 0 0 / 22%); color: #fff; font-size: .85rem; font-weight: 600; max-width: 180px; box-shadow: inset 0 1px 2px rgb(0 0 0 / 30%), 0 1px 0 rgb(255 255 255 / 10%); }
.user-chip .icon { color: var(--brand-gold); }
.user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.security-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; font-size: .88rem; color: var(--text-2); }
.security-list li { display: flex; gap: 8px; align-items: center; }
.security-list .icon { color: var(--good); }

/* ---------- Bandeaux (sauvegarde, installation) ---------- */
.banners { display: flex; flex-direction: column; gap: 8px; padding: 12px 32px 0; }
.banners[hidden] { display: none; }
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--hairline), var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--bevel), var(--shadow);
  border-left: 5px solid var(--warning);
}
.banner-install { border-left-color: var(--primary); }
.banner > .icon { color: var(--warning); }
.banner-logo { border-radius: 10px; flex-shrink: 0; box-shadow: 0 0 0 1px rgb(255 215 0 / 55%); }
.banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: .92rem; color: var(--text); }
.banner-text strong { font-size: .98rem; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.ios-share { display: inline-flex; vertical-align: -3px; padding: 1px 3px; border-radius: 5px; background: var(--primary-soft); color: var(--primary-strong); }

/* ---------- Mobile ---------- */
@media (min-width: 901px) {
  .sidebar { transition: width .2s ease, padding .2s ease; }
  .sidebar-collapsed .sidebar { width: 68px; padding-inline: 10px; }
  .sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
  .sidebar-collapsed .nav-link > span:last-child { display: none; }
  .sidebar-collapsed .nav-link.active::before { left: -10px; }
}

@media (max-width: 900px) {
  .menu-toggle { display: none; }
  .drawer-open .bottom-more { color: var(--primary-strong); }
  .nav-link.nav-primary { display: none; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; height: 100vh; width: 280px;
    padding-top: calc(16px + env(safe-area-inset-top));
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .drawer-open .sidebar { transform: none; }
  .sidebar-brand {
    display: block; margin: calc(-16px - env(safe-area-inset-top)) -12px 12px; padding: calc(16px + env(safe-area-inset-top)) 16px 16px;
    background: var(--topbar-bg); border-bottom: 2px solid #c9a000;
  }
  .drawer-open .sidebar { box-shadow: 0 0 40px rgb(0 0 0 / 35%); }
  .drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 40%); }
  .nav-link[data-nav="settings"] { margin-top: 12px; }
  .main { padding: 16px 16px calc(var(--bottom-h) + 24px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--hairline), var(--panel); border-top: 1px solid var(--panel-border);
    box-shadow: var(--bevel), 0 -4px 14px rgb(0 0 0 / 14%);
  }
  .bottom-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--text-2); text-decoration: none; font: inherit; font-size: .7rem; font-weight: 700;
    background: none; border: 0; cursor: pointer; padding: 0 2px; min-width: 0;
  }
  .bottom-link span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bottom-link { position: relative; }
  .bottom-link.active { color: var(--primary-strong); }
  .bottom-link.active::before {
    content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 4px; border-radius: 0 0 4px 4px; background: var(--gold-metal); box-shadow: 0 1px 4px rgb(201 154 0 / 55%);
  }
  .update-bar { bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.3rem; }
  .page-actions { width: 100%; }
  .page-actions .btn-primary, .page-actions .btn-accent { flex: 1 1 100%; }
  .page-actions .btn-secondary { flex: 1 1 auto; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 1.3rem; }
  .two-col { grid-template-columns: 1fr; }
  .banners { padding: 10px 16px 0; gap: 6px; }
  .banner { flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; padding: 10px 12px; }
  .banner-text { flex: 1 1 200px; font-size: .86rem; line-height: 1.4; }
  .banner-text strong { font-size: .92rem; }
  .banner-logo { width: 32px; height: 32px; }
  .banner-actions { width: 100%; justify-content: flex-end; flex-wrap: nowrap; }
  .banner-actions .btn { flex: 0 1 auto; min-width: 0; white-space: normal; text-align: center; line-height: 1.2; }
  .banner-actions .btn-ghost { flex-shrink: 0; white-space: nowrap; }
  .tabs { align-self: stretch; flex-wrap: wrap; overflow-x: visible; }
  .tab { flex: 1 1 auto; min-width: min-content; justify-content: center; text-align: center; padding: 8px 6px; font-size: .92rem; white-space: normal; line-height: 1.2; }
  .user-chip { display: none; }
  .topbar { gap: 2px; padding-right: 10px; }
  .card { padding: 14px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .inline-field { flex: 1 1 140px; }
  .inline-field input, .inline-field select { width: 100%; min-width: 0; }
}

@media (max-width: 420px) {
  .tab-count { display: none; }
}
@media (max-width: 360px) {
  .tab { font-size: .82rem; padding: 8px 4px; }
}

@media (max-width: 480px) {
  .topbar .brand { flex-shrink: 0; }
  /* Un bouton d'une carte (« Exporter une sauvegarde chiffrée », « Générer une nouvelle clé de secours »…) ne dépasse jamais
     la largeur de l'écran : son libellé passe à la ligne (sinon la page entière défile horizontalement sur un petit téléphone). */
  .card .btn { max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; }
}

/* Petits téléphones : le logo reste entier, les commandes se compactent */
@media (max-width: 400px) {
  .topbar { padding-left: 8px; padding-right: 8px; }
  .topbar .brand { gap: 7px; }
  .topbar .brand img { width: 26px; height: 26px; }
  .topbar .brand-name { font-size: 1.24rem; }
  .topbar .btn-icon { width: 32px; min-height: 36px; }
  .lang-btn { padding: 4px 8px; }
}
@media (max-width: 340px) {
  .topbar .brand img { display: none; }
}

@media (max-width: 360px) {
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.persist-warn { display: flex; gap: 6px; align-items: center; color: var(--warning); font-weight: 600; }
.notice-bar { max-width: min(560px, calc(100vw - 32px)); }
.notice-bar .icon { color: var(--info); }

.field-error { color: var(--critical); font-size: .78rem; font-weight: 600; }
.field-error:empty { display: none; }
input[aria-invalid="true"] { border-color: var(--critical); }

/* Œil afficher / masquer */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 52px; }
.pw-eye {
  position: absolute; top: 50%; right: 2px; transform: translateY(-50%);
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer;
}
.pw-eye:hover { color: var(--text); background: var(--hover-tint); }
.pw-eye:focus-visible { outline: 2px solid var(--primary-strong); outline-offset: -2px; }
.farm-chip { color: rgb(255 255 255 / 85%); font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }

@media (max-width: 900px) { .farm-chip { max-width: 12ch; font-size: .75rem; } }
.farm-banner { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.farm-banner[hidden] { display: none; }

.id-box { padding: 14px 16px; border-radius: var(--radius); background: var(--primary-soft); border: 2px solid var(--primary-strong); text-align: center; }
.id-label { margin: 0 0 6px; font-weight: 700; color: var(--primary-strong); }
.id-value { display: block; font-size: 2rem; font-weight: 800; letter-spacing: .02em; word-break: break-all; color: var(--text); }
.id-h2 { font-size: 1.05rem; margin: 6px 0 0; }

.field[hidden] { display: none; }
.link-subtle { font-size: .8rem; color: var(--text-3); text-decoration: none; margin-top: 4px; }
.link-subtle:hover { color: var(--primary); text-decoration: underline; }
/* Écran de démarrage : deux grandes cartes cliquables, aux couleurs du logo (or, inox, vert). Couleurs propres aux cartes :
   mêmes contrastes en thème clair et sombre (texte vert foncé #1B4332 sur or ou inox clair, rapport > 7:1). */
.start-choices { gap: 16px; margin-top: 8px; }
.start-choices h1 { margin-bottom: 0; }
.start-choices .muted { margin: 0 0 4px; }
.choice {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 88px; padding: 14px 14px 14px 16px;
  border-radius: 16px; cursor: pointer; text-align: left; font: inherit; color: #1B4332; -webkit-tap-highlight-color: transparent;
  transition: transform .1s, box-shadow .15s, filter .15s;
}
.choice-primary {
  background: var(--hairline), linear-gradient(180deg, #FFE866 0%, #FFD700 50%, #FACF00 100%); border: 2px solid #A67C00;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%), 0 2px 3px rgb(0 0 0 / 28%), 0 6px 14px rgb(166 124 0 / 35%);
}
.choice-secondary {
  background: var(--hairline), linear-gradient(180deg, #FFFFFF 0%, #EEF1EF 45%, #D6DCD9 100%); border: 2px solid #2D6A4F;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 95%), 0 2px 3px rgb(0 0 0 / 22%), 0 6px 14px rgb(0 0 0 / 14%);
}
.choice-icon { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; color: #1B4332; }
.choice-primary .choice-icon { background: rgb(27 67 50 / 14%); }
.choice-secondary .choice-icon { background: rgb(45 106 79 / 14%); }
.choice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.choice-text strong { font-size: 1.05rem; line-height: 1.25; color: #1B4332; }
.choice-text small { font-size: .85rem; line-height: 1.3; color: #1B4332; }
.choice-arrow { flex: none; color: #1B4332; }
@media (hover: hover) { .choice:hover { filter: brightness(1.04); transform: translateY(-1px); } }
.choice:active { transform: translateY(1px) scale(.99); filter: brightness(.95); box-shadow: inset 0 2px 5px rgb(0 0 0 / 30%); }
.choice:focus-visible { outline: 3px solid var(--primary-strong); outline-offset: 3px; }
@media (max-width: 340px) { .choice { gap: 10px; padding: 12px; } .choice-icon { width: 40px; height: 40px; } }

/* « Se connecter » : bouton principal doré quand un compte existe déjà sur l'appareil. */
.btn-primary.btn-gold {
  background: var(--hairline), var(--gold-metal); color: var(--on-gold); border-color: #a07800; text-shadow: 0 1px 0 rgb(255 255 255 / 45%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%), 0 1px 2px rgb(0 0 0 / 30%), 0 3px 10px rgb(201 154 0 / 35%);
}

/* ---------- Rapport imprimable d'un lot (Imprimer / PDF) ---------- */
.print-root { display: none; }
@page { size: A4 portrait; margin: 12mm; }
@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; display: block !important; }
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-report {
  width: 186mm; max-height: 272mm; overflow: hidden; box-sizing: border-box;
  color: #000; background: #fff; font: 10pt/1.3 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.print-report * { box-sizing: border-box; }
.print-report h1, .print-report h2, .print-report p { margin: 0; }
.pr-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; border-bottom: 1.5pt solid #000; padding-bottom: 6px; }
.pr-kicker { font-size: 8.5pt; letter-spacing: .04em; text-transform: uppercase; }
.pr-head h1 { font-size: 20pt; line-height: 1.15; overflow-wrap: anywhere; }
.pr-sub { font-size: 9.5pt; }
.pr-date { font-size: 9pt; white-space: nowrap; }
.pr-figures { display: grid; grid-template-columns: repeat(4, 1fr); border-top: .5pt solid #000; border-left: .5pt solid #000; margin: 8px 0 6px; }
.pr-fig { display: flex; flex-direction: column; min-width: 0; height: 16.5mm; padding: 3px 6px; border-right: .5pt solid #000; border-bottom: .5pt solid #000; }
.pr-fig > span, .pr-fig > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-fig > .pr-fig-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.15; }
.pr-fig-label { font-size: 7.5pt; text-transform: uppercase; letter-spacing: .03em; }
.pr-fig-value { font-size: 12pt; line-height: 1.2; }
.pr-fig-sub { font-size: 7.5pt; }
.pr-chart { margin-top: 6px; break-inside: avoid; }
.pr-chart h2 { font-size: 10pt; border-bottom: .5pt solid #000; padding-bottom: 1px; }
.pr-chart-host { height: 176px; }
.pr-chart-host .chart { display: block; }
.pr-chart-host svg { display: block; width: 100%; height: auto; overflow: visible; }
.pr-chart-host .grid { stroke: #b0b0b0; stroke-width: .6; stroke-dasharray: 2 2; }
.pr-chart-host .axis { stroke: #000; stroke-width: 1; }
.pr-chart-host .tick { fill: #000; } /* taille fixée par le tracé (PRINT_TICK_PX) */
.pr-empty { padding-top: 60px; text-align: center; }
.pr-last { font-size: 8.5pt; min-height: 1.3em; }
.pr-foot { margin-top: 8px; border-top: .5pt solid #000; padding-top: 3px; font-size: 8pt; }
.print-option { display: flex; align-items: flex-start; gap: 12px; min-height: 52px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.print-option:has(input:checked) { border-color: var(--accent, #2a78d6); box-shadow: 0 0 0 1px var(--accent, #2a78d6); }
.print-option input[type="radio"] { flex: none; width: 22px; min-width: 22px; height: 22px; min-height: 0; padding: 0; margin: 1px 0 0; box-shadow: none; accent-color: var(--primary); }
.print-option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
/* Mode couleur : les couleurs du thème clair, quel que soit le thème de l'écran (le fond reste blanc, le texte noir). */
/* Papier, mode couleur : le bleu du thème clair ; orange et vert plus foncés que sur l'écran pour rester lisibles une fois imprimés. */
.print-report.pr-color { --pr-mort: #0b4fb3; --pr-feed: #a34a00; --pr-weight: #006e5c; }

/* ---------- Financier : liste des écritures ---------- */
.fin-totals { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.fin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; }
.fin-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px 12px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid rgb(0 0 0 / 9%); }
.fin-row:last-child { border-bottom: 0; }
.fin-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.fin-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.fin-amount { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
@media (max-width: 480px) {
  .fin-row { grid-template-columns: 1fr auto; }
  .fin-row .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
.fin-orphan { color: var(--warning); font-style: italic; }
.fin-orphan-banner { margin-bottom: 0; }
.lot-costs-total { margin-bottom: 8px; }
.lot-costs-sub { font-size: .9rem; margin: 12px 0 6px; color: var(--text-2); }
.lot-costs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lot-costs-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 4.2rem; align-items: baseline; gap: 2px 8px; margin-bottom: 4px; }
.lot-costs-name { min-width: 0; overflow-wrap: anywhere; }
.lot-costs-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.lot-costs-pct { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-2); }
.lot-costs-fill { background: var(--green-metal); }
.lot-costs-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 12px; gap: 8px; }
.fin-tag { font-size: .72rem; font-weight: 650; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.fin-tag-late { border-color: var(--warning); color: var(--warning); background: var(--warning-soft); }

/* ---------- Financier : résultat du lot ---------- */
.lot-result-notes { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; color: var(--warning); }
.lot-result-kpis { margin: 8px 0; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.lot-result-kpis .kpi-value { font-size: 1.35rem; overflow-wrap: anywhere; }
.lot-result-kpis .kpi-value[data-kind="loss"] { color: var(--critical); }
.lot-result-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; }
.lot-result-row { padding: 10px 0; border-bottom: 1px solid rgb(0 0 0 / 9%); }
.lot-result-row:last-child { border-bottom: 0; }
.lot-result-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.lot-result-name { flex: 1 1 11rem; min-width: 0; }
.lot-result-value { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.lot-result-row[data-empty="1"] .lot-result-value { color: var(--text-2); }
.lot-result-how { margin-top: 12px; }
.lot-result-how summary { cursor: pointer; font-weight: 650; min-height: 32px; display: flex; align-items: center; }
.lot-result-how p { margin: 6px 0; overflow-wrap: anywhere; }
.lot-result-warning { margin-top: 10px; }
.lot-result-provisional { display: inline-block; margin-bottom: 4px; }

/* Prophylaxie (É6) */
.proph-indicative { font-weight: 650; margin: 0 0 6px; overflow-wrap: anywhere; }
.proph-list, .proph-summary, .proph-bio-list, .proph-edit-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.proph-bio-list { list-style: disc; padding-left: 20px; }
.proph-row { display: flex; gap: 8px 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.proph-row:first-child { border-top: 0; }
.proph-main { flex: 1 1 220px; min-width: 0; }
.proph-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.proph-name { overflow-wrap: anywhere; }
.proph-date { margin-top: 2px; font-size: .9rem; }
.proph-details { margin-top: 4px; font-size: .85rem; color: var(--text-2); }
.proph-line { display: flex; flex-wrap: wrap; gap: 2px 14px; overflow-wrap: anywhere; }
.proph-confirm { font-style: italic; }
.proph-actions { align-self: center; }
.proph-layer { margin: 8px 0; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.proph-kind { border-top: 1px solid var(--border); padding-top: 10px; }
.proph-kind:first-child { border-top: 0; padding-top: 0; }
.proph-kind-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.proph-kind-head h3 { margin: 0; font-size: 1rem; }
.proph-summary li { overflow-wrap: anywhere; }
.proph-group { border-top: 1px solid var(--border); padding-top: 8px; }
.proph-group:first-child { border-top: 0; padding-top: 0; }
.proph-edit-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.proph-edit-text { min-width: 0; overflow-wrap: anywhere; flex: 1 1 200px; }
