/* Gardien — système de design du dashboard.
   Source unique des couleurs web. Anatomie et intentions : docs/DESIGN.md. */

/* ============================================================
   1. Tokens
   ============================================================ */

:root {
  color-scheme: light;

  --g-bg: #f6f7fb;
  --g-bg-tint: #edeff9;
  --g-surface: #ffffff;
  --g-surface-2: #f2f4fa;
  --g-surface-3: #e8ebf5;

  --g-ink: #1b1d2a;
  --g-ink-2: #4a4f63;
  --g-muted: #6b7185;

  --g-line: #e3e6f0;
  --g-line-strong: #cdd2e2;

  --g-brand: #5b5bd6;
  --g-brand-hover: #5151cd;
  --g-brand-ink: #3e3f94;
  --g-brand-soft: #eeeefb;
  --g-on-brand: #ffffff;

  --g-ok: #0f9b8e;
  --g-ok-ink: #0c7a70;
  --g-ok-soft: #e3f5f2;

  --g-warn: #b5730b;
  --g-warn-ink: #8f5a06;
  --g-warn-soft: #fdf3e0;

  --g-danger: #dc3e43;
  --g-danger-ink: #b62b30;
  --g-danger-soft: #fdecec;

  --g-info: #3b82c4;
  --g-info-soft: #e9f2fb;

  --g-scrim: rgba(27, 29, 42, 0.44);
  --g-focus-ring: rgba(91, 91, 214, 0.28);

  --g-radius-xs: 8px;
  --g-radius-sm: 12px;
  --g-radius-md: 16px;
  --g-radius-lg: 20px;
  --g-radius-xl: 28px;
  --g-radius-pill: 999px;

  --g-shadow-sm: 0 1px 2px rgba(16, 18, 28, 0.05), 0 1px 3px rgba(16, 18, 28, 0.04);
  --g-shadow-md: 0 4px 14px -6px rgba(16, 18, 28, 0.12), 0 2px 6px -3px rgba(16, 18, 28, 0.06);
  --g-shadow-lg: 0 24px 48px -28px rgba(16, 18, 28, 0.32);
  --g-shadow-brand: 0 10px 28px -14px rgba(91, 91, 214, 0.55);

  --g-font-title: "Outfit", "Segoe UI", system-ui, sans-serif;
  --g-font-ui: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;

  --g-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --g-dur-fast: 120ms;
  --g-dur-base: 200ms;
  --g-dur-slow: 320ms;
}

html.dark {
  color-scheme: dark;

  --g-bg: #0f1117;
  --g-bg-tint: #151824;
  --g-surface: #171a24;
  --g-surface-2: #1e2231;
  --g-surface-3: #262b3d;

  --g-ink: #edeff7;
  --g-ink-2: #c2c7d8;
  --g-muted: #8b92a8;

  --g-line: #262a38;
  --g-line-strong: #343a4d;

  --g-brand: #7c7cf0;
  --g-brand-hover: #8e8ef5;
  --g-brand-ink: #b0b0fa;
  --g-brand-soft: rgba(124, 124, 240, 0.16);
  --g-on-brand: #0f1117;

  --g-ok: #2ac4b3;
  --g-ok-ink: #6fe3d4;
  --g-ok-soft: rgba(42, 196, 179, 0.14);

  --g-warn: #e8a33d;
  --g-warn-ink: #f5c57a;
  --g-warn-soft: rgba(232, 163, 61, 0.14);

  --g-danger: #f2686c;
  --g-danger-ink: #ff9ca0;
  --g-danger-soft: rgba(242, 104, 108, 0.14);

  --g-info: #6ea8dc;
  --g-info-soft: rgba(110, 168, 220, 0.14);

  --g-scrim: rgba(6, 7, 12, 0.62);
  --g-focus-ring: rgba(124, 124, 240, 0.32);

  --g-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --g-shadow-md: 0 6px 18px -8px rgba(0, 0, 0, 0.6), 0 2px 6px -3px rgba(0, 0, 0, 0.45);
  --g-shadow-lg: 0 28px 56px -30px rgba(0, 0, 0, 0.8);
  --g-shadow-brand: 0 10px 28px -14px rgba(124, 124, 240, 0.6);
}

/* ============================================================
   2. Base
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--g-font-ui);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--g-ink);
  background-color: var(--g-bg);
  background-image:
    radial-gradient(ellipse 70% 45% at 12% -10%, var(--g-bg-tint), transparent 60%),
    radial-gradient(ellipse 55% 40% at 100% 0%, var(--g-brand-soft), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--g-font-title);
  margin: 0;
}

p,
dl,
dd,
ul,
ol,
figure,
pre {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--g-brand);
  text-decoration: none;
  font-weight: 700;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: none;
  border-color: var(--g-brand);
  box-shadow: 0 0 0 3px var(--g-focus-ring);
}

::selection {
  background: var(--g-brand-soft);
  color: var(--g-brand-ink);
}

.g-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--g-line-strong) transparent;
}

.g-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.g-scroll::-webkit-scrollbar-thumb {
  background: var(--g-line-strong);
  border-radius: var(--g-radius-pill);
}

.g-scroll::-webkit-scrollbar-track {
  background: transparent;
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* ============================================================
   3. Typographie
   ============================================================ */

.g-title,
.g-subtitle {
  font-family: var(--g-font-title);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--g-ink);
}

.g-title {
  font-size: 1.375rem;
  line-height: 1.25;
}

