/* Expenses Tracker — UI inspirée dashboard POS moderne (sidebar sombre + workspace clair) */

:root {
  --sidebar-bg: #172554;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-accent: #22c55e;
  --sidebar-border: rgba(96, 165, 250, 0.14);

  --workspace-bg: #f0f2f5;
  --workspace-card: #ffffff;
  --workspace-border: #e8ecf1;
  --text-card-accent-bar: linear-gradient(180deg, #3b82f6, #22c55e);
  --text-card-accent-bg: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.06) 0%,
    rgba(34, 197, 94, 0.05) 48%,
    var(--workspace-card) 100%
  );
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;

  --kpi-green: #22c55e;
  --kpi-green-bg: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  /* Global — vert sombre (cartes, graphiques, accents) */
  --kpi-global: #166534;
  --kpi-global-dark: #14532d;
  --kpi-global-bg: linear-gradient(135deg, #166534 0%, #14532d 100%);
  --accent-global: #166534;
  --accent-global-hover: #14532d;
  --accent-global-soft: rgba(22, 101, 52, 0.14);
  --accent-global-ring: rgba(22, 101, 52, 0.28);
  --lcl-blue: #244cb5;
  --lcl-blue-dark: #1e3d9e;
  --lcl-blue-hover: #2a55c9;
  --lcl-blue-soft: rgba(30, 61, 158, 0.14);
  --lcl-blue-ring: rgba(30, 61, 158, 0.28);
  --kpi-blue: #244cb5;
  --kpi-blue-bg: linear-gradient(135deg, #1e3d9e 0%, #244cb5 100%);
  --kpi-orange: #f59e0b;
  --kpi-orange-bg: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --brsma-purple: #512da8;
  --brsma-purple-dark: #452593;
  --brsma-purple-hover: #5c33bd;
  --brsma-purple-soft: rgba(81, 45, 168, 0.14);
  --brsma-purple-ring: rgba(81, 45, 168, 0.28);
  --kpi-purple: #512da8;
  --kpi-purple-bg: #512da8;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --radius: 12px;

  /* Grilles de cartes flexibles (plateforme) */
  --platform-card-min: 168px;
  --platform-card-min-wide: 280px;
  --platform-card-min-flex: 300px;
  --platform-card-gap: 0.85rem;

  /* Cartes graphiques (réf. Overview / Détails) */
  --chart-box-min-height: 300px;
  --chart-box-min-height-mobile: 240px;
  --chart-cards-grid-gap: 1.5rem;

  /* En-têtes de colonnes (tableaux) */
  --table-head-bg: #eef1f6;
}

[data-theme="dark"] {
  --workspace-bg: #0f1419;
  --workspace-card: #1a2332;
  --workspace-border: #2d3a4f;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --table-head-bg: #232f42;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  background: var(--sidebar-bg);
}

.app-body {
  background: var(--workspace-bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

/* Shell connecté : sidebar + workspace scrollent indépendamment */
body.app-shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

body.app-shell .sidebar {
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
  flex-shrink: 0;
}

body.app-shell .workspace {
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.app-shell .topbar {
  flex-shrink: 0;
  z-index: 30;
}

body.app-layout-wide.app-shell .main-content,
body.app-layout-wide.app-shell .topbar-inner {
  max-width: none;
}

body.app-layout-wide.app-shell .main-content {
  padding-left: clamp(1rem, 3vw, 2.5rem);
  padding-right: clamp(1rem, 3vw, 2.5rem);
}

body.app-shell .main-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ——— Sidebar ——— */
.sidebar {
  background: linear-gradient(180deg, #1e3a8a 0%, #172554 38%, #0f172a 100%);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  min-height: 100vh;
  transition: width 0.24s ease, min-width 0.24s ease;
  margin: 0 !important;
  padding-left: 0;
  left: 0;
  display: flex;
  flex-direction: column;
}

body.app-shell .sidebar {
  min-height: 0;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.55) rgba(15, 23, 42, 0.55);
}

.sidebar-nav::-webkit-scrollbar {
  width: 7px;
}

.sidebar-nav::-webkit-scrollbar-track {
  margin: 6px 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
}

.sidebar-nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.75), rgba(37, 99, 235, 0.55));
  border: 2px solid transparent;
  background-clip: padding-box;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.9), rgba(59, 130, 246, 0.75));
  background-clip: padding-box;
}

body.app-shell .main-content {
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: rgba(99, 102, 241, 0.55) rgba(226, 232, 240, 0.9);
}

body.app-shell .main-content::-webkit-scrollbar {
  width: 11px;
}

body.app-shell .main-content::-webkit-scrollbar-track {
  background: var(--workspace-bg);
  border-left: 1px solid var(--workspace-border);
}

body.app-shell .main-content::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.45);
  border: 3px solid var(--workspace-bg);
  background-clip: padding-box;
}

body.app-shell .main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.65);
  background-clip: padding-box;
}

[data-theme="dark"] body.app-shell .main-content {
  scrollbar-color: rgba(129, 140, 248, 0.55) rgba(15, 20, 25, 0.95);
}

[data-theme="dark"] body.app-shell .main-content::-webkit-scrollbar-track {
  background: var(--workspace-bg);
  border-left-color: var(--workspace-border);
}

[data-theme="dark"] body.app-shell .main-content::-webkit-scrollbar-thumb {
  border-color: var(--workspace-bg);
  background: rgba(129, 140, 248, 0.5);
  background-clip: padding-box;
}

/* Overlay mobile pour fermer la sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
}

body.sidebar-open {
  overflow: hidden;
}

/* ——— Floating assistant ——— */
.assist-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 70;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 14px 35px rgba(37, 99, 235, 0.25);
}

.assist-fab:hover {
  transform: translateY(-1px);
}

.assist-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 65;
}

.cmdk-dropdown {
  position: fixed;
  z-index: 90;
  border-radius: 14px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.cmdk-filter {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--workspace-border);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--workspace-card);
  color: var(--text);
  outline: none;
}

.cmdk-filter::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.cmdk-list {
  display: grid;
  max-height: 320px;
  overflow: auto;
}

.cmdk-item {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--workspace-border);
}

.cmdk-item:last-child {
  border-bottom: none;
}

.cmdk-item:hover,
.cmdk-item.is-active {
  background: rgba(99, 102, 241, 0.10);
}

.assist-panel {
  position: fixed;
  right: 18px;
  bottom: 92px;
  width: min(380px, calc(100vw - 36px));
  max-height: min(520px, calc(100vh - 150px));
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  z-index: 75;
}

.assist-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--workspace-border);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.10), rgba(99, 102, 241, 0.02));
}

.assist-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}

.assist-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.assist-close {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
}

.assist-body {
  padding: 0.9rem 1rem 1rem;
  overflow: auto;
  max-height: calc(520px - 64px);
}

.assist-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0.35rem 0 0.6rem;
}

.assist-body .assist-actions.mb-3 {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed var(--workspace-border);
}

.assist-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.assist-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: rgba(34, 197, 94, 0.08);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
}

.assist-action:hover {
  border-color: rgba(34, 197, 94, 0.35);
}

.assist-action-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}

.assist-action-danger:hover {
  border-color: rgba(239, 68, 68, 0.55);
}

.assist-tips {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--text-muted);
  font-size: 0.86rem;
}

body.assist-open {
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.85rem 0.9rem;
  border-bottom: 1px solid var(--sidebar-border);
  position: relative;
  flex-shrink: 0;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--sidebar-text-active);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sidebar-logo--img {
  object-fit: cover;
  background: transparent;
  flex-shrink: 0;
  border-radius: 50%;
}

.settings-logo-btn {
  padding: 0.25rem;
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.settings-logo-btn.is-active {
  border-color: var(--accent, #64748b);
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.25);
}

.settings-logo-btn img {
  display: block;
  border-radius: 6px;
}

.import-columns-hint {
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: var(--surface-muted, #f1f5f9);
}

.raw-import-feedback {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--workspace-bg);
}

.raw-import-feedback--ok {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.06);
}

.raw-import-feedback--warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.raw-import-feedback--info {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.06);
}

.raw-import-feedback-line {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.82rem;
  margin-top: 0.35rem;
}

.raw-import-feedback-line--ok {
  color: #15803d;
}

.raw-import-feedback-line--err,
.raw-import-feedback-line--dup {
  color: #b91c1c;
}

.raw-import-feedback-line--warn {
  color: #b45309;
}

.sidebar-brand-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: 0.7rem;
  color: var(--sidebar-text);
  opacity: 0.85;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle-btn {
  display: none;
  position: relative;
  top: auto;
  right: auto;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(148, 163, 184, 0.55);
}

@media (min-width: 768px) {
  .sidebar-toggle-btn {
    display: inline-flex;
  }
}

.nav-section {
  padding: 1rem 0.75rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.7);
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  margin: 0.1rem 0.5rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text-active);
}

.nav-link-active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--sidebar-accent);
}

.nav-link-active--lcl {
  background: rgba(30, 58, 138, 0.2);
  color: #93c5fd;
}

.nav-link-active--brsma {
  background: rgba(91, 33, 182, 0.2);
  color: #c4b5fd;
}

.nav-icon {
  width: 1.25rem;
  flex-shrink: 0;
  text-align: center;
  opacity: 0.9;
  font-size: 1rem;
}

.nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem 1.15rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.sidebar-footer-label {
  margin: 0 0 0.55rem;
  padding: 0 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.9);
}

.sidebar-account-menu {
  position: relative;
}

.sidebar-user-chip {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 0.42rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.sidebar-user-chip:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-chip-label {
  flex: 1;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 600;
}

.sidebar-account-menu .user-menu-panel,
.sidebar-user-menu-panel {
  right: 0;
  left: 0;
  bottom: calc(100% + 0.5rem);
  top: auto;
  width: 100%;
  z-index: 90;
  border-color: rgba(148, 163, 184, 0.35);
  background: #1e293b;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

.sidebar-user-menu-panel .user-menu-head {
  border-bottom-color: rgba(148, 163, 184, 0.25);
}

.sidebar-user-menu-panel .user-menu-name,
.sidebar-user-menu-panel .user-menu-email {
  color: #f1f5f9;
}

.sidebar-user-menu-panel .user-menu-provider {
  color: #94a3b8;
}

.sidebar-user-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem 0.85rem;
}

.sidebar-user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  color: #e2e8f0;
  border: 1px solid transparent;
}

.sidebar-user-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(148, 163, 184, 0.25);
}

.sidebar-user-menu-item--logout {
  margin-top: 0.25rem;
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.sidebar-user-menu-item--logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
}

/* Sidebar pliée (desktop) */
@media (min-width: 768px) {
  .sidebar .sidebar-brand-title,
  .sidebar .sidebar-brand-sub,
  .sidebar .nav-section,
  .sidebar .sidebar-footer .min-w-0,
  .sidebar .sidebar-footer .sidebar-logout {
    transition: opacity 0.18s ease;
  }

  body.sidebar-collapsed .sidebar {
    width: 76px !important;
    min-width: 76px;
  }

  body.sidebar-collapsed .sidebar-brand {
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 0.95rem 0.45rem 3.1rem;
  }

  body.sidebar-collapsed .sidebar-brand-link {
    justify-content: center;
    flex: 0 0 auto;
    width: 100%;
  }

  body.sidebar-collapsed .sidebar-brand-title,
  body.sidebar-collapsed .sidebar-brand-sub,
  body.sidebar-collapsed .nav-section,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-user-chip-label,
  body.sidebar-collapsed .sidebar-footer-label,
  body.sidebar-collapsed .sidebar-snapshot-label {
    display: none !important;
  }

  /* Abrégés visibles quand la sidebar est repliée (TDB / VE) */
  body.sidebar-collapsed .nav-section-peek {
    display: block !important;
    margin: 0.35rem 0.4rem 0.15rem;
    padding: 0.2rem 0;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: center;
    color: rgba(148, 163, 184, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.sidebar-collapsed .nav-section-peek::before {
    content: attr(data-peek);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.06em;
  }

  body.sidebar-collapsed .nav-section-peek {
    font-size: 0;
    color: transparent;
  }

  body.sidebar-collapsed .nav-link-overview.nav-link-active {
    box-shadow: inset 3px 0 0 #38bdf8;
    background: rgba(56, 189, 248, 0.12);
  }

  body.sidebar-collapsed .nav-link-overview.nav-link-active--lcl {
    box-shadow: inset 3px 0 0 #3b82f6;
    background: rgba(59, 130, 246, 0.15);
  }

  body.sidebar-collapsed .nav-link-overview.nav-link-active--brsma {
    box-shadow: inset 3px 0 0 #8b5cf6;
    background: rgba(139, 92, 246, 0.15);
  }

  body.sidebar-collapsed .sidebar-user-chip {
    justify-content: center;
    border-radius: 12px;
    padding: 0.42rem;
  }

  body.sidebar-collapsed .sidebar-user-chip .user-chip-caret {
    display: none;
  }

  body.sidebar-collapsed .sidebar-account-menu .user-menu-panel {
    left: calc(100% + 0.5rem);
    right: auto;
    bottom: 0;
    width: min(290px, 84vw);
  }

  body.sidebar-collapsed .nav-link {
    justify-content: center;
    gap: 0;
    margin: 0.12rem 0.35rem;
    padding: 0.62rem 0;
    border-left-width: 0 !important;
  }

  body.sidebar-collapsed .nav-link-active {
    box-shadow: inset 3px 0 0 var(--sidebar-accent);
    background: rgba(34, 197, 94, 0.18);
  }

  body.sidebar-collapsed .nav-link-sub {
    padding-left: 0;
  }

  body.sidebar-collapsed .nav-icon {
    width: auto;
    font-size: 1.15rem;
  }

  body.sidebar-collapsed .sidebar-snapshot-link {
    justify-content: center;
    margin-left: 0.35rem;
    margin-right: 0.35rem;
    padding: 0.5rem;
  }

  body.sidebar-collapsed .sidebar-snapshot-icon {
    font-size: 1.1rem;
  }

  body.sidebar-collapsed .sidebar-footer {
    padding: 0.65rem 0.35rem 0.85rem;
  }

  body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    margin-bottom: 0;
  }

  body.sidebar-collapsed .sidebar-toggle-btn {
    position: absolute;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: auto;
    bottom: 0.75rem;
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logout {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.75rem;
}

.sidebar-logout:hover {
  text-decoration: underline;
}

/* ——— Topbar (workspace) ——— */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--workspace-bg);
  transition: margin-left 0.24s ease;
}

.topbar {
  background: var(--workspace-card);
  border-bottom: 1px solid var(--workspace-border);
  min-height: 64px;
  padding: 0.65rem 1.25rem;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.topbar-start {
  min-width: 0;
}

.topbar-center {
  min-width: 0;
  width: 100%;
  max-width: none;
  justify-self: stretch;
}

.topbar-center-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.topbar-end {
  justify-self: end;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  isolation: isolate;
}

.topbar-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.6rem;
}

.topbar-source-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--workspace-border);
}

