/* PriceBot 3.0 Pro — Architettura UI/UX ad alta densità (UI/UX Agent Skill System) */

:root, :root[data-theme="dark"] {
  --bg: #070a13;
  --bg-glow-1: rgba(16, 185, 129, .06);
  --bg-glow-2: rgba(59, 130, 246, .07);
  --topbar-bg: rgba(13, 19, 32, .92);
  --sidebar-bg: #0a0f1b;
  --surface: #0f1726;
  --surface-2: #162033;
  --surface-hover: #1c2a42;
  --line: #1c293d;
  --line-strong: #2c3e5a;
  --text: #f8fafc;
  --muted: #94a3b8;
  --faint: #64748b;

  --blue: #3b82f6;
  --violet: #8b5cf6;
  --teal: #14b8a6;
  --brand-grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --brand-ink: #ffffff;

  --deal: #10b981;          /* Smeraldo vivo per offerte e sotto soglia */
  --deal-ink: #022c22;
  --deal-soft: rgba(16, 185, 129, .15);
  --deal-glow: rgba(16, 185, 129, .25);

  --glitch: #f59e0b;        /* Ambra vivo per errori di prezzo e tolleranza */
  --glitch-soft: rgba(245, 158, 11, .15);
  --deal-amber: #f59e0b;
  --deal-amber-soft: rgba(245, 158, 11, .15);

  --vip: #eab308;           /* Oro vivo per VIP */
  --vip-soft: rgba(234, 179, 8, .15);

  --notif: #a855f7;         /* Viola vivo per notifiche Telegram e avvisi */
  --notif-soft: rgba(168, 85, 247, .15);

  --telemetry: #06b6d4;     /* Ciano vivo per scraping HFT e cluster */
  --telemetry-soft: rgba(6, 182, 212, .15);

  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, .14);
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, .14);
  --info: #3b82f6;
  --focus: #3b82f6;

  --amazon: #ff9900;
  --aliexpress: #ff4747;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 16px;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-s: 13px; --fs-m: 15px; --fs-l: 20px; --fs-price: 17px;
  --nav-w: 216px;
  --shadow: 0 16px 40px rgba(0, 0, 0, .55);
}

:root[data-theme="light"] {
  --bg: #eef2f7;
  --bg-glow-1: rgba(16, 185, 129, .05);
  --bg-glow-2: rgba(59, 130, 246, .06);
  --topbar-bg: rgba(255, 255, 255, .96);
  --sidebar-bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-hover: #e2e8f0;
  --line: #cbd5e1;
  --line-strong: #94a3b8;
  --text: #0f172a;
  --muted: #475569;
  --faint: #64748b;

  --blue: #2563eb;
  --violet: #7c3aed;
  --teal: #0d9488;
  --brand-grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --brand-ink: #ffffff;

  --deal: #059669;
  --deal-ink: #ffffff;
  --deal-soft: rgba(5, 150, 105, .12);
  --deal-glow: rgba(5, 150, 105, .20);

  --glitch: #d97706;
  --glitch-soft: rgba(217, 119, 6, .12);
  --deal-amber: #d97706;
  --deal-amber-soft: rgba(217, 119, 6, .12);

  --vip: #ca8a04;
  --vip-soft: rgba(202, 138, 4, .12);

  --notif: #7c3aed;
  --notif-soft: rgba(124, 58, 237, .12);

  --telemetry: #0284c7;
  --telemetry-soft: rgba(2, 132, 199, .12);

  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, .12);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, .10);
  --info: #2563eb;
  --focus: #2563eb;

  --amazon: #d97706;
  --aliexpress: #e11d48;

  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(900px 500px at 85% -10%, var(--bg-glow-2), transparent 70%),
    radial-gradient(700px 420px at 10% 0%, var(--bg-glow-1), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 var(--fs-m)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-s); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }

.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i-fill { fill: currentColor; }

/* ---------- Layout & Global TopBar ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 240px;
}

.topbar a.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text);
  padding: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
  color: var(--text);
}
.brand-badge.brand-v3 {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--deal) 18%, transparent);
  color: var(--deal);
  border: 1px solid color-mix(in srgb, var(--deal) 35%, transparent);
}

.topbar-engine {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: all .15s ease;
}
.topbar-engine:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--deal) 40%, var(--line));
  transform: translateY(-1px);
}
.topbar-engine .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  flex: none;
}
.topbar-engine .dot.bad {
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}

.topbar-center {
  flex: 1;
  max-width: 440px;
  margin: 0 var(--space-4);
  display: flex;
  align-items: center;
}

.topbar-search-wrap {
  width: 100%;
  max-width: 440px;
}
.topbar-search-input {
  width: 100%;
  height: 36px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.topbar-search-input:hover {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
}
.topbar-search-input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.topbar-search-input::placeholder {
  color: var(--muted);
  font-weight: 450;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.topbar-icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--line-strong);
}
.topbar-icon-btn .i {
  width: 17px;
  height: 17px;
}

.topbar-add-btn {
  background: var(--brand-grad);
  border: none;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(16, 185, 129, .25);
  transition: transform .15s, box-shadow .15s;
}
.topbar-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, .35);
}

.app-layout {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  flex: 1;
  min-height: calc(100vh - 58px);
}

.nav {
  position: sticky; top: 58px; height: calc(100vh - 58px);
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4) var(--space-3);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-4); }
.brand-mark {
  width: 22px; height: 22px; background: var(--deal);
  clip-path: polygon(0 0, 70% 0, 100% 50%, 70% 100%, 0 100%);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3); border-radius: var(--radius-m);
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-count {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--deal); color: var(--deal-ink); font-size: 12px; text-align: center; line-height: 20px;
}
.nav-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Sidebar Footer Audio Toggle */
.nav-foot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-m);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
  user-select: none;
}
.nav-foot-btn:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--deal) 40%, var(--line));
  color: var(--deal);
}
.nav-foot-btn.muted {
  color: var(--muted);
  background: transparent;
  border-style: dashed;
}
.nav-foot-btn.muted:hover {
  color: var(--text);
  border-style: solid;
}
.nav-foot-btn .i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.engine-pill { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-s); color: var(--muted); padding: var(--space-2) var(--space-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

.main { padding: var(--space-6) var(--space-6) 96px; max-width: 1180px; width: 100%; min-width: 0; }
.main:focus { outline: none; }

.view-head { display: flex; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-5); }
.view-head h1 { font-size: 26px; line-height: 1.15; margin: 0 0 var(--space-1); letter-spacing: -.02em; }
.view-head p { margin: 0; color: var(--muted); max-width: 62ch; }
.view-head .actions { margin-left: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }

.section { margin-top: var(--space-6); }
.section > h2 { font-size: var(--fs-m); font-weight: 600; margin: 0 0 var(--space-3); display: flex; align-items: baseline; gap: var(--space-2); }
.section > h2 .muted { font-weight: 400; font-size: var(--fs-s); }

/* ---------- Controlli ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 38px; padding: 0 var(--space-4);
  border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: var(--muted); border-color: var(--muted); }
.btn-deal { background: var(--deal); color: var(--deal-ink); border-color: var(--deal); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-block { width: 100%; }
.btn-s { min-height: 32px; padding: 0 var(--space-3); font-size: var(--fs-s); }

/* Pulsanti con sola icona: stessa altezza dei pulsanti piccoli (32), icona da 18 come nei pulsanti */
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: var(--radius-m); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn .i { width: 18px; height: 18px; }
/* Segnaposto invisibile: tiene allineata la colonna dei pulsanti quando un'azione manca */
.ph { visibility: hidden; }
/* Touch: bersagli più grandi per il dito */
@media (pointer: coarse) {
  .btn-s, .icon-btn { min-height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--deal); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); }
.icon-btn.cart:hover { color: var(--ok); background: var(--ok-soft); }
.icon-btn.on .i { fill: currentColor; }

.field { display: grid; gap: 6px; font-size: var(--fs-s); color: var(--muted); }
.field > span { font-weight: 500; }
.field small { color: var(--faint); }
input[type="text"], input[type="number"], input[type="password"], input[type="url"], input[type="search"], input[type="time"], input[type="date"], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px var(--space-3);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-m);
  color: var(--text); font-size: var(--fs-m);
}
textarea { min-height: 120px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.grid-2.fields-top { align-items: start; }
.grid-2.fields-top .field { align-content: start; }
.row-fields { display: flex; gap: var(--space-3); align-items: flex-start; }
.row-fields > .field { flex: 1 1 0; min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.stack { display: grid; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: var(--space-2); }

.check { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; font-size: var(--fs-m); color: var(--text); }
.check input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--deal); flex: none; }
.check small { display: block; color: var(--muted); font-size: var(--fs-s); }

