/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0f1e;
  --bg2:       #111827;
  --bg3:       #1f2937;
  --bg4:       #374151;
  --accent:    #e85d26;
  --accent2:   #f97316;
  --accent-soft: rgba(232,93,38,.12);
  --blue:      #3b82f6;
  --green:     #22c55e;
  --yellow:    #eab308;
  --red:       #ef4444;
  --text:      #f9fafb;
  --text2:     #9ca3af;
  --text3:     #6b7280;
  --border:    #1f2937;
  --border2:   #374151;
  --radius:    12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  --transition: .18s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 600; }
p  { line-height: 1.6; color: var(--text2); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ── Top bar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem;
  background: rgba(10,15,30,.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  height: 48px;
}

/* Bottom tab bar */
.bottom-tabs {
  display: flex; align-items: stretch;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(10,15,30,.97);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(56px + env(safe-area-inset-bottom, 0px));
}
.btab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .15rem;
  background: none; border: none; color: var(--text3);
  font-size: .65rem; cursor: pointer; padding: .35rem 0;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btab-icon { font-size: 1.15rem; }
.btab-label { font-weight: 500; }
.btab.active { color: var(--accent2); }
.btab:active { transform: scale(.92); }

.nav-logo {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 800; font-size: 1rem; color: var(--text);
  text-decoration: none; letter-spacing: -.02em;
  flex-shrink: 0; white-space: nowrap; z-index: 1;
}

.nav-logo .logo-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; box-shadow: 0 2px 8px rgba(232,93,38,.4);
  flex-shrink: 0;
}

.logo-img {
  width: 38px; height: 38px; border-radius: 8px;
  object-fit: contain; flex-shrink: 0;
}

.nav-logo .logo-accent { color: var(--accent); font-style: italic; }

@media (max-width: 380px) { .nav-logo .logo-casa { display: none; } }

/* Tab centrati in assoluto — non interferiscono con logo/account */
.nav-tabs {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex; gap: .15rem;
  background: var(--bg2); border-radius: 8px; padding: 2px;
  border: 1px solid var(--border);
  pointer-events: auto;
}

.btn-account {
  flex-shrink: 0; z-index: 1;
}

.nav-tab {
  padding: .28rem .65rem; border-radius: 6px; border: none;
  background: transparent; color: var(--text2);
  font-size: .76rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}

.nav-tab:hover { color: var(--text); background: var(--bg3); }
.nav-tab.active { background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(232,93,38,.35); }

/* ── Main content ─────────────────────────────────────────────────────────── */
main { flex: 1; padding: .75rem 1rem calc(60px + env(safe-area-inset-bottom, 0px)); max-width: 680px; margin: 0 auto; width: 100%; }

/* ── Views ────────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 2rem 0 1.5rem; }

.hero-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(232,93,38,.1); border: 1px solid rgba(232,93,38,.25);
  color: var(--accent2); border-radius: 999px;
  padding: .28rem .85rem; font-size: .75rem; font-weight: 600;
  margin-bottom: 1rem; letter-spacing: .02em;
}

.hero h1 { margin-bottom: .5rem; }
.hero h1 span { color: var(--accent); }
.hero p { font-size: .95rem; margin-bottom: 1.75rem; }

/* ── Search ───────────────────────────────────────────────────────────────── */
.search-wrap { position: relative; margin-bottom: .5rem; }

.search-wrap .search-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none; font-size: 1rem;
}

#search-input {
  width: 100%; padding: .9rem 1rem .9rem 2.75rem;
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: var(--radius); color: var(--text);
  font-size: 1rem; outline: none; transition: var(--transition);
}

#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,38,.15); }
#search-input::placeholder { color: var(--text3); }

/* ── Autocomplete ─────────────────────────────────────────────────────────── */
#autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); z-index: 200; display: none;
  max-height: 280px; overflow-y: auto;
}
#autocomplete.open { display: block; }

.ac-item {
  padding: .7rem 1rem; cursor: pointer;
  display: flex; align-items: center; gap: .75rem;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.focused { background: var(--bg3); }

.ac-item .ac-badge {
  background: var(--accent-soft); color: var(--accent2);
  border-radius: 5px; padding: .15rem .45rem;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
}
.ac-item .ac-name { font-weight: 600; font-size: .92rem; }
.ac-item .ac-region { font-size: .75rem; color: var(--text3); }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.15rem;
  margin-bottom: .85rem;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .85rem;
}