.topbar-source-pill--global {
  color: #14532d;
  background: rgba(22, 101, 52, 0.12);
  border-color: rgba(22, 101, 52, 0.35);
}

.topbar-source-pill--lcl {
  color: var(--lcl-blue-dark);
  background: var(--lcl-blue-soft);
  border-color: rgba(30, 58, 138, 0.35);
}

.topbar-source-pill--brsma {
  color: var(--brsma-purple-dark);
  background: var(--brsma-purple-soft);
  border-color: rgba(91, 33, 182, 0.38);
}

.topbar-toolbar-primary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-filter-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.topbar-source-switcher {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 22rem;
  padding: 0.2rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
  gap: 0.2rem;
}

.topbar-source-switcher .btn {
  flex: 1 1 0;
  min-width: 5.5rem;
  justify-content: center;
  border-radius: 9px;
  font-weight: 600;
  padding: 0.45rem 1rem;
}

.topbar-toolbar-split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.topbar-toolbar-split .topbar-source-switcher {
  flex: 1 1 14rem;
  max-width: 20rem;
}

.topbar-toolbar-split .topbar-filter-shortcuts {
  flex: 0 0 auto;
  margin-left: auto;
}

.topbar-toolbar-secondary {
  flex: 1 1 100%;
}

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

.topbar-global-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 220px;
  min-width: 0;
  min-height: 42px;
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-global-search:focus-within {
  border-color: rgba(99, 102, 241, 0.55);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.topbar-global-search-icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  opacity: 0.75;
  line-height: 1;
}

.topbar-global-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
}

.topbar-global-search-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-global-search-clear {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.topbar-global-search-clear:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.topbar-global-search-submit {
  flex-shrink: 0;
  height: 34px;
  padding: 0 0.9rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.topbar-global-search-submit:hover {
  filter: brightness(1.05);
}

/* ——— Recherche globale (autocomplétion) ——— */
.global-search-dropdown {
  position: fixed;
  z-index: 120;
  border-radius: 14px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  max-height: min(70vh, 420px);
  overflow: hidden;
}

.global-search-dropdown-inner {
  max-height: min(70vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.35rem 0;
}

.global-search-group-label {
  padding: 0.45rem 0.85rem 0.25rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.global-search-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.global-search-item:hover,
.global-search-item.is-active {
  background: rgba(67, 154, 134, 0.1);
}

.global-search-item-label {
  font-size: 0.84rem;
  font-weight: 700;
}

.global-search-item-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.global-search-empty {
  margin: 0;
  padding: 0.75rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.search-page-header .topbar-global-search {
  width: 100%;
  max-width: 720px;
}

.search-page-toolbar {
  padding: 0.15rem 0 0.35rem;
}

.search-page-meta {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.search-page-toolbar-hint {
  line-height: 1.4;
}

.search-result-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.search-result-source {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  line-height: 1.3;
}

.search-result-source--lcl {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.search-result-source--brsma {
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
}

.search-result-item--transaction .search-result-desc {
  font-variant-numeric: tabular-nums;
}

.search-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--workspace-border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.search-result-item:hover {
  background: rgba(67, 154, 134, 0.08);
  border-color: rgba(67, 154, 134, 0.35);
}

.search-result-label {
  font-weight: 700;
  font-size: 0.88rem;
}

.search-result-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-shortcuts {
  display: none;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.topbar-icon-btn:hover {
  border-color: rgba(59, 130, 246, 0.45);
  color: #2563eb;
  background: rgba(59, 130, 246, 0.06);
}

.topbar-kbd {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.topbar-jump {
  display: none;
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

.topbar-jump-select {
  width: 100%;
  min-height: 42px;
  padding: 0 2rem 0 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.topbar-jump-select:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.55);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

@media (min-width: 900px) {
  .topbar-shortcuts {
    display: inline-flex;
  }

  .topbar-kbd {
    display: inline-flex;
  }

  .topbar-jump {
    display: block;
  }

  .topbar-toolbar-secondary {
    flex: 0 1 280px;
    max-width: 320px;
  }
}

@media (min-width: 1200px) {
  .topbar-center-inner {
    flex-wrap: nowrap;
    max-width: 960px;
    margin: 0 auto;
  }

  .topbar-toolbar-primary {
    flex: 1 1 auto;
  }

  .topbar-toolbar-secondary {
    flex: 0 0 280px;
    max-width: 300px;
  }
}

@media (max-width: 899px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "start end"
      "center center";
  }

  .topbar-start {
    grid-area: start;
  }

  .topbar-center {
    grid-area: center;
    justify-self: stretch;
  }

  .topbar-center-inner {
    flex-wrap: wrap;
  }

  .topbar-end {
    grid-area: end;
  }

  .topbar-global-search {
    flex: 1 1 100%;
  }

  .topbar-global-search-submit {
    padding: 0 0.65rem;
    font-size: 0;
    width: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.1a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
  }
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

.topbar-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.5rem 0.65rem;
  max-width: min(100%, 420px);
}

/* Bandeau compact 6 vues */
.views-hub-compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
}

.assist-panel .views-hub-compact {
  margin-bottom: 0.75rem;
  padding: 0.5rem;
}

.views-hub-compact-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.views-hub-compact-link:hover {
  text-decoration: none;
  background: var(--workspace-bg);
  color: var(--text);
}

.views-hub-compact-link.is-active {
  font-weight: 700;
}

.views-hub-compact-link--global.is-active {
  color: #14532d;
  background: rgba(22, 101, 52, 0.12);
  border-color: rgba(22, 101, 52, 0.3);
}

.views-hub-compact-link--lcl.is-active {
  color: var(--lcl-blue-dark);
  background: var(--lcl-blue-soft);
  border-color: rgba(30, 58, 138, 0.3);
}

.views-hub-compact-link--brsma.is-active {
  color: var(--brsma-purple-dark);
  background: var(--brsma-purple-soft);
  border-color: rgba(91, 33, 182, 0.32);
}

.views-hub-compact-sep {
  grid-column: 1 / -1;
  width: 100%;
  height: 1px;
  margin: 0.1rem 0;
  background: var(--workspace-border);
}

.page-hint {
  margin: 0;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(22, 101, 52, 0.08);
  border: 1px solid rgba(22, 101, 52, 0.22);
}

.source-theme-global .page-hint {
  color: #166534;
}

.page-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.page-footer-links a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.page-footer-links a:hover {
  text-decoration: underline;
}

.page-footer-links-sep {
  opacity: 0.45;
}

.filter-panel {
  border: 1px solid var(--workspace-border);
  border-radius: 14px;
  overflow: visible;
}

.filter-panel .filter-card {
  overflow: visible;
}

.filter-panel-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--text);
  background: var(--workspace-bg);
}

.filter-panel-summary::-webkit-details-marker {
  display: none;
}

.filter-panel-summary::before {
  content: "▸";
  margin-right: 0.35rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.filter-panel[open] .filter-panel-summary::before {
  transform: rotate(90deg);
}

.filter-panel-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--workspace-card);
  border: 1px solid var(--workspace-border);
}

.filter-panel-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--workspace-border);
}

.filter-panel-body .filter-cards-grid {
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .views-hub-compact-link {
    font-size: 0.65rem;
    padding: 0.38rem 0.35rem;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 0.5rem 0.65rem;
  }

  .topbar-start {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-end {
    grid-column: 2;
    grid-row: 1;
  }

  .topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
    order: unset;
  }

  .topbar-global-search {
    width: 100%;
  }

  .topbar-global-search-input {
    width: 100%;
    max-width: none;
  }

  .page-toolbar-filter-btn .filter-panel-badge--inline {
    display: none;
  }

  .page-tabs--source .page-tab {
    min-width: 0;
    padding: 0.52rem 0.65rem;
    font-size: 0.78rem;
  }

  .page-tabs--source .page-tab-icon {
    font-size: 0.85rem;
  }

  .topbar-source-switcher {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .topbar-source-switcher .btn {
    min-width: 0;
    padding: 0.42rem 0.55rem;
    font-size: 0.75rem;
  }

  .topbar-toolbar-split {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-toolbar-split .topbar-filter-shortcuts {
    margin-left: 0;
    justify-content: flex-end;
  }

  .planner-tabbar .planner-tab {
    flex: 1 1 calc(50% - 0.2rem);
    min-width: calc(50% - 0.2rem);
    font-size: 0.74rem;
    padding: 0.5rem 0.55rem;
  }
}

.topbar-search {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.18rem 0.25rem 0.18rem 0.18rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
}

.topbar-search-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 800;
}

.topbar-search-input {
  width: 220px;
  max-width: 260px;
  height: 34px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  padding-right: 0.6rem;
}

.topbar-search-input::placeholder {
  color: var(--text-muted);
  font-weight: 600;
}

.topbar-jump {
  margin-right: 0.25rem;
}

.topbar-jump-select {
  min-width: 210px;
  max-width: 260px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
  color: var(--text);
  padding: 0 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
}

.topbar-jump-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.14);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  background: var(--workspace-bg);
  border: 1px solid var(--workspace-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

.topbar-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.topbar-logout-btn:hover {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.topbar-bell-btn,
.topbar-settings-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  cursor: pointer;
  font-size: 1.05rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.topbar-settings-btn:hover {
  border-color: var(--accent);
  background: var(--workspace-hover);
}

.notif-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--workspace-card);
}

.notif-menu {
  position: relative;
}

.notif-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(340px, 88vw);
  border-radius: 16px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.22);
  z-index: 80;
  overflow: hidden;
}

.notif-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border-bottom: 1px solid var(--workspace-border);
}

.notif-menu-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}

.notif-menu-link {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
}

.notif-list {
  display: grid;
}

.notif-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.75rem 0.95rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--workspace-border);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: rgba(99, 102, 241, 0.08);
}

.notif-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.12);
  font-size: 0.88rem;
}

.notif-item strong {
  display: block;
  font-size: 0.84rem;
  line-height: 1.3;
}

.notif-item small {
  display: block;
  margin-top: 0.18rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.user-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-menu {
  position: relative;
}

.user-chip-btn {
  border: 1px solid var(--workspace-border);
  cursor: pointer;
}

.user-chip-caret {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, 92vw);
  border-radius: 16px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.22);
  z-index: 80;
  overflow: hidden;
}

.user-menu-head {
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--workspace-border);
}

.user-menu-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.user-menu-email {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--text);
}

.user-menu-provider {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.user-menu-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.8rem 1rem 1rem;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  text-decoration: none;
  font-weight: 800;
  color: var(--text);
}

