/* ─── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* El atributo [hidden] nativo pierde contra cualquier `display` de autor
   (ej. .empty-state{display:flex}) por cómo el navegador prioriza el
   stylesheet del sitio sobre el del user-agent. Esta regla garantiza que
   hidden siempre gane, sin importar qué otras clases tenga el elemento. */
[hidden] {
  display: none !important;
}

:root {
  --bg: #F7F7F7;
  --surface: #FFFFFF;
  --surface-alt: #EFEFEF;
  --border: #E5E5E5;
  --border-brand: rgba(237, 37, 47, 0.2);
  --brand: #ed252f;
  --brand-soft: rgba(237, 37, 47, 0.08);
  --brand-glow: rgba(237, 37, 47, 0.15);
  --text: #111111;
  --text-secondary: #4B5563;
  --muted: #9CA3AF;
  --dark: #1E1E1E;
  --font: 'Inter', system-ui, sans-serif;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ─── Animated background orbs ─────────────────────────────── */
body {
  position: relative;
  overflow-x: clip;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.3;
  pointer-events: none;
  animation: drift 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: #E5E5E5;
  top: -140px;
  left: -140px;
}

.orb-2 {
  width: 380px;
  height: 380px;
  background: rgba(237, 37, 47, 0.06);
  bottom: -120px;
  right: -100px;
  animation-delay: -9s;
}

@keyframes drift {
  from {
    transform: translate(0, 0) scale(1);
  }

  to {
    transform: translate(40px, 30px) scale(1.08);
  }
}

/* ─── Layout ────────────────────────────────────────────────── */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 5rem 2rem 3rem;
}

/* ─── Header Section ────────────────────────────────────────── */
.header-section {
  text-align: center;
  margin-bottom: 3rem;
  animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Banners Grid ──────────────────────────────────────────── */
.banners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  width: 100%;
  max-width: 1100px;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.banner {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 380px;
  border-radius: 20px;
  overflow: hidden;
  text-decoration: none;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1),
    box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 30%, transparent 55%);
  z-index: 1;
  transition: opacity 0.4s ease;
}

.banner-overlay {
  position: absolute;
  inset: 0;
  background: var(--brand-glow);
  opacity: 0;
  z-index: 2;
  transition: opacity 0.4s ease;
  mix-blend-mode: overlay;
}

