/* =========================================================
   FEFGUI — Thème d'administration
   Barre latérale bleu marine + contenu clair en cartes
   (navy / teal / gold, police Inter)
   ========================================================= */

:root,
html[data-theme="light"] {
  --fx-navy: #0B2545;
  --fx-navy-2: #12325a;
  --fx-teal: #0E7C7B;
  --fx-teal-dark: #0a5f5e;
  --fx-gold: #E0A526;
  --fx-bg: #f3f5f8;
  --fx-card: #ffffff;
  --fx-border: #e3e8ef;
  --fx-text: #1f2a3c;
  --fx-muted: #66758a;
  --fx-sidebar-w: 260px;

  --primary: #0B2545;
  --primary-fg: #ffffff;
  --secondary: #0E7C7B;
  --accent: #0E7C7B;

  --link-fg: #0E7C7B;
  --link-hover-color: #0a5f5e;
  --link-selected-fg: #0a5f5e;

  --header-bg: #0B2545;
  --header-color: #ffffff;
  --header-branding-color: #ffffff;
  --header-link-color: #cfe0ee;

  --breadcrumbs-bg: #ffffff;
  --breadcrumbs-fg: #66758a;
  --breadcrumbs-link-fg: #0E7C7B;

  --button-bg: #0E7C7B;
  --button-hover-bg: #0a5f5e;
  --button-fg: #ffffff;
  --default-button-bg: #0B2545;
  --default-button-hover-bg: #12325a;
  --close-button-bg: #7c8aa0;
  --close-button-hover-bg: #5f6b7f;

  --object-tools-bg: #0B2545;
  --object-tools-hover-bg: #12325a;

  --body-bg: #f3f5f8;
  --body-fg: #1f2a3c;
  --body-quiet-color: #66758a;
  --body-loud-color: #0B2545;

  --selected-row: #eef6f6;
  --selected-bg: #eaf3f3;

  --font-family-primary: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-monospace: ui-monospace, SFMono-Regular, Menlo, monospace;
}

body { font-family: var(--font-family-primary); background: var(--fx-bg); color: var(--fx-text); }