.user-menu-logout:hover {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.badge-duck {
  font-size: 0.65rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  background: rgba(255, 170, 0, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge-duck {
  color: #fbbf24;
  background: rgba(255, 170, 0, 0.15);
}

/* ——— Controls (FR/EN + Light/Dark) ——— */
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.segmented {
  display: flex;
  align-items: center;
  padding: 0.18rem;
  border-radius: 14px;
  border: 1px solid var(--workspace-border);
  background: rgba(255, 255, 255, 0.04);
}

.segmented-lang .seg-btn {
  width: 46px;
  padding: 0.35rem 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.segmented-lang .seg-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.segmented-lang .seg-btn-active {
  background: rgba(134, 239, 172, 0.55);
  color: #15803d;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.25);
}

[data-theme="dark"] .segmented-lang .seg-btn-active {
  background: rgba(34, 197, 94, 0.22);
  color: #86efac;
}

.theme-toggle-form {
  margin: 0;
}

.theme-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--workspace-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: background 0.15s, border-color 0.15s;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(34, 197, 94, 0.35);
}

/* ——— Main content ——— */
.main-content {
  flex: 1;
  padding: 1.5rem;
  overflow: auto;
}

@media (max-width: 768px) {
  body.app-shell .main-content {
    padding: 1rem;
  }

  .bank-data-page {
    display: flex;
    flex-direction: column;
  }

  .bank-data-page > .filter-panel {
    order: 50;
  }

  .bank-data-page > .page-toolbar,
  .bank-data-page > .raw-page-toolbar,
  .bank-data-page > .filter-chips-bar,
  .bank-data-page > .page-hint,
  .bank-data-page > .dashboard-quick-links {
    order: 1;
  }

  .bank-data-page > .raw-scope-bar,
  .bank-data-page > .bank-section,
  .bank-data-page > .dashboard-global-section,
  .bank-data-page > .overview-standard-block,
  .bank-data-page > .table-pagination-bar,
  .bank-data-page > .widget,
  .bank-data-page > section {
    order: 10;
  }

  .filter-chips-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .filter-chips-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-chips-bar .chip-set {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
  }

  .filter-chips-bar .chip {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .dashboard-quick-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .dashboard-quick-links .btn {
    width: 100%;
    justify-content: center;
  }

  .chart-box {
    min-height: var(--chart-box-min-height-mobile);
    height: var(--chart-box-min-height-mobile);
    max-height: var(--chart-box-min-height-mobile);
  }

  .kpi-grid--gradient {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .raw-scope-bar .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  body.app-shell.sidebar-open .main-content {
    overflow: hidden;
  }
}

/* Recherche globale : intégrée dans .topbar-global-search */

/* ——— Fil d'Ariane (masqué — navigation sidebar + titre suffisent) ——— */
.breadcrumbs {
  display: none !important;
}

.breadcrumbs-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumbs-link:hover {
  text-decoration: underline;
}

.breadcrumbs-sep {
  opacity: 0.45;
  user-select: none;
}

.breadcrumbs-current {
  color: var(--text);
  font-weight: 700;
}

.breadcrumbs-part {
  color: var(--text-muted);
  font-weight: 600;
}

.flash-alert {
  position: relative;
  padding-right: 2.5rem;
}

.flash-dismiss {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  border: none;
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.65;
}

.flash-dismiss:hover {
  opacity: 1;
}

.flash-alert.is-hiding {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-top-btn {
  position: fixed;
  right: 1.35rem;
  bottom: 5.5rem;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.scroll-top-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.scroll-top-btn.hidden {
  display: none;
}

.wiki-cta {
  background: var(--text-card-accent-bg);
}

.wiki-cta-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wiki-cta-text {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.empty-state {
  max-width: 520px;
  margin: 2rem auto;
}

.empty-state-icon {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.empty-state-message {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.error-page .error-code {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
}

.workspace-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.workspace-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.workspace-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.workspace-footer-links a:hover {
  color: var(--accent);
}

.platform-footer-bar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  color: var(--text-muted);
  font-size: 0.74rem;
  text-align: center;
}

.platform-footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.platform-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.platform-footer-links a:hover {
  color: var(--accent-primary, var(--accent));
}

/* Hero accueil */
.home-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--workspace-border);
  border-radius: 16px;
  background: var(--text-card-accent-bg);
}

.home-hero-body {
  position: relative;
  z-index: 1;
  padding: 1.35rem 1.5rem 1.35rem 1.65rem;
}

.home-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.home-hero-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.home-hero-stat strong {
  color: var(--text);
  font-weight: 700;
}

.home-hero-stat--lcl {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.06);
}

.home-hero-stat--brsma {
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.08);
}

.topbar-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
  color: var(--text-muted);
  font-weight: 800;
  text-decoration: none;
}

.topbar-help-btn:hover {
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--accent);
}

.topbar-help-btn--desktop {
  display: none;
}

@media (min-width: 768px) {
  .topbar-help-btn--desktop {
    display: inline-flex;
  }
}

.login-shell {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.login-topbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.login-pref-form {
  margin: 0;
}

.home-page .section-title,
.wiki-page .section-title {
  margin: 0 0 1rem;
}

.wiki-intro {
  background: var(--text-card-accent-bg);
}

.wiki-intro-title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.wiki-intro-text {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.wiki-card .flex-card-desc {
  min-height: 3.25rem;
}

.welcome-banner {
  background: var(--text-card-accent-bg);
  border: 1px solid var(--workspace-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.welcome-banner h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.welcome-banner p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ——— Cartes texte : barre dégradée bleu → vert ——— */
.text-card-accent,
.flex-card,
.home-workflow-step,
.home-guide-section,
.views-hub,
.wiki-intro,
.wiki-cta,
.welcome-banner,
.settings-card,
.about-card,
.about-app-card,
.about-section-card,
.filter-card,
.search-page-header,
.search-group,
.search-suggestions,
.search-empty,
.advanced-scope-bar,
.empty-state {
  position: relative;
  overflow: hidden;
  background: var(--text-card-accent-bg);
}

.text-card-accent::before,
.flex-card::before,
.home-workflow-step::before,
.home-guide-section::before,
.views-hub::before,
.wiki-intro::before,
.wiki-cta::before,
.welcome-banner::before,
.settings-card::before,
.about-card::before,
.about-app-card::before,
.about-section-card::before,
.filter-card::before,
.search-page-header::before,
.search-group::before,
.search-suggestions::before,
.search-empty::before,
.advanced-scope-bar::before,
.empty-state::before,
.home-hero::before {
  display: none;
}

.flex-card::before {
  border-radius: 14px 0 0 14px;
}

.home-workflow-step::before,
.filter-card::before,
.advanced-scope-bar::before {
  border-radius: var(--radius-md, 10px) 0 0 var(--radius-md, 10px);
}

.home-guide-section::before,
.views-hub::before,
.settings-card::before,
.about-card::before,
.about-app-card::before,
.about-section-card::before,
.search-page-header::before,
.search-group::before,
.search-suggestions::before,
.search-empty::before,
.wiki-intro::before,
.wiki-cta::before,
.welcome-banner::before,
.empty-state::before {
  border-radius: 12px 0 0 12px;
}

.flex-card > *,
.home-workflow-step > *,
.home-workflow-step-body,
.views-hub > *,
.settings-card > *,
.filter-card > * {
  position: relative;
  z-index: 1;
}

/* ——— Flexible cards (repository-style) ——— */
.flex-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min-flex)), 1fr));
  gap: var(--platform-card-gap);
  align-items: stretch;
}

.flex-card {
  border: 1px solid var(--workspace-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.flex-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.flex-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.flex-card-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text);
}

.flex-card-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.flex-card-status {
  font-size: 0.78rem;
  font-weight: 700;
  color: #3b82f6;
}

.flex-card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  flex: 1 1 auto;
}

.flex-card-statline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.flex-card-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.flex-card-stat strong {
  color: var(--text);
  font-weight: 800;
}

.flex-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.flex-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.46rem;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.08);
  color: #60a5fa;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.flex-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.flex-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
}

/* ——— KPI cards (colorées) ——— */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min)), 1fr));
  gap: var(--platform-card-gap);
  align-items: stretch;
}

/* Dashboard LCL/BRSMA : grille fluide (plus de colonnes figées) */
.bank-section .kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 0.75rem;
}

.kpi-card {
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  color: #fff;
  background: var(--kpi-global-bg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  min-height: 96px;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.kpi-card--green { background: var(--kpi-green-bg); }
.kpi-card--blue { background: var(--kpi-blue-bg); }
.kpi-card--orange { background: var(--kpi-orange-bg); }
.kpi-card--purple { background: var(--kpi-purple-bg); }

/* Sans modificateur explicite : ardoise Global (LCL/BRSMA via classes ou source-theme) */
.kpi-grid > .kpi-card:not(.kpi-card--green):not(.kpi-card--blue):not(.kpi-card--orange):not(.kpi-card--purple) {
  background: var(--kpi-global-bg);
}

.kpi-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.kpi-card-icon {
  font-size: 1.5rem;
  opacity: 0.95;
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.92;
}

.kpi-value {
  font-size: 1.38rem;
  font-weight: 700;
  margin: 0.25rem 0 0;
  line-height: 1.2;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.kpi-foot {
  font-size: 0.7rem;
  opacity: 0.88;
  margin-top: 0.35rem;
}

.kpi-period,
.stat-period {
  font-size: 0.65rem;
  line-height: 1.35;
  opacity: 0.82;
  margin: 0.35rem 0 0;
  font-weight: 500;
}

.kpi-card--green .kpi-period,
.kpi-card--blue .kpi-period,
.kpi-card--orange .kpi-period,
.kpi-card--purple .kpi-period,
.source-theme-lcl .kpi-grid > .kpi-card .kpi-period,
.source-theme-brsma .kpi-grid > .kpi-card .kpi-period,
.source-theme-global .kpi-grid > .kpi-card .kpi-period {
  opacity: 0.9;
}

.stat-period {
  margin-top: 0.25rem;
}

.home-hero-period {
  display: block;
  font-size: 0.65rem;
  opacity: 0.75;
  font-weight: 500;
  margin-top: 0.15rem;
}

@media (max-width: 620px) {
  .bank-section .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .bank-section .kpi-card {
    min-height: 84px;
    padding: 0.65rem 0.75rem;
  }

  .bank-section .kpi-value {
    font-size: 1.05rem;
  }

  .bank-section .kpi-card-icon {
    font-size: 1.15rem;
  }

  .bank-section .kpi-foot {
    display: none;
  }

  .bank-section .kpi-period {
    display: block;
    font-size: 0.58rem;
    margin-top: 0.2rem;
  }
}

/* ——— Planner (contexte Global via .source-theme-global) ——— */
.planner-page .planner-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min)), 1fr));
  gap: 0.65rem;
  align-items: stretch;
}

.planner-page .planner-kpi-grid.planner-kpi-grid--2 {
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.planner-page .planner-kpi-grid.planner-kpi-grid--3 {
  grid-template-columns: 1fr;
}

.planner-page .planner-kpi-grid.planner-kpi-grid--4 {
  grid-template-columns: 1fr;
}

@media (min-width: 520px) {
  .planner-page .planner-kpi-grid.planner-kpi-grid--3,
  .planner-page .planner-kpi-grid.planner-kpi-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 640px) {
  .planner-page .planner-kpi-grid.planner-kpi-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .planner-page .planner-kpi-grid.planner-kpi-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .planner-page .planner-kpi-grid.planner-kpi-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.planner-page .planner-classic-card {
  min-width: 0;
}

.planner-page .planner-classic-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 1rem;
}

.planner-page .planner-classic-table {
  width: 100%;
  min-width: 0;
  font-size: 0.84rem;
}

.planner-page .planner-classic-table thead th {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--workspace-border);
  background: var(--table-head-bg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.planner-page .planner-classic-table tbody td {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--workspace-border);
  vertical-align: top;
}

.planner-page .planner-classic-table tbody td:first-child {
  font-weight: 600;
  color: var(--text);
  text-align: left;
  line-height: 1.35;
  word-break: break-word;
  padding-right: 0.75rem;
}

.planner-page .planner-classic-table tbody td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.planner-page .planner-classic-input-cell {
  padding-left: 0.35rem;
}

.planner-page .planner-classic-input {
  width: 100%;
  max-width: 8.5rem;
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  font-size: 0.84rem;
}

.planner-page .planner-classic-toolbar .input {
  min-width: 9rem;
}

.planner-page .planner-goals-classic-form .page-hint,
.planner-page .planner-classic-form .page-hint {
  font-size: 0.82rem;
}

.planner-page .planner-classic-table tbody tr:last-child td {
  border-bottom: none;
}

.planner-page .planner-classic-table tfoot td {
  padding: 0.65rem 0 0;
  border-top: 2px solid var(--workspace-border);
  border-bottom: none;
  font-weight: 700;
  color: var(--text);
  font-size: 0.86rem;
}

.planner-page .planner-classic-table tfoot td:first-child {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.planner-page .planner-classic-kpis .kpi-card {
  min-height: 76px;
}

.planner-page .planner-classic-card.widget {
  padding: 0;
  min-width: 0;
  overflow: hidden;
}

.planner-page .planner-classic-card .widget-header {
  padding: 0.85rem 1rem;
}

.planner-page .planner-classic-card-body {
  padding: 0 1rem 1rem;
  min-width: 0;
}

.planner-page .planner-classic-facts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.planner-page .planner-classic-fact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
  align-items: baseline;
  column-gap: 1rem;
  row-gap: 0.25rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--workspace-border);
  font-size: 0.84rem;
  line-height: 1.35;
}

