/* === V&B Modern Analytics Design System === */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(245, 158, 11, 0.3);
  
  --text-main: #f3f4f6;
  --text-muted: #a9b1bd;
  --text-dim: #8590a0;

  --accent-primary: #f59e0b; /* Amber / V&B Gold */
  --accent-primary-hover: #d97706;
  --accent-primary-glow: rgba(245, 158, 11, 0.15);

  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --sky: #38bdf8;
  --sky-bg: rgba(56, 189, 248, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.5);
}

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

/* Un élément masqué le reste, quel que soit son mode d'affichage */
[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 10% 10%, rgba(245, 158, 11, 0.05) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(56, 189, 248, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.app-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* === Glass Card Utility === */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* === Barre de navigation === */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.navbar-inner {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0.6rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
  flex: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #d97706, #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text {
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: -0.5px;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.navbar-tabs {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease;
}

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

.nav-tab.active {
  background: rgba(245, 158, 11, 0.14);
  color: var(--accent-primary);
  border-color: rgba(245, 158, 11, 0.3);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

/* Pastille d'état d'une connexion : verte si connecté, rouge sinon */
.conn-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

.conn-dot.off {
  background: var(--rose);
}

/* Menus déroulants de la barre (magasin, compte) */
.menu-wrap {
  position: relative;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.store-btn {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--border-accent);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem 0;
  z-index: 100;
  display: none;
}

.menu-dropdown.open {
  display: block;
}

.menu-title {
  padding: 0.4rem 0.9rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.55rem 0.9rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.menu-wide {
  min-width: 290px;
}

.menu-state {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.menu-btn-label {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.menu-item.active {
  color: var(--accent-primary);
  font-weight: 700;
}

.menu-item-danger {
  color: var(--rose);
}

@media (max-width: 1100px) {
  .navbar-inner {
    flex-wrap: wrap;
  }

  .navbar-tabs {
    order: 3;
    flex-basis: 100%;
  }

  .navbar-right {
    margin-left: auto;
  }
}

/* Indicateur de chargement dans un bouton */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #111;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

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

.btn-xs {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

/* === En-tête de page === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-header p {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 78ch;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* === Barre de filtres, identique sur toutes les pages === */
.filter-card {
  padding: 1rem 1.25rem;
}

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem 1.25rem;
  flex-wrap: wrap;
}

.filter-row + .filter-row {
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-subtle);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.filter-field > label,
.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-search {
  flex: 1 1 260px;
  max-width: 420px;
}

.filter-grow {
  flex: 1 1 260px;
}

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

.filter-sep,
.period-label,
.filter-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.filter-hint {
  margin-left: auto;
  align-self: center;
}

.filter-reset {
  margin-left: auto;
  white-space: nowrap;
}

/* Des filtres sont actifs : le bouton de remise à zéro se fait remarquer */
.filter-reset.has-filters {
  color: var(--accent-primary);
  border-color: var(--border-accent);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.4rem;
  font-family: inherit;
  font-size: 0.88rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-icon input:focus,
.styled-select:focus,
.styled-select-sm:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.clear-btn {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

.clear-btn:hover {
  color: var(--text-main);
}

.styled-select, .styled-select-sm {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  color-scheme: dark;
}

.styled-select-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

/* Choix exclusif en boutons accolés (détail par jour / semaine / mois...) */
.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.segment-btn {
  flex: 1;
  padding: 0.4rem 0.75rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.15s;
}

.segment-btn.active,
.segment-btn:has(input:checked) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

/* Catégories */
.category-pills {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.pill {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.pill.active,
.pill:has(input:checked) {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #111;
  font-weight: 700;
}

/* Le bouton radio reste accessible au clavier mais c'est son étiquette qui se voit */
.pill input,
.segment-btn input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill:has(input:focus-visible),
.segment-btn:has(input:focus-visible) {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.check-pill:has(input:checked) {
  color: var(--text-main);
  border-color: var(--border-accent);
  background: var(--accent-primary-glow);
}

/* === Bandeaux d'information === */
.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.banner-error {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fecdd3;
}

.banner-success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.banner-action {
  margin-left: 0.5rem;
  padding: 0.25rem 0.7rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: #111;
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

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

.message-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* === KPI Grid === */
.kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, border-color 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
}

.badge-positive {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.badge-negative {
  background: var(--rose-bg);
  color: var(--rose);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

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

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  font-family: var(--font-sans);
  letter-spacing: -0.03em;
}

.text-emerald {
  color: var(--emerald);
}

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

/* === Analytics & Charts === */
.analytics-section {
  padding: 1.25rem 1.5rem;
}

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

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title-wrap h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.badge-subtle {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.chart-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.chart-canvas-wrapper {
  position: relative;
  height: 240px;
  width: 100%;
}

/* === Table Section === */
.table-section {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.table-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-heading {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.table-heading h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.results-count {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.table-quick-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive Table Wrapper per modern web guidance */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: 65vh;
  container-type: inline-size;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

/* Sticky column headers */
thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  background: #111827;
}

th {
  padding: 0.75rem 0.9rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover {
  color: var(--accent-primary);
}

td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

tbody tr {
  transition: background-color 0.15s ease;
  cursor: pointer;
}

tbody tr:hover {
  background-color: var(--bg-card-hover);
}

.code-cell {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-primary);
  font-weight: 500;
}

.name-cell {
  font-weight: 600;
  color: var(--text-main);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.action-col {
  text-align: center;
}

.cat-pill-cell {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.trend-up {
  color: var(--emerald);
  background: var(--emerald-bg);
}

.trend-down {
  color: var(--rose);
  background: var(--rose-bg);
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-indicator {
  font-weight: 600;
  color: var(--text-main);
}

/* === Drawer & Modals === */
.drawer-overlay, .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: min(480px, 90vw);
  height: 100%;
  background: #111827;
  border-left: 1px solid var(--border-subtle);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.badge-accent {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-primary);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 0.4rem;
}

.drawer-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.drawer-cat {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
}

.drawer-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.drawer-stat {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

.drawer-comparison {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.drawer-comparison h4 {
  font-size: 0.9rem;
  font-weight: 700;
}

.comparison-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-alt {
  background: var(--sky);
}

/* Modal Dialog */
.modal-overlay {
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  width: min(540px, 92vw);
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.form-group textarea, .form-group input {
  width: 100%;
  padding: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  outline: none;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.test-result {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.test-result.success {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid var(--emerald);
}

.test-result.error {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid var(--rose);
}

/* === Product Isolation Bar === */
.product-combobox {
  position: relative;
  display: flex;
  align-items: center;
}

.combobox-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
}

.product-combobox input {
  width: 100%;
  padding: 0.6rem 2.2rem 0.6rem 2.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.product-combobox input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.suggestions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

.suggestion-item {
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.suggestion-item:hover {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-primary);
}

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

.active-product-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.85rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: #fde68a;
}

/* === Single Product Hero Section === */
.single-product-hero {
  padding: 1.5rem;
  animation: fade-in 0.3s ease;
}

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

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.hero-cat {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* === Matrix Table Specifics === */
.matrix-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  padding: 0.65rem 0.8rem;
}

.matrix-cell.zero {
  color: rgba(255, 255, 255, 0.15);
}

.matrix-cell.heat-low {
  background: rgba(245, 158, 11, 0.08);
  color: #fef3c7;
}

.matrix-cell.heat-mid {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  font-weight: 700;
}

.matrix-cell.heat-high {
  background: rgba(245, 158, 11, 0.32);
  color: #fff;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.4);
}

.total-qty-cell {
  text-align: right;
  font-weight: 800;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.06);
}

.peak-cell {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

/* === Login Page === */
.login-wrapper {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: min(420px, 92vw);
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-header {
  text-align: center;
}

.login-header .brand-logo {
  margin: 0 auto 1rem auto;
}

.login-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.login-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-footer-hint {
  padding: 0.75rem;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: #7dd3fc;
  text-align: center;
}

/* === Options Page === */
.options-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}

.options-card {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.options-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.options-card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.store-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.store-card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.2s;
}

.store-card-item.active {
  border-color: var(--accent-primary);
  background: rgba(245, 158, 11, 0.08);
}

.store-item-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.store-item-info span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.store-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}



/* === Catalogue magasin === */
.catalog-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.catalog-history {
  padding: 1.25rem;
}

.catalog-history ul {
  list-style: none;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

tbody.static-rows tr {
  cursor: default;
}

.text-rose {
  color: var(--rose);
}

.text-dim {
  color: var(--text-dim);
}

.banner a {
  color: inherit;
  font-weight: 700;
}

/* Quantité non recalculée (produit sans contenance) */
.qty-api-fallback {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-dim);
  cursor: help;
}

/* === Tableaux compacts : le maximum de colonnes visibles sans défilement latéral === */
.app-layout {
  max-width: 1760px;
}

table.compact {
  font-size: 0.85rem;
}

table.compact th,
table.compact td {
  padding: 0.5rem 0.55rem;
}

table.compact th {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* La colonne produit prend la place restante et tronque son contenu au lieu d'élargir le tableau */
table.compact .product-cell {
  width: 100%;
  max-width: 0;
  min-width: 190px;
}

.product-line {
  display: flex;
  align-items: center;
  min-width: 0;
}

.product-name {
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-meta {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-meta .code {
  font-family: var(--font-mono);
  color: var(--accent-primary);
}

/* Cellule de texte secondaire à largeur plafonnée (appellation, marque...) */
table.compact .clip-cell {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.two-lines > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.two-lines > span + span {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Millésimes plus anciens fusionnés dans ce produit */
.vintage-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--sky-bg);
  color: var(--sky);
  cursor: pointer;
  flex: none;
  white-space: nowrap;
}

.vintage-badge:hover {
  border-color: var(--sky);
}

/* Détail des millésimes dans le panneau latéral */
.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drawer-vintages {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.drawer-vintages h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--sky);
}

.vintage-table thead {
  position: static;
  background: transparent;
}

.vintage-table td.two-lines {
  max-width: 230px;
}

.vintage-table td.two-lines > span {
  white-space: nowrap;
}

.vintage-total td {
  font-weight: 800;
  border-top: 1px solid var(--border-subtle);
  border-bottom: none;
}

/* En-tête de colonne triable (catalogue) */
th a.sort-link {
  color: inherit;
  text-decoration: none;
}

th a.sort-link:hover,
th a.sort-link.active {
  color: var(--accent-primary);
}

tbody.clickable-rows tr {
  cursor: pointer;
}

.match-badge {
  display: inline-block;
  padding: 0 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.match-sure {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.match-check {
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
}

.match-none {
  background: var(--rose-bg);
  color: var(--rose);
}

/* Matrice par période : la colonne produit reste visible quand les périodes défilent */
table.compact .sticky-col {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #111827;
  width: 260px;
  min-width: 220px;
  max-width: 300px;
}

table.compact thead .sticky-col {
  z-index: 11;
}

table.compact .matrix-cell {
  padding: 0.4rem 0.4rem;
  min-width: 44px;
}

/* === Commande : contrôles du panier === */
.cart-control {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  justify-content: flex-end;
}

.cart-control input[type="number"] {
  width: 3.6rem;
  padding: 0.25rem 0.3rem;
  text-align: right;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.8rem;
}

.cart-control input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.cart-unit {
  display: flex;
  justify-content: flex-end;
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 300px;
  margin-left: auto;
}

/* Le nom de l'unité se tronque ; le nombre de pièces et le prix restent toujours lisibles */
.cart-unit-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-unit > span + span {
  flex: none;
  white-space: pre;
}

.btn-icon {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.2;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

tr.row-busy {
  opacity: 0.55;
  pointer-events: none;
}

.toast {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 200;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
  box-shadow: var(--shadow-md);
}

.toast.error {
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fecdd3;
}

/* === Fenêtre de connexion et formulaires === */
.modal-hint {
  margin-right: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-footer {
  align-items: center;
}

.login-popup-form,
.advanced-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

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

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
}

.form-field textarea {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-field-row {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Réglages repliés par défaut : ils n'encombrent pas l'écran de ceux qui n'en ont pas besoin */
details.advanced {
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
}

details.advanced > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

details.advanced > summary:hover {
  color: var(--text-main);
}

details.advanced[open] {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

details.advanced[open] > summary {
  margin-bottom: 0.25rem;
}

/* === Options === */
.options-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.status-line.ok {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.07);
}

.status-line.off {
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.07);
}

.status-line > span {
  flex: 1 1 260px;
}
