/* ============================================================
   Ricerca Auto — light "pit lane" theme
   Display type: Barlow Condensed (headings, numbers, buttons). Text: Barlow.
   ============================================================ */
@import url("fonts/fonts.css");

:root {
  --bg: #eceef2;
  --bg-top: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --surface-3: #e7e9ee;
  --border: #dfe2e8;
  --border-strong: #c7ccd6;
  --text: #0f1216;
  --muted: #5f6775;
  --carbon: #15181d;
  --carbon-2: #23272e;
  --accent: #e0001f;
  --accent-dark: #b30019;
  --accent-2: #ff3b4e;
  --accent-soft: rgba(224, 0, 31, .09);
  --accent-text: #ffffff;
  --grad: linear-gradient(100deg, #ff2a44 0%, #d10020 100%);
  --grad-dark: linear-gradient(100deg, #2b3038 0%, #15181d 100%);
  --good: #0f9d58;
  --good-soft: rgba(15, 157, 88, .11);
  --warn: #b26a00;
  --warn-soft: rgba(255, 170, 0, .16);
  --bad: #d11a2a;
  --bad-soft: rgba(209, 26, 42, .10);
  --info: #1f5fd6;
  --info-soft: rgba(31, 95, 214, .10);
  --shadow: 0 14px 34px rgba(16, 22, 34, .12), 0 2px 6px rgba(16, 22, 34, .06);
  --shadow-sm: 0 2px 8px rgba(16, 22, 34, .08);
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 18px;
  --font: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Barlow Condensed", "Barlow", -apple-system, "Segoe UI", Roboto, sans-serif;
  --bar-h: 62px;
  --bar-gap: 10px;
  --cut: 9px;
  color-scheme: light;
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .45) 0 2px, transparent 2px 14px),
    linear-gradient(180deg, var(--bg-top), var(--bg) 320px);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-family: var(--display); letter-spacing: .01em; }
h1 { font-size: 34px; font-weight: 800; text-transform: uppercase; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
b, strong { font-weight: 700; }

input, select, button, textarea { font: inherit; color: inherit; }
input, select {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 11px;
  min-width: 0;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--carbon); box-shadow: 0 0 0 3px rgba(21, 24, 29, .12); }