.planner-page .planner-classic-fact:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.planner-page .planner-classic-fact-label {
  min-width: 0;
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

.planner-page .planner-classic-fact-value {
  justify-self: end;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.planner-page .planner-classic-longterm {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.planner-page .planner-classic-cards {
  margin-bottom: 1.25rem;
}

@media (max-width: 639px) {
  .planner-page .planner-classic-charts {
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .planner-page .planner-classic-charts .chart-box {
    min-height: var(--chart-box-min-height-mobile);
    height: var(--chart-box-min-height-mobile);
    max-height: var(--chart-box-min-height-mobile);
  }

  .planner-page .planner-classic-table-wrap,
  .planner-page .planner-classic-card-body {
    padding: 0 0.85rem 0.85rem;
  }

  .planner-page .planner-classic-fact {
    grid-template-columns: 1fr;
    row-gap: 0.15rem;
  }

  .planner-page .planner-classic-fact-value {
    justify-self: start;
    text-align: left;
  }

  .planner-page .planner-classic-input {
    max-width: 100%;
  }
}

.planner-page .planner-goals-form {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 0.65rem;
}

.planner-page .planner-section-head {
  margin-bottom: 0.85rem;
}

.planner-page .planner-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.planner-page .planner-section-divider {
  margin: 1.75rem 0 1.25rem;
  border: 0;
  border-top: 1px solid var(--workspace-border);
}

.planner-page .planner-goals-classic-form .page-hint {
  font-size: 0.82rem;
}

.planner-page .planner-alerts-table tbody td.num {
  font-variant-numeric: tabular-nums;
}

.planner-page .planner-alerts-input-cell {
  padding-left: 0.35rem;
}

.planner-page .planner-alerts-input {
  width: 100%;
  max-width: 7.5rem;
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  font-size: 0.84rem;
}

.planner-page .planner-comparator-months {
  max-width: 52rem;
}

@media (min-width: 480px) {
  .planner-page .planner-comparator-months {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .planner-page .planner-comparator-months {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.planner-page .planner-comparator-form .btn-primary {
  margin-top: 0.15rem;
}

.planner-page .planner-kpi-grid .kpi-card {
  min-height: 88px;
  min-width: 0;
  padding: 0.85rem 0.95rem;
}

.planner-page .planner-kpi-grid .kpi-label {
  font-size: 0.65rem;
  line-height: 1.35;
  word-break: break-word;
  hyphens: auto;
}

.planner-page .planner-kpi-grid .kpi-value {
  font-size: clamp(1rem, 4.2vw, 1.35rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.planner-page .planner-kpi-highlight {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0.75rem;
  padding: 1rem 1.1rem;
}

.planner-page .planner-kpi-highlight .kpi-label,
.planner-page .planner-kpi-highlight .kpi-value {
  color: #fff;
}

.planner-page .planner-kpi-highlight .kpi-value {
  font-size: clamp(1.1rem, 5vw, 1.45rem);
}

.planner-page .planner-rec-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}

.planner-page .planner-rec-list li.card {
  margin: 0;
  padding: 0.85rem 1rem;
  background: var(--workspace-card);
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.planner-page .planner-hint {
  padding: 0 0.1rem;
  line-height: 1.5;
}

.planner-page .planner-kpi-grid .kpi-status {
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.25;
}

@media (max-width: 519px) {
  .planner-page #planner-targeted-sim .flex.flex-wrap.items-center {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .planner-page #planner-targeted-sim .flex.flex-wrap.items-center .min-w-\[8rem\] {
    min-width: 0;
  }

  .planner-page #planner-targeted-sim .flex.flex-wrap.items-center input[type="range"] {
    width: 100%;
    min-width: 0;
  }
}

.planner-tabbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
  gap: 0.35rem;
  padding: 0.28rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  background: var(--workspace-bg);
}

.planner-tabbar .planner-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 6.75rem;
  max-width: 100%;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 650;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  text-align: center;
  box-shadow: none;
  transform: none;
}

.planner-tabbar .planner-tab:hover {
  color: var(--text);
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(148, 163, 184, 0.2);
  transform: none;
}

.planner-tabbar .planner-tab.planner-tab-active,
.planner-page.source-theme-global .planner-tabbar .planner-tab.planner-tab-active {
  color: #fff;
  background: linear-gradient(135deg, #14532d, #166534);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.28);
}

.planner-tabbar .planner-tab.btn-secondary {
  background: transparent;
  border: none;
  color: var(--text-muted);
}

.planner-tabbar .planner-tab.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #14532d, #166534);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.28);
}

[data-theme="dark"] .planner-tabbar {
  border-color: rgba(148, 163, 184, 0.16);
}

[data-theme="dark"] .planner-tabbar .planner-tab:hover {
  border-color: rgba(148, 163, 184, 0.16);
}

.planner-page .kpi-status {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-top: 0.6rem;
  border: 1px solid transparent;
  position: relative;
  z-index: 1;
}

.planner-page .kpi-status.is-good {
  color: #166534;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(22, 163, 74, 0.35);
}

.planner-page .kpi-status.is-warn {
  color: #92400e;
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.35);
}

.planner-page .kpi-status.is-alert {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

/* Cartes KPI vertes : pastilles opaques lisibles sur fond sombre */
.planner-page .kpi-card .kpi-status.is-good {
  color: #14532d;
  background: #ecfdf5;
  border-color: #86efac;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}

.planner-page .kpi-card .kpi-status.is-warn {
  color: #78350f;
  background: #fef3c7;
  border-color: #fbbf24;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}

.planner-page .kpi-card .kpi-status.is-alert {
  color: #fff;
  background: #dc2626;
  border-color: #fca5a5;
  box-shadow: 0 1px 4px rgba(127, 29, 29, 0.35);
}

/* ——— Planificateur : tableau Détails ——— */
.planner-details-toolbar {
  padding: 0 0.15rem;
}

.planner-details-panel {
  max-height: min(36rem, 62vh);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
}

.planner-details-table {
  table-layout: fixed;
  width: 100%;
  min-width: 72rem;
  font-size: 0.78rem;
}

.planner-details-table th {
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--table-head-bg);
  box-shadow: 0 1px 0 var(--workspace-border);
}

.planner-details-table td {
  vertical-align: middle;
  padding: 0.55rem 0.65rem;
  line-height: 1.35;
}

.planner-details-table .planner-col-date {
  width: 6.25rem;
}

.planner-details-table .planner-col-label {
  width: 12%;
  min-width: 8.5rem;
}

.planner-details-table .planner-col-category {
  width: 15%;
  min-width: 9.5rem;
}

.planner-details-table .planner-col-amount,
.planner-details-table .planner-col-savings,
.planner-details-table .planner-col-score {
  width: 6.75rem;
}

.planner-details-table .planner-col-freq {
  width: 5.75rem;
}

.planner-details-table .planner-col-type {
  width: 6.25rem;
}

.planner-details-table .planner-col-priority {
  width: 9.25rem;
}

.planner-details-table .planner-col-rec {
  width: 12%;
  min-width: 9.5rem;
}

.planner-details-table .cell-label-text {
  display: block;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.planner-details-table .cell-category-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.74rem;
  word-break: break-word;
}

.planner-details-table .planner-freq-badge,
.planner-details-table .planner-type-badge,
.planner-details-table .planner-score-badge,
.planner-details-table .planner-priority-badge,
.planner-details-table .planner-rec-cell-badge,
.planner-details-table .planner-savings-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}

.planner-details-table .planner-savings-badge {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.28);
  font-variant-numeric: tabular-nums;
}

.planner-details-table .planner-type-badge--essential {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.28);
}

.planner-details-table .planner-type-badge--luxury {
  background: rgba(139, 92, 246, 0.12);
  color: #6d28d9;
  border-color: rgba(139, 92, 246, 0.3);
}

.planner-details-table .planner-type-badge--other {
  background: rgba(148, 163, 184, 0.12);
  color: #64748b;
  border-color: rgba(148, 163, 184, 0.25);
}

.planner-details-table .planner-score-badge--priority,
.planner-details-table .planner-priority-badge--priority,
.planner-details-table .planner-rec-cell-badge--priority {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.32);
}

.planner-details-table .planner-score-badge--recommended,
.planner-details-table .planner-priority-badge--recommended {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.35);
}

.planner-details-table .planner-rec-cell-badge--optimize {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
}

.planner-details-table .planner-score-badge--low,
.planner-details-table .planner-priority-badge--low {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.25);
}

.planner-details-table .planner-score-badge--incompressible,
.planner-details-table .planner-priority-badge--incompressible {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
  border-color: rgba(34, 197, 94, 0.28);
}

.planner-details-table .planner-rec-cell-badge--keep {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.25);
}

.planner-details-table td.cell-amount-negative {
  font-weight: 600;
}

.planner-details-table tr:hover td {
  background: rgba(100, 116, 139, 0.06);
}

[data-theme="dark"] .planner-details-table .planner-savings-badge {
  color: #93c5fd;
}

[data-theme="dark"] .planner-details-table .planner-score-badge--priority,
[data-theme="dark"] .planner-details-table .planner-priority-badge--priority,
[data-theme="dark"] .planner-details-table .planner-rec-cell-badge--priority {
  color: #fca5a5;
}

[data-theme="dark"] .planner-details-table .planner-rec-cell-badge--optimize {
  color: #fcd34d;
}

[data-theme="dark"] .planner-details-table .planner-rec-cell-badge--keep {
  color: #cbd5e1;
}

.planner-details-legend summary {
  list-style: none;
}

.planner-details-legend summary::-webkit-details-marker {
  display: none;
}

/* ——— Widgets (graphiques) ——— */
.widget {
  background: var(--workspace-card);
  border: 1px solid var(--workspace-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.widget:not(.filter-panel) > .chart-box,
.widget:not(.filter-panel) > .overflow-x-auto,
.widget:not(.filter-panel) > .table-wrap,
.widget:not(.filter-panel) > .spend-ai-tune-form + .overview-spend-ai-body,
.widget:not(.filter-panel) > .overview-spend-ai-body {
  flex: 1 1 auto;
}

.widget:not(.filter-panel) > .chart-box:not(.chart-box--sm) {
  flex: 0 0 auto;
  min-height: var(--chart-box-min-height);
  height: var(--chart-box-min-height);
  max-height: var(--chart-box-min-height);
  overflow: hidden;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--workspace-border);
}

.widget-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.widget-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.widget-header-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-left: auto;
}

.widget-badge--filter {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent, #6366f1);
  border: 1px dashed rgba(99, 102, 241, 0.35);
  white-space: nowrap;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.widget-badge--filter.is-used {
  opacity: 0.55;
}

[data-theme="dark"] .widget-badge--filter {
  background: rgba(129, 140, 248, 0.15);
  color: #a5b4fc;
  border-color: rgba(129, 140, 248, 0.35);
}

.widget:has(.widget-badge--filter) .chart-box .chart-filter-hint {
  display: none !important;
}

[data-theme="dark"] .widget-badge {
  color: #4ade80;
}

.chart-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--chart-cards-grid-gap);
  margin-bottom: var(--chart-cards-grid-gap);
  align-items: start;
}

@media (min-width: 1024px) {
  .chart-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-cards-grid > .widget--chart-span-2,
  .chart-cards-grid > .lg-col-span-2 {
    grid-column: span 2;
  }
}

.chart-cards-grid > .widget {
  align-self: start;
  height: auto;
}

.chart-box {
  min-height: var(--chart-box-min-height);
  padding: 0.5rem 0.75rem 1rem;
}

.chart-box.chart-filterable {
  position: relative;
  cursor: pointer;
}

.chart-filter-hint {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  z-index: 2;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  pointer-events: none;
  opacity: 0.85;
}

[data-theme="dark"] .chart-filter-hint {
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(148, 163, 184, 0.25);
}

.chart-box--gauge {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-box--donut {
  min-height: var(--chart-box-min-height);
  height: var(--chart-box-min-height);
  max-height: var(--chart-box-min-height);
  padding: 0.25rem 0.5rem 0.5rem;
}

.overview-amount-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.overview-amount-stats .stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 120px;
}

.overview-amount-stats .stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
  .widget:not(.filter-panel) > .chart-box:not(.chart-box--sm) {
    min-height: var(--chart-box-min-height-mobile);
    height: var(--chart-box-min-height-mobile);
    max-height: var(--chart-box-min-height-mobile);
  }

  .chart-box--donut {
    min-height: var(--chart-box-min-height-mobile);
    height: var(--chart-box-min-height-mobile);
    max-height: var(--chart-box-min-height-mobile);
  }

  .overview-amount-stats {
    grid-template-columns: 1fr;
  }
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 1rem;
}

.bank-section {
  margin-bottom: 2rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.5rem;
}

.bank-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.bank-section-title {
  margin: 0;
}

.bank-section-link {
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
  white-space: nowrap;
}

.bank-section-link:hover {
  text-decoration: underline;
}

.source-theme-lcl .bank-section-link {
  color: var(--lcl-blue);
}

.source-theme-global .bank-section-link {
  color: var(--accent-global-hover);
}

.source-theme-brsma .bank-section-link {
  color: var(--brsma-purple);
}

.dashboard-summary .section-title {
  margin-bottom: 0.85rem;
}

.dashboard-global-section .stat-meta,
.overview-global-summary .stat-meta {
  margin: auto 0 0;
  padding-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Grille KPI globale — colonnes fluides, cartes égales */
.global-stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--platform-card-gap);
  align-items: stretch;
}

.global-stat-grid .stat-card {
  min-height: 7.25rem;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.global-stat-grid .stat-label {
  font-size: 0.68rem;
  line-height: 1.35;
  margin-bottom: 0.5rem;
  min-height: 2.1rem;
}

.global-stat-grid .stat-label-icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.global-stat-grid .stat-value {
  margin-top: auto;
  font-size: clamp(1.15rem, 1.8vw, 1.5rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.stat-card--global {
  border-top: 3px solid var(--accent-global);
}

.stat-card--global::after {
  background: var(--accent-global-soft);
}

.stat-card--metric::after {
  background: var(--accent-global-soft);
}

.stat-card--metric {
  border-top: 3px solid var(--accent-global);
}

.stat-value--negative {
  color: #dc2626;
}

[data-theme="dark"] .stat-value--negative {
  color: #f87171;
}

@media (max-width: 520px) {
  .global-stat-grid .stat-card {
    min-height: 0;
    padding: 0.9rem 1rem;
  }

  .global-stat-grid .stat-label {
    min-height: 0;
  }
}

.overview-global-extra {
  display: none;
}

.subscriptions-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min)), 1fr));
  gap: 0.65rem;
  align-items: stretch;
}