.g-subtitle {
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.g-body {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.55;
}

.g-small {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
}

.g-micro {
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.g-muted {
  color: var(--g-muted);
}

.g-strong {
  font-weight: 700;
  color: var(--g-ink);
}

.g-num {
  font-variant-numeric: tabular-nums;
}

.g-mono {
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
}

.g-truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   4. Primitives de mise en page
   ============================================================ */

.g-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.g-stack--sm {
  gap: 0.5rem;
}

.g-stack--md {
  gap: 0.75rem;
}

.g-stack--lg {
  gap: 1.5rem;
}

.g-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.g-row--wrap {
  flex-wrap: wrap;
}

.g-row--top {
  align-items: flex-start;
}

.g-row--tight {
  gap: 0.5rem;
}

.g-row--between {
  justify-content: space-between;
}

.g-row--right {
  justify-content: flex-end;
}

.g-fill {
  flex: 1;
  min-width: 0;
}

.g-push {
  margin-left: auto;
}

.g-grid {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.g-grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}

/* Deux tuiles par ligne sur un téléphone, quatre sur un écran large. */
.g-grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(148px, 100%), 1fr));
}

.g-grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(min(132px, 100%), 1fr));
}

/* Pour les tuiles qui portent une icône, deux lignes de texte et une commande. */
.g-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

.g-grid--devices {
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}

.g-grid--gallery {
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

/* ============================================================
   5. Coquille de l'application
   ============================================================ */

.g-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.g-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: color-mix(in srgb, var(--g-surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--g-line);
}

.g-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.g-brand__mark {
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--g-radius-md);
  background: var(--g-brand);
  color: var(--g-on-brand);
  box-shadow: var(--g-shadow-brand);
}

.g-brand__mark--lg {
  width: 3rem;
  height: 3rem;
  border-radius: var(--g-radius-lg);
}

.g-brand__name {
  font-family: var(--g-font-title);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.g-brand__tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--g-muted);
}

.g-nav {
  display: none;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-2);
  border: 1px solid var(--g-line);
  overflow-x: auto;
  scrollbar-width: none;
}

.g-nav::-webkit-scrollbar {
  display: none;
}

.g-nav__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border: 0;
  border-radius: var(--g-radius-pill);
  background: transparent;
  color: var(--g-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--g-dur-fast) var(--g-ease), color var(--g-dur-fast) var(--g-ease);
}

.g-nav__item:hover {
  color: var(--g-ink);
  background: var(--g-surface-3);
}

.g-nav__item.is-active {
  color: var(--g-brand-ink);
  background: var(--g-surface);
  box-shadow: var(--g-shadow-sm);
}

.g-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.g-main {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2.5rem;
}

.g-page-head {
  margin-bottom: 1.5rem;
}

.g-page-title {
  font-family: var(--g-font-title);
  font-size: clamp(1.875rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0;
}

.g-page-sub {
  margin-top: 0.375rem;
  font-size: 0.9375rem;
  color: var(--g-muted);
}

.g-bottomnav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.375rem 0.5rem calc(0.375rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--g-surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(18px);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--g-line);
}

.g-bottomnav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 3.25rem;
  padding: 0.375rem 0.25rem;
  border: 0;
  border-radius: var(--g-radius-md);
  background: transparent;
  color: var(--g-muted);
  font: inherit;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color var(--g-dur-fast) var(--g-ease), background var(--g-dur-fast) var(--g-ease);
}

.g-bottomnav__item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-bottomnav__item.is-active {
  color: var(--g-brand-ink);
  background: var(--g-brand-soft);
}

@media (min-width: 960px) {
  .g-topbar {
    padding: 0.75rem 2rem;
  }

  .g-nav {
    display: flex;
  }

  /* Huit onglets ne tiennent pas avec leurs libellés : icônes seules jusqu'à 1280px. */
  .g-nav__item span {
    display: none;
  }

  .g-nav__item {
    padding: 0.5rem 0.7rem;
  }

  .g-main {
    padding: 2rem 2rem 3rem;
  }

  .g-bottomnav {
    display: none;
  }
}

@media (min-width: 1280px) {
  .g-nav__item span {
    display: inline;
  }

  .g-nav__item {
    padding: 0.5rem 0.85rem;
  }
}

@media (max-width: 959px) {
  .g-main {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }

  .g-only-desktop {
    display: none !important;
  }
}

/* ============================================================
   6. Écran de connexion
   ============================================================ */

.g-login {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  overflow-y: auto;
}

.g-login__halo {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 22% 8%, var(--g-brand-soft), transparent 62%),
    radial-gradient(ellipse 50% 40% at 82% 92%, var(--g-ok-soft), transparent 60%),
    linear-gradient(170deg, var(--g-bg-tint), var(--g-bg) 55%);
}

.g-login__card {
  position: relative;
  width: 100%;
  max-width: 25rem;
  padding: 2rem;
  border-radius: var(--g-radius-xl);
  background: var(--g-surface);
  border: 1px solid var(--g-line);
  box-shadow: var(--g-shadow-lg);
}

.g-login__eyebrow {
  color: var(--g-brand-ink);
}

.g-login__version {
  text-align: center;
  color: var(--g-muted);
}

/* ============================================================
   7. Boutons
   ============================================================ */

.g-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--g-radius-md);
  background: transparent;
  color: var(--g-ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--g-dur-fast) var(--g-ease),
    border-color var(--g-dur-fast) var(--g-ease),
    color var(--g-dur-fast) var(--g-ease),
    transform var(--g-dur-fast) var(--g-ease);
}

.g-btn:hover {
  text-decoration: none;
}

.g-btn:active {
  transform: translateY(1px);
}

.g-btn:disabled,
.g-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.g-btn--primary {
  background: var(--g-brand);
  color: var(--g-on-brand);
  box-shadow: var(--g-shadow-brand);
}

.g-btn--primary:hover:not(:disabled) {
  background: var(--g-brand-hover);
}

.g-btn--secondary {
  background: var(--g-surface);
  color: var(--g-ink);
  border-color: var(--g-line);
  box-shadow: var(--g-shadow-sm);
}