.banner-content {
  position: relative;
  z-index: 3;
  padding: 2rem;
  transform: translateY(10px);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.banner-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.banner-content p {
  color: var(--brand);
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

/* ─── Hover Elevation Effect ────────────────────────────────── */
.banner:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(237, 37, 47, 0.2);
}

.banner:hover .banner-overlay {
  opacity: 0.25;
}

.banner:hover .banner-content {
  transform: translateY(0);
}

.banner:hover .banner-content p {
  opacity: 1;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Badge ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(237, 37, 47, 0.1);
  border: 1px solid rgba(237, 37, 47, 0.3);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 2rem;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

/* ─── Title ─────────────────────────────────────────────────── */
.logo-container {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.main-logo {
  width: 320px;
  height: 86px;
  object-fit: contain;
}

@media (max-width: 480px) {
  .main-logo {
    width: 240px;
    height: auto;
  }
}

.title {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ─── Subtitle ──────────────────────────────────────────────── */
.subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

/* ─── Status bar ─────────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 18px;
  font-size: 0.85rem;
  color: var(--muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: color 0.3s, border-color 0.3s;
}

.status.offline {
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ─── Inner Pages Layout ──────────────────────────────────────── */
.page-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8rem 12px 3rem;
  padding-top: calc(8rem + env(safe-area-inset-top));
  max-width: 1400px;
  margin: 0 auto;
}

/* ─── Top Navigation ─────────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1rem 2rem;
  padding-top: max(1rem, calc(env(safe-area-inset-top, 0px) + 0.5rem));
  padding-left: max(2rem, calc(env(safe-area-inset-left, 0px) + 1rem));
  padding-right: max(2rem, calc(env(safe-area-inset-right, 0px) + 1rem));
  background: var(--dark);
  border-bottom: none;
  z-index: 100;
}

/* En modo PWA standalone sobre iOS, forzamos que el contenido del nav
   arranque siempre debajo del notch/status bar. */
@supports (padding-top: env(safe-area-inset-top)) {
  .top-nav {
    min-height: calc(env(safe-area-inset-top, 0px) + 56px);
  }
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 16px 8px 12px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.3s ease;
  width: 100px;
  cursor: pointer;
}

.back-btn:hover {
  background: rgba(237, 37, 47, 0.2);
  border-color: rgba(237, 37, 47, 0.5);
}

.icon-sm {
  width: 18px;
  height: 18px;
}

.nav-title {
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-logo {
  height: 38px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* ─── Content Panels ─────────────────────────────────────────── */
.content-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05);
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.empty-state-icon::after {
  content: '👈';
  display: inline-block;
  animation: pointing-left 1.5s ease-in-out infinite;
}

@keyframes pointing-left {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(-15px);
  }
}

@keyframes pointing-down {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(15px);
  }
}

@media (max-width: 1280px) {
  .empty-state-icon::after {
    content: '👇';
    animation: pointing-down 1.5s ease-in-out infinite;
  }

  .title {
    font-size: 1.5rem;
  }
}

.show-mobile-only {
  display: none !important;
}

.empty-state h3 {
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.empty-state p {
  color: var(--muted);
  max-width: 320px;
}



@media (max-width: 480px) {
  .top-nav {
    padding: 0.75rem;
  }
}

/* ─── Force Refresh Button ──────────────────────────────────── */
.force-refresh-btn {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.force-refresh-btn:hover {
  color: var(--text);
  border-color: var(--brand);
  transform: scale(1.1) rotate(180deg);
}

/* ─── Subtle Force Refresh Link (home) ──────────────────────── */
.force-refresh-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 1rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  letter-spacing: 0.04em;
  transition: color 0.3s ease;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0.6;
}

.force-refresh-link:hover {
  opacity: 1;
  color: var(--text-secondary);
}

.force-refresh-link svg {
  width: 11px;
  height: 11px;
  transition: transform 0.5s ease;
}

.force-refresh-link:hover svg {
  transform: rotate(360deg);
}

/* ─── Version Footer ─────────────────────────────────────────── */
.version-footer {
  width: 100%;
  text-align: center;
  padding: 2rem 0 1rem;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  opacity: 0.5;
  user-select: none;
  pointer-events: none;
}

/* ─── PCMO Grid Layout ──────────────────────────────────────── */
.pcmo-layout {
  max-width: 1400px;
}

.pcmo-content-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  /* Sidebar izquierda, araña centro/derecha mas ancha */
  gap: 2rem;
  width: 100%;
}

.chart-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
  position: relative;
  padding: 16px !important;
}



/* ─── Filters & Chips ───────────────────────────────────────── */
.filters-sidebar h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.filter-group {
  margin-bottom: 1.5rem;
}

.filter-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.filter-search {
  margin-bottom: 1rem;
}

.filter-search input {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

.filter-search input:focus {
  border-color: var(--brand);
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  transition: max-height 0.3s ease;
}

.chips-container.collapsible {
  max-height: 125px;
  /* Altura para unas 3 filas aprox */
  overflow: hidden;
  position: relative;
}

.chips-container.expanded {
  max-height: 2000px;
}

.view-more-btn {
  display: inline-block;
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity 0.2s;
}

.view-more-btn:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.chip {
  padding: 6px 14px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.chip:hover {
  background: #F3F4F6;
  border-color: #D1D5DB;
  color: var(--text);
}

.chip.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

.chip.disabled {
  display: none !important;
}

/* ─── Searchable Selector (Dropdown) ────────────────────────── */
.searchable-selector {
  position: relative;
  width: 100%;
}

.selector-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.selector-control:hover {
  border-color: #D1D5DB;
}

.selector-arrow {
  width: 14px;
  height: 14px;
  opacity: 0.4;
  transition: transform 0.3s ease;
}

.searchable-selector.open .selector-arrow {
  transform: rotate(180deg);
}

.selector-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 1001;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.searchable-selector.open .selector-dropdown {
  display: flex;
}

.selector-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.selector-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.selector-list {
  max-height: 250px;
  overflow-y: auto;
  padding: 8px;
}

.selector-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selector-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.selector-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.selector-item.disabled {
  display: none !important;
}

.selector-item span.check {
  display: none;
}

.selector-item.active span.check {
  display: block;
}

/* ─── Global Buttons ────────────────────────────────────────── */
.btn-primary,
.btn-secondary {
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  font-family: var(--font);
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(237, 37, 47, 0.25);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #E5E5E5;
}

@media (max-width: 1280px) {
  .page-container {
    padding-top: 6rem;
    padding-top: calc(6rem + env(safe-area-inset-top));
  }

  .pcmo-content-grid {
    display: contents;
  }

  .chart-panel {
    position: sticky;
    top: 85px;
    z-index: 10;
  }

  .content-panel,
  .card {
    padding: 1.5rem !important;
  }

  .chart-panel {
    min-height: 0;
    padding: 8px 12px !important;
  }

  .chart-panel canvas {
    max-height: 85vw;
  }

  /* --- Mobile Filter Drawer --- */
  .filters-sidebar {
    position: fixed;
    bottom: -100%;
    /* Hidden by default */
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--surface);
    height: 85vh;
    border-radius: 24px 24px 0 0;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
    transition: bottom 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    visibility: hidden;
  }

  .filters-header {
    display: none !important;
  }

  .header-section {
    margin-bottom: 4px !important;
  }

  .filters-sidebar.open {
    bottom: 0;
    visibility: visible;
  }

  /* Backdrop */
  #filters-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  #filters-backdrop.open {
    opacity: 1;
    visibility: visible;
  }

  /* Drawer Header */
  .drawer-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .drawer-handle {
    width: 40px;
    height: 4px;
    background: #D1D5DB;
    border-radius: 2px;
    margin: 0 auto 1.5rem;
  }

  /* Scrollable area */
  .drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
  }

  /* Bottom Sticky Bar in Drawer */
  .drawer-footer {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  /* Main Sticky Link at bottom of page (Container) */
  #mobile-filter-trigger {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 900;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  /* Mobile View Toggle Hidden */
  .view-toggle {
    display: none !important;
  }

  /* Sticky layout overrides */
  #mobile-filter-trigger button {
    width: 100%;
    box-shadow: 0 0 20px rgba(237, 37, 47, 0.4);
  }

  .show-mobile-only {
    display: flex !important;
  }


  .page-container {
    padding-bottom: 120px;
    /* Space for the bottom trigger */
  }

  /* Tooltip override for the first category to avoid collision with drawer header */
  .filter-group.first-group .tooltip-text {
    bottom: auto !important;
    top: 50% !important;
    left: 100% !important;
    transform: translateY(-50%) translateX(10px) scale(0.95) !important;
    width: 210px;
    text-align: left;
  }

  .filter-group.first-group .tooltip-container:hover .tooltip-text {
    transform: translateY(-50%) translateX(15px) scale(1) !important;
  }

  .filter-group.first-group .tooltip-text::after {
    top: 50% !important;
    left: -12px !important;
    bottom: auto !important;
    margin-top: -6px !important;
    margin-left: 0 !important;
    border-color: transparent rgba(17, 24, 39, 0.95) transparent transparent !important;
  }

  /* Responsive Table */
  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    align-content: start;
    gap: 0.25rem 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border: none !important;
    white-space: normal !important;
    text-align: right;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 1rem;
    text-align: left;
  }

  .data-table td[data-label="Imagen"]::before,
  .data-table td[data-label="Producto"]::before {
    display: none !important;
  }

  .data-table td[data-label="Imagen"] {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
    padding: 0;
  }

  .data-table td[data-label="Producto"] {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    text-align: right;
    padding: 0;
    border-bottom: none !important;
    margin-bottom: 0;
  }

  .data-table td[data-label="Producto"] .badge-status {
    width: auto;
    text-align: right;
  }

  .data-table td:not([data-label="Imagen"]):not([data-label="Producto"]) {
    grid-column: 1 / span 2;
  }

  .data-table td[data-label="Viscosidad"] {
    border-top: 1px solid var(--border) !important;
    margin-top: 0.5rem;
    padding-top: 1rem !important;
  }
}

