/* ============================================================
   Gabon FSA - Design System (Notion-inspired, clean & contemporary)
   ============================================================ */

:root {
  /* Primary: vibrant indigo with gradient accents */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --primary-soft: #e0e7ff;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --primary-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

  /* Vibrant accent palette */
  --accent-violet: #a855f7;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;

  /* Semantic */
  --success: #10b981;
  --success-soft: #d1fae5;
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

  /* Neutrals: cool modern grays */
  --neutral-50:  #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-150: #e9eef5;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;

  /* Sidebar dark navy */
  --sidebar-bg: #0b1120;
  --sidebar-bg-accent: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-bright: #f8fafc;
  --sidebar-text-muted: #64748b;
  --sidebar-hover: rgba(99, 102, 241, 0.12);
  --sidebar-active: rgba(99, 102, 241, 0.18);
  --sidebar-border: rgba(99, 102, 241, 0.15);

  /* Surface tokens */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-input: #ffffff;
  --border-subtle: #e2e8f0;
  --border-default: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Shape */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows: layered with subtle color tint */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 16px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12), 0 8px 16px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 32px 64px rgba(15, 23, 42, 0.18);
  --shadow-glow-primary: 0 4px 16px rgba(99, 102, 241, 0.35), 0 2px 4px rgba(99, 102, 241, 0.2);
  --shadow-glow-success: 0 4px 16px rgba(16, 185, 129, 0.35);
  --shadow-glow-danger: 0 4px 16px rgba(239, 68, 68, 0.35);
  --shadow-focus: 0 0 0 4px rgba(99, 102, 241, 0.18);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.1);

  /* Motion */
  --transition: 120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 240ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }

/* ============================================================
   Loading state
   ============================================================ */
