/* Habillage inspiré de la feuille LSPD : marine, or, noir et rouge. */
:root {
  --navy: #1e2645; --navy-deep: #0b174f; --gold: #d7ae5c; --blue: #224f9c; --sky: #c9daf8; --red: #a21313; --grey: #666666;
  --bg: #151b33; --panel: #1e2645; --panel-2: #283159; --line: #3a4573; --text: #eef1fa; --muted: #a9b3d1; --amber: #f0b429;
  --paper: #ffffff; --ink: #14182b; --rule: #d8dce8; --ink-muted: #5b6380;
  --font: "Lexend", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--navy); color: var(--text); font: 15px/1.45 var(--font); }

/* Bandeau : insigne + devise à gauche, grand titre, sceau de la ville à droite */
.masthead { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px 24px; padding: 14px 28px; background: var(--navy); }
.mast-left { display: flex; align-items: center; gap: 14px; }
.mast-badge { height: 96px; width: auto; }
.mast-tagline { height: 56px; width: auto; }
.mast-title { margin: 0; text-align: center; color: #fff; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; line-height: 1.05; font-size: clamp(22px, 3.6vw, 48px); }
.mast-right { display: flex; align-items: center; gap: 12px; }
.mast-seal { height: 84px; width: auto; }
.mast-city { color: #fff; font-style: italic; font-size: 15px; max-width: 7em; line-height: 1.2; }

/* Barre d'onglets et de connexion : noire, filets or */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 8px 28px; background: #000; border-top: 3px solid var(--gold); border-bottom: 3px solid var(--gold); }
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab, .btn { background: transparent; color: #fff; border: 1px solid #444; padding: 6px 14px; border-radius: 4px; cursor: pointer; text-decoration: none; font: inherit; font-size: 14px; }
.tab.active { background: var(--gold); border-color: var(--gold); color: #000; font-weight: 700; }
.btn:hover, .tab:hover { border-color: var(--gold); }
.session { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.banner { margin: 0; padding: 10px 28px; background: #3a2a05; color: var(--amber); border-bottom: 1px solid var(--amber); }

main { padding: 20px 28px 40px; max-width: 1600px; margin: 0 auto; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.tools input, .tools select { background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 4px; padding: 8px 12px; font: inherit; min-width: 240px; }
.counts { color: var(--muted); margin-left: auto; }

/* Sections : feuille blanche, bandeaux de couleur par niveau */
.unit { margin: 0 0 26px; background: var(--paper); color: var(--ink); border-radius: 2px; overflow: hidden; }
.unit .unit { margin: 0; border-radius: 0; }
.unit > h2 { margin: 0; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px 16px; min-height: 48px; font-size: 18px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; text-align: center; background: var(--blue); color: #fff; }
.unit > h2[role=button] { cursor: pointer; user-select: none; }
.unit > h2:focus-visible, tr.selectable:focus-visible, .tab:focus-visible, .btn:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.unit-logo { height: 48px; width: auto; max-width: 80px; object-fit: contain; flex: none; }
.unit-count { background: rgba(0, 0, 0, .28); color: inherit; border-radius: 999px; padding: 1px 10px; font-size: 13px; letter-spacing: 0; font-weight: 700; }
.unit.kind-headquarters > h2 .unit-count { background: rgba(0, 0, 0, .75); color: var(--gold); }
.unit.kind-office > h2 .unit-count { background: var(--blue); color: #fff; }
.unit.collapsed > :not(h2) { display: none; }
.unit-count::after { content: " \25BE"; }
.unit > h2[aria-expanded=false] .unit-count::after { content: " \25B8"; }
.unit.kind-unassigned > h2 { background: #3d4466; color: #fff; }
.unit.kind-headquarters > h2 { background: var(--gold); color: #000; font-size: 20px; }
.unit.kind-headquarters > h2::before, .unit.kind-headquarters > h2::after { content: "\274B\274B\274B"; letter-spacing: .15em; }
.unit.kind-office > h2 { background: var(--sky); color: var(--blue); font-size: 15px; }
.unit.kind-office > h2::before, .unit.kind-office > h2::after { content: "\274B"; }
.unit.kind-bureau > h2 { background: var(--blue); color: #fff; }
.unit.kind-division > h2 { background: var(--grey); color: #fff; font-size: 22px; letter-spacing: .12em; }
.unit.kind-unit > h2 { background: var(--navy-deep); color: #fff; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; vertical-align: middle; font-size: 14px; }
th { background: var(--red); color: #fff; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 0; }
.unit.kind-headquarters > .table-wrap th { background: #000; }
tbody tr:hover { background: #eef2fb; }
td.name { font-weight: 600; white-space: normal; }
td.blank { color: #aeb4c8; }
.c-stripes, .c-badge { text-align: center; }
th.c-status, td.c-status { width: 130px; }
.insignia { display: block; height: 28px; width: auto; max-width: 60px; object-fit: contain; }

/* Statut : toute la cellule est colorée, comme dans la feuille */
.status-cell { text-align: center; font-weight: 600; background: #d9ead3; color: #274e13; }
.status-cell.status-loa { background: #fff2cc; color: #7f6000; }
.status-cell.status-inactive { background: #fce5cd; color: #783f04; }
.status-cell.status-resigned { background: #d9d2e9; color: #351c75; }
.status-cell.status-fired { background: #f4cccc; color: #85200c; }
.status-cell.status-tbd, .status-cell.status-former { background: #cfe2f3; color: #0b5394; }
.status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; }
.flag { color: #b45f06; font-size: 12px; margin-left: 6px; }
.empty { color: var(--ink-muted); padding: 16px; margin: 0; }
.foot { color: var(--muted); text-align: center; padding: 18px; border-top: 3px solid var(--gold); background: #000; }
@media (max-width: 900px) {
  .masthead { padding: 10px 14px; gap: 8px 12px; grid-template-columns: auto 1fr auto; }
  .mast-badge { height: 56px; } .mast-tagline { display: none; } .mast-seal { height: 52px; } .mast-city { display: none; }
  .mast-title { font-size: clamp(15px, 4.4vw, 26px); }
  .bar { padding: 6px 14px; } main { padding: 12px; }
  .tools input, .tools select { min-width: 0; flex: 1; }
  .unit > h2 { font-size: 14px; min-height: 40px; gap: 10px; padding: 8px 10px; }
  .unit-logo { height: 34px; max-width: 54px; }
}
@media (max-width: 720px) {
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 9px 12px; border-bottom: 1px solid var(--rule); }
  td { border: 0; padding: 0; white-space: normal; font-size: 13px; }
  td.blank { display: none; }
  td.c-insignia { order: 0; flex: 0 0 46px; }
  td.c-insignia .insignia { max-width: 46px; }
  td.c-insignia.blank { display: block; visibility: hidden; }
  td.c-name { order: 1; flex: 1 1 0; min-width: 0; font-size: 15px; }
  td.c-status { order: 2; flex: none; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
  td.c-rank { order: 3; flex: 1 0 100%; color: var(--ink-muted); font-weight: 600; }
  td.c-badge, td.c-callsign, td.c-assignment, td.c-hire, td.c-promotion, td.c-stripes, td.c-extra { order: 4; color: var(--ink-muted); }
  td.c-badge::before, td.c-callsign::before, td.c-assignment::before, td.c-hire::before, td.c-promotion::before,
  td.c-stripes::before, td.c-extra::before { content: attr(data-label) ": "; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #8a91a8; }
  td.c-stripes, td.c-badge { text-align: left; }
  tbody tr:last-child { border-bottom: 0; }
}

/* Fenêtre d'édition et éléments réservés au commandement : fond marine */
dialog { background: var(--panel); color: var(--text); border: 2px solid var(--gold); border-radius: 8px; padding: 0; max-width: 560px; width: 92vw; }
dialog::backdrop { background: rgba(5, 9, 18, .72); }
.editor { padding: 18px 20px; display: grid; gap: 10px; }
.editor h3 { margin: 0 0 4px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; font: inherit; }
.actions { display: flex; gap: 10px; justify-content: flex-end; }
.message { color: var(--amber); margin: 0; min-height: 1.2em; }
tr.selectable { cursor: pointer; }
.unit .btn { background: var(--navy); border-color: var(--navy); }
.unit .btn:hover { border-color: var(--gold); }
td input, td select { background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 4px; padding: 5px 8px; font: inherit; max-width: 240px; }
td .btn { margin-right: 6px; padding: 4px 10px; }
.flag-cell { color: #b45f06; }