.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px var(--space-3); border-radius: 7px; font-size: var(--fs-s); font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface-2); color: var(--text); }
.seg button b { font-weight: 500; color: var(--faint); margin-left: 4px; }

.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px var(--space-3); border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-s); font-weight: 600; cursor: pointer; color: var(--muted); background: transparent; }
.chip input { display: none; }
.chip:has(input:checked), .chip.on { color: var(--bg); background: var(--text); border-color: var(--text); }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; background: var(--surface-2); color: var(--muted); }
.badge-amazon { color: var(--amazon); background: color-mix(in srgb, var(--amazon) 14%, transparent); }
.badge-aliexpress { color: var(--aliexpress); background: color-mix(in srgb, var(--aliexpress) 14%, transparent); }
.badge-deal { color: var(--deal-ink); background: var(--deal); }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-bad { color: var(--bad); background: var(--bad-soft); }
.badge-wh { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); }
.badge-new { color: var(--text); background: var(--surface-2); }

.toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-2); }
.search { position: relative; flex: 1 1 260px; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 18px; height: 18px; }
.search input { padding-left: 36px; padding-right: 12px; }
.toolbar-actions { display: flex; gap: var(--space-2); align-items: center; margin-left: auto; }
.toolbar-stat-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); padding: 0 4px; min-height: 20px; }
.filtered-stat { font-size: 12.5px; font-weight: 500; color: var(--muted); }

/* ---------- Stato e righe ---------- */
.status-line { display: flex; gap: var(--space-5); flex-wrap: wrap; padding: var(--space-4) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.status-line .fact { display: grid; gap: 2px; }
.status-line .fact b { font-size: var(--fs-l); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-line .fact span { font-size: var(--fs-s); color: var(--muted); }
.status-sentence { font-size: var(--fs-l); line-height: 1.35; margin: 0 0 var(--space-4); max-width: 60ch; }
.status-sentence .dot { display: inline-block; margin-right: var(--space-2); vertical-align: middle; }

.list { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); overflow: hidden; }
.list + .list { margin-top: var(--space-4); }

.prow {
  display: grid;
  align-items: center;
  gap: 14px;
  grid-template-columns: 44px minmax(200px, 1fr) 172px 286px 96px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background .12s ease;
}
.prow:first-child { border-top: 0; }
.prow:hover { background: var(--surface-2); }
.prow.paused { opacity: .55; }
.prow.no-img { grid-template-columns: minmax(200px, 1fr) 172px 286px 96px; }
.thumb { width: 44px; height: 44px; border-radius: var(--radius-m); background: #fff; object-fit: contain; border: 1px solid var(--line); flex-shrink: 0; }
.thumb-empty { width: 44px; height: 44px; border-radius: var(--radius-m); background: var(--surface-2); border: 1px solid var(--line); }
.pname { min-width: 0; }
.pname .t { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.pname .t a { text-decoration: none; color: var(--text); }
.pname .t a:hover { text-decoration: underline; color: var(--brand); }
.pname .m { display: flex; gap: 6px; align-items: center; margin-top: 4px; font-size: var(--fs-s); color: var(--muted); flex-wrap: wrap; }
.badge-asin { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); letter-spacing: .02em; }
.badge-group { font-size: 11px; font-weight: 600; color: var(--text-2); background: color-mix(in srgb, var(--brand) 12%, transparent); padding: 1px 6px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.badge-vip { color: #f59e0b; background: rgba(245, 158, 11, .15); border: 1px solid rgba(245, 158, 11, .3); }
.badge-paused { color: var(--muted); background: var(--surface-2); }
.badge-linked { font-size: 11px; color: var(--info); font-weight: 600; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--info) 14%, transparent); }

/* Strip comparativo store dedicato: tutte le bandierine sulla stessa riga */
.pstores-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  min-width: 0;
}
.pstores-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  flex-shrink: 0;
  padding: 1.5px 5px;
  background: var(--surface-2);
  border-radius: 4px;
  border: 1px solid var(--line);
  line-height: 1.2;
  user-select: none;
}
.pstores-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.pstores-list::-webkit-scrollbar { display: none; }

/* Meter & Delta Pill */
.meter-cell { min-width: 0; }
.meter-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.delta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.delta-pill .delta-arrow { font-size: 10px; }
.delta-pill .delta-sub { font-weight: 500; font-size: 10.5px; opacity: .85; }
.delta-pill.deal {
  background: var(--deal-soft);
  color: var(--deal);
  border: 1px solid color-mix(in srgb, var(--deal) 35%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--deal) 20%, transparent);
}
.delta-pill.deal b { font-weight: 800; }
.delta-pill.tol {
  background: rgba(245, 165, 36, .15);
  color: #f5a524;
  border: 1px solid rgba(245, 165, 36, .35);
}
.delta-pill.above {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.delta-pill.neutral {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.delta-pill.stale {
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
}
.dot-warn { width: 6px; height: 6px; border-radius: 50%; background: var(--bad); }

.meter-bar { position: relative; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--text) 9%, transparent); overflow: visible; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--blue), color-mix(in srgb, var(--bad) 70%, var(--blue))); opacity: .85; }
.meter-bar.deal .meter-fill { background: linear-gradient(90deg, var(--ok), var(--deal)); opacity: 1; }
.meter-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 1px; }
.meter-th-text { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.meter-th-text b { color: var(--text); font-weight: 600; }

/* Price Column */
.price { text-align: right; font-size: var(--fs-price); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.price.deal { color: var(--deal); }
.price.stale { color: var(--faint); }
.price.none { color: var(--faint); font-weight: 500; font-size: var(--fs-s); }
.price .price-waiting { font-size: 13px; font-weight: 600; color: var(--muted); }
.pl-single { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

/* Nuovo e Usato su due righe, ciascuno col suo store e soglia in 4 colonne fisse allineate */
.price.dual { display: flex; flex-direction: column; gap: 4px; align-items: stretch; font-size: 13.5px; width: 100%; }
.price.dual .pl {
  display: grid;
  grid-template-columns: 74px 76px 18px 100px;
  align-items: center;
  justify-content: end;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.price.dual .k { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; text-align: right; }
.price.dual .pl.wh .k { color: var(--info); }
.price.dual b { font-weight: 650; text-align: right; }
.price.dual .pl.is-empty b { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.price.dual .pl.deal b { color: var(--deal); font-weight: 700; }
.price.dual .th-slot { display: flex; justify-content: flex-end; align-items: center; min-width: 0; }
.price.dual .th-badge { font-size: 10.5px; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; letter-spacing: 0; white-space: nowrap; }
.price.dual .pl.deal .th-badge { color: var(--deal); background: color-mix(in srgb, var(--deal) 14%, transparent); font-weight: 600; }
.price.dual .flag { width: 18px; height: 12px; flex: none; justify-self: center; }
.price.dual .nof { display: block; width: 18px; height: 12px; flex: none; }
.price.dual.stale b { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1px; }
.price.dual small.stale-warn { font-size: 11px; color: var(--bad); text-align: right; }

.pact { display: flex; justify-content: flex-end; gap: 4px; }

/* Group Head */
.group-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); cursor: pointer; user-select: none;
  border-top: 1px solid var(--line);
  background: var(--surface);
  transition: background .12s ease;
  min-width: 0;
}
.group-head:first-child { border-top: 0; }
.group-head:hover { background: var(--surface-2); }
.group-head.open { background: var(--surface-2); }
.group-head + .prow { border-top-color: var(--line); }
.group-head .chev-wrap { display: grid; place-items: center; flex-shrink: 0; }
.group-head .chev { transition: transform .15s; color: var(--muted); }
.group-head.open .chev { transform: rotate(90deg); }
.ghead-titles { display: flex; align-items: center; gap: 8px; flex: 1 1 160px; min-width: 0; }
.group-head h3 { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gcount-badge { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); flex-shrink: 0; }
.badge-pulse { animation: pulseDeal 2s infinite ease-in-out; flex-shrink: 0; }
@keyframes pulseDeal {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .4); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
}
.ghead-right { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; flex-shrink: 0; }
.grange { font-size: 12px; color: var(--muted); white-space: nowrap; }
.grange b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-group-manage { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12px; padding: 3px 10px; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn-group-manage:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-group-manage .i { width: 14px; height: 14px; }
.group-head.paused h3, .group-head.paused .gicon, .group-head.paused .grange { opacity: .5; }
.group-head.paused h3 { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }
.badge.gpause { gap: 4px; flex: none; color: #e0901a; background: rgba(245, 165, 36, .16); }
.badge.gpause .i { width: 12px; height: 12px; }

.nrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); align-items: center; }
.nrow:first-child { border-top: 0; }
.nrow .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nrow .m { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: var(--fs-s); color: var(--muted); margin-top: 3px; }
.nrow .side { display: flex; align-items: center; gap: var(--space-3); }
.nrow .side .price { min-width: 92px; }

.empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: var(--space-1); }
.loading { padding: var(--space-6); text-align: center; color: var(--faint); }
.form-error { color: var(--bad); font-size: var(--fs-s); margin: 0; }
.note { padding: var(--space-3) var(--space-4); border-radius: var(--radius-m); background: var(--surface-2); color: var(--muted); font-size: var(--fs-s); }
.note.warn { background: var(--deal-soft); color: var(--text); }


table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
table.t th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr:last-child td { border-bottom: 0; }

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); margin-bottom: var(--space-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; color: var(--muted); padding: 10px var(--space-3); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--text); }

