/* ──────────────────────────────────────────────────────────────────────────
   Belvedere Immobiliare · CRM concept — design tokens + componenti condivisi
   © 2026 MoP Dev — https://mop.dev — proof of concept, dati fittizi
   ────────────────────────────────────────────────────────────────────────── */
:root {
  --bg: #f1f3f7;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eceff4;
  --border: #dde2ea;
  --border-strong: #c5ccd8;
  --text: #182230;
  --text-2: #4b5768;
  --muted: #76829a;
  --primary: #1f4e79;
  --primary-2: #173c5e;
  --primary-soft: #e4edf6;
  --accent: #0f8b8d;
  --accent-soft: #e0f3f3;
  --ok: #1e8e5a;
  --ok-soft: #e1f3ea;
  --warn: #b9731a;
  --warn-soft: #fbf0df;
  --danger: #b93a2f;
  --danger-soft: #f9e4e1;
  --info: #2f6fb3;
  --info-soft: #e5eef9;
  --violet: #6b4fbb;
  --violet-soft: #ece7f8;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 4px 14px rgba(16, 24, 40, .10);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, .18);
  --r-sm: 5px;
  --r: 8px;
  --r-lg: 12px;
  --font: Inter, "Segoe UI", Roboto, "Helvetica Neue", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --fs: 13.5px;
  --sidebar-w: 236px;
  --topbar-h: 54px;
  --on-primary: #ffffff;
  color-scheme: light;
}
/* Tema scuro: segue il sistema salvo scelta esplicita (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0f141b;
  --surface: #171d26;
  --surface-2: #1c2330;
  --surface-3: #242d3a;
  --border: #2a3441;
  --border-strong: #3b4756;
  --text: #e6ebf2;
  --text-2: #b7c0cc;
  --muted: #8591a1;
  --primary: #7cadde;
  --primary-2: #9cc1e8;
  --primary-soft: #1b2b3e;
  --accent: #46bfc1;
  --accent-soft: #123333;
  --ok: #58c994;
  --ok-soft: #133324;
  --warn: #e3a94f;
  --warn-soft: #3b2d13;
  --danger: #f08478;
  --danger-soft: #3d1c19;
  --info: #7cadde;
  --info-soft: #1b2b3e;
  --violet: #b19ff0;
  --violet-soft: #28213f;
  --on-primary: #0b1016;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141b;
  --surface: #171d26;
  --surface-2: #1c2330;
  --surface-3: #242d3a;
  --border: #2a3441;
  --border-strong: #3b4756;
  --text: #e6ebf2;
  --text-2: #b7c0cc;
  --muted: #8591a1;
  --primary: #7cadde;
  --primary-2: #9cc1e8;
  --primary-soft: #1b2b3e;
  --accent: #46bfc1;
  --accent-soft: #123333;
  --ok: #58c994;
  --ok-soft: #133324;
  --warn: #e3a94f;
  --warn-soft: #3b2d13;
  --danger: #f08478;
  --danger-soft: #3d1c19;
  --info: #7cadde;
  --info-soft: #1b2b3e;
  --violet: #b19ff0;
  --violet-soft: #28213f;
  --on-primary: #0b1016;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
p { margin: 0 0 .6em; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
img, svg, canvas, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Icone ─────────────────────────────────────────────────────────────── */
.ic { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; display: inline-block; vertical-align: -3px; }
.ic.lg { width: 20px; height: 20px; }
.ic.xl { width: 28px; height: 28px; }

/* ── Bottoni ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 500; font-size: 13px; line-height: 1.2;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-primary); }
.btn.accent:hover { filter: brightness(.93); }
.btn.danger { color: var(--danger); border-color: #e4b5b0; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.ai { border-color: var(--violet-soft); background: var(--violet-soft); color: var(--violet); }
.btn.ai:hover { filter: brightness(.95); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.xs { padding: 2px 7px; font-size: 11.5px; }
.btn.icon { padding: 7px; }
.btn.sm.icon { padding: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.btn-group .btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); position: relative; z-index: 1; }

/* ── Badge / chip ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.5;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ai { background: var(--violet-soft); color: var(--violet); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 12px; color: var(--text-2);
}
.chip b { color: var(--text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Card / pannelli ──────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.card-h h2, .card-h h3 { font-size: 14px; }
.card-b { padding: 14px 16px; }
.card-b.tight { padding: 0; }
.card-f { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.card + .card { margin-top: 14px; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 320px; }
.grid.side-l { grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 1100px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .grid.c2, .grid.c3, .grid.c4, .grid.side, .grid.side-l { grid-template-columns: minmax(0, 1fr); }
}
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.sep { height: 1px; background: var(--border); margin: 12px 0; }

/* ── KPI tile ─────────────────────────────────────────────────────────── */
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--text-2); }
.kpi.warn .val { color: var(--warn); }
.kpi.danger .val { color: var(--danger); }
.kpi.ok .val { color: var(--ok); }
.kpi.accent .val { color: var(--accent); }