/* ── Zone list ────────────────────────────────────────────────────────────── */
.zone-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1.1rem;
  margin-bottom: .6rem; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
}
.zone-item:hover { border-color: var(--accent); background: rgba(232,93,38,.04); }
.zone-item .zone-info { flex: 1; min-width: 0; }
.zone-item .zone-info h3 {
  margin-bottom: .15rem; font-size: .92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zone-item .zone-info p { font-size: .78rem; margin: 0; }

.zone-badge {
  background: var(--bg3); color: var(--text2);
  border-radius: var(--radius-xs); padding: .18rem .5rem;
  font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.fascia-B { background: rgba(59,130,246,.15); color: #60a5fa; }
.fascia-C { background: rgba(34,197,94,.12); color: var(--green); }
.fascia-D { background: rgba(234,179,8,.12); color: var(--yellow); }
.fascia-E { background: rgba(239,68,68,.12); color: var(--red); }
.fascia-R { background: rgba(156,163,175,.1); color: var(--text2); }

/* ── Section title ────────────────────────────────────────────────────────── */
.section-title {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text3); margin-bottom: .7rem;
}

/* ── Input row ────────────────────────────────────────────────────────────── */
.input-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-bottom: .65rem;
}
.input-group { display: flex; flex-direction: column; gap: .3rem; }
.input-group label { font-size: .78rem; color: var(--text2); font-weight: 500; }
.input-group input {
  background: var(--bg3); border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: .55rem .8rem; font-size: .95rem; outline: none;
  transition: border-color var(--transition);
}
.input-group input:focus { border-color: var(--accent); }

/* ── Condition items ──────────────────────────────────────────────────────── */
.condition-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 0; border-bottom: 1px solid var(--border);
  gap: .5rem;
}
.condition-item:last-child { border-bottom: none; }
.condition-left { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; }
.condition-icon { font-size: 1.2rem; width: 1.8rem; text-align: center; }
.condition-label { font-size: .85rem; font-weight: 500; }
.condition-weight { font-size: .7rem; color: var(--text3); }

.condition-buttons { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

.cond-btn {
  padding: .32rem .65rem; border-radius: var(--radius-xs);
  border: 1.5px solid var(--border2);
  background: transparent; color: var(--text2); font-size: .75rem;
  font-weight: 600; cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.cond-btn:hover { border-color: var(--text2); color: var(--text); }
.cond-btn.ok   { background: rgba(34,197,94,.12);  border-color: var(--green);  color: var(--green); }
.cond-btn.bad  { background: rgba(239,68,68,.12);  border-color: var(--red);    color: var(--red); }
.cond-btn.na   { background: rgba(156,163,175,.08); border-color: var(--text3); color: var(--text3); }
.cond-btn.warn { background: rgba(234,179,8,.12);  border-color: var(--yellow); color: var(--yellow); }

/* Energy class buttons */
.energy-btn { padding: .28rem .4rem; min-width: 30px; font-size: .7rem; font-weight: 700; }

/* ── Result card ──────────────────────────────────────────────────────────── */
.result-card {
  background: linear-gradient(135deg, rgba(232,93,38,.12), rgba(249,115,22,.06));
  border: 1.5px solid rgba(232,93,38,.3);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: .85rem;
  text-align: center;
}
.result-label {
  font-size: .72rem; color: var(--text2); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: .4rem;
}
.result-value {
  font-size: 2.6rem; font-weight: 900; letter-spacing: -.04em;
  background: linear-gradient(135deg, #fff 30%, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-range { font-size: .8rem; color: var(--text2); margin-top: .3rem; }

/* ── Range bar ────────────────────────────────────────────────────────────── */
.range-bar-wrap { margin: .85rem 0; }
.range-bar-track {
  height: 7px; background: var(--bg3); border-radius: 999px;
  position: relative; overflow: visible;
}
.range-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.range-bar-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  transition: left .5s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.range-labels {
  display: flex; justify-content: space-between;
  font-size: .7rem; color: var(--text3); margin-top: .35rem;
}

/* ── Breakdown ────────────────────────────────────────────────────────────── */
.breakdown-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .45rem 0; border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { color: var(--text2); }
.breakdown-value { font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .7rem 1.4rem; border-radius: var(--radius-sm); border: none;
  font-size: .88rem; font-weight: 600; cursor: pointer; transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 3px 12px rgba(232,93,38,.35);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--bg4); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-full { width: 100%; }
.btn-sm { padding: .38rem .8rem; font-size: .78rem; }

/* ── Portfolio ────────────────────────────────────────────────────────────── */
.portfolio-empty { text-align: center; padding: 3rem 1rem; }
.portfolio-empty .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.portfolio-empty h2 { margin-bottom: .5rem; }

.portfolio-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .7rem;
}
.portfolio-item-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: .7rem;
}
.portfolio-item-name { font-weight: 700; font-size: .95rem; margin-bottom: .15rem; }
.portfolio-item-meta { font-size: .75rem; color: var(--text2); }
.portfolio-item-value {
  font-size: 1.35rem; font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.portfolio-trend {
  display: flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; margin-top: .15rem;
}
.trend-up   { color: var(--green); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--text2); }
.chart-wrap { height: 180px; margin-top: .7rem; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: .65rem 1.1rem;
  font-size: .85rem; font-weight: 500; box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.4,0,.2,1); z-index: 999;
  white-space: nowrap; max-width: calc(100vw - 2rem);
  overflow: hidden; text-overflow: ellipsis;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--green); color: var(--green); }