.g-btn--secondary:hover:not(:disabled) {
  border-color: var(--g-line-strong);
  background: var(--g-surface-2);
}

.g-btn--soft {
  background: var(--g-brand-soft);
  color: var(--g-brand-ink);
}

.g-btn--soft:hover:not(:disabled) {
  background: color-mix(in srgb, var(--g-brand-soft) 70%, var(--g-brand) 12%);
}

.g-btn--danger {
  background: var(--g-danger-soft);
  color: var(--g-danger-ink);
}

.g-btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--g-danger-soft) 70%, var(--g-danger) 14%);
}

.g-btn--ok {
  background: var(--g-ok-soft);
  color: var(--g-ok-ink);
}

.g-btn--ok:hover:not(:disabled) {
  background: color-mix(in srgb, var(--g-ok-soft) 70%, var(--g-ok) 14%);
}

.g-btn--ghost {
  background: transparent;
  color: var(--g-muted);
}

.g-btn--ghost:hover:not(:disabled) {
  color: var(--g-ink);
  background: var(--g-surface-2);
}

.g-btn--sm {
  min-height: 2rem;
  padding: 0 0.65rem;
  font-size: 0.75rem;
  border-radius: var(--g-radius-sm);
}

.g-btn--lg {
  min-height: 3rem;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
}

.g-btn--block {
  display: flex;
  width: 100%;
}

.g-btn--icon {
  width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  flex: none;
}

.g-btn--icon.g-btn--sm {
  width: 2rem;
  min-height: 2rem;
}

@media (pointer: coarse) {
  .g-btn {
    min-height: 2.75rem;
  }

  .g-btn--sm {
    min-height: 2.25rem;
  }

  .g-btn--icon {
    width: 2.75rem;
  }
}

.g-btn-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
  gap: 0.5rem;
}

/* ============================================================
   8. Champs de formulaire
   ============================================================ */

.g-input,
.g-select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-md);
  background: var(--g-surface-2);
  color: var(--g-ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  transition: border-color var(--g-dur-fast) var(--g-ease), box-shadow var(--g-dur-fast) var(--g-ease);
}

.g-input::placeholder {
  color: var(--g-muted);
  font-weight: 500;
}

.g-input:focus,
.g-select:focus {
  outline: none;
  border-color: var(--g-brand);
  box-shadow: 0 0 0 3px var(--g-focus-ring);
}

.g-input:disabled,
.g-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.g-select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 55%, calc(100% - 0.7rem) 55%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  cursor: pointer;
}

.g-input--color {
  width: 3rem;
  padding: 0.25rem;
  cursor: pointer;
}

.g-input--auto,
.g-select--auto {
  width: auto;
  min-width: 11rem;
}

.g-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.g-field__label {
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g-muted);
}

.g-field__help {
  font-size: 0.8125rem;
  color: var(--g-muted);
}

.g-field__error {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--g-danger-ink);
}

.g-field--grow {
  flex: 1;
  min-width: 11rem;
}

.g-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.g-switch {
  position: relative;
  width: 3rem;
  height: 1.75rem;
  flex: none;
  padding: 0;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-3);
  cursor: pointer;
  transition: background var(--g-dur-base) var(--g-ease), border-color var(--g-dur-base) var(--g-ease);
}

.g-switch__knob {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--g-surface);
  box-shadow: var(--g-shadow-sm);
  transform: translateY(-50%);
  transition: transform var(--g-dur-base) var(--g-ease);
}

.g-switch.is-on {
  background: var(--g-brand);
  border-color: var(--g-brand);
}

.g-switch.is-on .g-switch__knob {
  transform: translate(1.25rem, -50%);
}

.g-check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-md);
  background: var(--g-surface);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.g-check input {
  accent-color: var(--g-brand);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.g-choice {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.g-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.g-choice__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-pill);
  background: var(--g-surface);
  color: var(--g-muted);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: background var(--g-dur-fast) var(--g-ease), color var(--g-dur-fast) var(--g-ease),
    border-color var(--g-dur-fast) var(--g-ease);
}

.g-choice input:checked + .g-choice__box {
  background: var(--g-brand);
  border-color: var(--g-brand);
  color: var(--g-on-brand);
}

.g-choice input:focus-visible + .g-choice__box {
  border-color: var(--g-brand);
  box-shadow: 0 0 0 3px var(--g-focus-ring);
}

/* ============================================================
   9. Puces, badges, avatars
   ============================================================ */

.g-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.625rem;
  padding: 0 0.625rem;
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-2);
  color: var(--g-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
}

.g-pill > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.g-pill--ok {
  background: var(--g-ok-soft);
  color: var(--g-ok-ink);
}

.g-pill--warn {
  background: var(--g-warn-soft);
  color: var(--g-warn-ink);
}

.g-pill--danger {
  background: var(--g-danger-soft);
  color: var(--g-danger-ink);
}

.g-pill--brand {
  background: var(--g-brand-soft);
  color: var(--g-brand-ink);
}

.g-pill--info {
  background: var(--g-info-soft);
  color: var(--g-info);
}

.g-pill--neutral {
  background: var(--g-surface-3);
  color: var(--g-muted);
}

.g-pill--live::before {
  animation: gPulse 1.8s ease-in-out infinite;
}

.g-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--g-dot-color, var(--g-muted));
  display: inline-block;
}

.g-avatar {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border-radius: var(--g-radius-md);
  background: var(--g-brand-soft);
  color: var(--g-brand-ink);
  font-family: var(--g-font-title);
  font-weight: 700;
}

.g-avatar--sm {
  width: 2rem;
  height: 2rem;
  border-radius: var(--g-radius-sm);
}

