.stats-2charts-layout {
  display: flex;
  flex-direction: row;
  gap: 2.8rem;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 2.2rem auto;
}
.stats-2charts {
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
  align-items: center;
  justify-content: center;
}
.stats-chart-tile.big {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 18px rgba(47,125,101,0.08);
  padding: 1.6rem 2.2rem 2.2rem 2.2rem;
  min-width: 340px;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: box-shadow 0.18s, transform 0.18s;
}
.stats-chart-tile.big:hover {
  box-shadow: 0 10px 32px rgba(47,125,101,0.16);
  transform: translateY(-2px) scale(1.03);
}
#supplierPieChart {
  background: #f8fafc;
  border-radius: 14px;
  margin-top: 0.5rem;
  width: 340px !important;
  height: 340px !important;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
}
#topProductsBarChart {
  background: #f8fafc;
  border-radius: 14px;
  margin-top: 0.5rem;
  width: 440px !important;
  height: 340px !important;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
}
.classic-stats-summary.chicchette.card-stats.stats-lab-beauty {
  background: none;
  box-shadow: none;
  padding: 0;
  min-width: 260px;
  max-width: 340px;
  margin-top: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: center;
}
.stat-card.lab-beauty {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: linear-gradient(90deg, #e0f2f1 0%, #f1f5f9 100%);
  border-radius: 15px;
  box-shadow: 0 2px 12px rgba(47,125,101,0.10);
  padding: 1.3rem 1.7rem;
  font-size: 1.13rem;
  color: #17624a;
  font-weight: 500;
  min-width: 0;
  width: 100%;
  max-width: 340px;
  transition: box-shadow 0.18s;
}
.stat-card.lab-beauty:hover {
  box-shadow: 0 8px 32px rgba(47,125,101,0.13);
}
.stat-icon {
  font-size: 2.1rem;
  margin-right: 0.2rem;
  opacity: 0.85;
}
.stat-label {
  font-size: 1.07rem;
  color: #2f7d65;
  font-weight: 600;
}
.stat-value {
  font-size: 1.22rem;
  color: #17624a;
  font-weight: 700;
  margin-top: 0.1rem;
}
@media (max-width: 1100px) {
  .stats-2charts-layout {
    flex-direction: column;
    gap: 2.2rem;
    align-items: center;
  }
  .stats-2charts {
    flex-direction: row;
    gap: 2.2rem;
    align-items: center;
    justify-content: center;
  }
  #supplierPieChart, #topProductsBarChart {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 220px !important;
  }
}
@media (max-width: 700px) {
  .stats-2charts-layout {
    flex-direction: column;
    gap: 1.2rem;
    align-items: stretch;
  }
  .stats-2charts {
    flex-direction: column;
    gap: 1.2rem;
    align-items: center;
  }
  .classic-stats-summary.chicchette.card-stats.stats-lab-beauty {
    min-width: 0;
    max-width: 100%;
    padding: 0;
    gap: 0.7rem;
  }
  #supplierPieChart, #topProductsBarChart {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 180px !important;
  }
}
.lab-stats-layout {
  display: flex;
  flex-direction: row;
  gap: 2.8rem;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 2.2rem auto;
}
.lab-main-chart {
  flex: 2 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.lab-side-panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
  align-items: stretch;
}
.stats-chart-tile.lab-big {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 18px rgba(47,125,101,0.08);
  padding: 1.6rem 2.2rem 2.2rem 2.2rem;
  min-width: 340px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: box-shadow 0.18s, transform 0.18s;
}
.stats-chart-tile.lab-big:hover {
  box-shadow: 0 10px 32px rgba(47,125,101,0.16);
  transform: translateY(-2px) scale(1.03);
}
.stats-chart-tile.lab-side {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(47,125,101,0.06);
  padding: 1.1rem 1.5rem 1.5rem 1.5rem;
  min-width: 220px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
#supplierPieChart {
  background: #f8fafc;
  border-radius: 14px;
  margin-top: 0.5rem;
  width: 400px !important;
  height: 400px !important;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
}
#priceDistChart {
  background: #f8fafc;
  border-radius: 14px;
  margin-top: 0.5rem;
  width: 320px !important;
  height: 220px !important;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
}
.lab-stats-summary.formal {
  background: #f9fafb;
  border-radius: 13px;
  box-shadow: 0 1px 8px rgba(47,125,101,0.04);
  padding: 1.3rem 1.7rem;
  font-size: 1.09rem;
  color: #1e293b;
  font-family: 'Inter', 'Roboto Mono', monospace, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.2rem;
  min-width: 0;
  max-width: 340px;
}
.lab-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.4rem 0;
  font-size: 1.07rem;
}
.lab-stat-label {
  color: #2f7d65;
  font-weight: 600;
  font-family: 'Roboto Mono', monospace, Arial, sans-serif;
  letter-spacing: 0.01em;
}
.lab-stat-value {
  color: #17624a;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace, Arial, sans-serif;
  font-size: 1.13rem;
}
@media (max-width: 1100px) {
  .lab-stats-layout {
    flex-direction: column;
    gap: 2.2rem;
    align-items: center;
  }
  .lab-main-chart, .lab-side-panel {
    width: 100%;
    max-width: 98vw;
  }
  #supplierPieChart {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 320px !important;
  }
}
@media (max-width: 700px) {
  .lab-stats-layout {
    flex-direction: column;
    gap: 1.2rem;
    align-items: stretch;
  }
  .lab-main-chart, .lab-side-panel {
    width: 100%;
    max-width: 100vw;
  }
  #supplierPieChart {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 220px !important;
  }
  #priceDistChart {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 140px !important;
  }
}
/* Tabella AI scrollabile */
.ai-results table.ranking-table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.ai-results .ranking-table th, .ai-results .ranking-table td {
  min-width: 90px;
  padding: 0.5rem 0.7rem;
}
/* --- STATISTICHE: TABS, GRAFICI, CHICCHETTE --- */
.stats-tabs-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1.2rem;
  margin-bottom: 1.5rem;
}
.stats-tabs {
  display: flex;
  gap: 1.2rem;
  background: #e0f2f1;
  border-radius: 40px;
  padding: 0.25rem 0.4rem;
  box-shadow: 0 2px 12px rgba(47,125,101,0.06);
}
.stats-tab {
  background: transparent;
  color: #2f7d65;
  border: none;
  border-radius: 30px;
  padding: 0.55rem 1.6rem;
  font-size: 1.08rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s;
  outline: none;
  box-shadow: 0 0 0 rgba(47,125,101,0);
  position: relative;
}
.stats-tab.active {
  background: linear-gradient(90deg, #2f7d65 0%, #60a5fa 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(47,125,101,0.10);
  transform: scale(1.08);
  z-index: 1;
}
.stats-tab:not(.active):hover {
  background: #b2dfdb;
  color: #17624a;
  box-shadow: 0 2px 8px rgba(47,125,101,0.08);
  transform: scale(1.04);
}
.classic-stats-flex {
  display: flex;
  gap: 2.8rem;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}
.classic-stats-charts.grid-4charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2.2rem;
  align-items: stretch;
  justify-items: center;
  width: 100%;
  max-width: 950px;
}
.stats-chart-tile.big {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 18px rgba(47,125,101,0.08);
  padding: 1.2rem 1.6rem 1.5rem 1.6rem;
  min-width: 260px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: box-shadow 0.18s, transform 0.18s;
}
.stats-chart-tile.big:hover {
  box-shadow: 0 10px 32px rgba(47,125,101,0.16);
  transform: translateY(-2px) scale(1.03);
}
#supplierPieChart, #topProductsBarChart, #monthlyTrendChart, #avgQualityChart {
  background: #f8fafc;
  border-radius: 14px;
  margin-top: 0.5rem;
  width: 320px !important;
  height: 320px !important;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
}
#topProductsBarChart, #monthlyTrendChart {
  width: 420px !important;
}
.classic-stats-summary.chicchette.card-stats {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background: none;
  box-shadow: none;
  padding: 0;
  min-width: 220px;
  max-width: 320px;
  margin-top: 0.2rem;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: linear-gradient(90deg, #e0f2f1 0%, #f1f5f9 100%);
  border-radius: 13px;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
  padding: 1.1rem 1.3rem;
  font-size: 1.08rem;
  color: #17624a;
  font-weight: 500;
  min-width: 0;
  transition: box-shadow 0.18s;
}
.stat-card:hover {
  box-shadow: 0 4px 18px rgba(47,125,101,0.13);
}
.stat-icon {
  font-size: 2.1rem;
  margin-right: 0.2rem;
  opacity: 0.85;
}
.stat-label {
  font-size: 1.01rem;
  color: #2f7d65;
  font-weight: 600;
}
.stat-value {
  font-size: 1.18rem;
  color: #17624a;
  font-weight: 700;
  margin-top: 0.1rem;
}
/* AI INTRO (sotto filtri AI) */
.ai-intro {
  margin: 1.1rem 0 1.5rem 0;
  background: linear-gradient(90deg, #e0f2f1 0%, #f1f5f9 100%);
  border-radius: 12px;
  padding: 1.1rem 1.5rem;
  color: #17624a;
  font-size: 1.04rem;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
  text-align: left;
}
.classic-stats-summary.chicchette {
  background: linear-gradient(90deg, #e0f2f1 0%, #f1f5f9 100%);
  border-radius: 14px;
  padding: 1.1rem 1.5rem;
  box-shadow: 0 1px 8px rgba(47,125,101,0.06);
  min-width: 210px;
  max-width: 270px;
  margin-top: 0.2rem;
  font-size: 1.01rem;
  color: #17624a;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.classic-stats-summary.chicchette h4 {
  margin-top: 0;
  color: #2f7d65;
  font-size: 1.08rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.classic-stats-summary.chicchette ul {
  margin: 0.2rem 0 0 0;
  padding-left: 1.1rem;
  color: #17624a;
  font-size: 1.01rem;
  line-height: 1.7;
}
@media (max-width: 1200px) {
  .classic-stats-charts.grid-4charts {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 1.5rem;
    max-width: 98vw;
  }
}
@media (max-width: 900px) {
  .classic-stats-flex {
    flex-direction: column;
    gap: 1.5rem;
    align-items: stretch;
  }
  .classic-stats-charts.grid-4charts {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 1.2rem;
    align-items: center;
    max-width: 98vw;
  }
}
@media (max-width: 700px) {
  .classic-stats-flex {
    flex-direction: column;
    gap: 1.2rem;
    align-items: stretch;
  }
  .classic-stats-charts.grid-4charts {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 1.1rem;
    align-items: center;
    max-width: 98vw;
  }
  .stats-tab {
    padding: 0.5rem 1rem;
    font-size: 1rem;
  }
  .classic-stats-summary.chicchette.card-stats {
    min-width: 0;
    max-width: 100%;
    padding: 0;
    gap: 0.7rem;
  }
  #supplierPieChart, #topProductsBarChart, #monthlyTrendChart, #avgQualityChart {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 180px !important;
  }
}
/* --- STATISTICHE: TABS E GRAFICI --- */
.stats-tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.stats-tab {
  background: #f3f4f6;
  color: #2f7d65;
  border: 1.5px solid #d1d5db;
  border-radius: 30px;
  padding: 0.6rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(.4,0,.2,1);
  outline: none;
}
.stats-tab.active {
  background: linear-gradient(90deg, #2f7d65 0%, #60a5fa 100%);
  color: #fff;
  border-color: #2f7d65;
  box-shadow: 0 2px 8px rgba(47,125,101,0.08);
}
.classic-stats-charts {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
#supplierPieChart, #topProductsBarChart {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(47,125,101,0.04);
  padding: 1.2rem;
  margin-top: 0.5rem;
}
.classic-stats-summary {
  background: #f9fafb;
  border-radius: 10px;
  padding: 1.2rem 1.5rem;
  box-shadow: 0 1px 4px rgba(47,125,101,0.03);
  margin-top: 1.5rem;
}
.classic-stats-summary h4 {
  margin-top: 0;
  color: #2f7d65;
  font-size: 1.1rem;
  font-weight: 600;
}
.classic-stats-summary ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.2rem;
  color: #374151;
  font-size: 1rem;
}
@media (max-width: 700px) {
  .classic-stats-charts {
    grid-template-columns: 1fr;
  }
  .stats-tab {
    padding: 0.5rem 1rem;
    font-size: 1rem;
  }
}
/* Stile decorativo per la scritta Gestionale */
.gestionale-deco {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.08em;
  padding: 0.35em 0.8em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  margin-left: 0.7rem;
  text-transform: uppercase;
}
  background: rgba(255, 255, 255, 1);
  transform: translateY(-4px) scale(1.01);
}

.ia-tile {
  flex: 1 1 32%;
  min-width: 280px;
  background: var(--card-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.ia-tile:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.info-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  width: 100%;
}

.info-icon {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 500;
}

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

.info-desc {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
  margin-top: 0;
  line-height: 1.4;
}

.ia-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: white;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
}

.ia-btn:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow);
}

