/* Gestion GREGAN : feuille de style unique.
   Reprend le langage visuel des maquettes validées (octobre 2026) : barre latérale #13284F,
   accent #183A76, fond #F6F5F2, bordures #E3E1DB, puces d'état, Manrope + IBM Plex Mono.
   Aucune règle n'est écrite dans les pages (politique de sécurité du contenu stricte). */

@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url('/static/fonts/manrope-latin-wght-normal.woff2') format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url('/static/fonts/manrope-latin-ext-wght-normal.woff2') format('woff2-variations');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-display: swap;
    font-weight: 400;
    src: url('/static/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-display: swap;
    font-weight: 500;
    src: url('/static/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

:root {
    --navy: #13284F;
    --navy-hover: #1E3765;
    --navy-count: #2B4A86;
    --navy-text: #D5DCEA;
    --navy-muted: #B9C4D8;
    --accent: #183A76;
    --accent-hover: #122C5A;
    --accent-dark: #0F2550;
    --accent-soft: #EEF2F9;
    --bg: #F6F5F2;
    --surface: #FFFFFF;
    --surface-alt: #FBFAF8;
    --border: #E3E1DB;
    --border-soft: #EEECE7;
    --border-input: #C9C5BC;
    --border-btn: #D6D3CB;
    --text: #16181B;
    --text-2: #4D535A;
    --muted: #5B6068;
    --hover-row: #F7F8FB;
    --ok-bg: #E4F1E8; --ok-fg: #1D6638;
    --warn-bg: #FBEBD3; --warn-fg: #874600;
    --bad-bg: #FBE5E3; --bad-fg: #9E2219;
    --info-bg: #E6EDF8; --info-fg: #1C4C8A;
    --neutral-bg: #ECEDEE; --neutral-fg: #4A5057;
    --essai: #A64F00; /* blanc sur cette couleur : 5,6:1 (4,5 au moins pour ce texte) */
    --font: 'Manrope', 'Segoe UI', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Sur le fond foncé du menu, l'accent ne se voit pas (1,3:1) : contour blanc (14,5:1). */
.side :focus-visible { outline-color: #FFFFFF; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--surface); color: var(--accent); padding: 10px 14px; border: 2px solid var(--accent); border-radius: 6px; font-weight: 700; }
.skip:focus { left: 16px; }
main:focus { outline: none; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0; font-weight: 700; }
h3 { font-size: 13px; margin: 0; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
ul { margin: 0; padding-left: 20px; }
.mono { font-family: var(--mono); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.between.baseline { align-items: baseline; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 16px; align-items: start; }
.grid-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border-btn); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text-2); background: var(--surface); }
.ic { width: 18px; height: 18px; flex: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Bandeau de la copie d'essai */
.essai { background: var(--essai); color: #FFFFFF; font-weight: 700; text-align: center; padding: 6px 16px; letter-spacing: .02em; }

/* Gabarit : barre latérale + zone principale */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; background: var(--navy); color: #FFFFFF; display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; }
.side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side .side-toggle { display: none; }
.side-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #FFFFFF; text-decoration: none; }
.brand:hover { color: #FFFFFF; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: #FFFFFF; color: var(--navy); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.brand-name { font-weight: 800; }
.brand-host { font-size: 12px; color: var(--navy-muted); }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side a.nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 6px; color: var(--navy-text); text-decoration: none; font-weight: 600; }
.side a.nav:hover { background: var(--navy-hover); color: #FFFFFF; }
.side a.nav.on { background: #FFFFFF; color: var(--navy); }
.count { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: var(--navy-count); color: #FFFFFF; }
.count.alert { background: var(--bad-fg); }
.side .sep { flex: 1; min-height: 24px; }
.side-foot { padding: 10px 12px 0; font-size: 12px; color: var(--navy-muted); }
.side-foot kbd { background: var(--navy-hover); color: #FFFFFF; border-color: #3A5793; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.search { flex: 1 1 320px; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--border-btn); border-radius: 6px; background: var(--surface-alt); color: var(--muted); margin: 0; }
.search input { border: 0; background: transparent; font: inherit; color: var(--text); flex: 1; min-width: 0; outline: none; min-height: 38px; }
.search:focus-within { border-color: var(--accent); }
.content { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
.content.tabs-first { padding-top: 0; }

/* Boutons : un seul bouton plein (primary) par écran */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border-btn); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #F1EFEA; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn.primary:hover { background: var(--accent-hover); color: #FFFFFF; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--bad-fg); border-color: #E7B9B4; }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad-fg); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.wrap { white-space: normal; text-align: left; min-height: 36px; height: auto; padding-top: 6px; padding-bottom: 6px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.card-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.pad { padding: 14px 16px; }
.empty { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1 1 260px; min-width: 0; }
a.row { text-decoration: none; color: var(--text); }
a.row:hover { background: var(--hover-row); color: var(--text); }
a.row:hover .strong { text-decoration: underline; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); color: var(--text); }
.tile .big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.foot { font-size: 12px; color: var(--muted); }

/* Puces d'état : toujours un mot, jamais la couleur seule */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ok { background: var(--ok-bg); color: var(--ok-fg); }
.warn { background: var(--warn-bg); color: var(--warn-fg); }
.bad { background: var(--bad-bg); color: var(--bad-fg); }
.info { background: var(--info-bg); color: var(--info-fg); }
.neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Sous-menu d'une rubrique */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); padding-top: 8px; }
.subnav a { padding: 10px 12px; color: var(--text-2); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a.on { color: var(--accent); border-bottom-color: var(--accent); }
.subnav a:hover { color: var(--text); }

/* Tableaux denses (lignes d'environ 36 px) */
/* position: relative : un texte masqué (.sr) d'une cellule reste dans la zone qui défile,
   sinon il élargit toute la page sur téléphone. */
.tbl-wrap { overflow-x: auto; position: relative; }
table.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { background: var(--surface-alt); font-size: 12px; font-weight: 700; color: var(--text-2); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--hover-row); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .sub { display: block; font-size: 12px; color: var(--muted); }
.tbl tr.off td { color: var(--muted); }

/* Formulaires */
form { margin: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .input { min-height: 40px; padding: 0 10px; border: 1px solid var(--border-input); border-radius: 6px; font: inherit; font-size: 14px; font-weight: 500; color: var(--text); background: var(--surface); width: 100%; }
.field input:focus, .field select:focus, .input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.field .hint { font-weight: 500; color: var(--muted); }
.field.has-error input, .field.has-error select { border-color: var(--bad-fg); }
.field .error { color: var(--bad-fg); font-weight: 600; }
.field-code input { font-family: var(--mono); font-size: 20px; letter-spacing: .2em; max-width: 220px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 16px; }
.filters .field { flex: 1 1 180px; }
.filters .field.narrow { flex: 0 1 160px; }

/* Messages */
.msg { padding: 10px 14px; border-radius: 6px; font-weight: 600; }
.msg.ok { border: 1px solid #BFDCC8; }
.msg.bad { border: 1px solid #EDC2BE; }
.msg.warn { border: 1px solid #F0D2A6; }
.msg.info { border: 1px solid #C9D7EE; }

/* Secret affiché une seule fois */
.secret { border: 2px solid var(--accent); border-radius: 8px; background: var(--accent-soft); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.secret-value { font-family: var(--mono); font-size: 20px; font-weight: 500; letter-spacing: .04em; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; word-break: break-all; user-select: all; }
.secret-warn { color: var(--bad-fg); font-weight: 700; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 16px; }

/* Définitions (fiche) */
.dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* Actions repliables : la conséquence est écrite avant le bouton de confirmation */
details.action { border-top: 1px solid var(--border-soft); }
details.action:first-of-type { border-top: 0; }
details.action > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--accent); display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 44px; }
details.action > summary::-webkit-details-marker { display: none; }
details.action > summary::after { content: '+'; font-weight: 700; color: var(--muted); }
details.action[open] > summary::after { content: '\2212'; }
details.action > summary.danger { color: var(--bad-fg); }
details.action .action-body { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 10px; }

/* Menus de la barre du haut */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(22, 24, 27, .10); padding: 6px; display: flex; flex-direction: column; }
.menu a, .menu button.item { display: flex; align-items: center; min-height: 40px; padding: 0 10px; border-radius: 6px; color: var(--text); text-decoration: none; font: inherit; font-weight: 600; background: none; border: 0; text-align: left; cursor: pointer; width: 100%; }
.menu a:hover, .menu button.item:hover { background: var(--accent-soft); color: var(--text); }
.menu .menu-note { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.menu .menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; }

/* Fenêtre des raccourcis */
dialog.dialog { border: 1px solid var(--border); border-radius: 10px; padding: 0; max-width: min(520px, calc(100vw - 32px)); width: 100%; color: var(--text); }
dialog.dialog::backdrop { background: rgba(22, 24, 27, .35); }
.dialog-h { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.keys { margin: 0; padding: 12px 16px 16px; display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; }
.keys dd { margin: 0; }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border-soft); }

/* Pages de connexion */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; }
.auth-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 18px; }
.auth-card.wide { max-width: 600px; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: var(--navy); }
.auth-brand .brand-mark { background: var(--navy); color: #FFFFFF; }
.auth-card .card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.qr { display: flex; justify-content: center; padding: 8px; background: #FFFFFF; border: 1px solid var(--border); border-radius: 8px; width: max-content; max-width: 100%; }
.qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* Rubrique pas encore construite */
.phase { display: flex; gap: 12px; align-items: flex-start; }
.phase .chip { flex: none; }

/* Téléphone : menu replié derrière un bouton « Menu » (déplié, il forme une grille),
   cibles de 44 px au moins */
@media (max-width: 720px) {
    /* Sans cela, la hauteur libre de l'écran est répartie entre le menu et la page. */
    .app { align-content: flex-start; }
    .side { padding: 8px 12px; }
    .brand { padding: 4px; }
    .side .side-toggle { display: inline-flex; min-height: 44px; background: transparent; color: #FFFFFF; border-color: #3A5793; }
    .side-toggle:hover { background: var(--navy-hover); color: #FFFFFF; }
    .js .side-body { display: none; }
    .js .side.open .side-body { display: flex; padding-top: 8px; }
    .side-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
    .side a.nav { min-height: 44px; }
    .side .sep { display: none; }
    .side-foot { display: none; }
    .top { padding: 8px 16px; gap: 6px; }
    .top .btn { padding: 0 10px; }
    .content { padding: 16px 16px 32px; }
    .btn, .btn.sm { min-height: 44px; }
    .field input, .field select, .input { min-height: 44px; }
    .search { min-height: 44px; }
    .search input { min-height: 42px; }
    .subnav a { min-height: 44px; display: inline-flex; align-items: center; }
    .crumb a, .card-h a, .hint a { display: inline-flex; align-items: center; min-height: 44px; }
    .hide-phone { display: none; }
    .menu { position: fixed; left: 16px; right: 16px; top: auto; }
}

@media print {
    .side, .top, .essai { display: none; }
    body { background: #FFFFFF; }
    .card { border-color: #999999; }
}
