/* Design system « Cockpit nuit » — composants réutilisables (appli client et console admin). */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation; /* pas de zoom au double appui (clavier du code) ; le zoom à deux doigts reste possible */
}
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(120% 60% at 50% -10%, #12203a 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img,
svg {
  display: block;
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--gold-2);
  text-underline-offset: 3px;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- mise en page */
.shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: calc(var(--s-4) + var(--safe-t)) var(--s-4) calc(var(--nav-h) + var(--s-8) + var(--safe-b));
}
.shell.wide {
  max-width: 1180px;
}
.shell.no-nav {
  padding-bottom: calc(var(--s-8) + var(--safe-b));
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.row.between {
  justify-content: space-between;
}
.row.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}
.center {
  text-align: center;
}

/* ---------------------------------------------------------------- typographie */
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.h1 {
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.h2 {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}
.big {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: var(--fs-sm);
}
.xs {
  font-size: var(--fs-xs);
}
.pos {
  color: var(--green);
}
.neg {
  color: var(--red);
}
.gold {
  color: var(--gold);
}
p {
  margin: 0;
}

/* ---------------------------------------------------------------- en-tête */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--gold-2), var(--gold) 55%, #c99a1c);
  display: grid;
  place-items: center;
  color: var(--gold-ink);
  font-weight: 900;
  font-size: 0.85rem;
  box-shadow: 0 6px 18px rgba(245, 197, 66, 0.25);
}

