:root {
  --color-primary: #01696f;
  --color-bg: #f7f6f2;
  --color-surface: #f9f8f5;
  --color-text: #28251d;
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
}

body {
  font-family: 'Satoshi', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  min-height: 100vh;
}

* {
  box-sizing: border-box;
}

#app {
  min-height: 100vh;
}

.login-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-8);
  background:
    radial-gradient(circle at top left, rgba(1, 105, 111, 0.16), transparent 30%),
    linear-gradient(135deg, #f7f6f2 0%, #efe7da 100%);
}

.login-form {
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
  padding: 2rem;
  border-radius: 1.25rem;
  background: rgba(249, 248, 245, 0.92);
  box-shadow: var(--shadow-md);
}

.login-form label {
  display: grid;
  gap: 0.5rem;
  font-size: var(--text-sm);
}

.form-support {
  margin: 0;
  color: #625e55;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.form-message {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.form-message-error {
  color: #8c1d18;
  background: #fdebea;
  border: 1px solid #efb8b6;
}

.form-message-success {
  color: #1c6b2d;
  background: #e9f7ec;
  border: 1px solid #b9e2c1;
}

.inline-banner {
  margin-bottom: 1rem;
}

.change-password-wrapper {
  min-height: calc(100vh - 88px);
}

.login-form input,
.filters-bar input,
.filters-bar select {
  min-height: 44px;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 37, 29, 0.2);
  background: #fff;
  font: inherit;
}

.login-form button,
.filters-bar button,
.pagination button,
.products-table td button,
.error-state button,
.empty-state button,
.sort-button {
  min-height: 44px;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Header, sidebar, layout base */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-size: 2rem; }
.title { font-size: var(--text-xl); font-weight: 700; }
.user-menu { display: flex; align-items: center; gap: var(--space-4); }
.user-menu button { background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: var(--text-base); }

.sidebar {
  position: fixed;
  left: 0; top: 64px; bottom: 0;
  width: 220px;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) 0;
}
.sidebar nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar nav li { margin-bottom: var(--space-4); }
.sidebar nav a { color: var(--color-primary); text-decoration: none; font-size: var(--text-base); padding: 8px 24px; display: block; border-radius: var(--radius-md); }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--color-bg); }

.content {
  margin-left: 240px;
  padding: var(--space-8);
  min-height: 100vh;
}

/* Tabella prodotti */
.products-section { max-width: 1200px; margin: 0 auto; }
.authorizations-section {
  display: grid;
  gap: 1rem;
}
.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.auth-card {
  background: #fff;
  border-radius: 1rem;
  border: 1px solid rgba(40, 37, 29, 0.12);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
}
.auth-card h4 {
  margin: 0.5rem 0 0.25rem;
}
.auth-card-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
}
.brand-logo {
  width: 20px;
  height: 20px;
}
.brand-logo-amazon {
  filter: invert(56%) sepia(86%) saturate(950%) hue-rotate(354deg) brightness(102%) contrast(102%);
}
.brand-logo-shopify {
  filter: invert(42%) sepia(53%) saturate(547%) hue-rotate(88deg) brightness(96%) contrast(93%);
}
.auth-form {
  display: grid;
  gap: 0.7rem;
}
.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-size: var(--text-sm);
}
.shopify-status-box {
  padding: 0.75rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(40, 37, 29, 0.12);
  background: rgba(1, 105, 111, 0.06);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.auth-form input {
  min-height: 44px;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 37, 29, 0.2);
  background: #fff;
  font: inherit;
}
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  align-items: start;
}

.filters-stack {
  display: grid;
  gap: 0.85rem;
  flex: 1 1 720px;
}

.filters-bar input[type="text"] {
  flex: 1;
  min-width: 320px;
}

.advanced-filters-panel {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid rgba(40, 37, 29, 0.12);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.82);
}

.advanced-filters-header {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.advanced-filters-header strong {
  display: block;
  margin-bottom: 0.15rem;
}

.advanced-filters-header p {
  margin: 0;
  color: #6b675d;
  font-size: var(--text-sm);
}

.advanced-filters-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.advanced-filters-list {
  display: grid;
  gap: 0.75rem;
}

.advanced-filter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(150px, 1fr) minmax(180px, 1.2fr) auto;
  gap: 0.75rem;
  align-items: center;
}
.filters-bar button {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-base);
  cursor: pointer;
}
.filters-bar button[type="button"] {
  background: #eee;
  color: var(--color-text);
  border: 1px solid #ccc;
}