.g-avatar--ok {
  background: var(--g-ok-soft);
  color: var(--g-ok-ink);
}

.g-avatar--warn {
  background: var(--g-warn-soft);
  color: var(--g-warn-ink);
}

.g-avatar--danger {
  background: var(--g-danger-soft);
  color: var(--g-danger-ink);
}

.g-avatar--neutral {
  background: var(--g-surface-3);
  color: var(--g-muted);
}

/* ============================================================
   10. Cartes
   ============================================================ */

.g-card {
  position: relative;
  padding: 1.25rem;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-xl);
  background: var(--g-surface);
  box-shadow: var(--g-shadow-sm);
  min-width: 0;
}

@media (min-width: 640px) {
  .g-card {
    padding: 1.5rem;
  }
}

.g-card--flush {
  padding: 0;
  overflow: hidden;
}

.g-card--tint {
  background: var(--g-surface-2);
  box-shadow: none;
}

.g-card--interactive {
  transition: transform var(--g-dur-base) var(--g-ease), box-shadow var(--g-dur-base) var(--g-ease),
    border-color var(--g-dur-base) var(--g-ease);
}

.g-card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--g-shadow-md);
  border-color: var(--g-line-strong);
}

.g-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.g-card--flush .g-card__head {
  margin-bottom: 0;
  padding: 1.25rem 1.25rem 1rem;
}

.g-card__icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border-radius: var(--g-radius-md);
  background: var(--g-brand-soft);
  color: var(--g-brand-ink);
}

.g-card__titles {
  flex: 1;
  min-width: 0;
}

.g-card__title {
  font-family: var(--g-font-title);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--g-ink);
}

.g-card__sub {
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  color: var(--g-muted);
}

.g-card__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.g-card__section {
  padding: 1.25rem;
  border-top: 1px solid var(--g-line);
}

/* Dans un flux `.g-stack`, l'espacement vient déjà du parent. */
.g-stack > .g-card__head {
  margin-bottom: 0;
}

/* ============================================================
   11. Statistiques, jauges, anneau
   ============================================================ */

.g-stat {
  padding: 1rem;
  border-radius: var(--g-radius-lg);
  background: var(--g-surface-2);
  min-width: 0;
}

.g-stat__label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g-muted);
}

.g-stat__title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--g-ink);
}

.g-stat__hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--g-muted);
}

.g-stat__value {
  margin-top: 0.35rem;
  font-family: var(--g-font-title);
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--g-ink);
}

.g-stat__value-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin-top: 0.35rem;
}

.g-stat__value-row .g-stat__value {
  margin-top: 0;
}

.g-stat__period {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--g-muted);
}

.g-stat__value--sm {
  font-size: 1.375rem;
}

.g-stat__note {
  margin-top: 0.2rem;
  font-size: 0.8125rem;
  color: var(--g-muted);
}

.g-overview-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 1rem;
}

.g-overview-stats__devices {
  flex: 1 1 16rem;
  min-width: 0;
}

.g-overview-stats__heading {
  margin-bottom: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g-muted);
}

.g-overview-stats__filter {
  flex: 0 1 11.5rem;
  min-width: min(100%, 11.5rem);
  display: flex;
}

.g-stat--filter {
  flex: 1;
  border-inline-start: 3px solid var(--g-line);
}

.g-stat--ok .g-stat__value {
  color: var(--g-ok-ink);
}

.g-stat--warn .g-stat__value {
  color: var(--g-warn-ink);
}

.g-stat--danger .g-stat__value {
  color: var(--g-danger-ink);
}

@media (max-width: 540px) {
  .g-overview-stats__filter {
    flex-basis: 100%;
  }

  .g-stat--filter {
    border-inline-start: none;
    border-block-start: 3px solid var(--g-line);
  }
}

.g-gauge {
  position: relative;
  height: 10px;
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-3);
  overflow: hidden;
}

.g-gauge__fill {
  display: block;
  height: 100%;
  width: var(--g-fill, 0%);
  border-radius: var(--g-radius-pill);
  background: var(--g-ok);
  transition: width var(--g-dur-slow) var(--g-ease), background var(--g-dur-base) var(--g-ease);
}

.g-gauge--warn .g-gauge__fill {
  background: var(--g-warn);
}

.g-gauge--danger .g-gauge__fill {
  background: var(--g-danger);
}

.g-gauge--brand .g-gauge__fill {
  background: var(--g-brand);
}

.g-gauge--sm {
  height: 6px;
}

.g-meter-group {
  margin: 0;
  padding-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--g-muted);
}

.g-meter-group:not(:first-child) {
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--g-line);
}

.g-meter {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.g-meter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.g-meter__label {
  font-weight: 700;
  color: var(--g-ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-meter__value {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--g-muted);
}

.g-ring {
  position: relative;
  width: var(--g-ring-size, 10rem);
  height: var(--g-ring-size, 10rem);
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(
    var(--g-ring-color, var(--g-ok)) calc(var(--g-ring-value, 0) * 1%),
    var(--g-surface-3) 0
  );
}

.g-ring::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--g-surface);
}

.g-ring--warn {
  --g-ring-color: var(--g-warn);
}

.g-ring--danger {
  --g-ring-color: var(--g-danger);
}

.g-ring--brand {
  --g-ring-color: var(--g-brand);
}

.g-ring__inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 0.5rem;
}

.g-ring__value {
  font-family: var(--g-font-title);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--g-ink);
}

.g-ring__unit {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--g-muted);
}

.g-ring__label {
  margin-top: 0.15rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g-muted);
}

.g-hero {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  flex-wrap: wrap;
}

.g-hero__ring {
  flex: none;
  margin-inline: auto;
}

.g-hero__body {
  flex: 1;
  min-width: min(17rem, 100%);
}