@media (min-width: 1281px) {
  #mobile-filter-trigger {
    display: none;
  }

  .drawer-header,
  .drawer-footer {
    display: none;
  }
}

/* ─── Data Table ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.data-table tbody tr {
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #F3F4F6;
}

.data-table tbody tr.selected-row {
  background: #F9FAFB !important;
  box-shadow: inset 4px 0 0 0 #D1D5DB;
}

.data-table td {
  color: var(--text);
  font-size: 0.95rem;
}

/* Base columns never wrap — width:1% makes them shrink to their natural content width */
@media (min-width: 1281px) {
  .data-table th:not(.oem-th),
  .data-table td:not(.oem-cell) {
    white-space: nowrap;
    width: 1%;
  }
}

/* ─── OEM Cells ─────────────────────────────────────────────── */
.data-table td.oem-cell {
  font-size: 0.85rem;
  color: var(--text);
  white-space: normal;       /* OEM content can wrap */
  min-width: 100px;
  max-width: 160px;
}

/* Em-dash placeholder (no OEM value or no spec) looks muted */
.data-table td.oem-empty,
.data-table td.spec-empty {
  color: var(--muted);
  opacity: 0.5;
}

/* Desktop OEM column headers */
@media (min-width: 1281px) {
  .data-table th.oem-th {
    min-width: 100px;
    max-width: 160px;
    white-space: normal;
  }
}