.subscriptions-kpi-grid .kpi-card {
  min-height: 88px;
  min-width: 0;
  padding: 0.85rem 0.95rem;
}

.source-theme-global .subscriptions-kpi-grid .kpi-card,
.source-theme-lcl .subscriptions-kpi-grid .kpi-card,
.source-theme-brsma .subscriptions-kpi-grid .kpi-card {
  background: var(--kpi-gradient, linear-gradient(135deg, #052e16 0%, #166534 100%));
  color: #fff;
}

.source-theme-lcl .subscriptions-kpi-grid .kpi-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.source-theme-brsma .subscriptions-kpi-grid .kpi-card {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
}

.subscriptions-kpi-grid .kpi-card .kpi-label,
.subscriptions-kpi-grid .kpi-card .kpi-value,
.subscriptions-kpi-grid .kpi-card .kpi-foot {
  color: #fff;
}

.subscriptions-kpi-grid .kpi-foot {
  opacity: 0.85;
  font-size: 0.68rem;
  margin-top: 0.25rem;
}

.subscriptions-kpi-grid .kpi-label {
  line-height: 1.35;
  word-break: break-word;
}

.subscriptions-kpi-grid .kpi-value {
  font-size: clamp(1rem, 4.2vw, 1.35rem);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.subscriptions-kpi-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .subscriptions-kpi-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .subscriptions-kpi-grid--3 {
    grid-template-columns: 1fr;
  }
}

.subscriptions-kpi-grid .kpi-card--wide .kpi-value--truncate {
  font-size: clamp(0.85rem, 3vw, 1.1rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subscriptions-quick-nav {
  padding: 0.5rem 0;
}

.subscriptions-detail-cta {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md, 0.5rem);
  background: var(--surface-muted, #f8fafc);
  border: 1px dashed var(--workspace-border);
}

.subscriptions-top10-card .table-scroll-container {
  padding: 0 1rem 1rem;
}

.subscriptions-exceptions-card .widget-header {
  align-items: flex-start;
}

.subs-exceptions-count {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-muted));
  color: var(--text-muted);
  white-space: nowrap;
}

.subscriptions-top10-table {
  width: 100%;
  min-width: 100%;
}

.data-table tfoot tr.data-table-foot-row td {
  font-weight: 600;
  background: var(--surface-muted, #f8fafc);
  border-top: 2px solid var(--workspace-border);
}

.subscriptions-top10-table tfoot .subs-top10-total-label,
.subscriptions-table tfoot .subs-table-total-label {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.subscriptions-exceptions-table {
  width: 100%;
  min-width: 100%;
}

.subscriptions-exceptions-form .label {
  margin-bottom: 0.25rem;
}

.subscriptions-table-panel .card-header {
  background: var(--surface-muted, #f8fafc);
}

.subs-source-breakdown {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}

.subs-source-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.subs-source-chip--lcl {
  background: rgba(30, 58, 138, 0.12);
  color: #1e3a8a;
}

.subs-source-chip--brsma {
  background: rgba(91, 33, 182, 0.12);
  color: #5b21b6;
}

.subs-source-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subs-source-badge--lcl {
  background: rgba(30, 58, 138, 0.12);
  color: #1e3a8a;
}

.subs-source-badge--brsma {
  background: rgba(91, 33, 182, 0.12);
  color: #5b21b6;
}

.subs-source-badge--mixed {
  background: rgba(22, 101, 52, 0.12);
  color: #166534;
}

.subscriptions-export-bar {
  padding-top: 0.15rem;
}

.source-theme-global .kpi-card--green {
  background: var(--kpi-global-bg) !important;
}

.subscriptions-filters .label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.subscriptions-date-filters .subs-date-filters-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}

.subscriptions-table .subs-rec-badge,
.subscriptions-table .subs-score-badge {
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Score récurrence (0–100) — vert si faible, rouge progressif vers 100 */
.subs-score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}

.subs-score-badge--low {
  background: rgba(22, 163, 74, 0.16);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.4);
}

.subs-score-badge--medium {
  background: rgba(234, 179, 8, 0.18);
  color: #a16207;
  border-color: rgba(234, 179, 8, 0.42);
}

.subs-score-badge--high {
  background: rgba(249, 115, 22, 0.16);
  color: #c2410c;
  border-color: rgba(249, 115, 22, 0.38);
}

.subs-score-badge--very-high {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.4);
}

[data-theme="dark"] .subs-score-badge--low {
  color: #86efac;
}

[data-theme="dark"] .subs-score-badge--medium {
  color: #fde047;
}

[data-theme="dark"] .subs-score-badge--high {
  color: #fdba74;
}

[data-theme="dark"] .subs-score-badge--very-high {
  color: #fca5a5;
}

.subscriptions-table-panel {
  padding: 0;
  overflow: hidden;
}

.subscriptions-table-panel .table-scroll-container {
  max-height: min(28rem, 52vh);
  overflow: auto;
  overscroll-behavior: contain;
}

.subscriptions-table-panel .subscriptions-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--table-head-bg);
  box-shadow: 0 1px 0 var(--workspace-border);
}

.subscriptions-table-panel .subscriptions-table thead th.sortable-th[aria-sort="ascending"],
.subscriptions-table-panel .subscriptions-table thead th.sortable-th[aria-sort="descending"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--table-head-bg));
}

.subscriptions-table-footer {
  padding-bottom: 0.25rem;
}

.subs-rec-badge--cancel.status-badge--danger {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.subs-rec-badge--keep.status-badge--success {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.subs-rec-badge--monitor.status-badge--warning,
.subs-rec-badge--watch.status-badge--warning {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.subs-rec-badge--renegotiate.status-badge--info {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .subs-rec-badge--cancel.status-badge--danger {
  color: #fca5a5;
}

[data-theme="dark"] .subs-rec-badge--keep.status-badge--success {
  color: #86efac;
}

[data-theme="dark"] .subs-rec-badge--monitor.status-badge--warning,
[data-theme="dark"] .subs-rec-badge--watch.status-badge--warning {
  color: #fcd34d;
}

[data-theme="dark"] .subs-rec-badge--renegotiate.status-badge--info {
  color: #93c5fd;
}

.dashboard-source-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Hub 6 vues — accueil & wiki */
.views-hub-head {
  margin-bottom: 1.25rem;
}

.views-hub-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.views-hub-desc {
  font-size: 0.875rem;
  color: var(--text-muted, #64748b);
}

.views-hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .views-hub-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
}

.views-hub-col-title {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #64748b);
}

.views-hub-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.views-hub-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  background: var(--surface-1, #fff);
  color: var(--text-primary, #0f172a);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.views-hub-link:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.views-hub-link-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.views-hub-link--global:hover {
  border-color: #166534;
  background: rgba(22, 101, 52, 0.08);
}

.views-hub-link--lcl:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.06);
}

.views-hub-link--brsma:hover {
  border-color: var(--brsma-purple);
  background: var(--brsma-purple-soft);
}

.stat-card--lcl::after {
  background: var(--lcl-blue-soft);
}

.stat-card--brsma::after {
  background: var(--brsma-purple-soft);
}

.stat-card--lcl {
  border-top: 3px solid var(--lcl-blue);
}

.stat-card--brsma {
  border-top: 3px solid var(--brsma-purple);
}

.flex-card--lift {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.flex-card--lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.flex-tag--global {
  border-color: rgba(34, 197, 94, 0.35);
  color: #16a34a;
  background: rgba(34, 197, 94, 0.08);
}

.flex-tag--lcl {
  border-color: rgba(59, 130, 246, 0.35);
  color: #2563eb;
  background: rgba(59, 130, 246, 0.08);
}

.flex-tag--brsma {
  border-color: rgba(139, 92, 246, 0.35);
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.08);
}

.btn-source-lcl {
  border-color: rgba(59, 130, 246, 0.45);
}

.btn-source-lcl:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.65);
}

.btn-source-brsma {
  border-color: rgba(139, 92, 246, 0.45);
}

.btn-source-brsma:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.65);
}

.btn-source-lcl.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: transparent;
}

.btn-source-brsma.btn-primary {
  background: linear-gradient(135deg, #4c1d95, #5b21b6);
  border-color: transparent;
}

.sidebar-user-chip-active {
  border-color: rgba(34, 197, 94, 0.65) !important;
  background: rgba(34, 197, 94, 0.12) !important;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
}

.sidebar-user-menu-item.is-active {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.topbar.topbar-scrolled {
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .topbar.topbar-scrolled {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.settings-page {
  display: grid;
  gap: 1.25rem;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.2fr);
  gap: 1rem;
  align-items: start;
}

.settings-card-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.settings-card-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.settings-account-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-account-avatar {
  width: 48px;
  height: 48px;
  font-size: 0.9rem;
}

.settings-account-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.settings-account-email {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--text);
}

.settings-account-provider {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-logout-btn {
  width: fit-content;
}

.settings-form .label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.settings-current-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.95rem;
}

.settings-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
}

.settings-summary-chip strong {
  color: var(--text);
  font-weight: 800;
}

.settings-card-hints {
  margin-top: 0.25rem;
}

.settings-hints-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.settings-hint-link {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.settings-hint-link:hover {
  border-color: var(--accent);
  background: var(--workspace-hover);
}

.settings-hint-link strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}

.settings-hint-link small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.settings-hint-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.raw-scope-bar .stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.raw-scope-bar .stat-card {
  padding: 0.75rem 0.9rem;
}

.raw-scope-bar .stat-value {
  font-size: 1rem;
}

.settings-form {
  display: grid;
  gap: 0.8rem;
}

.settings-pref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 0.95rem;
  align-items: stretch;
}

.settings-pref-card {
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  padding: 0.9rem 0.95rem 1rem;
  box-shadow: var(--shadow-sm);
  min-height: 172px;
}

.settings-segmented {
  width: 100%;
  max-width: 100%;
}

.settings-segmented-lang .seg-btn {
  width: 60px;
  font-size: 0.92rem;
}

.settings-segmented-theme {
  gap: 0.25rem;
}

.settings-segmented-theme .seg-btn {
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 0.48rem 0.7rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.settings-segmented-theme .seg-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text);
}

.settings-segmented-theme .seg-btn-active {
  background: rgba(99, 102, 241, 0.18);
  color: var(--accent-hover);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}

[data-theme="dark"] .settings-segmented-theme .seg-btn-active {
  color: #c7d2fe;
  background: rgba(129, 140, 248, 0.2);
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.35);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.3rem;
}

@media (max-width: 1060px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .settings-card-body {
    padding: 1rem 1rem 1.1rem;
  }

  .settings-pref-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    justify-content: stretch;
  }

  .settings-actions .btn {
    width: 100%;
  }
}

/* ——— Stat cards (compact KPIs / info) ——— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min)), 1fr));
  gap: var(--platform-card-gap);
  align-items: stretch;
}

.stat-card {
  background: var(--workspace-card);
  border: 1px solid var(--workspace-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 0.95rem 1rem;
  position: relative;
  overflow: hidden;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -22px;
  top: -22px;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--accent-global-soft);
}

.stat-card--neutral {
  border-top: 3px solid var(--accent-global);
}

.stat-card--neutral::after {
  background: var(--accent-global-soft) !important;
}

.source-theme-lcl .stat-card--neutral,
.source-theme-lcl .overview-spend-ai .stat-card {
  border-top-color: var(--lcl-blue);
}

.source-theme-lcl .stat-card--neutral::after,
.source-theme-lcl .overview-spend-ai .stat-card::after {
  background: rgba(59, 130, 246, 0.12) !important;
}

.source-theme-brsma .stat-card--neutral,
.source-theme-brsma .overview-spend-ai .stat-card {
  border-top-color: var(--brsma-purple);
}

.source-theme-brsma .stat-card--neutral::after,
.source-theme-brsma .overview-spend-ai .stat-card::after {
  background: rgba(139, 92, 246, 0.12) !important;
}

.stat-label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.35rem 0;
}

.stat-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.stat-hint {
  margin: 0.35rem 0 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

[data-theme="dark"] .stat-card::after {
  background: var(--accent-global-soft);
}

/* ——— Filter chips ——— */
.chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  background: rgba(99, 102, 241, 0.08);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
}

[data-theme="dark"] .chip {
  background: rgba(34, 197, 94, 0.10);
}

.filter-chips-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
}

.filter-chips-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.filter-chips-bar .chip-set {
  flex: 1 1 auto;
  min-width: 0;
}

/* ——— Cards & forms ——— */
.card {
  background: var(--workspace-card);
  border: 1px solid var(--workspace-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.input {
  width: 100%;
  background: var(--workspace-bg);
  border: 1px solid var(--workspace-border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--workspace-card);
  border: 1px solid var(--workspace-border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* ——— Raw-data filter cards ——— */
.filter-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min-wide)), 1fr));
  gap: var(--platform-card-gap);
  align-items: stretch;
}

.filter-columns-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--platform-card-min-wide)), 1fr));
  gap: var(--platform-card-gap);
  margin-top: 1rem;
  align-items: stretch;
}