/* ============================================================
   12. Listes, tableaux, onglets
   ============================================================ */

.g-list {
  display: flex;
  flex-direction: column;
}

.g-list__item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--g-line);
  min-width: 0;
}

.g-list__item:first-child {
  border-top: 0;
}

.g-list__item--top {
  align-items: flex-start;
}

.g-list__item.is-highlight {
  background: var(--g-brand-soft);
}

.g-list--boxed {
  gap: 0.5rem;
}

.g-list--boxed .g-list__item {
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-md);
  background: var(--g-surface-2);
  padding: 0.75rem 0.875rem;
}

.g-table-wrap {
  overflow-x: auto;
}

.g-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.g-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--g-line);
}

.g-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--g-line);
  color: var(--g-ink-2);
  vertical-align: middle;
}

.g-table tbody tr:last-child td {
  border-bottom: 0;
}

.g-table tbody tr:hover td {
  background: var(--g-surface-2);
}

.g-table__empty td {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--g-muted);
}

.g-table__empty:hover td {
  background: transparent;
}

@media (max-width: 767px) {
  .g-table thead {
    display: none;
  }

  .g-table tbody tr {
    display: grid;
    gap: 0.3rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--g-line);
  }

  .g-table tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0;
    border: 0;
    text-align: right;
  }

  .g-table tbody tr:hover td {
    background: transparent;
  }

  .g-table tbody td::before {
    content: attr(data-label);
    flex: none;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--g-muted);
  }

  .g-table__empty td {
    justify-content: center;
    padding: 2rem 0;
  }

  .g-table__empty td::before {
    display: none;
  }
}

.g-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-2);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.g-tabs::-webkit-scrollbar {
  display: none;
}

.g-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.125rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: var(--g-radius-pill);
  background: transparent;
  color: var(--g-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--g-dur-fast) var(--g-ease), color var(--g-dur-fast) var(--g-ease);
}

.g-tab:hover {
  color: var(--g-ink);
}

.g-tab.is-active {
  background: var(--g-surface);
  color: var(--g-brand-ink);
  box-shadow: var(--g-shadow-sm);
}

/* ============================================================
   13. États vides et squelettes
   ============================================================ */

.g-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1.5rem;
  border: 1px dashed var(--g-line-strong);
  border-radius: var(--g-radius-xl);
  background: var(--g-surface);
  text-align: center;
}

/* Version compacte, pour une liste vide à l'intérieur d'une carte. */
.g-empty--sm {
  padding: 1.5rem 1rem;
  border-radius: var(--g-radius-lg);
  background: var(--g-surface-2);
}

.g-empty--sm .g-empty__title {
  font-size: 0.9375rem;
}

.g-empty--sm .g-empty__icon svg {
  width: 2rem;
  height: 2rem;
}

.g-empty__icon {
  color: var(--g-muted);
  opacity: 0.45;
  margin-bottom: 0.25rem;
}

.g-empty__title {
  font-family: var(--g-font-title);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--g-ink);
}

.g-empty__text {
  max-width: 34ch;
  font-size: 0.8125rem;
  color: var(--g-muted);
}

.g-empty__action {
  margin-top: 0.5rem;
}

.g-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--g-radius-sm);
  background: var(--g-surface-3);
}

.g-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--g-surface) 70%, transparent),
    transparent
  );
  animation: gShimmer 1.4s infinite;
}

.g-skeleton--title {
  height: 1.25rem;
  width: 55%;
  border-radius: var(--g-radius-pill);
}

.g-skeleton--line {
  height: 0.75rem;
  width: 80%;
  border-radius: var(--g-radius-pill);
}

.g-skeleton--pill {
  height: 1.625rem;
  width: 6rem;
  border-radius: var(--g-radius-pill);
}

.g-skeleton--icon {
  height: 2.5rem;
  width: 2.5rem;
  border-radius: var(--g-radius-md);
}

.g-skeleton--block {
  height: 3rem;
  border-radius: var(--g-radius-md);
}

.g-skeleton--ring {
  height: 10rem;
  width: 10rem;
  border-radius: 50%;
}

.g-skeleton--media {
  aspect-ratio: 16 / 10;
  border-radius: 0;
}

/* ============================================================
   14. Panneau latéral, modales, notification
   ============================================================ */

.g-scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: var(--g-scrim);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: gFade var(--g-dur-base) var(--g-ease);
}

.g-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: 30rem;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--g-surface);
  border-left: 1px solid var(--g-line);
  box-shadow: var(--g-shadow-lg);
  animation: gSlideIn var(--g-dur-slow) var(--g-ease);
}

.g-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.g-stack > .g-sheet__head {
  margin-bottom: 0;
}

.g-sheet--bottom {
  top: auto;
  left: 0;
  right: 0;
  max-width: none;
  border-left: 0;
  border-top: 1px solid var(--g-line);
  border-radius: var(--g-radius-xl) var(--g-radius-xl) 0 0;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  animation: gSlideUp var(--g-dur-slow) var(--g-ease);
}

.g-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.g-modal__scrim {
  position: absolute;
  inset: 0;
  background: var(--g-scrim);
  border: 0;
  padding: 0;
  cursor: pointer;
}

.g-modal__card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding: 1.5rem;
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-xl);
  background: var(--g-surface);
  box-shadow: var(--g-shadow-lg);
  animation: gPop var(--g-dur-base) var(--g-ease);
}

.g-modal__card--wide {
  max-width: 56rem;
}

.g-code-block {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--g-radius-md);
  background: var(--g-surface-2);
  border: 1px solid var(--g-line);
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

.g-code-block--scroll {
  max-height: 18rem;
  overflow-y: auto;
  white-space: pre;
  word-break: normal;
}