.loading-shell {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
  background: var(--neutral-50);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--neutral-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   AUTH (Login / Signup)
   ============================================================ */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 80% 80% at 20% 30%, rgba(99, 102, 241, 0.55), transparent 60%),
    radial-gradient(ellipse 70% 70% at 80% 70%, rgba(168, 85, 247, 0.45), transparent 60%),
    radial-gradient(ellipse 60% 60% at 50% 50%, rgba(236, 72, 153, 0.25), transparent 60%),
    linear-gradient(135deg, #0b1120 0%, #1e1b4b 100%);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.auth-shell::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}
.auth-card {
  background: rgba(255, 255, 255, 0.98); padding: 2.5rem;
  border-radius: var(--radius-xl);
  box-shadow:
    0 32px 64px rgba(15, 15, 30, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  width: 100%; max-width: 460px;
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 1;
}
.auth-card h1 {
  font-size: 1.875rem; margin: 0 0 0.5rem;
  color: var(--text-primary); letter-spacing: -0.02em; font-weight: 700;
}
.auth-card .subtitle { color: var(--text-secondary); margin: 0 0 2rem; font-size: 0.9375rem; }
.auth-card .brand {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.75rem;
  padding-bottom: 1.25rem; border-bottom: 1px solid var(--border-subtle);
}
.auth-card .brand-logo {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 1.25rem;
  box-shadow: var(--shadow-glow-primary), var(--shadow-inset);
}
.auth-card .brand-name { font-weight: 700; font-size: 1.125rem; color: var(--text-primary); letter-spacing: -0.01em; }
.auth-card .switch { margin-top: 1.5rem; text-align: center; color: var(--text-secondary); font-size: 0.875rem; }
.auth-card .switch a {
  color: var(--primary); font-weight: 600; cursor: pointer;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: 'sidebar header' 'sidebar main';
  height: 100vh;
}

.app-header {
  grid-area: header;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; padding: 0 1.75rem;
  gap: 1rem;
  backdrop-filter: blur(8px);
}
.app-header .breadcrumb { flex: 1; color: var(--text-secondary); font-size: 0.875rem; font-weight: 500; }
.app-header .breadcrumb strong {
  color: var(--text-primary); font-weight: 600;
  background: var(--primary-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.app-header .user-menu {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.375rem 0.75rem 0.375rem 0.375rem; border-radius: 999px;
  cursor: pointer; transition: all var(--transition);
  border: 1px solid transparent;
}
.app-header .user-menu:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}
.app-header .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-gradient);
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8125rem;
  box-shadow: var(--shadow-glow-primary);
}

.app-sidebar {
  grid-area: sidebar;
  background:
    radial-gradient(ellipse at top left, rgba(99, 102, 241, 0.15), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.1), transparent 50%),
    var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; flex-direction: column;
  padding: 1rem 0.75rem;
  position: relative;
  overflow: hidden;
}
.app-sidebar::before {
  content: ''; position: absolute; top: 0; right: 0; left: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.6), transparent);
}
.app-sidebar .logo {
  padding: 0.5rem 0.625rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 0.625rem;
}
.app-sidebar .logo-mark {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  background: var(--primary-gradient);
  color: white;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 0.9375rem; letter-spacing: -0.02em;
  box-shadow: var(--shadow-glow-primary), var(--shadow-inset);
}
.app-sidebar .logo-text {
  font-weight: 600; font-size: 0.9375rem;
  color: var(--sidebar-text-bright); letter-spacing: -0.01em;
}
.app-sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 0.125rem; }
.app-sidebar nav a {
  padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--sidebar-text); display: flex; align-items: center; gap: 0.625rem;
  font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.app-sidebar nav a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-bright);
  text-decoration: none;
}
.app-sidebar nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-bright); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary-light);
}
.app-sidebar nav a.active::before {
  content: ''; position: absolute; left: -0.125rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--primary-light); border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--primary-light);
}
.app-sidebar .org-info {
  margin-top: auto; padding: 0.75rem 0.875rem; border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; gap: 0.625rem; align-items: center;
  backdrop-filter: blur(8px);
}
.app-sidebar .org-info .org-logo {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.app-sidebar .org-info .org-logo img { max-width: 100%; max-height: 100%; }
.app-sidebar .org-info .org-name { font-size: 0.8125rem; font-weight: 600; color: var(--sidebar-text-bright); }
.app-sidebar .org-info .org-role {
  font-size: 0.6875rem; color: var(--sidebar-text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}

.app-main {
  grid-area: main;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  background:
    radial-gradient(ellipse 600px 400px at 5% 0%, rgba(99, 102, 241, 0.04), transparent 60%),
    radial-gradient(ellipse 500px 400px at 95% 5%, rgba(168, 85, 247, 0.04), transparent 60%),
    var(--bg-app);
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5625rem 1rem; border-radius: var(--radius-md);
  font-weight: 600; font-size: 0.875rem;
  border: 1px solid transparent; background: transparent;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: -0.005em;
  position: relative;
  cursor: pointer;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active:not([disabled]) { transform: translateY(1px); }

.btn-primary {
  background: var(--primary-gradient); color: white;
  box-shadow: var(--shadow-glow-primary), var(--shadow-inset);
}
.btn-primary:hover {
  background: var(--primary-gradient-hover);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45), var(--shadow-inset);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border-color: var(--border-default); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-card); border-color: var(--primary);
  color: var(--primary); box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn-success {
  background: var(--success-gradient); color: white;
  box-shadow: var(--shadow-glow-success), var(--shadow-inset);
}
.btn-success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45), var(--shadow-inset);
  transform: translateY(-1px);
}
.btn-danger {
  background: var(--danger-gradient); color: white;
  box-shadow: var(--shadow-glow-danger), var(--shadow-inset);
}
.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45), var(--shadow-inset);
  transform: translateY(-1px);
}
.btn-ghost { color: var(--text-secondary); font-weight: 500; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-large { padding: 0.75rem 1.5rem; font-size: 0.9375rem; }
.btn-small { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-icon { padding: 0.5rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block; font-weight: 500; color: var(--text-primary);
  margin-bottom: 0.3125rem; font-size: 0.8125rem;
  letter-spacing: -0.005em;
}
.form-group .help {
  display: block; margin-top: 0.3125rem; color: var(--text-muted); font-size: 0.75rem;
  line-height: 1.5;
}
.form-group .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-size: 0.875rem; font-family: inherit;
  color: var(--text-primary);
  transition: border var(--transition), box-shadow var(--transition);
  background: var(--bg-input);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
.form-control:hover:not(:focus) { border-color: var(--neutral-400); }
.form-control.with-unit {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
}
.input-group { display: flex; }
.input-group .unit {
  padding: 0.5rem 0.75rem;
  background: var(--neutral-100);
  border: 1px solid var(--border-default);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary); font-size: 0.8125rem;
  display: flex; align-items: center;
}
textarea.form-control { min-height: 80px; resize: vertical; line-height: 1.5; }
select.form-control {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235d5b56' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.625rem center;
  padding-right: 2rem; appearance: none;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 1rem;
}
.card-title { font-weight: 600; font-size: 1rem; margin: 0; flex: 1; letter-spacing: -0.01em; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.875rem 1.25rem; border-top: 1px solid var(--border-subtle);
  background: var(--neutral-50); display: flex; justify-content: flex-end; gap: 0.5rem;
}

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.1875rem 0.5rem; border-radius: var(--radius-sm);
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-success { background: var(--success-soft); color: #166534; }
.badge-warning { background: var(--warning-soft); color: #92400e; }
.badge-danger  { background: var(--danger-soft); color: #991b1b; }
.badge-info    { background: var(--primary-soft); color: #1e40af; }
.badge-neutral { background: var(--neutral-150); color: var(--text-secondary); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.125rem; }
.kpi-card {
  background: var(--bg-card); padding: 1.375rem 1.5rem; border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary-gradient);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-card:nth-child(2)::before { background: linear-gradient(135deg, #10b981, #06b6d4); }
.kpi-card:nth-child(3)::before { background: linear-gradient(135deg, #f59e0b, #ec4899); }
.kpi-card:nth-child(4)::before { background: linear-gradient(135deg, #a855f7, #ec4899); }
.kpi-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.3);
}
.kpi-card .label {
  font-size: 0.6875rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
}
.kpi-card .value {
  font-size: 2rem; font-weight: 700; color: var(--text-primary);
  margin: 0.5rem 0 0.25rem; letter-spacing: -0.025em; line-height: 1.1;
  font-feature-settings: 'tnum';
}
.kpi-card .value.positive {
  background: var(--success-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-card .value.negative {
  background: var(--danger-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-card .delta { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.6875rem 0.875rem; text-align: left; font-size: 0.875rem; }
.table th {
  background: var(--neutral-50); font-weight: 600; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.6875rem;
}
.table td { border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); }
.table tr:hover td { background: var(--neutral-50); }
.table input.cell-input {
  width: 100%; padding: 0.3125rem 0.5rem;
  border: 1px solid transparent; background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: inherit; color: var(--text-primary);
  transition: all var(--transition);
}
.table input.cell-input:hover { background: var(--neutral-50); }
.table input.cell-input:focus { outline: none; border-color: var(--primary); background: var(--bg-app); box-shadow: var(--shadow-focus); }

/* Progress bar */
.progress { height: 5px; background: var(--neutral-150); border-radius: 999px; overflow: hidden; }
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 999px;
}

/* Stepper - Wizard steps (uniformized typography) */
.stepper {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  overflow-x: auto;
  padding: 0.25rem 0.125rem 0.75rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.stepper::-webkit-scrollbar { height: 6px; }
.stepper::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
.stepper-item {
  flex: 0 0 auto;
  width: 148px;
  min-height: 104px;
  padding: 0.75rem 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  scroll-snap-align: start;
}
.stepper-item .num {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.1;
  height: 16px;
}
.stepper-item .name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.005em;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
}
.stepper-item .progress {
  margin-top: auto;
  height: 4px;
}
.stepper-item.active {
  border-color: transparent;
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-glow-primary);
}
.stepper-item.active .num, .stepper-item.active .name { color: white; }
.stepper-item.active .progress { background: rgba(255, 255, 255, 0.25); }
.stepper-item.active .progress-bar { background: white; }
.stepper-item.completed .num::before { content: '✓ '; color: var(--success); font-weight: 700; }
.stepper-item.active.completed .num::before { color: white; }
.stepper-item:hover:not(.active) {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.studies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.25rem; }
.study-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle); padding: 1.5rem;
  cursor: pointer; transition: all var(--transition);
  position: relative; overflow: hidden;
}
.study-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary-gradient);
  opacity: 0; transition: opacity var(--transition);
}
.study-card:hover {
  box-shadow: var(--shadow-lg); transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.4);
}
.study-card:hover::before { opacity: 1; }
.study-card .header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 0.5rem; }
.study-card h3 { margin: 0 0 0.25rem; font-size: 1.125rem; color: var(--text-primary); letter-spacing: -0.015em; font-weight: 700; }
.study-card .client { color: var(--neutral-500); font-size: 0.8125rem; }
.study-card .stats { display: flex; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--neutral-100); }
.study-card .stat { flex: 1; }
.study-card .stat .label { font-size: 0.6875rem; color: var(--neutral-500); text-transform: uppercase; font-weight: 600; }
.study-card .stat .value { font-size: 0.95rem; font-weight: 600; color: var(--neutral-800); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 1000;
}
.modal {
  background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
}
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--neutral-200); display: flex; align-items: center; gap: 0.5rem; }
.modal-title { font-size: 1.125rem; font-weight: 600; flex: 1; margin: 0; }
.modal-close {
  background: none; border: none; color: var(--neutral-500); font-size: 1.25rem;
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--neutral-100); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--neutral-200); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 2000; }
.toast {
  padding: 0.75rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow-md);
  background: white; border-left: 4px solid var(--primary);
  display: flex; align-items: center; gap: 0.5rem; min-width: 240px;
  animation: slide-in 0.3s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   UTILS
   ============================================================ */
