/* ================================================================
   KLAVIA — Design Tokens + Component Library v2.0
   Source de vérité brand, typo, couleurs, composants.
   Chargé en premier sur toutes les pages.
   ================================================================ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@700;800;900&family=Inter:wght@400;500;600;700;800&display=swap');

/* ================================================================
   PHASE 1 — Design Tokens
   ================================================================ */

:root {
  /* ── Brand Colors ── */
  --primary:            #291155;
  --primary-dark:       #1a0a3d;
  --primary-mid:        #5B21B6;
  --primary-light:      #C4B5FD;
  --primary-lighter:    #ede9fe;
  --secondary:          #4C1D95;
  --accent:             #7C3AED;

  /* ── Surface / Background ── */
  --bg:                 #FAFAF9;
  --bg-soft:            #FFFFFF;
  --surface:            #ffffff;
  --surface-2:          #f8f7ff;
  --surface-3:          #ede9fe;

  /* ── Text ── */
  --text-primary:       #1e1040;
  --text:               #1e1040;
  --text-secondary:     #4a3f70;
  --text-light:         #64748b;
  --text-muted:         #94a3b8;
  --text-inverse:       #ffffff;

  /* ── Ink aliases (sémantiques, lisibles, sans historique de nommage) ── */
  --ink:                #1e1040;
  --ink-secondary:      #4a3f70;
  --ink-muted:          #94a3b8;

  /* ── Status Colors ── */
  --success:            #10b981;
  --success-bg:         #d1fae5;
  --success-text:       #065f46;
  --warning:            #f59e0b;
  --warning-bg:         #fef3c7;
  --warning-text:       #92400e;
  --danger:             #ef4444;
  --danger-bg:          #fee2e2;
  --danger-text:        #991b1b;
  --info:               #3b82f6;
  --info-bg:            #dbeafe;
  --info-text:          #1e40af;

  /* ── Borders ── */
  --border:             #ddd6fe;
  --border-soft:        #e9e4fb;
  --border-focus:       #7C3AED;

  /* ── Shadows ── */
  --shadow-xs:          0 1px 3px rgba(46, 16, 101, .06);
  --shadow-sm:          0 2px 8px rgba(46, 16, 101, .08);
  --shadow:             0 4px 16px rgba(46, 16, 101, .10);
  --shadow-md:          0 8px 24px rgba(46, 16, 101, .12);
  --shadow-lg:          0 16px 48px rgba(46, 16, 101, .16);
  --shadow-xl:          0 24px 64px rgba(46, 16, 101, .20);

  /* ── Border Radius ── */
  --radius-xs:          4px;
  --radius-sm:          6px;
  --radius:             10px;
  --radius-md:          12px;
  --radius-lg:          16px;
  --radius-xl:          20px;
  --radius-2xl:         24px;
  --radius-full:        9999px;

  /* ── Typography ── */
  --font-body:          'Inter', system-ui, sans-serif;
  /* D3 — Outfit scope : h1, h2, h3, KPI numériques (.kpi-value), wordmark uniquement.
     Tout le reste de l'interface utilise --font-body (Inter). */
  --font-title:         'Outfit', sans-serif;
  --font-mono:          'Fira Code', 'Cascadia Code', monospace;

  /* ── Spacing ── */
  --space-1:            4px;
  --space-2:            8px;
  --space-3:            12px;
  --space-4:            16px;
  --space-5:            20px;
  --space-6:            24px;
  --space-8:            32px;
  --space-10:           40px;
  --space-12:           48px;
  --space-7:            28px;
  --space-9:            36px;
  --space-14:           56px;
  --space-16:           64px;

  /* ── Semantic spacing ── */
  --padding-input:      10px 14px;
  --padding-btn:        9px 18px;
  --padding-btn-sm:     6px 12px;
  --padding-btn-lg:     12px 24px;

  /* ── Typographic Scale (11 niveaux — ligne-hauteur + espacement inclus) ── */
  /* USAGE RESTREINT --text-micro : timestamps, captions, IDs internes, références
     techniques. JAMAIS body text, label formulaire, message d'état. Limite WCAG. */
  --text-micro:         10px;  --lh-micro:   1.5;  --ls-micro:   0.04em;
  --text-xs:            11px;  --lh-xs:      1.5;  --ls-xs:      0.04em;
  --text-sm:            12px;  --lh-sm:      1.5;  --ls-sm:      0.02em;
  /* --text-sm2 : gap 13px comblé (2382 occ.) entre --text-sm et --text-base */
  --text-sm2:           13px;  --lh-sm2:     1.5;  --ls-sm2:     0.01em;
  --text-base:          14px;  --lh-base:    1.6;  --ls-base:    0;
  --text-md:            15px;  --lh-md:      1.5;  --ls-md:     -0.01em;
  --text-lg:            17px;  --lh-lg:      1.45; --ls-lg:     -0.01em;
  --text-xl:            20px;  --lh-xl:      1.35; --ls-xl:     -0.02em;
  --text-2xl:           24px;  --lh-2xl:     1.25; --ls-2xl:    -0.02em;
  /* --text-display : grands KPI Outfit (font-title), titres hero — entre 2xl et 3xl */
  --text-display:       28px;  --lh-display: 1.15; --ls-display: -0.03em;
  --text-3xl:           30px;  --lh-3xl:     1.15; --ls-3xl:    -0.03em;

  /* ── Font Weights ── */
  --fw-regular:         400;
  --fw-medium:          500;
  --fw-semibold:        600;
  --fw-bold:            700;
  --fw-extrabold:       800;

  /* ── Focus Ring ── */
  --focus-ring:         0 0 0 3px rgba(41, 17, 85, .35);
  --focus-ring-offset:  2px;

  /* ── Layout ── */
  --sidebar-width:      260px;
  --sidebar-collapsed-w:64px;
  --topbar-h:           60px;
  --z-base:             1;
  --z-dropdown:         50;
  --z-sidebar:          100;
  --z-topbar:           200;
  --z-modal:            300;
  --z-toast:            400;
  --z-tooltip:          9999;
  --z-skip:             99999;

  /* ── Transitions ── */
  --transition-fast:    100ms ease;
  --transition:         150ms ease;
  --transition-slow:    200ms ease;

  /* ── Compat aliases (backward compat) ── */
  --white:              #ffffff;
  --shadow-card:        var(--shadow-sm);
  --radius-card:        var(--radius-md);
}