/* Mobile: OEM rows inside card */
@media (max-width: 1280px) {
  /* Hide empty OEM and spec rows inside cards — no value to show */
  .data-table td.oem-empty,
  .data-table td.spec-empty {
    display: none !important;
  }

  /* Divider between Tecnología and first OEM */
  .data-table td.oem-first {
    border-top: 1px solid var(--border) !important;
    margin-top: 0.5rem;
    padding-top: 1rem !important;
  }

  .data-table td.oem-cell {
    padding: 0.6rem 0 !important;
    font-size: 0.85rem;
    white-space: normal !important;
    min-width: unset;
    max-width: unset;
  }

  .data-table td.oem-cell::before {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
    margin-right: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border-brand);
  color: var(--brand);
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--brand-soft);
}

.badge-status .color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-status.indigo {
  border-color: rgba(99, 102, 241, 0.4);
  color: #818cf8;
}

/* ─── Global Loader ─────────────────────────────────────────── */
#global-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#global-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* ─── Tooltip ─────────────────────────────────────────────── */
.tooltip-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  vertical-align: middle;
  cursor: help;
  /* Garantiza un área mínima visible amplia */
  min-width: 24px;
  min-height: 24px;
  justify-content: center;
}

/* Expansión del área táctil (hit area) para móviles a 44px */
@media (max-width: 1280px) {
  .tooltip-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    /* El pseudo-elemento es invisible pero captura eventos */
  }

  .tooltip-icon {
    width: 18px !important;
    height: 18px !important;
    font-size: 11px !important;
  }
}

.tooltip-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  font-style: normal;
  line-height: 1;
}

.tooltip-container:hover .tooltip-icon {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.tooltip-text {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px) scale(0.95);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f3f4f6;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  width: 210px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2100;
  pointer-events: none;
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: normal;
}

.tooltip-container:hover .tooltip-text {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-8px) scale(1);
}

.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(17, 24, 39, 0.95) transparent transparent transparent;
}