.ia-btn-icon {
  font-size: 1.1rem;
}

.card-flex {
  display: flex;
  flex-direction: row;
  gap: 0.8rem;
  align-items: stretch;
  width: 100%;
}

.vertical-flex {
  flex-direction: row !important;
  align-items: stretch !important;
}

.new-main-flex {
  display: flex;
  flex-direction: row;
  gap: 0.8rem;
  justify-content: space-between;
  width: 100%;
}

.wide-forms {
  width: 100%;
}


.search-section, .add-section {
  flex: 1 1 32%;
  min-width: 280px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 1rem;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transition: all 0.2s ease;
  position: relative;
}

.search-section:hover, .add-section:hover {
  box-shadow: 0 4px 12px rgba(47, 125, 101, 0.08);
  border-left-width: 4px;
}

/* Header decorativo per le form */
.form-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.form-header .form-icon {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 500;
}

.form-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
}



input::placeholder, select::placeholder {
  color: var(--muted);
  opacity: 0.6;
  font-weight: 400;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 125, 101, 0.1);
  background: white;
}

input:hover, select:hover {
  border-color: var(--muted);
}


/* Riduci spazio sopra e sotto i titoli delle form */
h2 {
  margin-top: 0.2rem;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
  margin-top: 0;
  font-weight: 400;
  line-height: 1.4;
}