#toast.error   { border-color: var(--red);   color: var(--red); }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--border2); border-top-color: var(--accent);
  animation: spin .7s linear infinite; margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { text-align: center; padding: 2rem; }
.loading-wrap p { margin-top: .65rem; font-size: .85rem; }

/* ── Back button ──────────────────────────────────────────────────────────── */
.back-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--text2); font-size: .82rem; font-weight: 500;
  background: none; border: none; cursor: pointer; padding: 0;
  margin-bottom: 1.1rem; transition: color var(--transition);
}
.back-btn:hover { color: var(--accent); }

/* ── Semestre selector ────────────────────────────────────────────────────── */
.sem-select {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: .35rem .65rem; font-size: .82rem; outline: none; cursor: pointer;
}

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: .85rem 0; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

/* ── Mobile touch ─────────────────────────────────────────────────────────── */
@media (hover: none) {
  * { -webkit-tap-highlight-color: transparent; }
  .zone-item:hover { background: var(--bg2); border-color: var(--border); }
  .btn-primary:hover { transform: none; }
  .cond-btn { min-height: 34px; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  h1 { font-size: 1.35rem; }
  .result-value { font-size: 2rem; }
  .input-row { grid-template-columns: 1fr; }
  nav { padding: .65rem .9rem; }
  .nav-tab { padding: .32rem .6rem; font-size: .76rem; }
  .hero { padding: 1.25rem 0 1rem; }
  .hero p { font-size: .88rem; margin-bottom: 1.25rem; }
  .condition-item { flex-wrap: wrap; }
  .condition-buttons { width: 100%; justify-content: flex-end; }
  .card { padding: .9rem; }
  #toast { bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
  #modal-overlay { align-items: flex-start; padding-top: 15vh; }
  .input-group input[type="number"] { font-size: 16px; }
}

@supports (padding: max(0px)) {
  nav { padding-top: max(.75rem, env(safe-area-inset-top)); }
  #toast { bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 1rem)); }
  main { padding-bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + 1rem)); }
}

/* ── PWA Banner ───────────────────────────────────────────────────────────── */
#pwa-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom, 0px));
  background: rgba(17,24,39,.97);
  border-top: 1px solid var(--border2);
  backdrop-filter: blur(16px);
  animation: slideUp .35s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pwa-banner-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 680px; margin: 0 auto; gap: .75rem;
}
.pwa-banner-left { display: flex; align-items: center; gap: .75rem; }
.pwa-banner-icon {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.pwa-banner-title { font-weight: 700; font-size: .9rem; }
.pwa-banner-sub   { font-size: .75rem; color: var(--text2); }
.pwa-banner-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ── Home / Landing ───────────────────────────────────────────────────────── */
#view-home { position: relative; overflow: hidden; padding-bottom: 3rem; }

/* Animated background */
.bg-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  overflow: hidden;
}
.bg-orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: .18;
  transition: transform .1s linear;
  will-change: transform;
}
.orb-1 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  top: -100px; left: -100px;
}
.orb-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  bottom: 10%; right: -80px;
}
.orb-3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #22c55e, transparent 70%);
  top: 40%; left: 30%;
}
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
}

/* Hero */
.home-hero {
  position: relative; z-index: 1;
  text-align: center; padding: 3.5rem 1rem 2rem;
}
.home-hero h1 {
  font-size: 2.4rem; font-weight: 900; letter-spacing: -.04em;
  line-height: 1.15; margin: .75rem 0 1rem;
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent2), #f59e0b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.btn-hero {
  padding: .85rem 2rem; font-size: 1rem; border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(232,93,38,.4);
}

/* Stats strip */
.stats-strip {
  position: relative; z-index: 1;
  display: flex; justify-content: center; gap: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 0 0 2rem;
  overflow: hidden;
}
.stat-item {
  flex: 1; text-align: center; padding: 1rem .5rem;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-num { font-size: 1.5rem; font-weight: 900; color: var(--accent2); letter-spacing: -.03em; }
.stat-label { font-size: .72rem; color: var(--text2); margin-top: .15rem; }

/* How it works */
.how-section {
  position: relative; z-index: 1;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.25rem; margin-bottom: 1rem;
}
.how-steps {
  display: flex; align-items: flex-start; gap: .5rem;
  overflow-x: auto; padding-bottom: .25rem;
  scrollbar-width: none;
}
.how-steps::-webkit-scrollbar { display: none; }
.how-step {
  flex: 1; min-width: 120px; text-align: center;
}
.how-step-icon {
  font-size: 1.75rem; margin-bottom: .5rem;
  display: block;
}
.how-step-title { font-size: .82rem; font-weight: 700; margin-bottom: .3rem; color: var(--text); }
.how-step-desc  { font-size: .72rem; color: var(--text2); line-height: 1.5; }
.how-step-arrow {
  color: var(--text3); font-size: 1.1rem; padding-top: 1.5rem;
  flex-shrink: 0; align-self: flex-start;
}

/* Data cards */
.data-section {
  position: relative; z-index: 1; margin-bottom: 1rem;
}
.data-cards { display: flex; flex-direction: column; gap: .75rem; }
.data-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.15rem;
  display: flex; gap: 1rem; align-items: flex-start;
  transition: border-color var(--transition);
}
.data-card:hover { border-color: var(--accent); }
.data-card-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: .1rem; }
.data-card-title { font-size: .9rem; font-weight: 700; margin-bottom: .3rem; color: var(--text); }
.data-card-desc  { font-size: .78rem; color: var(--text2); line-height: 1.55; }