input::placeholder { color: #9aa1ad; }

/* icons */
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
[data-icon] { display: inline-flex; }

/* ============================================================
   Buttons: cut-corner racing style
   ============================================================ */
.btn {
  --cut-l: var(--cut);
  --btn-bg: var(--carbon);
  --btn-edge: var(--carbon);
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; background: none;
  color: #fff;
  padding: 10px 18px;
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .05em; text-transform: uppercase;
  line-height: 1.1;
  cursor: pointer; white-space: nowrap; max-width: 100%;
  transition: color .15s, transform .05s, filter .15s;
}
/* The slanted shape is drawn by two layers: the edge (border colour) and, 1.5px inside, the fill;
   so outlined buttons keep a clean border along the cut sides. */
.btn::before, .btn::after {
  content: ""; position: absolute; inset: 0; z-index: -2;
  clip-path: polygon(var(--cut-l) 0, 100% 0, calc(100% - var(--cut-l)) 100%, 0 100%);
  background: var(--btn-edge);
  transition: background .15s, filter .15s;
}
.btn::after { inset: 1.5px; z-index: -1; background: var(--btn-bg); }
.btn:hover { --btn-bg: var(--carbon-2); --btn-edge: var(--carbon-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn .ic { width: 17px; height: 17px; }
.btn.primary { --btn-bg: var(--grad); --btn-edge: var(--accent-dark); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.glow { filter: drop-shadow(0 8px 18px rgba(224, 0, 31, .3)); }
.btn.glow:hover { filter: drop-shadow(0 8px 18px rgba(224, 0, 31, .3)) brightness(1.06); }
.btn.ghost { --btn-bg: var(--surface); --btn-edge: var(--border-strong); color: var(--text); }
.btn.ghost:hover { --btn-bg: var(--surface-2); --btn-edge: var(--carbon); }
.btn.danger { color: var(--bad); }
.btn.ghost.danger { --btn-edge: rgba(209, 26, 42, .35); }
.btn.ghost.danger:hover { --btn-edge: var(--bad); }
.btn.link { background: none; color: var(--muted); font-family: var(--font); text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13px; padding: 6px; }
.btn.link::before, .btn.link::after { display: none; }
.btn.link:hover { color: var(--text); }
.btn.sm { --cut-l: 6px; padding: 7px 13px; font-size: 13px; }
.btn.xl { --cut-l: 12px; padding: 15px 24px; font-size: 18px; }
.btn.wide { width: 100%; }
.btn.icon-only { --cut-l: 5px; padding: 9px 11px; }
.btn.icon-only.sm { padding: 7px 9px; }
a.btn:hover { text-decoration: none; }

.alert { padding: 11px 14px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; }
.alert.error { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.alert.loading { display: flex; gap: 10px; align-items: center; }
.alert.loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg { min-height: 18px; font-size: 13px; color: var(--muted); }
.msg.ok { color: var(--good); }
.msg.err { color: var(--bad); }

/* logo */
.logo-mark {
  width: 36px; height: 36px; flex: none;
  background: url("icons/icon-192.png") center / contain no-repeat;
  filter: drop-shadow(0 3px 6px rgba(16, 22, 34, .18));
}
.logo-mark.big { width: 84px; height: 84px; margin: 0 auto 14px; background-image: url("icons/icon-512.png"); }

/* ============================================================
   Login
   ============================================================ */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  position: relative; overflow: hidden;
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 36px 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--grad); }
.login-card h1 { margin-bottom: 4px; }
.login-card > p { margin: 0 0 24px; }
.login-card .stack { text-align: left; }
.stack { display: grid; gap: 12px; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.login-foot { margin: 18px 0 0; }

/* ============================================================
   App shell: floating top bar
   ============================================================ */
.app { min-height: 100%; display: flex; flex-direction: column; padding-top: calc(var(--bar-h) + var(--bar-gap) * 2); }
.topbar {
  position: fixed; top: var(--bar-gap); left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(1500px, calc(100% - var(--bar-gap) * 2));
  height: var(--bar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 10px 0 16px;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(16, 22, 34, .14), 0 1px 0 rgba(255, 255, 255, .8) inset;
}
.topbar::before { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 3px; border-radius: 3px; background: var(--grad); opacity: .9; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.tabs { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; margin: 0 auto; }
.tabs button {
  position: relative; display: flex; align-items: center; gap: 7px;
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 9px; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .04em; text-transform: uppercase;
  transition: background .15s, color .15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--carbon); color: #fff; box-shadow: var(--shadow-sm); }
.tabs button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px; background: var(--accent-2); border-radius: 2px; }
.tab-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--grad); color: #fff; font-size: 11px; display: grid; place-items: center; font-family: var(--font); }
.top-right { display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
  max-width: 260px;
}
.status-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; box-shadow: 0 0 0 3px var(--good-soft); }
.status-pill.busy i { background: var(--info); animation: pulse 1s infinite alternate; box-shadow: 0 0 0 3px var(--info-soft); }
.status-pill.warn { color: var(--warn); border-color: var(--warn); }
.status-pill.warn i { background: var(--warn); animation: pulse .6s infinite alternate; box-shadow: none; }
.status-pill.error i { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
@keyframes pulse { from { opacity: 1; } to { opacity: .3; } }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--carbon); color: #fff; font-family: var(--display); font-weight: 800; font-size: 15px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
.avatar.sm { width: 30px; height: 30px; font-size: 13px; display: grid; place-items: center; flex: none; cursor: default; border-radius: 8px; }
.menu {
  position: absolute; right: 6px; top: calc(100% + 8px); z-index: 40;
  min-width: 230px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 6px;
}
.menu-head { display: grid; padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; text-align: left; font-weight: 600; }
.menu-item:hover { background: var(--surface-2); }

.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 auto 6px; width: min(1500px, calc(100% - var(--bar-gap) * 2)); padding: 10px 16px; border-radius: 12px; font-weight: 600; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner > span:not([data-icon]) { flex: 1 1 200px; min-width: 0; }

.tab { flex: 1; min-width: 0; }

/* ============================================================
   Search
   ============================================================ */
.search-hero { padding: 18px clamp(12px, 3vw, 28px) 8px; max-width: 1000px; margin: 0 auto; width: 100%; }
.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: 16px; padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.searchbox:focus-within { border-color: var(--carbon); }
.searchbox-icon { color: var(--muted); }
.searchbox input { flex: 1; border: 0; background: transparent; box-shadow: none; font-size: 17px; font-weight: 500; padding: 10px 4px; }
.searchbox input:focus { box-shadow: none; }
.searchbox .btn { padding: 12px 24px; font-size: 16px; }
.quick-picks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.quick-picks button {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.quick-picks button:hover { color: var(--text); border-color: var(--carbon); }

.filterbar-wrap { position: sticky; top: calc(var(--bar-h) + var(--bar-gap) * 2 - 6px); z-index: 20; background: linear-gradient(rgba(243, 244, 247, .95), rgba(243, 244, 247, .85)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.filterbar {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px clamp(12px, 3vw, 28px);
  max-width: 1500px; margin: 0 auto;
}
.filterbar::-webkit-scrollbar { display: none; }
.fbtn {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.fbtn:hover { border-color: var(--carbon); }
.fbtn .ic { width: 16px; height: 16px; color: var(--muted); }
.fbtn .val { color: var(--muted); font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.fbtn.on { border-color: var(--carbon); background: var(--carbon); color: #fff; }
.fbtn.on .ic, .fbtn.on .val { color: #fff; opacity: .85; }
.fbtn .count { background: var(--grad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; }
.fbtn.sort { margin-left: auto; }
.fbtn .chev { width: 14px; height: 14px; }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 clamp(12px, 3vw, 28px); max-width: 1500px; margin: 0 auto; }
.active-filters:empty { display: none; }
.afchip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 12px; font-weight: 600;
}
.afchip.exclude { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.afchip button { border: 0; background: var(--surface-3); color: inherit; border-radius: 50%; width: 18px; height: 18px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.afchip button .ic { width: 12px; height: 12px; }
.afclear { border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; }

.results { padding: 18px clamp(12px, 3vw, 28px) 60px; max-width: 1500px; margin: 0 auto; width: 100%; min-width: 0; }
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.results-head > div:first-child { min-width: 0; }
.result-count { font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: .01em; text-transform: uppercase; line-height: 1; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   Cards
   ============================================================ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 18px; min-width: 0; }
.grid > * { min-width: 0; }
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  color: inherit; text-decoration: none !important;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card.removed { opacity: .5; filter: grayscale(.6); }
.photo { position: relative; aspect-ratio: 16 / 11; background: var(--surface-3); overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .photo img { transform: scale(1.04); }
.photo::after { content: ""; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); pointer-events: none; }
.photo .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.photo .noimg .ic { width: 42px; height: 42px; opacity: .5; }
.badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 6px; z-index: 1; }
.badges > span { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(15, 18, 22, .72); color: #fff; backdrop-filter: blur(6px);
  font-family: var(--display); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 6px;
}
.badge.hot { background: var(--grad); }
.score {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  font-family: var(--display); font-weight: 800; font-size: 16px; color: var(--text);
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255, 255, 255, .35) 0);
  position: relative; flex: none;
}
.score::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: rgba(255, 255, 255, .94); }
.score span { position: relative; }
.card .body { padding: 13px 15px 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; flex: 1; min-width: 0; align-content: start; }
.card .body > * { min-width: 0; }
.card .title { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: .01em; line-height: 1.1; text-transform: uppercase; }
.card .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
/* price + km: the key facts of every listing */
.keyfacts { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.kf-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.kf-price b { font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: .01em; line-height: 1; color: var(--text); }
.kf-price s { font-size: 13px; color: var(--muted); }
.kf-drop { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 800; color: var(--good); background: var(--good-soft); border-radius: 999px; padding: 2px 8px; align-self: center; }
.kf-drop .ic { width: 13px; height: 13px; }
.kf-km { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; min-width: 0; }
.kf-km .ic { width: 18px; height: 18px; color: var(--accent); }
.kf-km b { font-family: var(--display); font-size: 19px; font-weight: 700; }
.kf-km.unknown b { color: var(--muted); font-weight: 600; font-size: 15px; }
.kf-kpy { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 7px; }
.kf-kpy.good { color: var(--good); background: var(--good-soft); }
.kf-kpy.warn { color: var(--warn); background: var(--warn-soft); }
.specs-mini { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.specs-mini span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.specs-mini .ic { width: 13px; height: 13px; }

.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.specs div { display: flex; align-items: center; gap: 7px; color: var(--text); min-width: 0; }
.specs div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.specs .ic { width: 15px; height: 15px; color: var(--muted); }
.card .foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); padding-top: 9px; margin-top: auto; min-width: 0; }
.card .foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.labels { display: flex; flex-wrap: wrap; gap: 5px; }
.label { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--muted); }
.tone-good { background: var(--good-soft); color: var(--good); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }

/* deal meter: where the price sits compared to the estimate */
.meter { display: grid; gap: 4px; min-width: 0; }
.meter-bar { position: relative; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--good), #c9d94a 40%, #f0a500 65%, var(--bad)); }
.meter-bar i { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--carbon); border: 2px solid #fff; transform: translate(-50%, -50%); box-shadow: var(--shadow-sm); }
.meter-text { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); min-width: 0; }
.meter-text > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-text b { color: var(--text); }
.spark { width: 100%; height: 26px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.empty { text-align: center; padding: 60px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty .ic { width: 46px; height: 46px; opacity: .5; }
.empty b { color: var(--text); font-size: 18px; font-family: var(--display); text-transform: uppercase; letter-spacing: .03em; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 28px; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-lg); height: 360px; border: 1px solid var(--border); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   Popover / drawer / chips / switches
   ============================================================ */
.scrim { position: fixed; inset: 0; z-index: 49; background: rgba(15, 18, 22, .3); }
/* Title and buttons stay put; only the middle scrolls. Height is set from JS to fit the window. */
.popover {
  position: fixed; z-index: 50;
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.sheet-handle { display: none; }
.pop-title { flex: none; font-family: var(--display); font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: 8px; padding: 14px 12px 4px 16px; }
.pop-close { margin-left: auto; }
.pop-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 16px 16px; display: grid; gap: 14px; align-content: start; }
.pop-foot { flex: none; display: flex; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.range > span { color: var(--muted); }
.range select, .range input { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  max-width: 100%;
}
.chip:hover { border-color: var(--carbon); }
.chip .cnt { color: var(--muted); font-weight: 500; font-size: 12px; }
.chip.on { background: var(--carbon); border-color: var(--carbon); color: #fff; }
.chip.on .cnt { color: #fff; opacity: .8; }
.chip.off.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.chip.static { cursor: default; }

.optlist { display: grid; gap: 6px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1.5px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 10px 12px; cursor: pointer; width: 100%; min-width: 0;
}
.opt:hover { border-color: var(--border-strong); }
.opt.on { border-color: var(--carbon); background: var(--surface-2); }
.opt .ic { color: var(--muted); }
.opt.on .ic { color: var(--accent); }
.opt b { display: block; font-size: 14px; }
.opt small { color: var(--muted); font-size: 12px; }

.switches { display: grid; gap: 4px; }
.switch { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; min-width: 0; }
.switch > span { min-width: 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 40px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; flex: none; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch span small { display: block; color: var(--muted); font-size: 12px; }

.taginput { display: flex; gap: 6px; min-width: 0; }
.taginput input { flex: 1; min-width: 0; }
.pop-body > *, .stack > * { min-width: 0; }
.searchlist { display: grid; gap: 2px; max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.searchlist label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.searchlist label:hover { background: var(--surface-2); }
.searchlist .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(440px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: 8px 18px 18px; }
.facet { border-bottom: 1px solid var(--border); padding: 12px 0; }
.facet summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.facet summary::-webkit-details-marker { display: none; }
.facet summary .ic { transition: transform .15s; color: var(--muted); }
.facet[open] summary .ic { transform: rotate(180deg); }
.facet .sel { color: var(--accent); font-size: 12px; font-weight: 700; margin-left: auto; }
.facet-body { margin-top: 10px; display: grid; gap: 8px; }

/* ============================================================
   Watches
   ============================================================ */
.watches-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); max-width: 1500px; margin: 0 auto; width: 100%; padding: 0 clamp(12px, 3vw, 28px); gap: 18px; }
.watch-list-pane { padding: 18px 0; position: sticky; top: calc(var(--bar-h) + var(--bar-gap) * 2); height: calc(100vh - var(--bar-h) - var(--bar-gap) * 2); overflow: auto; min-width: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: center; margin: 0 4px 14px; }
.witem {
  display: grid; gap: 6px; width: 100%; text-align: left;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; cursor: pointer; min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.witem:hover { border-color: var(--border-strong); }
.witem.active { border-color: var(--carbon); box-shadow: inset 4px 0 0 var(--accent), var(--shadow-sm); }
.witem-head { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.witem-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.witem-stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.witem-stats b { color: var(--text); }
.newpill { background: var(--grad); color: #fff; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 8px; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.paused { background: var(--muted); }
.dot.error { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.dot.running { background: var(--info); animation: pulse 1s infinite alternate; }

.watch-detail { padding: 18px 0 60px; min-width: 0; }
.whero {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.whero::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--grad); }
.whero-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.whero-top > div { min-width: 0; }
.whero h2 { font-size: 28px; font-weight: 800; text-transform: uppercase; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.whero .chips { margin: 10px 0 8px; }
.whero .chip { cursor: default; font-weight: 500; }
.wactions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px; margin-bottom: 16px; }
.stats .stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; min-width: 0; box-shadow: var(--shadow-sm); }
.stat .v { font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .k .ic { width: 14px; height: 14px; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lchip { border: 1.5px solid transparent; border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 700; cursor: pointer; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-sm); }
.lchip.on { border-color: currentColor; }
.events { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 16px; max-height: 360px; overflow: auto; }
.event { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.event:last-child { border-bottom: 0; }
.event-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.event-main { min-width: 0; }
.event-main a, .event-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-price { font-family: var(--display); font-weight: 700; font-size: 15px; text-align: right; white-space: nowrap; }

/* ============================================================
   Settings / panels
   ============================================================ */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 18px; padding: 18px clamp(12px, 3vw, 28px) 60px; max-width: 1400px; margin: 0 auto; align-items: start; }
.panel { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow-sm); overflow: hidden; }
.panel::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--grad-dark); }
.panel > * { min-width: 0; }
.panel-head { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.panel-head > div { min-width: 0; flex: 1; }
.panel-head p { margin: 2px 0 0; }
.panel-icon { width: 40px; height: 40px; border-radius: 10px; display: grid !important; place-items: center; background: var(--carbon); color: var(--accent-2); flex: none; clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px); }
.steps { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > * { min-width: 0; }
.field > span { font-weight: 700; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.row input { flex: 1; min-width: 140px; }
.list { display: grid; gap: 6px; }
.li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; min-width: 0;
}
.li .grow { flex: 1; min-width: 0; }
.li .grow > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li code { font-size: 13px; letter-spacing: .06em; }
.li > code, .li > b { overflow-wrap: anywhere; min-width: 0; }
.pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.off { background: var(--surface-3); color: var(--muted); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.invite-new {
  border: 1.5px dashed var(--accent); background: var(--accent-soft);
  border-radius: var(--r); padding: 16px; display: grid; gap: 10px; text-align: center;
}
.invite-new .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 24px; font-weight: 800; letter-spacing: .12em; }

/* ============================================================
   Dialogs & toast
   ============================================================ */
dialog {
  border: 1px solid var(--border-strong); border-radius: 20px; padding: 0;
  background: var(--surface); color: var(--text);
  width: min(540px, calc(100vw - 24px)); box-shadow: var(--shadow);
}
dialog.wide-dialog { width: min(1100px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 18, 22, .5); backdrop-filter: blur(3px); }
.dialog-body { padding: 22px; display: grid; gap: 14px; min-width: 0; }
.dialog-body > * { min-width: 0; }
.dialog-title { display: flex; align-items: center; gap: 12px; }
.dialog-body input[type="text"], .dialog-body input[type="number"], .dialog-body select { width: 100%; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.dialog-actions .muted { margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shot-wrap { background: var(--surface-2); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.shot-wrap img { display: block; width: 100%; height: auto; cursor: crosshair; min-height: 200px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--carbon); color: #fff; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow);
  animation: toastin .2s ease; max-width: calc(100vw - 32px);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }

/* favourite heart on the photo */
.fav-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(15, 18, 22, .55); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .15s, background .15s;
}
.fav-btn .ic { width: 19px; height: 19px; }
.fav-btn:hover { background: rgba(15, 18, 22, .75); }
.fav-btn.on { color: var(--accent); background: #fff; }
.fav-btn.on .ic { fill: currentColor; }
.fav-btn.pop { animation: favpop .3s ease; }
@keyframes favpop { 50% { transform: scale(1.25); } }

/* saved searches list */
.opt.saved { padding: 0 6px 0 0; gap: 0; }
.saved-main { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; text-align: left; background: none; border: 0; padding: 10px 12px; cursor: pointer; color: inherit; }
.saved-main > span { min-width: 0; }
.saved-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* owner-only controls */
body:not(.is-owner) .owner-only { display: none !important; }
body.is-owner .not-owner { display: none !important; }

/* ============================================================
   AI assistant
   ============================================================ */
.ai-tab { position: relative; }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; margin-left: 2px; }
.ai-tab.ai-on .ai-dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.ai-tab.ai-off { opacity: .6; }
.tabs-top .ai-tab.ai-off:hover::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; z-index: 60; font-size: 12px; font-weight: 600; font-family: var(--font); text-transform: none; letter-spacing: 0;
  background: var(--carbon); color: #fff; padding: 7px 11px; border-radius: 9px; box-shadow: var(--shadow);
}
.ai-wrap { max-width: 1500px; margin: 0 auto; padding: 18px clamp(12px, 3vw, 28px) 60px; min-width: 0; }
.ai-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.ai-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); max-width: 100%; }
.ai-pill i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.ai-pill.on i { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.ai-pill.warn i { background: var(--warn); }
.ai-offline {
  max-width: 620px; margin: 30px auto; text-align: center; display: grid; gap: 14px; justify-items: center;
  background: var(--surface); border: 1.5px dashed var(--border-strong); border-radius: 22px; padding: 34px 26px;
}
.ai-offline .steps { text-align: left; }
.ai-off-icon { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.ai-off-icon .ic { width: 36px; height: 36px; }
.ai-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); gap: 18px; align-items: start; }
.ai-left { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; min-width: 0; }

/* radar */
.radar-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.radar-form > .field:first-child, .radar-form > .radar-segs-field, .radar-form > .switch { grid-column: 1 / -1; }
.radar-form > .switch { padding: 2px 0; }
.radar-form .row input { min-width: 0; }
.radar-form select, .radar-form input:not([type="checkbox"]) { width: 100%; }
.radar-form.busy > *:not(:has(#radar-auto)) { opacity: .5; pointer-events: none; }
.radar-run { display: grid; gap: 6px; }
.radar-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.radar-bar i { display: block; height: 100%; width: 3%; border-radius: 4px; background: var(--grad); transition: width .5s; }
.radar-run-text { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.radar-run-text span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* economics of a listing */
.econ { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.econ > * { min-width: 0; }
.econ-flow { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.econ-flow > div, .pick-prices > div { display: grid; gap: 1px; min-width: 0; }
.econ-flow > div:last-child, .pick-prices > div:last-child { text-align: right; }
.econ-flow small, .pick-prices small { font-size: 11px; color: var(--muted); }
.econ-flow b, .pick-prices b { font-family: var(--display); font-size: 19px; font-weight: 700; white-space: nowrap; }
.econ-arrow { color: var(--muted); font-size: 18px; flex: none; }
.econ-margin { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-3); }
.econ-margin > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.econ-margin b { font-family: var(--display); font-size: 22px; font-weight: 800; white-space: nowrap; }
.econ-margin small { grid-column: 1 / -1; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.econ-margin.tone-good { background: var(--good-soft); } .econ-margin.tone-good b { color: var(--good); }
.econ-margin.tone-warn { background: var(--warn-soft); } .econ-margin.tone-warn b { color: var(--warn); }
.econ-margin.tone-bad { background: var(--bad-soft); } .econ-margin.tone-bad b { color: var(--bad); }
.risk { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.risk b { font-size: 12px; white-space: nowrap; }
.risk-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.risk-bar i { display: block; height: 100%; border-radius: 3px; }
.c-good { color: var(--good); } .c-warn { color: var(--warn); } .c-bad { color: var(--bad); } .c-muted { color: var(--muted); }
.econ-table { width: 100%; font-size: 12px; border-collapse: collapse; margin-top: 6px; table-layout: fixed; }
.econ-table td { padding: 3px 0; border-bottom: 1px dashed var(--border); vertical-align: top; overflow-wrap: anywhere; }
.econ-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8px; width: 7.5em; }
.econ-table td[colspan] { white-space: normal; text-align: left; width: auto; padding-left: 0; font-size: 11px; }
.econ-table tr.sub td { font-weight: 700; }
.econ-table tr.total td { font-weight: 800; border-bottom: 0; font-size: 13px; }
.econ ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.econ p, .econ li { overflow-wrap: anywhere; }

/* market, alternatives, radar picks */
.mkt, .alt { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); min-width: 0; box-shadow: var(--shadow-sm); }
.mkt > *, .alt > * { min-width: 0; }
.alt.rec { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good), var(--shadow-sm); }
.mkt-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.mkt-head > div { min-width: 0; }
.mkt-head b { font-family: var(--display); font-size: 18px; text-transform: uppercase; letter-spacing: .02em; }
.mkt-head .ic { width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
.mkt p, .alt p { margin: 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.mkt ul { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 4px; }
.mkt.avoid { border-color: var(--bad-soft); box-shadow: inset 4px 0 0 var(--bad), var(--shadow-sm); }
.mkt-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.mkt-stats .stat { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--surface-3); max-width: 100%; }
.mkt-stats .stat b { font-weight: 800; }
.mkt-stats .stat.good { background: var(--good-soft); color: var(--good); }
.mkt-stats .stat.bad { background: var(--bad-soft); color: var(--bad); }
.mkt-stats .stat.muted { background: none; color: var(--muted); padding-left: 0; }
.opp { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-weight: 800; font-size: 16px; flex: none; }
.opp i { display: inline-block; width: 44px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--c) var(--p), var(--surface-3) var(--p)); }
.ai-section-title { margin: 14px 0 0; font-size: 20px; text-transform: uppercase; letter-spacing: .03em; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-section-title .ic { width: 18px; height: 18px; color: var(--accent); }
.ai-section-title .muted { font-family: var(--font); text-transform: none; letter-spacing: 0; font-weight: 500; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.pick { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); align-content: start; min-width: 0; box-shadow: var(--shadow-sm); }
.pick > * { min-width: 0; }
.pick-head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.pick-head > div { min-width: 0; }
.pick-head b { font-family: var(--display); font-size: 20px; text-transform: uppercase; }
.pick-title { font-weight: 700; color: var(--accent); }
.pick p { margin: 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.pick-prices { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.pick .btn { justify-self: start; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; max-width: 100%; background: var(--surface); }
.radar-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 820px; }
.radar-table th, .radar-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.radar-table th { font-family: var(--display); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
.radar-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.radar-table tr.err td { color: var(--muted); }
.radar-table tr.picked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.radar-table tbody tr:last-child td { border-bottom: 0; }
.trend-cell { display: flex; align-items: center; gap: 8px; }
.trend-cell .spark { width: 80px; height: 22px; }
.mobile-switch { display: none; }
.ai-steps { display: grid; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.ai-step { display: flex; gap: 9px; align-items: center; color: var(--muted); min-width: 0; }
.ai-step i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.ai-step.now { color: var(--text); }
.ai-step.now i { background: var(--accent); animation: pulse .7s infinite alternate; }
.ai-step.err { color: var(--bad); }
.ai-step.err i { background: var(--bad); }
.ai-report-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.ai-report-head b { font-family: var(--display); font-size: 18px; text-transform: uppercase; letter-spacing: .02em; }
.ai-summary { margin: 4px 0; padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); line-height: 1.55; box-shadow: var(--shadow-sm); }
.ai-grid-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.ai-block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.ai-block > * { min-width: 0; }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-head .row { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.verdict { display: inline-flex; align-items: center; gap: 5px; font-family: var(--display); font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; padding: 3px 10px; border-radius: 6px; background: var(--surface-3); }
.verdict .ic { width: 14px; height: 14px; }
.offer { font-size: 13px; color: var(--muted); white-space: nowrap; }
.offer b { color: var(--text); font-family: var(--display); font-size: 17px; }
.ai-why { margin: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-list summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); }
.ai-list ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }
.ai-list li { overflow-wrap: anywhere; }
.open-link { justify-self: start; }
.ai-chat { display: flex; flex-direction: column; min-height: 520px; max-height: calc(100vh - 120px); position: sticky; top: calc(var(--bar-h) + var(--bar-gap) * 2); }
.ai-messages { flex: 1; overflow-y: auto; display: grid; gap: 12px; align-content: start; padding: 4px 2px 10px; min-height: 0; }
.ai-empty { display: grid; gap: 8px; }
.ai-empty .chip { text-align: left; white-space: normal; }
.msg-row { display: grid; gap: 8px; min-width: 0; }
.msg-row.user { justify-items: end; }
.bubble { max-width: 92%; padding: 10px 13px; border-radius: 14px; line-height: 1.5; font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.msg-row.user .bubble { background: var(--carbon); color: #fff; border-bottom-right-radius: 4px; }
.msg-row.assistant .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 8px; padding-left: 18px; }
.bubble .ref { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.bubble .ref .ic { width: 12px; height: 12px; }
.tool-lines { display: grid; gap: 3px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tool-lines div { display: flex; gap: 6px; align-items: center; min-width: 0; }
.tool-lines .ic { width: 12px; height: 12px; }
.chat-cards { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); width: 100%; }
.ai-input { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 12px; }
.ai-input textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 140px; min-width: 0;
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 12px; padding: 11px 12px; outline: none;
}
.ai-input textarea:focus { border-color: var(--carbon); box-shadow: 0 0 0 3px rgba(21, 24, 29, .12); }
.ai-input .btn { height: 44px; width: 44px; flex: none; }

/* saved analyses: always readable, also with the PC off */
.ai-report-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 4px; min-width: 0; }
#ai-report { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.ai-offline + .ai-report-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.ai-report-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-report-bar b { font-family: var(--display); font-size: 18px; text-transform: uppercase; letter-spacing: .03em; }
.ai-report-bar select { flex: 1 1 200px; min-width: 0; max-width: 100%; text-overflow: ellipsis; }
.ai-offline.compact { max-width: none; margin: 0 0 16px; padding: 16px 20px; grid-template-columns: auto minmax(0, 1fr) auto; text-align: left; justify-items: start; align-items: center; gap: 4px 16px; }
.ai-offline.compact .ai-off-icon { width: 48px; height: 48px; border-radius: 14px; grid-row: span 2; }
.ai-offline.compact .ai-off-icon .ic { width: 24px; height: 24px; }
.ai-offline.compact h2 { font-size: 18px; }
.ai-offline.compact > p.muted:not(.small) { margin: 0; font-size: 13px; grid-column: 2; }
.ai-offline.compact .steps, .ai-offline.compact #ai-off-detail { display: none; }
.ai-offline.compact .row { grid-column: 3; grid-row: 1 / span 2; justify-content: flex-end !important; }

/* install banner, phone tab bar, back button: hidden on desktop */
.tabs-bottom, .back-btn { display: none !important; }
.install-banner {
  position: fixed; left: 12px; right: 12px; z-index: 45;
  bottom: calc(86px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 12px 10px 12px 14px; box-shadow: var(--shadow);
  animation: toastin .25s ease;
}
.install-banner .grow { flex: 1; min-width: 0; display: grid; }
.install-banner .logo-mark { width: 44px; height: 44px; }

/* ============================================================
   Notes on favourites (team chat)
   ============================================================ */
.notes-btn { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; text-align: left; width: 100%; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: inherit; cursor: pointer; min-width: 0; }
.notes-btn:hover { border-color: var(--border-strong); }
.notes-btn.unread { border-color: var(--accent); background: var(--accent-soft); }
.notes-btn-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.notes-btn-head .ic { width: 15px; height: 15px; color: var(--accent); }
.notes-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.notes-btn-last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
dialog.notes-dialog { width: min(620px, calc(100vw - 24px)); }
.notes-wrap { display: flex; flex-direction: column; height: min(760px, calc(100dvh - 60px)); }
.notes-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notes-car { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.notes-car img, .notes-car .noimg { width: 64px; height: 48px; object-fit: cover; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-3); }
.notes-car-text { min-width: 0; flex: 1; }
.notes-car-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.notes-empty { margin: auto; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; max-width: 340px; font-size: 13px; }
.notes-empty .ic { width: 30px; height: 30px; color: var(--accent); }
.notes-day { align-self: center; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; margin: 6px 0 2px; text-transform: capitalize; }
.note-row { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; min-width: 0; }
.note-row.mine { align-self: flex-end; }
.note-avatar { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: var(--carbon); color: #fff; }
.note-bubble { padding: 8px 12px 6px; border-radius: 14px; border-bottom-left-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; display: grid; gap: 3px; }
.note-row.mine .note-bubble { background: var(--accent-soft); border-color: transparent; border-radius: 14px; border-bottom-right-radius: 4px; }
.note-row.flash .note-bubble { box-shadow: 0 0 0 2px var(--accent); }
.note-author { font-size: 12px; font-weight: 800; color: var(--accent); }
.note-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-text.deleted { font-style: italic; color: var(--muted); }
.note-quote { display: grid; gap: 1px; text-align: left; padding: 5px 9px; border-radius: 9px; border: 0; border-left: 3px solid var(--accent); background: rgba(127, 127, 127, .12); color: inherit; cursor: pointer; font-size: 12px; max-width: 100%; min-width: 0; }
.note-quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-meta { display: flex; gap: 10px; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); }
.note-meta button { border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 700; padding: 0; cursor: pointer; }
.note-meta button:hover { color: var(--accent); }
.notes-reply { display: flex; align-items: center; gap: 8px; margin: 0 16px; padding: 7px 10px; border-left: 3px solid var(--accent); border-radius: 9px; background: var(--surface-2); font-size: 12px; }
.notes-reply > div { flex: 1; min-width: 0; display: grid; }
.notes-reply span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-input { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 0; }

.rejected-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; }
.rejected-list li { min-width: 0; }
.rejected-list li a { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.rejected-list li a:hover { color: var(--accent); }

/* ============================================================
   Gestionale
   ============================================================ */
.garage { max-width: 1500px; margin: 0 auto; padding: 18px clamp(12px, 3vw, 28px) 60px; display: grid; gap: 16px; min-width: 0; }
#g-home { display: grid; gap: 16px; min-width: 0; }
.garage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.garage-head > div { max-width: 720px; min-width: 0; }
.g-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 10px; }
.g-kpi, .g-tile { display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); min-width: 0; box-shadow: var(--shadow-sm); }
.g-kpi span, .g-tile span { font-size: 12px; font-weight: 700; color: var(--muted); }
.g-kpi b, .g-tile b { font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-kpi small, .g-tile small { font-size: 11px; color: var(--muted); }
.g-kpi.good b, .g-tile.good b { color: var(--good); }
.g-kpi.bad b, .g-tile.bad b { color: var(--bad); }
.g-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.g-card { text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 0; }
.g-status { display: inline-block; font-family: var(--display); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 3px 10px; border-radius: 6px; background: var(--surface-3); color: var(--text); }
.g-status.tone-accent { background: var(--accent); color: #fff; }
.badges .g-status { box-shadow: var(--shadow-sm); }
.g-money { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.g-money > div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; min-width: 0; }
.g-money span { color: var(--muted); }
.g-money .c-good b { color: var(--good); }
.g-money .c-bad b { color: var(--bad); }

.g-detail { display: grid; gap: 16px; min-width: 0; }
.g-detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.g-detail-bar #g-saved { margin-left: auto; color: var(--good); }
.g-hero { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
.g-photo { position: relative; border-radius: 18px; overflow: hidden; background: var(--surface-3); aspect-ratio: 4 / 3; box-shadow: var(--shadow-sm); }
.g-photo img, .g-photo .noimg { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; }
.g-photo .noimg .ic { width: 48px; height: 48px; color: var(--muted); }
.g-photo-actions { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.g-photo-actions .btn { background: rgba(15, 18, 22, .7); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.g-hero-text { display: grid; gap: 10px; align-content: start; min-width: 0; }
.g-hero-text h2 { margin: 0; font-size: clamp(26px, 3vw, 36px); line-height: 1.05; text-transform: uppercase; overflow-wrap: anywhere; }
.g-steps { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; width: fit-content; max-width: 100%; }
.g-steps button { border: 0; background: none; color: var(--muted); font-family: var(--display); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-radius: 9px; cursor: pointer; }
.g-steps button.on { background: var(--carbon); color: #fff; }
.g-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.g-tile.strong { border-color: var(--border-strong); }
.g-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.g-col { display: grid; gap: 16px; min-width: 0; }
.g-col .panel h3 { margin: 0 0 4px; font-size: 18px; color: var(--text); letter-spacing: .02em; }
.g-col .panel { display: grid; gap: 12px; }
.g-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px 12px; }
.g-form .field.wide { grid-column: 1 / -1; }
.g-form input, .g-form textarea { width: 100%; min-width: 0; }
.g-form textarea { resize: vertical; background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; }
.g-move-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.g-move-form input[name="description"] { grid-column: 1 / -1; }
.g-move-form input[name="date"] { grid-column: 1 / 3; }
.g-move-form input, .g-move-form select { width: 100%; min-width: 0; }
.g-moves { display: grid; gap: 6px; }
.g-move { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.g-move-date { font-size: 12px; color: var(--muted); }
.g-move-text { display: grid; min-width: 0; font-size: 13px; }
.g-move-text span { color: var(--muted); overflow-wrap: anywhere; }
.g-move-amount { font-family: var(--display); font-size: 16px; font-weight: 700; white-space: nowrap; }
.g-move.costo .g-move-amount { color: var(--bad); }
.g-move.ricavo .g-move-amount { color: var(--good); }
.g-drop { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 18px; border: 2px dashed var(--border-strong); border-radius: 14px; cursor: pointer; color: var(--muted); }
.g-drop .ic { width: 26px; height: 26px; color: var(--accent); }
.g-drop b { color: var(--text); }
.g-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.g-files { display: grid; gap: 8px; }
.g-file { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.g-file-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.g-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.g-file-text { display: grid; min-width: 0; }
.g-file-text a { color: inherit; font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-file-text a:hover { color: var(--accent); }
.g-file-actions { display: flex; gap: 4px; }
.g-analysis summary { cursor: pointer; font-weight: 700; }
.g-analysis p, .g-analysis ul { margin: 0; font-size: 13px; line-height: 1.5; }
.garage-btn {
  position: absolute; right: 56px; bottom: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(15, 18, 22, .55); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.garage-btn .ic { width: 18px; height: 18px; }
.garage-btn:hover { transform: scale(1.08); }
.garage-btn.on { background: var(--grad); }

/* ============================================================
   "Perché?", comparables, grade, max price
   ============================================================ */
.why-row { display: flex; }
.why-btn { position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--accent); font-family: var(--display); font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 7px 14px; cursor: pointer; }
.why-btn::before, .why-btn::after { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--accent); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }
.why-btn::after { inset: 1.5px; z-index: -1; background: var(--surface); }
.why-btn .ic { width: 15px; height: 15px; }
.why-btn:hover { color: #fff; }
.why-btn:hover::after { background: var(--accent); }
dialog.why-dialog { width: min(660px, calc(100vw - 24px)); max-height: min(86vh, 900px); }
.why-body { overflow-y: auto; max-height: inherit; }
.why-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.why-head > div { min-width: 0; }
.why-head h2 { margin: 0; font-size: 26px; text-transform: uppercase; }
.why-verdict { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; font-family: var(--display); font-size: 20px; flex-wrap: wrap; }
.why-verdict.tone-neutral { background: var(--surface-2); }
.why-verdict b { text-transform: uppercase; letter-spacing: .03em; }
.why-verdict span { font-weight: 800; }
.why-body h3 { margin: 4px 0 -4px; font-size: 13px; letter-spacing: .08em; color: var(--muted); }
.why-list, .why-todo { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.why-list > li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: start; font-size: 14px; line-height: 1.5; }
.why-list > li > i { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.why-list > li > i .ic { width: 14px; height: 14px; }
.why-list > li > div { min-width: 0; }
.why-list > li.why-good > i { background: var(--good-soft); color: var(--good); }
.why-list > li.why-bad > i { background: var(--bad-soft); color: var(--bad); }
.why-list > li.why-warn > i { background: var(--warn-soft); color: var(--warn); }
.why-list > li.why-info > i { background: var(--accent-soft); color: var(--accent); }
.why-todo li { position: relative; padding: 9px 12px 9px 34px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; line-height: 1.45; }
.why-todo li::before { content: "→"; position: absolute; left: 13px; color: var(--accent); font-weight: 800; }
.why-extra { margin-top: 6px; display: grid; gap: 2px; }
.comps-list { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 12px; }
.comps-list li { min-width: 0; }
.comps-list a { color: inherit; text-decoration: none; display: block; max-width: 100%; padding: 4px 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comps-list a:hover { color: var(--accent); }
.comps-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }

.grade { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 3px 9px 3px 4px; border-radius: 6px; background: var(--surface-3); }
.grade b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--carbon); color: #fff; font-size: 13px; }
.grade.tone-good { background: var(--good-soft); color: var(--good); }
.grade.tone-good b { background: var(--good); }
.grade.tone-bad { background: var(--bad-soft); color: var(--bad); }
.grade.tone-bad b { background: var(--bad); }
.grade.tone-info { background: var(--info-soft); color: var(--info); }
.grade.tone-info b { background: var(--info); }
.econ-max { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: baseline; gap: 4px 6px; font-size: 12px; padding: 6px 10px; border-radius: 10px; background: var(--surface-3); }
.econ-max .ic { width: 14px; height: 14px; align-self: center; }
.econ-max b { font-family: var(--display); font-size: 17px; white-space: nowrap; }
.econ-max small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.econ-max.ok b { color: var(--good); }
.econ-max.tight b { color: var(--warn); }
.profile-line { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }

/* ============================================================
   Price over time (SVG drawn at the container's pixel size: never stretched)
   ============================================================ */
.market-chart { min-width: 0; }
.market-chart[hidden] { display: none; }
#market-chart { margin-bottom: 14px; }
.pchart-box { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); min-width: 0; box-shadow: var(--shadow-sm); }
.pchart-box > * { min-width: 0; }
.pchart-box.compact { padding: 10px 12px; gap: 6px; }
.pchart-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.pchart-head > div { min-width: 0; }
.pchart-head b { font-family: var(--display); font-size: 18px; text-transform: uppercase; letter-spacing: .02em; }
.pchart-head b .ic { width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
.pchart-now { display: grid; text-align: right; }
.pchart-now b { font-family: var(--display); font-size: 24px; font-weight: 800; }
.pchart-wrap { width: 100%; min-width: 0; }
.pchart { width: 100%; height: auto; display: block; }
.pchart .grid { stroke: var(--border); stroke-width: 1; }
.pchart .ax { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.pchart .area { fill: var(--accent); opacity: .1; }
.pchart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.pchart .dot { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.pchart .trend { stroke: var(--carbon); stroke-width: 1.5; stroke-dasharray: 6 5; opacity: .7; }
.pchart .stock { fill: var(--carbon); opacity: .1; }
.pchart-trend { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.pchart-trend .ic { width: 15px; height: 15px; flex: none; }
.pchart-trend.tone-good { background: var(--good-soft); color: var(--good); }
.pchart-trend.tone-bad { background: var(--bad-soft); color: var(--bad); }

/* ============================================================
   Responsive
   ============================================================ */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .card:hover .photo img { transform: none; }
}

/* top bar with six tabs: tighter on medium screens, icons only (name on hover) on small laptops */
@media (max-width: 1240px) and (min-width: 861px) {
  .topbar { gap: 10px; }
  .tabs button { padding: 7px 10px; gap: 6px; font-size: 14px; }
  .status-pill { max-width: 150px; }
}
@media (max-width: 1080px) and (min-width: 861px) {
  .tabs-top button > span:not([data-icon]) { display: none; }
  .tabs-top button { padding: 8px 12px; }
  .brand span { display: none; }
}
@media (max-width: 1100px) {
  .g-cols { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  :root { --bar-h: 54px; --bar-gap: 8px; }
  body { font-size: 15px; }
  /* iOS zooms into inputs smaller than 16px */
  input, select, textarea { font-size: 16px; }

  /* floating header, respects the notch */
  .app { padding-top: calc(var(--bar-h) + var(--bar-gap) * 2 + env(safe-area-inset-top)); }
  .topbar { top: calc(var(--bar-gap) + env(safe-area-inset-top)); padding: 0 8px 0 12px; gap: 10px; border-radius: 16px; }
  .brand { font-size: 18px; }
  .tabs-top { display: none; }
  .top-right { margin-left: auto; }
  .status-pill { max-width: 128px; padding: 6px 10px; }
  .banner { padding: 10px 14px; font-size: 14px; }

  /* floating bottom tab bar like a native app */
  .tabs-bottom {
    display: flex !important;
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40;
    margin: 0; border-radius: 18px; border: 1px solid rgba(255, 255, 255, .9);
    padding: 5px 6px;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
    box-shadow: 0 10px 30px rgba(16, 22, 34, .18);
  }
  .tabs-bottom button {
    flex: 1; flex-direction: column; gap: 3px; justify-content: center;
    padding: 6px 1px; font-size: 10.5px; letter-spacing: 0; border-radius: 12px; min-width: 0; white-space: nowrap; overflow: hidden;
  }
  .tabs-bottom button > span:not([data-icon]) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabs-bottom button .ic { width: 22px; height: 22px; }
  .tabs-bottom button.active { background: var(--carbon); color: #fff; }
  .tabs-bottom button.active::after { display: none; }
  .tabs-bottom .tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); }
  .app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* search */
  .search-hero { padding: 10px 14px 4px; }
  .searchbox { border-radius: 14px; padding: 5px 5px 5px 14px; }
  .searchbox input { font-size: 16px; padding: 9px 2px; }
  .searchbox .btn { padding: 10px 14px; font-size: 15px; }
  .quick-picks { justify-content: flex-start; margin-top: 10px; }
  .quick-picks button { padding: 6px 11px; font-size: 12px; }
  .quick-picks button:nth-child(n+7) { display: none; }
  .filterbar-wrap { top: calc(var(--bar-h) + var(--bar-gap) * 2 + env(safe-area-inset-top) - 4px); }
  .filterbar { padding: 8px 14px; }
  .fbtn { padding: 9px 13px; }
  .fbtn.sort { margin-left: 0; }
  .active-filters { padding: 0 14px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .active-filters::-webkit-scrollbar { display: none; }
  .afchip, .afclear { flex: none; }
  .results { padding: 14px 14px 24px; }
  .results-head { align-items: center; }
  .result-count { font-size: 28px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }

  /* cards: compact rows (photo left, details right) to scan quickly */
  .grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .card { flex-direction: row; border-radius: 16px; min-height: 148px; }
  .card .photo { width: 40%; max-width: 170px; flex: none; aspect-ratio: auto; }
  .card .photo::after { inset: 50% 0 0; }
  .card .badges { top: 7px; left: 7px; right: 7px; flex-direction: column; align-items: flex-start; }
  .card .badges > span:last-child { display: none; } /* seller badge: no room on the small photo */
  .fav-btn { width: 32px; height: 32px; right: 7px; bottom: 7px; }
  .fav-btn .ic { width: 16px; height: 16px; }
  .tabs-bottom .ai-dot { position: absolute; top: 6px; left: calc(50% + 9px); margin: 0; }
  .ai-wrap { padding: 12px 14px 24px; }
  .mobile-switch { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
  .mobile-switch button { flex: 1; border: 0; background: none; color: var(--muted); font-family: var(--display); font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; padding: 9px; border-radius: 9px; }
  .mobile-switch button.on { background: var(--carbon); color: #fff; }
  .ai-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-grid:not([data-show="chat"]) .ai-chat, .ai-grid[data-show="chat"] .ai-left,
  .ai-grid[data-show="radar"] .ai-hunt, .ai-grid:not([data-show="radar"]) .ai-radar { display: none; }
  .ai-left { gap: 12px; }
  .econ-flow b, .pick-prices b { font-size: 17px; }
  .ai-chat { position: static; min-height: calc(100dvh - 260px); max-height: none; }
  .ai-offline { margin: 10px 0; padding: 26px 18px; }
  .ai-offline.compact { grid-template-columns: auto minmax(0, 1fr); padding: 14px; }
  .ai-offline.compact .row { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start !important; }
  .ai-offline + .ai-report-panel { padding: 14px; }
  .ai-report-bar select { flex-basis: 100%; }
  /* analysis cards carry a lot of text: photo on top, full-width details */
  .ai-grid-cards .card, .chat-cards .card { flex-direction: column; }
  .ai-grid-cards .card .photo, .chat-cards .card .photo { width: 100%; max-width: none; aspect-ratio: 16 / 9; }
  .ai-grid-cards .card .badges > span:last-child, .chat-cards .card .badges > span:last-child { display: inline-flex; }
  .ai-grid-cards, .ai-offline + .ai-report-panel .ai-grid-cards { grid-template-columns: minmax(0, 1fr); }
  .badge { font-size: 10px; padding: 2px 7px; }
  .score { width: 34px; height: 34px; font-size: 13px; }
  .keyfacts { padding: 8px 10px; gap: 4px 8px; border-radius: 12px; }
  .kf-price b { font-size: 23px; }
  .kf-price s { display: none; }
  .kf-km b { font-size: 16px; }
  .kf-km .ic { width: 15px; height: 15px; }
  .specs-mini { font-size: 11px; gap: 3px 10px; }
  .card .body { padding: 10px 12px; gap: 6px; }
  .card .title { font-size: 17px; }
  .card .sub { font-size: 11px; }
  .specs { grid-template-columns: 1fr 1fr; gap: 3px 8px; font-size: 12px; }
  .specs .ic { width: 13px; height: 13px; }
  .meter-text { font-size: 10px; }
  .meter-text > span:first-child, .meter-text > span:last-child { display: none; }
  .labels .label { font-size: 10px; }
  .card .foot { font-size: 11px; padding-top: 6px; }

  /* watches: list → detail */
  .watches-layout { grid-template-columns: minmax(0, 1fr); padding: 0 14px; gap: 0; }
  .watch-list-pane { position: static; height: auto; padding: 14px 0; }
  .watch-detail { display: none; padding: 12px 0 24px; }
  .watches-layout.show-detail .watch-list-pane { display: none; }
  .watches-layout.show-detail .watch-detail { display: block; }
  .back-btn { display: inline-flex !important; margin: 0 0 10px; }
  .witem { padding: 14px; }
  .whero { padding: 16px; }
  .whero h2 { font-size: 24px; }
  .wactions { width: 100%; }
  .wactions .btn:not(.icon-only) { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats .stat { padding: 11px 13px; }
  .stat .v { font-size: 21px; }
  .pchart-now { text-align: left; }
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .lchip { flex: none; font-size: 11px; padding: 4px 9px; }
  .toolbar-right { justify-content: space-between; }
  .event { grid-template-columns: 34px minmax(0, 1fr); }
  .event-price { grid-column: 2; text-align: left; }

  /* settings */
  .settings { grid-template-columns: minmax(0, 1fr); padding: 14px 14px 24px; gap: 14px; }
  .panel { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .row > .btn { flex: 1 1 auto; min-width: 0; white-space: normal; text-align: center; }
  .row > .btn.icon-only { flex: none; }
  .invite-new .code { font-size: 20px; }

  /* gestionale */
  .garage { padding: 12px 14px 24px; gap: 12px; }
  .g-hero { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .g-kpi b, .g-tile b { font-size: 20px; }
  .garage-btn { width: 32px; height: 32px; right: 45px; bottom: 7px; }
  .garage-btn .ic { width: 15px; height: 15px; }
  .g-move { grid-template-columns: 52px minmax(0, 1fr) auto auto; gap: 6px; }
  .g-move-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-move-form input[name="date"] { grid-column: auto; }
  .g-move-form .btn { grid-column: 1 / -1; }
  .g-steps { width: 100%; }
  .g-steps button { flex: 1; padding: 8px 6px; }

  /* popovers become bottom sheets */
  .popover {
    left: 0 !important; right: 0; top: auto !important; bottom: 0;
    width: 100%; max-height: calc(100dvh - 40px - env(safe-area-inset-top)) !important;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    animation: sheetin .22s ease;
  }
  .sheet-handle { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .pop-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .pop-foot .btn { flex: 1; padding: 12px; font-size: 15px; }
  .scrim { background: rgba(15, 18, 22, .45); }
  .drawer { width: 100vw; padding-top: env(safe-area-inset-top); }
  .drawer .pop-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

  /* dialogs become full-width sheets */
  dialog, dialog.wide-dialog, dialog.notes-dialog, dialog.why-dialog {
    width: 100%; max-width: 100%; max-height: calc(100dvh - 30px);
    margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0;
  }
  .dialog-body { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .dialog-actions .btn { flex: 1; padding: 12px; }
  .notes-wrap { height: calc(100dvh - 30px); }
  .note-row { max-width: 92%; }
  .why-head h2 { font-size: 22px; }

  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); text-align: center; }
  .login { padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .login-card { padding: 30px 20px 22px; border-radius: 22px; }
}
@keyframes sheetin { from { transform: translateY(40px); opacity: 0; } }

/* installed app (standalone): no browser bars, keep content clear of the notch */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}

/* gestionale: selling price */
.g-sell { box-shadow: inset 0 4px 0 var(--accent), var(--shadow-sm); }
.g-sell::before { display: none; }
.g-opts { margin-bottom: 4px; }
.g-opts .chip { padding-right: 6px; gap: 4px; }
.chip-x { border: 0; background: var(--surface-3); color: var(--muted); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0; }
.chip-x .ic { width: 11px; height: 11px; }
.chip-x:hover { background: var(--bad-soft); color: var(--bad); }
.g-prices { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.g-prices .g-tile { gap: 4px; }
.g-prices .g-tile .btn { justify-self: start; margin-top: 4px; }
.g-tile.accent { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent), var(--shadow-sm); }
.g-tile.accent b { color: var(--accent); }
.g-tile.bad b { color: var(--bad); }
.g-comps { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.g-comp a { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: inherit; text-decoration: none; font-size: 13px; min-width: 0; }
.g-comp a:hover { border-color: var(--border-strong); text-decoration: none; }
.g-comp.cheaper a { box-shadow: inset 3px 0 0 var(--bad); }
.g-comp a > b { font-family: var(--display); font-size: 16px; }
.g-comp-delta { font-size: 12px; font-weight: 700; }
.g-ad { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.g-ad p { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.g-ad .btn { justify-self: start; }
.g-sell .ai-why { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
