/* FEDIMAG – feuille de styles
   Palette tirée du logo : indigo (structure) et rouge (accent rare).
   L'élévation de rack de la page d'accueil est le seul élément démonstratif. */

:root {
  --indigo: #180c6e;
  --indigo-2: #2b1f97;
  --indigo-soft: #e9e7f6;
  --red: #e1060b;
  --red-ink: #b3261e;
  --concrete: #eef0f3;
  --paper: #ffffff;
  --ink: #161a2b;
  --muted: #5a6074;
  --line: #d6dae3;
  --focus: #f2c230;
  --ok: #1d6b45;
  --ok-bg: #e6f3ec;
  --warn-bg: #fff4d6;
  --err-bg: #fdecea;

  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius: 4px;
  --wrap: 72rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
img { max-width: 100%; height: auto; }
a { color: var(--indigo-2); text-underline-offset: 2px; }
a:hover { color: var(--indigo); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; color: var(--indigo); margin: 0 0 .6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1rem; }
.page { padding: 2.5rem 0 4rem; }
.narrow { max-width: 40rem; }
.measure { max-width: 42rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--focus); color: var(--ink); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.inline { display: inline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- En-tête ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.header-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 5rem; flex-wrap: wrap; padding-top: .5rem; padding-bottom: .5rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--indigo); }
.brand img { width: 72px; height: auto; display: block; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; }
.brand-sub { font-size: .8rem; color: var(--muted); max-width: 16rem; line-height: 1.3; }
.main-nav { margin-left: auto; }
.main-nav ul { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; flex-wrap: wrap; }
.main-nav a { display: block; padding: .5rem .75rem; text-decoration: none; color: var(--ink); font-weight: 600; border-bottom: 3px solid transparent; }
.main-nav a:hover { color: var(--indigo); }
.main-nav a[aria-current="page"] { border-bottom-color: var(--red); color: var(--indigo); }
.account { display: flex; align-items: center; gap: .75rem; font-size: .92rem; }
.account-link { color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--indigo-2); text-decoration: underline; cursor: pointer; }

@media (max-width: 760px) {
  .main-nav { margin-left: 0; order: 3; width: 100%; }
  .main-nav ul { gap: 0; }
  .main-nav a { padding: .5rem .6rem; }
  .account { margin-left: auto; }
  .brand-sub { display: none; }
}