/* ─── Radar Chart Category Tooltip ───────────────────────── */
.radar-category-tooltip {
  position: fixed;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f3f4f6;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-family: var(--font, 'Inter', sans-serif);
  line-height: 1.5;
  width: 240px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 3000;
  pointer-events: none;
  transform: scale(0.95);
}

.radar-category-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.radar-category-tooltip-title {
  font-weight: 700;
  color: var(--brand, #ff3b45);
  margin-bottom: 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

/* ─── Applied Filters Chips ─────────────────────────────────── */
.applied-filters-container {
  display: none;
  /* Hidden on desktop */
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 0;
}

.applied-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--brand-soft);
  border: 1px solid var(--border-brand);
  border-radius: 100px;
  font-size: 0.72rem;
  color: var(--brand);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: fadeInDown 0.3s ease-out;
  transition: all 0.2s ease;
}

.applied-filter-chip:hover {
  background: rgba(237, 37, 47, 0.12);
  border-color: rgba(237, 37, 47, 0.4);
}

.applied-filter-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  color: var(--brand);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}

.applied-filter-remove:hover {
  opacity: 1;
  transform: scale(1.2);
}

@media (max-width: 1280px) {
  .applied-filters-container {
    display: flex;
    /* Visible on mobile */
    margin-top: 0;
    gap: 8px;
  }

  .applied-filter-chip {
    padding: 5px 10px;
    font-size: 0.68rem;
  }
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Additives Result Card ─────────────────────────────────── */
.additive-result-card {
  margin-bottom: 1.5rem;
  padding: 1.5rem !important;
  box-shadow: none !important;
}

@media (max-width: 1280px) {
  .additive-result-card {
    padding: 16px !important;
  }
}

/* ─── Additives Video ──────────────────────────────────────────── */
.additive-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
}

.additive-video iframe,
.additive-video-facade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.additive-video-facade {
  padding: 0;
  background: #111;
  cursor: pointer;
}

.additive-video-facade img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.additive-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}

.additive-video-facade:hover .additive-video-play {
  transform: translate(-50%, -50%) scale(1.08);
}

.additive-video-offline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.6rem 0.9rem;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ─── Additives Catalog (TB-14) ──────────────────────────────── */
/* Cuadrícula de packshots agrupada por sistema (plana mientras se busca).
   Vive dentro de #results-main-panel, y .chart-panel centra su contenido:
   hay que estirarla. */
.additives-catalog {
  width: 100%;
  align-self: stretch;
}

.additives-catalog-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.additives-catalog-search {
  position: relative;
  display: flex;
  align-items: center;
}

.additives-catalog-search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.additives-catalog-search input {
  width: 100%;
  height: 48px;
  padding: 0 46px 0 42px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  /* 16 px: con menos, Safari de iPhone hace zoom al enfocar el campo */
  font-size: 1rem;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.additives-catalog-search input::placeholder {
  color: var(--muted);
}

.additives-catalog-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  display: none;
}

.additives-catalog-search input:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.additives-catalog-search-clear {
  position: absolute;
  right: 6px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.additives-catalog-search-clear:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.additives-catalog-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.additives-catalog-group + .additives-catalog-group {
  margin-top: 2rem;
}

.additives-catalog-group-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.additives-catalog-group-title::before {
  content: '';
  width: 4px;
  height: 1.1em;
  border-radius: 2px;
  background: var(--brand);
  flex-shrink: 0;
}

.additives-catalog-group-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 100px;
  padding: 2px 8px;
}

.additives-catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.additives-catalog-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.6rem 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

@media (hover: hover) {
  .additives-catalog-card:hover {
    border-color: var(--border-brand);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
  }
}

.additives-catalog-card:active {
  transform: scale(0.98);
}

.additives-catalog-card:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.additives-catalog-card-img {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}

.additives-catalog-card-img img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 4%;
  object-fit: contain;
}

.additives-catalog-card-name {
  /* Máximo dos líneas; min-height iguala la altura de las tarjetas de una fila */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

.additives-catalog-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-secondary);
}