/* ---------------------------------------------------------------- cartes */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}
.card.flat {
  background: var(--surface);
  box-shadow: none;
}
.card.tap {
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-med) var(--ease);
}
.card.tap:active {
  transform: scale(0.985);
}
.card.tap:hover {
  border-color: var(--line-2);
}
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.list {
  display: flex;
  flex-direction: column;
}
.list > .item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 56px;
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}
.list > .item:first-child {
  border-top: 0;
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-med) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-med);
  user-select: none;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-color: transparent;
  color: var(--gold-ink);
  box-shadow: 0 8px 22px rgba(245, 197, 66, 0.22);
}
.btn.danger {
  background: var(--red-bg);
  border-color: rgba(255, 91, 110, 0.35);
  color: var(--red);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.block {
  width: 100%;
}
.btn.lg {
  min-height: 54px;
  font-size: var(--fs-lg);
  border-radius: var(--r-lg);
}
.btn.sm {
  min-height: 36px;
  padding: 0 var(--s-3);
  font-size: var(--fs-sm);
}
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------------- bouton marche / arrêt */
.power {
  position: relative;
  width: 168px;
  height: 168px;
  margin: var(--s-2) auto var(--s-3);
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: radial-gradient(circle at 50% 35%, var(--surface-3), var(--surface) 70%);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  transition: box-shadow var(--t-slow) var(--ease), color var(--t-slow) var(--ease), transform var(--t-fast);
}
.power:active {
  transform: scale(0.97);
}
.power svg {
  width: 56px;
  height: 56px;
}
.power .label {
  position: absolute;
  bottom: 30px;
  font-weight: 800;
  font-size: var(--fs-sm);
  letter-spacing: 0.14em;
}
.power[aria-pressed="true"] {
  color: var(--green);
  border-color: rgba(61, 220, 155, 0.45);
  box-shadow: var(--glow-green);
}
.power[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(61, 220, 155, 0.35);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- pastilles, badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.ok {
  background: var(--green-bg);
  color: var(--green);
}
.badge.warn {
  background: var(--amber-bg);
  color: var(--gold);
}
.badge.err {
  background: var(--red-bg);
  color: var(--red);
}
.badge.info {
  background: var(--blue-bg);
  color: var(--blue);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.side {
  font-weight: 800;
  font-size: var(--fs-xs);
  padding: 2px 7px;
  border-radius: 6px;
}
.side.buy {
  background: var(--green-bg);
  color: var(--green);
}
.side.sell {
  background: var(--red-bg);
  color: var(--red);
}

/* ---------------------------------------------------------------- contrôle segmenté */
.segmented {
  display: flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.segmented button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-med) var(--ease), color var(--t-med);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.chips {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.chip {
  flex: none;
  min-height: 36px;
  padding: 0 var(--s-4);
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--amber-bg);
}

/* ---------------------------------------------------------------- formulaires */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label,
.label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
}
.input {
  width: 100%;
  min-height: 50px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--t-med), box-shadow var(--t-med);
}
.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.18);
}
.input[aria-invalid="true"] {
  border-color: var(--red-strong);
}
.hint {
  font-size: var(--fs-xs);
  color: var(--muted);
}
.error-text {
  font-size: var(--fs-sm);
  color: var(--red);
  font-weight: 600;
}
.check {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  min-height: var(--tap);
}
.check input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--gold);
  flex: none;
}
.switch {
  position: relative;
  width: 52px;
  height: 32px;
  flex: none;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  cursor: pointer;
  transition: background var(--t-med) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform var(--t-med) var(--ease);
}
.switch:checked {
  background: var(--green);
  border-color: var(--green);
}
.switch:checked::after {
  transform: translateX(20px);
  background: #062016;
}
.stepper {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.stepper output {
  min-width: 70px;
  text-align: center;
  font-weight: 800;
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
}
.suggest {
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  max-height: 240px;
  overflow: auto;
}
.suggest button {
  display: block;
  width: 100%;
  min-height: var(--tap);
  text-align: left;
  padding: 0 var(--s-4);
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.suggest button:first-child {
  border-top: 0;
}
.suggest button:hover,
.suggest button:focus-visible {
  background: var(--surface-3);
}

/* ---------------------------------------------------------------- bannières */
.banner {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.banner.warn {
  background: var(--amber-bg);
  border-color: rgba(245, 197, 66, 0.35);
}
.banner.err {
  background: var(--red-bg);
  border-color: rgba(255, 91, 110, 0.35);
}
.banner.ok {
  background: var(--green-bg);
  border-color: rgba(61, 220, 155, 0.35);
}
.banner strong {
  display: block;
}

/* ---------------------------------------------------------------- navigation basse */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 6px var(--s-4) calc(6px + var(--safe-b));
  background: rgba(7, 12, 24, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar nav {
  display: flex;
  max-width: var(--max);
  margin: 0 auto;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  color: var(--muted-2);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: var(--r-md);
}
.tabbar a svg {
  width: 24px;
  height: 24px;
}
.tabbar a[aria-current="page"] {
  color: var(--gold);
}

/* ---------------------------------------------------------------- feuille (détail) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: var(--max);
  max-height: 88dvh;
  margin: 0 auto;
  overflow: auto;
  padding: var(--s-3) var(--s-5) calc(var(--s-6) + var(--safe-b));
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(100%);
  transition: transform var(--t-slow) var(--ease);
}
.sheet.open {
  transform: translateY(0);
}
.sheet-backdrop.open {
  opacity: 1;
}
.sheet .grab {
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: var(--line-2);
  margin: 0 auto var(--s-4);
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--s-4);
  border-left: 2px solid var(--line-2);
}
.timeline li {
  position: relative;
  padding: 0 0 var(--s-4) var(--s-3);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--s-4) - 6px);
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--surface);
}

/* ---------------------------------------------------------------- squelettes, vides, toasts */
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-3) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  min-height: 18px;
}
.skeleton.card-h {
  height: 96px;
  border-radius: var(--r-lg);
}
.skeleton.circle {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  margin: 0 auto;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
.empty {
  text-align: center;
  padding: var(--s-8) var(--s-4);
  color: var(--muted);
}
.empty svg {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--s-3);
  color: var(--line-2);
}
.empty strong {
  display: block;
  color: var(--text);
  font-size: var(--fs-lg);
  margin-bottom: 4px;
}
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--s-3) + var(--safe-t));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  pointer-events: none;
  padding: 0 var(--s-4);
}
.toast {
  pointer-events: auto;
  max-width: 480px;
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  font-weight: 600;
  font-size: var(--fs-sm);
  animation: toast-in var(--t-slow) var(--ease);
}
.toast.err {
  border-color: rgba(255, 91, 110, 0.5);
}
.toast.ok {
  border-color: rgba(61, 220, 155, 0.5);
}
@keyframes toast-in {
  from {
    transform: translateY(-12px);
    opacity: 0;
  }
}
.view {
  animation: view-in var(--t-slow) var(--ease);
}
@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------------------------------------------------------------- mention permanente */
.mention {
  margin-top: var(--s-6);
  font-size: var(--fs-xs);
  color: var(--muted-2);
  text-align: center;
  line-height: 1.4;
}
details.advanced > summary {
  list-style: none;
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
}
details.advanced > summary::-webkit-details-marker {
  display: none;
}
details.advanced[open] > summary .chev {
  transform: rotate(180deg);
}
.chev {
  transition: transform var(--t-med) var(--ease);
}

/* ---------------------------------------------------------------- tableaux (console, PC) */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th,
.table td {
  padding: var(--s-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th {
  color: var(--muted-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface);
  position: sticky;
  top: 0;
}
.table tr:last-child td {
  border-bottom: 0;
}

@media (min-width: 900px) {
  .only-mobile {
    display: none !important;
  }
}
@media (max-width: 899px) {
  .only-desktop {
    display: none !important;
  }
}

.center > .brand-mark,
.center .brand-mark {
  margin: 0 auto;
}
.right {
  text-align: right;
}
.dot.pos {
  color: var(--green);
}
.dot.neg {
  color: var(--red-strong);
}
