/* ==========================================================================
   OrbitChain CSS - Design System Tour de Contrôle Spatiale & SaaS Industriel
   ========================================================================== */

:root {
  /* Mode Nuit (Défaut) */
  --bg-dark: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #19243d;
  --bg-input: #0f1626;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(0, 242, 254, 0.3);
  
  --text-primary: #f8fafc;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --accent-cyan: #00f2fe;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --header-bg: rgba(19, 27, 46, 0.85);
  --modal-bg: rgba(19, 27, 46, 0.95);
  --modal-overlay: rgba(5, 8, 16, 0.85);
  --table-stripe: rgba(255, 255, 255, 0.02);
  --table-hover: rgba(0, 242, 254, 0.04);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.37);

  --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  /* Mode Jour */
  --bg-dark: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: rgba(0, 0, 0, 0.09);
  --border-highlight: rgba(2, 132, 199, 0.35);
  
  --text-primary: #0f172a;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  
  --accent-cyan: #0284c7;
  --accent-blue: #2563eb;
  --accent-purple: #7c3aed;
  --accent-green: #059669;
  --accent-amber: #d97706;
  --accent-red: #dc2626;

  --header-bg: rgba(255, 255, 255, 0.9);
  --modal-bg: #ffffff;
  --modal-overlay: rgba(15, 23, 42, 0.6);
  --table-stripe: rgba(0, 0, 0, 0.02);
  --table-hover: rgba(2, 132, 199, 0.05);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Theme Toggle Control (Nuit / Jour / Auto) */
.theme-switch-control {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

[data-theme="light"] .theme-switch-control {
  background: rgba(226, 232, 240, 0.9);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.theme-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

.theme-btn:hover {
  color: var(--text-primary);
}

.theme-btn.active {
  background: var(--accent-cyan);
  color: #0b0f19;
  box-shadow: 0 2px 8px rgba(0, 242, 254, 0.3);
}

[data-theme="light"] .theme-btn.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

/* Header & Nav */
.app-header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
a.brand, a.brand:hover, a.brand:visited, a.brand:active {
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

/* Prestation : achat non stocke admis en nomenclature. Teinte distincte du
   cyan « achete » pour qu'on ne confonde pas une intervention avec un article
   qui entre en stock. */
.node-prod-badge.is-service {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.35);
}

.badge-tag {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0, 242, 254, 0.3);
  text-transform: uppercase;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--accent-green);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.7; box-shadow: 0 0 4px var(--accent-green); }
  50% { transform: scale(1.4); opacity: 1; box-shadow: 0 0 12px var(--accent-green); }
  100% { transform: scale(1); opacity: 0.7; box-shadow: 0 0 4px var(--accent-green); }
}

/* User Profile & Organization Badge Header */
.user-profile-header-container {
  position: relative;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 12px 4px 6px;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.user-profile-badge:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-card-hover);
  box-shadow: 0 2px 10px rgba(0, 242, 254, 0.15);
}

.user-avatar-circle {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  border-radius: 50% !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
  background: linear-gradient(135deg, #0284c7, #3b82f6);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
  box-sizing: border-box !important;
}

.user-avatar-circle[style*="width: 32px"],
.user-avatar-circle.avatar-md {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
}

#settings-profile-avatar,
.user-avatar-circle.avatar-lg {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  min-height: 52px !important;
  max-width: 52px !important;
  max-height: 52px !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.user-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.775rem;
  color: var(--text-primary);
}

.badge-role {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 700;
}

.user-org-name {
  font-size: 0.675rem;
  color: var(--text-muted);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User Profile Dropdown Menu */
.user-profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: 92vw;
  box-sizing: border-box;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  padding: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeInDown 0.15s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: 4px 6px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dropdown-header strong {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 700;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

.dropdown-section-title {
  font-size: 0.675rem;
  color: var(--text-muted);
  font-weight: 700;
  padding: 2px 4px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.dropdown-roles-switch {
  display: flex;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  margin: 2px 0 4px 0;
}

.btn-role-switch {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 7px 4px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

.btn-role-switch:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
  background: rgba(56, 189, 248, 0.08);
}

.btn-role-switch.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color);
}

.dropdown-item.dropdown-item-logout {
  color: #f87171;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  margin-top: 4px;
}

.dropdown-item.dropdown-item-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  max-width: 1440px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}

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

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex: 0 1 auto;
}

.nav-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.05);
}

.badge-count {
  background: var(--accent-amber);
  color: #000;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 10px;
}

@media (max-width: 1360px) {
  .nav-tabs {
    padding: 0 8px;
  }
  .nav-tab {
    padding: 9px 8px;
    font-size: 0.775rem;
    gap: 4px;
  }
}

/* Main Layout */
.main-content {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards & Grids */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
}

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

.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex: none;
}

.kpi-icon svg {
  width: 18px;
  height: 18px;
}

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.kpi-subtext {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.charts-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 320px; }
.flex-2 { flex: 2; min-width: 480px; }

.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-container {
  position: relative;
  height: 320px;
  width: 100%;
  margin-top: 16px;
}

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

.card-header h2, .card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.badge-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* Controls & Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #000;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.input-control, .select-control, .form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-control:focus, .select-control:focus, .form-input:focus, .form-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(0, 242, 254, 0.15);
}

select.input-control, select.form-input, select.select-control, select.form-select {
  cursor: pointer;
  appearance: auto;
}

input[type="range"] {
  accent-color: var(--accent-cyan);
  cursor: pointer;
  height: 6px;
  border-radius: 4px;
}

.filter-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Badges */
.badge {
  display: inline-block;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger  { background: rgba(239, 68, 68, 0.15);  color: var(--accent-red);   border: 1px solid rgba(239, 68, 68, 0.3); }
/* Sans objet plutôt que nul : une prestation n'a pas de stock, ce n'est pas un
   stock à zéro. La pastille reste neutre pour ne pas se lire comme une alerte. */
.badge-neutral { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); border: 1px solid rgba(100, 116, 139, 0.3); }
.badge-info    { background: rgba(0, 242, 254, 0.15);  color: var(--accent-cyan);  border: 1px solid rgba(0, 242, 254, 0.3); }

/* Suppliers Grid */
.suppliers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.supplier-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.supplier-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 24px rgba(0, 242, 254, 0.12);
  transform: translateY(-2px);
}

.supplier-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.supplier-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.supplier-code {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.supplier-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Info Box */
.info-box {
  background: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* Parts Advanced Filter System */
.parts-filter-section {
  background: rgba(15, 22, 38, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.quick-search-wrapper {
  position: relative;
  width: 100%;
}

.quick-search-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.quick-search-wrapper .search-input {
  width: 100%;
  padding-left: 40px;
  font-size: 0.9rem;
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.12);
}

.quick-search-wrapper .search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.advanced-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  transition: all 0.3s ease;
}

.advanced-filters-grid.hidden {
  display: none;
}

.filter-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  min-height: 58px;
}

.filter-label {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 18px;
  line-height: 18px;
  display: block;
}

.filter-group .select-control {
  width: 100%;
  height: 36px;
  background: var(--bg-card);
  font-size: 0.825rem;
}

/* View Mode Switcher (Matrice vs Liste) */
.view-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-card-hover);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.btn-view-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-view-mode:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-view-mode.active {
  color: #0b1120;
  background: var(--accent-cyan);
  font-weight: 700;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

/* Utility Classes */
.hidden { display: none !important; }
.margin-top-sm { margin-top: 10px; }
.margin-top-md { margin-top: 16px; }
.margin-top-lg { margin-top: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-amber { color: var(--accent-amber); }
.font-mono { font-family: var(--font-mono); }

/* Modal & Product Sheet Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  max-width: 920px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-color);
  padding: 24px 28px 20px 28px;
  background: var(--bg-card);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.modal-body {
  padding: 24px 28px;
}

.modal-title-box h2 {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* Fiche fournisseur : ligne « code • pays » suivie du contact achats. */
.supplier-sheet-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin-top: 2px;
}

.supplier-sheet-contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.supplier-sheet-contact:hover {
  color: var(--accent-cyan);
  text-decoration: underline;
}

/* Price list fournisseur (onglet catalogue de la fiche fournisseur). */
.supp-catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.supp-catalog-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Valeur reprise de l'article faute de valeur fournisseur (MOQ, délai). */
.price-line-fallback {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-muted);
}