.panel { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); padding: var(--space-5); }
.panel + .panel { margin-top: var(--space-4); }
.panel h3 { margin: 0 0 var(--space-1); font-size: var(--fs-m); }
.panel > p { margin: 0 0 var(--space-4); color: var(--muted); font-size: var(--fs-s); }
.setting { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting .lbl { flex: 1; }
.setting .lbl b { display: block; font-weight: 600; font-size: var(--fs-m); }
.setting .lbl small { color: var(--muted); font-size: var(--fs-s); }
.setting input[type="number"], .setting select, .setting input[type="time"] { width: 140px; }

.brief summary { cursor: pointer; font-weight: 600; }
.brief-text { white-space: pre-wrap; margin-top: var(--space-3); color: var(--muted); font-size: 14px; max-height: 360px; overflow-y: auto; }

/* ---------- Pannello laterale ---------- */
.scrim { position: fixed; inset: 0; background: rgba(5, 10, 18, .5); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 100vw); background: var(--bg); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); align-content: start; }
.drawer-foot { display: flex; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--line); }
.drawer-foot:empty { display: none; }
.drawer-foot .spacer { flex: 1; }
.dsec { display: grid; gap: var(--space-3); }
.dsec > h3 { margin: 0; font-size: var(--fs-s); font-weight: 600; color: var(--muted); }

.drawer-top-row {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
}
.drawer-grid { display: flex; flex-direction: column; gap: var(--space-5); }
.drawer-col-form, .drawer-col-data { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.drawer .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 768px) {
  .drawer[data-kind="diagnostics"] {
    width: min(680px, 94vw);
  }
}

@media (min-width: 900px) {
  .drawer[data-kind="product"] {
    width: min(920px, 92vw);
  }
  .drawer[data-kind="product"] .drawer-grid {
    display: grid;
    grid-template-columns: minmax(360px, 1.15fr) minmax(340px, 1fr);
    gap: var(--space-5);
    align-items: start;
  }
  .drawer[data-kind="product"] .drawer-col-data {
    position: sticky;
    top: 0;
  }
}

.variant-list { display: grid; gap: var(--space-1); max-height: 260px; overflow-y: auto; }
.variant { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-m); cursor: pointer; }
.variant:has(input:checked) { border-color: var(--text); background: var(--surface); }
.variant input { accent-color: var(--deal); }
.variant .vl { flex: 1; min-width: 0; }
.variant .vp { font-weight: 600; font-variant-numeric: tabular-nums; }
.variant.off { opacity: .45; cursor: default; }

.chart { width: 100%; height: 180px; display: block; }
.chart .axis { stroke: var(--line); }
.chart .l-new { stroke: var(--text); fill: none; stroke-width: 1.8; }
.chart .l-wh { stroke: var(--info); fill: none; stroke-width: 1.8; }
.chart .l-th { stroke: var(--deal); stroke-dasharray: 4 4; stroke-width: 1.2; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: var(--space-4); font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 6px; }

.result { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-m); }
.result .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result .m { font-size: var(--fs-s); color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.chat { display: grid; gap: var(--space-3); }
.msg { padding: var(--space-3) var(--space-4); border-radius: var(--radius-m); background: var(--surface); white-space: pre-wrap; font-size: 14px; }
.msg.me { background: var(--surface-2); justify-self: end; max-width: 85%; }

.ask-btn {
  position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 30;
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 44px; padding: 0 var(--space-4); border-radius: 22px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}

.confirm { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); color: var(--text); padding: var(--space-5); max-width: 420px; width: calc(100vw - 32px); }
.confirm::backdrop { background: rgba(5, 10, 18, .55); }
.confirm p { margin: 0 0 var(--space-5); }

.toasts { position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%); z-index: 60; display: grid; gap: var(--space-2); }
.toast { padding: 10px var(--space-4); border-radius: var(--radius-m); background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }

.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.login-box { width: min(360px, 100%); display: grid; gap: var(--space-4); }

/* ---------- Palette Semantica ad Alta Densità (UI/UX Pro Max) ----------
   Identità visiva distintiva per ogni sezione e indicatore operativo. */
.main[data-view="home"]         { --tone: var(--deal); }
.main[data-view="prodotti"]     { --tone: var(--blue); }
.main[data-view="notifiche"]    { --tone: var(--notif); }
.main[data-view="radar"]        { --tone: var(--telemetry); }
.main[data-view="impostazioni"] { --tone: var(--amazon); }

.nav-item[data-view="home"] .i         { color: var(--deal); }
.nav-item[data-view="prodotti"] .i     { color: var(--blue); }
.nav-item[data-view="notifiche"] .i    { color: var(--notif); }
.nav-item[data-view="radar"] .i        { color: var(--telemetry); }
.nav-item[data-view="impostazioni"] .i { color: var(--amazon); }

.nav-item { position: relative; }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--deal); }

.view-head h1 { display: flex; align-items: center; gap: var(--space-3); }
.view-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: none;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.view-icon .i { width: 20px; height: 20px; }

.btn-primary { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(16, 185, 129, .3); }
.btn-primary:hover { background: var(--brand-grad); filter: brightness(1.08); border-color: transparent; }

.list, .panel { box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .15); }

/* Riquadri con i numeri: uguali in tutte le pagine (factTiles in app.js) */
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.fact-tile {
  position: relative; overflow: hidden; display: grid; gap: 4px;
  padding: var(--space-4); border-radius: var(--radius-l); border: 1px solid var(--line);
  background: linear-gradient(160deg, color-mix(in srgb, var(--ft) 12%, var(--surface)) 0%, var(--surface) 80%);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.fact-tile.is-clickable {
  cursor: pointer;
}
.fact-tile.is-clickable:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--ft) 55%, var(--line));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ft) 18%, transparent);
}
.fact-tile.is-clickable:active { transform: translateY(0); }
.fact-tile .ficon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--ft); background: color-mix(in srgb, var(--ft) 18%, transparent); margin-bottom: var(--space-1); }
.fact-tile .ficon .i { width: 18px; height: 18px; }
.fact-tile b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); letter-spacing: -.02em; }
.fact-tile span { font-size: var(--fs-s); color: var(--muted); font-weight: 500; }
.fact-tile[data-tone="deal"] { --ft: var(--deal); }
.fact-tile[data-tone="violet"] { --ft: var(--notif); }
.fact-tile[data-tone="blue"] { --ft: var(--blue); }
.fact-tile[data-tone="teal"] { --ft: var(--telemetry); }
.fact-tile[data-tone="bad"] { --ft: var(--bad); }
.fact-tile[data-tone="glitch"] { --ft: var(--glitch); }
.fact-tile[data-tone="vip"] { --ft: var(--vip); }