.results-count-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.results-toolbar-left,
.results-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.results-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(1, 105, 111, 0.12);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(40, 37, 29, 0.08);
  color: var(--color-text);
  font-size: var(--text-sm);
}

.removable-chip {
  border: 1px solid rgba(40, 37, 29, 0.1);
  cursor: pointer;
}

.removable-chip:hover {
  background: rgba(40, 37, 29, 0.14);
}

.results-meta,
.results-count {
  font-size: var(--text-sm);
  color: #6b675d;
}

.table-shell {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  min-width: 1100px;
}
.products-table th, .products-table td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid #ececec;
  vertical-align: top;
}
.products-table th {
  background: var(--color-bg);
  font-size: var(--text-sm);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}
.products-table th:last-child,
.products-table td:last-child {
  position: sticky;
  right: 0;
  background: var(--color-surface);
  box-shadow: -10px 0 16px rgba(249, 248, 245, 0.96);
}

.products-table th:last-child {
  background: var(--color-bg);
}
.products-table tr:hover {
  background: #f0f6f7;
}
.products-table tr:hover td:last-child {
  background: #f0f6f7;
}
.products-table td button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 4px 12px;
  cursor: pointer;
  font-size: var(--text-sm);
}
.ghost-button {
  min-height: 44px;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 37, 29, 0.18);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
}

.ghost-button:hover {
  background: rgba(1, 105, 111, 0.06);
}

.small-button {
  min-height: 36px;
  padding: 0.45rem 0.75rem;
  font-size: var(--text-sm);
}
.products-table td button:hover {
  background: #01484b;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.image-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 0.75rem;
  background: rgba(1, 105, 111, 0.08);
  overflow: hidden;
}

.image-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cell-empty {
  color: #9a9589;
}

.numeric-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.title-cell {
  display: inline-flex;
  align-items: start;
  gap: 0.5rem;
}

.variant-indicator {
  width: 0.7rem;
  height: 0.7rem;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--variant-color, var(--color-primary));
  flex: 0 0 auto;
}

.clamped-text {
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 360px;
  line-height: 1.45;
}

.actions-column {
  min-width: 220px;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 220px;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(40, 37, 29, 0.28);
  z-index: 40;
}

.product-drawer {
  width: min(42vw, 680px);
  height: 100vh;
  overflow-y: auto;
  background: var(--color-surface);
  box-shadow: -8px 0 24px rgba(40, 37, 29, 0.12);
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
}

.specific-panel {
  width: min(72vw, 980px);
  height: 100vh;
  overflow-y: auto;
  background: var(--color-surface);
  box-shadow: -8px 0 24px rgba(40, 37, 29, 0.12);
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
}

.drawer-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.drawer-header h3 {
  margin: 0.2rem 0 0;
  font-size: 1.4rem;
}

.drawer-eyebrow {
  margin: 0;
  color: #6b675d;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.drawer-form {
  display: grid;
  gap: 1rem;
}

.drawer-section-header h4 {
  margin: 0.2rem 0 0;
  font-size: 1.15rem;
}

.drawer-section-note {
  margin: 0.35rem 0 0;
  color: #6b675d;
  font-size: var(--text-xs);
}

.drawer-images-block {
  display: grid;
  gap: 1rem;
}

.drawer-images-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.image-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(40, 37, 29, 0.12);
  background: #fff;
}

.image-card-preview-wrap {
  min-height: 140px;
  display: grid;
  place-items: center;
  border-radius: 0.85rem;
  overflow: hidden;
  background: rgba(1, 105, 111, 0.08);
}

.image-card-preview {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.image-card-placeholder {
  color: #6b675d;
  font-size: var(--text-sm);
}

.image-card-body {
  display: grid;
  gap: 0.75rem;
}

.image-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.drawer-field {
  display: grid;
  gap: 0.45rem;
}

.drawer-field span {
  font-size: var(--text-sm);
  color: #4c483f;
}

.drawer-field input,
.drawer-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 37, 29, 0.18);
  background: #fff;
  font: inherit;
}

.drawer-field textarea {
  min-height: 120px;
  resize: vertical;
}

.drawer-field-wide {
  grid-column: 1 / -1;
}

.drawer-image-section {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: 1rem;
  background: rgba(1, 105, 111, 0.08);
  overflow: hidden;
}

.drawer-image-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.drawer-image-placeholder {
  color: #6b675d;
}

.specific-product-summary {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(1, 105, 111, 0.06);
}