/* ── Tabelle ──────────────────────────────────────────────────────────── */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort { opacity: .5; margin-left: 2px; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.link { cursor: pointer; }
.tbl tr.active { background: var(--primary-soft); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .thumb { width: 56px; height: 40px; border-radius: 4px; object-fit: cover; }
.tbl-foot { padding: 8px 12px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
@media (max-width: 760px) {
  .tbl th.hm, .tbl td.hm { display: none; }
}

/* ── Form ─────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .lbl { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); font-size: 13px; min-height: 34px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.textarea { min-height: 80px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2376829a' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; }
.input.sm, .select.sm { padding: 4px 8px; min-height: 28px; font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.switch { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { background: var(--ok); }
.switch.on::after { left: 16px; }

/* ── Definition list (dati scheda) ───────────────────────────────────── */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 500; }
.dl dd { margin: 0; font-weight: 500; }
.dl.c2 { grid-template-columns: max-content 1fr max-content 1fr; }
@media (max-width: 900px) { .dl.c2 { grid-template-columns: max-content 1fr; } }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 13px; border: 0; background: none; cursor: pointer; font-weight: 500; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .badge { font-size: 10.5px; padding: 0 6px; }

/* ── Progress / meter ─────────────────────────────────────────────────── */
.bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.primary > i { background: var(--primary); }
.score { display: inline-flex; align-items: center; gap: 8px; }
.score b { font-variant-numeric: tabular-nums; min-width: 32px; }

/* ── Timeline ─────────────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.warn::before { border-color: var(--warn); }
.timeline .when { font-size: 11.5px; color: var(--muted); }

/* ── Avatar ───────────────────────────────────────────────────────────── */
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.a2 { background: var(--accent-soft); color: var(--accent); }
.avatar.a3 { background: var(--warn-soft); color: var(--warn); }
.avatar.a4 { background: var(--violet-soft); color: var(--violet); }
.avatar.a5 { background: var(--ok-soft); color: var(--ok); }

/* ── Modal / toast ────────────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(640px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-3); animation: pop .18s; }
.modal.wide { width: min(960px, 100%); }
.modal .card-b { overflow: auto; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0 } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1b2430; color: #fff; padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-3); font-size: 13px; max-width: 360px; display: flex; gap: 8px; align-items: flex-start; animation: pop .2s; }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.warn { border-left: 4px solid var(--warn); }
.toast.danger { border-left: 4px solid var(--danger); }
.toast.ai { border-left: 4px solid var(--violet); }

/* ── Note / callout ───────────────────────────────────────────────────── */
.note { padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start; }
.note.warn { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn); }
.note.danger { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger); }
.note.ok { background: var(--ok-soft); border-color: var(--ok-soft); color: var(--ok); }
.note.info { background: var(--info-soft); border-color: var(--info-soft); color: var(--info); }
.note.ai { background: var(--violet-soft); border-color: var(--violet-soft); color: var(--violet); }
:root:not([data-theme="dark"]) .note.warn { color: #6d4410; } :root:not([data-theme="dark"]) .note.danger { color: #7a2419; } :root:not([data-theme="dark"]) .note.ok { color: #145c3a; } :root:not([data-theme="dark"]) .note.info { color: #1b4578; } :root:not([data-theme="dark"]) .note.ai { color: #3f2c7a; }
.note .ic { margin-top: 1px; }

/* ── Empty ────────────────────────────────────────────────────────────── */
.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Kbd ──────────────────────────────────────────────────────────────── */
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--text-2); }