/* CTA bottom */
.home-cta {
  position: relative; z-index: 1;
  text-align: center; padding: 2rem 1rem;
  background: linear-gradient(135deg, rgba(232,93,38,.08), rgba(99,102,241,.06));
  border: 1px solid rgba(232,93,38,.2);
  border-radius: var(--radius);
}
.home-cta h2 { font-size: 1.3rem; margin-bottom: .4rem; }

/* Auth tab */
.auth-tab {
  flex: 1; padding: .45rem; border-radius: var(--radius-xs); border: none;
  background: transparent; color: var(--text2);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: var(--transition);
}
.auth-tab.active { background: var(--accent); color: #fff; }

/* btn-account */
.btn-account {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: .38rem .6rem;
  font-size: 1rem; cursor: pointer; transition: var(--transition);
  color: var(--text2);
}
.btn-account:hover { border-color: var(--accent); color: var(--accent); }

/* zone-name overflow fix */
.zone-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}

/* ── Responsive home ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .home-hero h1 { font-size: 1.7rem; }
  .how-step { min-width: 100px; }
  .how-step-arrow { display: none; }
  .how-steps { gap: .75rem; }
}

/* ── Portfolio photo ──────────────────────────────────────────────────────── */
.portfolio-photo-wrap {
  position: relative; flex-shrink: 0; cursor: pointer;
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  overflow: hidden; display: block;
}
.portfolio-photo {
  width: 52px; height: 52px; object-fit: cover;
  border-radius: var(--radius-sm); display: block;
}
.portfolio-photo-empty {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1.5px dashed var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.portfolio-photo-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; opacity: 0;
  transition: opacity var(--transition);
  border-radius: var(--radius-sm);
}
.portfolio-photo-wrap:hover .portfolio-photo-overlay { opacity: 1; }

/* ── Photo upload in modal ────────────────────────────────────────────────── */
.photo-upload-wrap { margin-bottom: .25rem; }
.photo-upload-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .85rem; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border2); background: var(--bg3);
  color: var(--text2); font-size: .82rem; cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.photo-upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.photo-preview-wrap {
  position: relative; display: flex; align-items: center; gap: .75rem;
}
.photo-preview-wrap img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border2);
}
.photo-remove-btn {
  position: absolute; top: -6px; left: 60px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: .65rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  line-height: 1;
}

/* ── Chart fullscreen modal ───────────────────────────────────────────────── */
.chart-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.25rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chart-modal-hint {
  text-align: center; font-size: .72rem; color: var(--text3);
  padding: .35rem; flex-shrink: 0;
}
.chart-modal-body {
  flex: 1; padding: .75rem 1rem 1rem; min-height: 0;
}
.chart-modal-body canvas { width: 100% !important; height: 100% !important; }