.price-line-tiers-count {
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

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

/* Éditeur de ligne de tarif, empilé au-dessus de la fiche fournisseur. */
.price-line-modal {
  max-width: 760px;
  display: flex;
  flex-direction: column;
}

.price-line-subtitle {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.price-line-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.price-line-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.price-line-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.price-line-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.price-line-money {
  display: flex;
  gap: 6px;
}

.price-line-money input { flex: 1; min-width: 0; }
.price-line-money select { flex: 0 0 96px; }

.price-line-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.price-line-tiers {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.price-line-tiers-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.price-line-tiers-head strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.price-line-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.price-line-tier-table {
  width: 100%;
  border-collapse: collapse;
}

.price-line-tier-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 0 6px 6px 0;
}

.price-line-tier-table td {
  padding: 0 6px 6px 0;
}

.price-line-tier-table td:last-child,
.price-line-tier-table th:last-child {
  width: 32px;
  padding-right: 0;
}

.price-line-tier-remove {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.price-line-tier-remove:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.price-line-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price-line-footer-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.price-line-delete:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

/* Fiche fournisseur : largeurs par défaut des colonnes, calées sur leur
   contenu mesuré (libellé d'en-tête compris). Les colonnes courtes sont fixes
   pour ne jamais tronquer une date, un montant ou un statut ; la désignation
   (resp. la pièce), sans largeur, absorbe le reste. Sous 1220px, la table
   défile horizontalement plutôt que de couper l'information. Chaque largeur
   reste au-dessus du seuil où le moteur replie l'en-tête en icône (~90px).
   Base = libellés FR ; surcharges :lang() là où l'EN ou le PT est plus long.
   Le moteur de colonnes écrit ses largeurs en inline sur les <col> : un
   redimensionnement manuel l'emporte, et le double-clic de réinitialisation
   ramène ici. */
#modal-supplier-sheet .data-table { min-width: 1220px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.ref"] { width: 133px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.cost"] { width: 116px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.leadtime"] { width: 95px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.allocation"] { width: 121px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.action"] { width: 96px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.supplierRef"] { width: 134px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.moq"] { width: 101px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.origin"] { width: 120px; }
#modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.tiers"] { width: 96px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.number"] { width: 175px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.status"] { width: 108px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.orderDate"] { width: 138px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.expected"] { width: 144px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.actual"] { width: 141px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.qty"] { width: 93px; }
#modal-supplier-sheet col[data-col-key="supplierModal.pos.th.total"] { width: 132px; }
html:lang(en) #modal-supplier-sheet col[data-col-key="supplierModal.pos.th.expected"] { width: 152px; }
html:lang(en) #modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.tiers"] { width: 103px; }
html:lang(pt) #modal-supplier-sheet col[data-col-key="supplierModal.catalog.th.cost"] { width: 131px; }
html:lang(pt) #modal-supplier-sheet col[data-col-key="supplierModal.pos.th.orderDate"] { width: 162px; }
html:lang(pt) #modal-supplier-sheet col[data-col-key="supplierModal.pos.th.expected"] { width: 146px; }
html:lang(pt) #modal-supplier-sheet col[data-col-key="supplierModal.pos.th.total"] { width: 139px; }

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: var(--accent-red);
}

.clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.clickable-row:hover td {
  background-color: rgba(56, 189, 248, 0.08) !important;
}

/* Resizable Table Columns & Handles */
.resizable-table {
  table-layout: fixed !important;
  width: 100%;
  border-collapse: collapse;
}

.resizable-table th {
  position: relative;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 25px;
  padding: 10px 10px;
  box-sizing: border-box;
  transition: color 0.16s ease;
}

.resizable-table th > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.resizable-table th span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.resizable-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0; /* Permet à table-layout: fixed de tronquer proprement avec des ellipses */
  padding: 10px 10px;
  box-sizing: border-box;
}

.resizable-table td * {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resizable-table td a,
.resizable-table td span,
.resizable-table td strong,
.resizable-table td div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* 5.3 Poignée de déplacement des colonnes (⋮⋮) : visible au survol de
   l'en-tête, drag & drop sans casser le tri au clic. Double-clic = ordre
   d'origine. Indicateurs bleu cyan pendant le survol de la cible. */
.col-drag {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  cursor: grab;
  opacity: 0;
  padding: 0 2px;
  font-size: 0.75rem;
  letter-spacing: -2px;
  color: var(--text-muted, #64748b);
  user-select: none;
}
/* Place permanente pour la poignée : le libellé ne bouge pas au survol. */
.resizable-table th {
  padding-left: 20px;
}
.resizable-table th:hover .col-drag {
  opacity: 0.55;
}
.col-drag:hover {
  opacity: 1 !important;
  color: var(--accent-cyan, #38bdf8);
}
.col-drag:active {
  cursor: grabbing;
}
.resizable-table th.dragging-col {
  opacity: 0.4;
}
.resizable-table th.col-drop-before {
  box-shadow: inset 2px 0 0 var(--accent-cyan, #38bdf8);
}
.resizable-table th.col-drop-after {
  box-shadow: inset -2px 0 0 var(--accent-cyan, #38bdf8);
}

/* 5.3b Icône de repli + transition vortex : quand la colonne devient trop
   étroite, le libellé tourbillonne (rotation + rétrécissement + fondu) vers
   une icône SVG centrée, et inversement à l'élargissement. Transform/opacity
   uniquement : aucune incidence sur la mise en page (pas de boucle
   ResizeObserver), aucun halo ni décor. */
.resizable-table th > .col-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  color: var(--text-muted, #64748b);
  opacity: 0;
  transform: rotate(140deg) scale(0.3);
  transition: opacity 0.16s ease, transform 0.24s cubic-bezier(0.3, 1.45, 0.6, 1);
  pointer-events: none;
}
.resizable-table th > .col-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.resizable-table th > :not(.col-drag):not(.col-resizer):not(.col-icon) {
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(0.5, 0, 0.6, 1);
  transform-origin: 50% 50%;
}
.resizable-table th.col-collapsed > :not(.col-drag):not(.col-resizer):not(.col-icon) {
  opacity: 0;
  transform: rotate(-200deg) scale(0.25);
  pointer-events: none;
}
.resizable-table th.col-collapsed > .col-icon {
  opacity: 0.9;
  transform: rotate(0deg) scale(1);
}
/* Thead statiques (alertes, production…) : le libellé est un nœud texte
   direct qu'aucun sélecteur ne peut masquer — on le rend transparent.
   L'icône et la poignée gardent leur propre couleur et restent visibles. */
.resizable-table th.col-collapsed {
  color: transparent;
}
.resizable-table th.col-collapsed > .col-drag {
  color: var(--text-muted, #64748b);
}

.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
  touch-action: none;
}

/* 5.3c Visibilité des colonnes : menu clic droit, toast de rappel.
   Les cellules masquées sortent de la mise en page. */
.resizable-table .col-hidden {
  display: none;
}
.col-menu {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  max-width: 300px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 8px;
}
.col-menu-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #64748b);
  padding: 4px 8px 8px;
}
.col-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.col-menu-item:hover {
  background: var(--bg-card-hover, #273449);
}
.col-menu-item span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-menu-all {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 7px 8px;
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  background: transparent;
  color: var(--accent-cyan, #38bdf8);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.col-menu-all:hover {
  background: rgba(56, 189, 248, 0.1);
}
.col-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  z-index: 9999;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border, #334155);
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.8rem;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.col-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.col-resizer::after {
  content: '';
  position: absolute;
  top: 15%;
  bottom: 15%;
  right: 2px;
  width: 2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
  transition: all 0.15s ease;
}

.col-resizer:hover::after,
.col-resizer.is-resizing::after {
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-cyan, #38bdf8);
  box-shadow: 0 0 8px var(--accent-cyan, #38bdf8);
}

body.is-col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.part-cell-link {
  color: var(--accent-cyan, #38bdf8);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.part-cell-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* Agentic Intelligence & News Cards */
.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.clickable-news-card {
  cursor: pointer;
}

.news-card:hover, .clickable-news-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 25px rgba(0, 242, 254, 0.15);
}

.news-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.news-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.news-card-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-top: 6px;
}

.news-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.725rem;
  color: var(--text-muted);
}

.risk-progress-bar {
  width: 100px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.risk-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  animation: spin 1s linear infinite;
}

/* Scan Progress Status Banner */
.scan-status-banner {
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 4px 20px rgba(0, 242, 254, 0.15);
  transition: all 0.3s ease;
}

.scan-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.scan-status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pulsing-dot {
  width: 12px;
  height: 12px;
  background-color: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: pulse-glow 1.2s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes pulse-glow {
  0% { transform: scale(0.9); opacity: 0.7; box-shadow: 0 0 4px var(--accent-cyan); }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 16px var(--accent-cyan); }
  100% { transform: scale(0.9); opacity: 0.7; box-shadow: 0 0 4px var(--accent-cyan); }
}

.scan-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-amber));
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Planning & Gantt Timeline Styles */
/* Le planning defile DANS son cadre, pas avec la page. Sans hauteur bornee,
   le conteneur grandissait jusqu'a 68 000 px pour 816 commandes : l'en-tete
   marque `sticky` ne s'accrochait alors a rien — `overflow-x: auto` fait deja
   du conteneur un scrollport vertical, mais qui ne defilait jamais — et la
   rangee des mois comme le repere « aujourd'hui » disparaissaient vers le haut
   des qu'on descendait dans la liste. */
#planning-gantt-container::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
#planning-gantt-container::-webkit-scrollbar-track {
  background: var(--bg-card);
}
#planning-gantt-container::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 4px;
}
#planning-gantt-container::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.5);
}

/* ==========================================================================
   Home Page / SaaS Portal Styles
   ========================================================================== */








/* Home Page / SaaS Portal Styles — blocs hero/workflow supprimés (morts, 2026-09-05) */
/* ==========================================================================
   Light Mode Theme Overrides
   ========================================================================== */
[data-theme="light"] {
  color-scheme: light;
}

[data-theme="light"] .card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .card-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .card-description {
  color: #475569;
}














[data-theme="light"] .btn-secondary {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
}

[data-theme="light"] .btn-secondary:hover {
  background: #f8fafc;
}

[data-theme="light"] .select-control,
[data-theme="light"] .input-control {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .select-control:focus,
[data-theme="light"] .input-control:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

[data-theme="light"] .nav-tab:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #0f172a;
}

[data-theme="light"] .nav-tab.active {
  background: rgba(2, 132, 199, 0.08);
  color: #0284c7;
}

[data-theme="light"] .kpi-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .kpi-card:hover {
  border-color: #0284c7;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.12);
}

[data-theme="light"] .kpi-title {
  color: #64748b;
  font-weight: 700;
}

[data-theme="light"] .kpi-value {
  color: #0f172a;
}

[data-theme="light"] .kpi-subtext {
  color: #475569;
}

[data-theme="light"] .modal-content {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .table-container,
[data-theme="light"] .data-table {
  background: #ffffff;
}

[data-theme="light"] .data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
}

[data-theme="light"] .data-table td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: #334155;
}

[data-theme="light"] .data-table tr:hover td {
  background: rgba(2, 132, 199, 0.04);
}

[data-theme="light"] .news-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
  color: #0f172a;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .news-card:hover {
  border-color: #0284c7;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.1);
}

