:root {
  --bg: #0e1013;
  --bg-elev: #171a1f;
  --card: #1d2127;
  --card-2: #262b33;
  --line: #2e343d;
  --text: #f4f5f7;
  --text-2: #a3aab5;
  --text-3: #6f7782;
  --accent: #34c759;
  --accent-ink: #0b2a14;
  --accent-soft: rgba(52, 199, 89, .14);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, .16);
  --red: #ff5a52;
  --red-soft: rgba(255, 90, 82, .15);
  --yellow: #ffc542;
  --yellow-soft: rgba(255, 197, 66, .14);
  --blue: #4da3ff;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --tabbar-h: 64px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f4f6;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #eef0f3;
  --line: #e1e4e9;
  --text: #14171c;
  --text-2: #5b636e;
  --text-3: #8b939e;
  --accent: #1f9d45;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 157, 69, .12);
  --green: #1f9d45;
  --green-soft: rgba(31, 157, 69, .12);
  --red: #d93a32;
  --red-soft: rgba(217, 58, 50, .1);
  --yellow: #b07800;
  --yellow-soft: rgba(224, 160, 0, .14);
  --shadow: 0 8px 24px rgba(20, 23, 28, .08);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
a { color: var(--accent); }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; min-height: 40px; }
.topbar h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 0; flex: 1; }
.topbar .title-sm { font-size: 18px; font-weight: 700; flex: 1; text-align: center; margin: 0; }
.back {
  background: none; border: 0; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 4px; cursor: pointer; font-size: 16px; min-width: 80px;
}
.back svg { width: 20px; height: 20px; }
.topbar .spacer { min-width: 80px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.pill b { color: var(--text); font-weight: 600; }

/* ---------- elementi base ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
}
.section-label {
  font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  margin: 22px 2px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.section-label span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.manual { color: var(--yellow); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 16px;
  cursor: pointer; background: var(--card-2); color: var(--text); width: 100%;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: #fff; }
:root[data-theme="light"] .btn-primary { color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
.btn-danger { background: transparent; border: 1.5px solid var(--red); color: var(--red); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-sm { padding: 9px 12px; font-size: 14px; border-radius: 11px; width: auto; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1.5px solid transparent; background: var(--card); color: var(--text);
  padding: 8px 15px; border-radius: 999px; font-size: 14px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip select { background: transparent; border: 0; outline: 0; appearance: none; padding-right: 2px; cursor: pointer; }
.chip svg { width: 14px; height: 14px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 8px;
  background: var(--card-2); color: var(--text-2); font-size: 12.5px; font-weight: 600;
}
.tag.gold { background: var(--yellow-soft); color: var(--yellow); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: rgba(77, 163, 255, .15); color: var(--blue); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 9px; font-size: 14px; font-weight: 700; white-space: nowrap;
}
.badge.pos { background: var(--green); color: #fff; }
.badge.neg { background: var(--red); color: #fff; }
.badge.neutral { background: var(--card-2); color: var(--text-2); }

/* ---------- form ---------- */
.field { margin-top: 16px; }
.field > label, .field-label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg-elev); border: 1.5px solid var(--line); border-radius: 13px;
  padding: 13px 14px; font-size: 16px; outline: none; transition: border-color .15s;
}
:root:not([data-theme="light"]) .input { background: #12151a; }
.input:focus { border-color: var(--accent); }
.input.manual-input { border-color: var(--yellow); background: var(--yellow-soft); }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.hint { font-size: 13px; color: var(--text-3); margin-top: 6px; }
.hint button { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; cursor: pointer; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; gap: 12px; }
.switch-row .field-label { margin: 0; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--card-2); border-radius: 999px; transition: background .2s; cursor: pointer;
}
.switch span::after {
  content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.subpanel { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 4px 14px 14px; margin-top: 12px; }

.segmented { display: inline-flex; background: var(--card-2); border-radius: 12px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--text-2); cursor: pointer;
}
.segmented button.active { background: var(--accent); color: #fff; }
.segmented.full { display: flex; }
.segmented.full button { flex: 1; }

/* ---------- ricerca ---------- */
.search-box {
  display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 18px; padding: 4px 6px 4px 16px;
  border: 1.5px solid transparent;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { width: 22px; height: 22px; color: var(--text-3); flex: none; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 12px 0; font-size: 17px; }
.search-box .clear { background: none; border: 0; color: var(--text-3); padding: 10px; cursor: pointer; }
.mode-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 12px 0; }

.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.list-item {
  display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: var(--radius);
  padding: 11px 14px 11px 11px; cursor: pointer; text-align: left; border: 0; width: 100%;
  transition: background .15s;
}
.list-item:active { background: var(--card-2); }
.thumb {
  width: 56px; height: 78px; border-radius: 6px; object-fit: cover; background: var(--card-2); flex: none;
}
.thumb.lg { width: 104px; height: 145px; border-radius: 9px; }
.li-title { font-size: 17px; font-weight: 700; line-height: 1.25; }
.li-sub { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.li-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.li-price { text-align: right; flex: none; }
.li-price .lbl { font-size: 12.5px; color: var(--text-3); }
.li-price .val { font-size: 18px; font-weight: 800; }
.li-price .sub { font-size: 12.5px; color: var(--text-2); margin-top: 4px; white-space: nowrap; }

/* ---------- dettaglio carta ---------- */
.hero-img {
  width: 62%; max-width: 260px; aspect-ratio: 245 / 342; margin: 4px auto 16px; border-radius: 14px;
  background: var(--card-2); object-fit: cover; box-shadow: var(--shadow);
}
.card-title { font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin: 0; }
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.price-tile {
  background: var(--card); border-radius: var(--radius); padding: 13px 12px; text-align: center;
}
.price-tile .lbl { font-size: 14px; color: var(--text-2); }
.price-tile .val { font-size: 25px; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.price-tile .sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.price-tile.featured { background: var(--accent-soft); }
.price-tile.featured .val { color: var(--accent); }
.chart-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.chart-card svg { width: 100%; height: 120px; display: block; margin-top: 8px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.sticky-cta {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); margin-top: 18px; z-index: 5;
}

/* ---------- inventario ---------- */
.summary { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; }
.summary .lbl { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.summary .big { font-size: 36px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 12px; }
.summary .split { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); padding-top: 12px; }
.summary .split > div + div { border-left: 1px solid var(--line); }
.summary .split .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 2px 0; font-size: 14px; color: var(--text-2); }
.toolbar select { background: transparent; border: 0; color: var(--text); font-weight: 600; outline: 0; cursor: pointer; }
.mini-search { margin-top: 12px; }

/* ---------- dettaglio inventario ---------- */
.item-head { display: flex; gap: 14px; }
.kv { font-size: 15px; margin-top: 4px; }
.kv .k { color: var(--text-2); }
.compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.compare > div { border-radius: 14px; padding: 12px 6px; text-align: center; background: var(--card); }
.compare .lbl { font-size: 13.5px; color: var(--text-2); }
.compare .val { font-size: 20px; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.compare .delta { font-size: 13px; font-weight: 700; margin-top: 2px; min-height: 18px; }
.compare .is-pos { background: var(--green-soft); }
.compare .is-neg { background: var(--red-soft); }
.compare .is-manual { background: var(--yellow-soft); }
.margin-line { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15px; }
.margin-line + .margin-line { margin-top: 6px; }
.margin-line b { font-size: 18px; }
.history { background: var(--card); border-radius: var(--radius); padding: 4px 14px; }
.history-row { padding: 11px 0; font-size: 14.5px; display: flex; gap: 10px; }
.history-row + .history-row { border-top: 1px solid var(--line); }
.history-row .when { color: var(--text-3); flex: none; width: 74px; }
.sold-banner { background: var(--green-soft); color: var(--green); border-radius: 14px; padding: 12px 14px; font-weight: 600; margin-top: 12px; }

/* ---------- attività ---------- */
.day-label { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin: 22px 2px 10px; }
.feed { position: relative; }
.feed-item { display: flex; gap: 12px; margin-bottom: 10px; position: relative; }
.feed-item::before {
  content: ""; position: absolute; left: 21px; top: 46px; bottom: -12px; width: 2px; background: var(--line);
}
.feed-item:last-child::before { display: none; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  color: #fff; flex: none; font-size: 18px; z-index: 1;
}
.avatar.sm { width: 36px; height: 36px; font-size: 15px; }
.feed-card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; flex: 1; min-width: 0; display: flex; gap: 10px; cursor: pointer; border: 0; text-align: left; }
.feed-card .txt { font-size: 15.5px; line-height: 1.35; }
.feed-card .when { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.feed-card .right { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.feed-card .right img { width: 40px; height: 56px; border-radius: 4px; object-fit: cover; background: var(--card-2); }
.feed-card .amt { font-weight: 800; font-size: 15px; white-space: nowrap; }

/* ---------- impostazioni ---------- */
.group { background: var(--card); border-radius: var(--radius); padding: 4px 14px; }
.group-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 56px; }
.group-row + .group-row { border-top: 1px solid var(--line); }
.group-row .icon-btn { background: none; border: 0; color: var(--text-3); padding: 8px; cursor: pointer; }
.group-row .icon-btn svg { width: 18px; height: 18px; }
.slider-row { display: grid; grid-template-columns: 96px 1fr 64px; align-items: center; gap: 12px; padding: 10px 0; }
.slider-row + .slider-row { border-top: 1px solid var(--line); }
.slider-row output { background: var(--bg); border-radius: 10px; padding: 6px 0; text-align: center; font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tabbar-h); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-3); font-size: 12px; font-weight: 500;
}
.tabbar a svg { width: 25px; height: 25px; }
.tabbar a.active { color: var(--accent); }

/* ---------- varie ---------- */
.empty { text-align: center; color: var(--text-2); padding: 40px 20px; }
.empty svg { width: 46px; height: 46px; color: var(--text-3); margin-bottom: 10px; }
.empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--card-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%) translateY(20px); opacity: 0; transition: all .25s ease;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600;
  z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); font-size: 15px; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); color: #fff; }