/* ── Chart wrap fullscreen btn ────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 180px; margin-top: .7rem; }
.chart-fullscreen-btn {
  position: absolute; top: .4rem; right: .4rem;
  background: rgba(17,24,39,.8); border: 1px solid var(--border2);
  border-radius: var(--radius-xs); color: var(--text2);
  font-size: .85rem; padding: .2rem .45rem; cursor: pointer;
  opacity: 0; transition: opacity var(--transition);
  backdrop-filter: blur(4px);
}
.chart-wrap:hover .chart-fullscreen-btn { opacity: 1; }

/* ── PWA card (non-invasiva) ──────────────────────────────────────────────── */
.pwa-card {
  display: none; /* mostrata solo da JS quando disponibile */
  align-items: center; justify-content: space-between;
  gap: .75rem; margin-top: 1rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem;
}
.pwa-card-left { display: flex; align-items: center; gap: .75rem; }
.pwa-card-icon {
  font-size: 1.5rem; width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pwa-card-title { font-size: .88rem; font-weight: 700; }
.pwa-card-sub   { font-size: .73rem; color: var(--text2); margin-top: .1rem; }

/* ── Tipo abitazione selector ─────────────────────────────────────────────── */
.tipo-selector {
  display: flex; gap: .5rem; flex-wrap: wrap;
}
.tipo-btn {
  display: flex; align-items: center; gap: .4rem;
  padding: .45rem .85rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border2); background: var(--bg3);
  color: var(--text2); font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.tipo-btn:hover { border-color: var(--accent); color: var(--text); }
.tipo-btn.active {
  border-color: var(--accent); background: rgba(232,93,38,.12);
  color: var(--accent2);
}

/* ── Orb CSS animation (no JS permission needed on mobile) ───────────────── */
.orb-1 { animation: orbFloat1 18s ease-in-out infinite; }
.orb-2 { animation: orbFloat2 22s ease-in-out infinite; }
.orb-3 { animation: orbFloat3 26s ease-in-out infinite; }

@keyframes orbFloat1 {
  0%,100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, 30px) scale(1.05); }
  66%      { transform: translate(-20px, 50px) scale(0.97); }
}
@keyframes orbFloat2 {
  0%,100% { transform: translate(0, 0) scale(1); }
  40%      { transform: translate(-50px, -30px) scale(1.08); }
  70%      { transform: translate(30px, -50px) scale(0.95); }
}
@keyframes orbFloat3 {
  0%,100% { transform: translate(0, 0) scale(1); }
  30%      { transform: translate(30px, -40px) scale(1.04); }
  60%      { transform: translate(-40px, 20px) scale(1.02); }
}
/* Su desktop il JS sovrascrive transform con il mouse, su mobile resta CSS */
@media (hover: none) {
  .bg-orb { animation-play-state: running !important; }
}

/* ── Search address (Nominatim) ───────────────────────────────────────────── */
.search-spinner {
  display: none;
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border2); border-top-color: var(--accent);
  animation: spin .6s linear infinite;
  pointer-events: none;
}
.search-hint {
  font-size: .78rem; color: var(--text3);
  margin-top: .5rem; padding: 0 .25rem;
  min-height: 1.2em;
  transition: color var(--transition);
}
.ac-badge-map {
  background: rgba(99,102,241,.12);
  color: #818cf8;
  font-size: .85rem;
  padding: .2rem .35rem;
}

/* ── Zone suggerite ───────────────────────────────────────────────────────── */
.zone-item-suggested {
  border-color: rgba(232,93,38,.35);
  background: rgba(232,93,38,.04);
}
.zone-item-suggested:hover {
  border-color: var(--accent);
  background: rgba(232,93,38,.08);
}
.zone-match-badge {
  font-size: .68rem; font-weight: 700;
  background: rgba(232,93,38,.15); color: var(--accent2);
  border-radius: 4px; padding: .1rem .4rem;
  white-space: nowrap;
}

/* ── Zona OMI tags ────────────────────────────────────────────────────────── */
.zona-tags {
  display: flex; flex-wrap: wrap; gap: .3rem; align-items: center;
}
.zona-tag {
  display: inline-block;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-xs);
  padding: .18rem .55rem;
  font-size: .78rem; font-weight: 500; color: var(--text);
  white-space: nowrap;
}
.zone-item-suggested .zona-tag {
  background: rgba(232,93,38,.08);
  border-color: rgba(232,93,38,.25);
}

/* ── Mode toggle (vendita/affitto) ────────────────────────────────────────── */
.mode-toggle {
  display: flex; gap: .3rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .25rem;
  margin-bottom: 1rem;
}
.mode-btn {
  flex: 1; padding: .55rem .5rem; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text2);
  font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: var(--transition);
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(232,93,38,.35);
}

/* ── Result tabs (vendita/affitto nel risultato) ──────────────────────────── */
.result-tabs {
  display: flex; gap: .3rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .25rem;
  margin-bottom: .85rem;
}
.result-tab {
  flex: 1; padding: .5rem; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text2);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: var(--transition);
}
.result-tab.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(232,93,38,.3);
}

/* ── Stima rapida note ────────────────────────────────────────────────────── */
.stima-rapida-note {
  margin-top: .6rem; padding: .5rem .75rem;
  background: rgba(234,179,8,.08); border: 1px solid rgba(234,179,8,.25);
  border-radius: var(--radius-xs); color: var(--yellow);
  font-size: .78rem; line-height: 1.4;
}

/* ── Sezione 2 dettaglio (collassabile) ───────────────────────────────────── */
.section2-hint {
  font-size: .78rem; color: var(--text3);
  padding: .4rem .6rem; margin-bottom: .75rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}
