@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Palette chiara neutra */
  --bg-base: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-subtle: #f9fafb;

  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;

  --text-primary: #0f172a;
  --text-muted: #4b5563;
  --text-soft: #9ca3af;

  /* Accento principale blu */
  --accent-primary: #2563eb;
  --accent-primary-strong: #1d4ed8;
  --accent-primary-soft: #eff6ff;

  /* Link */
  --link: #1d4ed8;
  --link-hover: #1e40af;

  /* Stati */
  --success: #16a34a;
  --success-bg: #ecfdf3;
  --success-text: #166534;

  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-text: #991b1b;

  --selection-width: 340px;
  --header-height: 64px;
  --subheader-height: 40px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ===== PAGINE ===== */

body.page-login {
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

body.page-signup {
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

body.page-app {
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;

  /* niente height fissa:
     - resta almeno alto quanto il viewport
     - ma può adattarsi quando Safari cambia l'altezza (barra indirizzi, tastiera, ecc.) */
  min-height: 100vh;
  min-height: 100dvh;

  overflow: hidden;
  /* riduce il “rimbalzo” a livello di pagina */
  overscroll-behavior-y: none;
}



/* ===== FORM / INPUT / BUTTON ===== */

label {
  font-size: 0.8rem;
  color: var(--text-soft);
  display: block;
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.searchInputRow {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.searchInputRow input {
  flex: 1;
  min-width: 0;
}

.searchSubmitBtn--inline {
  white-space: nowrap;
  padding-inline: 12px;
}

.field {
  margin-bottom: 12px;
}

/* checkbox generiche (non prodotti) = native */
input[type="checkbox"] {
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* checkbox prodotti custom: quadrato perfetto e spunta centrata */
.productSelectCheckbox {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: inline-block;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
}

.productSelectCheckbox:hover {
  background: var(--bg-base);
}

.productSelectCheckbox:focus {
  outline: none;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
  border-color: var(--accent-primary);
}

.productSelectCheckbox:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.productSelectCheckbox:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 11px;
  border: 2px solid #ffffff;
  border-top: none;
  border-left: none;
  transform: translate(-50%, -65%) rotate(45deg);
}

/* select tematizzata */

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  padding-right: 28px;
  cursor: pointer;

  background-image:
    linear-gradient(45deg, var(--text-soft) 50%, transparent 50%),
    linear-gradient(135deg, var(--text-soft) 50%, transparent 50%),
    linear-gradient(to right, var(--border-subtle), var(--border-subtle));
  background-position:
    calc(100% - 12px) 50%,
    calc(100% - 7px) 50%,
    calc(100% - 26px) 50%;
  background-size: 5px 5px, 5px 5px, 1px 60%;
  background-repeat: no-repeat;
}

/* ===== FILTRI RICERCA ===== */

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

.filtersSummary {
  font-size: 0.75rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filtersPanel {
  display: none;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.filtersPanel.filtersPanel--open {
  display: block;
}

.filtersHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

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

.filtersSub {
  font-size: 0.75rem;
  color: var(--text-soft);
  text-align: right;
}

.brandFilterList {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.brandFilterItem {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.brandFilterAvatar {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.brandFilterAvatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 999px;
  background: var(--bg-surface);
}

.brandFilterItem--selected {
  border-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  color: var(--accent-primary-strong);
}

.brandFilterName {
  white-space: nowrap;
}

.brandFilterCheck {
  font-size: 0.8rem;
  min-width: 14px;
  text-align: right;
}

.resultsFilters {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.resultsFiltersHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.resultsFiltersTitle {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
}

.resultsFiltersHint {
  font-size: 0.72rem;
}

.resultsFiltersRow {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}

.resultsFiltersRow:last-child {
  margin-bottom: 0;
}

.resultsFiltersRowLabel {
  width: 90px;
  flex-shrink: 0;
  color: var(--text-soft);
}

.resultsFiltersProducers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.resultsFilterChip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.resultsFilterChip--active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  color: var(--accent-primary-strong);
}

.resultsFiltersSort select {
  max-width: 180px;
}

/* ===== BUTTONS & TEXT ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 999px;
  border: none;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Manteniamo il nome .btn--green ma usiamo l'accento blu */
.btn--green {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn--green:hover:not(:disabled) {
  background: var(--accent-primary-strong);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}

.btn--blue {
  background: var(--accent-primary-soft);
  color: var(--accent-primary-strong);
  border: 1px solid var(--accent-primary);
}

.btn--blue:hover:not(:disabled) {
  background: #dbeafe;
}

.btn--ghost {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--accent-primary);
  color: var(--accent-primary-strong);
}

.btn-mini {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-mini:hover {
  border-color: var(--border-strong);
}

/* stato attivo per i bottoni del mini-header (Ricerche / Confronto) */
.appSubHeader-btn--active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  color: var(--accent-primary-strong);
}

.searchSubmitBtn {
  min-width: 42px;
  padding-inline: 10px;
}

.searchBtnIcon {
  font-size: 1.1rem;
  line-height: 1;
}

.searchBtnSpinner {
  font-size: 0.85rem;
}

.tiny,
.text-xs {
  font-size: 0.75rem;
  color: var(--text-soft);
}

/* ===== LOGIN ===== */

body.page-login .card {
  background: var(--bg-surface);
  border-radius: 14px;
  padding: 24px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
  border: 1px solid var(--border-subtle);
}

body.page-login h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--text-primary);
}

body.page-login .subtitle {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin-bottom: 20px;
}

.error {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--error-text);
  background: var(--error-bg);
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid var(--error);
}

body.page-login .link-row {
  margin-top: 14px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  color: var(--text-soft);
}

.loginBrand {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 16px;
  text-align: center;
}

/* ===== SIGNUP ===== */

body.page-signup .card {
  background: var(--bg-surface);
  border-radius: 14px;
  padding: 24px 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
  border: 1px solid var(--border-subtle);
}

body.page-signup h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--text-primary);
}

body.page-signup .subtitle {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 10px;
}

.row .field {
  flex: 1;
}

.msg {
  margin-top: 10px;
  font-size: 0.82rem;
  border-radius: 8px;
  padding: 8px 10px;
  display: none;
}

.msg.error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error);
}

