/* =============================================================================
   ARTISCODE ERP — COMPOSANTS
   Boutons, cartes, formulaires, badges, statistiques, onglets, alertes…
   ========================================================================== */

/* -----------------------------------------------------------------------------
   BOUTONS
   -------------------------------------------------------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:active {
  transform: scale(0.975);
  transition-duration: var(--dur-instant);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn i {
  font-size: 0.92em;
  transition: transform var(--dur-base) var(--ease-spring);
}

/* Primaire — dégradé de marque + halo */
.btn-primary {
  background: var(--gradient-brand);
  background-size: 160% 160%;
  color: var(--fg-onbrand);
  box-shadow: var(--shadow-brand), var(--shadow-inner);
}

.btn-primary:hover {
  background-position: 100% 50%;
  color: var(--fg-onbrand);
  box-shadow: 0 14px 30px rgba(255, 104, 1, 0.38), var(--shadow-inner);
  transform: translateY(-2px);
}

.btn-primary:hover i {
  transform: translateX(2px);
}

/* Accent — navy plein */
.btn-accent {
  background: var(--gradient-navy);
  color: var(--fg-ondark);
  box-shadow: var(--shadow-md);
}

.btn-accent:hover {
  color: var(--fg-ondark);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* Secondaire — surface neutre */
.btn-secondary {
  border-color: var(--border);
  background: var(--bg-surface);
  color: var(--fg-strong);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-2);
  color: var(--fg-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Fantôme */
.btn-ghost {
  color: var(--fg-muted);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--fg-strong);
}

/* Contour de marque */
.btn-outline {
  border-color: var(--brand-ring);
  color: var(--brand);
}

.btn-outline:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-hover);
}

/* Sémantiques */
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.26);
}

.btn-danger:hover {
  background: var(--c-red-700);
  color: #fff;
  transform: translateY(-2px);
}

.btn-danger-soft {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger-fg);
}

.btn-danger-soft:hover {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.24);
}

.btn-success:hover {
  color: #fff;
  transform: translateY(-2px);
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.24);
}

.btn-warning:hover {
  color: #fff;
  transform: translateY(-2px);
}

.btn-info {
  background: var(--info);
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24);
}

.btn-info:hover {
  color: #fff;
  transform: translateY(-2px);
}

/* Tailles */
.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-xs);
  font-size: var(--text-sm);
}

.btn-lg {
  min-height: 48px;
  padding: 0 var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-lg);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-lg { width: 48px; }

/* Groupe de boutons */
.btn-group {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Bouton en cours de traitement */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 1em;
  height: 1em;
  border: 2px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 620ms linear infinite;
}

.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after,
.btn-outline.is-loading::after {
  border-color: var(--fg-muted);
  border-right-color: transparent;
}

/* Actions compactes dans les tableaux */
.action-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.action-btn:hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.action-btn--danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.action-btn--success:hover {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

/* -----------------------------------------------------------------------------
   CARTES ET PANNEAUX
   -------------------------------------------------------------------------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.card--glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-color: var(--glass-border);
}

.card--flush {
  overflow: hidden;
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.card__title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-snug);
}

.card__title i {
  color: var(--brand);
}

.card__subtitle {
  margin-top: var(--space-1);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.card__body {
  flex: 1;
  padding: var(--space-5);
}

.card__body--flush {
  padding: 0;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Liseré de marque en haut de carte */
.card--accent::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--gradient-brand);
}

/* -----------------------------------------------------------------------------
   CARTES DE STATISTIQUE
   -------------------------------------------------------------------------- */

.stat {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  isolation: isolate;
  transition:
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

/* Halo coloré qui se révèle au survol */
.stat::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -30%;
  z-index: -1;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--stat-tint, var(--brand)), transparent 68%);
  opacity: 0.1;
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

.stat:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.stat:hover::before {
  opacity: 0.22;
  transform: scale(1.18);
}

.stat__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.stat__label {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 550;
}

.stat__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--stat-tint, var(--brand)) 12%, transparent);
  color: var(--stat-tint, var(--brand));
  font-size: 1rem;
  transition: transform var(--dur-base) var(--ease-spring);
}

.stat:hover .stat__icon {
  transform: scale(1.12) rotate(-6deg);
}

.stat__value {
  display: block;
  margin-top: var(--space-4);
  color: var(--fg-strong);
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: var(--tracking-tight);
}

.stat__value .unit {
  color: var(--fg-muted);
  font-size: var(--text-lg);
  font-weight: 600;
}

.stat__foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--fg-subtle);
  font-size: var(--text-xs);
}