.text-muted { color: var(--neutral-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.75rem; }
.page-header h2 {
  margin: 0; font-size: 1.75rem; color: var(--text-primary); flex: 1;
  letter-spacing: -0.025em; font-weight: 700; line-height: 1.2;
}
.page-subtitle { color: var(--text-secondary); font-size: 0.9375rem; margin: 0.375rem 0 0; line-height: 1.5; }

.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--neutral-500);
  background: white; border-radius: var(--radius-lg); border: 2px dashed var(--neutral-200);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 0.5rem; }
.empty-state h3 { margin: 0.5rem 0; color: var(--neutral-800); }
.empty-state p { margin: 0 0 1.5rem; }

/* ============================================================
   PRESENCE BAR (realtime collaboration)
   ============================================================ */
.presence-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(90deg, #ecfdf5, #f0fdf4);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  min-height: 24px;
  flex-wrap: wrap;
}
.presence-bar:empty { display: none; }
.presence-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; font-weight: 600; font-size: 0.7rem;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  position: relative;
}
.presence-avatar::after {
  content: ''; position: absolute; bottom: -1px; right: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #16a34a; border: 2px solid white;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
}
.presence-label {
  color: #166534; font-size: 0.8rem; font-weight: 600; margin-left: 0.5rem;
}

/* ============================================================
   SECTION FORM (the meat of the app)
   ============================================================ */
.section-wrapper { max-width: 1100px; margin: 0 auto; }