/* ---------- Boutons et formulaires ---------- */
.btn {
  display: inline-block; font: inherit; font-weight: 700; font-size: 1rem;
  padding: .65rem 1.15rem; border-radius: var(--radius); border: 2px solid var(--indigo);
  background: var(--indigo); color: #fff; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--indigo-2); border-color: var(--indigo-2); color: #fff; }
.btn-secondary { background: var(--paper); color: var(--indigo); }
.btn-secondary:hover { background: var(--indigo-soft); color: var(--indigo); }
.btn-danger { background: var(--paper); color: var(--red-ink); border-color: var(--red-ink); }
.btn-danger:hover { background: var(--err-bg); color: var(--red-ink); border-color: var(--red-ink); }
.btn-small { padding: .4rem .8rem; font-size: .9rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-top: 1.25rem; }

label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1.1rem; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .88rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=month], input[type=url], select, textarea {
  font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid #9aa1b2; border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
textarea { min-height: 8rem; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .95rem; }
input:focus, select:focus, textarea:focus { border-color: var(--indigo); }
.checkbox { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.checkbox input { margin-top: .35rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.5rem; }
legend { font-weight: 700; color: var(--indigo); padding: 0 .4rem; }

/* ---------- Messages ---------- */
.flashes { padding-top: 1rem; }
.flash, .notice { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: .75rem; border-left: 4px solid; }
.flash-success, .notice-ok { background: var(--ok-bg); border-color: var(--ok); }
.flash-error, .notice-error { background: var(--err-bg); border-color: var(--red-ink); }
.flash-info, .notice-info { background: var(--indigo-soft); border-color: var(--indigo); }
.notice-warn { background: var(--warn-bg); border-color: #b7791f; }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1.5rem; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { border-bottom: 2px solid var(--indigo); color: var(--indigo); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #f7f8fb; }
.table-compact th, .table-compact td { padding: .35rem .5rem; }
td.actions-cell { white-space: nowrap; text-align: right; }
tr.row-highlight td { background: var(--indigo-soft); font-weight: 700; }
.var-up { color: var(--ink); }
.var-down { color: var(--red-ink); }
.var-flat, .var-none { color: var(--muted); }
.tag { display: inline-block; font-size: .78rem; padding: .05rem .45rem; border-radius: 99px; background: var(--concrete); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-draft { background: var(--warn-bg); color: #7a5410; }
.tag-red { background: var(--err-bg); color: var(--red-ink); }

/* ---------- Accueil ---------- */
.hero { background: var(--indigo); color: #fff; padding: 3rem 0 3.5rem; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 3rem; align-items: center; }
.hero h1 { color: #fff; font-size: clamp(1.9rem, 4vw, 3rem); font-weight: 800; letter-spacing: -0.02em; }
.hero-lead { font-size: 1.15rem; max-width: 32rem; color: #dcd9f2; }
.hero .btn { background: #fff; color: var(--indigo); border-color: #fff; }
.hero .btn:hover { background: var(--indigo-soft); }
.hero .btn-secondary { background: transparent; color: #fff; border-color: #fff; }
.hero .btn-secondary:hover { background: rgba(255,255,255,.12); color: #fff; }

/* Élévation de rack : montants indigo clair, lisses rouges, charges blanches */
.rack { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 10px; }
.rack::before, .rack::after {
  content: ""; position: absolute; top: 0; bottom: -14px; width: 10px; background: #5b51b8;
  background-image: repeating-linear-gradient(to bottom, transparent 0 10px, rgba(0,0,0,.25) 10px 13px);
}
.rack::before { left: 0; }
.rack::after { right: 0; }
.bay { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 8.5rem; padding: .9rem .6rem 0; border-bottom: 9px solid var(--red); }
.bay + .bay, .bay:nth-child(3n+1) { }
.bay:not(:nth-child(3n+1))::before {
  content: ""; position: absolute; left: -5px; top: 0; bottom: -9px; width: 10px; background: #5b51b8;
  background-image: repeating-linear-gradient(to bottom, transparent 0 10px, rgba(0,0,0,.25) 10px 13px);
}
.load { background: #fff; color: var(--ink); border-radius: 2px; padding: .7rem .75rem .6rem; margin: 0 .25rem; box-shadow: 0 -3px 0 0 #d8d4ef inset; }
.load strong { display: block; font-size: clamp(1.25rem, 2.4vw, 1.75rem); line-height: 1.05; color: var(--indigo); font-weight: 800; letter-spacing: -0.02em; }
.load span { display: block; font-size: .82rem; color: var(--muted); line-height: 1.3; margin-top: .2rem; }
.load-tall { padding-top: 1.4rem; }
.rack-floor { height: 14px; margin: 0 -1rem; background: repeating-linear-gradient(-45deg, var(--focus) 0 12px, var(--indigo) 12px 24px); opacity: .9; }
@media (prefers-reduced-motion: no-preference) {
  .load { animation: stock .5s ease-out both; }
  .bay:nth-child(2) .load { animation-delay: .08s; }
  .bay:nth-child(3) .load { animation-delay: .16s; }
  .bay:nth-child(4) .load { animation-delay: .24s; }
  .bay:nth-child(5) .load { animation-delay: .32s; }
  .bay:nth-child(6) .load { animation-delay: .4s; }
  @keyframes stock { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
}
@media (max-width: 420px) {
  .bay { min-height: 7.5rem; padding-left: .3rem; padding-right: .3rem; }
  .load { padding: .5rem .45rem; margin: 0 .1rem; }
  .load span { font-size: .74rem; }
}

.section { padding: 3.5rem 0; }
.section-concrete { background: var(--concrete); }
.split { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2.5rem; }
.split h2 { margin-top: .1rem; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; gap: .5rem; } }
.prose { max-width: 42rem; }
.prose ul { padding-left: 1.2rem; }
.domains { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; list-style: none; margin: 1rem 0 0; }
.domains li { background: var(--paper); border: 1px solid var(--line); padding: .25rem .65rem; border-radius: 99px; font-size: .92rem; }
.section-concrete .domains li { background: #fff; }
.members-band { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: center; border-top: 4px solid var(--red); padding-top: 1.75rem; }
@media (max-width: 760px) { .members-band { grid-template-columns: 1fr; } }
.index-names { columns: 2; column-gap: 2rem; padding-left: 1.1rem; margin: .5rem 0 0; }
@media (max-width: 520px) { .index-names { columns: 1; } }

/* ---------- Pages indices ---------- */
.page-head { background: var(--concrete); border-bottom: 1px solid var(--line); padding: 2rem 0 1.5rem; }
.page-head h1 { margin-bottom: .3rem; }
.page-head p { margin: 0; color: var(--muted); }
.copyright { font-size: .85rem; color: var(--red-ink); margin-top: .6rem !important; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin: 1.5rem 0 0; padding: 0; list-style: none; border-bottom: 1px solid var(--line); }
.tabs a { display: block; padding: .55rem .9rem; text-decoration: none; color: var(--ink); font-weight: 600; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; margin-bottom: -1px; }
.tabs a[aria-current="page"] { background: var(--paper); border-color: var(--line); color: var(--indigo); box-shadow: inset 0 3px 0 var(--red); }

.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; }
.figure { border: 1px solid var(--line); border-top: 4px solid var(--indigo); padding: 1rem 1.1rem; border-radius: var(--radius); }
.figure .label { font-weight: 700; color: var(--indigo); font-size: .95rem; }
.figure .value { font-size: 2.1rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; margin: .25rem 0; color: var(--ink); }
.figure .meta { font-size: .88rem; color: var(--muted); }

.explain { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1.5rem; margin: 0 0 2rem; }
.explain dt { font-weight: 700; }
.explain dd { margin: 0; }
@media (max-width: 560px) { .explain { grid-template-columns: 1fr; gap: 0; } .explain dd { margin-bottom: .5rem; } }

.chart { width: 100%; height: auto; display: block; margin: .5rem 0 2rem; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .series { fill: none; stroke: var(--indigo); stroke-width: 2.5; stroke-linejoin: round; }
.chart .series-2 { stroke: var(--red); stroke-dasharray: 6 4; }
.chart .series-3 { stroke: #6b7bb3; }
.chart .dot { fill: var(--indigo); }
.chart .end-label { fill: var(--indigo); font-size: 13px; font-weight: 700; font-family: var(--font); }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin-top: -1.25rem; margin-bottom: 2rem; }
.legend i { display: inline-block; width: 1.5rem; height: 0; border-top: 3px solid var(--indigo); vertical-align: middle; margin-right: .4rem; }
.legend i.l2 { border-top: 3px dashed var(--red); }
.legend i.l3 { border-top-color: #6b7bb3; }

.group-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1.5rem 0 2.5rem; }
.group-card { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--indigo); padding: 1rem 1.1rem; border-radius: var(--radius); }
.group-card:hover { border-color: var(--indigo); color: var(--ink); background: #fafaff; }
.group-card h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.group-card dl { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .15rem .75rem; margin: 0; font-size: .93rem; }
.group-card dt { color: var(--muted); }
.group-card dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.group-card dd.v { font-weight: 700; }

.synthese th, .synthese td { text-align: right; }
.synthese th:first-child, .synthese td:first-child { text-align: left; }
.synthese tr.idx td { color: var(--indigo); font-weight: 700; border-bottom-width: 2px; }

/* ---------- Administration ---------- */
.admin-nav { background: var(--indigo); }
.admin-nav ul { list-style: none; display: flex; flex-wrap: wrap; margin: 0; padding: 0; }
.admin-nav a { display: block; color: #dcd9f2; text-decoration: none; padding: .7rem .9rem; font-weight: 600; font-size: .95rem; }
.admin-nav a:hover { color: #fff; }
.admin-nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -3px 0 var(--red); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.card h2 { font-size: 1.1rem; }
.card .big { font-size: 1.6rem; font-weight: 800; color: var(--indigo); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .3rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; }
.checklist li:last-child { border-bottom: 0; }
.status-ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.status-missing::before { content: "○ "; color: var(--red-ink); font-weight: 700; }
details.panel { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
details.panel > summary { cursor: pointer; padding: .75rem 1rem; font-weight: 700; color: var(--indigo); }
details.panel[open] > summary { border-bottom: 1px solid var(--line); }
details.panel > div { padding: 1rem; }
.comment-row { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: .75rem; margin-bottom: .5rem; align-items: center; }
.comment-row input { margin: 0; }
@media (max-width: 640px) { .comment-row { grid-template-columns: 1fr; gap: .25rem; } }
.code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .9em; }
.secret { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 1.15rem; background: var(--paper); padding: .15rem .5rem; border: 1px dashed var(--indigo); }

/* ---------- Pied de page ---------- */
.site-footer { background: var(--concrete); border-top: 1px solid var(--line); padding: 2rem 0; font-size: .9rem; color: var(--muted); margin-top: 0; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem; }
.footer-name { font-weight: 800; color: var(--indigo); margin-bottom: .25rem; }
.site-footer p { margin-bottom: .35rem; }

/* ---------- Impression : remplace les anciens PDF ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 14mm 12mm; }
  body { font-size: 10.5pt; color: #000; }
  .site-header, .site-footer, .admin-nav, .tabs, .no-print, .flashes, .skip { display: none !important; }
  .print-only { display: block; }
  .print-head { display: flex; gap: 12px; align-items: center; border-bottom: 2px solid var(--indigo); padding-bottom: 6px; margin-bottom: 10px; }
  .print-head img { width: 80px; }
  .print-head p { margin: 0; font-size: 9pt; font-weight: 700; color: var(--indigo); font-style: italic; }
  .page-head { background: none; border: 0; padding: 0 0 6px; }
  .page { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .figure, .group-card { break-inside: avoid; }
  .chart { max-height: 70mm; }
  .history { display: none; }
  table { font-size: 9.5pt; }
}
.spaced { margin-top: 2rem; }
.prose .domains { padding-left: 0; }
.group-cards { align-items: start; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.group-card dl { grid-template-columns: minmax(7.5rem, 1fr) auto auto; }
.page-head select, .actions select { width: auto; max-width: 100%; }
.synthese { font-size: .88rem; }
.synthese thead th { white-space: normal; vertical-align: bottom; min-width: 4.5rem; }
.synthese th, .synthese td { padding: .35rem .4rem; }
tr.row-highlight th { background: var(--indigo-soft); }
.month-inputs { display: grid; grid-template-columns: repeat(3, minmax(5.5rem, 1fr)); gap: .5rem; min-width: 18rem; }
.month-inputs label { margin-bottom: .15rem; white-space: nowrap; }

/* Liens vers les séries sources (saisie des indices) */
.source-liens a { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