.section2-details { margin-bottom: 1.5rem; }
.section2-details .card {
  border-top-left-radius: 0; border-top-right-radius: 0;
  border-top: none; margin-bottom: 0;
}
.section2-summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; cursor: pointer;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); list-style: none;
  font-size: .88rem; font-weight: 600; color: var(--text);
  transition: background var(--transition);
}
.section2-summary::-webkit-details-marker { display: none; }
.section2-summary::after { content: '▼'; font-size: .7rem; color: var(--text3); transition: transform .2s; }
details[open] .section2-summary::after { transform: rotate(180deg); }
details[open] .section2-summary {
  border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.section2-summary:hover { background: var(--bg3); }
.section2-count {
  font-size: .72rem; font-weight: 600; color: var(--accent2);
  background: rgba(232,93,38,.1); border-radius: 999px;
  padding: .1rem .5rem; margin-right: .5rem;
}

/* ── Bussola esposizione ──────────────────────────────────────────────────── */
.exposure-wrap { display: flex; flex-direction: column; align-items: flex-end; }
.compass-grid {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: .25rem;
}
.compass-btn {
  min-width: 36px; padding: .28rem .4rem;
  font-size: .75rem; font-weight: 700;
  text-align: center;
}

/* ── Floor input ──────────────────────────────────────────────────────────── */
.floor-input-wrap { display: flex; flex-direction: column; gap: .4rem; align-items: flex-end; }
.floor-btns { display: flex; gap: .3rem; }
.floor-number-wrap {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end;
}
.floor-top-label {
  display: flex; align-items: center; gap: .3rem; cursor: pointer;
}

/* ── Trends page ──────────────────────────────────────────────────────────── */
.trends-controls {
  display: flex; gap: .65rem; flex-wrap: wrap; margin-bottom: .25rem;
}
.trends-controls .input-group { min-width: 120px; }

/* ── Calc spinner ─────────────────────────────────────────────────────────── */
.calc-spinner-wrap {
  text-align: center; padding: 1.5rem;
  animation: fadeIn .2s ease;
}
.calc-spinner-wrap .spinner { margin: 0 auto .5rem; }
.calc-spinner-wrap p { font-size: .82rem; color: var(--text2); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Tablet (481–768px) ───────────────────────────────────────────────────── */
@media (min-width: 481px) and (max-width: 768px) {
  main { padding: 1.5rem 1.25rem; }
  .input-row { grid-template-columns: 1fr 1fr; }
  .condition-item { flex-wrap: nowrap; }
}

/* ── Desktop (>768px) ─────────────────────────────────────────────────────── */
@media (min-width: 769px) {
  main { max-width: 720px; padding: 1.75rem 1.5rem; }
  .home-hero h1 { font-size: 3rem; }
  .how-steps { gap: 1rem; }
  .how-step-arrow { display: block; }
  .data-cards { flex-direction: row; }
  .data-card { flex: 1; }
}

/* ── Nav compatta con 3 tab ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .nav-tab { padding: .25rem .45rem; font-size: .7rem; }
  .nav-tabs { gap: .1rem; }
}
@media (max-width: 360px) {
  .nav-tab { padding: .22rem .32rem; font-size: .65rem; }
}

/* ── Safe area per notch/home indicator ───────────────────────────────────── */
@supports (padding: max(0px)) {
  nav {
    padding-top: max(.75rem, env(safe-area-inset-top));
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }
  main {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + 1rem));
  }
  #pwa-banner {
    padding-bottom: max(.75rem, calc(env(safe-area-inset-bottom) + .75rem));
  }
}

/* ── Prefers reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .bg-orb { animation: none !important; }
}

/* ── Touch targets minimi 44px ────────────────────────────────────────────── */
@media (hover: none) {
  .btn, .cond-btn, .nav-tab, .zone-item, .tipo-btn, .mode-btn {
    min-height: 44px;
  }
  .cond-btn { min-height: 38px; } /* eccezione per bottoni condizioni */
  .energy-btn, .compass-btn { min-height: 32px; }
}

/* ── Ottimizzazione font rendering ────────────────────────────────────────── */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* ── Portfolio item clickable ─────────────────────────────────────────────── */
.portfolio-item-clickable {
  transition: border-color var(--transition), box-shadow var(--transition);
}
.portfolio-item-clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(232,93,38,.15);
}
.portfolio-item-clickable:active { transform: scale(.99); }

/* ── Portfolio no-account banner ──────────────────────────────────────────── */
.portfolio-no-account-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .85rem 1rem; margin-bottom: 1rem;
  background: rgba(99,102,241,.08); border: 1px solid rgba(99,102,241,.25);
  border-radius: var(--radius); flex-wrap: wrap;
}

/* ── Logo text wrapper ────────────────────────────────────────────────────── */
.logo-text { white-space: nowrap; }

/* ── Logo text — nascosto su mobile stretto per dare spazio ai tab ────────── */
@media (max-width: 480px) {
  .nav-logo .logo-text { display: none; }
  .nav-logo { gap: 0; }
}

/* ══════════════════════════════════════════════════════════════════════════
   WIZARD VALUTAZIONE
   ══════════════════════════════════════════════════════════════════════════ */