.amount-range {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.amount-range-track-wrap {
  position: relative;
  height: 2rem;
  margin: 0.25rem 0 0.35rem;
}

.amount-range-slider {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 0.35rem;
  margin: 0;
  pointer-events: none;
  appearance: none;
  background: transparent;
  top: 50%;
  transform: translateY(-50%);
}

.amount-range-slider::-webkit-slider-runnable-track {
  height: 0.35rem;
  border-radius: 999px;
  background: var(--workspace-border);
}

.amount-range-slider::-webkit-slider-thumb {
  appearance: none;
  pointer-events: auto;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #439a86;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
  margin-top: -0.33rem;
  cursor: grab;
}

.amount-range-slider::-moz-range-track {
  height: 0.35rem;
  border-radius: 999px;
  background: var(--workspace-border);
}

.amount-range-slider::-moz-range-thumb {
  pointer-events: auto;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #439a86;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
  cursor: grab;
}

.amount-range-slider--max {
  z-index: 2;
}

.amount-range-values {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.amount-range-currency {
  color: var(--text-muted);
  font-weight: 500;
}

.filter-form-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--workspace-border);
}

.filter-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  height: 100%;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.filter-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.filter-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.filter-card-title {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.filter-card-icon {
  width: 1.1rem;
  text-align: center;
}

.filter-card-status {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--workspace-border);
  color: var(--text-muted);
  background: var(--workspace-bg);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-card-status.is-active {
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.1);
}

.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filter-two-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.filter-period-fields {
  align-items: start;
}

@media (min-width: 420px) {
  .filter-period-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ——— Filtres : listes déroulantes multi-sélection ——— */
.filter-ms {
  position: relative;
  display: block;
}

.filter-ms-field-label {
  display: block;
  margin-bottom: 0.35rem;
}

.filter-ms-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  text-align: left;
  cursor: pointer;
  background: var(--workspace-bg);
}

.filter-ms-trigger[aria-expanded="true"] {
  border-color: rgba(99, 102, 241, 0.55);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.filter-ms-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.filter-ms-value.is-empty {
  color: var(--text-muted);
  font-weight: 500;
}

.filter-ms-chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.filter-ms-trigger[aria-expanded="true"] .filter-ms-chevron {
  transform: rotate(180deg);
}

.filter-ms-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: min(280px, 50vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.filter-ms-panel.hidden {
  display: none;
}

.filter-ms-panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
}

.filter-ms-action {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}

.filter-ms-action:hover {
  background: rgba(99, 102, 241, 0.08);
}

.filter-ms-options {
  overflow-y: auto;
  padding: 0.35rem 0;
}

.filter-ms-empty {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.filter-ms-trigger:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.filter-ms-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.35;
  transition: background 0.12s ease;
}

.filter-ms-option:hover {
  background: rgba(99, 102, 241, 0.06);
}

.filter-ms-option input {
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.filter-ms-option-label {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* ——— Filtres : combobox marchand (saisie + liste) ——— */
.filter-combobox {
  position: relative;
  display: block;
}

.filter-combobox-control {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.filter-combobox-input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.filter-combobox-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 2.75rem;
  max-width: 9rem;
  padding: 0 0.55rem;
  border: 1px solid var(--workspace-border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  background: var(--workspace-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.filter-combobox-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--accent);
  text-align: right;
}

.filter-combobox-summary.is-empty {
  display: none;
}

.filter-combobox-toggle:hover,
.filter-combobox-toggle[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent) 8%, var(--workspace-bg));
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--text);
}

.filter-combobox-chevron {
  font-size: 0.72rem;
  transition: transform 0.15s ease;
}

.filter-combobox-toggle[aria-expanded="true"] .filter-combobox-chevron {
  transform: rotate(180deg);
}

.filter-combobox-panel {
  position: absolute;
  z-index: 55;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: min(300px, 52vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.filter-combobox-panel.hidden {
  display: none;
}

.filter-combobox-panel-search {
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
}

.filter-combobox-panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--workspace-border);
  background: var(--workspace-bg);
}

.filter-combobox-action {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}

.filter-combobox-action:hover {
  background: rgba(99, 102, 241, 0.08);
}

.filter-combobox-options {
  margin: 0;
  padding: 0.35rem 0;
  overflow-y: auto;
  max-height: min(240px, 40vh);
}

.filter-combobox-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.84rem;
  line-height: 1.35;
  transition: background 0.12s ease;
}

.filter-combobox-option:hover {
  background: rgba(99, 102, 241, 0.06);
}

.filter-combobox-option.hidden {
  display: none;
}

.filter-combobox-option input {
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.filter-combobox-option-label {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  color: var(--text);
}

.filter-combobox-empty {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.filter-combobox-empty.hidden {
  display: none;
}

.filter-dropdown-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 480px) {
  .filter-dropdown-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.filter-actions-card {
  justify-content: space-between;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.filter-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn-compact {
  padding: 0.34rem 0.65rem;
  font-size: 0.76rem;
}

.filter-helper {
  margin: 0;
}

.chip-x {
  border: none;
  background: transparent;
  color: currentColor;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
  padding: 0 0.1rem;
}

.chip-x:hover {
  opacity: 1;
}

/* ——— Page tabs (source LCL/BRSMA + vues) ——— */
.page-tab-shell {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.page-tab-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.page-tab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.page-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.22rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--workspace-bg);
}

.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.48rem 0.9rem;
  border-radius: 11px;
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.page-tab:hover {
  color: var(--text);
  background: rgba(100, 116, 139, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
}

.page-tab.is-active,
.page-tab.page-tab--active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.22);
}

[data-theme="dark"] .page-tabs {
  border-color: rgba(148, 163, 184, 0.16);
}

[data-theme="dark"] .page-tab:hover {
  border-color: rgba(148, 163, 184, 0.14);
}

.page-tabs--source {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
}

.page-toolbar .page-tabs--source,
.dashboard-page .page-tabs--source {
  max-width: 100%;
}

.page-tabs--source .page-tab {
  flex: 1 1 0;
  justify-content: center;
  min-width: 5rem;
  padding: 0.48rem 0.85rem;
  font-size: 0.78rem;
}

.page-toolbar .page-tabs--source,
.dashboard-page .page-tabs--source {
  max-width: 100%;
}

.page-tabs--source .page-tab-label {
  white-space: nowrap;
}

.page-tabs--source .page-tab.is-active {
  background: linear-gradient(135deg, #14532d, #166534);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.28);
}

/* Harmonisation visuelle par source */
.source-theme-lcl .page-tabs--source .page-tab.is-active {
  background: linear-gradient(135deg, #1e3d9e, #244cb5);
  box-shadow: 0 2px 8px var(--lcl-blue-ring);
}

.source-theme-brsma .page-tabs--source .page-tab.is-active {
  background: linear-gradient(135deg, #4c1d95, #5b21b6);
  box-shadow: 0 2px 8px var(--brsma-purple-ring);
}

.source-theme-global .page-tabs--source .page-tab.is-active {
  background: linear-gradient(135deg, #14532d, #166534);
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.28);
}

.source-theme-global .kpi-card {
  background: var(--kpi-global-bg) !important;
  color: #fff;
}

.source-theme-global .kpi-card::after {
  background: rgba(255, 255, 255, 0.12);
}

.source-theme-global .kpi-label {
  color: rgba(255, 255, 255, 0.88);
}

.source-theme-global .kpi-value {
  color: #fff;
}

.source-theme-global .planner-kpi-highlight {
  background: var(--kpi-global-bg) !important;
  border: none;
  box-shadow: var(--shadow-md);
}

.source-theme-global .widget-badge {
  color: var(--accent-global-hover);
  background: var(--accent-global-soft);
}

.source-theme-global .stat-card,
.source-theme-global .overview-spend-ai .stat-card,
.source-theme-global .stat-card--neutral,
.source-theme-global .stat-card--metric {
  border-top-color: var(--accent-global);
}

.source-theme-global .stat-card::after,
.source-theme-global .overview-spend-ai .stat-card::after {
  background: var(--accent-global-soft) !important;
}

.source-theme-global .btn-primary {
  background: var(--accent-global);
  box-shadow: 0 2px 8px var(--accent-global-ring);
}

.source-theme-global .btn-primary:hover {
  background: var(--accent-global-hover);
}

.source-theme-lcl .kpi-card::after,
.source-theme-brsma .kpi-card::after {
  background: rgba(255, 255, 255, 0.16);
}

/* LCL — toutes les cartes KPI en bleu */
.source-theme-lcl .kpi-grid > .kpi-card,
.source-theme-lcl .kpi-grid--gradient > .kpi-card {
  background: var(--kpi-blue-bg) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.source-theme-lcl .kpi-grid > .kpi-card .kpi-label,
.source-theme-lcl .kpi-grid--gradient > .kpi-card .kpi-label {
  color: rgba(255, 255, 255, 0.92) !important;
}

.source-theme-lcl .kpi-grid > .kpi-card .kpi-value,
.source-theme-lcl .kpi-grid--gradient > .kpi-card .kpi-value,
.source-theme-lcl .kpi-grid > .kpi-card .kpi-foot {
  color: #fff !important;
}

.source-theme-lcl .kpi-grid > .kpi-card::after,
.source-theme-lcl .kpi-grid--gradient > .kpi-card::after {
  background: rgba(255, 255, 255, 0.12);
  width: 80px;
  height: 80px;
  right: -20px;
  top: -20px;
}

/* BRSMA — toutes les cartes KPI en violet */
.source-theme-brsma .kpi-grid > .kpi-card,
.source-theme-brsma .kpi-grid--gradient > .kpi-card {
  background: var(--kpi-purple-bg) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.source-theme-brsma .kpi-grid > .kpi-card .kpi-label,
.source-theme-brsma .kpi-grid--gradient > .kpi-card .kpi-label {
  color: rgba(255, 255, 255, 0.92) !important;
}

.source-theme-brsma .kpi-grid > .kpi-card .kpi-value,
.source-theme-brsma .kpi-grid--gradient > .kpi-card .kpi-value,
.source-theme-brsma .kpi-grid > .kpi-card .kpi-foot {
  color: #fff !important;
}

.source-theme-brsma .kpi-grid > .kpi-card::after,
.source-theme-brsma .kpi-grid--gradient > .kpi-card::after {
  background: rgba(255, 255, 255, 0.12);
  width: 80px;
  height: 80px;
  right: -20px;
  top: -20px;
}

/* Global — toutes les cartes KPI en vert sombre */
.source-theme-global .kpi-grid > .kpi-card,
.source-theme-global .kpi-grid--gradient > .kpi-card {
  background: var(--kpi-global-bg) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.source-theme-global .kpi-grid > .kpi-card .kpi-label,
.source-theme-global .kpi-grid--gradient > .kpi-card .kpi-label {
  color: rgba(255, 255, 255, 0.92) !important;
}

.source-theme-global .kpi-grid > .kpi-card .kpi-value,
.source-theme-global .kpi-grid--gradient > .kpi-card .kpi-value,
.source-theme-global .kpi-grid > .kpi-card .kpi-foot {
  color: #fff !important;
}

.source-theme-global .kpi-grid > .kpi-card::after,
.source-theme-global .kpi-grid--gradient > .kpi-card::after {
  background: rgba(255, 255, 255, 0.12);
  width: 80px;
  height: 80px;
  right: -20px;
  top: -20px;
}

.source-theme-lcl .kpi-card::after,
.source-theme-brsma .kpi-card::after {
  background: rgba(255, 255, 255, 0.16);
}

.source-theme-global .chip {
  background: rgba(22, 101, 52, 0.12);
  border-color: rgba(22, 101, 52, 0.28);
  color: #14532d;
}

.source-theme-global .chip-x:hover {
  background: rgba(22, 101, 52, 0.22);
}

.source-theme-global .filter-card-status.is-active {
  color: #14532d;
  border-color: rgba(22, 101, 52, 0.35);
  background: rgba(22, 101, 52, 0.12);
}

.source-theme-global .filter-quick-actions .btn-secondary:hover {
  border-color: rgba(22, 101, 52, 0.45);
  color: #14532d;
}

.source-theme-lcl .widget-badge {
  color: var(--lcl-blue-dark);
  background: var(--lcl-blue-soft);
}

.source-theme-brsma .widget-badge {
  color: var(--brsma-purple-dark);
  background: var(--brsma-purple-soft);
}

.source-theme-lcl .stat-card::after {
  background: var(--lcl-blue-soft);
}

.source-theme-brsma .stat-card::after {
  background: var(--brsma-purple-soft);
}

.source-theme-lcl .filter-card-status.is-active {
  color: var(--lcl-blue-dark);
  border-color: rgba(30, 58, 138, 0.35);
  background: var(--lcl-blue-soft);
}

.source-theme-brsma .filter-card-status.is-active {
  color: var(--brsma-purple-dark);
  border-color: rgba(91, 33, 182, 0.38);
  background: var(--brsma-purple-soft);
}

.source-theme-lcl .chip {
  background: var(--lcl-blue-soft);
  border-color: rgba(30, 58, 138, 0.28);
}

.source-theme-brsma .chip {
  background: var(--brsma-purple-soft);
  border-color: rgba(91, 33, 182, 0.32);
}

.source-theme-lcl .chip-x:hover {
  color: var(--lcl-blue-dark);
}

.source-theme-brsma .chip-x:hover {
  color: var(--brsma-purple-dark);
}

.source-theme-lcl .filter-quick-actions .btn-secondary:hover {
  border-color: var(--lcl-blue);
  color: var(--lcl-blue-dark);
}

.source-theme-brsma .filter-quick-actions .btn-secondary:hover {
  border-color: var(--brsma-purple);
  color: var(--brsma-purple-dark);
}

.source-theme-brsma .btn-primary {
  background: var(--brsma-purple);
  box-shadow: 0 2px 8px var(--brsma-purple-ring);
}

.source-theme-brsma .btn-primary:hover {
  background: var(--brsma-purple-hover);
}

.source-theme-lcl .btn-primary {
  background: var(--lcl-blue);
  box-shadow: 0 2px 8px var(--lcl-blue-ring);
}

.source-theme-lcl .btn-primary:hover {
  background: var(--lcl-blue-hover);
}

/* ——— Overview (sections standard + avancé) ——— */
.overview-standard-block,
.overview-advanced-block {
  scroll-margin-top: 5.5rem;
}

.overview-advanced-block {
  border-top: 1px solid var(--workspace-border);
  padding-top: 2rem;
  margin-top: 2rem;
}

.advanced-scope-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--workspace-border);
}

.advanced-scope-bar > * {
  position: relative;
  z-index: 1;
}

.advanced-scope-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.advanced-scope-badge--global {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.advanced-scope-badge--lcl {
  background: rgba(37, 99, 235, 0.1);
  color: var(--lcl-blue, #2563eb);
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.advanced-scope-badge--brsma {
  background: rgba(124, 58, 237, 0.1);
  color: var(--brsma-purple, #7c3aed);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.advanced-scope-hint {
  flex: 1 1 12rem;
}

.advanced-scope-link {
  font-weight: 600;
  color: var(--accent-primary, #2563eb);
  text-decoration: none;
  white-space: nowrap;
}

.advanced-scope-link:hover {
  text-decoration: underline;
}

.overview-section-source-tabs {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-md, 10px);
  border: 1px dashed var(--workspace-border);
  background: var(--surface-muted, rgba(15, 23, 42, 0.02));
}

.section-title--sub {
  font-size: 1rem;
  font-weight: 650;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.overview-advanced-block .kpi-card--neutral-theme {
  background: var(--card-bg, #fff) !important;
  color: var(--text) !important;
  border: 1px solid var(--workspace-border);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
}

.source-theme-lcl .stat-card {
  border-top: 3px solid var(--lcl-blue);
}

.source-theme-brsma .stat-card {
  border-top: 3px solid var(--brsma-purple);
}

.overview-advanced-block .kpi-card--neutral-theme .kpi-label {
  color: var(--text-muted);
}

.overview-advanced-block--lcl .chart-cards-grid:has(> .widget:only-child),
.overview-advanced-block--brsma .chart-cards-grid:has(> .widget:only-child) {
  grid-template-columns: 1fr;
}

/* ——— Données brutes (toolbar) ——— */
.raw-page-toolbar,
.page-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.page-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  width: 100%;
}

.page-toolbar-row .page-tabs--source {
  flex: 1 1 auto;
  min-width: 0;
}

.page-toolbar-row--end {
  justify-content: flex-end;
}

.page-toolbar-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem 0.5rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.filter-panel-badge--inline {
  font-size: 0.65rem;
  padding: 0.12rem 0.45rem;
  margin-left: 0.15rem;
}

.raw-page-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.raw-page-toolbar-row--tabs {
  width: 100%;
}

.raw-page-toolbar-row--tabs .page-tabs {
  width: 100%;
  max-width: 100%;
}

.raw-page-toolbar-row--actions {
  width: 100%;
  justify-content: flex-end;
}

.raw-page-toolbar-link {
  margin-left: 0;
}

.explore-metrics-table-section .explore-metrics-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.explore-metrics-table-wrap {
  max-height: min(70vh, 640px);
  overflow: auto;
}

.explore-label-metrics-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head-bg);
  box-shadow: 0 1px 0 var(--workspace-border);
}

.explore-label-metrics-table td:first-child,
.explore-label-metrics-table th:first-child {
  min-width: 10rem;
  max-width: 18rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-tabs--view {
  display: flex;
  width: 100%;
  max-width: 100%;
}

.page-tabs--view .page-tab {
  flex: 1 1 0;
  justify-content: center;
  min-width: 5rem;
  font-size: 0.78rem;
  padding: 0.48rem 0.85rem;
}

.page-tabs--mode .page-tab.is-active {
  background: linear-gradient(135deg, #439a86, #2d7a6a);
  box-shadow: 0 4px 14px rgba(67, 154, 134, 0.28);
  color: #fff;
}

.page-toolbar-row--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.overview-mode-toolbar {
  width: 100%;
}

.overview-section-source-tabs {
  width: 100%;
}

.page-tab-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.page-tab-hint {
  margin: 0;
}

@media (min-width: 640px) {
  .filter-two-cols {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  }
}

/* ——— Alerts ——— */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
}

.alert-success {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

[data-theme="dark"] .alert-success {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.25);
}

[data-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

[data-theme="dark"] .alert-info {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}

/* ——— Tables ——— */
.table-wrap,
.table-scroll-container,
.overflow-x-auto {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.widget.table-wrap,
.widget.overflow-x-auto,
.widget:has(> .table-wrap),
.widget:has(> .table-scroll-container) {
  overflow-x: auto;
  overflow-y: visible;
}

.table-scroll-hint {
  display: none;
  margin: 0 0 0.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--accent) 6%, var(--workspace-bg));
  border-radius: 6px;
  border: 1px dashed color-mix(in srgb, var(--accent) 22%, var(--workspace-border));
}

@media (max-width: 768px) {
  .table-scroll-hint {
    display: block;
  }

  .table-wrap,
  .table-scroll-container,
  .overflow-x-auto {
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }
}

.table-wrap .data-table,
.table-scroll-container .data-table,
.overflow-x-auto .data-table,
.table-wrap > table.data-table,
.table-scroll-container > table.data-table {
  width: max-content;
  min-width: 100%;
}

.data-table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--workspace-border);
  text-align: left;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--table-head-bg);
  white-space: nowrap;
}

.data-table thead th {
  border-bottom: 1px solid var(--workspace-border);
}

.data-table--columns thead th {
  position: relative;
  padding-left: 1.65rem;
  padding-right: 0.85rem;
  vertical-align: middle;
}

.data-table--columns.has-col-widths {
  table-layout: fixed;
}

.data-table--columns.has-col-widths td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-drag-handle {
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.62rem;
  letter-spacing: -0.12em;
  line-height: 1;
  opacity: 0.45;
  user-select: none;
  padding: 0.15rem 0.2rem;
}

.data-table--columns thead th:hover .col-drag-handle,
.data-table--columns thead th:focus-within .col-drag-handle {
  opacity: 0.85;
}

.col-drag-handle:active {
  cursor: grabbing;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  right: 2px;
  width: 2px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--text-muted) 35%, transparent);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.data-table--columns thead th:hover .col-resize-handle::after,
.col-resize-active .col-resize-handle::after {
  opacity: 1;
}

.data-table--columns thead th.col-dragging {
  opacity: 0.55;
}

.data-table--columns thead th.col-drop-target {
  background: color-mix(in srgb, var(--accent) 14%, var(--table-head-bg));
  box-shadow: inset 3px 0 0 var(--accent);
}

body.col-resize-active {
  cursor: col-resize;
  user-select: none;
}

.table-toolbar--columns {
  justify-content: flex-end;
}

.data-table--sortable th.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.data-table--sortable th.sortable-th:hover,
.data-table--sortable th.sortable-th:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, var(--table-head-bg));
  color: var(--text);
  outline: none;
}

.data-table--sortable th.sortable-th[aria-sort="ascending"],
.data-table--sortable th.sortable-th[aria-sort="descending"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--table-head-bg));
}

.data-table--sortable .sort-indicator {
  display: inline-block;
  margin-left: 0.2rem;
  font-size: 0.65rem;
  opacity: 0.45;
  vertical-align: middle;
}

.data-table--sortable th.sortable-th[aria-sort="ascending"] .sort-indicator,
.data-table--sortable th.sortable-th[aria-sort="descending"] .sort-indicator {
  opacity: 1;
  font-weight: 700;
}

.data-table--sortable td.num,
.data-table--sortable th.num,
.data-table td.num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table td.cell-amount-negative {
  color: #dc2626;
  font-weight: 500;
}

.data-table td.cell-amount-positive {
  color: #16a34a;
}

.data-table td.cell-credit {
  color: #16a34a;
}

.data-table td.cell-debit {
  color: #64748b;
}

.data-table td.cell-empty {
  color: var(--text-muted);
}

.data-table td.cell-score-high {
  color: #16a34a;
  font-weight: 600;
}

.data-table td.cell-score-low {
  color: #dc2626;
}

.data-table td.cell-text {
  max-width: 22rem;
  word-break: break-word;
  line-height: 1.35;
}

.data-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--workspace-border);
  background: var(--workspace-card);
}