.deal-hero {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 16px 20px;
  border-radius: var(--radius-l);
  background: linear-gradient(135deg, color-mix(in srgb, var(--deal) 16%, var(--surface)) 0%, var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--deal) 40%, var(--line));
  box-shadow: 0 8px 30px color-mix(in srgb, var(--deal) 14%, transparent);
  margin-bottom: var(--space-4);
}
.deal-hero-badge {
  font-size: 13px;
  font-weight: 800;
  color: var(--deal);
  background: color-mix(in srgb, var(--deal) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--deal) 40%, transparent);
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.deal-hero-content { flex: 1; min-width: 0; }
.deal-hero-content h3 { margin: 0 0 4px 0; font-size: 16px; font-weight: 700; color: var(--text); }
.deal-hero-content h3 b { color: var(--deal); font-weight: 800; }
.deal-hero-content p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.btn-deal-hero,
.btn.btn-deal-hero {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background-color: #059669 !important;
  background-image: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: var(--radius-m);
  border: 1px solid #047857 !important;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(5, 150, 105, .32);
  cursor: pointer;
  transition: transform .12s, filter .12s, box-shadow .12s;
}
.btn-deal-hero:hover,
.btn.btn-deal-hero:hover,
.btn-deal-hero:focus-visible {
  background-color: #047857 !important;
  background-image: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  color: #ffffff !important;
  border-color: #065f46 !important;
  box-shadow: 0 6px 18px rgba(5, 150, 105, .42);
  transform: translateY(-1px);
  text-decoration: none;
}
.btn-deal-hero .i { width: 16px; height: 16px; }

.status-banner { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-l); margin-bottom: var(--space-4); font-weight: 500; font-size: 13.5px; }
.status-banner.ok { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); color: var(--text); }
.status-banner.bad { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }

/* Righe prodotto */
.prow.deal-row { box-shadow: inset 3px 0 0 var(--deal); background: linear-gradient(90deg, var(--deal-soft), transparent 45%); }
.thumb-mono {
  width: 40px; height: 40px; border-radius: var(--radius-s); display: grid; place-items: center;
  font-weight: 800; font-size: 15px; letter-spacing: -.02em; color: #fff;
}
.thumb-mono.amazon { background: linear-gradient(135deg, #ffb340, #ff7a00); }
.thumb-mono.aliexpress { background: linear-gradient(135deg, #ff6a5a, #e2231a); font-size: 12px; }

.meter-bar { background: color-mix(in srgb, var(--text) 9%, transparent); }
.meter-fill { background: linear-gradient(90deg, var(--blue), color-mix(in srgb, var(--bad) 75%, var(--blue))); opacity: .85; }
.meter.deal .meter-fill { background: linear-gradient(90deg, var(--ok), var(--deal)); opacity: 1; }

.gdot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: hsl(var(--h) 75% 58%); box-shadow: 0 0 0 3px hsl(var(--h) 75% 58% / .18); }

.badge-amazon { color: #ff9a1f; }
.seg button.on { background: color-mix(in srgb, var(--tone, var(--text)) 18%, var(--surface)); color: var(--text); }
.tabs button.on { border-bottom-color: var(--tone, var(--text)); }

.ask-btn { background: var(--brand-grad); color: var(--brand-ink); border-color: transparent; }

/* Impostazioni: una scheda uguale per ogni fonte */
.panel.source { padding: 0; overflow: hidden; }
.panel.source[data-tone="amazon"]     { --st: var(--amazon); }
.panel.source[data-tone="aliexpress"] { --st: var(--aliexpress); }
.panel.source[data-tone="blue"]       { --st: var(--blue); }
.panel.source[data-tone="violet"]     { --st: var(--violet); }
.panel.source[data-tone="teal"]       { --st: var(--teal); }
.panel.source[data-tone="deal"],
.panel.source[data-tone="amber"]      { --st: var(--deal); }
.panel.source[data-tone="ok"],
.panel.source[data-tone="green"]      { --st: var(--ok); }
.panel.source[data-tone="rose"],
.panel.source[data-tone="bad"]        { --st: var(--bad); }
.panel.source[data-tone="view"]       { --st: var(--blue); }
.source-head { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); background: linear-gradient(90deg, color-mix(in srgb, var(--st) 14%, transparent), transparent 70%); border-bottom: 1px solid var(--line); }
.source-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--st); background: color-mix(in srgb, var(--st) 18%, transparent); flex: none; }
.source-title { flex: 1; min-width: 0; }
.source-title h3 { margin: 0; font-size: 17px; }
.source-title p { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-s); }
.source-body { padding: var(--space-2) var(--space-5) var(--space-4); }
.source-sec { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-4); padding: var(--space-4) 0; border-top: 1px solid var(--line); }
.source-sec:first-child { border-top: 0; }
.source-sec h4 { margin: 12px 0 0; font-size: var(--fs-s); color: var(--st); font-weight: 700; }
.source-sec .setting:first-child { padding-top: 0; }
.badge-fixed { color: var(--ok); background: var(--ok-soft); }
@media (max-width: 640px) {
  .source-sec { grid-template-columns: 1fr; gap: var(--space-2); }
  .source-sec h4 { margin: 0; }
  .source-head, .source-body { padding-left: var(--space-4); padding-right: var(--space-4); }
}

/* Pannello laterale, conferme, login e avvisi con lo stesso colore del resto */
.drawer { background: var(--bg); }
.drawer[data-kind="product"], .drawer[data-kind="group"] { --dt: var(--blue); }
.drawer[data-kind="add"] { --dt: var(--deal); }
.drawer[data-kind="copilot"] { --dt: var(--violet); }
.drawer-head { background: linear-gradient(100deg, color-mix(in srgb, var(--dt, var(--blue)) 20%, var(--surface)) 0%, var(--surface) 75%); }
.drawer-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--dt, var(--blue)); background: color-mix(in srgb, var(--dt, var(--blue)) 18%, transparent); }
.drawer-icon .i { width: 18px; height: 18px; }
.drawer-foot { background: var(--surface); }
.drawer-body .dsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-4); }
.drawer-body .dsec > h3 { color: var(--dt, var(--blue)); display: flex; align-items: center; gap: 8px; }
.drawer-body .dsec > h3::before { content: ''; width: 4px; height: 14px; border-radius: 2px; background: var(--dt, var(--blue)); }
.drawer-body #editForm > .field, .drawer-body #editForm > .grid-2 { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-4); }
.drawer-body #editForm > .setting { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-3) var(--space-4) !important; }
.drawer-body section[data-pane] { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-4); }
.drawer-body .tabs { margin-bottom: 0; }
.drawer-body .tabs button.on { color: var(--dt); border-bottom-color: var(--dt); }
.drawer-body table.t th { color: var(--dt, var(--muted)); font-weight: 600; }
.drawer-body .result { background: var(--surface); }
.drawer-body .result:hover { border-color: color-mix(in srgb, var(--dt) 50%, var(--line)); }
.variant:has(input:checked) { border-color: var(--dt, var(--deal)); background: color-mix(in srgb, var(--dt, var(--deal)) 10%, var(--surface)); }
.msg { background: var(--surface); border: 1px solid var(--line); }
.msg.me { background: color-mix(in srgb, var(--violet) 16%, var(--surface)); border-color: color-mix(in srgb, var(--violet) 35%, var(--line)); }
.note { border-left: 3px solid var(--info); }
.note.warn { border-left-color: var(--deal); }

.confirm { border-top: 4px solid var(--bad); box-shadow: var(--shadow); }
.confirm-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--bad); background: var(--bad-soft); margin-bottom: var(--space-3); }

.toast { display: flex; align-items: center; gap: 8px; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.ok::before { content: '✓'; font-weight: 800; }
.toast.bad::before { content: '!'; font-weight: 800; }

.login { background:
  radial-gradient(600px 400px at 20% 10%, var(--bg-glow-1), transparent 70%),
  radial-gradient(700px 500px at 80% 90%, var(--bg-glow-2), transparent 70%); }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: var(--space-6); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.login-box::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--brand-grad); }
.login-box .brand { padding: 0; }
.login-box .brand-name { font-size: 22px; }
.login-sub { margin: 0; color: var(--muted); font-size: var(--fs-s); }

/* Icone di categoria e marchi degli store */
.thumb-cat { width: 40px; height: 40px; border-radius: var(--radius-s); display: grid; place-items: center;
  color: hsl(var(--h) 80% 62%); background: hsl(var(--h) 70% 55% / .16); border: 1px solid hsl(var(--h) 70% 55% / .25); }
.thumb-cat .i { width: 24px; height: 24px; stroke-width: 1.6; }
.gicon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none;
  color: hsl(var(--h) 80% 62%); background: hsl(var(--h) 70% 55% / .16); }
.gicon .i { width: 18px; height: 18px; }
:root[data-theme="light"] .thumb-cat, :root[data-theme="light"] .gicon { color: hsl(var(--h) 65% 38%); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .thumb-cat, :root:not([data-theme="dark"]) .gicon { color: hsl(var(--h) 65% 38%); } }