.wide-tile {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.search-section {
  border: 2px solid var(--accent-light);
}

.add-section {
  border: 2px solid var(--accent-light);
}


.ia-tile {
  margin-top: 1.2rem;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.08) 0%, rgba(255,255,255,0.95) 100%);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  padding: 1.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: var(--shadow-md);
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  transition: all 0.3s ease;
}

.ia-tile:hover {
  border-style: solid;
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.search-bar:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(234,179,8,0.08);
}

.search-results {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0;
  max-height: 180px;
  overflow-y: auto;
  border-radius: 6px;
  background: white;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin-top: 0.2rem;
}

.search-results li {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 400;
  color: var(--text);
  font-size: 0.85rem;
}

.search-results li:last-child { 
  border-bottom: none; 
}

.search-results li:hover {
  background: var(--card-subtle);
  color: var(--primary);
}

:root {
  /* Palette colori minimalista ed elegante */
  --bg: #fafafa;
  --card: #ffffff;
  --card-subtle: #f8f8f8;
  --primary: #2f7d65;
  --primary-dark: #244c3a;
  --accent: #2f7d65;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #1f2937;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.06);
}

/* page layout safe */
html{
  height:100%;
  margin:0;
  padding:0;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body{
  height:100%;
  margin:0;
  padding:0;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding-left: 200px;
  -moz-osx-font-smoothing: grayscale;
  padding-left: 200px; /* Spazio per la sidebar */
}

/* LOGO SIDEBAR */
.logo-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 200px;
  height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  box-shadow: 2px 0 12px rgba(0,0,0,0.03);
  animation: slideInLeft 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.logo-container {
  text-align: center;
  padding: 1.5rem 1rem;
  animation: fadeInScale 1.4s cubic-bezier(0.4, 0, 0.2, 1) 0.4s backwards;
}

@keyframes fadeInScale {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.sidebar-logo {
  width: 110px;
  height: auto;
  object-fit: contain;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(47, 125, 101, 0.15));
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 4px 8px rgba(47, 125, 101, 0.15));
  }
  50% {
    transform: scale(1.02);
    filter: drop-shadow(0 6px 12px rgba(47, 125, 101, 0.2));
  }
}