/* ── Media viewers (condivisi CRM + pubblico) ─────────────────────────── */
.viewer { position: relative; background: #0d1420; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; user-select: none; touch-action: none; }
.viewer canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.viewer.dragging canvas { cursor: grabbing; }
.viewer .hud { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.viewer .hud .btn { background: rgba(255,255,255,.92); border-color: transparent; }
.viewer .hud .btn.active { background: var(--accent); color: #fff; }
.viewer .tag { position: absolute; top: 10px; left: 10px; background: rgba(13,20,32,.75); color: #fff; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: flex; gap: 6px; align-items: center; backdrop-filter: blur(4px); }
.viewer .tag.r { left: auto; right: 10px; }
.viewer .hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: rgba(255,255,255,.8); font-size: 12px; background: rgba(13,20,32,.5); padding: 6px 10px; border-radius: 999px; pointer-events: none; transition: opacity .3s; }
.viewer.touched .hint { opacity: 0; }
.viewer .hotspot { position: absolute; transform: translate(-50%, -50%); background: rgba(255,255,255,.95); color: var(--text); border: 0; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-2); display: flex; gap: 4px; align-items: center; }
.viewer .hotspot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(15,139,141,.3); }
.viewer.vr { position: fixed; inset: 0; z-index: 300; border-radius: 0; aspect-ratio: auto; background: #000; }
.viewer.vr canvas { height: 100%; }
.viewer .stereo { display: none; position: absolute; inset: 0; }
.viewer.vr .stereo { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.viewer.vr .stereo canvas { width: 100%; height: 100%; }
.viewer.vr > canvas.main { display: none; }
.viewer.vr .stereo::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: #333; }
.viewer.vr .hotspot { display: none; }
.viewer.vr .hud { bottom: 18px; justify-content: center; }
.viewer .reticle { display: none; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.8); border-radius: 50%; transform: translate(-50%,-50%); pointer-events: none; }
.viewer.vr .reticle { display: block; }

/* Mappa 3D (CSS 3D) */
.map3d { position: relative; background: linear-gradient(#dbe6f1, #eef3f8); border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; perspective: 900px; user-select: none; touch-action: none; cursor: grab; border: 1px solid var(--border); }
.map3d.dragging { cursor: grabbing; }
.map3d .scene { position: absolute; left: 50%; top: 52%; width: 0; height: 0; transform-style: preserve-3d; }
.map3d .ground { position: absolute; width: 640px; height: 640px; left: -320px; top: -320px; background: #cfdac4; background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 40px 40px; transform-style: preserve-3d; box-shadow: 0 0 0 2px #b7c5ad; }
.map3d .road { position: absolute; background: #8e949c; transform-style: preserve-3d; }
.map3d .road::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(var(--dir, 90deg), transparent 0 14px, rgba(255,255,255,.7) 14px 24px); background-size: 100% 100%; opacity: .6; }
.map3d .road.h::after { --dir: 90deg; height: 2px; top: 50%; }
.map3d .road.v::after { --dir: 0deg; width: 2px; left: 50%; }
.map3d .park { position: absolute; background: #9fc18b; border-radius: 10px; }
.map3d .water { position: absolute; background: #8db8d8; }
.map3d .bld { position: absolute; transform-style: preserve-3d; }
.map3d .bld > i { position: absolute; left: 0; top: 0; display: block; background: var(--c, #e7e4dd); border: 1px solid rgba(0,0,0,.12); }
.map3d .bld.subject > i { background: var(--c, #2b8f8f); border-color: rgba(0,0,0,.25); }
.map3d .bld.subject .top { background: #1f4e79 !important; }
.map3d .bld .win { background-image: repeating-linear-gradient(0deg, transparent 0 8px, rgba(0,0,0,.14) 8px 11px), repeating-linear-gradient(90deg, transparent 0 8px, rgba(0,0,0,.14) 8px 11px); }
.map3d .pin { position: absolute; transform-style: preserve-3d; }
.map3d .pin > span { position: absolute; left: -60px; width: 120px; text-align: center; background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 6px; border-radius: 999px; white-space: nowrap; box-shadow: var(--shadow-2); }
.map3d .pin.poi > span { background: #fff; color: var(--text); border: 1px solid var(--border-strong); font-weight: 500; }
.map3d .hud { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.map3d .hud .btn { background: rgba(255,255,255,.95); }
.map3d .tag { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.9); padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; box-shadow: var(--shadow-1); }
.map3d .compass { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; box-shadow: var(--shadow-1); }

/* Video visita (simulato) */
.vplayer { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; }
.vplayer canvas { width: 100%; height: 100%; }
.vplayer .ctrls { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; background: linear-gradient(transparent, rgba(0,0,0,.75)); display: flex; gap: 8px; align-items: center; color: #fff; font-size: 12px; }
.vplayer .ctrls .btn { background: rgba(255,255,255,.92); border-color: transparent; }
.vplayer .track { flex: 1; height: 6px; background: rgba(255,255,255,.3); border-radius: 999px; position: relative; cursor: pointer; }
.vplayer .track > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
.vplayer .track .mk { position: absolute; top: -4px; width: 3px; height: 14px; background: #ffd166; border-radius: 2px; transform: translateX(-50%); cursor: pointer; }
.vplayer .rec { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; align-items: center; color: #fff; font-size: 11.5px; font-weight: 600; background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 999px; }
.vplayer .rec::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #e63946; }
.vplayer .tc { font-family: var(--mono); font-size: 11.5px; min-width: 84px; text-align: right; }

/* Galleria */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gallery .ph { position: relative; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; aspect-ratio: 4 / 3; }
.gallery .ph svg { width: 100%; height: 100%; }
.gallery .ph .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 11px; background: rgba(13,20,32,.6); color: #fff; }
.gallery .ph.main { grid-column: span 2; grid-row: span 2; }
.ph-cover { border-radius: var(--r); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); aspect-ratio: 16 / 10; }
.ph-cover svg { width: 100%; height: 100%; }

/* Stepper */
.stepper { display: flex; gap: 0; counter-reset: s; overflow-x: auto; }
.stepper .st { flex: 1; min-width: 120px; position: relative; padding: 8px 10px 8px 34px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; counter-increment: s; }
.stepper .st::before { content: counter(s); position: absolute; left: 10px; top: 9px; width: 18px; height: 18px; border-radius: 50%; background: var(--border-strong); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.stepper .st.done { background: var(--ok-soft); }
.stepper .st.done::before { background: var(--ok); content: "✓"; }
.stepper .st.cur { background: var(--primary-soft); border-color: var(--primary); }
.stepper .st.cur::before { background: var(--primary); }
.stepper .st b { display: block; font-size: 12.5px; }

/* Utility print */
@media print { .no-print { display: none !important; } }

/* ── Tooltip ──────────────────────────────────────────────────────────── */
.tooltip { position: fixed; z-index: 400; background: #1b2430; color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 6px; max-width: 280px; pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity .12s, transform .12s; box-shadow: var(--shadow-2); line-height: 1.35; }
.tooltip.show { opacity: 1; transform: none; }
.tooltip::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-top-color: #1b2430; border-bottom: 0; }
.tooltip.below::after { bottom: auto; top: -5px; border-top: 0; border-bottom: 5px solid #1b2430; }

/* ── Tour guidato ─────────────────────────────────────────────────────── */
.tour-bg { position: fixed; inset: 0; z-index: 500; }
.tour-spot { position: fixed; z-index: 501; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(16, 24, 40, .55), 0 0 0 3px var(--accent); pointer-events: none; transition: left .25s, top .25s, width .25s, height .25s; }
.tour-card { position: fixed; z-index: 502; width: min(360px, calc(100vw - 24px)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 14px 16px 12px; animation: pop .2s; transition: opacity .2s; }
.tour-card.hide, .tour-spot.hide { opacity: 0 !important; pointer-events: none; }
.tour-card h3 { font-size: 14px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.tour-card h3 .ic { color: var(--accent); }
.tour-card p { font-size: 13px; color: var(--text-2); margin: 0 0 10px; line-height: 1.5; }
.tour-card .tf { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tour-card .tf .n { font-size: 11.5px; color: var(--muted); margin-right: auto; font-variant-numeric: tabular-nums; }

/* ── Tour: cursore animato ───────────────────────────────────────────── */
.tour-cursor { position: fixed; left: 0; top: 0; z-index: 503; width: 30px; height: 30px; margin: -4px 0 0 -4px; pointer-events: none; opacity: 0; transition: transform .55s cubic-bezier(.22, .8, .3, 1), opacity .25s; }
.tour-cursor svg { width: 30px; height: 30px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); transition: transform .12s; transform-origin: 6px 4px; }
.tour-cursor.click svg { transform: scale(.82); }
.tour-cursor .wheel { display: none; position: absolute; left: 26px; top: 14px; width: 14px; height: 22px; border: 2px solid #1b2430; border-radius: 8px; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.35); }
.tour-cursor .wheel i { position: absolute; left: 4px; width: 2px; height: 5px; border-radius: 2px; background: var(--accent); animation: wheel .7s linear infinite; }
.tour-cursor.scrolling .wheel { display: block; }
@keyframes wheel { from { top: 3px; opacity: 1 } to { top: 12px; opacity: .2 } }
.tour-ripple { position: fixed; z-index: 502; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 3px solid var(--accent); box-shadow: 0 0 0 2px rgba(255,255,255,.7); pointer-events: none; animation: ripple .5s ease-out forwards; }
@keyframes ripple { from { transform: scale(.5); opacity: 1 } to { transform: scale(4.5); opacity: 0 } }

/* ── Telefono: tabelle a schede, modali a foglio, input senza zoom iOS ─ */
@media (max-width: 760px) {
  .input, .select, .textarea { font-size: 16px; }
  .input.sm, .select.sm { font-size: 14px; }
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody { display: block; width: 100%; }
  .tbl.stack tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .tbl.stack tbody tr.link:active { background: var(--surface-2); }
  .tbl.stack td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
  .tbl.stack td.hm { display: block; }
  .tbl.stack td.mh { display: none; }
  .tbl.stack td::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 1px; }
  .tbl.stack td[data-label=""]::before, .tbl.stack td.pri::before { display: none; }
  .tbl.stack td.pri { grid-column: 1 / -1; font-size: 14px; }
  .tbl.stack td.act { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
  .tbl.stack td.act:empty { display: none; }
  .tbl.stack td.act .row { justify-content: flex-start !important; }
  .tbl.stack td.mh { display: none; }
  .doclist .doc .nm { flex: 1 1 60%; }
  .doclist .doc .nm .input.sm { max-width: none; }
  .tbl-foot { padding: 8px 14px; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; animation: sheet .22s; }
  .modal .card-f { padding-bottom: calc(10px + env(safe-area-inset-bottom)); border-radius: 0; }
  .toasts { left: 12px; right: 12px; bottom: 70px; }
  .toast { max-width: none; }
  .tour-card { width: calc(100vw - 20px); }
  .viewer, .map3d { aspect-ratio: 4 / 3; }
  .viewer .hud, .map3d .hud { left: 6px; right: 6px; bottom: 6px; gap: 4px; }
  .viewer .hud .btn, .map3d .hud .btn { padding: 5px 7px; font-size: 11.5px; }
  .viewer .hud .btn .ic, .map3d .hud .btn .ic { width: 15px; height: 15px; }
  .viewer .hint, .map3d .hud .small { display: none; }
  .viewer .tag { font-size: 10.5px; padding: 2px 7px; }
  .viewer .tag.r { top: 34px; right: auto; left: 10px; }
  .map3d .tag { font-size: 10.5px; max-width: calc(100% - 60px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .viewer.vr { aspect-ratio: auto; }
  .stepper .st { min-width: 104px; }
}
@keyframes sheet { from { transform: translateY(24px); opacity: 0 } }

/* ── Popover / menu a comparsa ───────────────────────────────────────── */
.popover { position: fixed; z-index: 150; min-width: 264px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 6px; animation: pop .15s; }
.popover .ph { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.popover .ph b { display: block; font-size: 13.5px; }
.popover .ph span:not(.avatar) { font-size: 12px; color: var(--muted); display: block; line-height: 1.35; }
.popover .ph .avatar { flex: none; }
.popover .it { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); text-align: left; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; text-decoration: none; }
.popover .it:hover, .popover .it:focus-visible { background: var(--surface-2); outline: none; text-decoration: none; }
.popover .it .ic { color: var(--text-2); }
.popover .it .lbl { flex: 1; }
.popover .it .lbl small { display: block; color: var(--muted); font-size: 11.5px; }
.popover .it .r { font-size: 11.5px; color: var(--muted); }
.popover .it.danger { color: var(--danger); }
.popover .it.danger .ic { color: var(--danger); }
.popover .sep { height: 1px; background: var(--border); margin: 6px 4px; }
@media (max-width: 760px) { .popover { left: 8px !important; right: 8px; min-width: 0; width: calc(100vw - 16px); } .popover .it { padding: 11px 10px; font-size: 14px; } }

/* ── RTL (arabo) ─────────────────────────────────────────────────────── */
[dir="rtl"] .timeline { padding: 0 18px 0 0; border-left: 0; border-right: 2px solid var(--border); }
[dir="rtl"] .timeline li { padding: 0 12px 14px 0; }
[dir="rtl"] .timeline li::before { left: auto; right: -24px; }
[dir="rtl"] .select { background-position: left 9px center; padding-right: 10px; padding-left: 28px; }
[dir="rtl"] .toasts { right: auto; left: 16px; }
[dir="rtl"] .toast { border-left: 0; border-right: 4px solid transparent; }
[dir="rtl"] .toast.ok { border-right-color: var(--ok); } [dir="rtl"] .toast.warn { border-right-color: var(--warn); } [dir="rtl"] .toast.danger { border-right-color: var(--danger); } [dir="rtl"] .toast.ai { border-right-color: var(--violet); }
.popover .it.muted { font-size: 11.5px; color: var(--muted); white-space: normal; cursor: default; line-height: 1.4; }
.popover .it.muted:hover { background: none; }