[data-theme="light"] .badge-tag {
  background: rgba(2, 132, 199, 0.08);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.25);
}

[data-theme="light"] .badge-info {
  background: rgba(2, 132, 199, 0.1);
  color: #0369a1;
  border-color: rgba(2, 132, 199, 0.25);
}

[data-theme="light"] .badge-warning {
  background: rgba(217, 119, 6, 0.1);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.25);
}

[data-theme="light"] .badge-danger {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.25);
}

[data-theme="light"] .badge-success {
  background: rgba(5, 150, 105, 0.1);
  color: #047857;
  border-color: rgba(5, 150, 105, 0.25);
}

[data-theme="light"] #import-dropzone {
  background: rgba(241, 245, 249, 0.8) !important;
  border-color: rgba(2, 132, 199, 0.4) !important;
}

[data-theme="light"] .status-indicator {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.2);
}

[data-theme="light"] #planning-gantt-container {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
}

[data-theme="light"] #bom-view-catalog,
[data-theme="light"] #bom-view-detail {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
}

[data-theme="light"] .scan-status-banner {
  background: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 4px 18px rgba(2, 132, 199, 0.1);
}

[data-theme="light"] .risk-progress-bar {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .info-box {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
}

[data-theme="light"] input[type="date"] {
  color-scheme: light;
}

[data-theme="light"] .card-header h2,
[data-theme="light"] .card-header h3 {
  color: #0f172a;
}

[data-theme="light"] .erp-preset-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .erp-preset-card.active {
  background: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

[data-theme="light"] .nav-tab {
  color: #475569;
}

[data-theme="light"] .nav-tab.active {
  color: #0284c7;
  font-weight: 700;
}

[data-theme="light"] .user-profile-badge {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .user-profile-badge:hover {
  background: #f8fafc;
  border-color: #0284c7;
}

[data-theme="light"] .user-profile-dropdown {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .btn-role-switch {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.1);
  color: #475569;
}

[data-theme="light"] .btn-role-switch.active {
  background: rgba(2, 132, 199, 0.1);
  border-color: #0284c7;
  color: #0284c7;
}

[data-theme="light"] .dropdown-item:hover {
  background: #f1f5f9;
}

/* ===== RESPONSIVE — TABLET (max-width: 1024px) ===== */
@media (max-width: 1024px) {
  .header-container { flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .nav-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; gap: 2px; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .flex-2 { min-width: 0; }


}

/* ===== RESPONSIVE — MOBILE (max-width: 768px) ===== */
@media (max-width: 768px) {
  .header-container { flex-direction: column; align-items: stretch; padding: 8px 12px; }
  .app-title { font-size: 0.9rem; }
  .nav-tabs { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 0; }
  .nav-tab { font-size: 0.7rem; padding: 6px 10px; white-space: nowrap; }
  .main-content { padding: 12px; }
  .kpi-grid, .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .suppliers-grid { grid-template-columns: 1fr; }
  .card { padding: 12px; }
  .modal-container { width: 95vw; max-height: 85vh; margin: 8px; }
  .parts-filter-section { flex-direction: column; }
  .table-responsive { font-size: 0.75rem; }



}

/* ===== RESPONSIVE — SMALL MOBILE (max-width: 480px) ===== */
@media (max-width: 480px) {
  .kpi-grid, .kpi-grid-4 { grid-template-columns: 1fr; }
  .nav-tab span { display: none; }
  .header-status-group { display: none; }
  .modal-container { width: 100vw; max-height: 100vh; border-radius: 0; margin: 0; }
}

/* ==========================================================================
   INTERACTIVE COLLAPSIBLE BOM TREE EDITOR (MILESTONE 2)
   ========================================================================== */

.bom-tree-container {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

.bom-tree-header {
  display: grid;
  grid-template-columns: var(--bomtree-cols, minmax(320px, 2.5fr) 110px 100px 110px 120px 110px 140px 110px);
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.bom-tree-body {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 650px;
}

/* Poignées de redimensionnement des colonnes (même motif que .col-resizer du catalogue) */
.bom-tree-header > div {
  position: relative;
  min-width: 0;
}

.bom-tree-node {
  position: relative;
  display: flex;
  flex-direction: column;
}

.bom-tree-row {
  display: grid;
  grid-template-columns: var(--bomtree-cols, minmax(320px, 2.5fr) 110px 100px 110px 120px 110px 140px 110px);
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: background 0.15s ease, border-color 0.15s ease;
  font-size: 0.85rem;
  position: relative;
}

.bom-tree-row:hover {
  background: var(--bg-card-hover);
}

.bom-tree-row.is-critical {
  border-left: 3px solid var(--accent-red);
  background: rgba(239, 68, 68, 0.04);
}

.bom-tree-row.is-critical:hover {
  background: rgba(239, 68, 68, 0.08);
}

.node-tree-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tree-guide-indent {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  height: 100%;
}

.tree-branch-line {
  position: absolute;
  top: -16px;
  bottom: 50%;
  width: 16px;
  border-left: 1px dashed rgba(255, 255, 255, 0.15);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
  border-bottom-left-radius: 4px;
  pointer-events: none;
}

[data-theme="light"] .tree-branch-line {
  border-left-color: rgba(0, 0, 0, 0.2);
  border-bottom-color: rgba(0, 0, 0, 0.2);
}

.tree-toggle-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}

.tree-toggle-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.1);
}

.tree-toggle-btn.expanded .tree-chevron {
  transform: rotate(90deg);
}

.tree-toggle-spacer {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex-shrink: 0;
}

.tree-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Layer Badges */
.node-layer-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.675rem;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
  text-transform: uppercase;
}

.badge-l2 {
  background: rgba(139, 92, 246, 0.18);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.badge-l1 {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-l0 {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Single Source of Truth Reference Badge */
.badge-linked-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.675rem;
  font-weight: 700;
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.35);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.node-part-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-part-number {
  color: var(--accent-cyan);
  font-size: 0.85rem;
}

.node-part-name {
  color: var(--text-primary);
  font-size: 0.825rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Category Badge Truncation & Hover Expansion */
.node-category-cell {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 100%;
}

.node-cat-badge {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  box-sizing: border-box;
}

.node-cat-badge:hover {
  max-width: max-content;
  position: absolute;
  left: 0;
  z-index: 50;
  background: var(--bg-card);
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 242, 254, 0.4);
  white-space: nowrap;
}

.bom-tree-children {
  display: flex;
  flex-direction: column;
}

.bom-tree-children.collapsed {
  display: none;
}

/* Inline Quantity Inputs */
.inline-qty-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.input-inline-qty {
  width: 60px;
  padding: 3px 6px;
  font-size: 0.8rem;
  text-align: center;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.input-inline-qty:focus {
  border-color: var(--accent-cyan);
  outline: none;
}

/* Node action icons */
.node-actions-group {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.node-action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  transition: all 0.15s ease;
}

.node-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.node-action-btn.btn-action-add:hover {
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.1);
  border-color: rgba(0, 242, 254, 0.3);
}

.node-action-btn.btn-action-delete:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.node-crit-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.85rem;
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.node-crit-toggle.is-active {
  opacity: 1;
  color: var(--accent-red);
}

.node-crit-toggle:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Summary Metric Pills */
.bom-summary-pills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  width: 100%;
}

.bom-metric-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bom-metric-pill .pill-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.bom-metric-pill .pill-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Light theme overrides for tree view */
[data-theme="light"] .bom-tree-container {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .bom-tree-header {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

[data-theme="light"] .bom-tree-row {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .bom-tree-row:hover {
  background: #f1f5f9;
}

[data-theme="light"] .bom-tree-row.is-critical {
  background: rgba(239, 68, 68, 0.05);
}

[data-theme="light"] .bom-metric-pill {
  background: #ffffff;
  border-color: #e2e8f0;
}

/* ==========================================================================
   Logo rotatif en arrière-plan du hero (fond débordant, cropé haut/bas)
   ========================================================================== */
.hero-bg-logo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}

/* Le logo déborde volontairement du hero de 150px de haut :
   l'overflow:hidden du conteneur le coupe en bas et en haut (-75px chacun). */
.hero-bg-logo img {
  height: calc(100% + 150px);
  width: auto;
  aspect-ratio: 1 / 1;
  opacity: 0.10;
  animation: hero-logo-rotate 120s linear infinite;
  will-change: transform;
}





[data-theme="light"] .hero-bg-logo img {
  opacity: 0.07;
}

@keyframes hero-logo-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-bg-logo img { animation: none; }
}

#war-room-table th { position: sticky; top:0; background: var(--bg-card-hover); text-align:left; padding:6px 8px; border-bottom:1px solid var(--border-color); font-size:0.72rem; color:var(--text-muted); }
#war-room-table td { padding:6px 8px; border-bottom:1px solid rgba(255,255,255,0.06); }
#war-room-table tr:hover { background: rgba(245,158,11,0.06); }

/* ==========================================================================
   Centre de Paramètres & Administration (Enterprise Settings Control Center)
   ========================================================================== */
.settings-modal-container {
  max-width: 1080px;
  width: 94vw;
  height: 85vh;
  max-height: 820px;
  min-height: 520px;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  background: var(--bg-card);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[data-theme="light"] .settings-modal-container {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

/* Mode Agrandissement Studio PO avec Bandeau Latéral Compact */
.settings-modal-container.po-studio-active {
  max-width: 98vw;
  width: 98vw;
  height: 96vh;
  max-height: 96vh;
  transition: all 0.2s ease-out;
}

.settings-modal-container.po-studio-active .settings-sidebar {
  width: 145px;
  min-width: 145px;
  max-width: 145px;
  padding: 10px 6px;
  transition: all 0.2s ease;
}

.settings-modal-container.po-studio-active .settings-sidebar .settings-nav-btn {
  padding: 7px 8px;
  gap: 7px;
  font-size: 0.76rem;
  border-radius: 6px;
}

.settings-modal-container.po-studio-active .settings-sidebar .settings-nav-btn span {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-modal-container.po-studio-active .settings-sidebar .settings-nav-group-title {
  font-size: 0.6rem;
  padding: 8px 4px 2px 4px;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mode Mini-Barre Ultra Compacte (Icônes seules) */
.settings-sidebar.is-collapsed {
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  padding: 10px 4px !important;
}

.settings-sidebar.is-collapsed .settings-nav-group-title {
  display: none !important;
}

.settings-sidebar-divider {
  height: 1px;
  min-height: 1px;
  background: var(--border-color);
  border-radius: 1px;
  margin: 8px 10px;
}

.settings-sidebar.is-collapsed .settings-nav-group-row {
  display: none !important;
}

.settings-sidebar.is-collapsed .settings-nav-btn {
  justify-content: center;
  padding: 9px 0;
  width: 100%;
}

.settings-sidebar.is-collapsed .settings-nav-btn span {
  display: none !important;
}

.settings-modal-container.po-studio-active .settings-content {
  padding: 12px 16px;
  gap: 10px;
}

/* Mode Plein Écran Total */
.settings-modal-container.po-studio-fullscreen {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}

.settings-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.settings-sidebar {
  width: 275px;
  min-width: 275px;
  max-width: 275px;
  background: rgba(10, 17, 34, 0.95);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 10px;
  overflow-y: auto;
}

[data-theme="light"] .settings-sidebar {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.settings-nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 10px 4px 10px;
  white-space: nowrap;
}

.settings-nav-group-title::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: var(--border-color);
}

.settings-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  width: 100%;
  outline: none;
  font-family: inherit;
  white-space: nowrap;
  min-height: 38px;
  box-sizing: border-box;
}

.settings-nav-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

[data-theme="light"] .settings-nav-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.settings-nav-btn.active {
  background: rgba(56, 189, 248, 0.12) !important;
  border-color: rgba(56, 189, 248, 0.35) !important;
  color: var(--accent-cyan) !important;
  font-weight: 500;
}

[data-theme="light"] .settings-nav-btn.active {
  background: #e0f2fe !important;
  border-color: #38bdf8 !important;
  color: #0284c7 !important;
  font-weight: 500;
}

.settings-nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  opacity: 0.75;
}

.settings-nav-btn.active svg {
  opacity: 1;
  stroke: var(--accent-cyan);
}

[data-theme="light"] .settings-nav-btn.active svg {
  stroke: #0284c7;
}

.settings-content {
  flex: 1;
  padding: 22px 28px;
  overflow-y: auto;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

[data-theme="light"] .settings-content {
  background: #ffffff;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.settings-panel-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 700;
}

.settings-panel-desc {
  margin: 3px 0 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.settings-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

[data-theme="light"] .settings-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.settings-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.settings-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.settings-field-help {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.settings-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .settings-layout {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    min-width: unset;
    max-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 10px;
  }
  .settings-nav-group-title {
    display: none;
  }
  .settings-nav-btn {
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  .settings-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Sourcing Tree Hierarchy Styles */
#settings-family-policies-table-wrapper table tbody tr:hover {
  filter: brightness(1.08);
}
#settings-family-policies-table-wrapper input[type="number"] {
  border: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  border-radius: 4px;
  text-align: center;
  transition: border-color 0.15s;
}
#settings-family-policies-table-wrapper input[type="number"]:focus {
  border-color: var(--accent-cyan);
  outline: none;
  background: rgba(15, 23, 42, 0.9);
}

/* ==========================================================================
   PO Template Designer (A4 Drag & Drop Studio)
   ========================================================================== */
.po-designer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.po-designer-toolbar-left,
.po-designer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group-segmented {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-segmented {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-segmented.active {
  background: var(--accent-cyan);
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.po-designer-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

.btn-icon-sm {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
}

.btn-icon-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color);
}

/* Studio 3-Column Layout */
.po-designer-studio-layout {
  display: grid;
  grid-template-columns: 255px minmax(480px, 1fr) 280px;
  gap: 12px;
  min-height: 600px;
  height: calc(96vh - 145px);
  position: relative;
  transition: grid-template-columns 0.2s ease;
}

.settings-modal-container.po-studio-fullscreen .po-designer-studio-layout {
  height: calc(100vh - 110px);
}

.po-designer-studio-layout.hide-palette {
  grid-template-columns: 0px minmax(480px, 1fr) 280px;
}

.po-designer-studio-layout.hide-palette .po-designer-palette {
  display: none !important;
}

.po-designer-studio-layout.hide-inspector {
  grid-template-columns: 255px minmax(480px, 1fr) 0px;
}

.po-designer-studio-layout.hide-inspector .po-designer-inspector {
  display: none !important;
}

.po-designer-studio-layout.hide-palette.hide-inspector {
  grid-template-columns: 1fr;
}

/* Left: Studio Palette (Modern & Sleek Figma-like Sidebar) */
.po-designer-palette {
  background: var(--bg-card, #0f172a);
  border: 1px solid var(--border-color, #1e293b);
  border-radius: var(--radius-md, 10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.po-palette-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.po-palette-scrollable {
  padding: 8px 6px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Palette Search Input */
.po-palette-search-wrapper {
  position: relative;
  margin-bottom: 6px;
}

.po-palette-search-wrapper input {
  font-size: 0.72rem;
  padding: 5px 8px 5px 26px;
  width: 100%;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.po-palette-search-wrapper input:focus {
  border-color: var(--accent-cyan);
  outline: none;
}

.po-palette-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Palette Group (Clean Accordion Header) */
.po-palette-group {
  display: flex;
  flex-direction: column;
}

.po-palette-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted, #94a3b8);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.po-palette-group-title:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.po-palette-group-title .po-group-title-text {
  display: flex;
  align-items: center;
  gap: 5px;
}

.po-palette-group-title .po-group-chevron {
  font-size: 0.55rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.po-palette-group.is-collapsed .po-group-chevron {
  transform: rotate(-90deg);
}

.po-palette-group-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.po-palette-group.is-collapsed .po-palette-group-body {
  display: none;
}

/* Component Blocks (Blocs tab) */
.po-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  transition: all 0.15s ease;
}

.po-palette-item:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateX(2px);
}

.po-palette-item:active {
  cursor: grabbing;
}

.po-palette-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.po-palette-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.po-palette-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.po-palette-sub {
  font-size: 0.63rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tag Items (Balises tab) */
.po-palette-tag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 7px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.po-palette-tag-item:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateX(2px);
}

.po-palette-tag-code {
  font-family: 'SF Mono', 'Roboto Mono', monospace;
  font-size: 0.71rem;
  color: var(--accent-cyan, #38bdf8);
  font-weight: 600;
  display: block;
}

.po-palette-tag-desc {
  font-size: 0.62rem;
  color: var(--text-muted, #94a3b8);
  display: block;
  margin-top: 1px;
}

.po-palette-tag-item .tag-add-icon {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.po-palette-tag-item:hover .tag-add-icon {
  opacity: 1;
  color: var(--accent-cyan);
}

/* Light Theme overrides */
[data-theme="light"] .po-palette-item,
[data-theme="light"] .po-palette-tag-item {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .po-palette-item:hover,
[data-theme="light"] .po-palette-tag-item:hover {
  background: #f0f9ff;
  border-color: #38bdf8;
}

[data-theme="light"] .po-palette-tag-code {
  color: #0284c7;
}

/* Center: Canvas */
.po-designer-canvas-container {
  background: #090d16;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 0);
  background-size: 16px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  position: relative;
}

.po-canvas-scale-wrapper {
  transform-origin: top center;
  transition: transform 0.15s ease-out;
}

.po-a4-sheet {
  width: 210mm;
  min-height: 297mm;
  height: 297mm;
  background: #ffffff;
  color: #0f172a;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-sizing: border-box;
}

.po-a4-margins-guide {
  position: absolute;
  top: 15mm;
  left: 15mm;
  right: 15mm;
  bottom: 15mm;
  border: 1px dashed rgba(2, 132, 199, 0.25);
  pointer-events: none;
  z-index: 1;
}

.po-a4-grid-layer {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
                    linear-gradient(to bottom, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 5mm 5mm;
  pointer-events: none;
  z-index: 1;
}

.po-a4-blocks-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Individual A4 Blocks */
.po-block {
  position: absolute;
  cursor: move;
  box-sizing: border-box;
  user-select: none;
  transition: box-shadow 0.15s ease;
}

.po-block:hover {
  outline: 1px dashed #0284c7;
}

.po-block.selected {
  outline: 2px solid #0284c7 !important;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.2);
  z-index: 100;
}

.po-block.editing-inline {
  outline: 2px dashed var(--accent-cyan) !important;
  background: rgba(56, 189, 248, 0.08) !important;
  cursor: text !important;
  user-select: text !important;
  z-index: 200 !important;
}

.po-block.editing-inline * {
  user-select: text !important;
}

/* Floating Formatting Bubble Toolbar */
.po-floating-format-bar {
  position: fixed;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  border: 1px solid #475569;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  padding: 4px 8px;
  backdrop-filter: blur(12px);
  transform: translate(-50%, -100%);
  margin-top: -8px;
  pointer-events: auto;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.po-floating-format-bar.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.po-floating-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.po-floating-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.po-floating-select {
  background: #0f172a;
  border: 1px solid #475569;
  color: #f8fafc;
  font-size: 0.72rem;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}

.po-floating-color-picker {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

/* Resize Handles */
.po-resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #0284c7;
  border: 1px solid #ffffff;
  border-radius: 2px;
  z-index: 101;
}

.po-resize-handle.tl { top: -4px; left: -4px; cursor: nwse-resize; }
.po-resize-handle.tr { top: -4px; right: -4px; cursor: nesw-resize; }
.po-resize-handle.bl { bottom: -4px; left: -4px; cursor: nesw-resize; }
.po-resize-handle.br { bottom: -4px; right: -4px; cursor: nwse-resize; }
.po-resize-handle.tm { top: -4px; left: calc(50% - 4px); cursor: ns-resize; }
.po-resize-handle.bm { bottom: -4px; left: calc(50% - 4px); cursor: ns-resize; }
.po-resize-handle.lm { top: calc(50% - 4px); left: -4px; cursor: ew-resize; }
.po-resize-handle.rm { top: calc(50% - 4px); right: -4px; cursor: ew-resize; }

/* Right: Inspector */
.po-designer-inspector {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.po-inspector-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.po-inspector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  height: 100%;
}

.po-inspector-form {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.po-prop-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.po-prop-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.po-prop-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.po-prop-label {
  display: block;
  font-size: 0.725rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.po-prop-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

@media print {
  body * {
    visibility: hidden;
  }
  .po-a4-sheet, .po-a4-sheet * {
    visibility: visible;
  }
  .po-a4-sheet {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm !important;
    height: 297mm !important;
    box-shadow: none !important;
  }
  .po-a4-margins-guide,
  .po-a4-grid-layer,
  .po-resize-handle {
    display: none !important;
  }
}

/* ==========================================================================
   Purchase Order Generator Modal (#modal-po-generator) Styles
   ========================================================================== */

.po-generator-modal-container {
  max-width: 1240px;
  width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #111827);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.15);
  border-radius: 16px;
  overflow: hidden;
}

.po-gen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  gap: 16px;
  flex-wrap: wrap;
}

.po-wizard-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 8px;
  border-radius: 30px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.po-wizard-step-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.po-wizard-step-btn:hover {
  color: var(--text-primary, #f8fafc);
  background: rgba(255, 255, 255, 0.05);
}

.po-wizard-step-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(14, 165, 233, 0.35));
  color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.po-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 0.72rem;
  font-weight: 700;
}

.po-wizard-step-btn.active .po-step-num {
  background: #38bdf8;
  color: #0f172a;
}

.po-wizard-step-line {
  width: 16px;
  height: 2px;
  background: rgba(255, 255, 255, 0.15);
}

.po-gen-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg-primary, #0b0f19);
}

.po-gen-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}

.po-gen-card {
  background: var(--bg-card, #111827);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.po-gen-card-title {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

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

.po-gen-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.po-gen-supplier-info-box {
  background: rgba(56, 189, 248, 0.04);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.775rem;
  line-height: 1.5;
}

.po-gen-table-container {
  background: var(--bg-card, #111827);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.po-gen-items-table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}

.po-gen-items-table th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-secondary, #94a3b8);
  font-weight: 700;
  padding: 8px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
}

.po-gen-items-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.po-gen-item-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary, #f8fafc);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.775rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.po-gen-item-input:focus {
  border-color: var(--accent-cyan, #38bdf8);
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.25);
}

.po-gen-financial-footer {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-top: 14px;
  align-items: start;
}

.po-gen-totals-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.po-gen-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary, #94a3b8);
}

.po-gen-total-row.total-highlight {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary, #f8fafc);
}

/* Step 2 Preview Area */
.po-gen-preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  margin-bottom: 14px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.po-gen-preview-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.po-gen-canvas-viewport {
  width: 100%;
  min-height: 580px;
  max-height: calc(85vh - 220px);
  overflow: auto;
  background: #070a12;
  border-radius: 12px;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.po-gen-canvas-scale-wrapper {
  transform-origin: top center;
  transition: transform 0.15s ease-out;
}

.po-gen-a4-sheet {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  height: 297mm;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  overflow: hidden;
}

.po-gen-a4-sheet .po-block {
  cursor: text;
  transition: outline 0.15s ease;
}

.po-gen-a4-sheet .po-block:hover {
  outline: 1px dashed rgba(2, 132, 199, 0.4);
}

.po-gen-a4-sheet .po-block.editing-inline {
  outline: 2px solid #0284c7 !important;
  background: rgba(2, 132, 199, 0.02) !important;
  cursor: text !important;
  z-index: 10;
}

.po-gen-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
}

.po-gen-footer-left,
.po-gen-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 900px) {
  .po-gen-config-grid {
    grid-template-columns: 1fr;
  }
  .po-gen-financial-footer {
    grid-template-columns: 1fr;
  }
}






/* ==========================================================================
   ARBORESCENCE BOM — bascule d'unité de lead time & badges compacts
   ========================================================================== */

/* Pastille ronde j / s / m dans l'en-tête de la colonne Lead Time. */
.lead-unit-toggle {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-transform: lowercase;
}

.lead-unit-toggle:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Mode compact : quand la colonne « Structure » est réduite, les badges de
   niveau et de type de production deviennent des pastilles colorées au lieu
   d'être rognés en « … ». Le code couleur porte alors toute l'information,
   l'explication restant dans l'attribut title.
   La bascule se fait en vortex : la pastille se contracte en tournant sur
   elle-meme et s'effondre en un point, le texte et l'icone se resorbant vers le
   centre. Le passage etait instantane, donc brutal a la traversee du seuil.

   `width: auto` ne s'interpole pas : la geometrie naturelle de chaque gabarit
   est mesuree une fois par `bomMeasurePillGeometry()` et posee en variables CSS.
   Sans elles, la largeur sauterait au lieu de glisser — le repli `auto` laisse
   simplement la bascule instantanee plutot que cassee. */
.bom-tree-body .node-layer-badge {
  width: var(--pill-w-layer, auto);
  height: var(--pill-h-layer, auto);
}
.bom-tree-body .node-prod-badge.is-make {
  width: var(--pill-w-make, auto);
  height: var(--pill-h-make, auto);
}
.bom-tree-body .node-prod-badge.is-buy {
  width: var(--pill-w-buy, auto);
  height: var(--pill-h-buy, auto);
}

.bom-tree-body .node-layer-badge,
.bom-tree-body .node-prod-badge {
  overflow: hidden;
  justify-content: center;
  transform-origin: 50% 50%;
}

/* L'animation n'est armee qu'apres la premiere mise en page : sans ce garde,
   l'ouverture de l'onglet ferait tournoyer toutes les pastilles a la fois. */
/* Liste volontairement courte. Une nomenclature large affiche plusieurs
   centaines de lignes, et chaque propriete raccourcie y est multipliee par
   autant de pastilles : animer aussi `padding`, `border-width`, `border-color`
   et `border-radius` faisait passer la bascule de ~2 300 a plus de 9 000
   transitions simultanees, pour un gain visuel nul — a 9 px, un rayon de 4 px
   est deja quasiment un cercle, et la bordure comme le padding disparaissent
   derriere le texte qui se resorbe. */
.bom-tree-body.vortex-ready .node-layer-badge,
.bom-tree-body.vortex-ready .node-prod-badge {
  transition:
    width 340ms cubic-bezier(0.36, 0.06, 0.22, 1),
    height 340ms cubic-bezier(0.36, 0.06, 0.22, 1),
    min-width 340ms cubic-bezier(0.36, 0.06, 0.22, 1),
    font-size 200ms ease-in,
    transform 340ms cubic-bezier(0.36, 0.06, 0.22, 1);
}
.bom-tree-body.vortex-ready .node-prod-badge svg {
  transition:
    transform 300ms cubic-bezier(0.36, 0.06, 0.22, 1),
    opacity 170ms ease-in;
}

.bom-tree-body.tags-compact .node-layer-badge,
.bom-tree-body.tags-compact .node-prod-badge {
  width: 9px;
  height: 9px;
  min-width: 9px;
  padding: 0;
  border-radius: 50%;
  border-width: 0;
  border-color: transparent;
  font-size: 0;
  line-height: 0;
  /* Un demi-tour : visible pendant la contraction, sans trace une fois le point
     forme — un disque tourne reste le meme disque. */
  transform: rotate(-180deg);
}

/* L'icone est aspiree vers le centre plutot que coupee net. */
.bom-tree-body.tags-compact .node-prod-badge svg {
  transform: scale(0) rotate(180deg);
  opacity: 0;
}

/* Mouvement reduit : on garde la bascule, on retire le tournoiement. */
@media (prefers-reduced-motion: reduce) {
  .bom-tree-body.vortex-ready .node-layer-badge,
  .bom-tree-body.vortex-ready .node-prod-badge,
  .bom-tree-body.vortex-ready .node-prod-badge svg {
    transition: none;
  }
  .bom-tree-body.tags-compact .node-layer-badge,
  .bom-tree-body.tags-compact .node-prod-badge {
    transform: none;
  }
}

.bom-tree-body.tags-compact .badge-l0 { background: #f87171; }
.bom-tree-body.tags-compact .badge-l1 { background: #fbbf24; }
.bom-tree-body.tags-compact .badge-l2 { background: #a78bfa; }
.bom-tree-body.tags-compact .node-prod-badge.is-make { background: var(--accent-cyan); }
.bom-tree-body.tags-compact .node-prod-badge.is-buy { background: var(--text-muted); }
.bom-tree-body.tags-compact .node-prod-badge.is-service { background: var(--accent-purple); }

/* Sélecteur de fournisseur dans une ligne d'arborescence : discret, il ne doit
   pas alourdir la ligne tant que l'utilisateur ne l'ouvre pas. */
.input-inline-supplier {
  width: 100%;
  max-width: 100%;
  padding: 3px 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.input-inline-supplier:hover,
.input-inline-supplier:focus {
  border-color: var(--border-color);
  background: var(--bg-card-hover);
  color: var(--text-primary);
  outline: none;
}

/* ==========================================================================
   NOMENCLATURE — sélecteur de vues, Gantt relatif et graphe SVG
   ========================================================================== */

.bom-view-switch {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.bom-alt-view {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.bom-gantt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-hover);
  flex-wrap: wrap;
}

.bom-gantt-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.775rem;
  color: var(--text-secondary);
}

.bom-gantt-total strong {
  font-size: 1.05rem;
  color: var(--accent-cyan);
}

.bom-gantt-body {
  max-height: calc(100vh - 360px);
  min-height: 320px;
  overflow: auto;
}

/* Une ligne = libellé (largeur réglable, var --bom-gantt-label-w) + champs de
   paramétrage (3 slots de 72px + gaps = 228px : cases de 58px centrées,
   libellés d'en-tête sans débordement) + piste temporelle. */
.bom-gantt-head,
.bom-gantt-row {
  display: grid;
  grid-template-columns: var(--bom-gantt-label-w, minmax(220px, 1.2fr)) 228px minmax(300px, 3fr);
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-color);
}

.bom-gantt-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-card-hover);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.bom-gantt-row.is-critical {
  box-shadow: inset 3px 0 0 var(--accent-red);
  background: rgba(239, 68, 68, 0.04);
}

.bom-gantt-label {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.8rem;
  position: relative;
  padding-right: 10px;
}
/* Poignée de largeur de la colonne Component (même geste que les tableaux). */
.bom-gantt-label-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 5;
}
.bom-gantt-label-resize::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  width: 2px;
  border-radius: 2px;
  background: var(--text-muted, #64748b);
}
.bom-gantt-label:hover .bom-gantt-label-resize {
  opacity: 0.7;
}
.bom-gantt-label-resize:hover {
  opacity: 1 !important;
}

.bom-gantt-label .node-part-name {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* Le code article tronque comme le nom quand on réduit la colonne (sinon le
   flex le garde à sa taille mini et il déborde). Il rétrécit 2× moins vite
   que le nom pour rester lisible le plus longtemps. */
.bom-gantt-label .node-part-number {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 0.5;
}
.bom-gantt-label .tree-toggle-btn,
.bom-gantt-label .tree-toggle-spacer {
  flex-shrink: 0;
}

.bom-gantt-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.bom-gantt-fields .bom-gantt-input,
.bom-gantt-fields .bom-gantt-na {
  justify-self: center;
}

.bom-gantt-input {
  width: 58px;
  text-align: center;
}
/* En-tête : chaque libellé centré dans son slot (mêmes slots que les cases).
   Police réduite : "PRODUCTION" doit tenir dans son slot sans déborder. */
.bom-gantt-head .bom-gantt-fields span {
  min-width: 0;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0;
  white-space: nowrap;
}

.bom-gantt-track {
  position: relative;
  height: 22px;
}

.bom-gantt-grid {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-color);
  opacity: 0.5;
}

.bom-gantt-scale {
  height: 18px;
}

.bom-gantt-scale .bom-gantt-grid span {
  position: absolute;
  top: 0;
  left: 3px;
  font-size: 0.625rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.bom-gantt-bar {
  position: absolute;
  top: 4px;
  height: 14px;
  border-radius: 4px;
  background: var(--accent-cyan);
  opacity: 0.85;
}

.bom-gantt-bar.is-critical {
  background: var(--accent-red);
  opacity: 1;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.55);
}

/* Bande englobante d'un parent : du démarrage au point de réception des
   enfants (phase propre ensuite en barre pleine). */
.bom-gantt-span {
  position: absolute;
  top: 4px;
  height: 14px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px dashed rgba(56, 189, 248, 0.45);
  box-sizing: border-box;
}
.bom-gantt-span.is-critical {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.5);
}
.bom-gantt-row:hover {
  background: rgba(56, 189, 248, 0.05);
}

/* Vues graphe/gantt : les contrôles d'édition, recherche, filtres et la fiche
   système se replient en douceur (pas de display:none = pas de saut).
   En Gantt : toolbar + War Room (la fiche système et l'ajout racine restent). */
#bom-view-detail #bom-tree-toolbar,
#bom-view-detail #assembly-info-box {
  overflow: hidden;
  max-height: 260px;
  opacity: 1;
  transition: max-height 0.28s ease, opacity 0.22s ease, margin 0.28s ease,
    padding 0.28s ease, border-width 0.28s ease;
}
#bom-view-detail.bom-is-graph #bom-tree-toolbar,
#bom-view-detail.bom-is-graph #assembly-info-box,
#bom-view-detail.bom-is-gantt #bom-tree-toolbar {
  max-height: 0 !important;
  opacity: 0;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-width: 0 !important;
  pointer-events: none;
}
#bom-view-detail #btn-add-root-bom-node,
#bom-view-detail #btn-war-room-bom {
  overflow: hidden;
  white-space: nowrap;
  max-width: 280px;
  transition: max-width 0.28s ease, opacity 0.22s ease, margin 0.28s ease,
    padding 0.28s ease, border-width 0.28s ease;
}
#bom-view-detail.bom-is-graph #btn-add-root-bom-node,
#bom-view-detail.bom-is-graph #btn-war-room-bom,
#bom-view-detail.bom-is-gantt #btn-war-room-bom {
  max-width: 0 !important;
  opacity: 0;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border-width: 0 !important;
  pointer-events: none;
}

/* 2b — Glisser-déposer : poignée de redimensionnement, curseurs, infobulle. */
#bom-gantt-body.can-drag .bom-gantt-bar,
#bom-gantt-body.can-drag .bom-gantt-production,
#bom-gantt-body.can-drag .bom-gantt-span {
  cursor: grab;
}
.bom-gantt-resize {
  position: absolute;
  top: 2px;
  width: 9px;
  height: 18px;
  margin-left: 0;
  border-radius: 4px;
  background: rgba(241, 245, 249, 0.55);
  opacity: 0;
  cursor: ew-resize;
  z-index: 4;
  transition: opacity 0.15s ease;
}
.bom-gantt-row:hover .bom-gantt-resize {
  opacity: 0.85;
}
.bom-gantt-resize:hover {
  opacity: 1 !important;
  background: #fff;
}
body.bom-gantt-dragging,
body.bom-gantt-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}
.bom-gantt-dragtip {
  position: fixed;
  display: none;
  z-index: 9999;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border, #334155);
  color: var(--text-primary, #f1f5f9);
  font-size: 0.75rem;
  font-family: monospace;
  padding: 6px 10px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  white-space: nowrap;
}

/* Le temps de production interne prolonge la barre dans une teinte distincte :
   on doit voir d'un coup d'oeil ce qui est approvisionnement et ce qui est
   fabrication maison. */
.bom-gantt-production {
  position: absolute;
  top: 4px;
  height: 14px;
  border-radius: 0 4px 4px 0;
  background: var(--accent-amber);
  opacity: 0.85;
}

/* Sur une pièce achetée, la colonne production reste occupée par un tiret pour
   que les trois colonnes restent alignées d'une ligne à l'autre. */
.bom-gantt-na {
  display: inline-block;
  width: 58px;
  text-align: center;
  opacity: 0.45;
}

/* (La marge de sécurité traînante a été remplacée par le décalage du
   démarrage : voir .bom-gantt-span et le modèle englobant.) */

.bom-graph-body {
  height: calc(100vh - 360px);
  min-height: 400px;
  overflow: hidden;
  background: var(--bg-card);
}

.bom-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.825rem;
}

/* ==========================================================================
   TABLEAU DE BORD PERSONNALISABLE
   Grille 12 colonnes, widgets dans le flux : deplacer = reordonner, agrandir =
   occuper plus de colonnes et de rangees. Aucun chevauchement n'est possible,
   et la disposition reste lisible a toutes les largeurs.
   ========================================================================== */

.dashboard-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dashboard-actions { display: flex; align-items: center; gap: 8px; }
.dashboard-edit-tools { display: inline-flex; gap: 8px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: 104px;
  gap: 14px;
}

.dash-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

.dash-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--border-color);
}

.dash-widget-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Les outils n'apparaissent qu'en mode personnalisation : en lecture, le
   tableau de bord doit rester un tableau de bord, pas un editeur. */
.dash-widget-tools { display: none; gap: 4px; flex-shrink: 0; }
.dashboard-grid.is-editing .dash-widget-tools { display: inline-flex; }

.dash-tool {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 5px;
  line-height: 0;
}
.dash-tool:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.dash-tool-danger:hover { color: var(--accent-red); border-color: var(--accent-red); }

.dash-widget-body {
  flex: 1;
  min-height: 0;
  padding: 10px 12px 12px;
  overflow: auto;
}

.dash-kpi { display: flex; flex-direction: column; justify-content: center; height: 100%; }
.dash-kpi-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.dash-kpi-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.dash-chart { position: relative; height: 100%; min-height: 120px; }
.dash-table-wrap { height: 100%; overflow: auto; }
.dash-table th, .dash-table td { font-size: 0.72rem; padding: 5px 8px; }

.dash-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: 0.75rem; text-align: center;
}

.dash-blank {
  grid-column: 1 / -1;
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.dash-blank p { margin-bottom: 14px; }

/* --- Mode personnalisation --- */
.dashboard-grid.is-editing .dash-widget {
  border-color: rgba(0, 242, 254, 0.35);
  cursor: grab;
  user-select: none;
}
.dashboard-grid.is-editing .dash-widget.is-dragging {
  cursor: grabbing;
  opacity: 0.55;
  border-color: var(--accent-cyan);
}
.dashboard-grid.is-editing .dash-widget.is-resizing { border-color: var(--accent-cyan); }

/* Poignee de redimensionnement : un coin discret, visible seulement en edition. */
.dash-resize { display: none; }
.dashboard-grid.is-editing .dash-resize {
  display: block;
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  border-right: 2px solid var(--accent-cyan);
  border-bottom: 2px solid var(--accent-cyan);
  border-bottom-right-radius: 4px;
  opacity: 0.6;
}

/* --- Bibliotheque --- */
.lib-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 12px 24px; border-bottom: 1px solid var(--border-color);
}
.lib-tab {
  background: transparent; border: 1px solid var(--border-color); border-radius: 6px;
  color: var(--text-secondary); cursor: pointer; font-size: 0.75rem; padding: 5px 11px;
}
.lib-tab:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.lib-tab.active { color: var(--bg-card); background: var(--accent-cyan); border-color: var(--accent-cyan); font-weight: 600; }

.lib-body { padding: 16px 24px 24px; overflow-y: auto; }
.lib-section { margin-bottom: 24px; }
.lib-section h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.widget-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-card);
}
.widget-card.is-placed { border-style: dashed; }
.widget-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.widget-card-head strong { font-size: 0.8rem; color: var(--text-primary); }
.widget-card-desc { font-size: 0.72rem; color: var(--text-muted); margin: 0; flex: 1; }
.widget-card-reason {
  font-size: 0.72rem; color: var(--accent-cyan); margin: 0;
  border-left: 2px solid var(--accent-cyan); padding-left: 8px;
}
.widget-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }

/* Sur petit ecran, la grille 12 colonnes n'a plus de sens : chaque widget
   occupe toute la largeur, dans l'ordre choisi par l'utilisateur. */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dash-widget { grid-column: 1 / -1 !important; }
}

/* --- Widgets graphiques : legende d'encodage, gaufre, legende de series --- */

/* Ligne posee sous le titre : elle dit ce que le visuel encode (une longueur,
   une aire, un point). Sans elle, le lecteur doit deviner l'unite. */
.dash-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin: -2px 0 8px;
  line-height: 1.35;
}