.sidebar-logo:hover {
  transform: scale(1.08) rotate(2deg);
  filter: drop-shadow(0 8px 16px rgba(47, 125, 101, 0.25));
  animation: none; /* Stop pulse on hover */
}

.logo-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.logo-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 500;
}

/* TOPBAR */
.topbar{
  position:sticky;
  top:0;
  background: rgba(255,255,255,0.98);
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:0.7rem 1.5rem;
  border-bottom:1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index:40;
  box-shadow: var(--shadow);
}

.logo{
  height:40px!important;
  object-fit:contain;
  display:block;
}

/* NAV TABS */
nav{
  display:flex;
  align-items:center;
}

.nav-tabs{
  display:flex;
  gap:0.3rem;
  padding:4px;
  background: var(--card-subtle);
  border-radius:8px;
  align-items:center;
  position:relative;
  border: 1px solid var(--border);
}

nav button{
  background:none;
  border:none;
  padding:0.5rem 1rem;
  font-weight:500;
  cursor:pointer;
  color:var(--muted);
  border-radius:6px;
  transition: all 0.2s ease;
  min-width:80px;
  text-align:center;
  font-size:0.85rem;
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}

nav button:hover{ 
  color: var(--primary);
  background: rgba(47, 125, 101, 0.06);
}