.store-logo { display: inline-flex; align-items: baseline; gap: 0; height: 20px; padding: 1px 7px 0; border-radius: 5px; line-height: 1; white-space: nowrap; }
.store-logo.amz { background: #131921; color: #fff; }
.store-logo.amz .wm { position: relative; font: 700 12px/1 Arial, Helvetica, sans-serif; letter-spacing: -.02em; padding-bottom: 4px; }
.store-logo.amz .smile { position: absolute; left: 1px; right: 0; bottom: 0; width: calc(100% - 1px); height: 5px; fill: none; stroke: #ff9900; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.store-logo.amz .tld { font: 700 11px/1 Arial, Helvetica, sans-serif; color: #ff9900; margin-left: 1px; }
.store-logo.ali { background: #fff; border: 1px solid #ffd2c9; padding-top: 4px; }
.store-logo.ali b { font: 800 11px/1 Arial, Helvetica, sans-serif; color: #e62e04; }
.store-logo.ali i { font: italic 700 11px/1 Arial, Helvetica, sans-serif; color: #ff7a00; }

/* Bandierine degli store e logo sul prodotto senza foto */
.flag { display: inline-block; width: 22px; height: 15px; border-radius: 3px; overflow: hidden; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.25); vertical-align: middle; }
.flag svg { display: block; width: 100%; height: 100%; }
.thumb-logo { width: 40px; height: 40px; border-radius: var(--radius-s); display: grid; place-items: center; overflow: hidden; }
.thumb-logo.amz { background: #131921; }
.thumb-logo.amz .wm { position: relative; font: 700 10px/1 Arial, Helvetica, sans-serif; color: #fff; letter-spacing: -.03em; padding-bottom: 4px; }
.thumb-logo.amz .smile { position: absolute; left: 0; bottom: 0; width: 100%; height: 5px; fill: none; stroke: #ff9900; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.thumb-logo.ali { background: #fff; border: 1px solid #ffd2c9; flex-direction: column; line-height: 1; text-align: center; }
.thumb-logo.ali b { font: 800 11px/1 Arial, Helvetica, sans-serif; color: #e62e04; display: block; }
.thumb-logo.ali i { font: italic 700 8px/1 Arial, Helvetica, sans-serif; color: #ff7a00; display: block; }

/* Link per store sul prodotto: bandierina + prezzo (mai a capo, allineamento perfetto) */
.store-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px 2.5px 5px;
  border-radius: 6px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  transition: all .12s ease;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}
.store-link:hover {
  border-color: var(--brand);
  background: var(--surface);
  color: var(--text);
  transform: translateY(-1px);
}
.store-link.best {
  border-color: color-mix(in srgb, var(--deal) 65%, transparent);
  background: color-mix(in srgb, var(--deal) 12%, var(--surface-2));
  color: var(--deal);
  font-weight: 700;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--deal) 15%, transparent);
}
.store-link.best:hover {
  background: color-mix(in srgb, var(--deal) 22%, var(--surface-2));
  border-color: var(--deal);
}
.store-link.none {
  color: var(--faint);
  background: transparent;
  border: 1px dashed var(--line);
  opacity: .75;
}
.store-link.none:hover {
  opacity: 1;
  border-color: var(--muted);
  background: var(--surface-2);
}
.store-link.is-wh {
  border-color: color-mix(in srgb, var(--deal) 35%, var(--line));
}
.store-link .wh-tag {
  font-style: normal;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--deal);
  background: color-mix(in srgb, var(--deal) 14%, transparent);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 2px;
  line-height: 1;
}
.store-link i { font-style: normal; font-size: 10px; font-weight: 800; color: var(--info); margin-left: 2px; }
.store-link .flag {
  width: 16px;
  height: 11px;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 1px rgba(0, 0, 0, .3);
  display: inline-flex;
  flex-shrink: 0;
}
.store-link .flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Responsive Tablet & Telefono (piano §11.5 + Verifica a Tappeto v3.0) ---------- */
@media (max-width: 860px) {
  .topbar-center { display: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deal-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 16px;
  }
  .deal-hero-content { width: 100%; }
  .btn-deal-hero { width: 100%; justify-content: center; }
  .group-head .grange { display: none; }
  .prow {
    grid-template-columns: 42px minmax(0, 1fr) 272px;
    row-gap: 10px;
    column-gap: 12px;
  }
  .prow.no-img { grid-template-columns: minmax(0, 1fr) 272px; }
  .prow .pname { grid-column: 2 / -1; }
  .prow.no-img .pname { grid-column: 1 / -1; }
  .prow .pname .t {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .prow .pstores-list { flex-wrap: wrap; }
  .prow .meter-cell { grid-column: 2 / 3; order: 3; align-self: center; }
  .prow.no-img .meter-cell { grid-column: 1 / 2; order: 3; }
  .prow .price { grid-column: 3 / 4; order: 4; align-self: center; }
  .prow.no-img .price { grid-column: 2 / 3; order: 4; }
  .prow .pact { display: none; }
  .price.dual { font-size: 13px; gap: 3px; }
  .price.dual .pl { grid-template-columns: 70px 74px 16px 96px; gap: 4px; }
  .price.dual .k { font-size: 10px; }
  .price.dual .flag, .price.dual .nof { width: 14px; height: 10px; }
  .price.dual small { font-size: 10px; white-space: normal; }
}
@media (max-width: 640px) {
  .app-layout { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    padding: 0 var(--space-3);
    height: 52px;
    gap: var(--space-2);
  }
  .topbar-left { min-width: 0; gap: 8px; flex: 1; }
  .topbar-engine {
    display: inline-flex;
    padding: 3px 9px;
    font-size: 11px;
    gap: 5px;
    max-width: 175px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar a.brand .brand-badge { display: none; }
  .topbar-add-btn span { display: none; }
  .topbar-add-btn { min-height: 34px; padding: 0 10px; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 35;
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); background: var(--bg);
    backdrop-filter: none;
  }
  .brand, .nav-foot { display: none; }
  .nav-item { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; position: relative; }
  .nav-item.active { background: transparent; color: var(--text); }
  .nav-item.active::before { left: 25%; right: 25%; top: 0; bottom: auto; width: auto; height: 3px; }
  .nav-count { position: absolute; top: 0; right: 18%; min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
  .main { padding: var(--space-4) var(--space-3) 120px; }
  .view-head { flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
  .view-head h1 { font-size: 21px; }
  .view-head .actions { margin-left: 0; justify-content: flex-start; width: 100%; }
  .toolbar { gap: 8px; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar .seg { flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .toolbar .seg::-webkit-scrollbar { display: none; }
  .toolbar select#statusFilter { flex: 1 1 150px; }
  .toolbar-actions { width: 100%; justify-content: flex-end; margin-left: 0; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .row-fields { flex-direction: column; }
  .drawer { width: 100vw; border-left: 0; }
  .drawer-body { padding: var(--space-4); }
  .drawer-head, .drawer-foot { padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
  .drawer-top-row { flex-wrap: wrap; }
  .ask-btn { bottom: calc(76px + env(safe-area-inset-bottom)); right: var(--space-4); height: 40px; }
  .ask-btn span { display: none; }
  .nrow { grid-template-columns: 1fr; gap: var(--space-2); }
  .nrow .side { justify-content: space-between; }
  .nrow .side .price { text-align: left; }
  .setting { flex-wrap: wrap; }
  .setting input[type="number"], .setting select, .setting input[type="time"] { width: 100%; }
  /* Macro categorie responsive su smartphone */
  .group-head {
    padding: 10px 12px;
    gap: 8px;
  }
  .group-head .grange, .group-head .gbest { display: none; }
  .ghead-titles {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: wrap;
    gap: 4px 8px;
  }
  .group-head h3 {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 14px;
    line-height: 1.25;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .group-head .gmeta { white-space: nowrap; }
  .badge.gpause { padding: 0 5px; }
  .badge.gpause span { display: none; }
  .group-head.paused .gmeta, .group-head .gpart { display: none; }
  .group-head .btn { margin-left: 0; }
  .btn-group-manage { padding: 5px 8px; }
  .btn-group-manage span { display: none; }
  /* Righe prodotto su smartphone: layout verticale ordinato senza compressioni */
  .prow {
    grid-template-columns: 40px minmax(0, 1fr);
    padding: 12px;
    row-gap: 10px;
    column-gap: 10px;
  }
  .prow.no-img { grid-template-columns: minmax(0, 1fr); }
  .prow > .thumb, .prow > .thumb-logo, .prow > .thumb-empty { align-self: start; width: 40px; height: 40px; }
  .prow .pname { grid-column: 2 / -1; }
  .prow.no-img .pname { grid-column: 1 / -1; }
  .prow .meter-cell {
    grid-column: 1 / -1;
    order: 3;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }
  .prow .meter-wrap {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .prow .meter-bar { flex: 1 1 90px; min-width: 80px; }
  .prow .price {
    grid-column: 1 / -1;
    order: 4;
    text-align: left;
  }
  .prow .price.dual {
    align-items: stretch;
    gap: 5px;
  }
  .prow .price.dual .pl {
    grid-template-columns: 74px 76px 18px minmax(0, 1fr);
    justify-content: stretch;
  }
  .prow .price.dual .k { text-align: left; }
  .prow .pl-single { justify-content: flex-start; }
  .bench-table th, .bench-table td { padding: 9px 10px; font-size: 12px; }
  .bench-col-prod { min-width: 170px; }
  .status-line { gap: var(--space-4); }
  .status-sentence { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Cluster: master (VPS) e worker (PC aiutanti) */
.cluster { --warn: #f5a524; --warn-soft: rgba(245, 165, 36, .16); }
.cluster > h2 .i { width: 18px; height: 18px; color: var(--teal); align-self: center; }
.cluster .facts { margin-bottom: var(--space-3); }
.node-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--space-3); }
.node-card { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); padding: var(--space-4); display: grid; gap: var(--space-4); container-type: inline-size; }
@container (max-width: 330px) { .node-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.node-card[data-role="master"] { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
.node-card.is-off { opacity: .62; }
.node-head { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.node-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; color: var(--violet); background: color-mix(in srgb, var(--violet) 16%, transparent); }
.node-card[data-role="master"] .node-icon { color: var(--blue); background: color-mix(in srgb, var(--blue) 16%, transparent); }
.node-icon .i { width: 22px; height: 22px; }
.node-name { min-width: 0; flex: 1; }
.node-title { display: flex; align-items: center; gap: var(--space-2); }
.node-title b { font-size: var(--fs-m); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-chip { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: var(--violet); background: color-mix(in srgb, var(--violet) 14%, transparent); }
.node-card[data-role="master"] .role-chip { color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, transparent); }
.node-sub { font-size: var(--fs-s); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.node-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); font-weight: 600; padding: 3px 10px; border-radius: 999px; flex: none; }
.node-status .dot { box-shadow: none; }
.node-status.on { color: var(--ok); background: var(--ok-soft); }
.node-status.on .dot { background: var(--ok); }
.node-status.warn { color: var(--warn); background: var(--warn-soft); }
.node-status.warn .dot { background: var(--warn); }
.node-status.off { color: var(--muted); background: var(--surface-2); }
.node-status.off .dot { background: var(--bad); }
.node-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.nm { display: grid; gap: 1px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-m); background: var(--surface-2); min-width: 0; }
.nm-i { color: var(--muted); height: 16px; }
.nm-i .i { width: 16px; height: 16px; }
.nm b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nm span:last-child { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.node-lanes { display: grid; gap: var(--space-2); }
.lane { display: grid; grid-template-columns: auto minmax(0, 1fr) 72px 92px; align-items: center; gap: var(--space-3); font-size: var(--fs-s); }
.lane-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.lane-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--blue)); }
.lane-bar.warn i { background: var(--warn); }
.lane-bar.bad i { background: var(--bad); }
.lane-val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.lane-val small { font-weight: 500; color: var(--muted); }
.lane-ms { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.lane .badge { justify-self: end; }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.node-note { margin: 0; font-size: var(--fs-s); color: var(--muted); }
@media (max-width: 640px) {
  .node-grid { grid-template-columns: 1fr; }
  .node-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lane { grid-template-columns: auto minmax(0, 1fr) 64px; }
  .lane .badge, .lane-ms { grid-column: 2 / -1; justify-self: start; }
}

/* Caricamento a scheletro: la forma della sezione con un riflesso che scorre */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skel { display: grid; gap: var(--space-4); animation: skel-in .25s ease-out both; }
@keyframes skel-in { from { opacity: 0; } }
.skel i {
  display: block; border-radius: 8px;
  --sk: color-mix(in srgb, var(--surface-2) 82%, var(--text));
  --sk-hi: color-mix(in srgb, var(--surface-2) 64%, var(--text));
  background: linear-gradient(100deg, var(--sk) 30%, var(--sk-hi) 50%, var(--sk) 70%);
  background-size: 300% 100%; animation: skel-shine 1.3s ease-in-out infinite;
}
@keyframes skel-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skel-line { height: 12px; margin: 7px 0; }
.skel-line.h22 { height: 22px; } .skel-line.h18 { height: 18px; }
.skel-line.w15 { width: 15%; } .skel-line.w30 { width: 30%; } .skel-line.w40 { width: 40%; } .skel-line.w50 { width: 50%; }
.skel-line.w55 { width: 55%; } .skel-line.w60 { width: 60%; } .skel-line.w70 { width: 70%; } .skel-line.w75 { width: 75%; } .skel-line.w80 { width: 80%; }
.skel-head { display: flex; align-items: center; gap: var(--space-3); padding-bottom: var(--space-2); }
.skel-head > div { flex: 1; }
.skel-ico { width: 38px; height: 38px; flex: none; border-radius: 11px !important; }
.skel-ico.s { width: 30px; height: 30px; border-radius: 9px !important; margin-bottom: var(--space-2); }
.skel-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.skel-tile { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.skel-list { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); overflow: hidden; }
.skel-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 90px; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); }
.skel-row:first-child { border-top: 0; }
.skel-row > div { min-width: 0; }
.skel-row .skel-line.w15 { width: 100%; }
.skel-thumb { width: 44px; height: 44px; border-radius: 10px !important; }
.skel-row:nth-child(2) i { animation-delay: .08s; } .skel-row:nth-child(3) i { animation-delay: .16s; }
.skel-row:nth-child(4) i { animation-delay: .24s; } .skel-row:nth-child(5) i { animation-delay: .32s; } .skel-row:nth-child(6) i { animation-delay: .4s; }
@media (max-width: 640px) {
  .skel-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skel-row { grid-template-columns: 40px minmax(0, 1fr) 64px; }
}
@media (prefers-reduced-motion: reduce) { .skel i { animation: none; } }
/* Scheletro: in chiaro i blocchi devono restare tenui (la mescola del tema scuro qui veniva troppo grigia) */
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .skel i { --sk: color-mix(in srgb, var(--surface-2) 94%, var(--text)); --sk-hi: color-mix(in srgb, var(--surface-2) 86%, var(--text)); } }
:root[data-theme="light"] .skel i { --sk: color-mix(in srgb, var(--surface-2) 94%, var(--text)); --sk-hi: color-mix(in srgb, var(--surface-2) 86%, var(--text)); }

/* Schede Cluster v2: id come titolo, info in griglia, store nel riquadro dell'icona "i" */
.node-head { position: relative; }
.node-head .node-title { flex: 1; min-width: 0; }
.node-head .node-title b { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.node-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); margin: 0; padding: var(--space-3) 0 0; border-top: 1px solid var(--line); }
.node-info dt { font-size: 11.5px; color: var(--muted); margin: 0 0 2px; }
.node-info dd { margin: 0; font-size: var(--fs-s); font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-pop { position: relative; flex: none; }
.lane-pop > summary { list-style: none; }
.lane-pop > summary::-webkit-details-marker { display: none; }
.lane-pop[open] > summary { background: var(--surface-2); color: var(--text); }
.lane-pop-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(340px, 82vw);
  display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22); animation: pop-in .14s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.lane-pop-title { font-size: 12px; font-weight: 600; color: var(--muted); }
.node-info > div:first-child { grid-column: 1 / -1; }   /* il nome per intero sulla prima riga */

/* Righe dei prodotti e box Home: si adattano allo spazio reale dell'area centrale (#main).
   Solo per finestre intermedie desktop/tablet (tra 861px di viewport e 960px di container #main),
   senza mai sovrascrivere il layout mobile/tablet sotto 860px. */
#main { container-type: inline-size; container-name: main; }
@media (min-width: 861px) {
  @container main (max-width: 960px) {
    .prow { grid-template-columns: 44px minmax(0, 1fr) 286px 96px; row-gap: 8px; }
    .prow.no-img { grid-template-columns: minmax(0, 1fr) 286px 96px; }
    .prow .meter-cell { order: 5; grid-column: 2 / -1; }
    .prow.no-img .meter-cell { grid-column: 1 / -1; }
    .prow .meter-wrap { flex-direction: row; align-items: center; gap: 10px; }
    .prow .meter-bar { flex: 1; max-width: 220px; }
  }
  @container main (max-width: 780px) {
    .deal-hero {
      flex-direction: column;
      align-items: flex-start;
      gap: 12px;
      padding: 15px 16px;
    }
    .deal-hero-content { width: 100%; }
    .btn-deal-hero { width: 100%; justify-content: center; }
    .group-head .grange { display: none; }
  }
}
/* Riquadro degli store: sempre una riga per store, anche sul telefono */
.lane-pop-body .lane { grid-template-columns: auto minmax(0, 1fr) 58px 62px; gap: var(--space-2); }
.lane-pop-body .lane-ms { grid-column: auto; justify-self: end; }
/* Titolo della scheda: se lo spazio è poco l'etichetta Master/Worker va sotto l'id */
.node-head .node-title { flex-wrap: wrap; row-gap: 2px; }

/* Impostazioni: schede a pillola con icona (come i filtri delle altre sezioni) e nota in un riquadro */
.seg-tabs { display: flex; width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; margin-bottom: var(--space-4); }
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 7px var(--space-3); }
.seg-tabs button .i { width: 16px; height: 16px; opacity: .85; }
.seg-tabs button[data-st="fonti"] .i      { color: var(--blue); }
.seg-tabs button[data-st="avvisi"] .i     { color: var(--deal); }
.seg-tabs button[data-st="notifiche"] .i  { color: var(--violet); }
.seg-tabs button[data-st="ai"] .i         { color: var(--teal); }
.seg-tabs button[data-st="sistema"] .i    { color: var(--ok); }
.seg-tabs button.on .i { opacity: 1; }
.tab-note { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-m); background: var(--surface-2); color: var(--muted); font-size: var(--fs-s); }
.tab-note .i { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--info, var(--blue)); }
.tab-note p { margin: 0; }

/* Riquadri delle Impostazioni: tutti col modello delle Fonti, colore della sezione */
.panel.source[data-tone="view"] { --st: var(--tone, var(--blue)); }
.source-body > .row { padding: var(--space-3) 0 var(--space-1); }
.source-body > .setting:first-child { border-top: 0; }
.source-body > .stack { padding-top: var(--space-3) !important; }
/* Riquadri con solo pulsanti: i pulsanti stanno nell'intestazione, a destra (sotto, sul telefono) */
.source-head { flex-wrap: wrap; }
.source-head .source-title { min-width: 200px; }
.head-acts { flex: none; gap: var(--space-2); }
.panel.source:not(:has(.source-body)) .source-head { border-bottom: 0; }

/* Caselle "check" con lo stesso aspetto degli interruttori (prima: caselle arancioni accanto agli interruttori) */
.check input {
  appearance: none; -webkit-appearance: none; position: relative; width: 38px; height: 22px; margin: 1px 0 0;
  border-radius: 11px; background: var(--line); cursor: pointer; transition: background .15s;
}
.check input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.check input:checked { background: var(--ok); }
.check input:checked::after { transform: translateX(16px); background: #fff; }
.check input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Conferme di azioni distruttive: il pulsante di conferma è pieno, rosso, ben distinto da "Annulla" */
.confirm .btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.confirm .btn-danger:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.chat-empty p { margin: 0 0 var(--space-3); color: var(--muted); }
.chat-empty .chip { cursor: pointer; }
/* Riquadro degli store: colonne Store · barra · Velocità · Pagina · Rete */
.lane-pop-body { width: min(400px, 88vw); }
.lane-pop-body .lane { grid-template-columns: auto minmax(40px, 1fr) 58px 62px 52px; }
.lane-pop-body .lane-head { font-size: 11px; color: var(--muted); padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.lane-pop-body .lane-head span:nth-child(n+3) { text-align: right; }
.lane-ping { color: var(--teal); }

/* Schede Cluster: titolo master-1 / worker-N; il ruolo è nel suggerimento dell'icona grande */
.node-info > div:first-child { grid-column: auto; }   /* griglia 2×2: Nome · ID / Sistema · Online da */
.node-icon[data-tip] { position: relative; cursor: help; }
.node-icon[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 8px); z-index: 30;
  white-space: nowrap; padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: var(--text); color: var(--bg); box-shadow: 0 8px 20px rgba(0, 0, 0, .22);
  opacity: 0; transform: translateY(-3px); pointer-events: none; transition: opacity .12s, transform .12s;
}
.node-icon[data-tip]:hover::after, .node-icon[data-tip]:focus-visible::after { opacity: 1; transform: none; }
/* Riquadro degli store nel riquadro "i": Store · Barra · Velocità · Pagina · Rete */
.lane-pop-body { width: min(420px, 92vw); }
.lane-pop-body .lane { grid-template-columns: auto minmax(30px, 1fr) 56px 60px 50px; gap: 8px; }
/* Riquadro "i" agganciato alla scheda intera: resta dentro la scheda anche a sinistra e sul telefono */
.node-card { position: relative; }
.lane-pop { position: static; }
.lane-pop-body { left: var(--space-3); right: var(--space-3); top: 68px; width: auto; }

/* Codici AliExpress del periodo: una riga per codice, che va a capo sul telefono */
.promo-rows { display: grid; gap: var(--space-3); padding-top: var(--space-2); }
.promo-row { display: grid; grid-template-columns: minmax(120px, 1.3fr) minmax(130px, 1.1fr) repeat(2, minmax(100px, 1fr)) minmax(140px, 1.1fr) auto auto; gap: var(--space-3); align-items: end; padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.promo-row.gone input[data-k="expires"] { color: var(--bad); }
.promo-row.gone { opacity: .7; }
.promo-row input[data-k="code"] { text-transform: uppercase; font-weight: 600; letter-spacing: .02em; }
.promo-amt { display: flex; gap: var(--space-1); }
.promo-amt input { min-width: 0; flex: 1; }
.promo-amt select { width: 56px; flex: none; }
.promo-on { justify-items: start; }
.promo-on .switch { margin: 8px 0; }
.promo-row .icon-btn { margin-bottom: 3px; }
.promo-empty { margin: 0; }
@media (max-width: 860px) {
  .promo-row { grid-template-columns: 1fr 1fr; }
  /* Attivo e cestino nella stessa cella, accanto alla scadenza */
  .promo-row .promo-on, .promo-row .icon-btn { grid-row: 3; grid-column: 2; }
  .promo-row .icon-btn { justify-self: end; align-self: end; }
}

/* Evidenziazione animata del prodotto dalla notifica o dal radar */
@keyframes prowGlow {
  0% {
    box-shadow: 0 0 0 3px var(--deal, #10b981), 0 0 20px rgba(16, 185, 129, 0.4);
    background-color: rgba(16, 185, 129, 0.14);
  }
  35% {
    box-shadow: 0 0 0 5px var(--deal, #10b981), 0 0 25px rgba(16, 185, 129, 0.55);
    background-color: rgba(16, 185, 129, 0.22);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    background-color: transparent;
  }
}

.prow.prow-highlight {
  animation: prowGlow 3.5s ease-out forwards !important;
  border-radius: var(--rad, 10px);
  position: relative;
  z-index: 5;
}

.notif-jump-title:hover, .radar-jump-title:hover, [data-jump-asin]:hover {
  text-decoration: underline;
  color: var(--deal, #10b981);
  cursor: pointer;
}

/* Badge versione nel brand e nel footer nav */
.brand-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--deal) 14%, var(--surface));
  color: var(--deal);
  border: 1px solid color-mix(in srgb, var(--deal) 35%, transparent);
  letter-spacing: .02em;
  line-height: 1.2;
  margin-left: 4px;
  box-shadow: 0 0 10px color-mix(in srgb, var(--deal) 20%, transparent);
}
.brand-badge.brand-v3 {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(16, 185, 129, .5);
}

/* Home Quick Bar */
.home-quick-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all .15s ease;
}
.quick-chip:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  transform: translateY(-1px);
  text-decoration: none;
}
.quick-chip .i { width: 15px; height: 15px; color: var(--muted); }
.quick-chip b {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.quick-chip.highlight-vip {
  border-color: color-mix(in srgb, var(--vip) 40%, var(--line));
  background: color-mix(in srgb, var(--vip) 8%, var(--surface));
}
.quick-chip.highlight-vip .i { color: var(--vip); }
.quick-chip.highlight-vip b {
  background: color-mix(in srgb, var(--vip) 25%, transparent);
  color: var(--vip);
}
.quick-chip.highlight-deal {
  border-color: color-mix(in srgb, var(--deal) 45%, var(--line));
  background: color-mix(in srgb, var(--deal) 8%, var(--surface));
  box-shadow: 0 2px 12px color-mix(in srgb, var(--deal) 18%, transparent);
}
.quick-chip.highlight-deal b {
  background: var(--deal);
  color: var(--deal-ink);
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.chip-dot.deal-active {
  background: var(--deal);
  box-shadow: 0 0 8px var(--deal);
  animation: pulse-dot 2s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(1.2); }
}

.empty-compact {
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-home-deals {
  padding: var(--space-6) var(--space-5) !important;
  text-align: center;
}
.empty-home-deals b {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-home-deals p {
  max-width: 54ch;
  margin: 0 auto;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}
.version-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 6px var(--space-3) 2px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.version-foot b {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Sezione Moduli & Versioni (v3.0) */
.module-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 12%, var(--surface)) 0%, var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line));
  border-radius: var(--radius-l);
  margin-bottom: var(--space-4);
}
.module-hero-info h3 {
  margin: 0 0 4px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-hero-info p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-s);
}
.module-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 15%, var(--surface));
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  font-weight: 700;
  font-size: 13px;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-4);
}
.mod-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: var(--space-4);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: border-color .15s ease, transform .15s ease;
}
.mod-card:hover {
  border-color: color-mix(in srgb, var(--blue) 50%, var(--line));
  transform: translateY(-1px);
}
.mod-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: 8px;
}
.mod-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--text);
}
.mod-type {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
.mod-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mod-ver {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--blue) 14%, var(--surface));
  color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
  font-variant-numeric: tabular-nums;
}
.mod-runtime {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
}
.mod-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  flex: 1;
}
.mod-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.mod-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-weight: 600;
}
.mod-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