/* Gaufre : 100 pastilles, 1 pastille = 1 % du catalogue. */
.dash-waffle {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 3px;
  align-content: start;
}

.dash-waffle-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
  min-width: 4px;
}

.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.dash-legend-item { display: inline-flex; align-items: center; gap: 5px; }

.dash-legend-chip {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Constructeur de widget --- */

.builder-types { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.builder-type {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.73rem;
  padding: 5px 10px;
}
.builder-type:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.builder-type.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: var(--bg-card);
  font-weight: 600;
}

.builder-size { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }

.builder-preview-head {
  margin-top: 18px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* L'apercu montre la VRAIE donnee : on ne valide pas une definition sur une
   maquette, sous peine de decouvrir le probleme une fois le widget pose. */
.builder-preview {
  margin-top: 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  height: 240px;
  overflow: auto;
  background: var(--bg-dark);
}
.builder-preview .dash-chart { height: 190px; }

.builder-warn {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--accent-amber);
  border-left: 2px solid var(--accent-amber);
  padding-left: 10px;
}

.widget-card-create { border-style: dashed; border-color: rgba(0, 242, 254, 0.4); }

#btn-builder-save:disabled { opacity: 0.45; cursor: not-allowed; }

/* ==========================================================================
   Onglet Production — mise en production, jalons & périodes
   ========================================================================== */

#tab-production .card + .card { margin-top: 20px; }

.production-launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px 16px 8px 16px;
}