/* Variation (delta) */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.42rem;
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: 700;
}

.trend--up   { background: var(--success-soft); color: var(--success-fg); }
.trend--down { background: var(--danger-soft);  color: var(--danger-fg); }
.trend--flat { background: var(--bg-surface-3); color: var(--fg-muted); }

/* Teintes de statistiques */
.stat--brand   { --stat-tint: var(--brand); }
.stat--navy    { --stat-tint: var(--c-navy-500); }
.stat--success { --stat-tint: var(--c-green-500); }
.stat--warning { --stat-tint: var(--c-amber-500); }
.stat--danger  { --stat-tint: var(--c-red-500); }
.stat--info    { --stat-tint: var(--c-blue-500); }
.stat--violet  { --stat-tint: var(--c-violet-500); }
.stat--teal    { --stat-tint: var(--c-teal-500); }

/* -----------------------------------------------------------------------------
   BADGES ET PASTILLES
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
}

.badge--neutral { background: var(--bg-surface-3); color: var(--fg-muted); }
.badge--brand   { background: var(--brand-soft);   color: var(--brand-soft-fg); }
.badge--success { background: var(--success-soft); color: var(--success-fg); }
.badge--warning { background: var(--warning-soft); color: var(--warning-fg); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-fg); }
.badge--info    { background: var(--info-soft);    color: var(--info-fg); }

.badge--outline {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--fg-muted);
}

/* Pastille de statut avec point animé */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.status__dot {
  position: relative;
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}

.status--live .status__dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0;
  animation: pulse-glow 2s var(--ease-in-out) infinite;
}

.status--success { color: var(--success); }
.status--warning { color: var(--warning); }
.status--danger  { color: var(--danger); }
.status--info    { color: var(--info); }
.status--neutral { color: var(--fg-subtle); }

/* -----------------------------------------------------------------------------
   AVATARS
   -------------------------------------------------------------------------- */

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--gradient-navy);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--brand { background: var(--gradient-brand); }
.avatar--sm { width: 30px; height: 30px; font-size: var(--text-2xs); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar--xl { width: 84px; height: 84px; font-size: var(--text-2xl); }

.avatar--ring {
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 2px var(--brand-ring);
}

.avatar__status {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
  background: var(--success);
}

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar-stack .avatar + .avatar {
  margin-left: -10px;
  border: 2px solid var(--bg-surface);
  transition: transform var(--dur-fast) var(--ease-out);
}

.avatar-stack:hover .avatar {
  transform: translateY(-2px);
}

/* Cellule identité (avatar + texte) */
.identity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.identity__name {
  display: block;
  overflow: hidden;
  color: var(--fg-strong);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.identity__name:hover {
  color: var(--brand);
}

.identity__meta {
  display: block;
  overflow: hidden;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   FORMULAIRES
   -------------------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4) var(--space-5);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-strong);
  font-size: var(--text-sm);
  font-weight: 600;
}

.label .req {
  color: var(--danger);
}

.hint {
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.error-text {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: 550;
}

/* Contrôles */
.input,
.select,
.textarea,
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='search'],
input[type='tel'],
input[type='url'],
input[type='date'],
input[type='time'],
input[type='datetime-local'],
input[type='month'],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--fg-strong);
  font-family: inherit;
  font-size: var(--text-md);
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

textarea,
.textarea {
  min-height: 110px;
  line-height: var(--leading-base);
  resize: vertical;
}

select,
.select {
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

::placeholder {
  color: var(--fg-subtle);
  opacity: 1;
}

.input:hover,
input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  outline: none;
}

.input:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-inset);
  color: var(--fg-subtle);
  cursor: not-allowed;
}

.field.has-error .input,
.field.has-error input,
.field.has-error select,
.field.has-error textarea,
.input.is-invalid {
  border-color: var(--danger);
  animation: shake 400ms var(--ease-out);
}

.field.has-error .input:focus,
.field.has-error input:focus,
.field.has-error select:focus,
.field.has-error textarea:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

