:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1d1b19;
  --muted: #6d675f;
  --line: #e4dfd7;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --foil: #8a5cf6;
  --danger: #b4372b;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1f1d1a;
    --ink: #ece8e1;
    --muted: #9b948a;
    --line: #34302b;
    --accent: #6fb0e0;
    --accent-ink: #0e1a24;
    --foil: #b79bff;
    --danger: #ec7b6f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn {
  border: 0; border-radius: 8px; padding: 10px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn:disabled { opacity: .6; cursor: default; }
.login-card .btn { width: 100%; margin-top: 4px; }
.error { color: var(--danger); font-size: 14px; margin: 0 0 16px; }

/* ---------- App ---------- */
header.top {
  position: sticky; top: 0; z-index: 5; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1280px; margin: 0 auto; padding: 12px 16px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 8px; font-size: 13px; }
.badge-demo { background: #f0c75e; color: #3a2c00; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.user { color: var(--muted); font-size: 14px; }

.tabs {
  max-width: 1280px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin;
}
.tab {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab .count { font-size: 12px; margin-left: 6px; color: var(--muted); }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 240px; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.toolbar .view-toggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toolbar .view-toggle button { border: 0; background: var(--surface); padding: 8px 12px; cursor: pointer; color: var(--muted); }
.toolbar .view-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th[data-dir="asc"]::after { content: " ▲"; }
th[data-dir="desc"]::after { content: " ▼"; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
td.name { white-space: normal; min-width: 200px; font-weight: 500; }
td.name a { color: inherit; text-decoration: none; }
td.name a:hover { text-decoration: underline; }
.thumb { width: 32px; height: 44px; object-fit: cover; border-radius: 3px; vertical-align: middle; margin-right: 10px; background: var(--line); }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.foil { border-color: var(--foil); color: var(--foil); }
.muted { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .img { aspect-ratio: 63 / 88; background: var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.card .img img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 10px 12px; display: grid; gap: 4px; }
.card .title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .meta { font-size: 12px; color: var(--muted); }
.card .row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.card .price { font-weight: 700; font-variant-numeric: tabular-nums; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; color: var(--muted); font-size: 14px; }

.state { text-align: center; padding: 60px 16px; color: var(--muted); }
.state.err { color: var(--danger); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .brand small { display: none; }
  .stat .value { font-size: 18px; }
}

/* ---------- Pannello filtri ---------- */
.filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
}
.filters[hidden] { display: none; }
.fl { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.fl > span { text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.fl select, .fl input {
  width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); font-size: 14px; color: var(--ink);
}
.fl select:focus, .fl input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fl.range > div { display: flex; align-items: center; gap: 6px; }
.fl.range input { flex: 1; }
.fl-reset { align-self: end; }
.fl-reset .btn { width: 100%; padding: 8px 10px; font-size: 14px; }
.filter-summary { font-size: 14px; margin: 0 2px 10px; }
@media (max-width: 600px) {
  .filters { grid-template-columns: 1fr 1fr; padding: 10px; }
  .fl.range, .fl-reset { grid-column: 1 / -1; }
}

/* ---------- Clic su carte ---------- */
.clickable { cursor: pointer; }
.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card.clickable:hover { border-color: var(--accent); }
.pill.tag { border-color: var(--accent); color: var(--accent); }
.pill.you { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- Scheda dettaglio ---------- */
dialog#detail {
  border: 0; padding: 0; margin: 0 0 0 auto; height: 100vh; max-height: 100vh;
  width: min(760px, 100vw); max-width: 100vw;
  background: var(--bg); color: var(--ink);
  box-shadow: -12px 0 40px rgba(0,0,0,.25);
  overflow-y: auto;
}
dialog#detail::backdrop { background: rgba(10, 10, 10, .45); }
dialog#detail[open] { animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.d-head {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 18px; align-items: start;
  padding: 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.d-img { aspect-ratio: 63 / 88; background: var(--line); border-radius: 6px; overflow: hidden; display: grid; place-items: center; font-size: 11px; color: var(--muted); text-align: center; }
.d-img img { width: 100%; height: 100%; object-fit: cover; }
.d-title h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.25; }
.d-price { font-size: 22px; font-weight: 700; margin: 10px 0 6px; font-variant-numeric: tabular-nums; }
.d-price .muted { font-size: 15px; font-weight: 500; }
.ext { color: var(--accent); font-size: 14px; text-decoration: none; }
.ext:hover { text-decoration: underline; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 14px; }

.d-sec { padding: 18px 20px 6px; }
.d-sec h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.small { font-size: 13px; }
.fields {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.fields .f { background: var(--surface); padding: 10px 12px; }
.fields .f.wide { grid-column: 1 / -1; }
.fields .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.fields .v { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.mk-filters { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 4px 0 12px; font-size: 14px; }
.chk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
.mstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.mstat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.mstat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mstat .v { font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.mstat.ok .v { color: #2e8b57; }
.mstat.warn .v { color: #c26a00; }
@media (prefers-color-scheme: dark) {
  .mstat.ok .v { color: #6fd39b; }
  .mstat.warn .v { color: #f0a648; }
}
.mk-table th { cursor: default; }
.mk-table td.strong { font-weight: 700; }
.mk-table td.wrap { white-space: normal; min-width: 140px; }
.mk-table tr.mine td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.state.small { padding: 24px 12px; font-size: 14px; }

/* ---------- Allinea ---------- */
.d-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.d-actions .btn { padding: 8px 18px; }
#align-box:empty { display: none; }
#align-box { padding: 16px 20px 0; }
.align-box {
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 8px; font-size: 14px;
}
.align-box.err { border-color: var(--danger); color: var(--danger); }
.align-box.ok { border-color: #2e8b57; }
.align-box .a-title { font-weight: 700; font-size: 15px; }
.a-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0; }
.a-grid .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.a-grid .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.a-grid .v.accent { color: var(--accent); }
.a-grid .down { color: #c26a00; }
.a-grid .up { color: #2e8b57; }
.a-warn { background: color-mix(in srgb, #f0a648 18%, transparent); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.a-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: -3px; margin: 0 8px 0 0; }
@media (max-width: 600px) {
  #align-box { padding: 12px 16px 0; }
  .a-grid { grid-template-columns: 1fr 1fr; }
  .a-grid > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .d-head { grid-template-columns: 80px 1fr auto; gap: 12px; padding: 14px 16px; }
  .d-sec { padding: 14px 16px 4px; }
  .d-title h2 { font-size: 17px; }
  .d-price { font-size: 18px; }
  .fields { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Selezione multipla ---------- */
th.sel, td.sel { width: 36px; padding-right: 0; text-align: center; }
.sel input, .b-table th.sel input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
tbody tr.selected td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.card { position: relative; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card-sel {
  position: absolute; top: 8px; left: 8px; z-index: 1; background: var(--surface);
  border-radius: 6px; padding: 4px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
main { padding-bottom: 96px; }
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.12);
}
.selbar[hidden] { display: none; }
.selbar-inner { max-width: 1280px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.selbar .spacer { flex: 1; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 14px; text-decoration: underline; }

/* ---------- Dialog allineamento multiplo ---------- */
dialog.bulk {
  border: 0; border-radius: 14px; padding: 0; width: min(1000px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: none; flex-direction: column; overflow: hidden;
}
dialog.bulk[open] { display: flex; }
dialog.bulk::backdrop { background: rgba(10,10,10,.5); }
.b-head { padding: 18px 20px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.b-head h2 { margin: 0 0 6px; font-size: 19px; }
.b-head p { margin: 0; }
.b-progress { font-size: 14px; font-weight: 600; margin-top: 8px; color: var(--accent); }
.b-progress:empty { display: none; }
.b-table { margin: 0; border-radius: 0; border-left: 0; border-right: 0; overflow: auto; flex: 1; min-height: 120px; }
.b-table th { position: sticky; top: 0; z-index: 1; cursor: default; }
.b-table td { vertical-align: top; }
.b-table td.wrap { white-space: normal; min-width: 200px; }
.b-table .strong { font-weight: 600; }
.b-table .accent { color: var(--accent); }
.b-table .down { color: #c26a00; font-weight: 600; }
.b-table .up { color: #2e8b57; font-weight: 600; }
.b-state { white-space: normal !important; min-width: 120px; color: var(--muted); }
tr.b-done .b-state { color: #2e8b57; font-weight: 600; }
tr.b-failed .b-state, tr.b-error .b-state { color: var(--danger); }
tr.b-checking td, tr.b-applying td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
tr.b-skip td, tr.b-stopped td { opacity: .6; }
.b-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--line); }
.b-summary { flex: 1; font-size: 14px; min-width: 200px; }
.b-actions { display: flex; gap: 8px; }
.err-text { color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .b-table .up, tr.b-done .b-state { color: #6fd39b; }
  .b-table .down { color: #f0a648; }
}
@media (max-width: 600px) {
  dialog.bulk { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .b-actions { width: 100%; }
  .b-actions .btn { flex: 1; }
}

/* ---------- Impostazioni ---------- */
dialog.settings {
  border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog.settings::backdrop { background: rgba(10,10,10,.5); }
.settings-form { padding: 22px 22px 18px; display: grid; gap: 10px; }
.settings-form h2 { margin: 0 0 4px; font-size: 19px; }
.settings-form p { margin: 0; }
.settings-form .fl > span { font-size: 12px; }
.ok-text { color: #2e8b57; }
@media (prefers-color-scheme: dark) { .ok-text { color: #6fd39b; } }

/* ---------- Segno "modificato dall'app" ---------- */
.pill.tag.mark { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.settings-form hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0 2px; width: 100%; }
.strong-chk { font-weight: 600; font-size: 14px; }
.mark-grid { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.mark-grid input:disabled, .mark-grid select:disabled { opacity: .5; }

/* ---------- Carte per pagina ---------- */
.filter-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fs-right { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.page-size { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; }
.pager { flex-wrap: wrap; }

/* Shift+clic sulle caselle non deve selezionare il testo della pagina */
.sel, .sel input { user-select: none; -webkit-user-select: none; }

/* ---------- Storico ---------- */
.hist-head h2 { margin: 0 0 4px; font-size: 20px; }
.hist-head p { margin: 0 0 14px; }
.hist-table td { vertical-align: top; }
.hist-table td.wrap { white-space: normal; min-width: 200px; }
.hist-table .strong { font-weight: 600; }
.hist-table .down { color: #c26a00; font-weight: 600; }
.hist-table .up { color: #2e8b57; font-weight: 600; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.pill.src-align { border-color: var(--accent); color: var(--accent); }
.pill.src-bulk { border-color: var(--foil); color: var(--foil); }
.pill.src-restore { border-color: #c26a00; color: #c26a00; }
#history-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tabs[hidden] { display: none; }

dialog.versions {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: auto;
}
dialog.versions::backdrop { background: rgba(10,10,10,.5); }
.v-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.v-head h2 { margin: 0; font-size: 18px; }
.v-body { padding: 14px 18px 18px; display: grid; gap: 8px; }
.v-name { font-size: 16px; font-weight: 700; }
.v-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.v-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.v-item.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.v-price { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.v-actions { flex-shrink: 0; text-align: right; }
.v-confirm { display: grid; gap: 6px; justify-items: end; max-width: 260px; }
@media (prefers-color-scheme: dark) {
  .hist-table .up { color: #6fd39b; }
  .hist-table .down, .pill.src-restore { color: #f0a648; border-color: #f0a648; }
}
@media (max-width: 600px) {
  .v-item { flex-direction: column; align-items: stretch; }
  .v-actions, .v-confirm { text-align: left; justify-items: start; }
}

/* ---------- Navigazione sezioni ---------- */
.sections { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sections button { border: 0; background: var(--surface); padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 500; }
.sections button + button { border-left: 1px solid var(--line); }
.sections button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Ordini ---------- */
.ord-bar {
  display: flex; flex-wrap: wrap; align-items: end; gap: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
}
.ord-bar .fl { min-width: 150px; }
.ord-custom { display: inline-flex; align-items: center; gap: 6px; }
.ord-custom[hidden] { display: none; }
.ord-custom input { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.ord-checks { display: grid; gap: 4px; font-size: 14px; }
.ord-actions { margin-left: auto; display: flex; gap: 8px; }
.ord-summary { margin: 0 2px 4px; }
.ord-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.ord-sub { margin: 0 2px 12px; font-size: 13px; }
.ord-group { margin-bottom: 18px; }
.ord-group-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 6px; }
.ord-group-head h3 { margin: 0; font-size: 16px; }
.ord-table { font-size: 14px; }
.ord-table th { cursor: default; }
.ord-table td { vertical-align: top; }
.ord-table td.wrap { white-space: normal; }
.ord-table td.qty { font-weight: 700; width: 48px; }
.ord-table .strong { font-weight: 600; }
.ord-table tr.sub-head td { background: color-mix(in srgb, var(--accent) 7%, transparent); font-size: 13px; padding-top: 7px; padding-bottom: 7px; }
.ord-table tr.picked td:not(.sel) { opacity: .45; text-decoration: line-through; }
.ord-table td.sel input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.print-box, .print-only { display: none; }

/* ---------- Stampa ---------- */
@media print {
  @page { margin: 12mm; }
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; }
  body { background: #fff; color: #000; font-size: 11px; }
  header.top, .selbar, dialog, .no-print, .pager { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-only { display: block; }
  .print-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
  .ord-stats { font-size: 11px; margin-bottom: 8px; }
  .table-wrap { border: 0; overflow: visible; border-radius: 0; }
  .ord-group { break-inside: avoid-page; margin-bottom: 10px; }
  .ord-group-head { break-after: avoid; margin-bottom: 2px; }
  .ord-group-head h3 { font-size: 13px; }
  .ord-table { font-size: 10.5px; }
  .ord-table th, .ord-table td { padding: 3px 6px; border-bottom: 1px solid #ccc; }
  .ord-table th { position: static; font-size: 9px; }
  .ord-table tr { break-inside: avoid; }
  .ord-table tr.picked td:not(.sel) { opacity: 1; text-decoration: none; }
  .ord-table td.sel input { display: none; }
  .print-box { display: inline-block; width: 11px; height: 11px; border: 1.2px solid #000; border-radius: 2px; }
  .pill { border-color: #000 !important; color: #000 !important; }
}

@media print {
  .ord-table .small, .ord-table .muted.small { font-size: 9.5px; }
  .ord-table tr.sub-head td { font-size: 10px; padding: 3px 6px; background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ord-table td.qty { width: 30px; }
}

/* ---------- Ordini: valori da usare come posizione ---------- */
.ord-values { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.ord-values summary { cursor: pointer; }
.ord-values p { margin: 8px 0; }
.ov-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ov-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); cursor: pointer; }
.ov-item input { accent-color: var(--accent); }
.ov-item.off { opacity: .55; }
.ov-item.off .ov-text { text-decoration: line-through; }
.ov-text { font-weight: 600; }
.ord-bar .view-toggle { display: inline-flex; }

/* ---------- Ordini: vista a immagini ---------- */
.ord-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ord-sub-tiles { margin-bottom: 12px; }
.ord-sub-tiles .sub-head { font-size: 13px; padding: 6px 10px; margin-bottom: 8px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ord-tile { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.ord-tile.picked { opacity: .45; }
.ord-tile.picked .ot-name { text-decoration: line-through; }
.ot-check { position: absolute; top: 8px; left: 8px; z-index: 1; background: var(--surface); border-radius: 6px; padding: 4px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.ot-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.ot-qty { position: absolute; top: 8px; right: 8px; z-index: 1; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 15px; padding: 2px 8px; border-radius: 99px; }
.ot-img { aspect-ratio: 63 / 88; background: var(--line); display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted); padding: 0; }
.ot-img img { width: 100%; height: 100%; object-fit: cover; }
.ot-img span { padding: 8px; }
.ot-body { padding: 8px 10px 10px; display: grid; gap: 2px; }
.ot-name { font-weight: 600; font-size: 14px; line-height: 1.25; }

@media print {
  .ord-tiles { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .ord-tile { break-inside: avoid; border-color: #999; }
  .ord-tile.picked { opacity: 1; }
  .ord-tile.picked .ot-name { text-decoration: none; }
  .ot-check { box-shadow: none; padding: 2px; }
  .ot-check input { display: none; }
  .ot-qty { background: #000 !important; color: #fff !important; font-size: 11px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ot-body { padding: 4px 5px 5px; }
  .ot-name { font-size: 9.5px; }
  .ord-tile .small { font-size: 8.5px; }
  .ord-sub-tiles .sub-head { font-size: 10px; padding: 3px 6px; background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.ord-bar .view-toggle { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ord-bar .view-toggle button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; color: var(--muted); font-size: 14px; }
.ord-bar .view-toggle button + button { border-left: 1px solid var(--line); }
.ord-bar .view-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Stampa consequenziale: i gruppi possono spezzarsi tra le pagine, niente spazi vuoti */
@media print {
  .ord-group { break-inside: auto !important; page-break-inside: auto !important; margin-bottom: 6px; }
  .ord-group-head { break-after: avoid; page-break-after: avoid; margin: 4px 0 2px; }
  .ord-group .table-wrap, .ord-tiles, .ord-sub-tiles { break-before: avoid; page-break-before: avoid; }
  .ord-sub-tiles { margin-bottom: 4px; }
  .ord-sub-tiles .sub-head { break-after: avoid; page-break-after: avoid; margin-bottom: 4px; }
  .ord-table thead { display: table-header-group; }
  .ord-table tr, .ord-tile { break-inside: avoid; page-break-inside: avoid; }
}

.ord-bar .fl-order { min-width: 260px; flex: 1 1 260px; max-width: 420px; }
.ord-bar select:disabled { opacity: .55; }

/* ---------- Ordina per spedire ---------- */
.ord-ship[hidden] { display: none; }
.ord-ship { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; display: grid; gap: 10px; }
.os-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.os-sorts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ship-table .thumb { width: 26px; height: 36px; margin-right: 8px; vertical-align: middle; }
.ot-seq { position: absolute; bottom: auto; top: 40px; left: 8px; z-index: 1; background: var(--surface); color: var(--ink); font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 99px; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.strong { font-weight: 600; }
@media (max-width: 700px) { .os-sorts { grid-template-columns: 1fr 1fr; } }
@media print {
  .ord-ship { display: none !important; }
  .ship-table .thumb { display: none; }
  .ot-seq { box-shadow: none; border: 1px solid #000; }
}

.ship-name { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.ship-name .thumb { margin-right: 0; flex-shrink: 0; }

/* ---------- Lista dal PDF ---------- */
.os-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.os-modes button { border: 0; background: var(--surface); padding: 8px 12px; cursor: pointer; color: var(--muted); font-size: 14px; }
.os-modes button + button { border-left: 1px solid var(--line); }
.os-modes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.os-pdfinfo { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.pdf-stats { margin: 0 2px 8px; }
.pdf-table tr.nomatch td { background: color-mix(in srgb, #f0a648 14%, transparent); }
@media print { .pdf-table tr.nomatch td { background: none !important; } }

/* Shift+clic: niente selezione del testo sulle liste con caselle */
.ord-tile, [data-range-scope] td.sel, .ov-item { user-select: none; -webkit-user-select: none; }

/* ---------- Ordini: Lista (miniatura) / Immagini (immagine grande, stessi dati) ---------- */
#ord-list .ord-table .thumb { width: 30px; height: 42px; object-fit: cover; border-radius: 3px; background: var(--line); flex-shrink: 0; }
#ord-list.big-img .ord-table .thumb { width: 110px; height: 154px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
#ord-list.big-img .ord-table td { vertical-align: middle; }
#ord-list.big-img .ship-name { gap: 14px; min-width: 260px; }
#ord-list.big-img .ord-table .strong { font-size: 15px; }
@media (max-width: 700px) { #ord-list.big-img .ord-table .thumb { width: 80px; height: 112px; } }
@media print {
  #ord-list .ord-table .thumb { display: none; }
  #ord-list.big-img .ord-table .thumb { display: block; width: 52px; height: 73px; box-shadow: none; }
}

/* Anteprima al passaggio del mouse */
#thumb-zoom { position: fixed; z-index: 9999; width: 250px; height: 350px; object-fit: contain; pointer-events: none; border-radius: 10px; background: var(--card, #fff); box-shadow: 0 8px 28px rgba(0,0,0,.35); }
#thumb-zoom[hidden] { display: none; }
.thumb[src] { cursor: zoom-in; }
#ord-list.big-img .thumb { cursor: default; }
@media (hover: none) { #thumb-zoom { display: none !important; } }
@media print { #thumb-zoom { display: none !important; } }

/* ---------- Carica (scansioni -> CardTrader) ---------- */
.scan-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.scan-head h2 { margin: 0 0 4px; font-size: 20px; }
.scan-head p { margin: 0; max-width: 720px; }
.scan-batch { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.scan-batch select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); max-width: 320px; }
.scan-warn { padding: 14px 16px; border-radius: var(--radius); }
.scan-defaults { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.scan-defaults .fl { display: grid; gap: 4px; }
.scan-defaults .fl > span { font-size: 12px; color: var(--muted); }
.scan-defaults input, .scan-defaults select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 200px; }
.scan-drop {
  border: 2px dashed var(--line); border-radius: 14px; padding: 26px 16px; text-align: center; background: var(--surface);
  display: grid; gap: 6px; justify-items: center; margin-bottom: 14px; transition: border-color .15s, background .15s;
}
.scan-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.scan-drop.disabled { opacity: .55; }
.scan-catalog { margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.scan-batch select.scan-new { cursor: pointer; font-weight: 600; color: var(--ink); }
/* finitura Pokémon */
.scan-tip { flex-basis: 100%; margin: 0; max-width: 900px; }
.scan-finish { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 12px; }
.scan-finish.pending { border-color: #d08a1e; box-shadow: 0 0 0 2px color-mix(in srgb, #d08a1e 30%, transparent); }
.scan-finish option { background: var(--surface); color: var(--ink); }
.scan-notes { margin: 4px 0 0; padding-left: 0; list-style: none; }
.scan-finish-btns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.btn.warn-btn { background: #d08a1e; color: #fff; border-color: #d08a1e; }
.scan-fin { width: min(1100px, 96vw); }
.scan-fin-all { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.scan-fin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 12px 16px; max-height: 62vh; overflow: auto; }
.scan-fin-card { border: 2px solid var(--line); border-radius: 10px; padding: 8px; display: grid; gap: 3px; align-content: start; background: var(--surface); }
.scan-fin-card.is-rev { border-color: #8a5cd0; background: color-mix(in srgb, #8a5cd0 8%, var(--surface)); }
.scan-fin-card img { width: 100%; aspect-ratio: 63 / 88; object-fit: contain; border-radius: 6px; background: var(--bg, #0000); }
.scan-fin-opts { display: grid; gap: 2px; margin-top: 4px; font-size: 12px; }
.scan-fin-foot { padding: 10px 16px; align-items: center; }
.scan-fin-foot [role=status] { flex: 1; }
/* le voci dei menu a tendina con sfondo e testo del tema (in modo scuro su Windows restavano bianco su bianco) */
.scan-batch select option, .scan-defaults select option { background: var(--surface); color: var(--ink); }
.scan-drop-title { font-weight: 700; font-size: 17px; }
.scan-drop-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.scan-prog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; display: grid; gap: 8px; }
.scan-prog-text { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.scan-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.scan-bar > div { height: 100%; background: var(--accent); transition: width .3s; }
.scan-prog.done .scan-bar > div { background: #2e8b57; }
.scan-stats { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.scan-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.scan-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.scan-chip .count { margin-left: 6px; font-weight: 700; color: var(--ink); }
.scan-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.scan-chip[aria-pressed="true"] .count { color: var(--accent-ink); }
.scan-toolbar { align-items: center; }
.scan-toolbar .spacer { flex: 1; }
.scan-toolbar .btn { padding: 8px 12px; }
.scan-inline { padding: 7px 10px !important; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.danger-btn { background: var(--danger); color: #fff; }
.scan-table td { vertical-align: top; padding: 8px 8px; }
.scan-table th { cursor: default; padding: 8px; }
.scan-table td.wrap { white-space: normal; min-width: 130px; }
.scan-table td.center { text-align: center; }
.scan-table .thumb { margin-right: 0; }
.scan-table .scan-img { width: 70px; }
.scan-table .scan-thumb { width: 52px; height: 74px; display: block; }
.scan-ct { display: flex; gap: 8px; min-width: 190px; }
.scan-ct > div { min-width: 0; }
.scan-ct a { color: inherit; text-decoration: none; }
.scan-ct a:hover { text-decoration: underline; }
.tiny { font-size: 12px; }
.muted.tiny { overflow-wrap: anywhere; }
.scan-img .tiny { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; font-weight: 600; background: none; border: 1px dashed transparent; border-radius: 6px; padding: 2px 4px; margin-left: -4px; cursor: text; }
.scan-code:hover:not(:disabled) { border-color: var(--line); }
.scan-code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; width: 130px; padding: 4px 6px; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); }
.scan-table select, .scan-table input[type=text], .scan-table input[type=number] { padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.scan-qty { width: 56px; }
.scan-tag { width: 100px; }
.scan-price { min-width: 140px; max-width: 210px; white-space: normal !important; }
.scan-price-line { display: flex; gap: 4px; align-items: center; }
.scan-price-input { width: 72px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.scan-price-input.bad { border-color: var(--danger) !important; }
.scan-existing { margin-top: 4px; padding: 4px 6px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tiny-select { font-size: 12px; max-width: 100%; padding: 3px 4px !important; }
.scan-issues { margin: 4px 0 4px; padding-left: 16px; color: var(--muted); }
.scan-issues li { margin-bottom: 2px; }
.scan-state { min-width: 140px; max-width: 220px; }
.scan-acts { white-space: nowrap; }
.scan-acts .icon-btn { width: 30px; height: 30px; margin-left: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.pill.st-ok { border-color: #2e8b57; color: #2e8b57; }
.pill.st-check { border-color: #c26a00; color: #c26a00; }
.pill.st-error { border-color: var(--danger); color: var(--danger); }
.pill.st-published { background: #2e8b57; border-color: #2e8b57; color: #fff; }
.pill.st-reading { border-color: var(--accent); color: var(--accent); }
/* carte fuori CardTrader (giapponesi/coreane): solo magazzino e Shopify */
.pill.st-ocg { border-color: #b0306a; color: #b0306a; }
.scan-cand-more { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 13px; min-height: 120px; border-style: dashed !important; }
.db-src { display: inline-flex; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.db-src[hidden] { display: none; }
.db-src button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.db-src button + button { border-left: 1px solid var(--line); }
.db-src button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.db-ocg-note { margin: 0 0 6px; }
tr.st-published td { opacity: .7; }
tr.st-error td { background: color-mix(in srgb, var(--danger) 5%, transparent); }
.mini-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-left: 6px; vertical-align: middle; }
.pill.src-create { border-color: #2e8b57; color: #2e8b57; }
.pill.src-merge { border-color: #2e8b57; color: #2e8b57; }
@media (prefers-color-scheme: dark) {
  .pill.st-ok, .pill.src-create, .pill.src-merge { border-color: #6fd39b; color: #6fd39b; }
  .pill.st-check { border-color: #f0a648; color: #f0a648; }
  .pill.st-ocg { border-color: #f08cbc; color: #f08cbc; }
}
dialog.scan-dlg { width: min(1100px, calc(100vw - 24px)); }
.scan-dlg-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.scan-dlg-body { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 16px 20px 20px; overflow: auto; }
.scan-dlg-mine img { width: 100%; border-radius: 8px; display: block; }
.scan-dlg-right { display: grid; gap: 12px; align-content: start; }
.scan-cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.scan-cand { border: 2px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px; cursor: pointer; display: grid; gap: 4px; text-align: left; }
.scan-cand:hover { border-color: var(--accent); }
.scan-cand.current { border-color: #2e8b57; }
.scan-cand img, .scan-cand .noimg { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: var(--line); }
.scan-cand .noimg { display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.scan-dlg-search { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; }
.scan-dlg-search input { min-width: 220px; }
dialog.scan-pub { width: min(520px, calc(100vw - 24px)); }
.scan-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: min(640px, calc(100vw - 32px)); box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.scan-confirm { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) {
  .scan-dlg-body { grid-template-columns: 1fr; }
  .scan-dlg-mine { max-width: 200px; }
}
body[data-page="upload"] main { max-width: 1480px; }
.scan-diag { display: grid; gap: 8px; font-size: 14px; }
.scan-diag-line { line-height: 1.4; }
.scan-pre { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 260px; overflow: auto; white-space: pre-wrap; }

/* ---------- Database (magazzino + wishlist) ---------- */
.db-tabs button { padding: 9px 14px; }
.db-refresh { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -4px 0 12px; }
.db-table td { vertical-align: middle; }
.db-table tr.db-listed td { background: color-mix(in srgb, #2e8b57 4%, transparent); }
.db-table tr.db-hit td { background: color-mix(in srgb, #2e8b57 10%, transparent); }
.pill.st-stored { border-color: var(--foil); color: var(--foil); }
.db-up { color: #2e8b57; font-weight: 600; }
.db-down { color: var(--danger); font-weight: 600; }
.db-spark path { fill: none; stroke-width: 1.6; }
.db-spark path.up { stroke: #2e8b57; }
.db-spark path.down { stroke: var(--danger); }
.db-spark line.target { stroke: var(--muted); stroke-dasharray: 3 3; stroke-width: 1; }
.db-spark text { font-size: 10px; fill: var(--muted); }
.db-chart { width: 100%; height: auto; max-height: 260px; display: block; margin: 8px 0 4px; }
.db-chart .grid { stroke: var(--line); stroke-width: 1; }
.db-chart .axis { font-size: 11px; fill: var(--muted); }
.db-chart .strong-label { fill: var(--ink); font-weight: 600; }
.db-chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.db-chart .dot { fill: var(--accent); }
.db-chart .target { stroke: #2e8b57; stroke-dasharray: 5 4; stroke-width: 1.4; }
.db-chart .target-label { fill: #2e8b57; }
.db-chart .muted { fill: var(--muted); font-size: 13px; }
dialog.db-search { width: min(1180px, calc(100vw - 24px)); height: min(820px, calc(100vh - 40px)); }
.db-searchbar { display: flex; gap: 8px; margin-top: 10px; }
.db-searchbar select, .db-searchbar input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.db-q { flex: 1; }
.db-search-body { display: grid; grid-template-columns: 1fr 360px; gap: 0; flex: 1; min-height: 0; }
.db-results { overflow: auto; padding: 14px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; align-content: start; }
.db-result { display: grid; grid-template-columns: 48px 1fr; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px; cursor: pointer; align-items: start; }
.db-result:hover { border-color: var(--accent); }
.db-result.current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.db-result img, .db-result .noimg { width: 48px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 4px; background: var(--line); }
.db-form { border-left: 1px solid var(--line); background: var(--surface); padding: 16px; overflow: auto; display: grid; gap: 12px; align-content: start; }
.db-form-card { display: grid; grid-template-columns: 90px 1fr; gap: 12px; align-items: start; }
.db-form-card img { width: 90px; border-radius: 6px; }
.db-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.db-form-grid .fl input, .db-form-grid .fl select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.db-form-grid .chk { align-self: end; padding-bottom: 8px; }
.db-catalog { grid-column: 1 / -1; max-width: 560px; display: grid; gap: 10px; justify-items: start; padding: 10px 0; }
.db-wish-body { padding: 16px 20px 20px; overflow: auto; }
.db-wish-top { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: start; }
.db-wish-img { width: 120px; border-radius: 8px; }
.mstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin: 10px 0 6px; }
.mstat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.db-h3 { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.db-buy { display: flex; gap: 6px; align-items: center; }
.scan-toast.ok { background: #2e8b57; }
@media (max-width: 800px) {
  .db-search-body { grid-template-columns: 1fr; }
  .db-form { border-left: 0; border-top: 1px solid var(--line); }
  .db-wish-top { grid-template-columns: 1fr; }
}
.db-results-wrap { overflow: auto; padding: 12px 16px; display: grid; gap: 10px; align-content: start; }
.db-results-wrap .db-results { padding: 0; overflow: visible; }
.db-results-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.db-results-info { padding: 4px 0; }
.db-result { grid-template-columns: 18px 48px 1fr; }
.db-result input[type=checkbox] { margin-top: 2px; }
.db-result.picked { border-color: #2e8b57; background: color-mix(in srgb, #2e8b57 7%, var(--surface)); }
.db-picked { display: grid; gap: 6px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--bg); }
.db-picked-row { display: grid; grid-template-columns: 32px 1fr 60px 28px; gap: 8px; align-items: center; }
.db-picked-row .thumb { margin: 0; }
.icon-btn.sm-icon { width: 26px; height: 26px; font-size: 12px; }
.db-tabs, .scan-dlg-title .view-toggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.db-tabs button, .scan-dlg-title .view-toggle button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; color: var(--muted); font-weight: 500; }
.db-tabs button[aria-pressed="true"], .scan-dlg-title .view-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.db-wacts { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
a.btn { text-decoration: none; display: inline-block; }

/* ---------- Sezione Shopify ---------- */
.shop-body { display: grid; gap: 16px; }
.shop-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.shop-card h3 { margin: 0 0 10px; font-size: 16px; }
.shop-card h4 { margin: 18px 0 8px; font-size: 14px; }
.shop-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.shop-card-head h3 { margin: 0; }
.shop-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; vertical-align: 3px; margin-left: 6px; }
.shop-chip.on { background: color-mix(in srgb, #2e8b57 15%, transparent); color: #2e8b57; }
.shop-chip.off { background: var(--line); color: var(--muted); }
.shop-chip.err { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.shop-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 18px; }
.shop-kv > div > div { font-weight: 500; }
.shop-warn { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, #d99a00 14%, transparent); border: 1px solid color-mix(in srgb, #d99a00 40%, var(--line)); font-size: 14px; }
.shop-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.shop-pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; overflow-x: auto; margin: 4px 0; }
.shop-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.shop-form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; align-content: start; min-width: 0; }
.shop-form legend { font-weight: 600; padding: 0 6px; font-size: 14px; }
.shop-form textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; resize: vertical; }
.shop-form .fl small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.shop-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink); font-size: 14px; }
.shop-example { margin: 0; }
.shop-form-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.shop-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.shop-actions-main, .shop-actions-side { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.shop-stock { margin-bottom: 14px; }
.shop-stock-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.shop-stock-head h3 { margin: 0 0 4px; }
.shop-stock-head p { margin: 0; max-width: 680px; }
.shop-stock select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.shop-stock select option { background: var(--surface); color: var(--ink); }
.shop-job { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 8px; }
.shop-job-text { font-size: 14px; }
.shop-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.shop-bar > div { height: 100%; background: var(--accent); transition: width .3s; }
.shop-bar > div.indet { width: 30% !important; animation: shop-indet 1.2s ease-in-out infinite; }
@keyframes shop-indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.shop-table { max-height: 420px; overflow: auto; }
.shop-table td { white-space: pre-line; vertical-align: top; }
.shop-details { margin-top: 14px; }
.shop-details summary, .shop-log summary { cursor: pointer; font-weight: 600; }
.shop-log ul { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; max-height: 300px; overflow: auto; }
.shop-result .stats { margin-bottom: 6px; }
.shop-delete-body { padding: 16px 20px; display: grid; gap: 10px; overflow: auto; }
.shop-delete-body ul { margin: 0; padding-left: 20px; }
.shop-confirm { max-width: 260px; }
#shop-delete { width: min(620px, calc(100vw - 24px)); }
@media (max-width: 640px) { .shop-row { grid-template-columns: 1fr; } }
.shop-job[hidden] { display: none; }
/* intestazione: con 6 sezioni la riga resta unica */
.sections button { padding: 9px 12px; }
body[data-page]:not([data-page="inventory"]) .brand small { display: none; }
/* Shopify: prodotti collegati */
.shop-tabs { justify-self: start; display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.shop-tabs button { border: 0; background: var(--surface); padding: 9px 16px; cursor: pointer; color: var(--muted); font: inherit; font-weight: 500; }
.shop-tabs button + button { border-left: 1px solid var(--line); }
.shop-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.shop-intro { margin: 0 0 12px; max-width: 900px; }
.shop-linkbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.shop-linkbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.shop-links-table { max-height: none; }
.shop-links-table td.name { min-width: 180px; }
.shop-qty { font-size: 18px; font-weight: 700; }
.shop-lastmove { white-space: normal !important; min-width: 180px; max-width: 280px; }
.shop-rowacts { display: flex; gap: 6px; flex-wrap: wrap; }
.shop-link-body { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; overflow: hidden; }
.shop-link-col { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; min-height: 0; overflow: hidden; }
.shop-link-col + .shop-link-col { border-left: 1px solid var(--line); }
.shop-link-col h4 { margin: 0; }
.shop-link-col input[type=search] { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.shop-pick-list { overflow: auto; display: grid; gap: 6px; align-content: start; min-height: 260px; max-height: 52vh; }
.shop-pick { display: grid; grid-template-columns: 1fr; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 10px; cursor: pointer; font: inherit; }
.shop-pick:has(img) { grid-template-columns: 44px 1fr; column-gap: 10px; }
.shop-pick img { grid-row: span 3; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.shop-pick:hover:not(:disabled) { border-color: var(--accent); }
.shop-pick.current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.shop-pick:disabled { opacity: .5; cursor: default; }
.shop-pick-title { font-weight: 600; }
.shop-start { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; flex: 1; font-size: 14px; }
.shop-start-n { width: 80px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
dialog.shop-small { width: min(640px, calc(100vw - 24px)); }
@media (max-width: 760px) { .shop-link-body { grid-template-columns: 1fr; overflow: auto; } .shop-link-col + .shop-link-col { border-left: 0; border-top: 1px solid var(--line); } }
.shop-start-custom { display: inline-flex; align-items: center; gap: 6px; }
/* Shopify: menu del negozio */
.shop-menu [hidden] { display: none; }
.shop-menu-tree { font-size: 13px; border-left: 2px solid var(--line); padding: 2px 0 2px 10px; display: grid; gap: 2px; }
.shop-menu-tree:empty { display: none; }
.shop-tree-menu { color: var(--muted); }
.shop-tree-l1 { font-weight: 600; padding-left: 10px; }
.shop-tree-l2 { padding-left: 26px; }
.shop-tree-l3 { padding-left: 42px; color: var(--muted); }
.shop-tree-l1::before, .shop-tree-l2::before, .shop-tree-l3::before { content: "└ "; color: var(--muted); }
.shop-title-example { margin-top: -6px; }
/* Shopify: filtro per espansione */
.shop-exp { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.shop-exp summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; color: var(--muted); }
.shop-exp-sum { text-transform: none; letter-spacing: 0; font-weight: 500; }
.shop-exp-body { display: grid; gap: 8px; margin-top: 8px; }
.shop-exp-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.shop-exp-tools input { flex: 1; min-width: 140px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.shop-exp-list { max-height: 260px; overflow: auto; display: grid; gap: 2px; align-content: start; font-size: 14px; }
.shop-exp-game { font-weight: 600; margin-top: 6px; color: var(--ink); }
.shop-exp-row { padding: 2px 0; }
.shop-job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Allinea: sotto quale offerta (1ª, 2ª, 3ª) e prime offerte del market */
.a-rank-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.a-rank { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.a-rank button { border: 0; background: var(--surface); padding: 6px 11px; cursor: pointer; color: var(--muted); font-size: 13px; }
.a-rank button + button { border-left: 1px solid var(--line); }
.a-rank button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.a-rank button:disabled { opacity: .45; cursor: default; }
.a-ladder { margin: 8px 0 4px; padding-left: 22px; color: var(--muted); }
.a-ladder li { margin: 1px 0; }
.a-ladder li.on { color: var(--ink); font-weight: 600; }
.a-ladder li.on::marker { color: var(--accent); }
.b-rank { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.b-rank select { padding: 4px 8px; }

/* Carica: versioni escluse dal lotto */
.scan-ex-list { display: grid; gap: 6px; padding: 12px 20px; overflow: auto; max-height: 60vh; }
.scan-ex-row { display: grid; grid-template-columns: auto 40px 1fr; gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.scan-ex-row img, .scan-ex-row .noimg { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--bg); display: block; }

/* Carica: modifiche sulle carte selezionate */
.scan-bulk-edit { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 10px 12px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.scan-be-f { display: inline-flex; flex-direction: column; gap: 3px; }
.scan-be-f > .muted { text-transform: uppercase; letter-spacing: .04em; }
.scan-be-f > :not(.muted) { display: inline-flex; }
.scan-be-f { white-space: nowrap; }
.scan-bulk-edit .scan-be-f { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.scan-bulk-edit .scan-be-f > .muted { flex-basis: 100%; }
.scan-be-qty { width: 70px; }
.scan-bulk-edit .btn.sm { padding: 6px 10px; }
.scan-bulk-edit .scan-price-input { width: 84px; }