.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.modal {
  background: var(--bg-elev); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease;
}
.modal h3 { margin: 0 0 4px; font-size: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

.center-screen { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; padding: 20px; }
.logo { width: 76px; height: 76px; }
.notice { background: var(--yellow-soft); color: var(--yellow); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-top: 10px; }
input[type=search]::-webkit-search-cancel-button, input[type=search]::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- foto ---------- */
.cover { object-fit: cover; }
.img-btn { border: 0; padding: 0; background: none; cursor: zoom-in; border-radius: 9px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; border-radius: var(--radius); transition: outline-color .15s; outline: 2px dashed transparent; outline-offset: 4px; }
.gallery.drop-on { outline-color: var(--accent); }
.gal-thumb, .gal-add {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 0; padding: 0;
  background: var(--card); cursor: pointer;
}
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gal-main {
  position: absolute; left: 6px; bottom: 6px; background: rgba(0, 0, 0, .65); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
}
.gal-x {
  position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .65); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.gal-x svg { width: 16px; height: 16px; }
.gal-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--line); color: var(--text-2); font-size: 12.5px; font-weight: 600; background: transparent;
}
.gal-add svg { width: 26px; height: 26px; color: var(--accent); }

.viewer { position: fixed; inset: 0; z-index: 60; background: #050607; display: flex; flex-direction: column; animation: fade .15s ease; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; color: #fff; font-weight: 600; font-size: 14px; }
.viewer-bar .btn { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer-bar .btn-danger { background: transparent; color: #ff6b63; border-color: #ff6b63; }
.viewer-bar .btn svg { width: 18px; height: 18px; }
.viewer-wrap { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: zoom-in; touch-action: pan-y; }
.viewer-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer-wrap.zoomed { overflow: auto; display: block; cursor: zoom-out; touch-action: auto; }
.viewer-wrap.zoomed img { max-width: none; max-height: none; width: 220%; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, .1); color: #fff; font-size: 34px; cursor: pointer;
}
.viewer-nav.prev { left: 10px; }
.viewer-nav.next { right: 10px; }
.viewer-hint { text-align: center; color: rgba(255, 255, 255, .5); font-size: 12.5px; padding: 8px 0 calc(env(safe-area-inset-bottom) + 10px); }

/* ---------- impaginazione a due colonne (dettagli) ---------- */
.detail-layout { display: block; }

/* ---------- inventario: tabella e griglia (PC) ---------- */
.table-wrap { margin-top: 14px; background: var(--card); border-radius: var(--radius); overflow: auto; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.inv-table th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em;
  padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none;
  position: sticky; top: 0; background: var(--card);
}
.inv-table th:hover, .inv-table th.sorted { color: var(--text); }
.inv-table th.th-img { cursor: default; width: 52px; }
.inv-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inv-table tbody tr { cursor: pointer; transition: background .12s; }
.inv-table tbody tr:hover { background: var(--card-2); }
.inv-table tbody tr:last-child td { border-bottom: 0; }
.inv-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-table .tthumb { width: 36px; height: 50px; border-radius: 4px; object-fit: cover; background: var(--card-2); }
.inv-table .t-name { font-weight: 700; }
.inv-table .t-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.inv-table .t-loc { color: var(--text-2); font-size: 13.5px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-table .tag { font-size: 11px; padding: 1px 6px; }

.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 14px; }
.inv-card {
  background: var(--card); border: 0; border-radius: var(--radius); padding: 0; text-align: left; cursor: pointer;
  overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s;
}
.inv-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.inv-card-img { position: relative; aspect-ratio: 4 / 5; background: var(--card-2); display: grid; place-items: center; padding: 12px; }
.inv-card-img img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.inv-card-img.photo { padding: 0; }
.inv-card-img.photo img { width: 100%; height: 100%; max-height: none; border-radius: 0; object-fit: cover; }
.inv-card-img .badge { position: absolute; top: 10px; right: 10px; }
.inv-card-ph { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 7px; }
.inv-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.inv-card-body .li-title { font-size: 15.5px; }
.inv-card-body .li-sub { font-size: 13px; }
.inv-card-prices { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; flex-wrap: wrap; }
.tabbar .brand { display: none; }

/* ---------- PC e portatile ---------- */
@media (min-width: 900px) {
  :root { --side: 236px; }
  #app {
    max-width: calc(1240px + var(--side) + 80px);
    margin: 0;
    padding: 28px 40px 60px calc(var(--side) + 40px);
  }
  #app[data-w="narrow"] { max-width: calc(780px + var(--side) + 80px); }
  .topbar h1 { font-size: 34px; }

  .tabbar {
    top: 0; bottom: 0; right: auto; width: var(--side); padding: 22px 14px;
    border-top: 0; border-right: 1px solid var(--line); background: var(--bg-elev);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; padding: 0 10px 22px; }
  .tabbar .brand img { width: 34px; height: 34px; }
  .tabbar nav { display: flex; flex-direction: column; gap: 4px; height: auto; max-width: none; }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; border-radius: 12px; font-size: 15px; color: var(--text-2); }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a:hover { background: var(--card); color: var(--text); }
  .tabbar a.active { background: var(--accent-soft); color: var(--accent); }

  /* risultati di ricerca e liste in griglia */
  #app[data-w="wide"] .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
  #app[data-w="wide"] .list > .empty { grid-column: 1 / -1; }

  /* dettaglio a due colonne */
  .detail-layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 36px; align-items: start; }
  .detail-info > .section-label:first-child { margin-top: 0; }
  .hero-img { width: 100%; max-width: 400px; margin: 0; }
  .detail-media .item-head { flex-direction: column; }
  .detail-media .item-head > a, .detail-media .item-head > img { align-self: center; }
  .detail-media .item-head .thumb.lg { width: 220px; height: auto; aspect-ratio: 245 / 342; object-fit: contain; }
  .detail-media .item-head .img-btn { display: block; width: 100%; }
  .detail-media .item-head .img-btn { align-self: stretch; }
  .detail-media .item-head .img-btn .thumb.lg { width: 100%; height: 280px; aspect-ratio: auto; object-fit: cover; }
  .sticky-cta { position: static; }

  .summary { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; align-items: center; text-align: left; padding: 18px 24px; column-gap: 24px; }
  .summary .lbl { grid-column: 1; }
  .summary .big { grid-column: 1; margin: 2px 0 0; }
  .summary .split { grid-column: 2; grid-row: 1 / 3; border-top: 0; padding-top: 0; }
  .summary .split > div { padding-left: 24px; border-left: 1px solid var(--line); }
  .summary .split > div + div { border-left: 1px solid var(--line); }

  .modal-back { align-items: center; }
  .modal { border-radius: 22px; max-width: 520px; padding: 24px; }
  .toast { bottom: 28px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
@media (min-width: 900px) and (hover: hover) {
  .list-item:hover { background: var(--card-2); }
}
@media (min-width: 900px) {
  body:has(#tabbar.hidden) #app { padding-left: 40px; margin: 0 auto; }
}

/* filtro espansione nella ricerca */
.set-filter {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; background: var(--card); border-radius: 14px;
  padding: 4px 6px 4px 14px; border: 1.5px solid transparent;
}
.set-filter:focus-within { border-color: var(--accent); }
.set-filter.on { border-color: var(--accent); background: var(--accent-soft); }
.set-filter-lbl { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; flex: none; }
.set-filter input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 10px 0; font-size: 16px; font-weight: 600; }
.set-filter .clear { background: none; border: 0; color: var(--text-3); padding: 8px; cursor: pointer; }
.set-filter .clear svg { width: 18px; height: 18px; }
@media (min-width: 900px) {
  #searchForm { max-width: 760px; }
}
.rank { flex: none; width: 24px; text-align: center; font-weight: 800; color: var(--text-3); font-size: 15px; margin-right: -6px; }
.scan-box { margin-top: 12px; }
.progress { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* elenco espansioni a comparsa */
.picker-host { position: relative; }
.picker-dd {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; max-height: 320px; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
}
.picker-head { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px 4px; }
.picker-opt {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 11px 10px; border-radius: 10px; cursor: pointer; font-size: 15px; color: var(--text);
}
.picker-opt:hover, .picker-opt:focus { background: var(--card-2); outline: none; }
.picker-opt .faint { flex: none; }
.picker-msg { padding: 12px; color: var(--text-2); font-size: 14px; }

/* prezzi incoerenti */
.warn-box { background: var(--yellow-soft); color: var(--yellow); border-radius: 14px; padding: 12px 14px; margin-top: 12px; }
.warn-box .small { color: var(--text-2); }
.warn-tag { color: var(--yellow); font-size: .85em; cursor: help; }
.price-tile.suspect { background: var(--yellow-soft); }
.price-tile.suspect .val { color: var(--yellow); }
