/* ==========================================================================
   ABCSeller — design system
   Palette professionale: blu notte / ardesia con colore principale teal.
   I colori di Amazon, eBay e TikTok restano quelli di marca e non si confondono col tema.
   Layout responsive: monitor grandi (≥1600), desktop (1280–1599), tablet orizzontale (1024–1279, barra a icone),
   tablet verticale (768–1023, menu a scomparsa), smartphone (<768).
   ========================================================================== */
:root {
  /* Tema scuro */
  --bg: #0b1120;
  --bg-2: #0e1628;
  --surface: #111a2e;
  --surface-2: #16223a;
  --surface-solid: #131d33;
  --surface-hover: #1a2742;
  --border: #1e2b47;
  --border-strong: #2a3a5e;
  --text: #e7ecf6;
  --text-2: #a5b1c9;
  --text-3: #6d7a97;

  --primary: #14b8a6;
  --primary-strong: #0d9488;
  --primary-rgb: 20, 184, 166;
  --primary-ink: #04201d;          /* testo su sfondo primario */
  --accent: #38bdf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --info: #38bdf8;

  --font: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-head: 'Plus Jakarta Sans', 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;

  --amazon: #ff9900;
  --ebay: #3b82f6;
  --tiktok: #fe2c55;
  --tiktok-c: #25f4ee;
  --tiktok-m: #fe2c55;
  --ebay-r: #e53238;
  --ebay-b: #0064d2;
  --ebay-y: #f5af02;
  --ebay-g: #86b817;

  --grad: linear-gradient(135deg, #0d9488 0%, #0e7490 100%);
  --tint: rgba(var(--primary-rgb), .12);
  --tint-strong: rgba(var(--primary-rgb), .2);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px -12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .65);
  --ring: 0 0 0 3px rgba(var(--primary-rgb), .28);
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar: 264px;
  --rail: 76px;
  --input-bg: #0f182b;
  --chart-grid: rgba(148, 163, 184, .1);
  --gutter: 28px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5f9; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #f2f5f9; --surface-solid: #ffffff; --surface-hover: #eef2f7;
    --border: #e2e8f0; --border-strong: #cbd5e1; --text: #0f172a; --text-2: #475569; --text-3: #8392a8;
    --primary: #0d9488; --primary-strong: #0f766e; --primary-rgb: 13, 148, 136; --primary-ink: #ffffff;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -14px rgba(15, 23, 42, .18); --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .3);
    --input-bg: #ffffff; --chart-grid: rgba(15, 23, 42, .07); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f5f9; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #f2f5f9; --surface-solid: #ffffff; --surface-hover: #eef2f7;
  --border: #e2e8f0; --border-strong: #cbd5e1; --text: #0f172a; --text-2: #475569; --text-3: #8392a8;
  --primary: #0d9488; --primary-strong: #0f766e; --primary-rgb: 13, 148, 136; --primary-ink: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -14px rgba(15, 23, 42, .18); --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .3);
  --input-bg: #ffffff; --chart-grid: rgba(15, 23, 42, .07); color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-head); letter-spacing: -.015em; margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
code { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: .9em; }
::selection { background: rgba(var(--primary-rgb), .3); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.grad { color: var(--primary); }
.ic { flex-shrink: 0; }
.hidden { display: none !important; }

/* Lo sfondo decorativo non è più usato: interfaccia pulita */
.bg-orbs { display: none; }

#app { position: relative; z-index: 1; }
.boot, .page-loading { display: grid; place-items: center; min-height: 60vh; }
.boot { min-height: 100vh; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; flex-shrink: 0; }
.danger-text { color: var(--danger); }
.backup-action { display: flex; flex-direction: column; }
.backup-action .btn-row { margin-top: auto; padding-top: 18px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 20px 14px; display: flex; flex-direction: column; gap: 16px;
  background: var(--bg-2); border-right: 1px solid var(--border); z-index: 40; transition: transform .3s cubic-bezier(.2,.8,.2,1), width .25s;
}
/* ---------- Logo animato ABCSELLER (sidebar) */
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 4px 16px; min-width: 0; border-bottom: 1px solid var(--border); }
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 46px; height: 46px; flex-shrink: 0; overflow: visible; }
.brand-mark .bm-tile { transform-box: view-box; transform-origin: 24px 24px; animation: bmPop .7s cubic-bezier(.2, 1.4, .4, 1) both, bmFloat 4.5s ease-in-out 1s infinite; }
.brand-mark .bm-a { stroke-dasharray: 44; stroke-dashoffset: 44; animation: bmDraw 1s cubic-bezier(.6, 0, .2, 1) .35s forwards; }
.brand-mark .bm-bar { stroke-dasharray: 12; stroke-dashoffset: 12; animation: bmDraw .45s ease-out 1.15s forwards; }
.brand-mark .bm-shine { transform-box: view-box; animation: bmShine 5s ease-in-out 1.6s infinite; }
.brand-mark .bm-orbit { transform-box: view-box; transform-origin: 24px 24px; animation: bmSpin 9s linear infinite; }
.brand-mark .bm-orbit circle { animation: bmPulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.brand-mark .bm-orbit circle:nth-child(2) { animation-delay: .8s; }
.brand-mark .bm-orbit circle:nth-child(3) { animation-delay: 1.6s; }
.brand-word {
  display: flex; font-family: var(--font-head); font-weight: 800; font-size: 21px; letter-spacing: .04em; line-height: 1; white-space: nowrap;
}
/* lettera: <i> entra una volta, <b> interno fa l'onda periodica (animazioni separate, nessun conflitto) */
.brand-word i { font-style: normal; display: inline-block; color: var(--text); opacity: 0; animation: bmLetter .55s cubic-bezier(.2, .9, .3, 1.2) forwards; animation-delay: calc(.45s + var(--i) * .06s); }
.brand-word i.hl { color: var(--primary); }
.brand-word b { display: inline-block; font-weight: inherit; animation: bmWave 6s ease-in-out infinite; animation-delay: calc(2.4s + var(--i) * .09s); }
.brand-sub {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 7px; padding: 5px 13px; border-radius: 999px;
  font: 700 10.5px/1 var(--font); letter-spacing: .24em; text-transform: uppercase; color: var(--primary); white-space: nowrap;
  background: var(--tint); border: 1px solid rgba(var(--primary-rgb), .35);
  opacity: 0; animation: bmRise .6s ease-out 1.25s forwards;
}
.brand-sub::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .2); animation: bmDot 2s ease-in-out infinite; }
.brand-sub::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%); animation: bmGlint 5s ease-in-out 2.6s infinite;
}
.brand:hover .bm-orbit { animation-duration: 3s; }
@keyframes bmPop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bmFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.6px); } }
@keyframes bmDraw { to { stroke-dashoffset: 0; } }
@keyframes bmShine { 0%, 70% { transform: translateX(-40px); } 100% { transform: translateX(44px); } }
@keyframes bmSpin { to { transform: rotate(360deg); } }
@keyframes bmPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
@keyframes bmLetter { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes bmWave { 0%, 8%, 100% { transform: none; text-shadow: none; } 4% { transform: translateY(-3px); text-shadow: 0 0 12px rgba(var(--primary-rgb), .7); } }
@keyframes bmRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes bmDot { 0%, 100% { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .2); } 50% { box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0); } }
@keyframes bmGlint { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); padding: 16px 12px 6px; font-weight: 600; white-space: nowrap; }
.nav-item {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s; white-space: nowrap;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { color: var(--primary); background: var(--tint); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-strong); color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; }
.user-meta strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--text-3); font-size: 11.5px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; transition: margin-left .25s; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 16px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.page { padding: 24px var(--gutter) 64px; max-width: 1760px; width: 100%; margin: 0 auto; }
.page.enter { animation: pageIn .35s cubic-bezier(.2,.8,.2,1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mobile-only { display: none !important; }
.sidebar-scrim { display: none; }

/* ---------- Bottoni */
.btn {
  --bh: 40px; position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--bh); padding: 0 18px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, box-shadow .2s, transform .15s, opacity .2s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--text-3); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible, .tab:focus-visible, .nav-item:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn.primary:hover { background: var(--primary); border-color: var(--primary); box-shadow: 0 6px 18px -8px rgba(var(--primary-rgb), .7); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.danger { background: #e11d48; color: #fff; border-color: #e11d48; }
.btn.danger:hover { background: #f43f5e; border-color: #f43f5e; }
.btn.danger-text { color: var(--danger); }
.btn.success { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn.amazon { background: #ff9900; color: #111; border-color: #ff9900; }
.btn.amazon:hover { background: #ffad33; border-color: #ffad33; }
.btn.ebay { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.ebay:hover { background: #3b82f6; border-color: #3b82f6; }
.btn.tiktok { background: #111318; color: #fff; border-color: #2a2d36; box-shadow: inset 2px 0 0 var(--tiktok-c), inset -2px 0 0 var(--tiktok-m); }
.btn.tiktok:hover { background: #1b1e26; border-color: #3a3e4a; }
.btn.sm { --bh: 34px; padding: 0 13px; font-size: 13px; }
.btn.xs { --bh: 28px; padding: 0 10px; font-size: 12px; gap: 5px; border-radius: 8px; }
.btn.lg { --bh: 48px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.ghost.busy::after, .btn:not(.primary):not(.danger):not(.success):not(.ebay):not(.tiktok).busy::after { border-color: var(--border-strong); border-top-color: var(--primary); }
.icon-btn {
  position: relative; overflow: hidden; width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .25); transform: scale(0); animation: ripple .6s ease-out; pointer-events: none; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Card / griglie */
.card, .glass {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0;
}
.card + .card { margin-top: 20px; }
/* Card affiancate in una griglia: stessa altezza per riga, nessuno sfalsamento, contenuto in colonna
   con le azioni finali allineate in basso e gli stati vuoti centrati */
.grid > .card { margin-top: 0; display: flex; flex-direction: column; }
/* Guida laterale accanto a una colonna di più card (eBay, TikTok): resta in vista invece di allungarsi a vuoto */
.grid.main-side > div:not(.card) + .card.help { align-self: start; position: sticky; top: 88px; }
.grid > .card > :last-child.btn-row, .grid > .card > a.btn.block:last-child { margin-top: auto; }
.grid > .card > .btn-row.mt:last-child { padding-top: 20px; }
/* Pulsanti finali dei moduli (seguiti al massimo dall'esito del test) allineati in fondo alla card */
.grid > .card > .btn-row.mt:nth-last-child(2) { margin-top: auto; padding-top: 20px; }
.form > .btn.sm { align-self: flex-start; }
.info-bar { background: var(--surface); border-radius: var(--radius); padding: 16px 22px; box-shadow: var(--shadow); }
.card-foot { margin-top: auto; padding-top: 16px; }
.card > .card-foot { border-top: 1px solid var(--border); }
.grid > .card > .card-head + .card-foot, .card-foot:first-child { border-top: 0; }
.grid > .card > .empty { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.grid > .card > .card-head + .chart-box { flex-shrink: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head > div { min-width: 0; }
.card-head h3 { font-size: 16px; display: flex; align-items: center; gap: 10px; }
.card-head p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.grid { display: grid; gap: 20px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.mp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mt { margin-top: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 30px 0 14px; flex-wrap: wrap; }
.section-title h2 { font-size: 18px; }
.section-title p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }

/* KPI */
.kpi { position: relative; transition: border-color .2s; }
.kpi:hover { border-color: var(--border-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--primary); background: var(--tint); flex-shrink: 0; }
.kpi-ic.amz { color: #ff9900; background: rgba(255, 153, 0, .14); }
.kpi-ic.eb { color: #3b82f6; background: rgba(59, 130, 246, .14); }
.kpi-ic.ok { color: var(--success); background: rgba(34, 197, 94, .14); }
.kpi-ic.tt { color: var(--tiktok); background: rgba(254, 44, 85, .12); }
.kpi-value { font-family: var(--font-head); font-size: 26px; line-height: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.txt { font-size: 20px; }
.kpi .kpi-sub { margin-top: auto; padding-top: 6px; }
.kpi-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-weight: 600; font-size: 12px; }
.delta.up { color: var(--success); background: rgba(34, 197, 94, .12); }
.delta.down { color: var(--danger); background: rgba(244, 63, 94, .12); }
.delta.flat { color: var(--text-3); background: var(--surface-2); }

/* Schede marketplace della dashboard */
.mp-card { display: flex; flex-direction: column; }
.mp-card.amazon { --mp: #ff9900; }
.mp-card.ebay { --mp: #3b82f6; }
.mp-card.tiktok { --mp: #fe2c55; }
.mp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.mp-head .grow { flex: 1; min-width: 0; }
.mp-head h3 { font-size: 16px; }
.mp-head small { color: var(--text-3); font-size: 12px; }
.mp-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.mp-stat { padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.mp-stat small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-stat small { display: block; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.mp-stat strong { display: block; font-family: var(--font-head); font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-stat .delta { margin-top: 4px; }
.mp-listings { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
/* Area grafico: identica in tutte le schede marketplace (grafico, nessuna vendita o non collegato) */
.mp-body { height: 262px; display: flex; flex-direction: column; margin-bottom: 14px; }
.mp-body .chart-box { flex: 1; height: auto; min-height: 0; }
.mp-off { flex: 1; display: grid; place-items: center; text-align: center; padding: 10px; color: var(--text-2); border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.mp-off .empty-ic { margin-bottom: 10px; }
.mp-stat strong.na { color: var(--text-3); }
.mp-stat .delta.ph { visibility: hidden; } /* segnaposto: stessa altezza delle statistiche reali */
.mp-off p { margin: 8px 0 14px; font-size: 13.5px; }

/* ---------- Form */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.col-12 { grid-column: span 12; } .col-10 { grid-column: span 10; } .col-9 { grid-column: span 9; } .col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; } .col-6 { grid-column: span 6; } .col-5 { grid-column: span 5; } .col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.field small.hint { color: var(--text-3); font-size: 12px; font-weight: 500; }
.counter { font-weight: 500; font-size: 11.5px; color: var(--text-3); }
.counter.over { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--input-bg);
  color: var(--text); font: 500 14px var(--font); transition: border-color .15s, box-shadow .15s; outline: none;
}
textarea.input { height: auto; min-height: 110px; padding: 11px 14px; resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input.lg { height: 48px; font-size: 15px; border-radius: 12px; }
.input.invalid { border-color: var(--danger); }
.input[disabled], .input[readonly] { opacity: .75; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238392a8' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
select.input option { background: var(--surface-solid); color: var(--text); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 90px; }
.input-addon { position: absolute; right: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--surface-2); color: var(--text-2); font: 600 12px var(--font); cursor: pointer; }
.input-addon:hover { color: var(--text); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-icon .input { padding-left: 40px; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .25s cubic-bezier(.2,.8,.2,1); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--primary-strong); }
.switch input:checked + .track::after { transform: translateX(18px); }
.checkbox { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary-strong); }

/* Chip / tag */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 13px; font-weight: 500; }
.chip button { border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 0; display: grid; place-items: center; }
.chip button:hover { color: var(--danger); }
.chip-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-2); font: 600 13px var(--font); cursor: pointer; transition: all .15s; }
.chip-btn:hover { border-color: var(--primary); color: var(--text); }
.chip-btn.on { border-style: solid; background: var(--tint); color: var(--primary); border-color: rgba(var(--primary-rgb), .5); }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { color: var(--success); background: rgba(34, 197, 94, .12); }
.badge.warning { color: var(--warning); background: rgba(245, 158, 11, .13); }
.badge.danger { color: var(--danger); background: rgba(244, 63, 94, .12); }
.badge.info { color: var(--info); background: rgba(56, 189, 248, .12); }
.badge.muted { color: var(--text-3); background: var(--surface-2); }
.badge.plain::before { display: none; }

/* Marketplace logo */
/* Loghi ufficiali dei marketplace: icona quadrata arrotondata con leggero rilievo */
.brand-logo {
  display: inline-block; flex-shrink: 0; vertical-align: middle; border-radius: 22%; object-fit: contain; background: transparent;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .22), 0 3px 8px -3px rgba(15, 23, 42, .25), 0 0 0 1px rgba(15, 23, 42, .07);
  image-rendering: auto; user-select: none;
}
small .brand-logo, .badge .brand-logo { vertical-align: -4px; margin-right: 2px; box-shadow: 0 0 0 1px rgba(15, 23, 42, .08); }
h3 .brand-logo, h4 .brand-logo { margin-right: 2px; }
.segmented .brand-logo { box-shadow: 0 0 0 1px rgba(15, 23, 42, .1); }

/* Alert */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; border: 1px solid; }
.alert.danger { color: #fda4af; background: rgba(244, 63, 94, .08); border-color: rgba(244, 63, 94, .25); }
.alert.warning { color: #fcd34d; background: rgba(245, 158, 11, .08); border-color: rgba(245, 158, 11, .25); }
.alert.info { color: #7dd3fc; background: rgba(56, 189, 248, .08); border-color: rgba(56, 189, 248, .25); }
.alert.success { color: #86efac; background: rgba(34, 197, 94, .08); border-color: rgba(34, 197, 94, .25); }
:root[data-theme="light"] .alert.danger { color: #be123c; } :root[data-theme="light"] .alert.warning { color: #b45309; }
:root[data-theme="light"] .alert.info { color: #0369a1; } :root[data-theme="light"] .alert.success { color: #15803d; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .alert.danger { color: #be123c; } :root:not([data-theme="dark"]) .alert.warning { color: #b45309; }
  :root:not([data-theme="dark"]) .alert.info { color: #0369a1; } :root:not([data-theme="dark"]) .alert.success { color: #15803d; }
}
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Tabelle */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.prod-cell { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: #fff; border: 1px solid var(--border); flex-shrink: 0; }
.thumb.ph { display: grid; place-items: center; color: var(--text-3); background: var(--surface-2); }
.prod-cell strong { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-cell small { color: var(--text-3); font-size: 12px; }
.mp-actions { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.mp-row { display: flex; align-items: center; gap: 8px; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.toolbar .input-icon { flex: 1; min-width: 220px; max-width: 420px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); gap: 2px; max-width: 100%; overflow-x: auto; }
.segmented button { position: relative; overflow: hidden; border: 0; background: transparent; color: var(--text-2); padding: 7px 14px; border-radius: 8px; font: 600 13px var(--font); cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--primary-strong); color: #fff; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; color: var(--text-3); font-size: 13px; flex-wrap: wrap; }
.pager-pages { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: center; gap: 4px; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font: 600 13px var(--font); font-variant-numeric: tabular-nums; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.page-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.page-btn.on { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; cursor: default; }
.page-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.page-gap { width: 28px; text-align: center; color: var(--text-3); user-select: none; }
@media (max-width: 767px) {
  .pager { justify-content: center; }
  .pager-info { order: 1; width: 100%; text-align: center; }
  .pager-pages { order: 2; flex-basis: 100%; }
  .pager-nav { order: 3; }
}

/* Tabs */
/* I tab vanno a capo: tutti sempre visibili, nessuno nascosto da scorrimento orizzontale */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); width: fit-content; max-width: 100%; margin-bottom: 22px; }
.tab { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 13.5px; white-space: nowrap; transition: all .15s; cursor: pointer; border: 0; background: transparent; }
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab.active { background: var(--primary-strong); color: #fff; }

/* Empty */
.empty { text-align: center; padding: 44px 20px; }
.empty-ic { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--tint); color: var(--primary); }
.empty h3 { font-size: 17px; margin-bottom: 6px; }
.empty p { color: var(--text-2); max-width: 520px; margin: 0 auto 18px; }

/* Toast */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-weight: 500; max-width: 420px; transform: translateX(120%); opacity: 0; transition: all .3s cubic-bezier(.2,.8,.2,1); }
.toast.show { transform: none; opacity: 1; }
.toast.success .ic { color: var(--success); } .toast.error .ic { color: var(--danger); } .toast.info .ic { color: var(--info); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(2, 6, 18, .6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .2s; }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(12px) scale(.99); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.modal-backdrop.show .modal { transform: none; }
.modal.sm { max-width: 440px; } .modal.md { max-width: 620px; } .modal.lg { max-width: 920px; } .modal.xl { max-width: 1200px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- Login */
.auth-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; min-height: 100dvh; }
.auth-side { display: flex; align-items: center; padding: 60px; background: var(--bg-2); border-right: 1px solid var(--border); }
.auth-hero { max-width: 540px; }
.auth-hero img { border-radius: 14px; margin-bottom: 26px; }
.auth-hero h1 { font-size: clamp(32px, 3.6vw, 48px); line-height: 1.08; font-weight: 800; margin-bottom: 16px; }
.auth-hero p { color: var(--text-2); font-size: 16.5px; margin-bottom: 24px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-weight: 500; }
.auth-points .ic { color: var(--primary); }
.auth-panel { display: grid; place-items: center; padding: 30px; }
.auth-card { width: 100%; max-width: 440px; padding: 32px; border-radius: 20px; animation: pageIn .4s cubic-bezier(.2,.8,.2,1); }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h2 { font-size: 22px; margin: 14px 0 6px; }
.auth-badge { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center; background: var(--tint); color: var(--primary); }
.otp { display: flex; gap: 10px; justify-content: center; }
.otp-digit { width: 48px; height: 58px; text-align: center; font: 700 22px var(--font-head); border-radius: 12px; border: 1px solid var(--border-strong); background: var(--input-bg); color: var(--text); outline: none; transition: all .15s; }
.otp-digit:focus { border-color: var(--primary); box-shadow: var(--ring); }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.steps-list { padding-left: 20px; color: var(--text-2); margin: 0 0 18px; display: grid; gap: 6px; }
.qr-box { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 14px; width: fit-content; margin: 0 auto 14px; border: 1px solid var(--border); }
.secret-key { text-align: center; margin-bottom: 18px; }
.secret-key small { display: block; color: var(--text-3); margin-bottom: 4px; }
.secret-key code { font-size: 15px; letter-spacing: .08em; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); user-select: all; word-break: break-all; }

/* ---------- Editor prodotto */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.editor-side { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 18px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 14px; padding: 28px; text-align: center; cursor: pointer; transition: all .2s; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--tint); }
.dropzone .ic { color: var(--primary); }
.dropzone h4 { margin: 10px 0 4px; font-size: 15.5px; }
.dropzone p { margin: 0; color: var(--text-3); font-size: 13px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.img-tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #fff; cursor: grab; transition: box-shadow .2s; }
.img-tile:hover { box-shadow: var(--shadow); }
.img-tile.dragging { opacity: .4; }
.img-tile.over { outline: 2px solid var(--primary); outline-offset: 2px; }
.img-tile img { width: 100%; height: 100%; object-fit: contain; }
.img-tile .tag { position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--primary-strong); color: #fff; }
.img-tile .tag.warn { background: var(--warning); color: #111; left: auto; right: 8px; top: auto; bottom: 8px; }
.img-tile .tile-actions { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.img-tile:hover .tile-actions, .img-tile:focus-within .tile-actions { opacity: 1; }
.img-tile .tile-actions .icon-btn { width: 30px; height: 30px; background: rgba(10,15,30,.78); color: #fff; border-color: transparent; }
.img-tile .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.img-tile select { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 28px; font-size: 11.5px; border-radius: 8px; padding: 0 8px; background: rgba(10,15,30,.88); color: #fff; border: 0; }
.img-counter { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .4s; }
.variants-table input.input { height: 36px; border-radius: 8px; padding: 0 10px; font-size: 13px; min-width: 90px; }
.variants-table td { padding: 8px 6px; }
.attr-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 10px; align-items: center; }
.attr-list { display: flex; flex-direction: column; gap: 10px; }
.compliance-box h4 { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; }
.compliance-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
.compliance-list li { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); }
.compliance-list li .ic { margin-top: 2px; }
.compliance-list li.err .ic { color: var(--danger); } .compliance-list li.warn .ic { color: var(--warning); } .compliance-list li.ok .ic { color: var(--success); }
.score-ring { --v: 0; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c, var(--success)) calc(var(--v) * 1%), var(--surface-2) 0); position: relative; flex-shrink: 0; }
.score-ring::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface-solid); }
.score-ring b { position: relative; z-index: 1; font-family: var(--font-head); font-size: 15px; }
.mp-panel { display: flex; align-items: center; gap: 14px; padding: 13px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.mp-panel .grow { flex: 1; min-width: 0; }
.suggest { position: relative; }
.suggest-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; max-height: 300px; overflow-y: auto; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); padding: 6px; }
.suggest-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); padding: 9px 11px; border-radius: 8px; cursor: pointer; font: 500 13.5px var(--font); }
.suggest-list button:hover { background: var(--surface-hover); }
.suggest-list button small { display: block; color: var(--text-3); font-size: 12px; }
.sticky-actions { position: sticky; bottom: 16px; z-index: 20; display: flex; justify-content: flex-end; gap: 10px; padding: 10px; margin-top: 22px; border-radius: 14px; background: color-mix(in srgb, var(--surface-solid) 92%, transparent); border: 1px solid var(--border-strong); backdrop-filter: blur(10px); box-shadow: var(--shadow-lg); flex-wrap: wrap; }

/* ---------- Analisi mercato */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item { display: grid; grid-template-columns: 40px 60px minmax(0, 1fr) repeat(4, minmax(86px, 120px)) 120px; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); transition: border-color .15s, background .15s; cursor: pointer; }
.rank-item:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.rank-item .metric-row { display: contents; }
.rank-pos { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; background: var(--surface-2); }
.rank-item:nth-child(1) .rank-pos { background: #f59e0b; color: #111; }
.rank-item:nth-child(2) .rank-pos { background: #94a3b8; color: #111; }
.rank-item:nth-child(3) .rank-pos { background: #c2410c; color: #fff; }
.rank-img { width: 60px; height: 60px; border-radius: 10px; object-fit: contain; background: #fff; }
.rank-title { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rank-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.metric small { display: block; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.metric strong { font-family: var(--font-head); font-size: 15.5px; font-variant-numeric: tabular-nums; }
.metric strong.hot { color: var(--success); }
.spark { width: 120px; height: 40px; }
.tracker-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.tracker-pill { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; transition: all .15s; color: var(--text); font-size: 13.5px; }
.tracker-pill:hover { border-color: var(--primary); }
.tracker-pill.on { background: var(--tint); color: var(--primary); border-color: rgba(var(--primary-rgb), .5); }
.tracker-pill .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chart-box { position: relative; height: 300px; }
.chart-box.md { height: 220px; }
.chart-box.sm { height: 200px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.mini-item:last-child { border-bottom: 0; }
.mini-item img { width: 42px; height: 42px; border-radius: 10px; object-fit: contain; background: #fff; flex-shrink: 0; }
.mini-item .grow { flex: 1; min-width: 0; }
.mini-item .grow strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .grow small { color: var(--text-3); font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.status-dot.ko { background: var(--danger); box-shadow: 0 0 0 3px rgba(244,63,94,.18); }
.status-dot.off { background: var(--text-3); }
.hero-banner { position: relative; overflow: hidden; padding: 20px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hero-banner h2 { font-size: 18px; }
.hero-banner p { margin: 4px 0 0; color: var(--text-2); }

/* ---------- Galleria foto */
.lightbox {
  position: fixed; inset: 0; z-index: 300; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-columns: minmax(0, 1fr); gap: 10px;
  padding: 14px 18px 18px; background: rgba(3, 7, 18, .93); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #e7ecf6; animation: lbIn .18s ease-out;
}
.lightbox.closing { animation: lbOut .16s ease-in forwards; }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbOut { to { opacity: 0; } }
.lb-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lb-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-count { font-variant-numeric: tabular-nums; color: #a5b1c9; font-size: 13.5px; }
.lb-btn, .lb-nav {
  display: inline-grid; place-items: center; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .08); color: #fff;
  cursor: pointer; transition: background .15s, transform .15s;
}
.lb-btn { width: 40px; height: 40px; border-radius: 10px; }
.lb-btn:hover, .lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-btn:focus-visible, .lb-nav:focus-visible, .lb-thumb:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.lb-stage { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 0; }
.lb-nav { width: 52px; height: 52px; border-radius: 50%; }
.lb-nav:active { transform: scale(.94); }
.lb-frame { position: relative; height: 100%; min-height: 0; display: grid; place-items: center; overflow: hidden; border-radius: 14px; }
.lb-img {
  max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; background: #fff; user-select: none;
  cursor: zoom-in; transition: transform .25s ease, opacity .2s; box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .7);
}
.lb-img.loading { opacity: .25; }
.lb-frame.zoomed .lb-img { transform: scale(2.4); cursor: zoom-out; border-radius: 0; }
.lb-spin { position: absolute; border-color: rgba(255, 255, 255, .25); border-top-color: #fff; }
.lb-caption { text-align: center; color: #a5b1c9; font-size: 13.5px; min-height: 18px; }
.lb-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; scrollbar-width: thin; min-width: 0; }
.lb-thumbs::before, .lb-thumbs::after { content: ''; margin: auto; } /* centrate se entrano, scorrevoli se sono tante */
.lb-thumb { flex: 0 0 auto; width: 64px; height: 64px; padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #fff; cursor: pointer; opacity: .55; transition: opacity .15s, border-color .15s; }
.lb-thumb img { width: 100%; height: 100%; object-fit: contain; }
.lb-thumb:hover { opacity: .9; }
.lb-thumb.on { opacity: 1; border-color: var(--primary); }
@media (max-width: 767px) {
  .lightbox { padding: 10px 8px 12px; }
  .lb-stage { grid-template-columns: minmax(0, 1fr); }
  .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 42px; height: 42px; background: rgba(3, 7, 18, .55); }
  .lb-nav.prev { left: 6px; } .lb-nav.next { right: 6px; }
  .lb-nav:active { transform: translateY(-50%) scale(.94); }
  .lb-thumb { width: 52px; height: 52px; }
}

/* Foto cliccabili (lista prodotti ed editor) */
.thumb-btn { position: relative; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 10px; flex-shrink: 0; }
.thumb-btn .thumb { display: block; transition: transform .15s, box-shadow .15s; }
.thumb-btn:hover .thumb { transform: scale(1.06); box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .45); }
.thumb-btn .thumb-n { position: absolute; right: -6px; bottom: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; font: 700 11px var(--font); color: #fff; background: var(--primary-strong); border: 2px solid var(--surface); }
.img-tile img { cursor: zoom-in; }
button.badge-btn { border: 0; cursor: zoom-in; font-family: inherit; }
button.badge-btn:hover { filter: brightness(1.15); }
.prod-cell-wrap { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.prod-cell-wrap .prod-cell { min-width: 0; }

/* Filtro categorie (lista prodotti): una riga di pulsanti accanto agli stati, scorrevole se sono tanti */
/* riga dedicata sotto ricerca e stati: tutte le categorie visibili, vanno a capo */
.cat-filter { order: 10; flex: 1 1 100%; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0; }
.cat-filter .cat-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-right: 4px; display: inline-flex; align-items: center; gap: 5px; }
.cat-chip.more { border-style: dashed; color: var(--primary); }
.cat-filter:empty { display: none; }
.cat-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 600 13px var(--font); white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.cat-chip span { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); font-variant-numeric: tabular-nums; }
.cat-chip:hover { border-color: var(--primary); color: var(--text); }
.cat-chip.on { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.cat-chip.on span { background: rgba(255, 255, 255, .22); color: #fff; }
.cat-chip.none { font-style: italic; }
.cat-chip:focus-visible { outline: none; box-shadow: var(--ring); }

/* Scelta categoria nell'editor: menu + campo per una nuova categoria */
.cat-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pick > * { flex: 1 1 260px; min-width: 0; }

/* Colonna prodotto: nome, SKU, categoria, varianti */
.prod-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prod-link strong { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-link:hover strong { color: var(--primary); }
.prod-info > small { color: var(--text-3); font-size: 12px; }
.prod-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.prod-tags:empty { display: none; }
.tag-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 600 11.5px var(--font); color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.tag-btn:hover { color: var(--primary); border-color: rgba(var(--primary-rgb), .5); }
.var-toggle { color: var(--info); background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .3); }
.var-toggle .chev { display: inline-grid; transition: transform .2s; }
.var-toggle.on { color: #fff; background: var(--primary-strong); border-color: var(--primary-strong); }
.var-toggle.on .chev { transform: rotate(90deg); }
.var-sum { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; font-size: 12px; color: var(--text-2); }
.var-attr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.var-attr b { color: var(--text-3); font-weight: 600; }
.var-attr em { color: var(--text-3); font-style: normal; font-weight: 600; }
/* ---------- Griglia varianti sotto ogni prodotto */
.var-switch { font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.table tbody tr.var-row:hover { background: transparent; }
.table tr:has(+ .var-row) > td { border-bottom-color: transparent; }
.var-row > td { padding: 0 0 16px; }
/* fermo a sinistra e largo quanto l'area visibile della tabella (--list-w, meno i margini interni di 22px per lato):
   si adatta a ogni schermo anche quando le colonne dei marketplace scorrono in orizzontale */
.var-panel {
  --indent: 56px;
  position: sticky; left: 22px; margin-left: var(--indent);
  width: calc(var(--list-w, 100vw) - 44px - var(--indent)); max-width: calc(100% - var(--indent));
  padding: 12px 14px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
}
.vp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 10px; font-size: 12.5px; }
.vp-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); }
.vp-meta { color: var(--text-3); }
.vp-out { color: var(--danger); font-weight: 600; }
.vp-more { margin-left: auto; color: var(--primary); font-weight: 600; }
.vstock { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; color: var(--success); background: rgba(34, 197, 94, .12); }
.vstock.low { color: var(--warning); background: rgba(245, 158, 11, .14); }
.vstock.out { color: var(--danger); background: rgba(244, 63, 94, .12); }

/* schede (1 o 3+ attributi): colonne automatiche in base alla larghezza */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 2px; }
.vcard { display: flex; gap: 10px; align-items: center; min-width: 0; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s; }
.vcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.vcard.out { opacity: .7; }
.vimg { width: 44px; height: 44px; flex-shrink: 0; border-radius: 9px; object-fit: contain; background: #fff; border: 1px solid var(--border); cursor: zoom-in; }
.vimg.ph { display: grid; place-items: center; color: var(--text-3); background: var(--surface-2); cursor: default; }
.vc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.vc-attrs { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.vc-attrs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.vc-attrs em { font-style: normal; font-weight: 500; color: var(--text-3); margin-right: 2px; }
.vc-body code { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vc-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 6px; }
.vc-foot b { font-size: 13px; font-variant-numeric: tabular-nums; }

/* matrice (2 attributi, es. Colore × Misura) */
.vmatrix-wrap { overflow: auto; max-height: 460px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.vmatrix { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 12.5px; }
.vmatrix th { text-transform: none; letter-spacing: 0; }
.vmatrix th, .vmatrix td { padding: 7px 12px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; white-space: nowrap; }
.vmatrix tr > :last-child { border-right: 0; }
.vmatrix tbody tr:last-child > * { border-bottom: 0; }
.vmatrix thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: 12px; }
.vmatrix tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--text); }
.vmatrix tbody th img { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; background: #fff; border: 1px solid var(--border); vertical-align: middle; margin-right: 8px; cursor: zoom-in; }
.vmatrix th.corner { left: 0; z-index: 2; text-align: left; color: var(--text-3); font-weight: 600; }
.vmatrix th.corner span { opacity: .6; margin: 0 2px; }
.vmatrix td { min-width: 92px; }
.vmatrix td b { display: block; font-variant-numeric: tabular-nums; margin-bottom: 3px; }
.vmatrix td.out b { color: var(--text-3); text-decoration: line-through; }
.vmatrix td.na { color: var(--text-3); background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 8px); }
.vmatrix tbody tr:hover td:not(.na) { background: var(--surface-hover); }
@media (max-width: 767px) {
  .var-row > td { padding: 0 0 12px; }
  .var-panel { --indent: 0px; left: 16px; width: calc(var(--list-w, 100vw) - 32px); max-width: 100%; padding: 10px; }
  .vgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .vp-more { margin-left: 0; }
}

/* Prezzi e commissioni per marketplace (lista prodotti) */
.mp-actions { width: 186px; min-width: 186px; }
.mp-actions .mp-row { flex-wrap: wrap; gap: 6px; }
.mp-actions .btn.xs { width: 100%; }
.fee-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.markup-btn {
  display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 8px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 700 11.5px var(--font); color: var(--primary); background: var(--tint); border: 1px dashed rgba(var(--primary-rgb), .55); transition: all .15s;
}
.markup-btn:hover { background: var(--tint-strong); border-style: solid; }
.markup-btn.on { color: #fff; background: var(--primary-strong); border: 1px solid var(--primary-strong); }
.markup-btn.on:hover { background: #e11d48; border-color: #e11d48; }
.markup-btn.on:hover .mk-on { display: none; } .markup-btn .mk-off { display: none; } .markup-btn.on:hover .mk-off { display: inline; }
.markup-btn[disabled] { opacity: .5; cursor: wait; }
.pub-price { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--success); background: rgba(34, 197, 94, .12); white-space: nowrap; }
.pub-price::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.mp-price { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.mp-price b { color: var(--text); font-variant-numeric: tabular-nums; }
.mp-price s { color: var(--text-3); margin-right: 3px; }

/* ---------- Guide di collegamento (Impostazioni) */
.grid.guide-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.grid.guide-layout > .card { display: block; }
.guide .progress { margin-top: 2px; }
.guide-steps { list-style: none; margin: 18px 0 0; padding: 0; position: relative; }
.guide-step { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding-bottom: 20px; }
.guide-step:not(:last-child)::before { content: ''; position: absolute; left: 16px; top: 36px; bottom: 4px; width: 2px; background: var(--border); }
.guide-step.ok:not(:last-child)::before { background: rgba(34, 197, 94, .45); }
.gs-num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 800 14px var(--font-head);
  background: var(--surface-2); color: var(--text-2); border: 2px solid var(--border-strong); position: relative; z-index: 1;
}
.guide-step.ok .gs-num { background: var(--success); border-color: var(--success); color: #fff; }
.guide-step.todo .gs-num { border-color: var(--warning); color: var(--warning); }
.guide-step.next .gs-num { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; box-shadow: 0 0 0 5px rgba(var(--primary-rgb), .18); }
.gs-body { min-width: 0; padding-top: 5px; }
.gs-body h4 { font-size: 14.5px; margin: 0 0 6px; }
.guide-step.ok .gs-body h4 { color: var(--text-2); }
.gs-text { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.gs-text p { margin: 0 0 8px; }
.gs-text ul, .gs-text ol { margin: 0 0 8px; padding-left: 18px; }
.gs-text li { margin-bottom: 3px; }
.gs-text code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.gs-body .code-box { margin: 6px 0 8px; }
.gs-actions { gap: 6px; margin: 8px 0 6px; }
.gs-check { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 4px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.gs-check.ok { color: var(--success); background: rgba(34, 197, 94, .1); }
.gs-check.todo { color: var(--warning); background: rgba(245, 158, 11, .12); }
.gs-check.ext { color: var(--text-3); background: var(--surface-2); font-weight: 500; }
@keyframes fieldFlash { 0%, 100% { box-shadow: none; } 30%, 70% { box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .45); } }
.flash { animation: fieldFlash 1.5s ease-in-out; border-radius: 10px; }
@media (max-width: 1180px) {
  .grid.guide-layout { grid-template-columns: 1fr; }
  .grid.guide-layout > .guide { order: -1; } /* su schermi stretti la guida viene prima del modulo */
}

/* Import */
.steps { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text-3); font-weight: 600; font-size: 13.5px; }
.step b { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-size: 13px; }
.step.on { color: var(--text); border-color: rgba(var(--primary-rgb), .5); }
.step.on b { background: var(--primary-strong); color: #fff; }
.step.done b { background: var(--success); color: #fff; }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1.2fr) 90px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.map-row:last-child { border-bottom: 0; }
.map-row .head { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row .sample { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conf { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.conf i { display: block; height: 100%; border-radius: inherit; }
.import-item { padding: 13px 15px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 10px; }
.import-item summary { cursor: pointer; display: flex; align-items: center; gap: 12px; list-style: none; }
.import-item summary::-webkit-details-marker { display: none; }
.import-item .grow { flex: 1; min-width: 0; }
.import-item ul { margin: 10px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.code-box { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; overflow-x: auto; }
.code-box code { flex: 1; white-space: nowrap; }
.help { font-size: 13px; color: var(--text-2); }
.help ol, .help ul { padding-left: 20px; margin: 8px 0; }
.help li { margin-bottom: 4px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Monitor grandi e 4K: più spazio e testo leggermente più grande */
@media (min-width: 1600px) {
  :root { --gutter: 36px; --sidebar: 280px; }
  body { font-size: 15px; }
  .grid { gap: 24px; }
  .chart-box { height: 340px; }
  .chart-box.md { height: 240px; }
  .kpi-value { font-size: 28px; }
}
@media (min-width: 2200px) {
  body { font-size: 16px; }
  .page { max-width: 2100px; }
  .chart-box { height: 400px; }
  .chart-box.md { height: 280px; }
}

/* Desktop piccoli */
@media (max-width: 1440px) {
  .rank-item { grid-template-columns: 38px 56px minmax(0, 1fr) repeat(3, minmax(80px, 110px)); }
  .rank-item .spark-cell { display: none; }
}

/* Tablet orizzontale e laptop piccoli: barra laterale compatta a icone */
@media (max-width: 1279px) and (min-width: 1024px) {
  :root { --gutter: 22px; }
  .sidebar { width: var(--rail); padding: 18px 10px; }
  .main { margin-left: var(--rail); }
  .brand { justify-content: center; padding: 4px 0 12px; }
  .brand-word, .brand-sub, .nav-section, .nav-item span, .user-meta { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item.active::before { top: 10px; bottom: 10px; }
  .user-card { flex-direction: column; padding: 8px 4px; background: transparent; border: 0; }
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.mp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .mp-stats { gap: 8px; }
  .mp-stat strong { font-size: 17px; }
  .editor { grid-template-columns: minmax(0, 1fr) 300px; }
}

/* Fino a 1180: griglie su meno colonne */
@media (max-width: 1180px) {
  .grid.main-side { grid-template-columns: 1fr; }
}

/* Tablet verticale: menu a scomparsa, due colonne */
@media (max-width: 1023px) {
  :root { --gutter: 20px; }
  .sidebar { width: var(--sidebar); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(2,6,18,.5); z-index: 35; }
  .main { margin-left: 0; }
  .mobile-only { display: inline-grid !important; }
  /* Righe sempre complete: nessuna card isolata con uno spazio vuoto accanto */
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.mp-grid { grid-template-columns: 1fr; }
  .grid.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .topbar { padding: 14px var(--gutter); }
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-side > .card + .card { margin-top: 0; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .rank-item { grid-template-columns: 34px 52px minmax(0, 1fr); }
  .rank-item .metric-row { grid-column: 1 / -1; display: flex; gap: 18px; flex-wrap: wrap; padding-left: 4px; }
  .form-grid > .col-3 { grid-column: span 6; }
  .form-grid > .col-8 { grid-column: span 12; }
  .modal.lg, .modal.xl { max-width: 100%; }
}

/* Tablet verticale stretto e smartphone grandi */
@media (max-width: 860px) {
  .grid.k3, .grid.k2, .grid.mp-grid { grid-template-columns: 1fr; }
  .editor-side { grid-template-columns: 1fr; }
  .form-grid > [class*="col-"] { grid-column: span 12; }
  .map-row { grid-template-columns: 1fr; gap: 6px; }
  .map-row > .arrow { display: none; }
  .hide-mobile { display: none !important; }
}

/* Smartphone */
@media (max-width: 767px) {
  :root { --gutter: 14px; }
  .topbar h1 { font-size: 17px; }
  .page { padding: 16px var(--gutter) 48px; }
  .card { padding: 16px; border-radius: 14px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .card-head { margin-bottom: 14px; }
  .kpi-value { font-size: 23px; }
  .chart-box { height: 240px; }
  .chart-box.md, .chart-box.sm { height: 190px; }
  .toolbar { gap: 8px; }
  .toolbar .input-icon { min-width: 100%; max-width: 100%; }
  .tabs { width: 100%; }
  .sticky-actions { bottom: 10px; }
  .sticky-actions .btn { flex: 1; }
  #toasts { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .toast { max-width: none; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh; }
}
@media (max-width: 560px) {
  .grid.k4 { grid-template-columns: 1fr; }
  .mp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .otp { gap: 6px; }
  .otp-digit { width: 42px; height: 52px; font-size: 20px; }
  .auth-panel { padding: 16px; }
  .auth-card { padding: 22px; }
  .attr-row { grid-template-columns: 1fr auto; }
  .attr-row > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 380px) {
  .grid.k4 { gap: 12px; }
  .segmented button { padding: 7px 10px; }
}

/* Dispositivi touch: azioni sulle foto sempre visibili (non esiste l'hover) */
@media (hover: none) {
  .img-tile .tile-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