/* ================================================================
   PHASE 2 — Core Components
   ================================================================ */

/* ── Reset minimal ── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Base body ── */
body {
  font-family: var(--font-body);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ──────────────────────────────────────
   BUTTONS — v2.3
   ────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--padding-btn);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition),
              box-shadow var(--transition), transform var(--transition),
              border-color var(--transition), opacity var(--transition);
  outline: none;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  -webkit-user-select: none;
  user-select: none;
}

/* D2 — double-ring focus: white inner gap + primary outer ring */
.btn:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary-mid);
  z-index: 1;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

/* D3 — loading state: text hidden, spinner centered via ::after */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  cursor: wait;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ds-spin .55s linear infinite;
}

@keyframes ds-spin {
  to { transform: rotate(360deg); }
}

/* ── Primary ── D1: lift on hover */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-mid), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 33, 182, .28);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--primary-mid));
  box-shadow: 0 4px 16px rgba(91, 33, 182, .38);
  transform: translateY(-1px);
}
.btn-primary:active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(0) scale(0.97);
}

/* ── Secondary ── D1: bg/border shift, no lift */
.btn-secondary {
  background: var(--surface);
  color: var(--primary-mid);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--primary-lighter);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:active {
  background: var(--surface-3);
  transform: scale(0.97);
}

/* ── Outline — promoted from local override, now first-class ── */
/* D1: bg/border shift, no lift */
.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover {
  background: var(--surface-2);
  border-color: var(--primary-light);
  color: var(--primary-mid);
}
.btn-outline:active {
  background: var(--primary-lighter);
  transform: scale(0.97);
}

/* ── Ghost ── D1: bg shift only */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid transparent;
}
.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--primary-mid);
  border-color: var(--border-soft);
}
.btn-ghost:active {
  background: var(--border);
  transform: scale(0.97);
}

/* ── Danger ── D1: lift on hover, D2: red focus ring */
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, .28);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 4px 16px rgba(239, 68, 68, .38);
  transform: translateY(-1px);
}
.btn-danger:active {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(0) scale(0.97);
}
.btn-danger:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #ef4444;
}

/* ── Warning — promoted from local override, now first-class ── */
/* D1: lift on hover, D2: amber focus ring */
.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, .28);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 4px 16px rgba(245, 158, 11, .38);
  transform: translateY(-1px);
}
.btn-warning:active {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(0) scale(0.97);
}
.btn-warning:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f59e0b;
}

/* ── Success — completion action (sign, validate, create) ── */
.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, .28);
}
.btn-success:hover {
  background: #16a34a;
  box-shadow: 0 4px 16px rgba(5, 150, 105, .38);
  transform: translateY(-1px);
}
.btn-success:active {
  background: #15803d;
  transform: translateY(0) scale(0.97);
}
.btn-success:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #16a34a;
}
.btn-success:disabled,
.btn-success.is-disabled {
  opacity: .45;
  pointer-events: none;
}
.btn-success.is-loading::after {
  border-color: rgba(255,255,255,.3) rgba(255,255,255,.3) #fff #fff;
}

/* ── Link — inline text action, minimal frame ── */
.btn-link {
  background: transparent;
  color: var(--primary-mid);
  border: none;
  padding-left: 2px;
  padding-right: 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: transparent;
  box-shadow: none;
}
.btn-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.btn-link:active {
  transform: none;
}

/* ── Icon button ── D5: 36px default (backward compat), sm=32px, lg=40px */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 15px;
  transition: background var(--transition), color var(--transition),
              box-shadow var(--transition), transform var(--transition);
  outline: none;
  flex-shrink: 0;
}
.btn-icon:hover {
  background: var(--surface-3);
  color: var(--primary-mid);
}
.btn-icon:active {
  transform: scale(0.92);
}
.btn-icon:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary-mid);
}
.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-icon.btn-icon-sm {
  width: 32px;
  height: 32px;
  font-size: 13px;
}
.btn-icon.btn-icon-lg {
  width: 40px;
  height: 40px;
  font-size: 17px;
}

/* ── Size variants ── */
.btn-sm {
  padding: var(--padding-btn-sm);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: var(--padding-btn-lg);
  font-size: 16px;
  border-radius: var(--radius-md);
  gap: 8px;
}