/* Champ avec icône */
.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-affix > i,
.input-affix > .affix {
  position: absolute;
  left: var(--space-3);
  color: var(--fg-subtle);
  font-size: 0.9rem;
  pointer-events: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.input-affix > input {
  padding-left: 2.4rem;
}

.input-affix:focus-within > i,
.input-affix:focus-within > .affix {
  color: var(--brand);
}

.input-affix--end > i {
  left: auto;
  right: var(--space-3);
}

.input-affix--end > input {
  padding-left: var(--space-3);
  padding-right: 2.4rem;
}

/* Bouton révélant le mot de passe */
.input-reveal {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  color: var(--fg-subtle);
  pointer-events: auto;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.input-reveal:hover {
  background: var(--bg-hover);
  color: var(--fg-strong);
}

/* Cases et boutons radio */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.check input[type='checkbox'],
.check input[type='radio'],
input[type='checkbox'],
input[type='radio'] {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex-shrink: 0;
  margin-top: 1px;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-spring);
}

input[type='radio'] {
  border-radius: 50%;
}

input[type='checkbox']:checked,
input[type='radio']:checked {
  border-color: var(--brand);
  background: var(--brand);
  transform: scale(1.06);
}

input[type='checkbox']:checked {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 72%;
  background-position: center;
  background-repeat: no-repeat;
}

input[type='radio']:checked {
  box-shadow: inset 0 0 0 3.5px var(--bg-surface);
}

.check__text {
  font-size: var(--text-md);
}

.check__text small {
  display: block;
  color: var(--fg-muted);
}

/* Listes de cases / boutons radio rendues par Django (<ul><li><label>) */
.field ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
}

.field ul li label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.field ul li label:hover {
  background: var(--bg-hover);
}

.field select[multiple] {
  min-height: 160px;
  padding: var(--space-2);
  background-image: none;
}

.field select[multiple] option {
  padding: var(--space-2);
  border-radius: var(--radius-xs);
}

/* Interrupteur */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background-color var(--dur-base) var(--ease-out);
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-spring);
}

.switch input:checked + .switch__track {
  background: var(--brand);
}

.switch input:checked + .switch__track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* Zone de dépôt de fichier */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-5);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  color: var(--fg-muted);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.005);
}

.dropzone i {
  font-size: 1.6rem;
  color: var(--brand);
}

/* Séparateur de section de formulaire */
.form-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  color: var(--fg-strong);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
}

.form-section::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* -----------------------------------------------------------------------------
   BARRE DE FILTRES
   -------------------------------------------------------------------------- */

.filters {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--shadow-sm);
}

.filters .field {
  flex: 1 1 190px;
  min-width: 170px;
}

.filters .field--search {
  flex: 2 1 280px;
}

.filters__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .filters .field,
  .filters .field--search,
  .filters__actions {
    width: 100%;
    flex: 1 1 auto;
  }

  .filters__actions .btn {
    flex: 1;
  }
}

/* -----------------------------------------------------------------------------
   ONGLETS ET SEGMENTS
   -------------------------------------------------------------------------- */

.tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  padding: var(--space-3) var(--space-4);
  color: var(--fg-muted);
  font-size: var(--text-md);
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}

.tab::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px 0;
  height: 2px;
  border-radius: var(--radius-full) var(--radius-full) 0 0;
  background: var(--gradient-brand);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--dur-base) var(--ease-out);
}

.tab:hover {
  color: var(--fg-strong);
}

.tab.is-active {
  color: var(--brand);
}

.tab.is-active::after {
  transform: scaleX(1);
}

.tab__count {
  margin-left: var(--space-2);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface-3);
  color: var(--fg-muted);
  font-size: var(--text-2xs);
  font-weight: 700;
}

.tab.is-active .tab__count {
  background: var(--brand-soft);
  color: var(--brand-soft-fg);
}

/* Contrôle segmenté */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
}

.segmented button {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-xs);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.segmented button:hover {
  color: var(--fg-strong);
}

.segmented button.is-active {
  background: var(--bg-surface);
  color: var(--fg-strong);
  box-shadow: var(--shadow-xs);
}

/* -----------------------------------------------------------------------------
   ALERTES ET MESSAGES
   -------------------------------------------------------------------------- */

.alert {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  padding-left: var(--space-5);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.alert::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--alert-tint, var(--info));
}

.alert__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--alert-tint, var(--info)) 14%, transparent);
  color: var(--alert-tint, var(--info));
  font-size: 0.8rem;
}

.alert__body {
  flex: 1;
  min-width: 0;
  font-size: var(--text-md);
}

.alert__title {
  color: var(--fg-strong);
  font-weight: 650;
}

.alert__close {
  flex-shrink: 0;
  padding: var(--space-1);
  color: var(--fg-subtle);
  transition: color var(--dur-fast) var(--ease-out);
}

.alert__close:hover {
  color: var(--fg-strong);
}

.alert--success { --alert-tint: var(--success); }
.alert--warning { --alert-tint: var(--warning); }
.alert--danger,
.alert--error   { --alert-tint: var(--danger); }
.alert--info    { --alert-tint: var(--info); }