/* Progress bar */
.wizard-progress {
  height: 4px; background: var(--bg3); border-radius: 999px;
  margin-bottom: .4rem; overflow: hidden;
}
.wizard-progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px; transition: width .4s cubic-bezier(.4,0,.2,1);
}
.wizard-step-count {
  font-size: .72rem; color: var(--text3); text-align: right;
  margin-bottom: .75rem;
}

/* Zona info compatta */
.wizard-zona-info {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .85rem;
}

/* Card step */
.wizard-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.25rem;
  margin-bottom: 1rem;
}
.wizard-step-header {
  display: flex; align-items: flex-start; gap: .75rem;
  margin-bottom: 1rem;
}
.wizard-step-icon { font-size: 1.75rem; flex-shrink: 0; margin-top: .1rem; }
.wizard-step-title {
  flex: 1; font-size: 1.15rem; font-weight: 700; line-height: 1.3;
}
.wizard-hint-btn {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--border2); background: var(--bg3);
  color: var(--text2); font-size: .8rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.wizard-hint-btn:hover { border-color: var(--accent); color: var(--accent); }
.wizard-hint-box {
  background: rgba(99,102,241,.08); border: 1px solid rgba(99,102,241,.2);
  border-radius: var(--radius-sm); padding: .65rem .85rem;
  font-size: .8rem; color: var(--text2); line-height: 1.55;
  margin-bottom: .85rem;
}

/* Opzioni grandi */
.wizard-big-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .65rem;
}
.wizard-option {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3rem; padding: 1rem .75rem;
  background: var(--bg3); border: 2px solid var(--border2);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  min-height: 80px; text-align: center;
}
.wizard-option:hover { border-color: var(--accent); background: rgba(232,93,38,.06); }
.wizard-option:active { transform: scale(.97); }
.wizard-option.selected {
  border-color: var(--accent); background: rgba(232,93,38,.12);
}
.wizard-option-icon { font-size: 1.5rem; }
.wizard-option-label { font-size: .88rem; font-weight: 600; color: var(--text); }
.wizard-option-desc  { font-size: .72rem; color: var(--text2); }

/* Colori stato */
.wizard-option.energy-good { border-color: rgba(34,197,94,.3); }
.wizard-option.energy-good.selected { border-color: var(--green); background: rgba(34,197,94,.1); }
.wizard-option.energy-mid  { border-color: rgba(234,179,8,.3); }
.wizard-option.energy-mid.selected  { border-color: var(--yellow); background: rgba(234,179,8,.1); }
.wizard-option.energy-bad  { border-color: rgba(239,68,68,.3); }
.wizard-option.energy-bad.selected  { border-color: var(--red); background: rgba(239,68,68,.1); }

/* Classi energetiche — griglia più compatta */
.wizard-energy { grid-template-columns: repeat(5, 1fr); }
.wizard-energy .wizard-option { min-height: 52px; padding: .5rem .3rem; }
.wizard-energy .wizard-option-label { font-size: .82rem; }

/* Bussola esposizione */
.wizard-compass { grid-template-columns: repeat(4, 1fr); }
.wizard-compass .wizard-option { min-height: 60px; }

/* Input wizard */
.wizard-inputs { display: flex; flex-direction: column; gap: .75rem; }
.wizard-input-row { display: flex; flex-direction: column; gap: .3rem; }
.wizard-input-row label { font-size: .82rem; color: var(--text2); font-weight: 500; }
.wizard-input {
  background: var(--bg3); border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: .75rem 1rem; font-size: 1.1rem; outline: none;
  transition: border-color var(--transition); width: 100%;
}
.wizard-input:focus { border-color: var(--accent); }