.section-header {
  display: flex;
  align-items: center;             /* aligné au centre vertical du contenu */
  gap: 0.9rem;
  padding: 0.7rem 1rem;            /* réduit : 1.375rem → 0.7rem */
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;             /* réduit : 1.5rem → 1rem */
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.section-header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;                       /* barre verticale plus fine */
  background: var(--primary-gradient);
}
.section-header .step-num {
  width: 38px; height: 38px;       /* réduit : 56px → 38px */
  flex-shrink: 0;
  background: var(--primary-gradient);
  color: white;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;              /* réduit : 0.9375rem → 0.78rem */
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-glow-primary), var(--shadow-inset);
}
.section-header .flex-1 {
  min-width: 0;
  display: flex;
  flex-direction: row;             /* HORIZONTAL : titre + description + badges sur 1 ligne */
  align-items: center;
  gap: 0.7rem;
}
.section-header h2 {
  margin: 0;
  font-size: 1.15rem;              /* réduit : 1.4375rem → 1.15rem */
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.section-header .description {
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin: 0;
  line-height: 1.35;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;             /* 1 ligne continue, jamais coupée */
  overflow: hidden;
  text-overflow: ellipsis;         /* ... si vraiment trop long */
}
.section-header .meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.section-header .comments-btn {
  align-self: center;              /* aligné centre (et non plus flex-start) */
}

.section-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
.section-fields .full { grid-column: 1 / -1; }

.computed-banner {
  background: var(--primary-bg); border: 1px solid var(--primary-light);
  border-radius: var(--radius); padding: 0.75rem 1rem; margin-top: 1rem; font-size: 0.8125rem; color: var(--primary-dark);
}

.validation-issues { margin-top: 1rem; }
.issue {
  display: flex; gap: 0.5rem; padding: 0.625rem 0.75rem;
  border-radius: var(--radius); font-size: 0.8125rem; margin-bottom: 0.5rem;
  align-items: flex-start;
}
.issue.error { background: #fee2e2; color: #991b1b; }
.issue.warn { background: #fef3c7; color: #92400e; }
.issue .icon { font-weight: 700; }

.chart-container {
  background: white; border-radius: var(--radius-lg); padding: 1rem;
  border: 1px solid var(--neutral-200); position: relative; height: 320px;
}

/* Wide table for production plan / risk registry */
.wide-table-wrapper {
  background: white; border: 1px solid var(--neutral-200); border-radius: var(--radius-lg);
  overflow: hidden;
}
.wide-table-actions {
  display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--neutral-200);
  background: var(--neutral-50);
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: 'header' 'main'; }
  .app-sidebar { display: none; }
  .section-fields { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
}

/* ============================================================
   PWA Install button
   ============================================================ */
.pwa-install-btn {
  position: fixed; bottom: 1rem; right: 1rem;
  background: var(--primary); color: white;
  border: none; padding: 0.625rem 1.25rem;
  border-radius: 999px; box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 0.875rem;
  display: flex; align-items: center; gap: 0.5rem;
  z-index: 1500; cursor: pointer;
  animation: pulse 2s infinite;
}
.pwa-install-btn::before { content: '⬇'; font-size: 1.125rem; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ============================================================
   Language selector + mobile toggle
   ============================================================ */
.lang-selector {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius);
  background: white; font-size: 0.8125rem;
  color: var(--neutral-700); cursor: pointer;
}
.lang-selector:hover { border-color: var(--primary); }

.mobile-menu-toggle {
  display: none;
  background: transparent; border: none;
  font-size: 1.5rem; padding: 0.5rem;
  color: var(--neutral-700); cursor: pointer;
  border-radius: var(--radius);
}
.mobile-menu-toggle:hover { background: var(--neutral-100); }

/* ============================================================
   RESPONSIVE - Mobile first refinements
   ============================================================ */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: 'header' 'main';
  }
  .app-sidebar {
    display: none;
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px; z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  body.sidebar-open .app-sidebar {
    display: flex; transform: translateX(0);
  }
  body.sidebar-open::before {
    content: ''; position: fixed; inset: 0;
    background: rgba(15,23,42,0.5); z-index: 99;
  }
  .mobile-menu-toggle { display: block !important; }
  .app-header { padding: 0 0.75rem; gap: 0.5rem; }
  .app-header .breadcrumb { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-header .user-menu .user-info,
  .app-header .user-menu > div:not(.avatar) { display: none; }

  .app-main { padding: 1rem; }

  .section-wrapper { max-width: 100%; }
  .page-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .page-header h2 { font-size: 1.25rem; }

  .stepper {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .stepper-item {
    min-width: 140px; scroll-snap-align: start;
    flex: 0 0 auto;
  }

  .section-fields { grid-template-columns: 1fr; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .kpi-card { padding: 0.875rem; }
  .kpi-card .value { font-size: 1.25rem; }

  .studies-grid { grid-template-columns: 1fr; }

  .section-header { padding: 0.75rem; flex-direction: column; gap: 0.5rem; }
  .section-header .step-num { width: 36px; height: 36px; font-size: 0.875rem; }
  .section-header h2 { font-size: 1.125rem; }

  .table { font-size: 0.75rem; }
  .table th, .table td { padding: 0.4rem 0.5rem; }
  .wide-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .modal { max-height: 95vh; max-width: 95vw; margin: 0.5rem; }
  .modal-body { padding: 1rem; }

  .card-header, .card-body, .card-footer { padding: 0.875rem; }

  .auth-card { padding: 1.5rem; }
  .auth-card h1 { font-size: 1.375rem; }

  .pwa-install-btn { bottom: 0.5rem; right: 0.5rem; padding: 0.5rem 0.875rem; font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stepper-item { min-width: 120px; padding: 0.375rem 0.5rem; }
  .stepper-item .num { font-size: 0.625rem; }
  .stepper-item .name { font-size: 0.6875rem; }
  .btn { padding: 0.5rem 0.875rem; font-size: 0.8125rem; }
  .btn-large { padding: 0.625rem 1.125rem; font-size: 0.9375rem; }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
  button, .btn, a, input, select, textarea {
    min-height: 38px;
  }
  .cell-input { min-height: 30px; }
  .table input.cell-input { padding: 0.4rem 0.5rem; }
}

/* Larger text on very high DPI */
@media (min-resolution: 2dppx) {
  body { -webkit-font-smoothing: subpixel-antialiased; }
}

/* Safe area for notched phones (iPhone X+) */
@supports (padding: max(0px)) {
  .app-header { padding-top: max(0.5rem, env(safe-area-inset-top)); }
  .app-main { padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
}

/* ============================================================
   COMMENTS PANEL (side drawer, Notion-style)
   ============================================================ */
.comments-panel-backdrop {
  position: fixed; inset: 0; background: rgba(15, 15, 15, 0.25);
  z-index: 998; opacity: 0;
  transition: opacity var(--transition-slow);
}
.comments-panel-backdrop.open { opacity: 1; }

.comments-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg-app);
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--border-subtle);
  z-index: 999;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
.comments-panel.open { transform: translateX(0); }

.comments-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 0.75rem;
}
.comments-panel-header h3 {
  margin: 0; font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text-primary); flex: 1;
}
.comments-panel-header .close-btn {
  background: none; border: none; padding: 0.375rem;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.comments-panel-header .close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.comments-panel-section-label {
  padding: 0.625rem 1.25rem; font-size: 0.75rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}

.comments-list {
  flex: 1; overflow-y: auto; padding: 0.75rem 1rem;
}
.comments-list-empty {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
}
.comments-list-empty .icon { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.5; }

.comment {
  padding: 0.75rem; margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  transition: border-color var(--transition);
}
.comment:hover { border-color: var(--border-default); }
.comment.resolved { opacity: 0.6; background: var(--neutral-50); }
.comment-header {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem;
}
.comment-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.6875rem;
  box-shadow: var(--shadow-xs);
}
.comment-author { font-weight: 600; color: var(--text-primary); font-size: 0.8125rem; flex: 1; }
.comment-date { font-size: 0.6875rem; color: var(--text-muted); }
.comment-body {
  font-size: 0.875rem; line-height: 1.5; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word;
}
.comment-actions {
  display: flex; gap: 0.25rem; margin-top: 0.5rem;
}
.comment-action {
  background: none; border: none;
  font-size: 0.75rem; padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); transition: all var(--transition);
}
.comment-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.comment-action.danger:hover { background: var(--danger-soft); color: var(--danger); }
.comment-action.success:hover { background: var(--success-soft); color: var(--success); }
.comment-resolved-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.6875rem; color: var(--success); font-weight: 600;
  margin-left: 0.5rem;
}