.production-launcher-action { justify-content: flex-end; display: flex; flex-direction: column; }
.production-launcher-action .btn { width: 100%; }

/* --- Frise du planning : une piste par période, jalons en repères --- */
.prod-timeline {
  --prod-tl-name-w: 150px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
}

.prod-tl-scale {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.prod-tl-body { position: relative; }

.prod-tl-guides {
  position: absolute;
  left: var(--prod-tl-name-w);
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
}

.prod-tl-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-color);
}

.prod-tl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 26px;
}

.prod-tl-name {
  flex: 0 0 var(--prod-tl-name-w);
  width: var(--prod-tl-name-w);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.prod-tl-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
}

.prod-tl-bar {
  position: absolute;
  top: 6px;
  height: 14px;
  border-radius: 3px;
  min-width: 3px;
}

.prod-tl-msrow { height: 30px; }

.prod-tl-ms {
  position: absolute;
  top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  transform: translateX(-4px);
  white-space: nowrap;
}

.prod-tl-ms-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  transform: rotate(45deg);
  flex: none;
}

.prod-tl-ms-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* --- Tables d'édition : périodes & jalons --- */
.prod-planner-cols {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  padding: 14px 16px 4px 16px;
}

.prod-planner-col { min-width: 0; }

.prod-planner-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.prod-planner-col-head h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prod-inline-input {
  width: 100%;
  font-size: 0.78rem;
  padding: 4px 8px;
}