nav button.active{
  color: white;
  font-weight:600;
  background: var(--primary);
  box-shadow: 0 2px 6px rgba(47, 125, 101, 0.2);
}

/* indicator used for subtle underline when not using full pill active style */
nav .indicator{
  position:absolute;
  bottom:4px;
  height:3px;
  background:var(--primary);
  border-radius:2px;
  transition:transform .25s cubic-bezier(.2,.9,.3,1), width .25s;
  pointer-events:none;
  width:0; /* set by JS */
}

/* LAYOUT */
main{
  max-width:1400px;
  margin:0 auto;
  padding:1rem 1rem;
  width:100%;
  flex:1;
  overflow:hidden;
}

.page{display:none;}
.page.active{display:block}

/* card area */
.card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  max-height: calc(100vh - 180px);
  overflow: auto;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(47, 125, 101, 0.08);
  border-left-width: 4px;
}

/* FORM */
label{
  font-size: .85rem;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

input, select {
  width: 100%;
  padding: 0.65rem 1rem;
  margin: 0.18rem 0 1.05rem 0;
  border-radius: 0.6rem;
  border: 1.2px solid var(--border);
  background: rgba(255,255,255,0.85);
  font-size: 1.04rem;
  color: #244c3a;
  transition: all 0.2s ease;
  display: block;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

input:focus,select:focus{
  outline:none;
  border-color:var(--primary);
  box-shadow:0 0 0 3px rgba(47, 125, 101, 0.1), 0 4px 18px rgba(47,125,101,0.06);
  background: white;
}

/* grid responsive */
.grid{
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* primary button */
.primary {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(47, 125, 101, 0.15);
  transition: all 0.2s ease;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: rgba(47, 125, 101, 0.2);
  user-select: none;
}

.primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(47, 125, 101, 0.25);
  transform: translateY(-1px);
}

.primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(47, 125, 101, 0.2);
  background: var(--primary-dark);
}
  border-color: var(--primary-dark);
  box-shadow: var(--shadow);
}