.comments-composer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-app);
}
.comments-composer textarea {
  width: 100%; padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-family: inherit; font-size: 0.875rem; line-height: 1.5;
  color: var(--text-primary); background: var(--bg-input);
  resize: vertical; min-height: 60px; max-height: 200px;
  transition: all var(--transition);
}
.comments-composer textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--shadow-focus);
}
.comments-composer-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.5rem; gap: 0.5rem;
}
.comments-composer-hint { font-size: 0.6875rem; color: var(--text-muted); }

.comments-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.4375rem 0.75rem; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px solid var(--border-default);
  font-size: 0.8125rem; font-weight: 500; color: var(--text-primary);
  cursor: pointer; transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.comments-btn:hover { background: var(--bg-hover); }
.comments-btn-count {
  background: var(--primary); color: white;
  padding: 0.0625rem 0.4375rem; border-radius: 999px;
  font-size: 0.6875rem; font-weight: 600;
  min-width: 18px; text-align: center;
}

/* ============================================================
   NUMBER SPINNER (custom +/- buttons on number inputs)
   ============================================================ */
.number-spinner {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  width: 100%;
}
.number-spinner .form-control.with-spinner {
  padding-right: 2.25rem;
  flex: 1;
  /* Hide native browser spinners (Chrome, Safari, Edge, Firefox) */
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
}
.number-spinner .form-control.with-spinner::-webkit-outer-spin-button,
.number-spinner .form-control.with-spinner::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.number-spinner.with-unit + .unit,
.input-group .number-spinner .form-control.with-spinner {
  /* keep right padding for our buttons even when next to a unit */
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
/* When in input-group, our spinner's right border should match group */
.input-group .number-spinner {
  flex: 1;
}
.spinner-buttons {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 1.875rem;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
  background: var(--neutral-50);
  border-radius: 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0;
  overflow: hidden;
}
.input-group .number-spinner .spinner-buttons {
  border-radius: 0;
}
.spinner-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  font-size: 0.625rem;
  user-select: none;
}
.spinner-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.spinner-btn:active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: scale(0.92);
}
.spinner-btn-up {
  border-bottom: 1px solid var(--border-subtle);
}
.spinner-btn svg { display: block; }
.form-control.with-spinner:focus + .spinner-buttons {
  background: var(--primary-bg);
}
.form-control.with-spinner:focus ~ .spinner-buttons {
  border-left-color: var(--primary);
}

/* ============================================================
   GROUPED FIELD LIST (hierarchical groups + items)
   ============================================================ */
.grouped-field-list {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-xs);
}
.gfl-group {
  margin-bottom: 1.25rem;
}
.gfl-group:last-of-type { margin-bottom: 0.5rem; }
.gfl-group-title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.625rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-soft);
  position: relative;
}
.gfl-group-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--primary-gradient);
  border-radius: 2px;
  margin-right: 0.5rem;
  vertical-align: middle;
  transform: translateY(-1px);
}
.gfl-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1.25rem;
}
.gfl-item {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.gfl-item:hover {
  background: var(--neutral-50);
}
.gfl-label {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  font-size: 0.875rem;
}
.gfl-label-text {
  color: var(--text-primary);
  font-weight: 500;
}
.gfl-ref {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 500;
  font-feature-settings: 'tnum';
}
.gfl-input-group {
  display: flex;
  width: 100%;
}
.gfl-input-group .gfl-input {
  flex: 1;
}
.gfl-input-group .unit {
  padding: 0.5rem 0.75rem;
  background: var(--neutral-50);
  border: 1px solid var(--border-default);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  white-space: nowrap;
  max-width: 200px;
}
.gfl-input.with-unit,
.gfl-input-group:has(.unit) .gfl-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.gfl-actions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}
@media (max-width: 640px) {
  .gfl-item { grid-template-columns: 1fr; gap: 0.375rem; }
  .gfl-items { padding-left: 0.5rem; }
}

/* ============================================================
   TYPOGRAPHY UNIFORMIZATION (professional rendering)
   ============================================================ */

/* Uniform table titles (h3 above each table) */
.section-wrapper h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 1.5rem 0 0.75rem;
  padding: 0.625rem 0.875rem 0.625rem 1rem;
  background: linear-gradient(90deg, var(--primary-bg) 0%, transparent 100%);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* First h3 keeps a tighter top margin */
.section-wrapper .card-body > div:first-child > h3,
.section-wrapper > div:first-child > h3 {
  margin-top: 0.5rem;
}

/* Form labels — consistent typography */
.form-group label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4375rem;
  font-size: 0.8125rem;
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.form-group .help {
  display: block;
  margin-top: 0.375rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.5;
  font-style: italic;
}
.form-group .required {
  color: var(--danger);
  margin-left: 3px;
  font-weight: 700;
}

/* Section fields grid — uniform gaps and alignment */
.section-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.125rem 1.5rem;
  align-items: start;
}
.section-fields .form-group { margin-bottom: 0; }
@media (max-width: 768px) {
  .section-fields { grid-template-columns: 1fr; gap: 1rem; }
}

/* Card body — consistent padding */
.card-body {
  padding: 1.5rem 1.625rem;
}
.card-footer {
  padding: 0.875rem 1.625rem;
  background: var(--neutral-50);
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Wide table styling refinement */
.wide-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.wide-table-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--neutral-50);
  flex-wrap: wrap;
}