.prod-phase-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* --- Réglages : catalogue de périodes de l'organisation --- */
.prod-phase-row,
.prod-phase-add {
  display: grid;
  grid-template-columns: 44px minmax(120px, 1fr) 140px 90px 90px auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}

.prod-phase-add {
  grid-template-columns: minmax(120px, 1fr) 44px 90px auto;
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
  padding-top: 12px;
}

.prod-phase-color {
  padding: 2px;
  height: 32px;
  cursor: pointer;
}

.prod-phase-code {
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .prod-planner-cols { grid-template-columns: 1fr; }
  .prod-timeline { --prod-tl-name-w: 110px; }
  .prod-phase-row { grid-template-columns: 44px 1fr 80px auto; }
  .prod-phase-row .prod-phase-code { display: none; }
  .prod-phase-add { grid-template-columns: 1fr 44px 80px; }
}

/* Tables d'édition du planning : formulaires, pas grilles — largeur au contenu
   (le moteur de colonnes est désactivé par `data-no-colctl` côté markup). */
#table-prod-periods,
#table-prod-milestones { table-layout: auto; }

#table-prod-periods th,
#table-prod-periods td,
#table-prod-milestones th,
#table-prod-milestones td { padding: 6px 8px; }

#table-prod-periods th:nth-child(1),
#table-prod-periods td:nth-child(1) { width: 132px; }
#table-prod-periods th:nth-child(3),
#table-prod-periods td:nth-child(3),
#table-prod-periods th:nth-child(4),
#table-prod-periods td:nth-child(4),
#table-prod-milestones th:nth-child(2),
#table-prod-milestones td:nth-child(2) { width: 118px; }
#table-prod-periods th:nth-child(5),
#table-prod-periods td:nth-child(5) { width: 46px; text-align: right; }
#table-prod-periods th:nth-child(6),
#table-prod-periods td:nth-child(6),
#table-prod-milestones th:nth-child(3),
#table-prod-milestones td:nth-child(3) { width: 66px; }