/* ---------- Radar Deal Cards (v3.0 Overhaul) ---------- */
.radar-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.radar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 12px 16px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.radar-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.radar-card.is-glitch {
  border-left: 4px solid var(--deal-amber);
  background: linear-gradient(90deg, rgba(245, 158, 11, .07), var(--surface) 28%);
}

.radar-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.radar-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-s);
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 2px;
  flex: none;
}

.radar-details {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radar-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.radar-title.in-catalog {
  color: var(--focus);
}

.radar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.radar-channel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 130, 246, .14);
  color: #60a5fa;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.radar-glitch-badge {
  background: var(--deal-amber-soft);
  color: var(--deal-amber);
  border: 1px solid rgba(245, 158, 11, .35);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.radar-side {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: none;
}

.radar-price-block {
  text-align: right;
  min-width: 90px;
}
.radar-price {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.radar-card.is-glitch .radar-price {
  color: var(--deal-amber);
}

.radar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.radar-actions .btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

/* Quick Threshold Calculation Chips */
.th-quick-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.th-chip {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.th-chip:hover {
  background: var(--line);
  color: var(--text);
  border-color: var(--focus);
}

@media (max-width: 720px) {
  .radar-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .radar-side {
    width: 100%;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
}

/* ---------- Copilot & AI Briefing Drawer (UI/UX Pro Max) ---------- */
.copilot-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-3);
}

.copilot-briefing-card {
  background: linear-gradient(140deg, color-mix(in srgb, var(--violet) 12%, var(--surface)) 0%, var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--violet) 28%, var(--line));
  border-radius: var(--radius-l);
  padding: var(--space-4);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
  position: relative;
  overflow: hidden;
}