/* ── D4 Dense modifier — table/row-action context ── */
.btn-dense {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

/* ──────────────────────────────────────
   PILLS / FILTER TABS — v2.3
   ────────────────────────────────────── */

/* D6 — 4 active signals: bg tint + border + text color + font-weight 700 */
/* font-weight 600→700 causes ~3px width shift; use min-width on pill groups if layout-sensitive */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
  -webkit-user-select: none;
  user-select: none;
}
.pill:hover {
  background: var(--surface-2);
  border-color: var(--primary-light);
  color: var(--primary-mid);
}
.pill.is-active,
.pill[aria-selected="true"] {
  background: var(--primary-lighter);
  border-color: var(--primary-light);
  color: var(--primary-mid);
  font-weight: 700;
}
.pill:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary-mid);
}
.pill:disabled,
.pill[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.pill.pill-sm {
  padding: 3px 9px;
  font-size: 11px;
  gap: 4px;
}
.pill.pill-lg {
  padding: 7px 16px;
  font-size: 14px;
  gap: 6px;
}

/* ──────────────────────────────────────
   INPUTS
   ────────────────────────────────────── */

.input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:hover {
  border-color: var(--primary-light);
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
  background: #fff;
}

.input-error {
  border-color: var(--danger);
  box-shadow: none;
}
.input-error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}

.input-disabled,
.input:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.input-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ──────────────────────────────────────
   CARDS
   ────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-slow), transform var(--transition-slow),
              border-color var(--transition-slow);
}

.card-hover {
  cursor: pointer;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

.card-selected {
  border-color: var(--primary-mid);
  box-shadow: 0 0 0 3px rgba(91, 33, 182, .15), var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-body {
  /* flex container for card content */
}

.card-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ──────────────────────────────────────
   BADGES
   ────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-error,
.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-neutral {
  background: var(--surface-3);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--primary-lighter);
  color: var(--primary-mid);
}

/* ================================================================
   MODALS — Redesign v3.0
   ================================================================ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,10,40,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes modal-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.95); } }
.modal-closing .modal-content { animation: modal-out 120ms cubic-bezier(.4,0,1,1) both; }
.modal-content { background: #ffffff; border-radius: 16px; box-shadow: 0 24px 64px rgba(15,10,40,.22), 0 2px 8px rgba(15,10,40,.08); max-width: 560px; width: 90%; max-height: 90vh; overflow-y: auto; animation: modal-in 150ms cubic-bezier(.34,1.56,.64,1) both; border: 1px solid rgba(255,255,255,.12); }
.modal-header { background: linear-gradient(135deg, var(--primary, #291155) 0%, var(--accent, #7C3AED) 100%); height: 56px; min-height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-radius: 16px 16px 0 0; flex-shrink: 0; }
.modal-header h3, .modal-header h2 { color: #fff; font-weight: 700; font-size: 15px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close-btn { width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(255,255,255,.15); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background 150ms ease; margin-left: 8px; padding: 0; }
.modal-close-btn:hover { background: rgba(255,255,255,.28); }
.modal-close-btn svg { width: 14px; height: 14px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-soft, #f1f5f9); display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) { .modal-content, .modal-closing .modal-content { animation: none !important; } }
@media (max-width: 640px) { .modal-content { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; } .modal-header { border-radius: 16px 16px 0 0; } .modal-footer, .modal-body { padding: 16px; } }

/* ──────────────────────────────────────
   TABLE
   ────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
}

.table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: middle;
  transition: background var(--transition-fast);
}

.table tr:hover td {
  background: var(--primary-lighter);
}

.table tr:last-child td {
  border-bottom: none;
}

.table-wrapper {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

/* ──────────────────────────────────────
   TOAST NOTIFICATIONS
   ────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: #1e1040;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  min-width: 240px;
  max-width: 380px;
  animation: toast-slide-up 250ms ease both;
  border-left: 3px solid rgba(255,255,255,.3);
  role: alert;
}

@keyframes toast-slide-up {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.toast-success {
  background: var(--success-text);
  border-left-color: var(--success);
}
.toast-error {
  background: var(--danger-text);
  border-left-color: var(--danger);
}
.toast-warning {
  background: var(--warning-text);
  border-left-color: var(--warning);
}
.toast-info {
  background: var(--info-text);
  border-left-color: var(--info);
}

/* ──────────────────────────────────────
   SKELETON LOADING
   ────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-3) 25%,
    var(--border-soft) 50%,
    var(--surface-3) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}
.skeleton * { visibility: hidden; }

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ──────────────────────────────────────
   SPINNER
   ────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-mid);
  border-radius: 50%;
  animation: spinner-rotate 700ms linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

/* ──────────────────────────────────────
   EMPTY STATE
   ────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
  filter: grayscale(0.3);
}

.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0;
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.6;
  margin: 0;
}

.empty-state-cta {
  margin-top: 8px;
}

/* ──────────────────────────────────────
   SIDEBAR
   ────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-slow), width var(--transition-slow);
  overflow: hidden;
}

.sidebar-collapsed {
  width: var(--sidebar-collapsed-w) !important;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              padding var(--transition-slow);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-slow), max-width var(--transition-slow);
}

/* ──────────────────────────────────────
   TOPBAR
   ────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  height: var(--topbar-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-xs);
  transition: left var(--transition-slow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ================================================================
   KPI CARDS — Redesign v3.0
   ================================================================ */

/* Icon bubble */
.kpi-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-lighter, #ede9fe);
  color: var(--primary, #291155);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-bottom: 8px;
}
.kpi-icon svg { width: 18px; height: 18px; }

/* Card base */
.kpi-card {
  background: #fff;
  border: 1px solid var(--border-soft, #f1f5f9);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 6px rgba(30,16,64,.06);
  display: flex; flex-direction: column; gap: 4px;
  animation: kpi-fade-up 400ms ease both;
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.kpi-card:hover { box-shadow: 0 6px 20px rgba(30,16,64,.10); transform: translateY(-2px); }

/* Staggered entrance */
.kpi-card:nth-child(1) { animation-delay:   0ms; }
.kpi-card:nth-child(2) { animation-delay:  80ms; }
.kpi-card:nth-child(3) { animation-delay: 160ms; }
.kpi-card:nth-child(4) { animation-delay: 240ms; }
.kpi-card:nth-child(5) { animation-delay: 320ms; }
.kpi-card:nth-child(6) { animation-delay: 400ms; }

@keyframes kpi-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Value & label */
.kpi-value {
  font-size: 28px; font-weight: 800;
  font-family: var(--font-title, 'Outfit', sans-serif);
  color: var(--primary, #291155);
  line-height: 1.1;
}
.kpi-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted, #64748b); margin-top: 2px;
}

/* Trend badge */
.kpi-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  margin-top: 6px; width: fit-content;
}
.kpi-trend-up   { background: #dcfce7; color: #15803d; }
.kpi-trend-down { background: #fee2e2; color: #b91c1c; }
.kpi-trend-flat { background: #f1f5f9; color: #64748b; }

/* Skeleton loading state */
.kpi-card.loading .kpi-value,
.kpi-card.loading .kpi-label,
.kpi-card.loading .kpi-trend,
.kpi-card.loading .kpi-icon {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: kpi-shimmer 1.5s ease infinite;
  border-radius: 6px;
  color: transparent !important;
  pointer-events: none;
}
.kpi-card.loading .kpi-value  { height: 34px; width: 70%; display: block; }
.kpi-card.loading .kpi-label  { height: 12px; width: 55%; display: block; margin-top: 8px; }
.kpi-card.loading .kpi-trend  { height: 20px; width: 40%; }
.kpi-card.loading .kpi-icon   { background: #f1f5f9; animation: kpi-shimmer 1.5s ease infinite; }

@keyframes kpi-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .kpi-card,
  .kpi-card.loading .kpi-value,
  .kpi-card.loading .kpi-label,
  .kpi-card.loading .kpi-trend { animation: none !important; transition: none !important; }
}

/* ================================================================
   PHASE 3 — Enriched Components
   ================================================================ */

/* ──────────────────────────────────────
   PROGRESS BAR
   ────────────────────────────────────── */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary-mid), var(--accent));
  width: var(--pct, 0%);
  transition: width 600ms cubic-bezier(.4,0,.2,1);
}

.progress-fill-success { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-fill-warning { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.progress-fill-danger  { background: linear-gradient(90deg, var(--danger),  #f87171); }

/* ──────────────────────────────────────
   WIZARD STEPS
   ────────────────────────────────────── */

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  min-width: 80px;
}

.wizard-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--border);
  transition: background var(--transition-slow);
}

.wizard-step.done::after,
.wizard-step.active::after {
  background: var(--primary-mid);
}

.wizard-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
  z-index: 1;
}

.wizard-step.active .wizard-step-dot {
  background: var(--primary-mid);
  border-color: var(--primary-mid);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(91, 33, 182, .18);
}

.wizard-step.done .wizard-step-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.wizard-step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

.wizard-step.active .wizard-step-label {
  color: var(--primary-mid);
}

.wizard-step.done .wizard-step-label {
  color: var(--success-text);
}

/* ──────────────────────────────────────
   TIMELINE
   ────────────────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-mid);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary-mid);
  flex-shrink: 0;
  margin-top: 4px;
}

.timeline-dot-success { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot-warning { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot-danger  { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger);  }

.timeline-line {
  width: 2px;
  flex: 1;
  background: var(--border-soft);
  margin-top: 4px;
}

.timeline-content {
  flex: 1;
  padding-top: 0;
}

.timeline-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.timeline-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ──────────────────────────────────────
   TAGS
   ────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-soft);
  cursor: default;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tag:hover {
  background: var(--primary-lighter);
  border-color: var(--primary-light);
  color: var(--primary-mid);
}

.tag-removable {
  cursor: pointer;
}

.tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(0,0,0,.1);
  color: inherit;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition);
}
.tag-remove:hover {
  background: rgba(0,0,0,.2);
}

/* ──────────────────────────────────────
   AVATAR
   ────────────────────────────────────── */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-mid), var(--accent));
  color: #fff;
  font-weight: 700;
  font-family: var(--font-title);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-sm  { width: 28px; height: 28px; font-size: 11px; }