/* Les champs date natifs portent leur propre icône : on serre la saisie pour
   que les six colonnes tiennent sans barre de défilement horizontale. */
.prod-inline-input[type="date"] { font-size: 0.74rem; padding: 4px 4px; }
#table-prod-periods select.prod-inline-input { padding-right: 18px; }

.prod-phase-head {
  padding-bottom: 2px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.prod-phase-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Onglet Production — plan directeur (MPS), carnet de demande
   ========================================================================== */

#production-toolbar { padding: 14px 16px; }

.production-toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.prod-view-switch { display: flex; gap: 6px; flex-wrap: wrap; }

.production-toolbar-filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.prod-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prod-field .select-control,
.prod-field .input-control { font-size: 0.8rem; padding: 6px 10px; }
.prod-field-action { justify-content: flex-end; }

.mps-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.72rem; color: var(--text-muted); }
.mps-legend-item { display: inline-flex; align-items: center; gap: 5px; }

.mps-dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.mps-dot-firm { background: var(--accent-green); }
.mps-dot-forecast { background: var(--accent-blue); }
.mps-dot-planned { background: var(--accent-cyan); }
.mps-dot-over { background: var(--accent-red); }

/* --- La grille --- */
.mps-grid-container { padding: 4px 16px 12px 16px; }
.mps-scroll { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 10px; }