/* Hasta 1280 px el panel ocupa todo el ancho (los filtros pasan al cajón):
   las columnas se ajustan al ancho para que el packshot no crezca de más
   (3 en tablet vertical, 4 en horizontal, 5 a 1280). */
@media (max-width: 1280px) {
  .additives-catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  }
}

@media (max-width: 768px) {
  .additives-catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .additives-catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .additives-catalog-toolbar {
    margin-bottom: 1.25rem;
  }
}

/* ─── Product Modal: ficha del aditivo (TB-14) ───────────────── */
/* En celular ocupa casi toda la pantalla con scroll interno; en PC es una
   tarjeta centrada. El padding con env() la deja fuera del notch. */

/* Página fija mientras la ficha está abierta (additives.js pone el top
   negativo con el scroll actual). overflow: hidden solo no basta en iPhone. */
body.ficha-abierta {
  position: fixed;
  left: 0;
  right: 0;
  overflow: hidden;
}

/* Con barras de scroll clásicas (Windows), fijar el body quita la barra y la
   página se corría ~15 px. La barra se deja visible (deshabilitada) mientras
   la ficha está abierta; additives.js pone la clase solo si la página tenía
   barra. scrollbar-gutter: stable no la conservaba en Chrome. */
html.ficha-gutter {
  overflow-y: scroll;
}

.product-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  overscroll-behavior: contain;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.product-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalFadeIn 0.2s ease;
}

.product-modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  animation: productModalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes productModalIn {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.product-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: background 0.15s, color 0.15s;
}

.product-modal-close:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.product-modal-close svg {
  width: 20px;
  height: 20px;
}

.product-modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem;
}

.product-modal-packshot {
  height: clamp(200px, 38vh, 300px);
  border-radius: 14px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.product-modal-packshot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-modal-title {
  margin-top: 1.25rem;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}

.product-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 1.5rem;
}

.product-modal-tag {
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 100px;
  padding: 4px 10px;
  background: var(--surface-alt);
  color: var(--text-secondary);
}

.product-modal-tag--sistema {
  background: var(--brand-soft);
  color: var(--brand);
}

/* Bloques con el mismo lenguaje visual que la tarjeta de resultados */
.product-modal-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.product-modal-block p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.product-modal-block strong {
  font-weight: 600;
}

.product-modal-block-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-modal-block--symptom .product-modal-block-icon {
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.3);
}

.product-modal-block--benefit .product-modal-block-icon {
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.product-modal-block p.product-modal-quote {
  color: #111827;
  font-style: italic;
  font-weight: 600;
}

.product-modal-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.product-modal-details > div {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}

.product-modal-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.product-modal-value {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .product-modal {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .product-modal-body {
    padding: 1rem;
  }

  .product-modal-block {
    padding: 1rem;
  }

  .product-modal-title {
    font-size: 1.3rem;
  }
}

/* ─── Global Country Selector (Header) ───────────────────────── */
.global-country-selector {
  position: relative;
  min-width: 170px;
  max-width: 220px;
  z-index: 1005;
}

.country-selector-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 100px;
  color: #fff;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  text-align: left;
  justify-content: space-between;
}

.country-selector-btn:hover {
  background: rgba(237, 37, 47, 0.18);
  border-color: rgba(237, 37, 47, 0.4);
  box-shadow: 0 0 16px rgba(237, 37, 47, 0.25);
}

.country-selector-btn .flag-icon {
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
}

.country-selector-btn .country-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 6px;
  color: #f3f4f6;
}

.global-country-selector.open .selector-arrow {
  transform: rotate(180deg);
}

/* Dropdown */
.country-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: #111827; /* Dark elegant slate */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropdownFade 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 1006;
}

.global-country-selector.open .country-dropdown {
  display: flex;
}

.country-search {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.country-search input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.country-search input:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(237, 37, 47, 0.2);
}

.country-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
}