.table-wrap .table-toolbar {
  border-radius: var(--radius) var(--radius) 0 0;
}

.table-pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.table-pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.table-per-page-label {
  white-space: nowrap;
}

.table-per-page-group {
  display: inline-flex;
  border: 1px solid var(--workspace-border);
  border-radius: var(--radius-sm, 8px);
  overflow: hidden;
  background: var(--workspace-card);
}

.table-per-page-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-right: 1px solid var(--workspace-border);
  transition: background 0.15s ease, color 0.15s ease;
}

.table-per-page-chip:last-child {
  border-right: none;
}

.table-per-page-chip:hover {
  background: rgba(99, 102, 241, 0.06);
  color: var(--text);
}

.table-per-page-chip.is-active {
  background: var(--accent, #1e3a8a);
  color: #fff;
}

.table-per-page-chip.is-active:hover {
  color: #fff;
}

.table-pagination-nav {
  margin-left: auto;
}

.table-export-btn {
  font-size: 0.75rem;
}

/* ——— Login ——— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2332 0%, #0f172a 50%, #1e3a5f 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.login-card h2 {
  color: #1e293b;
  margin: 0 0 0.5rem;
}

.login-card .label {
  color: #64748b;
}

.login-card .input {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #1e293b;
}

.login-card .password-toggle-btn {
  color: #64748b;
}
.login-card .password-toggle-btn:hover,
.login-card .password-toggle-btn:focus-visible {
  color: #1e293b;
  background: rgba(15, 23, 42, 0.08);
}

/* ——— Loader & chat ——— */
.loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loader.active {
  display: flex;
}

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.chat-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
}

.chat-user {
  background: rgba(99, 102, 241, 0.08);
  margin-left: 2rem;
}

.chat-assistant {
  margin-right: 2rem;
}

#menu-toggle {
  background: transparent;
  border: 1px solid var(--workspace-border);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  color: var(--text-muted);
  cursor: pointer;
}

.sidebar-snapshot-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0.75rem 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #cbd5e1;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-snapshot-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-snapshot-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-badge--success,
.status-badge--ok {
  color: #15803d;
  background: rgba(34, 197, 94, 0.15);
}

.status-badge--muted {
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.12);
}

.status-badge--warning {
  color: #b45309;
  background: rgba(245, 158, 11, 0.18);
}

.status-badge--danger {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.15);
}

.status-badge--info {
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.14);
}

.overview-spend-ai-head {
  align-items: flex-start;
}

.overview-spend-ai-details {
  margin: 0;
}

.overview-spend-ai-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid var(--workspace-border);
}

.overview-spend-ai-details:not([open]) > .overview-spend-ai-summary {
  border-bottom: none;
}

.overview-spend-ai-summary::-webkit-details-marker {
  display: none;
}

.overview-spend-ai-summary::before {
  content: "▸";
  flex-shrink: 0;
  margin-top: 0.2rem;
  margin-right: 0.15rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.overview-spend-ai-details[open] > .overview-spend-ai-summary::before {
  transform: rotate(90deg);
}

.overview-spend-ai-summary-main {
  flex: 1;
  min-width: 0;
}

.spend-ai-planner-link {
  flex-shrink: 0;
}

.overview-spend-ai-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.2fr);
  gap: 1.25rem;
  padding: 0 1.25rem 1.25rem;
}

.overview-spend-ai-score-value {
  margin: 0.35rem 0;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.overview-spend-ai-score-value span {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.overview-spend-ai-resume {
  margin: 0.65rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.overview-spend-ai-metric {
  border: 1px solid var(--workspace-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: var(--workspace-card);
}

.overview-spend-ai-metric-value {
  margin: 0.25rem 0 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-hover);
}

.spend-ai-panels {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--workspace-border);
  padding-top: 1rem;
}

.spend-ai-panel {
  border: 1px solid var(--workspace-border);
  border-radius: 12px;
  background: var(--workspace-card);
  overflow: hidden;
}

.spend-ai-panel-summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.88rem;
  list-style: none;
}

.spend-ai-panel-summary::-webkit-details-marker {
  display: none;
}

.spend-ai-panel-body {
  padding: 0 1rem 1rem;
}

.spend-ai-rule-grid,
.spend-ai-proj-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.spend-ai-sim-badge.is-good {
  background: #dcfce7;
  color: #166534;
}

.spend-ai-sim-badge.is-warn {
  background: #fef9c3;
  color: #854d0e;
}

.spend-ai-sim-badge.is-alert {
  background: #fee2e2;
  color: #991b1b;
}

.spend-ai-tune-form {
  background: var(--surface-muted, #f8fafc);
}

/* ——— Accueil : parcours guidé ——— */
.home-workflow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .home-workflow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .home-workflow-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.home-workflow-step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--workspace-border);
  border-radius: var(--radius);
}

.home-workflow-step-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.home-workflow-step-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

/* ——— Paramètres : palettes nommées ——— */
.settings-palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.settings-palette-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--workspace-border);
  border-radius: 8px;
  background: var(--workspace-card);
  cursor: pointer;
  text-align: left;
}