.avatar     { width: 36px; height: 36px; font-size: 13px; }
.avatar-md  { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg  { width: 56px; height: 56px; font-size: 20px; }
.avatar-xl  { width: 72px; height: 72px; font-size: 26px; }

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

/* ──────────────────────────────────────
   DIVIDER
   ────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 16px 0;
  border: none;
}

/* ──────────────────────────────────────
   UTILITY CLASSES
   ────────────────────────────────────── */

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.text-danger    { color: var(--danger) !important; }
.text-info      { color: var(--info) !important; }

.text-micro   { font-size: var(--text-micro);   line-height: var(--lh-micro);   letter-spacing: var(--ls-micro); }
.text-xs      { font-size: var(--text-xs);      line-height: var(--lh-xs);      letter-spacing: var(--ls-xs); }
.text-sm      { font-size: var(--text-sm);      line-height: var(--lh-sm);      letter-spacing: var(--ls-sm); }
.text-sm2     { font-size: var(--text-sm2);     line-height: var(--lh-sm2);     letter-spacing: var(--ls-sm2); }
.text-base    { font-size: var(--text-base);    line-height: var(--lh-base); }
.text-md      { font-size: var(--text-md);      line-height: var(--lh-md);      letter-spacing: var(--ls-md); }
.text-lg      { font-size: var(--text-lg);      line-height: var(--lh-lg);      letter-spacing: var(--ls-lg); }
.text-xl      { font-size: var(--text-xl);      line-height: var(--lh-xl);      letter-spacing: var(--ls-xl); }
.text-2xl     { font-size: var(--text-2xl);     line-height: var(--lh-2xl);     letter-spacing: var(--ls-2xl); }
.text-display { font-size: var(--text-display); line-height: var(--lh-display); letter-spacing: var(--ls-display); }
.text-3xl     { font-size: var(--text-3xl);     line-height: var(--lh-3xl);     letter-spacing: var(--ls-3xl); }

/* Font weight utilities */
.fw-regular   { font-weight: var(--fw-regular); }
.fw-medium    { font-weight: var(--fw-medium); }
.fw-semibold  { font-weight: var(--fw-semibold); }
.fw-bold      { font-weight: var(--fw-bold); }
.fw-extrabold { font-weight: var(--fw-extrabold); }

/* Backward compat aliases — deprecated, use .fw-* */
.font-bold     { font-weight: var(--fw-bold); }
.font-semibold { font-weight: var(--fw-semibold); }
.font-medium   { font-weight: var(--fw-medium); }

/* Font family utilities */
.font-body  { font-family: var(--font-body); }
.font-title { font-family: var(--font-title); }
.font-mono  { font-family: var(--font-mono); }

.rounded    { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.shadow    { box-shadow: var(--shadow); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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;
}

/* ──────────────────────────────────────
   FORM GROUPS
   ────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group:last-child { margin-bottom: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  font-weight: 500;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ──────────────────────────────────────
   SELECT OVERRIDE
   ────────────────────────────────────── */

select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ──────────────────────────────────────
   MAIN CONTENT AREA
   ────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

.page-content {
  padding: 24px;
}

/* ──────────────────────────────────────
   RESPONSIVE — Mobile First
   ────────────────────────────────────── */

@media (max-width: 768px) {
  :root {
    --sidebar-width: 260px;
  }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .topbar {
    left: 0;
    padding-left: 16px;
    padding-right: 16px;
  }

  .main-content {
    margin-left: 0;
  }

  /* modal-content mobile handled by v3.0 block above */

  .form-row {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-value {
    font-size: 22px;
  }

  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 1024px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ──────────────────────────────────────
   REDUCED MOTION — A11Y
   ────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .skeleton {
    animation: none;
    background: var(--surface-3);
  }

  .spinner {
    animation: none;
    border-top-color: var(--primary-mid);
  }

  .btn:hover,
  .card-hover:hover,
  .kpi-card:hover {
    transform: none;
  }
}

/* ──────────────────────────────────────
   FOCUS VISIBLE — A11Y
   ────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--primary-mid);
  outline-offset: var(--focus-ring-offset);
}

/* ──────────────────────────────────────
   SCROLLBAR CUSTOM
   ────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light);
}

/* ──────────────────────────────────────
   SECTION / PAGE HEADER
   ────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ──────────────────────────────────────
   ALERT / BANNER
   ────────────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  border: 1.5px solid transparent;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: rgba(16, 185, 129, .3);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: rgba(245, 158, 11, .3);
}

.alert-error,
.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, .3);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: rgba(59, 130, 246, .3);
}

/* ──────────────────────────────────────
   LOADING OVERLAY
   ────────────────────────────────────── */

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
  backdrop-filter: blur(2px);
}

/* ──────────────────────────────────────
   GRID HELPERS
   ────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ================================================================
   SIDEBAR — Redesign v3.0
   ================================================================ */
.sidebar { width: var(--sidebar-width, 260px); height: 100vh; background: linear-gradient(175deg, var(--primary, #291155) 0%, var(--secondary, #4C1D95) 100%); color: #fff; position: fixed; left: 0; top: 0; display: flex; flex-direction: column; z-index: var(--z-sidebar, 100); overflow: hidden; transition: width 200ms ease, transform 200ms ease; box-shadow: 4px 0 24px rgba(46,16,101,.18); }
@media (prefers-reduced-motion: reduce) { .sidebar, .sidebar * { transition: none !important; } }
.sidebar-logo { padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.sidebar-logomark { width: 38px; height: 38px; border-radius: var(--radius, 10px); flex-shrink: 0; display: block; object-fit: cover; }
.sidebar-logo-text { display: flex; flex-direction: column; gap: 1px; overflow: hidden; transition: opacity 200ms ease; white-space: nowrap; }
.sidebar-logo-wordmark { font-family: var(--font-title, 'Outfit', sans-serif); font-weight: 900; font-size: 22px; color: #fff; letter-spacing: -.5px; line-height: 1.1; }
.sidebar-logo-sub { font-size: 10px; color: rgba(255,255,255,.55); letter-spacing: 1.2px; text-transform: uppercase; font-weight: 500; }
.sidebar-profile { padding: 16px 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.10); flex-shrink: 0; transition: padding 200ms ease; }
.sidebar-avatar { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.18); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; margin-bottom: 8px; border: 2px solid rgba(196,181,253,.5); transition: width 200ms ease, height 200ms ease; cursor: pointer; }
.sidebar-avatar:hover { border-color: var(--primary-light, #c4b5fd); background: rgba(255,255,255,.25); }
.sidebar-profile h3 { font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 200ms ease; }
.sidebar-profile p { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 2px; transition: opacity 200ms ease; }
.sb-lang-switcher { padding: 8px 16px; display: flex; gap: 4px; flex-shrink: 0; overflow: hidden; }
.lang-btn { flex: 1; padding: 5px; border: 1px solid rgba(255,255,255,.25); border-radius: var(--radius-sm, 6px); background: rgba(255,255,255,.08); cursor: pointer; font-size: 11px; font-weight: 700; color: #fff; transition: background 150ms ease, border-color 150ms ease; }
.lang-btn:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.4); }
.lang-btn.active { background: rgba(196,181,253,.30); border-color: var(--primary-light, #c4b5fd); }
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: rgba(196,181,253,.4) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(196,181,253,.35); border-radius: 4px; }
.nav-grp-hd { display: flex; align-items: center; gap: 6px; padding: 10px 20px 5px; font-size: 9px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: rgba(255,255,255,.32); cursor: pointer; user-select: none; transition: color 150ms ease; margin-top: 6px; }
.nav-grp-hd:hover { color: rgba(255,255,255,.65); }
.nav-grp-hd .ng-icon { width: 13px; height: 13px; stroke-width: 2; opacity: .65; display: block; flex-shrink: 0; }
.nav-grp-label { flex: 1; }
.nav-grp-hd .ng-arrow { margin-left: auto; font-size: 10px; transition: transform 200ms ease; opacity: .8; color: var(--primary-light, #c4b5fd); }
.nav-grp-hd.ng-closed .ng-arrow { transform: rotate(-90deg); }
.nav-grp-body { overflow: hidden; transition: max-height 250ms cubic-bezier(.4,0,.2,1); max-height: 800px; }
.nav-grp-body.ng-closed { max-height: 0; }
.sidebar-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 20px 10px 18px; color: rgba(255,255,255,.72); text-decoration: none; font-size: 13px; font-weight: 500; cursor: pointer; position: relative; border-left: 3px solid transparent; transition: background 150ms ease, color 150ms ease, border-color 150ms ease; border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0; margin-right: 8px; }
.sidebar-nav a:hover { background: rgba(196,181,253,.10); color: #fff; border-left-color: rgba(196,181,253,.35); }
.sidebar-nav a.active { background: rgba(196,181,253,.18); color: #fff; font-weight: 600; border-left-color: var(--primary-light, #c4b5fd); }
.sidebar-nav a:focus-visible { outline: 2px solid var(--primary-light, #c4b5fd); outline-offset: -2px; border-radius: var(--radius-sm, 6px); }
.sidebar-nav .nav-icon { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; display: block; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 200ms ease; }
.nav-badge { background: var(--danger, #ef4444); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: auto; flex-shrink: 0; min-width: 18px; text-align: center; }
.nav-item-ai { margin: 6px 8px 2px !important; background: rgba(196,181,253,.12) !important; border-radius: var(--radius, 10px) !important; border-left-color: transparent !important; }
.nav-item-ai:hover { background: rgba(196,181,253,.22) !important; }
.nav-item-ai .nav-label { color: var(--primary-light, #c4b5fd); font-weight: 700; }
.sidebar-bottom { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
#kv-mode-toggle { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; padding: 10px 14px; background: linear-gradient(135deg, #059669, #10b981); color: #fff; border: none; border-radius: var(--radius-md, 12px); font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: var(--font-body, 'Inter', system-ui, sans-serif); box-shadow: 0 3px 12px rgba(16,185,129,.35); transition: box-shadow 200ms ease, transform 200ms ease; white-space: nowrap; overflow: hidden; }
#kv-mode-toggle:hover { box-shadow: 0 5px 18px rgba(16,185,129,.5); transform: translateY(-1px); }
body.kc-mode #kv-mode-toggle { background: linear-gradient(135deg, var(--primary-mid, #5B21B6), var(--accent, #7C3AED)); box-shadow: 0 3px 12px rgba(124,58,237,.35); }
.plan-badge { display: flex; align-items: center; justify-content: center; gap: 6px; background: rgba(255,255,255,.10); padding: 8px 12px; border-radius: var(--radius-sm, 6px); font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,.8); cursor: pointer; border: 1px solid rgba(255,255,255,.12); transition: background 150ms ease; white-space: nowrap; overflow: hidden; }
.plan-badge:hover { background: rgba(255,255,255,.18); }
.sb-toggle-btn { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--radius-sm, 6px); background: rgba(255,255,255,.10); border: none; color: rgba(255,255,255,.65); cursor: pointer; transition: background 150ms ease, transform 200ms ease; align-self: flex-end; }
.sb-toggle-btn:hover { background: rgba(255,255,255,.20); color: #fff; }
body.sb-collapsed .sidebar { width: var(--sidebar-collapsed-w, 64px); overflow: visible; }
body.sb-collapsed .nav-grp-label, body.sb-collapsed .nav-grp-hd .ng-arrow, body.sb-collapsed .nav-label, body.sb-collapsed .sidebar-profile h3, body.sb-collapsed .sidebar-profile p, body.sb-collapsed .sidebar-logo-text, body.sb-collapsed .plan-badge, body.sb-collapsed .sb-toggle-label, body.sb-collapsed .sb-expand-only { display: none !important; }
body.sb-collapsed .sidebar-logo { padding: 16px 0; justify-content: center; }
body.sb-collapsed .sidebar-logomark { margin: 0 auto; }
body.sb-collapsed .sidebar-profile { padding: 10px; }
body.sb-collapsed .sidebar-avatar { width: 40px; height: 40px; font-size: 15px; margin-bottom: 0; }
body.sb-collapsed .sidebar-nav a { justify-content: center; padding: 11px 0; border-left-color: transparent; margin-right: 0; border-radius: 0; }
body.sb-collapsed .sidebar-nav a.active { background: rgba(196,181,253,.20); }
body.sb-collapsed .sidebar-nav .nav-icon { width: 18px; height: 18px; }
body.sb-collapsed .sidebar-bottom { padding: 12px 0; align-items: center; }
body.sb-collapsed .sb-toggle-btn { transform: scaleX(-1); }
body.sb-collapsed .nav-grp-hd { justify-content: center; padding: 8px 0; }
body.sb-collapsed .nav-grp-hd .ng-icon { width: 15px; height: 15px; }
body.sb-collapsed .main-content { margin-left: var(--sidebar-collapsed-w, 64px); }
body.sb-collapsed #main-topbar { left: var(--sidebar-collapsed-w, 64px); }
body.sb-collapsed #kv-mode-label { display: none; }
body.sb-collapsed .nav-item-ai { margin: 6px 0 2px !important; border-radius: 0 !important; }
body.kc-mode .sb-expand-only, body.kc-mode .sidebar-logo-text, body.kc-mode .nav-grp-label, body.kc-mode .nav-grp-hd .ng-arrow, body.kc-mode .nav-label, body.kc-mode .sidebar-profile h3, body.kc-mode .sidebar-profile p { display: none !important; }
body.kc-mode .sidebar-logo { padding: 16px 0; justify-content: center; }
body.kc-mode .sidebar-logomark { margin: 0 auto; }
body.kc-mode .sidebar-nav a { justify-content: center; padding: 11px 0; }
body.kc-mode .sidebar-nav .nav-icon { width: 18px; height: 18px; }
body.kc-mode .sidebar-bottom { padding: 12px 0; align-items: center; }
body.kc-mode .main-content { margin-left: var(--sidebar-collapsed-w, 64px); }
body.kc-mode.kc-sb-hidden .sidebar { width: 0 !important; overflow: hidden; }
body.kc-mode.kc-sb-hidden #main-topbar { left: 0; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(30,16,64,.55); backdrop-filter: blur(2px); z-index: 99; cursor: pointer; }
.sidebar-overlay.open { display: block; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 6px 0 32px rgba(46,16,101,.35); }
  body.sb-collapsed .sidebar { transform: translateX(-100%); }
  body.sb-collapsed .sidebar.open { transform: translateX(0); }
}
#nav-tooltip { position: fixed; background: var(--primary, #291155); color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; padding: 6px 12px; border-radius: var(--radius-sm, 6px); pointer-events: none; z-index: var(--z-tooltip); box-shadow: var(--shadow-md); opacity: 0; transition: opacity 120ms ease; border: 1px solid rgba(196,181,253,.25); }
#nav-tooltip::before { content: ''; position: absolute; left: -7px; top: 50%; transform: translateY(-50%); border: 4px solid transparent; border-right-color: var(--primary, #291155); }

/* ================================================================
   TOPBAR — Redesign v3.0
   ================================================================ */
#main-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width, 260px);
  right: 0;
  height: 52px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft, #f1f5f9);
  z-index: var(--z-topbar, 200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 16px;
  box-shadow: 0 1px 8px rgba(30,16,64,.06);
  transition: left 200ms ease;
}
@media (prefers-reduced-motion: reduce) { #main-topbar { transition: none; } }
#main-topbar .topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
#topbar-menu-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-sm, 6px); border: none; background: transparent; color: var(--text-muted, #64748b); cursor: pointer; flex-shrink: 0; transition: background 150ms ease, color 150ms ease; }
#topbar-menu-btn:hover { background: var(--primary-lighter, #ede9fe); color: var(--primary, #291155); }
#topbar-breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; color: var(--text-primary, #1e293b); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar-breadcrumb-icon { flex-shrink: 0; display: block; }
#topbar-breadcrumb-label { overflow: hidden; text-overflow: ellipsis; }
#main-topbar .topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#topbar-notif-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-sm, 6px); border: none; background: transparent; color: var(--text-muted, #64748b); cursor: pointer; transition: background 150ms ease, color 150ms ease; }
#topbar-notif-btn:hover { background: var(--primary-lighter, #ede9fe); color: var(--primary, #291155); }
#notif-count { display: none; position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; background: var(--danger, #ef4444); color: #fff; font-size: 10px; font-weight: 800; border-radius: 999px; align-items: center; justify-content: center; padding: 0 3px; line-height: 16px; text-align: center; border: 1.5px solid #fff; }
#notif-count.visible { display: flex; }
#topbar-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary, #291155), var(--accent, #7C3AED)); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid transparent; transition: border-color 150ms ease, box-shadow 150ms ease; flex-shrink: 0; }
#topbar-avatar:hover { border-color: var(--primary-light, #c4b5fd); box-shadow: 0 0 0 3px rgba(196,181,253,.25); }
#topbar-logout-btn { display: flex; align-items: center; gap: 5px; padding: 6px 12px; border: 1.5px solid var(--border, #e2e8f0); border-radius: var(--radius-sm, 6px); background: transparent; color: var(--text-muted, #64748b); font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font-body, 'Inter', system-ui, sans-serif); transition: border-color 150ms ease, color 150ms ease, background 150ms ease; white-space: nowrap; }
#topbar-logout-btn:hover { border-color: var(--danger, #ef4444); color: var(--danger, #ef4444); background: var(--danger-bg, #fee2e2); }
body.sb-collapsed #main-topbar { left: var(--sidebar-collapsed-w, 64px); }
body.kc-mode.kc-sb-hidden #main-topbar { left: 0; }
@media (max-width: 768px) { #main-topbar { left: 0; padding-left: 14px; } #topbar-logout-btn .topbar-logout-label { display: none; } }

/* ── Wizard step indicators ────────────────────────────────────── */
.dp-step-circle { cursor: pointer; transition: all 0.2s ease; user-select: none; }
.dp-step-circle:hover { transform: scale(1.15) !important; opacity: .85; }
@keyframes dp-shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.dp-field-error { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.15) !important; animation: dp-shake .3s ease; }

/* ================================================================
   RESPONSIVE — Mobile First
   Breakpoints : 480px (xs) | 640px (sm) | 768px (md) | 1024px (lg)
   ================================================================ */

/* ── LAYOUT PRINCIPAL ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 500;
    height: 100vh;
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }

  #main-topbar {
    left: 0 !important;
    
    padding-right: 12px;
  }

  .main-content {
    margin-left: 0 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-top: calc(var(--topbar-height, 56px) + 12px) !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .sidebar-hamburger {
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 499;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open { display: block; }
}

/* ── PAGE HEADER ── */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .page-header h1 { font-size: 18px !important; }
  .header-right { width: 100%; flex-wrap: wrap; }
}

/* ── KPI / STAT CARDS ── */
@media (max-width: 1024px) {
  .kpi-grid, .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  .kpi-grid, .stats-grid { grid-template-columns: 1fr !important; }
}

/* ── TABLES ── */
@media (max-width: 768px) {
  .table-wrapper, .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrapper table, .table-scroll table { min-width: 560px; }
  .col-hide-mobile { display: none !important; }
}

/* ── MODALS → bottom sheet sur mobile ── */
@media (max-width: 640px) {
  .modal-backdrop, [id$="-modal"][style*="position:fixed"],
  [id$="-modal-ov"], [id$="Overlay"][style*="position:fixed"] {
    align-items: flex-end !important;
  }
  .modal-content, [id$="-modal"] > div:first-child {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92dvh !important;
    overflow-y: auto;
  }
  .modal-footer { flex-direction: column-reverse; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

/* ── FORMULAIRES (évite zoom iOS sur focus) ── */
@media (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="tel"], input[type="date"],
  input[type="time"], select, textarea {
    font-size: 16px !important;
  }
  .form-row-2col, .form-row-2 { grid-template-columns: 1fr !important; }
}

/* ── WIZARD STEPS ── */
@media (max-width: 640px) {
  .wizard-steps, .dp-steps-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .wizard-steps::-webkit-scrollbar { display: none; }
  .dp-step-label, .wizard-step-label { font-size: 10px !important; }
}

/* ── BOUTONS ── */
@media (max-width: 480px) {
  .btn-group-stack { flex-direction: column; width: 100%; }
  .btn-group-stack .btn { width: 100%; justify-content: center; }
}

/* ── FINANCE / CAISSE ── */
@media (max-width: 768px) {
  .fc-cols-4 { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .fc-toggle-pill { width: 100%; justify-content: center; }
}
@media (max-width: 480px) {
  .fc-cols-4 { grid-template-columns: 1fr !important; }
}

/* ── AGENDA ── */
@media (max-width: 768px) {
  .agenda-week-view { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .agenda-week-grid { min-width: 560px; }
  .agenda-day-col { min-width: 110px; }
}

/* ── DOSSIERS TABS ── */
@media (max-width: 768px) {
  .dossier-tabs, .dp-tabs-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .dossier-tabs::-webkit-scrollbar { display: none; }
}

/* ── TOPBAR BREADCRUMB ── */
@media (max-width: 640px) {
  #topbar-breadcrumb-label {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media (max-width: 480px) {
  .topbar-user-name { display: none !important; }
}

/* ── BOOKING / RDV ── */
@media (max-width: 640px) {
  .booking-slots-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .booking-type-cards { flex-direction: column; }
  .booking-type-card { width: 100%; }
  .btn-join-consult { width: 100% !important; display: flex; justify-content: center; }
}

/* ── PAGE PRESTATAIRE ── */
@media (max-width: 768px) {
  .provider-hero { flex-direction: column; text-align: center; }
  .provider-services-grid { grid-template-columns: 1fr !important; }
}

/* ── LANDING / INDEX ── */
@media (max-width: 768px) {
  .hero-section { flex-direction: column; text-align: center; padding: 32px 16px !important; }
  .hero-title { font-size: 32px !important; }
  .hero-subtitle { font-size: 15px !important; }
  .hero-ctas { flex-direction: column; align-items: center; }
  .features-grid, .pricing-grid, .footer-grid { grid-template-columns: 1fr !important; }
}

/* ── SAFE AREA iPhone X+ ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .main-content {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  #main-topbar {
    padding-top: max(0px, env(safe-area-inset-top));
  }
}

/* ── TOUCH TARGETS (44px minimum WCAG 2.5.5) ── */
@media (hover: none) and (pointer: coarse) {
  .btn, button { min-height: 44px; }
  .nav-item, .sidebar-item { min-height: 48px; }
  a.nav-link { min-height: 44px; display: inline-flex; align-items: center; }
  .card-hover:hover { transform: none !important; box-shadow: var(--shadow-sm) !important; }
}

/* ── SCROLLBAR thin sur desktop ── */
@media (min-width: 769px) {
  * { scrollbar-width: thin; scrollbar-color: var(--primary-light, #c4b5fd) transparent; }
  *::-webkit-scrollbar { width: 5px; height: 5px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb { background: var(--primary-light, #c4b5fd); border-radius: 999px; }
}

/* ================================================================
   ACCESSIBILITÉ — WCAG 2.1 AA (complément)
   ================================================================ */
#skip-to-main {
  position: fixed;
  top: -40px;
  left: 8px;
  padding: 8px 16px;
  background: var(--primary, #291155);
  color: white;
  z-index: var(--z-skip);
  font-weight: 700;
  transition: top .15s;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
}
#skip-to-main:focus { top: 0; }

.btn-icon { min-width: 44px; }

@media (prefers-contrast: high) {
  :root { --border: #000000; }
  .btn-primary { border: 2px solid #000000; }
  .modal-content { border: 2px solid #000000; }
}