/* Custom scrollbar for dropdown */
.country-list::-webkit-scrollbar {
  width: 5px;
}
.country-list::-webkit-scrollbar-track {
  background: transparent;
}
.country-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}
.country-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.country-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #9ca3af;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.country-item.active {
  background: rgba(237, 37, 47, 0.12);
  color: #ff3b45;
  font-weight: 600;
}

.country-item span.check {
  display: none;
  color: #ff3b45;
}

.country-item.active span.check {
  display: block;
}

/* Home Navbar specific styling to stay transparent overlay */
.home-nav {
  background: transparent !important;
  box-shadow: none !important;
  border-bottom: none !important;
  position: absolute !important;
}

/* Responsive Styles for Mobile */
@media (max-width: 768px) {
  .global-country-selector {
    min-width: auto;
    width: auto;
  }

  .country-selector-btn {
    padding: 0;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    justify-content: center;
  }

  .country-selector-btn .country-name,
  .country-selector-btn .selector-arrow {
    display: none;
  }

  .country-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.5);
    animation: slideUpMobile 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none;
  }
}

@keyframes slideUpMobile {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* --- Modern Toast Notification --- */
.motul-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 50px);
  background: rgba(30, 30, 30, 0.95);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid rgba(237, 37, 47, 0.3);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: none;
}

.motul-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.motul-toast-icon {
  color: var(--brand);
  font-size: 1.1rem;
}

/* --- Toggle Switch --- */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}

.toggle-switch input {
  display: none;
}

.toggle-switch .slider {
  position: relative;
  width: 36px;
  height: 20px;
  background-color: #D1D5DB;
  border-radius: 20px;
  transition: .3s;
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
}

.toggle-switch input:checked + .slider {
  background-color: var(--brand);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

/* ─── Grid View (Desktop) ─────────────────────────────────── */
@media (min-width: 1281px) {
  .data-table.grid-view thead {
    display: none;
  }
  
  .data-table.grid-view,
  .data-table.grid-view tbody {
    display: block;
    width: 100%;
  }
  
  .data-table.grid-view tbody {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .data-table.grid-view tr {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    align-content: start;
    gap: 0.25rem 1rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 0;
  }

  .data-table.grid-view td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border: none !important;
    white-space: normal !important;
    text-align: right;
    width: 100%;
  }

  .data-table.grid-view td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 1rem;
    text-align: left;
  }

  .data-table.grid-view td[data-label="Imagen"]::before,
  .data-table.grid-view td[data-label="Producto"]::before {
    display: none !important;
  }

  .data-table.grid-view td[data-label="Imagen"] {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
    padding: 0;
  }

  .data-table.grid-view td[data-label="Producto"] {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    text-align: right;
    padding: 0;
    border-bottom: none !important;
    margin-bottom: 0;
  }

  .data-table.grid-view td[data-label="Producto"] .badge-status {
    width: auto;
    text-align: right;
  }

  .data-table.grid-view td:not([data-label="Imagen"]):not([data-label="Producto"]) {
    grid-column: 1 / span 2;
  }

  .data-table.grid-view td[data-label="Viscosidad"] {
    border-top: 1px solid var(--border) !important;
    margin-top: 0.5rem;
    padding-top: 1rem !important;
  }

  .data-table.grid-view td.oem-cell {
    padding: 0.6rem 0 !important;
    font-size: 0.85rem;
    white-space: normal !important;
    min-width: unset;
    max-width: unset;
  }

  .data-table.grid-view td.oem-empty,
  .data-table.grid-view td.spec-empty {
    display: none !important;
  }

  .data-table.grid-view td.oem-first {
    border-top: 1px solid var(--border) !important;
    margin-top: 0.5rem;
    padding-top: 1rem !important;
  }

  .data-table.grid-view td.oem-cell::before {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
    margin-right: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* ─── Image Modal / Lightbox ─────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  cursor: zoom-out;
}

.modal.is-open {
  display: flex;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  max-width: min(90vw, 480px);
  max-height: 80vh;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  cursor: default;
  animation: modalImgPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalImgPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

#modal-caption {
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
  opacity: 0.8;
  cursor: default;
}

.modal-close {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, transform 0.15s ease;
  z-index: 9001;
}

.modal-close:hover {
  color: #fff;
  transform: scale(1.15);
}

.product-img-cell img {
  cursor: zoom-in;
  transition: transform 0.15s ease, opacity 0.15s ease;
  border-radius: 8px;
}

.product-img-cell img:hover {
  transform: scale(1.08);
  opacity: 0.9;
}

/* ─── Auth Pages (TB-06) ──────────────────────────────────────── */
.auth-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05);
  animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-logo {
  display: block;
  height: 44px;
  width: auto;
  margin: 0 auto 1.5rem;
  object-fit: contain;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}