/* Navigazione wizard */
.wizard-nav {
  display: flex; gap: .75rem; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.wizard-next-btn { flex: 1; }

/* Mobile */
@media (max-width: 480px) {
  .wizard-big-options { grid-template-columns: repeat(2, 1fr); }
  .wizard-energy { grid-template-columns: repeat(5, 1fr); }
  .wizard-compass { grid-template-columns: repeat(4, 1fr); }
  .wizard-step-title { font-size: 1rem; }
  .wizard-card { padding: 1.1rem 1rem; }
}

/* ── Wizard shake validation ──────────────────────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ── Wizard detail choice ─────────────────────────────────────────────────── */
.wizard-detail-choice {
  margin-top: .5rem; margin-bottom: 1rem;
  padding: .85rem 1rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Tasti più responsivi ─────────────────────────────────────────────────── */
.wizard-option {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.wizard-option:active { transform: scale(.95); transition: transform .08s; }
.btn:active { transform: scale(.97); transition: transform .08s; }

/* ── Search clear button ──────────────────────────────────────────────────── */
.search-clear {
  position: absolute; right: 2.5rem; top: 50%; transform: translateY(-50%);
  display: none; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg4); border: none; color: var(--text2);
  font-size: .7rem; cursor: pointer; z-index: 2;
  transition: background var(--transition), color var(--transition);
}
.search-clear:hover { background: var(--red); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   APP MOBILE LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */

/* Home — compatta a schermo */
.app-home {
  display: flex; flex-direction: column; justify-content: center;
  min-height: calc(100dvh - 48px - 56px - 1.5rem);
  position: relative; z-index: 1;
}
.app-home-hero {
  text-align: center; padding: 1rem 0 .75rem;
}
.app-home-hero h1 { font-size: 1.6rem; margin-bottom: .4rem; }
.app-home-hero p { font-size: .85rem; margin-bottom: 0; }
.app-home-chart { margin-top: .75rem; }

/* Search header — compatta */
.app-search-header {
  padding: .75rem 0 .5rem;
}
.app-search-header h2 { font-size: 1.15rem; margin-bottom: .5rem; }

/* Onboarding popup */
#onboarding-popup {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.onboarding-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem 1.5rem;
  max-width: 360px; width: 100%; text-align: center;
  box-shadow: var(--shadow);
}

/* Hide old nav-tabs (replaced by bottom tabs) */
.nav-tabs { display: none !important; }
.nav-tab { display: none !important; }

/* btn-account in topbar */
.topbar .btn-account {
  flex-shrink: 0;
}

/* ── Home data section ────────────────────────────────────────────────────── */
.app-home-data {
  margin-top: .75rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem;
}
.app-data-item {
  display: flex; align-items: flex-start; gap: .5rem;
  font-size: .78rem; color: var(--text2); line-height: 1.5;
  padding: .3rem 0;
}
.app-data-item + .app-data-item { border-top: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════════════════
   SMOOTH ANIMATIONS & TRANSITIONS
   ══════════════════════════════════════════════════════════════════════════ */

/* View transitions — fade in */
.view {
  animation: none;
}
.view.active {
  animation: viewFadeIn .25s ease-out;
}
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Wizard step transition */
.wizard-card {
  animation: wizardSlideIn .3s cubic-bezier(.25,.46,.45,.94);
}
@keyframes wizardSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Result card entrance */
.result-card {
  animation: resultPop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes resultPop {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* Cards — subtle hover lift */
.card {
  transition: transform .15s ease, box-shadow .15s ease;
}

/* Buttons — smooth press */
.btn {
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.96); }
.btn-primary:active { box-shadow: 0 1px 4px rgba(232,93,38,.2); }

/* Wizard options — smooth select */
.wizard-option {
  transition: border-color .15s ease, background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.wizard-option:active { transform: scale(.95); }
.wizard-option.selected {
  box-shadow: 0 2px 12px rgba(232,93,38,.2);
}

/* Bottom tabs — smooth icon bounce */
.btab {
  transition: color .15s ease, transform .1s ease;
}
.btab:active { transform: scale(.88); }
.btab.active .btab-icon {
  animation: tabBounce .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes tabBounce {
  from { transform: scale(.8); }
  to   { transform: scale(1); }
}

/* Search autocomplete items */
.ac-item {
  transition: background .12s ease;
}

/* Zone items */
.zone-item {
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.zone-item:active { transform: scale(.98); }

/* Portfolio items */
.portfolio-item {
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.portfolio-item:active { transform: scale(.99); }

/* Range bar — smooth fill */
.range-bar-fill {
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.range-bar-thumb {
  transition: left .6s cubic-bezier(.4,0,.2,1);
}

/* Progress bar — smooth */
.wizard-progress-bar {
  transition: width .4s cubic-bezier(.4,0,.2,1);
}

/* Toast — smooth slide */
#toast {
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s ease;
}

/* Onboarding popup entrance */
.onboarding-card {
  animation: onboardingIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes onboardingIn {
  from { opacity: 0; transform: scale(.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Smooth scroll for all containers */
main {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Input focus glow */
input:focus, select:focus, .wizard-input:focus {
  transition: border-color .15s ease, box-shadow .15s ease;
  box-shadow: 0 0 0 3px rgba(232,93,38,.12);
}

/* Mode toggle buttons */
.mode-btn {
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

/* Result tabs */
.result-tab {
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

/* Chart wrap — fade in */
.chart-wrap canvas {
  animation: chartFadeIn .5s ease-out;
}
@keyframes chartFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Hint box — smooth open */
.wizard-hint-box {
  animation: hintSlideDown .2s ease-out;
}
@keyframes hintSlideDown {
  from { opacity: 0; transform: translateY(-8px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0); max-height: 200px; }
}

/* Stima rapida note */
.stima-rapida-note {
  animation: noteSlideIn .3s ease-out;
}
@keyframes noteSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Skeleton loading pulse for cards */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
.loading-wrap {
  animation: pulse 1.5s ease-in-out infinite;
}


/* ── Home logo ────────────────────────────────────────────────────────────── */
.home-logo {
  width: 72px; height: 72px; object-fit: contain;
  display: block; margin: 0 auto .5rem;
}