.primary:active {
  transform: translateY(1px);
}

/* TABLE */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 0.7rem;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

th, td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  text-align: left;
}

th {
  text-transform: uppercase;
  font-size: 0.75rem;
  background: var(--card-subtle);
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

tbody tr {
  transition: all 0.15s ease;
}

tbody tr:hover {
  background: rgba(47, 125, 101, 0.04);
  transform: scale(1.001);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* FILTRI */
.filters {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
  margin-bottom: 1rem;
  background: var(--card-subtle);
  border-radius: 8px;
  padding: 0.8rem;
  border: 1px solid var(--border);
}

/* PAGINATION */
.pagination{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:0.8rem;
  margin-top:1rem;
}

.pagination button{
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  box-shadow: none;
}

.pagination button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination button:active{ 
  transform: scale(0.95);
}

.pagination span {
  font-weight: 500;
  color: var(--text);
  font-size: 0.85rem;
}

/* FOOTER */
footer{
  text-align:center;
  padding:1rem;
  color: var(--muted);
  background: transparent;
  font-size: 0.8rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
}

/* TOAST */
#toast{
  position:fixed;
  bottom:20px;
  right:20px;
  background: var(--primary);
  color: white;
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 60;
  box-shadow: var(--shadow-md);
  font-weight: 500;
  font-size: 0.85rem;
}

#toast.show{
  opacity: 1;
  transform: translateY(0);
}

/* hidden helper */
.hidden{display:none}

/* fixed-select minimalista */
.fixed-select{
  position:relative;
  -webkit-appearance:none;
  -moz-appearance:none;
  appearance:none;
  background: white;
  padding-right:2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) calc(50%), calc(100% - 8px) calc(50%);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  max-width:100%;
}

/* chart wrapper minimalista */
.chart-wrap{
  height:280px;
  position:relative;
  background: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* Export buttons */
.export {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  justify-content: center;
}

.export button {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  box-shadow: none;
}

.export button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Product Dialog */
.product-dialog {
  border: none;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 85vw;
  max-height: 85vh;
  overflow: auto;
  background: white;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.product-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

/* Filter buttons in dialog */
.filterBtn {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.filterBtn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filterBtn:active,
.filterBtn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-light) 100%);
  border-radius: 10px;
  border: 2px solid var(--border);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--accent) 0%, #e6c256 100%);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page.active {
  animation: fadeIn 0.4s ease-out;
}

/* Headings styling */
h2 {
  font-family: 'Inter', sans-serif;
  color: var(--text);\n  font-weight: 600;
  letter-spacing: 0.01em;
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

/* Product details styling */
.product-details {
  margin-top: 0.8rem;
  padding: 0.8rem;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* Scrollbar minimalista */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--border-light);
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}
/* === PILLOLA STATISTICHE ANDAMENTO SPESE === */

/* Badge statistici sopra la pillola */
.stats-badges-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.8rem;
  transition: opacity 0.3s ease;
}

.stats-badges-row.dimmed {
  opacity: 0.3;
  pointer-events: none;
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 0.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
  transition: all 0.3s ease;
  cursor: default;
  border: 1px solid;
}