.settings-palette-btn.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.settings-palette-swatch {
  display: block;
  height: 1.25rem;
  border-radius: 4px;
}

.settings-palette-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.chart-box--sm {
  min-height: 220px;
  height: auto;
  max-height: none;
}

.chart-box--tall {
  min-height: var(--chart-box-min-height);
  height: var(--chart-box-min-height);
  max-height: var(--chart-box-min-height);
}

.upload-form .segmented-source {
  display: inline-flex;
  gap: 0.35rem;
}

.upload-form .segmented-source .seg-btn {
  cursor: pointer;
}

.upload-form .segmented-source input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.overview-spend-ai-recos-list {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .overview-spend-ai-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar.mobile-open {
    display: flex !important;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: 260px;
    height: 100vh; /* 100% peut ne pas suivre selon les parents */
    background: var(--sidebar-bg); /* assure le fond même si des styles hérités/transparent */
  }
}

/* Utilitaires layout (remplace Tailwind sur les pages secondaires) */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid { display: grid; align-items: stretch; }
.grid > .widget,
.grid > .card,
.grid > .stat-card,
.grid > .kpi-card,
.flex-cards-grid > .flex-card,
.kpi-grid > .kpi-card,
.stat-grid > .stat-card,
.filter-cards-grid > .filter-card {
  height: 100%;
}
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.ml-auto { margin-left: auto; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.w-full { width: 100%; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.min-w-0 { min-width: 0; }
.min-h-screen { min-height: 100vh; }
.hidden { display: none !important; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shrink-0 { flex-shrink: 0; }
.w-64 { width: 16rem; }
.overflow-y-auto { overflow-y: auto; }
.overflow-auto { overflow: auto; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-white { color: #fff; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-muted { color: var(--text-muted); }

.markdown-content h2 { font-size: 1.15rem; margin: 1.25rem 0 0.5rem; }
.markdown-content h3 { font-size: 1rem; margin: 1rem 0 0.35rem; color: var(--text-muted); }
.markdown-content h4 { font-size: 0.95rem; margin: 0.85rem 0 0.3rem; font-weight: 600; }
.markdown-content h5,
.markdown-content h6 { font-size: 0.88rem; margin: 0.75rem 0 0.25rem; font-weight: 600; color: var(--text-muted); }
.markdown-content ul,
.markdown-content ol { padding-left: 1.25rem; margin: 0.5rem 0; }
.markdown-content li { margin: 0.3rem 0; }
.markdown-content p { margin: 0.5rem 0; color: var(--text-muted); line-height: 1.55; }
.markdown-content strong { color: var(--text); font-weight: 600; }
.markdown-content em { color: var(--text-muted); }

.prose-content .chat-table-wrap,
.markdown-content .chat-table-wrap {
  overflow-x: auto;
  margin: 0.65rem 0;
  border: 1px solid var(--workspace-border);
  border-radius: 8px;
  background: var(--workspace-card);
}

.prose-content table,
.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.prose-content th,
.prose-content td,
.markdown-content th,
.markdown-content td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--workspace-border);
  text-align: left;
}

.prose-content th,
.markdown-content th {
  background: color-mix(in srgb, var(--accent) 6%, var(--workspace-bg));
  font-weight: 600;
}

.home-guide-section {
  border-left: 4px solid var(--accent);
}

.planner-hint p { margin: 0; }

.cell-alert-status--danger { color: #dc2626; font-weight: 600; }
.cell-alert-status--warn { color: #d97706; font-weight: 600; }
.cell-alert-status--ok { color: #16a34a; font-weight: 600; }

.home-hero h2 { margin: 0 0 0.5rem; }
.login-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.login-tagline { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-hint { font-size: 0.75rem; color: var(--text-muted); margin: 1rem 0 0; }

.password-field {
  position: relative;
  display: flex;
  align-items: stretch;
}
.password-field .input {
  width: 100%;
  padding-right: 2.75rem;
}
.password-toggle-btn {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.password-toggle-btn:hover,
.password-toggle-btn:focus-visible {
  color: #334155;
  background: rgba(15, 23, 42, 0.06);
  outline: none;
}
.password-toggle-btn--visible .password-toggle-icon--show { display: none; }
.password-toggle-btn:not(.password-toggle-btn--visible) .password-toggle-icon--hide { display: none; }
.password-toggle-icon { display: inline-flex; line-height: 0; }

.w-full { width: 100%; }

.about-profile { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.about-photo { border-radius: 50%; object-fit: cover; border: 3px solid var(--sidebar-accent); }
.about-links { display: flex; gap: 0.75rem; margin-top: 1rem; }
.about-layout { display: grid; gap: 1rem; }
.about-app-card { border-left: 4px solid #3b82f6; }
.about-sections-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.about-section-card { min-height: 100%; }
.about-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.55rem;
  color: var(--text-muted);
}
.about-list strong { color: var(--text); }
.about-social {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--workspace-card); border: 1px solid var(--workspace-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); text-decoration: none; font-size: 1.1rem;
}
.about-social:hover { border-color: var(--sidebar-accent); color: var(--sidebar-accent); }
.border-workspace { border-color: var(--workspace-border); }
.my-6 { margin-top: 1.5rem; margin-bottom: 1.5rem; }

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.list-disc { list-style-type: disc; }
.list-inside { list-style-position: inside; }
.border-b { border-bottom: 1px solid var(--workspace-border); }
.border-slate-800 { border-color: var(--workspace-border); }
.m-0 { margin: 0; }

@media (min-width: 768px) {
  .md-flex { display: flex !important; }
  .md-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .md-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
  .md-hidden { display: none !important; }
}

@media (min-width: 1024px) {
  .lg-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .lg-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
  .lg-col-span-1 { grid-column: span 1; }
  .lg-col-span-2 { grid-column: span 2; }
  .lg-col-span-3 { grid-column: span 3; }
  .about-sections-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: stretch; }
}

@media (min-width: 640px) {
  .sm-inline { display: inline !important; }
}

/* ——— Chat PDF (RAG headless, style conversation) ——— */
body.page-chat .main-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 0.5rem;
}

body.page-chat .platform-footer-bar {
  display: none;
}

body.page-chat .assist-fab {
  display: none;
}

body.page-chat .scroll-top-btn {
  bottom: 5.5rem;
}

.chat-fallback-panel {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  font-size: 0.85rem;
}

.chat-fallback-panel--warn {
  border-color: color-mix(in srgb, #f59e0b 45%, var(--workspace-border));
  background: color-mix(in srgb, #f59e0b 8%, var(--workspace-card));
}

.chat-fallback-panel--info {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--workspace-border));
  background: color-mix(in srgb, var(--accent) 6%, var(--workspace-card));
}

.chat-turn--fallback .chat-content {
  border-style: dashed;
}

.chat-fallback-badge {
  font-style: italic;
  opacity: 0.85;
}

.chat-noscript-fallback {
  margin: 0.5rem 0 0;
  padding: 0.5rem;
  font-size: 0.78rem;
  white-space: pre-wrap;
  background: var(--workspace-bg);
  border-radius: 6px;
}

.chat-bootstrap-banner {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem;
  margin-bottom: 0.65rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--workspace-border));
  background: color-mix(in srgb, var(--accent) 10%, var(--workspace-card));
  color: var(--text-muted);
  font-size: 0.82rem;
  animation: chat-fade-in 0.2s ease;
}

.chat-bootstrap-banner.hidden {
  display: none;
}

.topbar-chat-shortcuts {
  flex-wrap: wrap;
  justify-content: center;
}

.chat-pdf-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: calc(100vh - 5.5rem);
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
  min-height: 420px;
}

.chat-pdf-status-details {
  flex-shrink: 0;
}

.chat-pdf-status-summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.chat-pdf-status-summary::-webkit-details-marker {
  display: none;
}

.chat-pdf-status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.chat-pdf-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, var(--workspace-bg));
  border: 1px solid var(--workspace-border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-pdf-pill strong {
  color: var(--text);
  font-weight: 600;
}

.chat-pdf-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--workspace-border);
  border-radius: var(--radius-lg, 12px);
  background: var(--workspace-card);
  overflow: hidden;
}

.chat-pdf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  scroll-behavior: smooth;
}

.chat-pdf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  text-align: center;
  padding: 2rem 1rem;
}

.chat-pdf-greeting {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.chat-turn {
  display: flex;
  gap: 0.75rem;
  max-width: min(920px, 100%);
  margin: 0 auto 1.25rem;
  animation: chat-fade-in 0.25s ease;
}

.chat-turn--assistant,
.chat-turn--welcome {
  max-width: min(960px, 100%);
}

.chat-turn--assistant .chat-turn-body,
.chat-turn--welcome .chat-turn-body {
  width: 100%;
}

@keyframes chat-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-turn--user {
  flex-direction: row-reverse;
}

.chat-turn--user .chat-turn-body {
  align-items: flex-end;
  text-align: right;
}

.chat-turn--user .chat-content {
  background: color-mix(in srgb, var(--accent) 12%, var(--workspace-bg));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--workspace-border));
  border-radius: 1rem 1rem 0.25rem 1rem;
  padding: 0.65rem 0.9rem;
}

.chat-turn--assistant .chat-content,
.chat-turn--welcome .chat-content {
  background: var(--workspace-bg);
  border: 1px solid var(--workspace-border);
  border-radius: 1rem 1rem 1rem 0.25rem;
  padding: 0.85rem 1rem;
}

/* ——— Chat : rendu Markdown riche ——— */
.chat-prose {
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}

.chat-prose h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.1rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--workspace-border);
  color: var(--text);
}

.chat-prose h2:first-child {
  margin-top: 0;
}

.chat-prose h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0.85rem 0 0.4rem;
  color: var(--text-muted);
}

.chat-prose ul,
.chat-prose ol {
  margin: 0.4rem 0 0.65rem;
  padding-left: 1.25rem;
}

.chat-prose li {
  margin: 0.25rem 0;
}

.chat-prose li em,
.chat-prose p em {
  font-style: normal;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.9;
}

.chat-prose strong {
  font-weight: 600;
  color: var(--text);
}

.chat-prose code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 8%, var(--workspace-bg));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-table-wrap {
  overflow-x: auto;
  margin: 0.65rem 0;
  border: 1px solid var(--workspace-border);
  border-radius: 8px;
  background: var(--workspace-card);
}

.chat-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 0;
}

.chat-prose th,
.chat-prose td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--workspace-border);
  text-align: left;
  vertical-align: top;
}

.chat-prose th {
  background: color-mix(in srgb, var(--accent) 6%, var(--workspace-bg));
  font-weight: 600;
  white-space: nowrap;
}

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

.chat-prose tr:hover td {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.chat-sources-panel {
  border: 1px solid var(--workspace-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--workspace-bg) 80%, var(--workspace-card));
  font-size: 0.75rem;
}

.chat-sources-summary {
  cursor: pointer;
  padding: 0.45rem 0.65rem;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
}

.chat-sources-summary::-webkit-details-marker {
  display: none;
}

.chat-sources-body {
  margin: 0;
  padding: 0.5rem 0.65rem 0.65rem;
  white-space: pre-wrap;
  color: var(--text-muted);
  font-size: 0.72rem;
  border-top: 1px dashed var(--workspace-border);
  max-height: 12rem;
  overflow-y: auto;
}

.chat-turn-avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--workspace-bg);
  border: 1px solid var(--workspace-border);
  font-size: 0.95rem;
}

.chat-turn-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-turn-label,
.chat-welcome-label {
  margin: 0 0 0.35rem;
}

.chat-loading-dots {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.5rem 0;
}

.chat-loading-dots span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: chat-dot 1.2s infinite ease-in-out;
}

.chat-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.35; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.15); }
}

.chat-pdf-composer {
  flex-shrink: 0;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--workspace-border);
  background: color-mix(in srgb, var(--workspace-bg) 60%, var(--workspace-card));
}

.chat-pdf-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.chat-sugg-pill {
  border: 1px solid var(--workspace-border);
  background: var(--workspace-card);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.chat-sugg-pill:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--workspace-card));
}

.chat-sugg-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-pdf-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  border: 1px solid var(--workspace-border);
  border-radius: 999px;
  background: var(--workspace-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-pdf-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  padding: 0.5rem 0;
  outline: none;
  color: var(--text);
}

.chat-pdf-send {
  border-radius: 999px !important;
  padding: 0.5rem 1.1rem !important;
  min-height: 2.25rem;
}

.chat-pdf-composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.chat-pdf-clear {
  color: var(--text-muted);
  text-decoration: none;
}

.chat-pdf-clear:hover {
  color: var(--accent);
}

.chat-pdf-main .prose table,
.chat-turn .prose table {
  font-size: 0.8rem;
}

.chat-turn .prose p:first-child {
  margin-top: 0;
}

.chat-turn .prose p:last-child {
  margin-bottom: 0;
}

.chat-turn--error .chat-content {
  background: color-mix(in srgb, var(--danger, #dc2626) 8%, var(--workspace-bg));
  border-color: color-mix(in srgb, var(--danger, #dc2626) 35%, var(--workspace-border));
  color: var(--danger, #dc2626);
}

@media (max-width: 767px) {
  .chat-pdf-page {
    height: calc(100dvh - 4.75rem);
    min-height: 360px;
  }

  .chat-pdf-suggestions {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .chat-sugg-pill {
    flex-shrink: 0;
  }

  .topbar-chat-shortcuts .btn-sm {
    font-size: 0.72rem;
    padding: 0.35rem 0.55rem;
  }
}