/* Table cells — uniform spacing */
.wide-table-wrapper .table {
  font-size: 0.8125rem;
}
.wide-table-wrapper .table th {
  padding: 0.75rem 0.875rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--neutral-50);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.wide-table-wrapper .table td {
  padding: 0.5625rem 0.875rem;
  vertical-align: middle;
}
.wide-table-wrapper .table input.cell-input,
.wide-table-wrapper .table select.cell-input {
  font-size: 0.8125rem;
  line-height: 1.4;
  padding: 0.4375rem 0.5625rem;
}

/* Breadcrumb in app header — clearer hierarchy */
.app-header .breadcrumb {
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}
.app-header .breadcrumb strong {
  font-weight: 600;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.01em;
}

/* Page header consistency */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.875rem;
  flex-wrap: wrap;
}
.page-header > .flex-1 {
  min-width: 200px;
}
.page-header h2 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  font-weight: 700;
  line-height: 1.2;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin: 0.375rem 0 0;
  line-height: 1.5;
}

/* Grouped field list — refined typography */
.gfl-group-title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.625rem;
  border-bottom: 2px solid var(--primary-soft);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}
.gfl-label-text {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: -0.005em;
  line-height: 1.4;
}
.gfl-ref {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 500;
  font-feature-settings: 'tnum';
  letter-spacing: 0.02em;
}

/* Badges — consistent sizing */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.25rem 0.5625rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}

/* Selection card / dashboard study card titles */
.study-card h3 {
  margin: 0 0 0.375rem;
  font-size: 1.0625rem;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  font-weight: 700;
  line-height: 1.3;
}
.study-card .client {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0 0 0.875rem;
  font-weight: 500;
}

/* ============================================================
   COMPUTED KPIS BAR (auto-calculated indicators)
   ============================================================ */
.computed-kpis-bar {
  display: flex;
  flex-direction: column;        /* stack the 2 rows vertically */
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.computed-kpis-bar:empty { min-height: 40px; padding: 0.5rem; }
/* Each row : label + KPIs side by side, horizontal scroll if too wide */
.computed-kpis-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
  flex-wrap: nowrap;
}
.computed-kpis-row::-webkit-scrollbar { height: 6px; }
.computed-kpis-row::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
.computed-kpis-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  padding: 0.375rem 0.625rem 0.375rem 0;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
}
.computed-kpi {
  flex: 0 0 auto;
  min-width: 95px;
  padding: 0.375rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  transition: all var(--transition);
}
.computed-kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.computed-kpi-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.computed-kpi-value {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-feature-settings: 'tnum';
}
/* Accents per KPI category */
.computed-kpi-primary { border-top: 2px solid var(--primary); }
.computed-kpi-cyan { border-top: 2px solid var(--accent-cyan); }
.computed-kpi-amber { border-top: 2px solid var(--accent-amber); }
.computed-kpi-emerald { border-top: 2px solid var(--accent-emerald); }
.computed-kpi-pink { border-top: 2px solid var(--accent-pink); }
.computed-kpi-violet { border-top: 2px solid var(--accent-violet); }

/* KPI flaggés audit warnings (v1.11.184) */
.computed-kpi-flagged-warn {
  box-shadow: 0 0 0 1px rgba(245,158,11,0.45), 0 0 14px rgba(245,158,11,0.20);
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(245,158,11,0.02)) !important;
}
.computed-kpi-flagged-critical {
  box-shadow: 0 0 0 1px rgba(220,38,38,0.55), 0 0 18px rgba(220,38,38,0.28);
  background: linear-gradient(135deg, rgba(220,38,38,0.12), rgba(220,38,38,0.03)) !important;
  animation: kpi-flagged-pulse 2.5s ease-in-out infinite;
}
@keyframes kpi-flagged-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(220,38,38,0.55), 0 0 18px rgba(220,38,38,0.28); }
  50% { box-shadow: 0 0 0 1px rgba(220,38,38,0.7), 0 0 24px rgba(220,38,38,0.4); }
}
.kpi-warnings-banner:hover {
  filter: brightness(1.15);
}

/* ============================================================
   AI EXPERT — floating button + side panel chat
   ============================================================ */
.ai-expert-floating-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-primary), 0 8px 24px rgba(99,102,241,0.4);
  transition: all var(--transition);
  z-index: 990;
}
.ai-expert-floating-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 32px rgba(99,102,241,0.55), var(--shadow-inset);
}
.ai-expert-floating-btn::after {
  content: '✨';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 14px;
  background: var(--accent-amber);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ai-expert-backdrop {
  position: fixed; inset: 0; background: rgba(15, 15, 30, 0.35);
  z-index: 1000; opacity: 0;
  pointer-events: none;          /* CRITICAL: don't block clicks when closed */
  transition: opacity var(--transition-slow);
  backdrop-filter: blur(2px);
}
.ai-expert-backdrop.open { opacity: 1; pointer-events: auto; }

.ai-expert-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(480px, 95vw);
  background: var(--bg-app);
  box-shadow: -8px 0 32px rgba(15,15,30,0.18);
  border-left: 1px solid var(--border-subtle);
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
.ai-expert-panel.open { transform: translateX(0); }

.ai-expert-header {
  padding: 1rem 1.25rem;
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-glow-primary);
}
.ai-expert-header-title {
  display: flex; align-items: center; gap: 0.75rem; flex: 1;
}
.ai-expert-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.ai-expert-subtitle { font-size: 0.75rem; opacity: 0.85; line-height: 1.2; margin-top: 1px; }
.ai-expert-close {
  background: rgba(255,255,255,0.15); border: none; padding: 0.375rem;
  border-radius: var(--radius-sm); cursor: pointer; color: white;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.ai-expert-close:hover { background: rgba(255,255,255,0.25); }

.ai-expert-history {
  flex: 1; overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.625rem;
  background:
    radial-gradient(ellipse 400px 200px at 30% 0%, rgba(99,102,241,0.04), transparent 60%),
    var(--bg-app);
}

.ai-expert-welcome {
  text-align: center; padding: 2rem 1rem;
  color: var(--text-primary);
}
.ai-expert-welcome-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.ai-expert-welcome-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.5rem; }
.ai-expert-welcome-subtitle {
  font-size: 0.8125rem; color: var(--text-secondary);
  line-height: 1.55; max-width: 360px; margin: 0 auto 1.25rem;
}
.ai-expert-welcome-suggestions {
  display: flex; flex-direction: column; gap: 0.5rem; max-width: 380px; margin: 0 auto;
}
.ai-expert-suggestion {
  padding: 0.625rem 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.ai-expert-suggestion:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(2px);
}