.specific-product-summary h4,
.specific-product-summary p {
  margin: 0;
}

.specific-summary-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 1rem;
  background: rgba(1, 105, 111, 0.1);
}

.specific-summary-image.placeholder {
  display: grid;
  place-items: center;
  color: #6b675d;
  font-size: var(--text-sm);
}

.specific-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.specific-card {
  display: grid;
  gap: 0.75rem;
  min-height: 132px;
  padding: 0.85rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(40, 37, 29, 0.12);
  background: #fff;
  box-shadow: var(--shadow-sm);
  align-content: space-between;
}

.specific-card:hover {
  border-color: rgba(1, 105, 111, 0.2);
  box-shadow: var(--shadow-md);
}

.specific-card-actions,
.specific-actions-head,
.specific-editor-header,
.specific-editor-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.specific-card-body {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.specific-name-label {
  margin: 0;
  font-size: var(--text-xs);
  color: #6b675d;
  letter-spacing: 0.04em;
}

.specific-value-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.specific-card-actions {
  justify-content: flex-start;
  gap: 0.5rem;
  padding-top: 0.15rem;
  border-top: 1px solid rgba(40, 37, 29, 0.08);
}

.specific-card-actions .small-button {
  min-height: 32px;
  padding: 0.35rem 0.65rem;
}

.specific-card-editor {
  min-height: auto;
  padding: 0;
  overflow: hidden;
  border-color: rgba(1, 105, 111, 0.16);
  background: linear-gradient(180deg, rgba(1, 105, 111, 0.05), rgba(255, 255, 255, 0.95));
}

.specific-card-editor-new {
  grid-column: 1 / -1;
}

.specific-editor {
  display: grid;
  gap: 0.85rem;
  padding: 0.9rem;
}

.specific-editor h4 {
  margin: 0;
  font-size: 1rem;
}

.specific-editor .drawer-field span {
  font-size: var(--text-xs);
  color: #6b675d;
}

.specific-editor .drawer-field textarea {
  min-height: 90px;
}

.danger-button {
  color: #8c1d18;
  border-color: rgba(140, 29, 24, 0.2);
}

.danger-button:hover {
  background: rgba(140, 29, 24, 0.06);
}

.drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  position: sticky;
  bottom: 0;
  padding-top: 1rem;
  background: linear-gradient(180deg, rgba(249, 248, 245, 0), rgba(249, 248, 245, 0.96) 28%);
}

.empty-state {
  padding: var(--space-8);
  text-align: center;
  color: #888;
  background: #fffbe6;
  border-radius: var(--radius-md);
  margin-top: var(--space-4);
}

.error-state {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  color: #8c1d18;
  background: #fdebea;
  border: 1px solid #efb8b6;
  border-radius: var(--radius-md);
}

.skeleton-table {
  display: grid;
  gap: 0.75rem;
}

.skeleton-row {
  height: 56px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(1, 105, 111, 0.08), rgba(1, 105, 111, 0.16), rgba(1, 105, 111, 0.08));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

.pagination {
  margin: var(--space-4) 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.pagination-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: #6b675d;
  font-size: var(--text-sm);
}

.pagination select {
  min-height: 42px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 37, 29, 0.18);
  background: #fff;
  font: inherit;
}

.pagination-status {
  color: #6b675d;
  font-size: var(--text-sm);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(1, 105, 111, 0.28);
  outline-offset: 2px;
}

@media (max-width: 1024px) {
  .sidebar {
    width: 88px;
  }

  .sidebar nav a {
    padding-inline: 1rem;
    text-align: center;
  }

  .content {
    margin-left: 104px;
  }
}

@media (max-width: 768px) {
  .header {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .sidebar {
    position: static;
    width: auto;
    padding: 0 var(--space-4) var(--space-4);
    box-shadow: none;
  }

  .content {
    margin-left: 0;
    padding: 1rem;
  }

  .products-table {
    min-width: 900px;
  }

  .advanced-filter-row {
    grid-template-columns: 1fr;
  }

  .product-drawer {
    width: 100vw;
  }

  .specific-panel {
    width: 100vw;
  }

  .drawer-grid {
    grid-template-columns: 1fr;
  }

  .drawer-images-grid {
    grid-template-columns: 1fr;
  }

  .specific-product-summary {
    grid-template-columns: 1fr;
  }

  .specific-grid {
    grid-template-columns: 1fr;
  }
  .auth-grid {
    grid-template-columns: 1fr;
  }
}