.g-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 70;
  translate: -50% 0;
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0.7rem 1.1rem;
  border-radius: var(--g-radius-pill);
  background: var(--g-ink);
  color: var(--g-bg);
  font-size: 0.8125rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--g-shadow-lg);
  pointer-events: none;
  animation: gSlideUp var(--g-dur-base) var(--g-ease);
}

.g-toast--error {
  background: var(--g-danger);
  color: #ffffff;
}

@media (max-width: 959px) {
  .g-toast {
    bottom: calc(5.25rem + env(safe-area-inset-bottom));
  }
}

/* ============================================================
   15. Cartes d'appareil
   ============================================================ */

.g-device {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.g-device.is-locked {
  border-color: color-mix(in srgb, var(--g-danger) 38%, var(--g-line));
}

.g-device.is-soon {
  border-color: color-mix(in srgb, var(--g-warn) 38%, var(--g-line));
}

.g-device.is-offline {
  background: var(--g-surface);
}

.g-device.is-offline .g-device__identity {
  opacity: 0.78;
}

.g-device__head {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}

.g-device__identity {
  flex: 1;
  min-width: 0;
}

/* Un nom très long se tronque ; la puce d'état garde toujours sa place. */
.g-device__state {
  flex: none;
}

.g-device__name {
  font-family: var(--g-font-title);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--g-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-device__sub {
  margin-top: 0.1rem;
  font-size: 0.8125rem;
  color: var(--g-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Nuance de l'état (« Verrouillé par un parent », « Encore 12 min »). */
.g-device__reason {
  margin-top: -0.5rem;
  font-size: 0.8125rem;
  color: var(--g-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-device__reason:empty {
  display: none;
}

.g-device__quota {
  padding: 0.875rem 1rem;
  border-radius: var(--g-radius-lg);
  background: var(--g-surface-2);
}

.g-device__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.g-device__actions .g-device__bonus {
  grid-column: 1 / -1;
}

.g-device__actions--bonus-on .g-device__bonus {
  grid-column: auto;
}

.g-device__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  /* Cale les pieds de carte sur une même ligne quelle que soit la hauteur du contenu. */
  margin-top: auto;
  padding-top: 0.875rem;
  border-top: 1px solid var(--g-line);
}

.g-device__details {
  padding-top: 1rem;
  border-top: 1px dashed var(--g-line-strong);
  animation: gIn var(--g-dur-base) var(--g-ease);
}

.g-facts {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
}

.g-facts dt {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g-muted);
}

.g-facts dd {
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--g-ink);
  word-break: break-word;
}

.g-note {
  padding: 0.7rem 0.875rem;
  border-radius: var(--g-radius-md);
  font-size: 0.8125rem;
  line-height: 1.5;
  background: var(--g-surface-2);
  color: var(--g-ink-2);
}

.g-note--warn {
  background: var(--g-warn-soft);
  color: var(--g-warn-ink);
}

.g-note--brand {
  background: var(--g-brand-soft);
  color: var(--g-brand-ink);
}

.g-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--g-space-3);
  padding: var(--g-space-4);
  border-radius: var(--g-radius-lg);
  border: 1px solid var(--g-border);
}

.g-banner--risk {
  background: color-mix(in srgb, var(--g-danger) 10%, var(--g-surface));
  border-color: color-mix(in srgb, var(--g-danger) 35%, var(--g-border));
}

.g-banner__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--g-radius-md);
  background: var(--g-danger-soft);
  color: var(--g-danger-ink);
  flex-shrink: 0;
}

.g-banner__body {
  flex: 1 1 12rem;
  min-width: 0;
}

.g-banner__title {
  margin: 0 0 var(--g-space-1);
  font-family: var(--g-font-display);
  font-weight: 600;
  color: var(--g-danger-ink);
}

.g-banner__actions {
  flex: 0 0 auto;
  align-self: center;
}

.g-inline-risk {
  display: inline-flex;
  align-items: center;
  gap: var(--g-space-1);
}

.g-table tr.is-risk-ack {
  opacity: 0.85;
}

.g-table__actions {
  white-space: nowrap;
  text-align: right;
}

.g-table tr.is-risk {
  background: color-mix(in srgb, var(--g-danger) 8%, transparent);
}

.g-table tr.is-risk:hover {
  background: color-mix(in srgb, var(--g-danger) 14%, transparent);
}

.g-risk-domain {
  color: var(--g-danger-ink);
  font-weight: 600;
}

.g-pill--xs {
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

/* ============================================================
   16. Galerie de captures
   ============================================================ */

.g-shot {
  overflow: hidden;
  padding: 0;
}

.g-shot__preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: var(--g-surface-2);
  cursor: zoom-in;
}

.g-shot__preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--g-dur-base) var(--g-ease), transform var(--g-dur-slow) var(--g-ease);
}

.g-shot__preview:hover img {
  transform: scale(1.03);
}

.g-shot__preview.is-loaded img {
  opacity: 1;
}

.g-shot__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--g-muted);
  text-align: center;
}

.g-shot__preview.is-loaded .g-shot__loading {
  display: none;
}

.g-shot__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
}

.g-shot__viewer {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--g-radius-md);
  background: var(--g-surface-2);
}

/* ============================================================
   17. Mouvement
   ============================================================ */

.g-in {
  animation: gIn var(--g-dur-base) var(--g-ease) both;
}

@keyframes gIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes gFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes gPop {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes gSlideIn {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes gSlideUp {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes gPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes gShimmer {
  100% {
    transform: translateX(100%);
  }
}

/* ——— Téléphone : onglets + conversation ——— */
.g-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;
}

.g-comm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--g-space-1);
  padding: var(--g-space-1);
  border-radius: var(--g-radius-lg);
  background: var(--g-surface-2);
  border: 1px solid var(--g-border);
}