.msg.ok {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success);
}

body.page-signup .link-row {
  margin-top: 14px;
  font-size: 0.8rem;
  display: flex;
  justify-content: flex-end;
  color: var(--text-soft);
}

/* ===== HEADER APP (SOPRA TUTTO) ===== */
/* Logo Lystin in header */
.brandLogoLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brandLogoImg {
  display: block;
  height: 32px;   /* regola se lo vuoi più grande/piccolo */
  width: auto;
}
@media (max-width: 768px) {
  .brandLogoImg {
    height: 28px;
  }
}

.topHeader {
  height: var(--header-height);
  box-sizing: border-box;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(to bottom, #ffffff, var(--bg-base));
  display: flex;
  align-items: center;
  z-index: 10;
}

/* shell a larghezza piena (logo SX, user DX ai bordi) */
.shell {
  max-width: none;
  margin: 0;
  width: 100%;
}

.appHeader-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

/* Brand + utente */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logoCircle {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: conic-gradient(from 200deg, var(--accent-primary), #60a5fa, var(--accent-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.35);
}

.logoCircle span {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
}

.brandTitles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.brandSub {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.userBox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-soft);
  min-width: 0;
}

.userInfo {
  text-align: right;
  max-width: 220px;
}

.userName {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenantName {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-soft);
}

/* Logo Lystin */
.logoCircle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background-color: var(--primary-weak, #eef3ff);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logoCircle .logoImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Icone PNG generiche */
.icon {
  inline-size: 16px;
  block-size: 16px;
  display: inline-block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* Mappatura singole icone */
.icon--pin       { background-image: url('/img/pin.png'); }
.icon--new       { background-image: url('/img/new.png'); }
.icon--dots      { background-image: url('/img/dots.png'); }
.icon--searches  { background-image: url('/img/searches.png'); }
.icon--recent    { background-image: url('/img/recent.png'); }
.icon--settings  { background-image: url('/img/settings.png'); }
.icon--folder    { background-image: url('/img/folder.png'); }
.icon--search    { background-image: url('/img/search_icon.png'); }
.icon--user      { background-image: url('/img/user.png'); }
.icon--category  { background-image: url('/img/category.png'); }
.icon--trash     { background-image: url('/img/trash.png'); }
.icon--help      { background-image: url('/img/help.png'); }

/* Evita che dall'header parta lo scroll verticale della pagina su mobile */
.topHeader,
.appSubHeader {
  touch-action: pan-x;
}

/* ===== APP LAYOUT (SIDEBAR + MAIN) ===== */

.appShell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  /* niente height fissa: prende lo spazio che il body gli dà */
  min-height: 0;
}


/* sidebar sinistra: fissa, scroll interno */

.sidebar {
  border-right: 1px solid var(--border-subtle);
  padding: 12px 10px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  border-radius: 0;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-new-search {
  margin-bottom: 10px;
}

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

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sidebar-content {
  flex: 1;
  padding-top: 6px;
  padding-right: 4px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 0;
}

/* shell principale (risultati + confronto) */

.mainShell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
}


.mainContent {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
  padding: 0 0 0 16px;
  box-sizing: border-box;
  overflow: hidden;
  background: var(--bg-base);
}

.mainArea {
  flex: 1 1 auto;
  min-width: 420px;
  margin-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 0 24px;
}

/* Card generiche */

body.page-app .card {
  background: var(--bg-surface);
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

.cardTitle {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.cardSub {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-bottom: 12px;
}

/* pannello ricerca (hero) */

#searchCard {
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.searchCard--hidden {
  display: none;
}

/* messaggi form */

.msg {
  font-size: 0.78rem;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 8px;
  display: none;
}

.msg.error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error);
}

.msg.ok {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success);
}

/* risultati */

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

.resultsMeta {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.resultsMeta span {
  margin-right: 8px;
}

.refineBadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.7rem;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: var(--accent-primary-soft);
  color: var(--accent-primary-strong);
  white-space: nowrap;
}

/* usata per i nomi produttori nei risultati */
.refineBadge--brand {
}

/* blocco risultati per produttore */

.brandGroup {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  margin-bottom: 10px;
  background: radial-gradient(circle at top left, #f9fafb, var(--bg-surface));
}

.brandHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.brandName {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.brandTimings {
  font-size: 0.72rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.brandError {
  font-size: 0.78rem;
  color: var(--error-text);
}

.sectionLabel {
  font-size: 0.76rem;
  color: var(--text-soft);
  margin-top: 4px;
  margin-bottom: 4px;
}

/* lista prodotti + checkbox */

.productList {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.productHeaderRow {
  display: grid;
  grid-template-columns: 24px minmax(0, 2.8fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 2px 0 4px;
  font-size: 0.72rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(209, 213, 219, 0.9);
}

.prodHeaderCell {
  white-space: nowrap;
}

.prodHeaderCell--checkbox {
  text-align: center;
}

.prodHeaderCell--price {
  text-align: right;
}

.productRow--header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted, #777);
  background: var(--surface-subtle, #f7f7f7);
  border: 1px solid var(--selection-border-color, var(--accent-border, #c7d2ff));
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 4px;
}

/* celle dell'header */
.prodSelect--header,
.prodMain--header,
.prodPrice--header {
  display: flex;
  align-items: center;
}

.prodSelect--header {
  justify-content: center;
}

.prodMain--header {
  font-weight: 500;
  justify-content: flex-start;
  text-align: left;
}

.prodPrice--header {
  font-weight: 500;
  justify-content: flex-end;
  text-align: right;
}

.productRow {
  display: grid;
  grid-template-columns: 24px minmax(0, 2.8fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 6px 4px;
  font-size: 0.8rem;
  align-items: center;
  background: var(--bg-subtle);
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.productRow--selected {
  background: var(--accent-primary-soft);
  border-color: rgba(37, 99, 235, 0.45);
}

.productRow:first-child {
  border-top: none;
}

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

.prodMain {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prodName {
  font-size: 0.8rem;
  color: var(--text-primary);
}

.prodCode {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.prodPrice {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-muted);
  text-align: right;
}

.noResults {
  font-size: 0.8rem;
  color: var(--text-soft);
  padding: 6px 2px;
}

.moreBtn {
  margin-top: 6px;
  font-size: 0.76rem;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
}

.moreBtn span {
  opacity: 0.9;
}

.moreBtn:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

/* ===== SIDEBAR / CRONOLOGIA ===== */

.collapseToggle {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.collapseArrow {
  font-size: 0.75rem;
  color: var(--text-soft);
  transition: transform 0.12s ease, color 0.12s ease;
}

.collapseArrow--collapsed {
  transform: rotate(-90deg);
}

.history-section-label:hover .collapseArrow,
.history-group-header:hover .collapseArrow {
  color: var(--text-muted);
}

.history-group--collapsed .history-group-header {
  opacity: 0.9;
}

.historyContainer {
  font-size: 0.78rem;
}

.history-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-top: 8px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-section-title {
  flex: 1;
}

.history-group {
  margin-bottom: 6px;
}

.history-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  padding: 2px 4px;
  border-radius: 6px;
}

.history-group-main {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.history-group-main .history-group-new-search {
  padding-inline: 8px;
  font-size: 0.72rem;
}

.history-group--active .history-group-header {
  background: var(--accent-primary-soft);
  border-radius: 8px;
  padding: 4px 6px;
}

.history-group-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.history-item:hover {
  background: var(--bg-subtle);
}

.history-item--active {
  background: var(--accent-primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.7);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.history-item-sub {
  font-size: 0.7rem;
  color: var(--text-soft);
}

.history-empty {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: 8px;
}

/* “Nuova ricerca” dentro al gruppo */

.history-item--new {
  border: 1px dashed var(--border-subtle);
  background: var(--bg-subtle);
}

.history-item--new:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.history-item-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.78rem;
  padding: 4px 0;
  cursor: pointer;
  text-align: left;
}

.history-item-new-btn:hover {
  color: var(--text-muted);
}

.history-item-new-plus {
  font-size: 0.9rem;
}

/* menu 3 puntini */

.history-item-menu-wrap,
.history-group-menu-wrap {
  position: relative;
}

.history-menu-trigger {
  border: none;
  background: transparent;
  color: var(--text-soft);
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.history-item:hover .history-menu-trigger,
.history-group-header:hover .history-menu-trigger {
  background: var(--bg-subtle);
}

.history-item-menu,
.history-group-menu {
  position: absolute;
  top: 110%;
  right: 0;
  min-width: 160px;
  background: var(--bg-surface);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
  padding: 4px 0;
  display: none;
  z-index: 20;
}

.history-item--menu-open .history-item-menu {
  display: block;
}

.history-group--menu-open .history-group-menu {
  display: block;
}

.history-item-menu button,
.history-group-menu button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.78rem;
  cursor: pointer;
}

.history-item-menu button:hover,
.history-group-menu button:hover {
  background: var(--bg-subtle);
}

/* ===== PANNELLO DESTRA (CONFRONTO) ===== */

.resizeHandle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  margin: 0 4px;
}

.resizeHandle:hover {
  background: rgba(148, 163, 184, 0.4);
}

.selectionPane {
  flex: 0 0 var(--selection-width);
  min-width: 260px;
  max-width: 520px;
  border-left: 1px solid var(--border-subtle);
  padding: 16px 14px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-radius: 0;
  min-height: 0;
}

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

.selectionTitle {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.selectionSub {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.selectionList {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selectionEmpty {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.selectionRow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 6px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
}

.selectionMain {
  flex: 1;
  min-width: 0;
}

.selectionName {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.selectionMeta {
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.selectionRight {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 70px;
}

.selectionPrice {
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-muted);
}

.selectionRemoveBtn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 2px;
}

.selectionRemoveBtn:hover {
  color: var(--error);
}

/* ===== RESPONSIVE ===== */

/* ELEMENTI SOLO MOBILE */
.mobileOnly {
  display: none;
}

/* Mini-header: nascosto di default (desktop) */
.appSubHeader {
  display: none;
}

@media (max-width: 1024px) {
  :root {
    --header-height: 52px;      /* uguale alla .topHeader su mobile */
    --subheader-height: 52px;   /* leggermente più alta del mini-header reale */
  }
  /* HEADER PIÙ COMPATTO */
  .topHeader {
    height: 52px;
    padding: 6px 10px;
  }

  .logoCircle {
    width: 24px;
    height: 24px;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.25);
  }

  .logoCircle span {
    font-size: 0.7rem;
  }

  .brandName {
    font-size: 0.9rem;
  }

  .brandSub {
    display: none;
  }

  .usageBox {
    display: none !important;
  }

  .userBox {
    gap: 6px;
  }

  .userInfo {
    max-width: 140px;
  }

  .logoutBtn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  /* MINI-HEADER MOBILE */
  .appSubHeader {
    display: block;
    min-height: var(--subheader-height);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    position: relative;
    z-index: 9;
  }



  .appSubHeader-inner {
    max-width: none;
    margin: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    box-sizing: border-box;
    position: relative; /* per centrare le quote */
  }

  .appSubHeader-btn {
    border: none;
    background: transparent;
    padding: 6px;              /* area clic un po' più grande */
    border-radius: 999px;
    min-width: auto;
  }
  
  .appSubHeader-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    width: 100%;
  }

  .appSubHeader-btn .icon {
    width: 24px;
    height: 24px;
  }

  .appSubHeader-btn--active {
    border: none;
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent-primary);
  }

  .appSubHeader-btnLabel {
    display: none;
  }
  
  .appSubHeader-quotas {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;      /* una riga sopra l’altra */
    align-items: center;
    gap: 2px;                    /* spazio verticale tra le due righe */
    pointer-events: none;        /* non blocca il tap sui bottoni */
  }

  .appSubHeader-quotas span {
    white-space: nowrap;
    text-align: center;
  }
  
  
    /* LAYOUT SOTTO HEADER + MINI-HEADER */
  .appShell {
    grid-template-columns: minmax(0, 1fr);
  }



  .mainContent {
    padding: 10px 10px 12px;
  }

  .mainArea {
    min-width: 0;
  }

  .resizeHandle {
    display: none;
  }

  /* SIDEBAR = OVERLAY A SCHERMO INTERO SOTTO GLI HEADER */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    /* copre tutto lo schermo; niente 100vw per evitare “uscite” laterali */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;

    /* spinge il contenuto sotto header + mini-header, ma l'overlay parte da top:0 */
    padding-top: calc(var(--header-height) + var(--subheader-height) + 10px);

    background: var(--bg-surface);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.3);
    border-top: 1px solid var(--border-subtle);
    border-right: none;

    transform: translateX(-100%);
    transition: transform 0.18s ease-out;

    /* deve stare sopra al contenuto ma sotto all'header (z-index 10) */
    z-index: 5;
  }

  .sidebar.sidebar--open {
    transform: translateX(0);
  }


    /* CONFRONTO = OVERLAY A SCHERMO INTERO SOTTO GLI HEADER */
  .selectionPane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    width: 100%;
    max-width: 100%;
    box-sizing: border-box;

    /* spinge il contenuto sotto header + mini-header */
    padding-top: calc(var(--header-height) + var(--subheader-height) + 10px);
    padding-inline: 14px;
    padding-bottom: 12px;

    background: var(--bg-surface);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.3);
    border-top: 1px solid var(--border-subtle);
    border-left: none;

    transform: translateX(100%);
    transition: transform 0.18s ease-out;

    z-index: 5;
  }

  .selectionPane.selectionPane--open {
    transform: translateX(0);
  }


}

/* ===== MODAL OVERLAY / POPUP CUSTOM ===== */

.modalOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1000;
  padding: 16px;
  box-sizing: border-box;
}

.modal {
  background: var(--bg-surface);
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  max-width: 380px;
  width: 100%;
  padding: 16px 18px 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modalTitle {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.modalBody {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modalMessage {
  margin-bottom: 8px;
  line-height: 1.4;
}

.modalInput {
  width: 100%;
  margin-top: 4px;
  font-size: 0.9rem;
}

.modalActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.producerHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.producerLogo {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
}

.producerLogo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: var(--bg-surface);
}

.producerHeaderText {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.producerName {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.producerSlug {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.producerBody {
  margin-top: 6px;
  font-size: 0.8rem;
}

.producerSectionTitle {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.producerField {
  margin-top: 4px;
}

.producerFieldLabel {
  font-weight: 500;
  margin-right: 4px;
}

.modalActions .btn {
  font-size: 0.82rem;
  padding: 7px 12px;
}

.modalOverlay[style*="display: flex"] .modal {
  animation: modal-pop-in 0.12s ease-out;
}

@keyframes modal-pop-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* nomi utente/tenant cliccabili */
.userName,
.tenantName {
  cursor: pointer;
}

.userName:hover,
.tenantName:hover {
  text-decoration: underline;
}

/* brand cliccabili nei risultati */
.brandName--clickable {
  cursor: pointer;
}

.brandName--clickable .refineBadge--brand {
  transition: box-shadow 0.12s ease, transform 0.05s ease;
}

.brandName--clickable:hover .refineBadge--brand {
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

/* Riga che contiene il badge prezzo sopra il nome */
.prodBadges {
  margin-bottom: 2px;
  display: flex;
  align-items: center;
}

/* Badge prezzo molto compatto, coerente con la UI */
.priceMarker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
}

/* meno costoso */
.priceMarker--min {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success);
}

/* più costoso */
.priceMarker--max {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error);
}

.usageBox {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

/* ===== PULSANTE RICERCA: ICONA PNG + SPINNER ===== */

.searchSubmitBtn {
  min-width: 44px;
  padding-inline: 10px;
}

.searchBtnLabel,
.searchBtnSpinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.searchBtnIconImg {
  width: 16px;
  height: 16px;
  display: block;
}

/* spinner circolare */
.searchBtnSpinner {
  display: none;
}

.spinnerCircle {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  box-sizing: border-box;
  animation: searchSpinnerSpin 0.7s linear infinite;
}

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

/* ===== TOOLS RISULTATI (ORDINAMENTO) ===== */

.resultsTools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.resultsToolsLabel {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-soft);
}

/* ===== CONTROLLI PRODOTTI SIMILI (PAGINAZIONE A 5) ===== */

.similarControls {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.similarControlsGroup {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.similarControlsLabel {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.similarControls .moreBtn {
  font-size: 0.72rem;
  padding: 4px 8px;
}

/* ===== CHIP ORDINAMENTO (RILEVANZA / PREZZO) ===== */

.sortChips,
.resultsFiltersSort {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sortChip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.sortChip:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.sortChip--active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  color: var(--accent-primary-strong);
}

.resultsFiltersRow + .resultsFiltersRow {
  border-top: 1px dashed var(--border-subtle);
  margin-top: 6px;
  padding-top: 6px;
}
/* Separatore tra sezioni nel pannello Filtri (Ordina / Produttori) */
.filtersSection + .filtersSection {
  border-top: 1px dashed var(--border-subtle);
  margin-top: 8px;
  padding-top: 8px;
}
/* Evita auto-zoom su iOS in focus */
@media (max-width: 1024px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .tenantName {
    display: none; /* nascondi la riga azienda */
  }

  .userInfo {
    max-width: 110px;
  }

  .logoutBtn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
  height: 100%;
}
/* Intestazione tabella risultati (SEL. / PRODOTTO / PREZZO / UM) */
.productRow.productRow--header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted, #777);
  background: var(--surface-subtle, #f7f7f7);
  border: 1px solid var(--selection-border-color, var(--accent-border, #c7d2ff));
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 4px;
}

/* Celle dell'header */
.productRow.productRow--header .prodSelect--header,
.productRow.productRow--header .prodMain--header,
.productRow.productRow--header .prodPrice--header {
  display: flex;
  align-items: center;
  font-size: 11px !important;   /* <- stessa dimensione per SEL., PRODOTTO, PREZZO / UM */
  line-height: 1.2;
}

/* SEL. centrato sulla colonna checkbox */
.productRow.productRow--header .prodSelect--header {
  justify-content: center;
}

/* PRODOTTO allineato a sinistra (forzato) */
.productRow.productRow--header .prodMain--header {
  justify-content: flex-start !important;
  align-items: flex-start !important;
  text-align: left !important;
}

/* PREZZO / UM a destra */
.productRow.productRow--header .prodPrice--header {
  justify-content: flex-end;
  text-align: right;
}

/* --------------------------------------------------
   Icone PNG (cartella /public/img)
-------------------------------------------------- */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* mappatura singole icone */
.icon--pin       { background-image: url("/img/pin.png"); }
.icon--new       { background-image: url("/img/new.png"); }
.icon--dots      { background-image: url("/img/dots.png"); }
.icon--searches  { background-image: url("/img/searches.png"); }
.icon--recent    { background-image: url("/img/recent.png"); }
.icon--folder    { background-image: url("/img/folder.png"); }
.icon--search    { background-image: url("/img/search_icon.png"); }
.icon--user      { background-image: url("/img/user.png"); }
.icon--category  { background-image: url("/img/category.png"); }
.icon--trash     { background-image: url("/img/trash.png"); }
.icon--help      { background-image: url("/img/help.png"); }

/* non esiste ancora edit.png: uso settings.png come placeholder */
.icon--edit      { background-image: url("/img/settings.png"); }

/* allineamenti contestuali */
.appSubHeader-btn .icon {
  margin-right: 4px;
}

.sidebar-title .icon,
.history-section-title .icon,
.history-group-title .icon,
.selectionTitle .icon {
  margin-right: 6px;
}

.history-menu-trigger .icon {
  width: 14px;
  height: 14px;
}

/* icona utente nell'header */
.userInfo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.userInfo .icon--user {
  width: 24px;
  height: 24px;
}

/* testo solo per screen reader */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* sui bottoni mobili mostriamo solo l'icona */
.appSubHeader-btnLabel {
  display: none;
}

/* le icone si allineano al centro rispetto al testo */
.icon {
  vertical-align: middle;
}

/* allinea orizzontalmente icona + testo su un'unica riga */
.btn-mini,
.sidebar-title,
.selectionTitle,
.history-section-title,
.history-group-title {
  display: inline-flex;
  align-items: center;
}

/* spaziatura orizzontale fra icona e label */
.btn-mini .icon,
.sidebar-title .icon,
.selectionTitle .icon,
.history-section-title .icon,
.history-group-title .icon {
  margin-right: 6px;
}
/* Logo su pagine login / signup / invite */
.authLogo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.authLogoLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.authLogoImg {
  display: block;
  height: 40px;
  width: auto;
}

@media (max-width: 600px) {
  .authLogoImg {
    height: 32px;
  }
}

.mainArea,
.sidebar,
.selectionPane {
  -webkit-overflow-scrolling: touch;
  /* lo scroll non “passa” al body */
  overscroll-behavior: contain;
}