.stat-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Colori diversi per ogni badge */
.stat-badge-purple {
  background: linear-gradient(135deg, #d4f0e1 0%, #edf9f3 100%);
  border-color: #9dd3b8;
}

.stat-badge-purple:hover {
  background: linear-gradient(135deg, #c5ead7 0%, #e5f7ee 100%);
  border-color: #7ec8a6;
}

.stat-badge-teal {
  background: linear-gradient(135deg, #d4f0e1 0%, #edf9f3 100%);
  border-color: #9dd3b8;
}

.stat-badge-teal:hover {
  background: linear-gradient(135deg, #c5ead7 0%, #e5f7ee 100%);
  border-color: #7ec8a6;
}

.stat-badge-amber {
  background: linear-gradient(135deg, #d4f0e1 0%, #edf9f3 100%);
  border-color: #9dd3b8;
}

.stat-badge-amber:hover {
  background: linear-gradient(135deg, #c5ead7 0%, #e5f7ee 100%);
  border-color: #7ec8a6;
}

.stat-badge-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.3rem;
  text-align: center;
}

.stat-badge-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  text-align: center;
  color: #4a5568;
}

.stat-badge-purple .stat-badge-value {
  color: #4a5568;
}

.stat-badge-teal .stat-badge-value {
  color: #4a5568;
}

.stat-badge-amber .stat-badge-value {
  color: #4a5568;
}

/* Pillola andamento spese */
.spending-trends-pill {
  background: linear-gradient(135deg, rgba(115, 135, 142, 0.04) 0%, rgba(255,255,255,0.98) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid #73878e;
  border-radius: 8px;
  padding: 0.9rem;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  flex: 1;
}

.spending-trends-pill:hover {
  box-shadow: 0 4px 16px rgba(115, 135, 142, 0.15);
  border-left-width: 4px;
  transform: translateY(-2px);
}

.pill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.pill-header > div {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Badge totale periodo */
.period-total-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: linear-gradient(135deg, #e3f5ed 0%, #f5fbf8 100%);
  border: 1px solid #b8dcc9;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  margin-left: 0.5rem;
  box-shadow: 0 1px 3px rgba(47, 125, 101, 0.1);
  transition: all 0.2s ease;
}

.period-total-badge:hover {
  background: linear-gradient(135deg, #d6f0e4 0%, #f0f9f5 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(47, 125, 101, 0.15);
}

.period-total-label {
  color: var(--muted);
  font-size: 0.65rem;
}

.period-total-value {
  color: var(--primary);
  font-weight: 700;
}

.trend-icon {
  font-size: 1rem;
  filter: grayscale(0.3);
}

.pill-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.01em;
}

.trends-filter {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: white;
  font-size: 0.7rem;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 6px) calc(50%), calc(100% - 3px) calc(50%);
  background-size: 3px 3px, 3px 3px;
  background-repeat: no-repeat;
  padding-right: 1.2rem;
  min-width: 50px;
  max-width: 60px;
}

.trends-filter:hover {
  border-color: #73878e;
  background-color: rgba(115, 135, 142, 0.05);
}

.trends-filter:focus {
  outline: none;
  border-color: #73878e;
  box-shadow: 0 0 0 2px rgba(115, 135, 142, 0.15);
}

.trends-chart-wrapper {
  position: relative;
  height: 130px;
  margin: 0.6rem 0 0 0;
  background: white;
  border-radius: 6px;
  padding: 0.6rem;
  border: 1px solid var(--border-light);
}

.trends-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.trend-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid;
}

.trend-stat.trend-max {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(255,255,255,0.95) 100%);
  border-color: rgba(239, 68, 68, 0.2);
}

.trend-stat.trend-max:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(255,255,255,0.98) 100%);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
}

.trend-stat.trend-min {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(255,255,255,0.95) 100%);
  border-color: rgba(34, 197, 94, 0.2);
}

.trend-stat.trend-min:hover {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(255,255,255,0.98) 100%);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.trend-stat.trend-max .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #dc2626;
  font-family: 'Inter', sans-serif;
}

.trend-stat.trend-min .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #16a34a;
  font-family: 'Inter', sans-serif;
}
/* ===================================
   AI ANALYSIS STYLES
   =================================== */