.g-comm-tabs__item {
  display: inline-flex;
  align-items: center;
  gap: var(--g-space-2);
  flex: 1 1 auto;
  justify-content: center;
  min-height: 2.5rem;
  padding: var(--g-space-2) var(--g-space-3);
  border: 0;
  border-radius: var(--g-radius-md);
  background: transparent;
  color: var(--g-muted);
  font: inherit;
  font-size: var(--g-text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.g-comm-tabs__item:hover {
  color: var(--g-ink);
  background: color-mix(in srgb, var(--g-brand) 6%, transparent);
}

.g-comm-tabs__item.is-active {
  color: var(--g-brand-ink);
  background: var(--g-surface);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--g-ink) 8%, transparent);
}

.g-comm-panel__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--g-space-3);
  padding: var(--g-space-4);
  border-bottom: 1px solid var(--g-border);
  background: var(--g-surface);
}

.g-comm-panel__contact {
  display: flex;
  align-items: center;
  gap: var(--g-space-3);
  flex: 1 1 12rem;
  min-width: 0;
}

.g-comm-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--g-radius-pill);
  background: color-mix(in srgb, var(--g-brand) 16%, var(--g-surface));
  color: var(--g-brand-ink);
  font-family: var(--g-font-display);
  font-weight: 700;
  font-size: var(--g-text-sm);
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--g-brand) 24%, var(--g-border));
}

.g-comm-avatar--sm {
  width: 2.125rem;
  height: 2.125rem;
  font-size: 0.68rem;
}

.g-comm-contact-cell {
  display: flex;
  align-items: center;
  gap: var(--g-space-3);
  min-width: 0;
}

.g-comm-contact-cell__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.g-comm-panel__identity {
  min-width: 0;
}

.g-comm-panel__name {
  margin: 0;
  font-family: var(--g-font-display);
  font-weight: 600;
  font-size: var(--g-text-base);
  line-height: 1.25;
}

.g-comm-panel__meta {
  margin: var(--g-space-1) 0 0;
  font-size: var(--g-text-xs);
  color: var(--g-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.g-comm-panel__dot {
  opacity: 0.55;
}

.g-comm-panel__hint {
  margin: 0;
  flex: 1 1 12rem;
}

.g-comm-panel__switch {
  flex: 0 1 14rem;
  min-width: 10rem;
}

.g-comm-panel__select {
  width: 100%;
}

.g-comm-chat {
  display: flex;
  flex-direction: column;
  min-height: min(62vh, 520px);
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, color-mix(in srgb, var(--g-brand) 5%, transparent), transparent 55%),
    color-mix(in srgb, var(--g-surface-2) 65%, var(--g-surface));
}

.g-comm-chat__empty {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: var(--g-space-6);
}

.g-comm-chat__stats {
  padding: var(--g-space-2) var(--g-space-4);
  text-align: center;
  border-bottom: 1px solid color-mix(in srgb, var(--g-border) 70%, transparent);
  background: color-mix(in srgb, var(--g-surface) 55%, transparent);
}

/* Fil de conversation (SMS + appels) */
.g-thread {
  display: flex;
  flex-direction: column;
  gap: var(--g-space-2);
  flex: 1;
  max-height: min(58vh, 480px);
  padding: var(--g-space-4) var(--g-space-3);
  overflow-y: auto;
}

.g-thread__day {
  display: flex;
  justify-content: center;
  margin: var(--g-space-2) 0 var(--g-space-1);
}

.g-thread__day span {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: var(--g-radius-pill);
  background: color-mix(in srgb, var(--g-surface) 88%, var(--g-brand));
  border: 1px solid var(--g-border);
  font-size: var(--g-text-xs);
  font-weight: 600;
  color: var(--g-muted);
  text-transform: capitalize;
}

.g-thread__msg {
  display: flex;
  max-width: min(78%, 28rem);
  margin-bottom: var(--g-space-1);
}

.g-thread__msg.is-in {
  align-self: flex-start;
}

.g-thread__msg.is-out {
  align-self: flex-end;
}

.g-thread__bubble {
  padding: var(--g-space-3) var(--g-space-4);
  border-radius: 1.1rem;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--g-ink) 6%, transparent);
  border: 1px solid var(--g-border);
  background: var(--g-surface);
}

.g-thread__msg.is-in .g-thread__bubble {
  border-bottom-left-radius: 0.35rem;
  background: var(--g-surface);
}

.g-thread__msg.is-out .g-thread__bubble {
  border-bottom-right-radius: 0.35rem;
  background: color-mix(in srgb, var(--g-brand) 14%, var(--g-surface));
  border-color: color-mix(in srgb, var(--g-brand) 32%, var(--g-border));
}

.g-thread__msg.is-draft .g-thread__bubble {
  border-style: dashed;
  opacity: 0.88;
}

.g-thread__text {
  margin: 0;
  font-size: var(--g-text-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.g-thread__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--g-space-2);
  margin-top: var(--g-space-2);
  font-size: 0.68rem;
  color: var(--g-muted);
}

.g-thread__tag {
  padding: 0.05rem 0.4rem;
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.g-thread__call {
  display: flex;
  justify-content: center;
  margin: var(--g-space-2) 0;
}

.g-thread__call-card {
  display: inline-flex;
  align-items: center;
  gap: var(--g-space-3);
  padding: var(--g-space-2) var(--g-space-4);
  border-radius: var(--g-radius-pill);
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--g-ink) 5%, transparent);
  max-width: 100%;
}

.g-thread__call.is-in .g-thread__call-icon {
  color: var(--g-ok-ink);
  background: var(--g-ok-soft);
}

.g-thread__call.is-out .g-thread__call-icon {
  color: var(--g-brand-ink);
  background: var(--g-brand-soft);
}