.mps-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.8rem;
}

.mps-table th,
.mps-table td {
  border-bottom: 1px solid var(--border-color);
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
}

.mps-head-label,
.mps-label {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-card);
  text-align: left;
  min-width: 210px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid var(--border-color);
}

.mps-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-card-hover);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mps-head-label { z-index: 4; background: var(--bg-card-hover); }
.mps-head-bucket { min-width: 62px; }
.mps-head-bucket small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.62rem; }
.mps-bucket-month .mps-head-bucket { min-width: 82px; }

.mps-row-system .mps-label { cursor: pointer; }
.mps-row-system .mps-label strong { font-weight: 600; }
.mps-row-system .mps-label .font-mono { font-size: 0.7rem; margin-left: 6px; }
.mps-chevron { display: inline-block; width: 12px; color: var(--text-muted); }

.mps-sublabel { padding-left: 26px; font-size: 0.72rem; color: var(--text-muted); }
.mps-row-firm .mps-sublabel { cursor: pointer; }

.mps-cell { font-variant-numeric: tabular-nums; }
.mps-clickable { cursor: pointer; }
.mps-row-balance { color: var(--text-secondary); }
.mps-negative { color: var(--accent-red); font-weight: 600; }
.mps-over { background: rgba(239, 68, 68, 0.12); }
.mps-tight { background: rgba(245, 158, 11, 0.12); }

.mps-input {
  width: 100%;
  min-width: 46px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 3px 4px;
  text-align: center;
}

.mps-input:focus { outline: none; border-color: var(--border-highlight); }
.mps-input-capacity { color: var(--text-muted); background: transparent; border-color: transparent; }
.mps-input-capacity:focus { background: var(--bg-input); border-color: var(--border-highlight); }
.mps-input-override { color: var(--text-secondary); border-color: var(--border-color); }

.mps-row-total td {
  background: var(--bg-card-hover);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.mps-row-total .mps-label { background: var(--bg-card-hover); font-weight: 600; }

/* --- Carnet de demande --- */
.demand-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  padding: 14px 16px 8px 16px;
}

/* --- Détail d'une période --- */
.mps-cell-section {
  margin: 0 0 8px 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mps-cell-capacity {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

@media (max-width: 980px) {
  .production-toolbar-row { align-items: stretch; }
  .production-toolbar-filters { width: 100%; }
  .mps-head-label, .mps-label { min-width: 150px; }
}

/* Hub Données devenu section des réglages : les onglets internes et le corps
   vivent dans un panneau, plus dans une modale dédiée. */
.data-hub-panel { padding: 0; overflow: hidden; }

.data-hub-panel > div:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.data-hub-panel #data-hub-view-import,
.data-hub-panel #data-hub-view-erp,
.data-hub-panel #data-hub-view-logs { padding: 18px; }

/* Verrou d'authentification : sans session, l'application n'est pas seulement
   vide — elle est absente. Seuls l'en-tête (marque, langue, bouton Connexion)
   et la modale d'authentification restent visibles. */
body.auth-locked .nav-tabs,
body.auth-locked .main-content { display: none !important; }

/* ==========================================================================
   Widget globe fournisseurs
   ========================================================================== */
.dash-globe-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.dash-globe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  cursor: grab;
  touch-action: none;
}

.dash-globe.is-dragging { cursor: grabbing; }

.dash-globe-tip {
  position: absolute;
  transform: translate(-50%, -160%);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.dash-globe-tip.visible { opacity: 1; }

.dash-globe-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0 2px;
}

.dash-globe-ramp {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(0, 242, 254, 0.14), rgba(0, 242, 254, 0.76));
}

.dash-globe-foot {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 4px 2px 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-globe-tip.below { transform: translate(-50%, 60%); }