.ai-analyze-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  margin: 1.5rem 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(47, 125, 101, 0.3);
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.ai-analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(47, 125, 101, 0.4);
}

.ai-analyze-btn:disabled {
  background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
  cursor: not-allowed;
  box-shadow: none;
}

.ai-icon {
  font-size: 1.3rem;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.2) rotate(10deg); opacity: 0.8; }
}

.ai-loading {
  text-align: center;
  padding: 3rem 1rem;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f4f6;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ai-loading p {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.ai-results {
  margin-top: 2rem;
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-summary {
  background: linear-gradient(135deg, rgba(47, 125, 101, 0.08) 0%, rgba(255, 255, 255, 0.95) 100%);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.ai-summary h3 {
  color: var(--primary);
  font-size: 1.1rem;
  margin: 0 0 0.8rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.ai-summary-icon {
  font-size: 1.4rem;
}

.ai-summary p {
  color: var(--text);
  line-height: 1.6;
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

.ai-ranking {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.ranking-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.02em;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table th {
  background: var(--card-subtle);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ranking-table td {
  padding: 0.8rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-size: 0.8rem;
}

.ranking-table tr:hover {
  background: rgba(47, 125, 101, 0.02);
}

.ranking-table tr:last-child td {
  border-bottom: none;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
}

.rank-1 {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  color: #854d0e;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.rank-2 {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
  color: #374151;
  box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.rank-3 {
  background: linear-gradient(135deg, #cd7f32 0%, #e8a87c 100%);
  color: #78350f;
  box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

.rank-other {
  background: var(--card-subtle);
  color: var(--muted);
  border: 1px solid var(--border);
}

.quality-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.quality-ottima {
  background: #d1fae5;
  color: #065f46;
}

.quality-buona {
  background: #dbeafe;
  color: #1e40af;
}

.quality-media {
  background: #fef3c7;
  color: #92400e;
}

.quality-scarsa {
  background: #fee2e2;
  color: #991b1b;
}

.price-cell {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}

.supplier-cell {
  font-weight: 500;
  font-size: 0.82rem;
}

.date-cell {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Record selezionato dall'archivio */
.ranking-table tr.selected-record {
  background: linear-gradient(135deg, rgba(47, 125, 101, 0.12) 0%, rgba(47, 125, 101, 0.08) 100%);
  border-left: 4px solid var(--primary);
  box-shadow: 0 2px 8px rgba(47, 125, 101, 0.15);
}

.ranking-table tr.selected-record:hover {
  background: linear-gradient(135deg, rgba(47, 125, 101, 0.15) 0%, rgba(47, 125, 101, 0.1) 100%);
}

.selected-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.recommendation-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.recommendation-icon {
  font-size: 1rem;
}

/* Tabella prodotto analizzato */
.analyzed-product-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}

.analyzed-product-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.analyzed-product-content {
  padding: 1rem;
  background: linear-gradient(135deg, rgba(47, 125, 101, 0.02) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.analyzed-product-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.analyzed-product-desc {
  color: var(--text);
  line-height: 1.5;
  font-size: 0.85rem;
  margin: 0;
}

/* Tabella top fornitori */
.top-suppliers-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}

.top-suppliers-header {
  background: var(--card-subtle);
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.02em;
}

.top-suppliers-table table {
  width: 100%;
  border-collapse: collapse;
}

.top-suppliers-table th {
  background: var(--card-subtle);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.top-suppliers-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-size: 0.8rem;
}

.top-suppliers-table tr:last-child td {
  border-bottom: none;
}

.top-suppliers-table tr:hover {
  background: rgba(47, 125, 101, 0.02);
}

.supplier-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.7rem;
  background: var(--card-subtle);
  color: var(--muted);
  border: 1px solid var(--border);
}

.supplier-name-cell {
  font-weight: 600;
  color: var(--primary);
}

.quantity-cell {
  font-weight: 600;
  color: var(--text);
}