.ai-expert-bubble {
  max-width: 88%;
  padding: 0.6875rem 0.9375rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
  letter-spacing: -0.005em;
  animation: ai-bubble-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes ai-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-expert-bubble-user {
  align-self: flex-end;
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.ai-expert-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-xs);
}
.ai-expert-bubble-content h2,
.ai-expert-bubble-content h3,
.ai-expert-bubble-content h4 {
  margin: 0.5rem 0 0.25rem; font-weight: 700; letter-spacing: -0.01em;
}
.ai-expert-bubble-content h2 { font-size: 1rem; }
.ai-expert-bubble-content h3 { font-size: 0.9375rem; }
.ai-expert-bubble-content h4 { font-size: 0.875rem; color: var(--primary); }
.ai-expert-bubble-content ul { margin: 0.375rem 0; padding-left: 1.25rem; }
.ai-expert-bubble-content li { margin: 0.125rem 0; }
.ai-expert-bubble-content code {
  background: var(--neutral-100); padding: 0.125rem 0.3125rem;
  border-radius: 4px; font-size: 0.8125rem;
  font-family: var(--font-mono);
}
.ai-expert-bubble-content strong { color: var(--text-primary); }
.ai-expert-bubble-assistant .ai-expert-bubble-content code { background: var(--neutral-100); }
.ai-expert-bubble-user .ai-expert-bubble-content code { background: rgba(255,255,255,0.2); color: white; }

/* Markdown rendering in chat bubbles */
.ai-expert-bubble-content p { margin: 0.375rem 0; line-height: 1.55; }
.ai-expert-bubble-content ol { margin: 0.375rem 0; padding-left: 1.5rem; }
.ai-expert-bubble-content blockquote {
  border-left: 3px solid var(--primary);
  margin: 0.5rem 0; padding: 0.375rem 0.75rem;
  background: var(--neutral-50, #f9fafb);
  color: var(--text-secondary);
  border-radius: 0 4px 4px 0; font-size: 0.875rem;
}
.ai-expert-bubble-content pre {
  background: var(--neutral-100); padding: 0.5rem 0.75rem;
  border-radius: 6px; overflow-x: auto;
  font-size: 0.8125rem; margin: 0.5rem 0;
}
.ai-expert-bubble-content pre code { background: transparent; padding: 0; }
/* Markdown tables */
.ai-expert-bubble-content .ai-expert-table {
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.8125rem;
  width: 100%;
  background: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ai-expert-bubble-content .ai-expert-table th {
  background: var(--primary, #2563eb);
  color: white;
  text-align: left;
  padding: 0.5rem 0.625rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.ai-expert-bubble-content .ai-expert-table td {
  padding: 0.4375rem 0.625rem;
  border-top: 1px solid var(--neutral-200, #e5e7eb);
  vertical-align: top;
}
.ai-expert-bubble-content .ai-expert-table tbody tr:nth-child(even) {
  background: var(--neutral-50, #f9fafb);
}
.ai-expert-bubble-content .ai-expert-table tbody tr:hover {
  background: var(--primary-50, #eff6ff);
}

.ai-expert-typing {
  display: flex; gap: 4px; align-items: center; padding: 4px 0;
}
.ai-typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  animation: ai-typing 1.4s infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.ai-expert-composer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}
.ai-expert-input {
  width: 100%; padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-family: inherit; font-size: 0.875rem; line-height: 1.5;
  color: var(--text-primary); background: var(--bg-input);
  resize: vertical; min-height: 56px; max-height: 200px;
  transition: all var(--transition);
}
.ai-expert-input:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--shadow-focus);
}
.ai-expert-composer-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.5rem; gap: 0.5rem;
}
.ai-expert-hint { font-size: 0.6875rem; color: var(--text-muted); }

.ai-expert-footer {
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--neutral-50);
  display: flex; justify-content: center;
}
.ai-expert-clear {
  background: none; border: none; cursor: pointer;
  font-size: 0.75rem; color: var(--text-muted);
  padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.ai-expert-clear:hover { color: var(--danger); background: var(--danger-soft); }

/* ============================================================
   STUDY PAGE HEADER (harmonized layout)
   ============================================================ */
.study-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0;
  margin-bottom: 1.5rem;
}
.study-page-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  flex: 1 1 280px;
  min-width: 0;
}
.study-page-header-left .btn-ghost {
  flex-shrink: 0;
  padding: 0.4375rem 0.625rem;
  margin-top: 0.125rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.study-page-header-left .btn-ghost:hover {
  color: var(--primary);
  background: var(--primary-bg);
}
.study-page-header-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.study-page-header-titles h2 {
  margin: 0;
  font-size: 1.625rem;
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  word-break: break-word;
}
.study-page-header-titles .page-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.study-page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  justify-content: flex-end;
}
.study-page-header-actions .btn {
  min-height: 36px;
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.4375rem 0.75rem;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .study-page-header-actions {
    width: 100%;
    justify-content: flex-start;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--border-subtle);
    margin-top: 0.25rem;
  }
  .study-page-header-actions .btn { flex: 1 1 auto; min-width: 110px; }
}
@media (max-width: 560px) {
  .study-page-header-titles h2 { font-size: 1.375rem; }
  .study-page-header-actions .btn { font-size: 0.75rem; padding: 0.375rem 0.5rem; }
}