/* ---------- En-tête simple (page de connexion, popups) ---------- */
#header {
  background: linear-gradient(90deg, #0B2545 0%, #0E7C7B 160%);
  box-shadow: 0 2px 14px rgba(11, 37, 69, 0.18);
  padding: 12px 40px;
}
.fefgui-brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.fefgui-brand__mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #0E7C7B, #123256);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.fefgui-brand__mark svg { width: 22px; height: 22px; }
.fefgui-brand__text { color: #fff; font-weight: 800; font-size: 20px; line-height: 1; letter-spacing: .5px; }
.fefgui-brand__text small {
  display: block; font-size: 11px; font-weight: 500; letter-spacing: .12em;
  text-transform: uppercase; color: #8fe0d8; margin-top: 4px;
}

/* =========================================================
   Coque : barre latérale fixe
   ========================================================= */
body:has(.fx-sidebar) #container { width: auto; padding-left: var(--fx-sidebar-w); min-width: 0; }

/* Django 6 souligne tous les liens via un sélecteur à identifiant (a:not(#content-main.app-list a…)) :
   on le neutralise dans la coque et le dashboard, dont les liens sont des cartes ou des boutons. */
.fx-sidebar a, .fx-dash a { text-decoration: none !important; }
.fx-sidebar *, .fx-dash * { box-sizing: border-box; }
.fx-dash .fx-table td a:hover, .fx-dash .fx-link:hover { text-decoration: underline !important; }

.fx-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--fx-sidebar-w); z-index: 1000;
  display: flex; flex-direction: column;
  background: var(--fx-navy); color: #c9d6e8;
  box-shadow: 2px 0 16px rgba(11, 37, 69, .12);
}
.fx-sidebar__brand { padding: 22px 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.fx-flag { display: flex; gap: 3px; margin-bottom: 14px; }
.fx-flag i { display: block; width: 18px; height: 4px; border-radius: 2px; }
.fx-flag i:nth-child(1) { background: #CE1126; }
.fx-flag i:nth-child(2) { background: #FCD116; }
.fx-flag i:nth-child(3) { background: #009460; }
.fx-sidebar__name, .fx-sidebar__name:link, .fx-sidebar__name:visited {
  display: block; color: #fff; font-size: 19px; font-weight: 800; letter-spacing: .3px; text-decoration: none;
}
.fx-sidebar__tagline { display: block; font-size: 12.5px; color: #9fb2cb; margin-top: 4px; }

.fx-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.fx-nav__section {
  margin: 20px 10px 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: #7f95b3;
}
.fx-nav__link, .fx-nav__link:link, .fx-nav__link:visited {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; color: #d3deec; font-size: 14.5px; font-weight: 500; text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.fx-nav__link svg { flex: none; opacity: .9; }
.fx-nav__link:hover { background: rgba(255,255,255,.07); color: #fff; }
.fx-nav__link.is-active { background: #1d5fae; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); }

.fx-sidebar__user { padding: 16px 20px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.fx-sidebar__user strong { display: block; color: #fff; font-size: 14px; font-weight: 700; }
.fx-sidebar__user > span { display: block; font-size: 12.5px; color: #9fb2cb; margin-top: 2px; }
.fx-sidebar__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fx-sidebar__actions form { margin: 0; }
.fx-btn-outline, .fx-btn-outline:link, .fx-btn-outline:visited {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px;
  background: transparent; border: 1px solid rgba(255,255,255,.22); border-radius: 7px;
  color: #e3ebf5; font: 600 13.5px var(--font-family-primary); cursor: pointer; text-decoration: none;
}
.fx-btn-outline:hover { background: rgba(255,255,255,.08); color: #fff; }

.fx-mobilebar, .fx-backdrop { display: none; }

/* ---------- Zone de contenu ---------- */
body:has(.fx-sidebar) #content { padding: 24px 32px 40px; }
body:has(.fx-sidebar) #content > h1 { font-size: 22px; font-weight: 700; color: var(--fx-navy); }
div.breadcrumbs {
  background: #fff; color: var(--fx-muted); border-bottom: 1px solid var(--fx-border);
  padding: 14px 32px; font-size: 13px;
}
div.breadcrumbs a { color: var(--fx-teal); }
#footer { display: none; }

/* =========================================================
   Tableau de bord
   ========================================================= */
.dashboard.fefgui-dashboard #content { width: auto; max-width: none; padding-top: 0; }

.fx-topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 0 -32px 24px; padding: 18px 32px; background: #fff; border-bottom: 1px solid var(--fx-border);
}
.fx-topbar__title { margin: 0; font-size: 22px; font-weight: 700; color: var(--fx-navy); }
.fx-topbar__sub { margin: 4px 0 0; font-size: 13.5px; color: var(--fx-muted); }

.fx-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.fx-chip, .fx-chip:link, .fx-chip:visited {
  padding: 7px 13px; border: 1px solid var(--fx-border); border-radius: 7px; background: #fff;
  color: var(--fx-text); font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: all .15s ease;
}
.fx-chip:hover { border-color: var(--fx-navy); }
.fx-chip.is-active { background: var(--fx-navy); border-color: var(--fx-navy); color: #fff; }
.fx-date input {
  height: 38px; padding: 0 10px; border: 1px solid var(--fx-border); border-radius: 7px;
  font: 500 13.5px var(--font-family-primary); color: var(--fx-text); background: #fff;
}
.fx-date input:focus { outline: 2px solid rgba(14,124,123,.25); border-color: var(--fx-teal); }
.fx-filters__au { color: var(--fx-muted); font-size: 13.5px; }

.fx-alerts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.fx-alert, .fx-alert:link, .fx-alert:visited {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px;
  font-size: 13.5px; text-decoration: none; border: 1px solid transparent;
}
.fx-alert svg { width: 16px; height: 16px; }
.fx-alert--warn { background: #fdf3e1; border-color: #f4dcae; color: #8a5a0b; }
.fx-alert--info { background: #e7f0fb; border-color: #c4d8f2; color: #1d4f8f; }
.fx-alert:hover { filter: brightness(.97); }

/* KPI */
.fx-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 24px; }
.fx-kpi, .fx-kpi:link, .fx-kpi:visited {
  display: flex; gap: 16px; align-items: flex-start; padding: 22px 22px 20px; text-decoration: none;
  background: var(--fx-card); border: 1px solid var(--fx-border); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04); color: inherit;
  transition: box-shadow .15s ease, transform .15s ease;
}
.fx-kpi:hover { box-shadow: 0 10px 24px rgba(11,37,69,.08); transform: translateY(-2px); }
.fx-kpi__icon { flex: none; width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.fx-kpi__icon svg { width: 21px; height: 21px; }
.fx-tone-blue   { background: #e8f0fb; color: #1d5fae; }
.fx-tone-green  { background: #e5f4ec; color: #2f8a55; }
.fx-tone-gold   { background: #fcf1dc; color: #b7791f; }
.fx-tone-teal   { background: #e2f3f2; color: #0E7C7B; }
.fx-tone-violet { background: #efeafa; color: #6b4fbb; }
.fx-tone-red    { background: #fbe9e7; color: #c2453d; }
.fx-kpi__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fx-kpi__label { font-size: 13.5px; color: var(--fx-muted); }
.fx-kpi__value { font-size: 22px; font-weight: 800; color: var(--fx-navy); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fx-kpi__meta { font-size: 12.5px; color: var(--fx-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.fx-gauge { display: block; width: 100%; height: 5px; background: #edf1f5; border-radius: 999px; overflow: hidden; }
.fx-gauge > span { display: block; height: 100%; background: linear-gradient(90deg, #0E7C7B, #2F8A55); border-radius: 999px; }

.fefgui-delta { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.fefgui-delta--up { background: #e5f4ec; color: #2f8a55; }
.fefgui-delta--down { background: #fbe9e7; color: #c2453d; }
.fefgui-delta--flat, .fefgui-delta--na { background: #eef1f5; color: var(--fx-muted); }

/* Grilles et cartes */
.fx-grid { display: grid; gap: 20px; margin-bottom: 20px; align-items: start; }
.fx-grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.fx-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.fx-card {
  background: var(--fx-card); border: 1px solid var(--fx-border); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04); min-width: 0; overflow: hidden;
}
.fx-card__head { padding: 18px 20px 14px; border-bottom: 1px solid var(--fx-border); }
.fx-card__head--row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.fx-dash .fx-card__head h2 {
  margin: 0; padding: 0; background: none; color: var(--fx-navy);
  font-size: 16px; font-weight: 700; text-transform: none; letter-spacing: 0;
}
.fx-card__head p { margin: 3px 0 0; padding: 0; font-size: 13px; color: var(--fx-muted); }
.fx-card__body { padding: 18px 20px 20px; }
.fx-chart { position: relative; height: 250px; }
.fx-chart--tall { height: 360px; }
.fx-chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: var(--fx-muted); font-size: 13.5px; }
.fx-chart-empty[hidden] { display: none; }
.fx-link, .fx-link:link, .fx-link:visited { font-size: 13px; font-weight: 600; color: var(--fx-teal); text-decoration: none; white-space: nowrap; }

/* Tableaux */
.fx-table-wrap { overflow-x: auto; }
.fx-table-wrap--scroll { max-height: 430px; overflow-y: auto; }
.fx-table { width: 100%; border-collapse: collapse; }
.fx-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: #f8fafc; color: var(--fx-muted); text-align: left;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 11px 16px; border-bottom: 1px solid var(--fx-border);
}
.fx-table td { padding: 12px 16px; border-bottom: 1px solid #eef1f5; font-size: 14px; color: var(--fx-text); vertical-align: top; }
.fx-table tr:last-child td { border-bottom: none; }
.fx-table tbody tr:hover td { background: #fafbfd; }
.fx-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx-table a { font-weight: 600; text-decoration: none; }
.fx-muted { color: var(--fx-muted); font-size: 12.5px; }
.fx-empty { margin: 0; padding: 28px 20px; color: var(--fx-muted); font-size: 13.5px; }

.fx-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.fx-status--en_cours { background: #fcf1dc; color: #9a6413; }
.fx-status--confirmee { background: #e2f3f2; color: #0a5f5e; }
.fx-status--en_livraison { background: #e8f0fb; color: #1d5fae; }
.fx-status--livree { background: #e5f4ec; color: #2f8a55; }
.fx-status--annulee { background: #fbe9e7; color: #c2453d; }

/* Légendes HTML des graphiques */
.fefgui-legend { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
.fefgui-legend li { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: #4a5568; cursor: pointer; user-select: none; padding: 0; list-style: none; }
.fefgui-legend li.is-off { opacity: .4; text-decoration: line-through; }
.fefgui-legend__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Actions rapides */
.fx-quick { display: flex; flex-direction: column; padding: 8px 10px 12px; }
.fx-quick a, .fx-quick a:link, .fx-quick a:visited {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px;
  color: var(--fx-text); font-size: 14px; font-weight: 500; text-decoration: none;
}
.fx-quick a svg { color: var(--fx-teal); }
.fx-quick a:hover { background: #f3f7f9; color: var(--fx-navy); }

/* =========================================================
   Pages internes de l'admin (listes, formulaires)
   ========================================================= */
.module h2, .module caption, .inline-group h2 {
  background: var(--fx-navy) !important; color: #fff !important;
  font-weight: 700; letter-spacing: .02em;
}
.module { border-radius: 10px; }
#changelist .actions, #changelist-filter, .results, fieldset.module {
  border-radius: 10px;
}
#changelist-filter { border: 1px solid var(--fx-border); }
.button, input[type=submit], input[type=button], .submit-row input, a.button { border-radius: 7px; }
.object-tools a { border-radius: 7px; }
a:link, a:visited { color: var(--link-fg); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1280px) {
  .fx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .fx-grid--main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  body:has(.fx-sidebar) #container { padding-left: 0; }
  .fx-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.fx-nav-open .fx-sidebar { transform: none; }
  .fx-backdrop { position: fixed; inset: 0; z-index: 999; background: rgba(11,37,69,.45); }
  body.fx-nav-open .fx-backdrop { display: block; }
  .fx-mobilebar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 900;
    padding: 10px 16px; background: var(--fx-navy); color: #fff;
  }
  .fx-mobilebar__toggle { display: inline-flex; padding: 6px; background: none; border: 0; color: #fff; cursor: pointer; }
  .fx-mobilebar__title { font-weight: 700; font-size: 15px; }
  body:has(.fx-sidebar) #content { padding: 16px 16px 32px; }
  .fx-topbar { margin: 0 -16px 18px; padding: 16px; }
  div.breadcrumbs { padding: 12px 16px; }
}
@media (max-width: 640px) {
  .fx-kpis, .fx-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .fx-filters { width: 100%; }
  .fx-date { flex: 1 1 140px; min-width: 0; }
  .fx-date input { width: 100%; }
}