.auth-field {
  margin-bottom: 1.1rem;
}

.auth-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.auth-field input {
  width: 100%;
  min-height: 44px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.auth-field input:focus {
  border-color: var(--brand);
  background: var(--surface);
}

.auth-field-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 0.5rem;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none !important;
  box-shadow: none !important;
}

.auth-submit .spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
  margin: 0;
  border-top-color: #fff;
}

.auth-error,
.auth-info {
  display: none;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 1.1rem;
}

.auth-error.visible,
.auth-info.visible {
  display: flex;
}

.auth-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #b91c1c;
}

.auth-info {
  background: var(--brand-soft);
  border: 1px solid var(--border-brand);
  color: var(--text-secondary);
}

/* Salida alterna en las pantallas de auth: link discreto, nunca un botón que
   compita con la acción principal. Sólo se muestra cuando el camino normal
   quedó bloqueado (enlace ya usado o reemplazado). */
.auth-alt-action {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.auth-alt-action a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.8;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.auth-alt-action a:hover,
.auth-alt-action a:focus-visible {
  opacity: 1;
  color: var(--brand);
}

.auth-success {
  text-align: center;
  padding: 0.5rem 0 0.25rem;
}

.auth-success-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

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

/* Medidor de fortaleza de contraseña */
.password-strength {
  margin-top: 0.5rem;
  margin-bottom: 1.1rem;
}

.password-strength-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--surface-alt);
  overflow: hidden;
}

.password-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.25s ease, background-color 0.25s ease;
  background: #ef4444;
}

.password-strength-text {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

/* ─── Panel de administración (TB-08) ─────────────────────────── */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-search {
  flex: 1;
  min-width: 220px;
  margin-bottom: 0;
}

.admin-role-select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
}

.admin-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.admin-status-chip.status-active {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
}

.admin-status-chip.status-invited {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

.admin-status-chip.status-disabled {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
}

.admin-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font);
}

.admin-action-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.admin-action-btn.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modalFadeIn 0.2s ease;
}

.admin-modal-card {
  width: 100%;
  max-width: 420px;
  animation: none;
  max-height: 90vh;
  overflow-y: auto;
}

.admin-modal-card select {
  width: 100%;
  min-height: 44px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
}

.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ─── Modal: enlace de acceso manual (TB-09) ─── */
.admin-invite-link-recipient {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.invite-link-field {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.invite-link-field input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
}

.invite-link-copy-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.invite-link-copy-btn.copied,
.invite-link-copy-msg.copied {
  border-color: #16a34a;
  color: #16a34a;
}

.invite-link-expiry {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

.invite-link-warning {
  background: rgba(237, 37, 47, 0.06);
  border: 1px solid rgba(237, 37, 47, 0.25);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
}

.invite-link-warning p {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
}

.invite-link-warning p + p {
  margin-top: 0.5rem;
}

.invite-link-warning strong {
  color: var(--text);
}

.invite-link-copy-msg {
  width: 100%;
}

@media (max-width: 768px) {
  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-row-actions {
    justify-content: flex-end;
  }
}

/* ─── Home footer actions (logout junto a forzar actualización) ── */
.footer-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 2rem 1.5rem;
  }
}