.map-legend-item { display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.map-legend-pin {
  width: 11px; height: 11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 1.5px solid rgba(255,255,255,0.9); box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.map-legend-pin.blue { background: var(--accent); }
.map-legend-pin.gray { background: #9ca3af; }
.map-legend-pin.hq { background: var(--amber); border-radius: 50%; transform: rotate(0); width: 10px; height: 10px; }
.market-map-body { position: relative; background: #dde3ea; }
#market-map-leaflet { width: 100%; height: 500px; z-index: 1; }
.leaflet-container { font-family: 'Roboto', sans-serif; }
.city-label-marker { background: transparent; border: none; }
.map-attribution {
  position: absolute; bottom: 8px; left: 10px; z-index: 500;
  font-size: 0.68rem; color: var(--muted); background: rgba(255,255,255,0.88);
  padding: 0.2rem 0.45rem; border-radius: 4px; pointer-events: none;
}
.market-map-foot {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem;
  padding: 0.9rem 1.25rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface);
}
.map-stat { text-align: center; }
.map-stat-val { font-size: 1.35rem; font-weight: 500; color: var(--text); line-height: 1.1; }
.map-stat-val.accent { color: var(--accent); }
.map-stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 0.2rem; }

/* TAM · SAM · SOM chart */
.tam-chart {
  display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 2rem;
  align-items: end; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.5rem 1.75rem; margin: 1.25rem 0 2rem;
  box-shadow: 0 4px 18px rgba(26, 29, 38, 0.04);
}
.tam-rings { position: relative; width: 100%; max-width: 320px; margin: 0 auto; aspect-ratio: 1; align-self: end; }
.tam-rings svg { width: 100%; height: 100%; display: block; vertical-align: bottom; }
.tam-details { display: flex; flex-direction: column; gap: 1rem; }
.tam-row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 0.85rem; align-items: center;
  padding: 0.85rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2);
}
.tam-row.som { border-color: var(--accent); background: linear-gradient(180deg, #eef4ff 0%, var(--surface2) 100%); }
.tam-badge {
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  color: #fff; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.tam-badge.tam { background: #94a3b8; }
.tam-badge.sam { background: #64748b; }
.tam-badge.som { background: var(--accent); }
.tam-row-title { font-size: 0.92rem; font-weight: 500; margin-bottom: 0.15rem; }
.tam-row-desc { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.tam-row-pct { text-align: right; font-size: 1.5rem; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.1; }
.tam-row.som .tam-row-pct { color: var(--accent); }
.tam-row-pct small { display: block; font-size: 0.68rem; color: var(--muted); font-weight: 400; margin-top: 0.15rem; }
.tam-summary {
  margin-top: 0.25rem; padding: 0.85rem 1rem; border-radius: 8px; background: #ecfdf5;
  font-size: 0.85rem; color: #065f46; line-height: 1.5;
}

/* View tabs — header + full-body app switch */
.view-tabs {
  display: flex; gap: 0.2rem;
  padding: 0.2rem; background: var(--surface2); border-radius: 10px;
}
.view-tab {
  padding: 0.4rem 1rem; border: none; background: transparent;
  color: var(--muted); font-size: 0.82rem; font-weight: 500; border-radius: 8px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.view-tab:hover { color: var(--text); background: rgba(255,255,255,0.6); }
.view-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(26,29,38,0.08); }

.app-view { display: none; }
.app-view.active { display: block; }

#app-escenario {
  position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  overflow-y: auto; z-index: 90;
  padding: 1.5rem 2rem 3rem; background: var(--bg);
}
#app-escenario .escenario-inner { max-width: none; width: 100%; }
.scenario-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; margin-bottom: 1.25rem;
}
.scenario-kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.85rem 1rem;
}
.scenario-kpi-clickable {
  cursor: pointer; text-align: left; width: 100%;
  font: inherit; color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.scenario-kpi-clickable:hover { border-color: var(--accent-dim); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08); }
.scenario-kpi-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scenario-kpi-hint {
  display: block; margin-top: 0.35rem; font-size: 0.68rem; color: var(--accent); font-weight: 500;
}
.scenario-kpi-label {
  display: flex; align-items: center; gap: 0.25rem;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 0.25rem;
}
.scenario-kpi-val { font-size: 1.25rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.scenario-table-wrap {
  overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  box-shadow: 0 4px 18px rgba(26, 29, 38, 0.04);
  max-height: calc(100vh - var(--topbar-h) - 14rem);
}
.scenario-table-wrap table { margin: 0; font-size: 0.78rem; white-space: nowrap; }
.scenario-table-wrap th { position: sticky; top: 0; z-index: 2; }
.scenario-table-wrap th.sc-col-month,
.scenario-table-wrap td.sc-col-month {
  position: sticky; left: 0; z-index: 1;
  box-shadow: 2px 0 6px rgba(26, 29, 38, 0.07);
}
.scenario-table-wrap thead th.sc-col-month { z-index: 4; background: var(--surface2); }
.scenario-table-wrap tbody td.sc-col-month { background: var(--surface); }
.scenario-table-wrap tbody tr.row-growth td.sc-col-month { background: #f3f7fe; }
.scenario-table-wrap tbody tr.row-be td.sc-col-month { background: #ecfdf5; }

.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: 13px; height: 13px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--muted);
  font-size: 0.58rem; font-weight: 600; line-height: 1;
  cursor: help; position: relative; text-transform: none; letter-spacing: normal;
}
.help-tip:hover, .help-tip:focus-visible {
  color: var(--accent); border-color: var(--accent-dim); outline: none;
}
.help-tip::after,
.has-tip::after {
  content: attr(data-tip); position: absolute; left: 50%;
  transform: translateX(-50%); bottom: calc(100% + 8px);
  width: max-content; max-width: 240px; padding: 0.45rem 0.6rem;
  background: var(--text); color: #fff; font-size: 0.72rem; font-weight: 400;
  line-height: 1.4; white-space: normal; text-align: left;
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0; visibility: hidden; pointer-events: none; z-index: 20;
  transition: opacity 0.12s;
}
.help-tip:hover::after, .help-tip:focus-visible::after,
.has-tip:hover::after {
  opacity: 1; visibility: visible;
}
.help-tip-below::after, .has-tip-below::after { bottom: auto; top: calc(100% + 8px); }
.has-tip { cursor: help; position: relative; }
