:root {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1c2029;
  --line: #262b36;
  --line-strong: #343a48;
  --txt: #e7e9ef;
  --muted: #949cae;
  --acc: #7cb0ff;
  --acc-ink: #0a1424;
  --err: #ff7a7a;
  --err-bg: #2a1517;
  --ok: #6fdc9b;
  --ok-bg: #12261b;
  --sim: #f2c94c;
  --sim-bg: #241e0c;
  --radius: 10px;
  --space: 1rem;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--line-strong) var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #2c4a7a; color: #fff; }
input, textarea { caret-color: var(--acc); }
input[type=checkbox] { accent-color: var(--acc); width: 1rem; height: 1rem; margin: 0; }

a { color: var(--acc); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: .95rem; font-weight: 600; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

/* Bandeau de mode : toujours visible, en haut de chaque page */
.banner {
  display: flex; justify-content: center; align-items: center; gap: .5rem;
  background: var(--sim-bg); color: var(--sim);
  border-bottom: 1px solid #3d3313;
  padding: .35rem 1rem; font-size: .82rem; font-weight: 500;
}
.banner::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--sim); }

header { background: var(--surface); border-bottom: 1px solid var(--line); }
nav { display: flex; align-items: center; gap: .25rem; max-width: 1040px; margin: auto; padding: .5rem 1rem; }
.brand { font-weight: 700; letter-spacing: -.01em; margin-right: 1rem; }
nav a { color: var(--muted); text-decoration: none; padding: .4rem .65rem; border-radius: 6px; }
nav a:hover { color: var(--txt); background: var(--surface-2); }
nav a[aria-current=page] { color: var(--txt); background: var(--surface-2); }
nav form { margin: 0 0 0 auto; }

main { max-width: 1040px; margin: auto; padding: 1.75rem 1rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.page-head .meta { color: var(--muted); font-size: .9rem; }
.back { display: inline-block; margin-bottom: .75rem; font-size: .9rem; }

/* Résumé du tableau de bord */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1.5rem; }
.summary > div { padding: .9rem 1.1rem; }
.summary > div + div { border-left: 1px solid var(--line); }
.summary dt { color: var(--muted); font-size: .82rem; }
.summary dd { margin: .15rem 0 0; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary dd a { font-size: .85rem; font-weight: 400; margin-left: .4rem; }

.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 820px) { .grid { grid-template-columns: 3fr 2fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
.grid + .card { margin-top: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.card-head a { font-size: .85rem; }
.narrow { max-width: 400px; margin: 3rem auto; }
.login-brand { font-weight: 700; font-size: 1.1rem; margin-bottom: 1.25rem; }

/* Tableaux */
.scroll { overflow-x: auto; margin: 0 -.4rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; border-bottom-color: var(--line-strong); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #191d25; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.asset { font-weight: 600; }
.sub { color: var(--muted); font-weight: 400; font-size: .85em; }

.tag { display: inline-block; font-size: .78rem; line-height: 1.4; padding: 0 .45rem; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.tag.on { color: var(--ok); border-color: #285a3c; background: var(--ok-bg); }

/* Formulaires */
form { margin: 0; }
label { display: block; margin: 0 0 1rem; font-size: .9rem; font-weight: 500; }
.hint { display: block; color: var(--muted); font-weight: 400; font-size: .82rem; margin-top: .15rem; }
input[type=text], input[type=password], input:not([type]), textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .55rem .7rem;
  background: var(--bg); color: var(--txt);
  border: 1px solid var(--line-strong); border-radius: 7px; font: inherit; font-weight: 400;
}
input:hover, textarea:hover { border-color: #46506a; }
input:focus-visible, textarea:focus-visible { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px #7cb0ff33; }
input[inputmode=decimal] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 8rem; line-height: 1.5; }
.row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-size: .9rem; font-weight: 500; padding: 0; margin-bottom: .45rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips label { display: inline-flex; align-items: center; gap: .45rem; margin: 0; padding: .35rem .7rem; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; font-weight: 500; }
.chips label:hover { border-color: #46506a; }
.chips label:has(:checked) { border-color: var(--acc); background: #16243a; }
.check { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-foot .check { margin: 0; }

button {
  background: var(--acc); color: var(--acc-ink); border: 0; border-radius: 7px;
  padding: .55rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer;
  transition: filter .15s ease-out, transform .1s ease-out;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; filter: none; transform: none; }
button.link { background: none; color: var(--muted); padding: .4rem .65rem; font-weight: 400; border-radius: 6px; }
button.link:hover { color: var(--txt); background: var(--surface-2); filter: none; }
.danger { border-color: #4a2427; }
.danger h2 { color: var(--err); }
.danger-btn { background: transparent; color: var(--err); border: 1px solid #6b2e33; }
.danger-btn:hover { background: var(--err-bg); filter: none; }

/* Messages */
.muted { color: var(--muted); }
.error, .ok { padding: .6rem .8rem; border-radius: 7px; margin: 0 0 1rem; font-size: .9rem; }
.error { color: var(--err); background: var(--err-bg); border: 1px solid #4a2427; }
.ok { color: var(--ok); background: var(--ok-bg); border: 1px solid #234a33; }
ul.error { padding-left: 1.8rem; }
.empty { color: var(--muted); padding: .25rem 0; }
.empty strong { color: var(--txt); font-weight: 500; }
code { font: .85em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; color: var(--txt); }

@media (max-width: 560px) {
  nav { flex-wrap: wrap; padding: .4rem .6rem; }
  .brand { order: 0; margin: 0 auto 0 .4rem; }
  nav form { order: 1; margin: 0; }
  nav::after { content: ""; order: 2; flex-basis: 100%; }
  nav a { order: 3; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary > div:first-child { grid-column: 1 / -1; }
  .summary > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .summary > div:last-child { border-left: 1px solid var(--line); }
  .summary dd { font-size: 1.1rem; }
  main { padding-top: 1.25rem; }
  .card { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
.form-foot.bare { border: 0; padding: 0; }