.copilot-briefing-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--violet), var(--teal), var(--deal));
}

.cbc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.cbc-head-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.cbc-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  color: var(--violet);
  letter-spacing: -0.01em;
}

.cbc-badge .i {
  width: 17px;
  height: 17px;
  color: var(--violet);
}

.cbc-time {
  font-size: 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--violet) 8%, var(--surface-2));
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--violet) 20%, var(--line));
}

.cbc-actions {
  display: flex;
  align-items: center;
}

.cbc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--violet) 30%, var(--line));
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}

.cbc-btn:hover {
  background: color-mix(in srgb, var(--violet) 20%, var(--surface-2));
  border-color: var(--violet);
}

.cbc-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.cbc-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.cbc-content {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}

.cbc-heading {
  font-weight: 700;
  color: var(--violet);
  margin: 10px 0 4px;
  font-size: 13px;
}

.cbc-heading:first-child {
  margin-top: 0;
}

.cbc-list {
  margin: 4px 0 8px 16px;
  padding: 0;
  display: grid;
  gap: 4px;
}

.cbc-list li {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.cbc-list li strong,
.cbc-p strong {
  color: var(--text);
  font-weight: 700;
}

.cbc-p {
  margin: 0 0 6px;
}

.cbc-p:last-child {
  margin-bottom: 0;
}

.cbc-empty {
  text-align: center;
  padding: var(--space-4) var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.cbc-empty p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 380px;
  line-height: 1.5;
}

.cbc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--space-4);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.copilot-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.copilot-prompts-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.copilot-prompts .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.copilot-prompts .chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}

