/* VanScout — linguaggio visivo da strada: asfalto, cemento, blu targa, giallo cantiere.
   Elemento forte: il prezzo come targa italiana (.price). Tutto il resto resta sobrio. */
:root {
  --asphalt: #1b222b;
  --asphalt-2: #262f3a;
  --bg: #e4e7e2;
  --surface: #ffffff;
  --surface-2: #f2f4f0;
  --border: #d3d8d0;
  --border-strong: #b9c0b6;
  --text: #1b222b;
  --muted: #5d6772;
  --accent: #0033a0;          /* blu targa */
  --accent-soft: #e3e9f7;
  --yellow: #ffc72c;          /* giallo cantiere */
  --yellow-ink: #1b222b;
  --good: #00875a;            /* verde autostrada */
  --good-soft: #dff1e8;
  --warn: #a86400;
  --warn-soft: #fdf0d2;
  --bad: #c62f25;
  --bad-soft: #fbe6e4;
  --plate: #ffffff;
  --plate-ink: #11161c;
  --r1: #00875a; --r2: #4fa83d; --r3: #e0b000; --r4: #e5781e; --r5: #c62f25;
  --src-autoscout: #f5c400; --src-autoscout-text: #1b222b;
  --src-subito: #e83a45; --src-subito-text: #fff;
  --src-automobile: #0b5cff; --src-automobile-text: #fff;
  --src-autosupermarket: #ff6a00; --src-autosupermarket-text: #fff;
  --src-spoticar: #00205b; --src-spoticar-text: #fff;
  --shadow: 0 1px 0 rgba(27, 34, 43, .06);
  --shadow-lg: 0 14px 34px -12px rgba(27, 34, 43, .35);
  --radius: 14px;
  --radius-sm: 8px;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: Barlow, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a21; --surface: #1d252f; --surface-2: #232c37; --border: #2f3a46; --border-strong: #3f4b59;
    --text: #e8ebe6; --muted: #98a3ae; --accent: #6f95ff; --accent-soft: #1d2a4a;
    --good: #2fbf86; --good-soft: #12301f; --warn: #f0b23a; --warn-soft: #33270f; --bad: #ff6b5e; --bad-soft: #3a1a17;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3); --shadow-lg: 0 18px 40px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a21; --surface: #1d252f; --surface-2: #232c37; --border: #2f3a46; --border-strong: #3f4b59;
  --text: #e8ebe6; --muted: #98a3ae; --accent: #6f95ff; --accent-soft: #1d2a4a;
  --good: #2fbf86; --good-soft: #12301f; --warn: #f0b23a; --warn-soft: #33270f; --bad: #ff6b5e; --bad-soft: #3a1a17;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3); --shadow-lg: 0 18px 40px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--body); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; letter-spacing: 0; line-height: 1.1; }

/* ---------- topbar: asfalto con mezzeria ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px; padding: 12px 24px 16px;
  background: var(--asphalt); color: #e8ebe6; }
.lane { position: absolute; left: 0; right: 0; bottom: 5px; height: 3px; pointer-events: none;
  background: repeating-linear-gradient(90deg, var(--yellow) 0 34px, transparent 34px 60px); opacity: .9;
  animation: drive 1.4s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes drive { from { background-position: -600px 0; opacity: 0; } to { background-position: 0 0; opacity: .9; } }
.brand { display: flex; align-items: center; gap: 10px; font: 800 26px/1 var(--display); color: #fff; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand svg { color: var(--yellow); width: 30px; height: 30px; }
nav { display: flex; gap: 2px; }
nav a { white-space: nowrap; padding: 6px 14px; border-radius: 6px; color: #b8c1ca; font: 600 18px/1.2 var(--display); letter-spacing: .01em; }
nav a:hover { color: #fff; text-decoration: none; background: var(--asphalt-2); }
nav a.active { background: var(--yellow); color: var(--yellow-ink); }
nav a.active .pill { background: var(--asphalt); color: var(--yellow); }
.sync { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.sync-info { font-size: 12.5px; color: #98a3ae; text-align: right; line-height: 1.35; }
.sync-info b { color: #fff; font-weight: 600; }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--yellow); color: var(--yellow-ink);
  font: 700 12px/18px var(--body); text-align: center; margin-left: 2px; }
.topbar .btn-primary { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }

/* ---------- bottoni ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--text); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, #000); border-color: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13.5px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }

.reminders { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: inset 5px 0 0 var(--yellow); padding: 9px 24px 9px 29px;
  font-size: 14px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.reminders a { color: var(--text); font-weight: 600; }

/* ---------- targa: il prezzo ---------- */
.price, .big-price { position: relative; display: inline-flex; align-items: center; background: var(--plate); color: var(--plate-ink);
  border: 2px solid var(--plate-ink); border-radius: 6px; font: 700 26px/1 var(--display); letter-spacing: .03em;
  padding: 5px 20px 4px 30px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price::before, .big-price::before, .price::after, .big-price::after { content: ''; position: absolute; top: 0; bottom: 0; width: 20px; background: #0033a0; }
.price::before, .big-price::before { left: 0; border-radius: 3px 0 0 3px; content: 'I'; color: #fff; font: 700 11px/1 var(--body);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
  background: radial-gradient(circle at 50% 30%, #ffcc00 0 1.6px, transparent 2.2px) #0033a0; }
.price::after, .big-price::after { right: 0; width: 12px; border-radius: 0 3px 3px 0; }
.big-price { font-size: 44px; padding: 8px 28px 6px 42px; border-width: 3px; border-radius: 8px; }
.big-price::before { width: 28px; } .big-price::after { width: 16px; }
.big-price::before { font-size: 14px; padding-bottom: 6px; }
.price-sm { font-size: 17px; padding: 2px 12px 1px 18px; border-width: 1.5px; border-radius: 4px; }
.price-sm::before { width: 12px; } .price-sm::after { width: 7px; }
.price-sm::before { font-size: 8px; padding-bottom: 2px; }

/* ---------- ricerca ---------- */
.search-layout { display: grid; grid-template-columns: 290px 1fr; gap: 24px; padding: 24px; }
.search-layout.with-map { grid-template-columns: 290px minmax(0, 1fr) minmax(360px, 36%); }
.search-layout.with-map .grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
/* Colonne di card scelte dall'utente con la mappa: la mappa si stringe per far posto. */
.search-layout.with-map.cols-2 .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.search-layout.with-map.cols-3 { grid-template-columns: 290px minmax(0, 1fr) minmax(380px, 34%); }
.search-layout.with-map.cols-3 .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--asphalt); color: #fff; }
.map-wrap { position: sticky; top: 84px; height: calc(100vh - 108px); border-radius: var(--radius); overflow: hidden; border: 2px solid var(--asphalt); }
#map { width: 100%; height: 100%; background: var(--surface-2); }
.map-ctrl { position: absolute; z-index: 500; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.map-ctrl label, .map-ctrl button { background: var(--asphalt); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px;
  font-weight: 600; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.map-ctrl input { accent-color: var(--yellow); }
/* Pin: mini targa */
.price-pin { background: var(--plate); color: var(--plate-ink); border: 1.5px solid var(--plate-ink); border-left: 6px solid #0033a0; border-radius: 4px;
  padding: 2px 7px 1px 5px; font: 700 14px/1.1 var(--display); letter-spacing: .02em; white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0,0,0,.28); transform: translate(-50%, -50%); display: inline-block; transition: transform .1s; }
.price-pin.r-ottimo { border-left-color: var(--r1); box-shadow: 0 0 0 2px var(--r1), 0 3px 8px rgba(0,0,0,.28); }
.price-pin.r-buono { border-left-color: var(--r2); }
.price-pin.r-sospetto { border-left-color: #6b3fa0; }
.price-pin.hl, .price-pin:hover { transform: translate(-50%, -50%) scale(1.2); background: var(--yellow); z-index: 1000; }
.leaflet-div-icon.pin-icon { background: none; border: none; }
.me-pin { display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--asphalt); transform: translate(-50%, -50%);
  box-shadow: 0 0 0 7px rgba(255,199,44,.35), 0 1px 4px rgba(0,0,0,.4); }
.leaflet-popup-content { margin: 0; width: 240px !important; }
.leaflet-popup-content-wrapper { padding: 0; overflow: hidden; border-radius: 12px; }
.popcard img { width: 100%; height: 145px; object-fit: cover; display: block; }
.popcard div { padding: 10px 12px; font: 14px/1.4 var(--body); }
.popcard .price { margin-top: 4px; }
.marker-cluster { background: rgba(27, 34, 43, .2); border-radius: 50%; }
.marker-cluster div { width: 32px; height: 32px; margin: 4px; border-radius: 50%; background: var(--asphalt); color: var(--yellow);
  display: grid; place-items: center; font: 700 14px var(--display); }
.card.hl { outline: 3px solid var(--yellow); outline-offset: 1px; }
.heart { border: none; background: rgba(255,255,255,.95); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: #8a929b;
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.heart.on { color: #e0245e; }
.near { display: grid; grid-template-columns: 1fr 90px; gap: 6px; }
.wish-meta { font-size: 13px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.compare { overflow-x: auto; }
.compare td, .compare th { white-space: nowrap; }
.compare td:first-child, .compare th:first-child { position: sticky; left: 0; background: var(--surface); }
.best { color: var(--good); font-weight: 700; }

.filters { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 108px); overflow: auto; background: var(--surface);
  border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); }
.filters h3 { margin: 20px 0 8px; font-size: 19px; color: var(--text); }
.filters h3:first-child { margin-top: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 25%, transparent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-size: 13.5px; font-weight: 500; user-select: none; transition: background .12s; }
.chip-toggle:hover { border-color: var(--text); }
.chip-toggle.on { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.results-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.results-head h2 { margin: 0; font-size: 40px; font-weight: 800; }
.results-head .spacer { flex: 1; }
.results-head select { width: auto; }

/* ---------- card ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer; transition: border-color .12s, box-shadow .15s; }
.card:hover { border-color: var(--asphalt); box-shadow: var(--shadow-lg); }
.card.inactive { opacity: .55; filter: grayscale(.6); }
.card-media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media::after { content: ''; position: absolute; inset: auto 0 0; height: 40%; background: linear-gradient(transparent, rgba(0,0,0,.45)); pointer-events: none; }
.card-media .noimg { display: grid; place-items: center; height: 100%; color: var(--muted); }
.src-badge { position: absolute; z-index: 1; top: 10px; left: 10px; padding: 3px 9px; border-radius: 4px; font: 700 13px/1.2 var(--display); letter-spacing: .02em; }
.src-autoscout { background: var(--src-autoscout); color: var(--src-autoscout-text); }
.src-subito { background: var(--src-subito); color: var(--src-subito-text); }
.src-automobile { background: var(--src-automobile); color: var(--src-automobile-text); }
.src-autosupermarket { background: var(--src-autosupermarket); color: var(--src-autosupermarket-text); }
.src-spoticar { background: var(--src-spoticar); color: var(--src-spoticar-text); }
.media-tags { position: absolute; z-index: 1; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.media-bottom { position: absolute; z-index: 1; left: 10px; right: 10px; bottom: 10px; display: flex; justify-content: space-between; align-items: end; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-dark { background: rgba(0,0,0,.6); color: #fff; }
.tag-drop { background: var(--yellow); color: var(--yellow-ink); }
.tag-gone { background: #3a3f46; color: #fff; }
.tag-crm { background: var(--accent); color: #fff; }

.rating { color: #fff; }
.rating-ottimo { background: var(--r1); }
.rating-buono { background: var(--r2); }
.rating-equo { background: var(--r3); color: #1b222b; }
.rating-alto { background: var(--r4); }
.rating-molto-alto { background: var(--r5); }
.rating-sospetto { background: #6b3fa0; color: #fff; }

.card-body { padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card-title { font: 600 19px/1.15 var(--display); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.3em; }
.price-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.old-price { color: var(--muted); text-decoration: line-through; font: 600 16px var(--display); }
.fair { font-size: 13px; color: var(--muted); }
.fair b.neg { color: var(--good); }
.fair b.pos { color: var(--bad); }
.specs { display: flex; flex-wrap: wrap; gap: 4px; color: var(--text); font-size: 13px; font-weight: 500; }
.specs span { padding: 1px 7px; border-radius: 4px; background: var(--surface-2); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.b { padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); }
.b-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.b-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.b-info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted);
  border-top: 1px dashed var(--border-strong); padding-top: 9px; gap: 8px; }
.score { font: 700 16px var(--display); color: var(--text); }
.star { border: none; background: none; cursor: pointer; font-size: 20px; color: var(--border-strong); padding: 0; line-height: 1; }
.star.on { color: var(--yellow); text-shadow: 0 0 1px var(--asphalt); }

.pager { display: flex; justify-content: center; gap: 8px; margin: 28px 0; align-items: center; }
.empty { padding: 64px 24px; text-align: center; color: var(--muted); background: var(--surface); border: 2px dashed var(--border-strong); border-radius: var(--radius); font-size: 16px; }

/* ---------- dettaglio ---------- */
.detail { max-width: 1360px; margin: 0 auto; padding: 24px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(360px, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.panel + .panel { margin-top: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 24px; }
.gallery-main { position: relative; aspect-ratio: 4 / 3; background: var(--asphalt); border-radius: var(--radius); overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-nav { position: absolute; top: 50%; transform: translateY(-50%); background: var(--yellow); color: var(--yellow-ink); border: none; width: 44px; height: 44px;
  border-radius: 50%; font-size: 22px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.gallery-nav.prev { left: 14px; } .gallery-nav.next { right: 14px; }
.gallery-count { position: absolute; bottom: 12px; right: 12px; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.thumbs img { width: 88px; height: 66px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .55; flex: none; border: 3px solid transparent; }
.thumbs img.on { opacity: 1; border-color: var(--yellow); }
.detail h1 { font-size: 38px; font-weight: 800; margin: 10px 0 6px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.kv div { background: var(--surface); padding: 9px 12px; font-weight: 600; }
.kv span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.desc { white-space: pre-wrap; max-height: 380px; overflow: auto; font-size: 14.5px; max-width: 72ch; }
.scale { position: relative; margin: 30px 0 8px; }
.scale-bar { display: grid; grid-template-columns: repeat(5, 1fr); height: 12px; border-radius: 3px; overflow: hidden; gap: 2px; }
.scale-bar i:nth-child(1) { background: var(--r1); } .scale-bar i:nth-child(2) { background: var(--r2); } .scale-bar i:nth-child(3) { background: var(--r3); }
.scale-bar i:nth-child(4) { background: var(--r4); } .scale-bar i:nth-child(5) { background: var(--r5); }
.scale-labels { display: grid; grid-template-columns: repeat(5, 1fr); font-size: 12px; color: var(--muted); text-align: center; margin-top: 5px; }
.scale-marker { position: absolute; top: -24px; transform: translateX(-50%); font: 700 15px var(--display); white-space: nowrap; }
.scale-marker::after { content: ''; display: block; width: 3px; height: 24px; background: var(--text); margin: 1px auto 0; border-radius: 2px; }
.chart svg { width: 100%; height: 160px; display: block; }
.contact-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.comp { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px dashed var(--border-strong); }
.comp img { width: 76px; height: 57px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.comp .p { font: 700 18px var(--display); text-align: right; }
.timeline { list-style: none; padding: 0; margin: 14px 0 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px dashed var(--border-strong); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -8px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.timeline li.k-stage::before { border-color: var(--muted); }
.timeline li.k-msg_in::before { border-color: var(--good); }
.timeline li.k-offerta::before { border-color: var(--yellow); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; }
.timeline .del { float: right; visibility: hidden; }
.timeline li:hover .del, .timeline .del:focus-visible { visibility: visible; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label, .field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

/* ---------- CRM kanban: le fasi sono una sequenza, quindi numerate ---------- */
.crm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 20px 24px 0; }
.crm-sorts { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-from { display: flex; align-items: center; gap: 8px; }
.crm-from input { width: 180px; }
.warn-text { color: var(--warn); font-weight: 600; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(262px, 1fr); gap: 14px; padding: 16px 24px 24px; overflow-x: auto;
  min-height: calc(100vh - 130px); counter-reset: stage; }
.col { background: color-mix(in srgb, var(--surface-2) 60%, transparent); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px;
  display: flex; flex-direction: column; gap: 9px; counter-increment: stage; }
.col.drop { outline: 3px dashed var(--yellow); }
.col h4 { margin: 4px 4px 6px; font-size: 21px; display: flex; justify-content: space-between; align-items: center; }
.col h4 span:first-child::before { content: counter(stage); display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 8px;
  border-radius: 50%; background: var(--asphalt); color: var(--yellow); font-size: 14px; vertical-align: 2px; }
.col[data-stage=acquistato] h4 span:first-child::before { background: var(--good); color: #fff; }
.col[data-stage=scartato] h4 span:first-child::before { background: var(--muted); color: var(--surface); }
.col h4 .muted { font: 600 14px var(--body); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px; cursor: grab;
  display: grid; grid-template-columns: 72px 1fr; gap: 10px; transition: border-color .12s; }
.kcard:hover { border-color: var(--asphalt); }
.kcard img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.kcard .t { font: 600 16px/1.15 var(--display); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kprice { margin-top: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kdrop { color: var(--good); font-size: 12px; font-weight: 700; }
.kcard .meta { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.kcard .kloc { color: var(--text); font-weight: 600; }
.kcard .kloc b { color: var(--accent); }
.kcard .overdue { color: var(--bad); font-weight: 700; }

/* ---------- impostazioni ---------- */
.settings { max-width: 1000px; margin: 0 auto; padding: 24px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--border); }
th { font: 600 15px var(--display); color: var(--muted); }
pre.log { background: var(--asphalt); color: #d7dde3; padding: 14px; border-radius: var(--radius-sm); max-height: 320px; overflow: auto; font-size: 12px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--asphalt); color: #fff; padding: 11px 18px;
  border-radius: var(--radius-sm); border-left: 5px solid var(--yellow); z-index: 50; box-shadow: var(--shadow-lg); font-weight: 600; }

@media (max-width: 1200px) {
  .search-layout.with-map, .search-layout.with-map.cols-3 { grid-template-columns: 270px minmax(0, 1fr); }
  .search-layout.with-map .map-wrap { grid-column: 1 / -1; grid-row: 1; position: relative; top: 0; height: 400px; }
}
@media (max-width: 900px) {
  .search-layout, .search-layout.with-map, .search-layout.with-map.cols-3, .detail-grid { grid-template-columns: 1fr; }
  .search-layout { padding: 16px; }
  .search-layout.with-map[class*=cols-] .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .filters { position: static; max-height: none; }
  .topbar { flex-wrap: wrap; gap: 6px 16px; padding: 10px 16px 14px; }
  .brand { order: 1; font-size: 22px; }
  .sync { order: 2; }
  nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  nav a { white-space: nowrap; font-size: 16px; padding: 4px 10px; }
  .sync-info { display: none; }
  .results-head h2 { font-size: 32px; }
  .detail { padding: 16px; }
  .detail h1 { font-size: 30px; }
  .big-price { font-size: 34px; }
  .crm-bar, .kanban { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .lane { animation: none; }
  * { transition: none !important; }
}

/* ---------- bozza e opinione di Claude ---------- */
.ai-box { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: var(--surface-2); }
.ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-row select { width: auto; }
.ai-box h4 { margin: 14px 0 6px; font-size: 17px; }
.ai-box ul { margin: 0; padding-left: 18px; }
.ai-box li { margin: 3px 0; }
.ai-meta { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-obs { list-style: none; padding: 0 !important; display: grid; gap: 8px; }
.ai-obs li { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: start; }
.ai-obs img { width: 76px; height: 57px; object-fit: cover; border-radius: 6px; }
.ai-warn li { color: var(--bad); }
.opinion { border: 2px solid var(--asphalt); position: relative; }
.opinion h3 { display: flex; align-items: center; gap: 10px; }
.opinion > p:first-of-type { font-size: 16px; max-width: 70ch; }
.opinion h4 { margin: 14px 0 4px; font-size: 17px; }
.opinion ul { margin: 0; padding-left: 18px; }
.opinion li { margin: 4px 0; }
.opinion .b { font: 700 15px/1.2 var(--body); padding: 3px 10px; }

/* ---------- conversazione col venditore ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow-y: auto; padding: 12px; background: var(--surface-2); border-radius: 10px; }
.bubble { max-width: 82%; padding: 8px 12px 6px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--border); }
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff; border-color: transparent; border-radius: 14px 14px 4px 14px; }
.bubble.me .when { color: rgba(255,255,255,.75); }
.bubble.them { align-self: flex-start; }
.bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .when { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.chat-import { margin-top: 10px; }

/* ---------- account ---------- */
body:not(.is-admin) #syncBtn, body:not(.is-admin) #refreshOne { display: none; }
body.logged-out nav, body.logged-out .sync, body.logged-out .reminders { display: none !important; }
.user-box { display: flex; align-items: center; gap: 2px; padding-left: 12px; border-left: 1px solid var(--asphalt-2); }
.user-name { color: #fff; font-weight: 600; font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-out { color: #b8c1ca; }
.user-out:hover { color: #fff; border-color: transparent; }

.login { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(180deg, var(--yellow) 0 44px, transparent 44px 76px) center top / 6px 76px repeat-y, var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 2px solid var(--asphalt); border-radius: var(--radius); padding: 28px 26px 22px;
  display: flex; flex-direction: column; gap: 6px; }
.login-plate { align-self: flex-start; font-size: 22px; margin-bottom: 10px; }
.login-card h1 { font-size: 40px; margin: 0; }
.login-card > p { margin: 0 0 10px; }
.login-card label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.login-err { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 6px 0 0 !important; }
.btn-go { justify-content: center; background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); font: 700 20px var(--display); padding: 10px; margin-bottom: 12px; }
.btn-go:hover { border-color: var(--asphalt); }
.login-card code, .new-pass code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

.saved { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.saved-item { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; background: var(--surface); }
.saved-item.on { border-color: var(--asphalt); background: var(--asphalt); }
.saved-item.on .saved-go, .saved-item.on .saved-del { color: #fff; }
.saved-go, .saved-del { border: 0; background: none; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text); }
.saved-go { padding: 5px 4px 5px 12px; }
.saved-del { padding: 5px 10px 5px 6px; color: var(--muted); }
.saved-del:hover { color: var(--bad); }
.save-search { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.new-pass { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (max-width: 900px) {
  .user-box { border-left: 0; padding-left: 0; }
  .user-name { display: none; }
}

/* ---------- il progetto ---------- */
.vision h2 { font-size: 34px; margin: 0 0 10px; }
.vision-tagline { font: 600 22px/1.2 var(--display); color: var(--accent); margin: -4px 0 12px; }
.vision-intro { font-size: 16px; max-width: 66ch; margin: 0 0 18px; }
.vision dl { margin: 0; max-width: 820px; display: grid; grid-template-columns: minmax(150px, 210px) 1fr; border-top: 1px dashed var(--border-strong); }
.vision dt, .vision dd { margin: 0; padding: 11px 0; border-bottom: 1px dashed var(--border-strong); }
.vision dt { font: 700 19px/1.2 var(--display); padding-right: 16px; }
.vision-note { margin: 16px 0 0; padding-left: 12px; box-shadow: inset 4px 0 0 var(--yellow); font-weight: 600; }
.login-wrap { display: grid; grid-template-columns: 400px minmax(0, 560px); gap: 28px; align-items: start; }
.login-vision { background: var(--surface); border-radius: var(--radius); padding: 24px 26px; border: 1px solid var(--border); }
.login-vision h2 { font-size: 28px; }
.login-vision .vision-intro { font-size: 14.5px; }
.login-vision dt { font-size: 17px; }
.login-vision dd { font-size: 14px; }
@media (max-width: 1000px) {
  .login-wrap { grid-template-columns: minmax(0, 400px); justify-content: center; }
  .vision dl { grid-template-columns: 1fr; }
  .vision dt { padding-bottom: 0; border-bottom: 0; }
}

.market h2 { font-size: 34px; margin: 0 0 10px; }
.market h3 { font-size: 24px; margin: 22px 0 8px; }
.market-table { overflow-x: auto; }
.market-table td { vertical-align: top; }
.market dl { margin: 0; max-width: 820px; display: grid; grid-template-columns: minmax(150px, 210px) 1fr; border-top: 1px dashed var(--border-strong); }
.market dt, .market dd { margin: 0; padding: 11px 0; border-bottom: 1px dashed var(--border-strong); }
.market dt { font: 700 19px/1.2 var(--display); padding-right: 16px; }
.market-src { margin-top: 16px; }
.market-src summary { cursor: pointer; font-weight: 600; }
.market-src ul { margin: 6px 0 0; padding-left: 18px; columns: 2; }
@media (max-width: 1000px) {
  .market dl { grid-template-columns: 1fr; }
  .market dt { padding-bottom: 0; border-bottom: 0; }
  .market-src ul { columns: 1; }
}

/* ---------- pannello rapido del CRM ---------- */
.drawer-wrap[hidden] { display: none; }
.drawer-bg { position: fixed; inset: 0; z-index: 40; background: rgba(27, 34, 43, .35); }
.drawer { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface);
  border-left: 3px solid var(--asphalt); display: flex; flex-direction: column; box-shadow: -18px 0 40px -20px rgba(0,0,0,.5);
  animation: drawer-in .18s ease-out; outline: none; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: grid; grid-template-columns: 84px 1fr auto; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px dashed var(--border-strong); }
.drawer-head img { width: 84px; height: 63px; object-fit: cover; border-radius: 6px; }
.drawer-head h3 { margin: 0 0 6px; font-size: 20px; }
.drawer-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.drawer-x { align-self: start; font-size: 18px; }
.drawer-next { margin: 0; padding: 8px 16px; background: var(--warn-soft); font-weight: 600; font-size: 13.5px; }
.drawer-next.overdue { background: var(--bad-soft); color: var(--bad); }
.drawer-chat { flex: 1; max-height: none; border-radius: 0; margin: 0; }
.chat-event { align-self: center; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--muted); padding: 4px 10px;
  border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface); }
.chat-event div { color: var(--text); white-space: pre-wrap; }
.drawer-reply { padding: 12px 16px 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.drawer-reply textarea { min-height: 70px; }
.drawer-actions { display: flex; justify-content: space-between; gap: 8px; }
.kcard.open { border-color: var(--asphalt); box-shadow: 0 0 0 3px var(--yellow); }
body.drawer-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }

/* ---------- registrazione ---------- */
.login-tabs { align-self: stretch; display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.login-tabs button { padding: 8px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.login-form > p { margin: 0 0 6px; }
.login-ok { color: var(--good) !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
tr.u-pending td { background: var(--warn-soft); }

/* Pin con lo stesso punto: scostati a griglia (vedi drawMap) */
.pin-off { position: absolute; left: 0; top: 0; display: block; }