.g-thread__call.is-warn .g-thread__call-icon {
  color: var(--g-warn-ink);
  background: var(--g-warn-soft);
}

.g-thread__call-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--g-radius-pill);
  flex-shrink: 0;
}

.g-thread__call-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.g-thread__call-label {
  font-size: var(--g-text-sm);
  font-weight: 600;
}

.g-thread__call-meta {
  font-size: var(--g-text-xs);
  color: var(--g-muted);
}

.g-thread__event {
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--g-space-2);
  padding: var(--g-space-2) var(--g-space-3);
  border-radius: var(--g-radius-pill);
  background: var(--g-surface-2);
  border: 1px dashed var(--g-border);
}

.g-link.g-link--block {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: inherit;
  color: inherit;
}

.g-text-left {
  text-align: left;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   PWA — Adaptations mobiles (standalone + petits écrans)
   ============================================================ */

/* Topbar allégée sur mobile : cache le subtitle de marque, réduit l'espace */
@media (max-width: 959px) {
  .g-brand__tag {
    display: none;
  }

  .g-topbar {
    padding: 0.5rem 1rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top));
    gap: 0.625rem;
  }

  .g-brand__mark {
    width: 2rem;
    height: 2rem;
    border-radius: var(--g-radius-sm);
  }

  .g-brand__name {
    font-size: 1.0625rem;
  }

  /* Page title plus compact */
  .g-page-head {
    margin-bottom: 1rem;
  }

  .g-page-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  /* Grille d'appareils : 1 colonne forcée sous 480px */
  .g-grid--devices {
    grid-template-columns: 1fr;
  }

  /* Actions device : 1 colonne sur téléphone pour des gros boutons */
  .g-device__actions {
    grid-template-columns: 1fr;
  }

  .g-device__actions .g-device__bonus {
    grid-column: auto;
  }

  /* Boutons plus grands au pouce */
  .g-device__actions .g-btn {
    min-height: 3rem;
    font-size: 0.9375rem;
  }

  /* Quota card : padding réduit */
  .g-device__quota {
    padding: 0.75rem;
  }

  /* Sections de formulaire : colonnes → lignes */
  .g-grid--2,
  .g-grid--wide {
    grid-template-columns: 1fr;
  }

  /* Stats : 2 colonnes max sur mobile */
  .g-grid--3,
  .g-grid--4 {
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  }

  /* Cards : padding réduit */
  .g-card {
    padding: 1rem;
  }

  /* Inputs et selects plus grands au toucher */
  .g-input,
  .g-select {
    min-height: 3rem;
    font-size: 1rem;
  }

  /* Listes : items plus hauts */
  .g-list__item {
    min-height: 3rem;
    padding: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .g-list__item .g-fill {
    width: 100%;
  }

  /* Hero quota : layout vertical sur mobile */
  .g-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .g-hero__ring {
    align-self: center;
  }

  /* Bottom sheet : occupe + d'espace */
  .g-sheet--bottom {
    max-height: 85vh;
  }

  /* Tabs : scrollables sur mobile */
  .g-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .g-tabs::-webkit-scrollbar { display: none; }

  /* Form rows : empilés */
  .g-form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .g-form-row .g-btn[type="submit"] {
    width: 100%;
    min-height: 3rem;
  }
}

/* Mode standalone (installée en PWA) : padding top safe area sur la topbar */
@media (display-mode: standalone) {
  .g-topbar {
    padding-top: calc(0.5rem + env(safe-area-inset-top));
  }

  /* Le shell prend toute la hauteur de l'écran */
  .g-shell {
    min-height: 100dvh;
  }

  /* Pas de scroll horizontal accidentel */
  body {
    overscroll-behavior: none;
  }
}

/* Graphique historique quota */
.qh-chart {
  display: flex;
  align-items: flex-end;
  gap: .25rem;
  height: 120px;
  padding: .5rem 0 2.5rem;
  overflow-x: auto;
}
.qh-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 2rem;
  flex: 1;
  height: 100%;
  position: relative;
  cursor: default;
}
.qh-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: opacity .15s;
}
.qh-bar-wrap:hover .qh-bar { opacity: .75; }
.qh-val {
  position: absolute;
  bottom: 1.4rem;
  font-size: .6rem;
  color: var(--g-muted);
  white-space: nowrap;
}
.qh-val--over { color: var(--g-danger); font-weight: 600; }
.qh-day {
  position: absolute;
  bottom: 0;
  font-size: .55rem;
  color: var(--g-muted);
  white-space: nowrap;
  transform: rotate(-45deg) translateX(-4px);
  transform-origin: top right;
}

/* Bannière d'installation PWA */
.g-pwa-banner {
  position: fixed;
  bottom: calc(4.5rem + env(safe-area-inset-bottom));
  left: 1rem;
  right: 1rem;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--g-surface);
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius-lg);
  box-shadow: var(--g-shadow-lg);
  animation: gSlideUp var(--g-dur-slow) var(--g-ease);
}

@keyframes gSlideUp {
  from { transform: translateY(120%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.g-pwa-banner__icon {
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border-radius: var(--g-radius-sm);
  background: var(--g-brand);
  display: grid;
  place-items: center;
  color: var(--g-on-brand);
}

.g-pwa-banner__body {
  flex: 1;
  min-width: 0;
}

.g-pwa-banner__title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--g-ink);
}

.g-pwa-banner__sub {
  font-size: 0.75rem;
  color: var(--g-muted);
  margin-top: 0.1rem;
}

.g-pwa-banner__actions {
  display: flex;
  gap: 0.375rem;
  flex: none;
}

/* Sur desktop la bannière ne s'affiche pas */
@media (min-width: 960px) {
  .g-pwa-banner {
    display: none;
  }
}
