/* Bordée — charte : bleu marine, or, bleu océan, rouge. Smartphone d'abord, menu latéral sur ordinateur. */
:root {
  --navy: #002060; --navy-2: #0B1533; --gold: #D4A72C; --ocean: #2C9CDC; --red: #D8332B;
  --bg: #F3F5F9; --card: #FFFFFF; --line: #E1E6F0; --line-2: #D3DAE8; --text: #0E1A33; --muted: #4A5878; --soft: #EEF2FA;
  --ok-bg: #E6F5EC; --ok: #1C6B3C; --warn-bg: #FBF3DC; --warn: #6E540A; --bad-bg: #FDEBEA; --bad: #B4231C;
  --babord: #D8332B; --tribord: #1E8A4C;
  --radius: 16px; --nav-h: 72px;
  --title: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; }
h1, h2, h3, p { overflow-wrap: break-word; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* --- Structure --------------------------------------------------------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--navy); color: #fff; padding: calc(12px + env(safe-area-inset-top)) 16px 14px; }
.topbar-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.topbar img.logo { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; }
.topbar .ident { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
.topbar .ident b { font-family: var(--title); font-size: 20px; letter-spacing: .4px; text-transform: uppercase; line-height: 1.1; }
.topbar .ident span { font-size: 12px; color: #C9D3EA; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.12); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; text-decoration: none; }
.body { flex-grow: 1; display: flex; align-items: stretch; }
.main { flex: 1 1 auto; min-width: 0; max-width: 1280px; margin: 0 auto; width: 100%; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; }
.page-head .kicker { font-size: 13px; color: var(--muted); }
h1.title { margin: 0; font-family: var(--title); font-size: 32px; line-height: 1.05; color: var(--navy); }
h2.section { margin: 0; font-family: var(--title); font-size: 22px; color: var(--navy); }

/* Barre du bas (téléphone) */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bottomnav a, .bottomnav button { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: #6B7896; font-size: 11px; font-weight: 500; border: 0; background: none; cursor: pointer; }
.bottomnav .on { color: var(--navy); font-weight: 700; }

/* Panneau « Plus » */
.drawer-back { position: fixed; inset: 0 0 var(--nav-h) 0; z-index: 25; background: rgba(0,16,48,.45); border: 0; cursor: pointer; }
.drawer { position: fixed; top: 0; right: 0; bottom: var(--nav-h); z-index: 26; width: min(320px, 86vw); background: #fff; border-radius: 22px 0 0 22px; box-shadow: -10px 0 30px rgba(0,32,96,.25); padding: calc(18px + env(safe-area-inset-top)) 16px 18px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer-head b { font-family: var(--title); font-size: 24px; color: var(--navy); }
.menu-group { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: #6B7896; text-transform: uppercase; padding: 12px 4px 4px; display: flex; align-items: center; gap: 8px; }
.menu-item { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; background: var(--bg); border: 0; width: 100%; cursor: pointer; text-align: left; }
.menu-item.on { background: var(--navy); color: #fff; }
.menu-item.danger { color: var(--bad); background: none; }
.menu-item .soon { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--muted); }

/* Menu latéral (ordinateur) */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .bottomnav, .drawer, .drawer-back { display: none !important; }
  .sidebar { display: flex; flex-direction: column; gap: 2px; width: 252px; flex-shrink: 0; align-self: flex-start; position: sticky; top: 0; background: #fff; border-right: 1px solid var(--line); padding: 14px 12px 20px; min-height: calc(100vh - 70px); }
  .sidebar .menu-item { background: none; font-weight: 500; }
  .sidebar .menu-item.on { background: var(--navy); color: #fff; font-weight: 700; }
  .main { padding: 28px 32px 40px; }
}

/* --- Composants -------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.navy { background: var(--navy); color: #fff; border: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-family: var(--title); font-size: 28px; color: var(--navy); }
.kpi span { font-size: 12px; color: var(--muted); }
.btn { min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--navy); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line-2); font-weight: 600; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.chip { flex-shrink: 0; white-space: nowrap; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.pill { white-space: nowrap; flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--soft); color: #2B5B9A; }
.pill.gold { background: var(--gold); color: var(--navy); }
.pill.red { background: var(--bad-bg); color: var(--bad); }
.pill.green { background: var(--ok-bg); color: var(--ok); }
.pill.babord { background: var(--babord); color: #fff; }
.pill.tribord { background: var(--tribord); color: #fff; }
.muted { color: var(--muted); font-size: 13px; }
.notice { border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.info { background: var(--soft); color: var(--navy); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 46px; border: 1px solid var(--line-2); border-radius: 12px; padding: 0 12px; font-size: 15px; font-weight: 400; color: var(--text); background: #fff; width: 100%; }
.field textarea { padding: 10px 12px; min-height: 90px; }
.field small { font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; accent-color: var(--navy); }
.legend { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--navy); text-transform: uppercase; padding-bottom: 4px; border-bottom: 2px solid var(--gold); margin-top: 6px; }

/* Pages d'accès */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--navy); }
.auth .card { width: 100%; max-width: 440px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.auth .brand { display: flex; align-items: center; gap: 12px; }
.auth .brand img { width: 56px; height: 56px; }
.auth .brand b { font-family: var(--title); font-size: 30px; color: var(--navy); display: block; line-height: 1; }
.auth .brand span { font-size: 13px; color: var(--muted); }

/* Personnes */
.avatar { width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: var(--navy); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.grey { background: #8592AD; }
.person { display: flex; align-items: center; gap: 12px; }
.person .who { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; }
.person .who b { font-size: 15px; }
.trombi { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.trombi .t { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 13px; font-weight: 600; line-height: 1.2; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.mcard { text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; width: 100%; }
.mcard.on { border-color: var(--navy); box-shadow: 0 8px 20px rgba(0,32,96,.15); }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .left { flex: 2 1 420px; min-width: 0; }
.split > .right { flex: 1 1 320px; min-width: 0; }
.contact-link { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 12px; background: var(--bg); color: var(--navy); text-decoration: none; font-weight: 600; font-size: 14px; }

/* Épaulette (manchon) */
.ep { position: relative; display: inline-block; flex-shrink: 0; background: var(--navy-2); clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%); }
.ep svg { position: absolute; left: 50%; transform: translateX(-50%); }
.ep i { position: absolute; display: block; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; border-top: 0; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 20px; height: 20px; accent-color: var(--navy); }
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { white-space: nowrap; padding: 10px 12px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--gold); }

/* Fenêtre (PIN, confirmation) */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,16,48,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 20px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.pin-input { letter-spacing: 12px; text-align: center; font-size: 26px !important; font-weight: 700 !important; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); z-index: 70; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.bad { background: var(--bad); }
.copy-box { display: flex; gap: 8px; align-items: center; }
.copy-box input { flex-grow: 1; min-width: 0; min-height: 42px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 10px; font-size: 13px; background: var(--bg); }
[hidden] { display: none !important; }
td select { min-width: 130px; padding: 8px 10px; font-size: 14px; }
@media (max-width: 700px) {
  .members-table thead { display: none; }
  .members-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
  .members-table td { border: 0; padding: 0; }
  .members-table td:first-child { grid-column: 1 / -1; }
  .members-table td select { width: 100%; min-width: 0; }
}
