:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1b1f27;
  --muted: #6b7280;
  /* colore principale scelto dall'utente (Personalizza dashboard) */
  --accent-base: #4f46e5;
  --accent: var(--accent-base);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --pokemon: #eab308;
  --onepiece: #dc2626;
  --dragonball: #ea580c;
  --radius: 10px;
  /* colori delle serie nei grafici (palette categoriale validata, slot 1-3) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
}
/* Tema scuro: segue il sistema, oppure forzato da Personalizza (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --border: #262b35; --text: #e6e8ec; --muted: #8b93a1;
    --accent: color-mix(in srgb, var(--accent-base) 70%, white);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --border: #262b35; --text: #e6e8ec; --muted: #8b93a1;
  --accent: color-mix(in srgb, var(--accent-base) 70%, white);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; display: flex; min-height: 100vh; background: var(--bg); }

.sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; }
.brand { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; padding: 0 8px; }
.logo { color: var(--accent); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--bg); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent); }
.demo-badge { margin-top: auto; font-size: 12px; padding: 8px 10px; border-radius: 8px; background: #fef3c7; color: #92400e; }
.demo-badge.info { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

main { flex: 1; padding: 28px 32px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel.flush { padding: 0; overflow-x: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.game-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.game-row:last-child { border-bottom: 0; }
.game-row .bar { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.game-row .bar span { display: block; height: 100%; }
.game-row .name { width: 110px; font-weight: 600; }
.game-row .val { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.pokemon { background: var(--pokemon); } .dot.onepiece { background: var(--onepiece); } .dot.dragonball { background: var(--dragonball); }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#search { max-width: 320px; }
.chips { display: flex; gap: 6px; }
.chip { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
/* Tipo di prodotto: seconda riga sotto i giochi */
.sub-chips { flex-basis: 100%; order: 10; flex-wrap: wrap; margin-top: -4px; }
.sub-chips .chip { font-size: 13px; padding: 4px 11px; }
.sub-chips .chip .n { opacity: .65; margin-left: 4px; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.pill.slab { background: #fef3c7; color: #92400e; font-weight: 700; }
:root[data-theme="dark"] .pill.slab { background: rgba(251, 191, 36, .18); color: #fcd34d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.slab { background: rgba(251, 191, 36, .18); color: #fcd34d; } }
.form-grid [hidden] { display: none; }

.btn { text-decoration: none; display: inline-block; font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent-base); border-color: var(--accent-base); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: progress; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.card-name { font-weight: 600; }
.card-sub { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px; margin: 0; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.pill.ok { background: #d1fae5; color: #065f46; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.err { background: #fee2e2; color: #991b1b; }

.status-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.status-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.status-card strong { font-size: 16px; }

/* Drawer dettaglio */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; z-index: 10; }
.drawer[hidden] { display: none; }
.drawer-inner { width: min(560px, 100%); background: var(--surface); height: 100%; overflow-y: auto; padding: 24px; position: relative; }
.close { position: absolute; top: 14px; right: 16px; border: 0; background: none; font-size: 24px; color: var(--muted); cursor: pointer; }
.detail-head { display: flex; gap: 16px; margin-bottom: 20px; }
.detail-head img { width: 110px; border-radius: 8px; border: 1px solid var(--border); }
.detail-head .ph { width: 110px; height: 154px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.detail-head h2 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 20px; margin: 0 0 6px; }
.meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-head h3 { margin: 0; font-size: 15px; }
.market { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.market .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sources { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.source { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.source .s-name { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.source .s-val { font-size: 18px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.source .s-sub { font-size: 11px; color: var(--muted); }
.source.error .s-val { font-size: 12px; color: var(--err); font-weight: 500; }
.publish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.publish-grid label, .form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.platforms { display: flex; gap: 14px; margin-bottom: 14px; }
.platforms label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.platforms input, .check input { width: auto; }
.btn.publish { width: 100%; padding: 12px; font-size: 15px; }
.listing { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.listing:last-child { border-bottom: 0; }
.drawer-actions { display: flex; gap: 8px; margin-top: 20px; }

/* Dialog form */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: min(680px, 95vw); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; padding-top: 18px; }
.catalog { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.catalog-head { font-weight: 600; margin-bottom: 8px; }
.catalog-row { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: 8px; }
.ct-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; max-height: 300px; overflow-y: auto; }
.ct-results:empty { display: none; }
.ct-results .msg { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.ct-hit { font: inherit; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.ct-hit:hover { border-color: var(--accent); }
.ct-hit img, .ct-hit .ph-sm { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; border-radius: 4px; background: var(--bg); }
.ct-hit .n { font-size: 12px; font-weight: 600; line-height: 1.2; }
.ct-hit .s { font-size: 11px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 8px; z-index: 20; font-weight: 500; }

@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 16px; }
  nav { flex-direction: row; }
  .demo-badge { margin: 0; }
  main { padding: 20px 16px; }
  .kpis, .status-list { grid-template-columns: 1fr 1fr; }
  .grid-2, .sources { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-3 { grid-column: span 2; }
  .catalog-row { grid-template-columns: 1fr 1fr; }
}

.head-actions { display: flex; gap: 8px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; }
.bulk-bar span { font-weight: 600; margin-right: auto; }
.bulk-bar[hidden] { display: none; }
.table .sel { width: 36px; padding-right: 0; }
.table .sel input { width: auto; }
.form-grid.five { grid-template-columns: repeat(5, 1fr); }
.form-actions { align-items: center; }
.form-actions .card-sub { margin-right: auto; }

.sale-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sale-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.sale-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Grafico */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i, .chart-tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .dlabel { fill: var(--text); font-size: 11px; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; top: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); pointer-events: none; min-width: 150px; }
.chart-tip div { display: flex; align-items: center; margin-top: 4px; color: var(--muted); }
.chart-tip b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 8px; font-size: 12px; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table .table td, .chart-table .table th { padding: 6px 8px; }

/* Import */
#import-file { margin: 12px 0; }
.import-table { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.import-table .table td, .import-table .table th { padding: 6px 10px; font-size: 12px; }
.import-errors { color: var(--err); font-size: 12px; margin: 0 0 10px; padding-left: 18px; }
#import-dialog { width: min(820px, 95vw); }

@media (max-width: 900px) {
  .form-grid.five, .sale-grid { grid-template-columns: 1fr 1fr; }
  .head-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* Pagina di benvenuto e accesso */
body.welcome { display: grid; grid-template-columns: 1.2fr 1fr; min-height: 100vh; }
.hero { position: relative; overflow: hidden; padding: 32px 48px; display: flex; flex-direction: column; color: #eef0ff;
  background: radial-gradient(circle at 20% 10%, #4f46e5 0%, transparent 55%), radial-gradient(circle at 90% 90%, #7c3aed 0%, transparent 50%), #15132b; }
.hero .brand { font-size: 20px; padding: 0; }
.hero .logo { color: #c7d2fe; }
.hero-body { margin: auto 0; max-width: 520px; position: relative; z-index: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 600; color: #a5b4fc; margin: 0 0 14px; }
.hero h1 { font-size: 40px; line-height: 1.1; margin: 0 0 18px; letter-spacing: -.02em; }
.lead { font-size: 16px; line-height: 1.6; color: #cdd1f5; margin: 0 0 28px; }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; font-size: 14px; color: #e0e3ff; }
.features li { display: flex; align-items: center; gap: 4px; }
.features .dot { margin-right: 2px; }
.features li > :last-child { margin-right: 8px; }
.fi { width: 26px; display: inline-grid; place-items: center; color: #a5b4fc; font-weight: 700; margin-right: 8px; }
.fan { position: absolute; right: -40px; bottom: -60px; width: 300px; height: 320px; opacity: .9; }
.tcg { position: absolute; bottom: 0; left: 60px; width: 160px; height: 224px; border-radius: 12px; border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 20px 40px rgba(0,0,0,.35); transform-origin: 50% 100%; }
.tcg.c1 { background: linear-gradient(150deg, #fde047, #eab308); transform: rotate(-18deg); }
.tcg.c2 { background: linear-gradient(150deg, #fb923c, #ea580c); transform: rotate(0deg); }
.tcg.c3 { background: linear-gradient(150deg, #f87171, #dc2626); transform: rotate(18deg); }

.auth { display: grid; place-items: center; padding: 32px 16px; background: var(--bg); }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h2 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 22px; margin: 0; }
.auth-card > .card-sub { margin: -8px 0 4px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.auth-card label[hidden] { display: none; }
.auth-card .check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.auth-card .check input { width: auto; }
.auth-card .btn { padding: 11px; font-size: 15px; }
.auth-error { margin: 0; padding: 8px 10px; border-radius: 8px; background: #fee2e2; color: #991b1b; font-size: 13px; }
.auth-error[hidden] { display: none; }
.auth-note { text-align: center; margin: 0; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 0 10px; }
.user-box .who { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  body.welcome { grid-template-columns: 1fr; }
  .hero { padding: 24px 16px 40px; }
  .hero h1 { font-size: 32px; }
  .hero-body { margin: 32px 0 0; }
  .fan { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
}

/* Marchio */
.brand-wrap { display: flex; flex-direction: column; gap: 2px; }
.brand-tcg { color: var(--accent); }
.shop-name { font-size: 12px; color: var(--muted); padding: 0 8px 0 30px; }
.shop-name:empty { display: none; }

/* Dashboard a widget */
.widgets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; position: relative; }
.widget.size-s { grid-column: span 1; }
.widget.size-m { grid-column: span 2; }
.widget.size-l { grid-column: span 4; }
.widget.kpi-w .label { color: var(--muted); font-size: 12px; }
.widget.kpi-w .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.widget.kpi-w .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.widget h2 { margin-bottom: 12px; }
.widget-tools { display: none; }
.editing .widget { border-style: dashed; border-color: var(--accent); cursor: grab; }
.editing .widget.dragging { opacity: .4; }
.editing .widget.drop-before { box-shadow: -4px 0 0 0 var(--accent); }
.editing .widget.drop-after { box-shadow: 4px 0 0 0 var(--accent); }
.editing .widget-tools { display: flex; gap: 6px; align-items: center; margin: -4px 0 12px; }
.widget-tools .handle { color: var(--muted); font-size: 16px; cursor: grab; user-select: none; }
.widget-tools input { flex: 1; min-width: 0; padding: 4px 8px; font-size: 12px; }
.size-btns { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.size-btns button { font: inherit; font-size: 11px; border: 0; background: var(--surface); color: var(--muted); padding: 4px 7px; cursor: pointer; }
.size-btns button.on { background: var(--accent-base); color: #fff; }
.icon-btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; }
.icon-btn:hover { color: var(--err); }
.empty-w { color: var(--muted); font-size: 13px; margin: 0; }
.mini-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.mini-row:last-child { border-bottom: 0; }
.mini-row .r { white-space: nowrap; font-variant-numeric: tabular-nums; }

.customize { border-color: var(--accent); }
.customize-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.customize-head .card-sub { margin: -8px 0 0; }
.customize-grid { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 14px; align-items: end; }
.customize-grid label, .accent-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 2px var(--text); }
.swatches input[type=color] { width: 34px; height: 30px; padding: 2px; cursor: pointer; }
.hidden-widgets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.hidden-widgets:empty { display: none; }
.hidden-widgets .lbl { font-size: 12px; color: var(--muted); margin-right: 4px; }
.hidden-widgets button { font: inherit; font-size: 12px; border: 1px dashed var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.hidden-widgets button:hover { border-color: var(--accent); color: var(--accent); }

/* Grafico vendite mensili */
.bars .bar-rect { fill: var(--series-1); }
.bars .bar-rect.hover { fill: color-mix(in srgb, var(--series-1) 75%, var(--text)); }

/* Immagini pagina di benvenuto */
.branding-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.branding-slot { display: flex; flex-direction: column; gap: 6px; }
.branding-preview { height: 160px; border-radius: 10px; border: 1px solid var(--border); display: grid; place-items: center; color: #c7c9e8; font-size: 12px;
  background: #15132b center / cover no-repeat; overflow: hidden; }
.branding-preview.hero-preview { background-size: contain; background-color: var(--bg); color: var(--muted); }
.branding-slot label.btn { cursor: pointer; }

@media (max-width: 1100px) {
  .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget.size-m, .widget.size-l { grid-column: span 2; }
}
@media (max-width: 900px) {
  .customize-grid, .branding-grid { grid-template-columns: 1fr; }
  .customize-head { flex-direction: column; }
}
@media (max-width: 560px) {
  .widgets { grid-template-columns: 1fr; }
  .widget.size-s, .widget.size-m, .widget.size-l { grid-column: span 1; }
}

/* Pagina di benvenuto: sfondo e illustrazione caricati dall'utente */
.hero .brand-tcg { color: #c7d2fe; }
.hero.custom-bg { background: linear-gradient(90deg, rgba(14,12,34,.92) 0%, rgba(14,12,34,.7) 45%, rgba(14,12,34,.25) 100%), var(--hero-bg) center / cover no-repeat, #15132b; }
.hero-art { position: absolute; right: 24px; bottom: 0; max-width: 46%; max-height: 62%; object-fit: contain; object-position: bottom right;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,.45)); pointer-events: none; }
.hero-art[hidden], .fan[hidden] { display: none; }
.preview-note { margin: 0 0 12px; font-size: 13px; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--text); }
.preview-note[hidden] { display: none; }
.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; }
@media (max-width: 900px) {
  .hero-art { position: static; max-width: 70%; max-height: 260px; margin: 24px auto 0; display: block; }
}

/* Foto delle carte */
.table .thumb-col { width: 56px; padding-right: 0; }
.thumb { display: block; width: 40px; height: 56px; padding: 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.empty { cursor: pointer; border-style: dashed; color: var(--muted); font-size: 18px; display: grid; place-items: center; }
.thumb.empty:hover { border-color: var(--accent); color: var(--accent); }
.thumb-pop { position: fixed; z-index: 30; width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.25); pointer-events: none; }
.thumb-pop img { width: 100%; display: block; border-radius: 8px; }
.thumb-pop[hidden] { display: none; }

.detail-photo { padding: 0; border: 0; background: none; cursor: zoom-in; flex-shrink: 0; }
.detail-photo img { width: 110px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.detail-photo .ph { line-height: 1.5; text-align: center; }
.detail-photo .ph span { color: var(--accent); font-weight: 600; }

.photo-dialog { width: min(860px, 95vw); padding: 0; position: relative; }
.photo-dialog .close { z-index: 1; }
.photo-view { display: grid; grid-template-columns: minmax(0, 1.1fr) 1fr; }
.photo-frame { background: #0e0f13; display: grid; place-items: center; padding: 20px; min-height: 420px; }
.photo-frame img { max-width: 100%; max-height: 75vh; border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.photo-frame .ph.big { color: #9aa0ad; font-size: 14px; }
.photo-info { padding: 28px 24px; display: flex; flex-direction: column; gap: 10px; }
.photo-info h2 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 20px; margin: 0; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-actions label.btn { cursor: pointer; }
.photo-actions [hidden] { display: none; }
@media (max-width: 700px) {
  .photo-view { grid-template-columns: 1fr; }
  .photo-frame { min-height: 280px; }
}

/* Inventario: scelta tabella / griglia */
.view-toggle { display: inline-flex; margin-left: auto; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { font: inherit; font-size: 13px; border: 0; background: var(--surface); color: var(--muted); padding: 7px 12px; cursor: pointer; }
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.grid-select { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.grid-select input { width: auto; }
.grid-select[hidden], .card-grid[hidden], #cards-table[hidden] { display: none; }

/* Griglia stile raccoglitore */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.card-grid > .empty { grid-column: 1 / -1; }
.gcard { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
.gcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.gcard.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.gimg { position: relative; display: block; width: 100%; aspect-ratio: 5 / 7; padding: 0; border: 0; background: var(--bg); cursor: zoom-in; }
.gimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gimg.empty { cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: 13px; border-bottom: 1px dashed var(--border); }
.gimg.empty:hover { color: var(--accent); }
.gsel { position: absolute; top: 8px; left: 8px; z-index: 2; background: var(--surface); border-radius: 6px; padding: 4px; line-height: 0; box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: pointer; }
.gsel input { width: 16px; height: 16px; margin: 0; }
.gqty { position: absolute; top: 8px; right: 8px; z-index: 2; background: rgba(15,17,21,.8); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 9px; font-variant-numeric: tabular-nums; }
.gfoil { position: absolute; bottom: 8px; left: 8px; background: linear-gradient(90deg, #a5b4fc, #f0abfc, #fde68a); color: #1b1f27; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.gbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gbody .card-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gbody .card-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gtags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.gprice { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.gprice strong { font-size: 16px; }
@media (max-width: 560px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .view-toggle { margin-left: 0; }
}

/* Barra superiore su schermi stretti: logo e utente sopra, menu scorrevole sotto */
@media (max-width: 900px) {
  .sidebar { flex-wrap: wrap; gap: 10px 16px; }
  .sidebar nav { order: 3; width: 100%; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  main { overflow-x: hidden; }
}

/* Pulsante opzioni (☰) e menu delle carte */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.table .menu-col { width: 44px; text-align: right; }
.menu-btn { font: inherit; font-size: 15px; line-height: 1; width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; cursor: pointer; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.menu-btn.gmenu { position: absolute; top: 8px; right: 8px; z-index: 3; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.gcard .gqty { right: 46px; top: 11px; }

.card-menu { position: fixed; z-index: 40; min-width: 270px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 14px 36px rgba(0,0,0,.22); }
.card-menu[hidden] { display: none; }
.card-menu .menu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; font-weight: 600; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.card-menu button { font: inherit; width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.card-menu button:hover:not([disabled]), .card-menu button:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.card-menu button[disabled] { color: var(--muted); cursor: not-allowed; }
.card-menu .mi { width: 18px; text-align: center; color: var(--muted); }
.card-menu .pill { margin-left: auto; }
.card-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu-note { margin: 4px 10px 6px; font-size: 12px; color: var(--muted); }
#publish-dialog { width: min(520px, 95vw); }

/* Logo del negozio */
.shop-line { display: flex; align-items: center; gap: 8px; padding: 4px 8px 0; }
.shop-line[hidden] { display: none; }
.shop-line .shop-name { padding: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.shop-logo { display: block; object-fit: contain; }
.shop-logo[hidden] { display: none; }
#brand-logo[data-size="s"] { height: 24px; max-width: 60px; }
#brand-logo[data-size="m"] { height: 36px; max-width: 90px; }
#brand-logo[data-size="l"] { height: 52px; max-width: 120px; }

.app-header { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.app-header[hidden] { display: none; }
.app-header[data-size="s"] #header-logo { height: 40px; max-width: 200px; }
.app-header[data-size="m"] #header-logo { height: 64px; max-width: 300px; }
.app-header[data-size="l"] #header-logo { height: 96px; max-width: 420px; }
.app-header-name { font-weight: 700; font-size: 15px; }
.app-header-name:empty { display: none; }

.logo-field { display: grid; grid-template-columns: 120px 1fr 1.4fr; gap: 16px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.logo-preview { height: 80px; border: 1px dashed var(--border); border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 12px; overflow: hidden; }
.logo-preview img { max-width: 90%; max-height: 70px; object-fit: contain; }
.logo-controls { display: flex; flex-direction: column; gap: 6px; }
.logo-controls label.btn { cursor: pointer; }
.logo-controls [hidden] { display: none; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; }
.seg button { font: inherit; font-size: 12px; border: 0; background: var(--surface); color: var(--muted); padding: 6px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-checked="true"] { background: var(--accent-base); color: #fff; }
@media (max-width: 900px) {
  .logo-field { grid-template-columns: 1fr; }
  .shop-line { padding: 0; }
}
.demo-actions { align-items: center; } .demo-actions .card-sub { margin-right: auto; } .demo-actions [hidden] { display: none; }

/* Collegamenti nella barra laterale */
.conn-box { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.conn-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.conn-sync { font: inherit; font-size: 15px; line-height: 1; width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.conn-sync:hover { color: var(--accent); border-color: var(--accent); }
.conn-sync.spinning, #btn-sync-dialog.spinning { animation: spin 1s linear infinite; }
#btn-sync-dialog.spinning { animation: none; opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
.conn-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.conn-row { font: inherit; font-size: 13px; display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); padding: 4px 2px; border-radius: 6px; cursor: pointer; text-align: left; }
.conn-row:hover { background: var(--surface); }
.conn-name { flex: 1; }
.conn-state { font-size: 11px; color: var(--muted); }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.conn-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.conn-dot.warn { background: #f59e0b; }
.conn-dot.err { background: var(--err); }
.conn-dot.off { background: #9ca3af; }
.conn-time { font-size: 11px; color: var(--muted); margin-top: 4px; }

.conn-dialog { width: min(620px, 95vw); position: relative; }
.conn-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.conn-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.conn-card dl { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.conn-card dt { color: var(--muted); }
.conn-card dd { margin: 0; }
.conn-note { line-height: 1.5; }

/* Inventario: filtri, piattaforme, variazione */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar .btn[hidden] { display: none; }
.sort-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sort-field select { width: auto; }
#result-count { margin-left: auto; }
.filter-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.filter-panel[hidden] { display: none; }
.filter-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.pf-list { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pf { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 6px; border: 1px solid transparent; }
.pf-cardmarket { background: #e0e7ff; color: #1e3a8a; }
.pf-cardtrader { background: #dcfce7; color: #14532d; }
.pf-ebay { background: #fef3c7; color: #78350f; }
.pf.demo { background: transparent; border: 1px dashed var(--border); color: var(--muted); }
.gpf { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 2px; min-height: 20px; }
.chg { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.chg.up { color: var(--ok); }
.chg.down { color: var(--err); }
@media (max-width: 900px) {
  .conn-box { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
  .conn-head > span, .conn-time, .conn-name { display: none; }
  .conn-list { flex-direction: row; margin: 0; }
  #result-count { margin-left: 0; width: 100%; }
}

/* Barra laterale fissa: collegamenti e utente restano sempre in vista */
@media (min-width: 901px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}

/* Estensione Chrome */
.ext-status { margin: 4px 0 12px; }
.ext-token { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.ext-token[hidden] { display: none; }
.ext-token-row { display: flex; gap: 8px; }
.ext-token-row input { font-family: ui-monospace, Menlo, monospace; }
.ext-help { margin-top: 14px; font-size: 13px; }
.ext-help summary { cursor: pointer; color: var(--accent); }
.ext-help ol { line-height: 1.7; padding-left: 20px; }
#btn-ext-revoke[hidden] { display: none; }

/* Stato delle vendite */
.status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.status-bar .chips { flex-wrap: wrap; }
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #9ca3af; }
.sdot.ok { background: var(--ok); } .sdot.warn { background: #f59e0b; } .sdot.err { background: var(--err); } .sdot.info { background: #2563eb; }
.pill.info { background: #dbeafe; color: #1e40af; }
.status-select { width: auto; border: 0; font: inherit; font-size: 11px; padding: 2px 8px; cursor: pointer; }
.status-select:focus { outline: 2px solid var(--accent); }
.sale-cancelled td:not(:nth-child(4)):not(:last-child) { opacity: .45; text-decoration: line-through; }

/* Avvisi in cima alla pagina */
.banners { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.banners:empty { display: none; }
.banner { border-radius: 10px; padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--border); background: var(--surface); }
.banner a { color: var(--accent); font-weight: 600; }
.banner.admin { background: #312e81; color: #e0e7ff; border-color: #4338ca; }
.banner.trial { background: var(--accent-soft); }
.banner.warn { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.banner.info { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }
.banner .btn { margin-left: auto; }
.nav-admin { color: var(--accent) !important; font-weight: 700 !important; }
.locked { opacity: .55; }
.locked::after { content: ' 🔒'; }

/* Piano e team */
.plan-now { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.plan-now .big { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 18px; }
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.plan-card.current { border: 2px solid var(--accent); }
.plan-name { font-weight: 800; font-size: 18px; }
.plan-price { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-card ul { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 5px; font-size: 13px; flex: 1; }
.plan-card li.no { color: var(--muted); }
.plan-card li.yes { color: var(--text); }
.team-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.team-form input, .team-form select { flex: 1; min-width: 140px; }

/* Chiavi API */
.keys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.keys-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.link-btn { font: inherit; font-size: 11px; border: 0; background: none; color: var(--err); cursor: pointer; padding: 0; text-align: left; }

/* Amministrazione */
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 0; }
.new-shop { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; }
.new-shop[hidden] { display: none; }
.new-shop input, .new-shop select { flex: 1; min-width: 130px; }
#admin-shops select { width: auto; padding: 4px 6px; font-size: 12px; }
.admin-actions { white-space: nowrap; }
.admin-actions .btn + .btn { margin-left: 4px; }
.admin-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.admin-plan { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.admin-plan-head { display: flex; align-items: center; gap: 8px; }
.admin-plan-head input { font-weight: 700; max-width: 160px; }
.admin-plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.admin-plan-grid label, .admin-features label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.admin-features { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.admin-features label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 12px; }
.admin-features input { width: auto; }
.switch-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.switch-row input { width: auto; }
.audit { max-height: 360px; overflow-y: auto; }
.audit-row { display: grid; grid-template-columns: 130px 120px 1fr 160px; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
@media (max-width: 700px) { .audit-row { grid-template-columns: 1fr 1fr; } .admin-plan-grid { grid-template-columns: 1fr 1fr; } }
.auth-switch { text-align: center; margin: 0; font-size: 13px; color: var(--muted); } .auth-switch a { color: var(--accent); font-weight: 600; } .auth-switch[hidden], .auth-card label[hidden] { display: none; }

/* Prezzi e allarmi */
.nav-badge { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--err); color: #fff; font-size: 11px; font-weight: 700; text-align: center; margin-left: 4px; }
.nav-badge[hidden] { display: none; }
.upsell { border: 2px dashed var(--accent); }
.alert-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; margin: 12px 0; padding: 12px; background: var(--bg); border-radius: 10px; }
.alert-settings[hidden] { display: none; }
.alert-settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.alert-settings label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.alert-settings input[type=checkbox] { width: auto; }
#alert-filter { margin: 12px 0; flex-wrap: wrap; }
.alert-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-row .pill { justify-self: start; }
.alert-main a { color: var(--text); text-decoration: none; }
.alert-main a:hover { color: var(--accent); }
.alert-actions { display: flex; gap: 6px; }
.rule-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rule-row.off { opacity: .6; }
.rule-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rule-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; padding: 14px; background: var(--bg); border-radius: 12px; }
.rule-form[hidden] { display: none; }
.rule-form .span-2 { grid-column: span 2; }
.rule-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.rule-form label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; padding-top: 18px; }
.rule-form label.check input { width: auto; }
.rule-form fieldset { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 10px 12px 12px; }
.rule-form legend { font-size: 12px; font-weight: 700; color: var(--text); padding: 0 6px; }
.rule-form .form-actions { grid-column: 1 / -1; }
#rule-preview { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
#rule-preview[hidden] { display: none; }
#rule-preview .table td input, #rule-preview .table th input { width: auto; }
@media (max-width: 700px) { .alert-row { grid-template-columns: 1fr; } .rule-form { grid-template-columns: 1fr; } .rule-form .span-2 { grid-column: auto; } .rule-row { flex-direction: column; align-items: flex-start; } }

/* Spedizioni */
.ship-tabs { margin-bottom: 8px; flex-wrap: wrap; }
.ship-orders { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.ship-order { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.ship-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.ship-item { display: grid; grid-template-columns: auto 34px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.ship-item:not(:has(input)) { grid-template-columns: 34px 1fr auto; } /* spediti: senza casella di spunta */
.ship-item input { width: auto; }
.ship-item img, .ship-noimg { width: 34px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--bg); display: block; }
.ship-item a { color: var(--text); text-decoration: none; font-weight: 600; }
.ship-item a:hover { color: var(--accent); }
.ship-qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.ship-note { margin: 6px 0 0; }
.ship-items { margin-bottom: 12px; }
.ship-notes { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#ship-dialog { width: min(560px, 95vw); }
.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  body { background: #fff; display: block; }
  .print-area { display: block; color: #000; font: 12px -apple-system, sans-serif; }
  .print-area h1 { font-size: 18px; margin: 0 0 4px; }
  .print-area table { width: 100%; border-collapse: collapse; margin-top: 10px; }
  .print-area th, .print-area td { border: 1px solid #999; padding: 6px; text-align: left; }
  .print-area .box { font-size: 16px; width: 24px; text-align: center; }
}

/* --- Scanner con fotocamera ------------------------------------------------------------------ */
.scan-dialog { width: min(900px, 96vw); position: relative; }
.scan-dialog [hidden] { display: none !important; }
.scan-body { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; margin-top: 8px; }
.scan-shot { aspect-ratio: 63 / 88; background: var(--bg); border: 1px dashed var(--border); border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.scan-shot video, .scan-shot img { width: 100%; height: 100%; object-fit: contain; }
.scan-empty { color: var(--muted); padding: 24px; text-align: center; font-size: 13px; }
.scan-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.scan-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; display: grid; gap: 4px; justify-items: start; }
.scan-name { font-size: 18px; font-weight: 700; }
.scan-h { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
.scan-match { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; }
.scan-match.exact { border-color: var(--accent); background: var(--accent-soft); }
.scan-match img, .scan-match .ship-noimg { width: 38px; height: 53px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--bg); }
.scan-match-main { flex: 1; min-width: 0; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.scan-wait { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.err-text { color: var(--err); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 700px) { .scan-body { grid-template-columns: 1fr; } .scan-shot { max-height: 50vh; } }

/* --- Assistente AI ------------------------------------------------------------------------- */
.ai-fab { position: fixed; right: 20px; bottom: 20px; z-index: 15; border: 0; border-radius: 999px; padding: 11px 18px; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.18); cursor: pointer; }
.ai-panel { position: fixed; right: 20px; bottom: 76px; z-index: 16; width: min(420px, calc(100vw - 32px)); height: min(620px, calc(100vh - 110px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.22); display: flex; flex-direction: column; }
.ai-panel[hidden] { display: none; }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ai-x { border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.ai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.ai-msg p { margin: 0 0 6px; } .ai-msg p:last-child { margin-bottom: 0; }
.ai-msg ul { margin: 4px 0 6px; padding-left: 18px; }
.ai-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.assistant { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.ai-hello p { margin-top: 0; color: var(--muted); }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-suggest .chip { text-align: left; }
.ai-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.ai-form textarea { resize: none; }
@media (max-width: 600px) { .ai-panel { right: 16px; left: 16px; width: auto; bottom: 72px; } .ai-fab { right: 16px; bottom: 16px; } }
#scan-quota { line-height: 1.6; }
.credit.low strong { color: var(--err); }
.quota-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.scan-box { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; display: grid; gap: 8px; }
.scan-box p { margin: 0; }
.pop-kpis { display: flex; flex-wrap: wrap; gap: 18px; font-size: 12px; color: var(--muted); }
.pop-kpis span { display: block; font-size: 20px; font-weight: 700; color: var(--text); }
.pop-grades { display: flex; flex-wrap: wrap; gap: 4px; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.price-grid div { padding: 6px 8px; border-radius: 8px; background: var(--bg); display: grid; font-size: 12px; color: var(--muted); }
.price-grid strong { color: var(--text); font-size: 14px; }
.price-grid .mine { background: var(--accent-soft); outline: 1px solid var(--accent); }
.scan-links { font-size: 13px; }
/* Riquadri prezzo cliccabili: aprono la carta sul sito */
a.source.link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, background .15s; }
a.source.link:hover { border-color: var(--accent); background: var(--accent-soft); }
.source .s-open { font-size: 11px; color: var(--accent); margin-top: 6px; font-weight: 600; }
.ebay-loc { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.ebay-loc input { width: auto; flex: 1 1 120px; }
.bands { display: grid; gap: 8px; margin-top: 8px; }
.band { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.band input[name=up_to], .band input[name=cost] { width: 80px; }
.band input[name=label] { width: 150px; }
.band select { width: auto; flex: 1 1 220px; }
.bands-sum { margin: 6px 0; padding-left: 18px; }
.nowrap { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.ebay-note textarea { width: 100%; resize: vertical; }
.listing.past { opacity: .6; }
.group-row td { background: var(--bg); padding: 10px 12px; border-top: 1px solid var(--border); }
.group-head { grid-column: 1 / -1; padding: 6px 2px; border-bottom: 1px solid var(--border); margin-top: 6px; }

/* Prezzi oscurati dal pulsante 👁 della dashboard */
body.hide-prices .money { filter: blur(7px); user-select: none; transition: filter .15s; }
body.hide-prices input[type="number"][step="0.01"], body.hide-prices input[name*="price"] { filter: blur(6px); }
.icon-btn { min-width: 40px; padding-left: 10px; padding-right: 10px; }