.copilot-prompts .chip:hover {
  border-color: var(--violet);
  background: color-mix(in srgb, var(--violet) 12%, var(--surface));
  transform: translateY(-1px);
}

.msg.ai {
  border-left: 2px solid var(--violet);
  line-height: 1.55;
}

.msg.ai strong {
  font-weight: 700;
  color: var(--text);
}

.msg.ai code {
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.dot-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--violet) 70%, transparent);
  animation: pulse-dot 1.4s infinite cubic-bezier(0.66, 0, 0, 1);
  vertical-align: middle;
}

@keyframes pulse-dot {
  to {
    box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
  }
}

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

.i.spin {
  animation: spin 0.85s linear infinite;
}


/* =========================================================
   DIAGNOSTICA MOTORE HFT & STATO NEGOZI
   ========================================================= */
.topbar-engine.is-bad {
  border-color: rgba(239, 68, 68, 0.6) !important;
  background: rgba(239, 68, 68, 0.12) !important;
  color: #ef4444 !important;
  animation: pulse-border-bad 1.5s infinite ease-in-out;
}
.topbar-engine.is-warn {
  border-color: rgba(245, 158, 11, 0.6) !important;
  background: rgba(245, 158, 11, 0.12) !important;
  color: #f59e0b !important;
}

@keyframes pulse-border-bad {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
}

.diag-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.diag-store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.diag-store-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 11px 13px;
  transition: all .15s ease;
}
.diag-store-card.is-ok {
  border-color: rgba(16, 185, 129, 0.4);
  background: color-mix(in srgb, #10b981 4%, var(--surface));
}
.diag-store-card.is-err {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.05);
}
.diag-store-card.is-warn {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.05);
}

.diag-store-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.diag-store-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.diag-store-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}
.diag-store-stat b {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text);
}

.diag-log-box {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  max-height: 180px;
  overflow-y: auto;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.diag-log-line {
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-all;
}
.diag-log-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.05);
  font-size: 13px;
  color: var(--text);
}

/* =========================================================
   RADAR & BENCHMARK VELOCITÀ PRICEBOT VS TELEGRAM
   ========================================================= */
.radar-nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.tab-pill .i { width: 16px; height: 16px; }
.tab-pill:hover {
  background: var(--surface-2);
  color: var(--text);
}
.tab-pill.on {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.badge-speed {
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 2px 7px !important;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-win {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #059669 !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
}
.badge-loss {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #d97706 !important;
  border: 1px solid rgba(245, 158, 11, 0.35) !important;
}

.bench-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bench-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.bench-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.bench-row:hover td {
  background: var(--surface-2);
}
.bench-row.is-win td {
  background: rgba(16, 185, 129, 0.02);
}
.bench-col-prod {
  min-width: 220px;
  max-width: 340px;
}
.bench-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.bench-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bench-col-price b {
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bench-col-time {
  white-space: nowrap;
}
.bench-time-val {
  font-weight: 600;
  color: var(--text);
  font-size: 12.5px;
}
.bench-col-delta {
  white-space: nowrap;
}

.spinner-s {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
}