/* ============================================================
   COMPUTED FIELDS in grouped_field_list (Excel-like yellow highlight)
   ============================================================ */
.gfl-item-computed {
  background: linear-gradient(90deg, rgba(254, 240, 138, 0.18) 0%, rgba(254, 240, 138, 0.06) 100%);
  border-left: 3px solid var(--accent-amber);
  padding-left: 0.625rem;
  margin-left: -0.625rem;
  border-radius: var(--radius-sm);
}
.gfl-input-computed {
  background: rgba(254, 240, 138, 0.28) !important;
  border-color: var(--accent-amber) !important;
  color: #92400e !important;
  font-weight: 600 !important;
  font-feature-settings: 'tnum';
  cursor: not-allowed;
}
.gfl-input-computed:focus {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18) !important;
  border-color: var(--accent-amber) !important;
}
.gfl-computed-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent-amber);
  background: rgba(254, 240, 138, 0.4);
  padding: 0.0625rem 0.375rem;
  border-radius: 999px;
  margin-left: 0.375rem;
  letter-spacing: 0.02em;
}

/* ============================================================
   GUIDE TABS (Guide / Instructions / Lexique)
   ============================================================ */
.guide-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border-subtle);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}
.guide-tab {
  background: transparent;
  border: none;
  padding: 0.75rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
}
.guide-tab:hover { color: var(--primary); background: var(--bg-hover); }
.guide-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-bg);
}

/* ============================================================
   LEXIQUE
   ============================================================ */
.lexique-toolbar {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.lexique-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lexique-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.lexique-list::-webkit-scrollbar { width: 8px; }
.lexique-list::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 4px; }
.lexique-item {
  padding: 0.875rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}
.lexique-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.lexique-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}
.lexique-num {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--neutral-100);
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  font-feature-settings: 'tnum';
}
.lexique-term {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 200px;
}
.lexique-cat {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.1875rem 0.5625rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--neutral-100);
  color: var(--text-secondary);
}
.lex-cat-g-n-ral, .lex-cat-general { background: var(--primary-bg); color: var(--primary-dark); }
.lex-cat-g-ologie, .lex-cat-geologie { background: #fef3c7; color: #92400e; }
.lex-cat-mine { background: #ffedd5; color: #9a3412; }
.lex-cat-traitement { background: #dbeafe; color: #1e40af; }
.lex-cat-finance { background: #d1fae5; color: #065f46; }
.lex-cat-environnement, .lex-cat-esg { background: #ecfccb; color: #3f6212; }
.lex-cat-juridique { background: #ede9fe; color: #5b21b6; }
.lex-cat-sociale, .lex-cat-social { background: #fce7f3; color: #9d174d; }
.lexique-def {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}
.lexique-sheets {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================
   LEXICON SIDE PANEL — accessible from inside any study
   ============================================================ */
.lexicon-floating-btn {
  /* Hidden — replaced by a button in the study header (see views.js studyWorkbenchView) */
  display: none !important;
}
.lexicon-floating-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.5);
}
.lexicon-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0); pointer-events: none;
  transition: background 0.3s ease;
  z-index: 1000;
}
.lexicon-backdrop.open { background: rgba(0, 0, 0, 0.35); pointer-events: auto; }
.lexicon-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 96vw;
  background: var(--bg-card, white);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1001;
  display: flex; flex-direction: column;
}
.lexicon-panel.open { transform: translateX(0); }
.lexicon-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}
.lexicon-header-title { display: flex; align-items: center; gap: 0.625rem; }
.lexicon-title { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.lexicon-subtitle { font-size: 0.75rem; opacity: 0.9; }
.lexicon-close {
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.lexicon-close:hover { background: rgba(255,255,255,0.25); }
.lexicon-filters {
  padding: 0.875rem 1.25rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
  background: var(--neutral-50, #f9fafb);
}
.lexicon-search, .lexicon-category {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-default, #d1d5db);
  border-radius: var(--radius-md, 8px);
  font-family: inherit; font-size: 0.875rem;
  background: white; color: var(--text-primary, #111);
}
.lexicon-search:focus, .lexicon-category:focus {
  outline: none; border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.lexicon-count {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem; font-weight: 600; color: var(--text-secondary, #6b7280);
  text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--neutral-50, #f9fafb);
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}
.lexicon-list {
  flex: 1; overflow-y: auto;
  padding: 0.625rem 1rem 1.25rem;
}
.lexicon-card {
  padding: 0.75rem 0.875rem; margin-bottom: 0.625rem;
  background: white; border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  transition: all 0.15s ease;
}
.lexicon-card:hover {
  border-color: #f59e0b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.lexicon-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.375rem;
}
.lexicon-term {
  font-weight: 700; font-size: 0.875rem;
  color: var(--text-primary, #111); flex: 1;
}
.lexicon-num {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-secondary, #6b7280);
  background: var(--neutral-100, #f3f4f6);
  padding: 2px 6px; border-radius: 4px;
  font-family: monospace;
}
.lexicon-def {
  font-size: 0.8125rem; line-height: 1.5;
  color: var(--text-secondary, #4b5563);
  margin-bottom: 0.5rem;
}
.lexicon-meta {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
  font-size: 0.6875rem;
}
.lexicon-cat {
  background: rgba(245, 158, 11, 0.12); color: #b45309;
  padding: 2px 8px; border-radius: 12px; font-weight: 600;
}
.lexicon-feuilles {
  background: var(--neutral-100, #f3f4f6); color: var(--text-secondary, #6b7280);
  padding: 2px 8px; border-radius: 12px;
}
.lexicon-empty {
  text-align: center; padding: 2rem 1rem;
  color: var(--text-secondary, #6b7280);
}

@media (max-width: 640px) {
  .lexicon-panel { width: 100vw; }
}