/* -----------------------------------------------------------------------------
   ÉTATS VIDES
   -------------------------------------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.empty__art {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-2xl);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1.7rem;
  animation: float-y 5s var(--ease-in-out) infinite;
}

.empty__art::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 1px dashed var(--brand-ring);
  border-radius: inherit;
  animation: spin 22s linear infinite;
}

.empty__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
}

.empty__text {
  max-width: 46ch;
  color: var(--fg-muted);
  font-size: var(--text-md);
}

/* -----------------------------------------------------------------------------
   PROGRESSION
   -------------------------------------------------------------------------- */

.progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--bg-surface-3);
}

.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-brand);
  transform-origin: left center;
  transition: width var(--dur-slower) var(--ease-out);
}

.progress--success .progress__bar { background: var(--success); }
.progress--warning .progress__bar { background: var(--warning); }
.progress--danger  .progress__bar { background: var(--danger); }

/* Jauge circulaire */
.ring {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--ring-size, 92px);
  height: var(--ring-size, 92px);
}

.ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring__track {
  fill: none;
  stroke: var(--bg-surface-3);
  stroke-width: 8;
}

.ring__fill {
  fill: none;
  stroke: var(--brand);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-slower) var(--ease-out);
}

.ring__value {
  position: relative;
  color: var(--fg-strong);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
}

/* -----------------------------------------------------------------------------
   LISTES ET CHRONOLOGIE
   -------------------------------------------------------------------------- */

.list {
  display: flex;
  flex-direction: column;
}

.list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.list__item:last-child {
  border-bottom: 0;
}

.list__item:hover {
  background: var(--bg-hover);
}

.list__content {
  flex: 1;
  min-width: 0;
}

.list__title {
  display: block;
  overflow: hidden;
  color: var(--fg-strong);
  font-size: var(--text-md);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.list__meta .sep {
  color: var(--fg-subtle);
}

/* Chronologie verticale */
.timeline {
  position: relative;
  padding-left: var(--space-6);
}

.timeline::before {
  content: '';
  position: absolute;
  inset: var(--space-2) auto var(--space-2) 6px;
  width: 2px;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, var(--brand), var(--border) 70%);
}

.timeline__item {
  position: relative;
  padding: 0 0 var(--space-5) var(--space-2);
}

.timeline__item:last-child {
  padding-bottom: 0;
}

.timeline__dot {
  position: absolute;
  top: 4px;
  left: calc(var(--space-6) * -1 + 1px);
  width: 12px;
  height: 12px;
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-ring);
}

.timeline__time {
  color: var(--fg-subtle);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.timeline__title {
  margin-top: 2px;
  color: var(--fg-strong);
  font-weight: 650;
}

.timeline__text {
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

/* Paires clé/valeur — pages de détail */
.datalist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4) var(--space-6);
}

.datalist__item {
  min-width: 0;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.datalist__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.datalist__value {
  margin-top: var(--space-2);
  color: var(--fg-strong);
  font-size: var(--text-md);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Actions rapides en grille */
.quick-action {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--fg);
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.quick-action:hover {
  border-color: var(--brand-ring);
  color: var(--fg-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.quick-action__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand);
  transition: transform var(--dur-base) var(--ease-spring);
}

.quick-action:hover .quick-action__icon {
  transform: scale(1.1) rotate(-5deg);
}

.quick-action__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-md);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-action__arrow {
  color: var(--fg-subtle);
  transition: transform var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}

.quick-action:hover .quick-action__arrow {
  color: var(--brand);
  transform: translateX(4px);
}

/* -----------------------------------------------------------------------------
   GRAPHIQUES
   -------------------------------------------------------------------------- */

.chart-frame {
  position: relative;
  width: 100%;
  height: var(--chart-h, 300px);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 550;
}

.chart-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--swatch, var(--brand));
}

/* -----------------------------------------------------------------------------
   DIVERS
   -------------------------------------------------------------------------- */

.divider {
  height: 1px;
  margin: var(--space-4) 0;
  background: var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-surface-2);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.chip__remove {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--fg-subtle);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.chip__remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--fg-subtle);
  font-size: var(--text-2xs);
}

/* Code / référence monospace */
.ref {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-xs);
  background: var(--bg-surface-3);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Montant financier */
.amount {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: var(--tracking-snug);
}

.amount--in  { color: var(--success); }
.amount--out { color: var(--danger); }

.amount__currency {
  color: var(--fg-subtle);
  font-size: 0.78em;
  font-weight: 600;
}
