StrategyForge's picture
Claude Opus 4.6
Design system overhaul: neutral monochrome theme, Geist Variable font, new chart palette
d933a8b
Raw History Blame Contribute Delete
24.4 kB
{% extends "base.html" %}
{% block page_title %}Create Scenario{% endblock %}
{% block content %}
<div class="page-header">
<h2>Create New Scenario</h2>
<p>Build a simulation or optimization across Media, Consumer Promo &amp; Trade buckets</p>
</div>
<!-- ═══════════════════════════════════════════════════════════════
STEP 1: Scenario Configuration
═══════════════════════════════════════════════════════════════ -->
<div class="section-header">
<h3>&#x2699; Step 1: Scenario Configuration</h3>
<span class="section-subtitle">Define scope, type, and objectives</span>
</div>
<div class="screen-filters" style="margin-bottom:6px;">
<div class="filter-group">
<label>Scenario Name</label>
<input type="text" id="scenarioName" placeholder="My Scenario" class="sim-input" style="width:160px;">
</div>
<div class="filter-group">
<label>Type</label>
<select id="scenarioType" onchange="toggleScenarioType()">
<option value="simulation">Simulation</option>
<option value="optimization">Optimization</option>
</select>
</div>
<div class="filter-group">
<label>Retailer</label>
<select id="scopeRetailer">
{% for r in sim_retailers %}
<option value="{{ r.value }}" {{ 'selected' if r.value == 'Shoppers Drug Mart' }}>{{ r.label }}</option>
{% endfor %}
</select>
</div>
<div class="filter-group">
<label>Category</label>
<select id="scopeCategory" onchange="onCategoryChange()">
{% for c in sim_categories %}
<option value="{{ c.value }}" {{ 'selected' if c.value == 'Foods' }}>{{ c.label }}</option>
{% endfor %}
</select>
</div>
<div class="filter-group">
<label>Brand</label>
<select id="scopeBrand" onchange="onBrandChange()">
{% for b in sim_brands %}
<option value="{{ b.value }}" data-cat="{{ b.category }}" {{ 'selected' if b.value == 'Brand 1' }}>{{ b.label }}</option>
{% endfor %}
</select>
</div>
<div class="filter-group">
<label>Start</label>
<input type="date" id="scopeStart" value="2025-01-06" class="sim-input">
</div>
<div class="filter-group">
<label>End</label>
<input type="date" id="scopeEnd" value="2025-06-30" class="sim-input">
</div>
</div>
<!-- Optimization-only fields -->
<div id="optimFields" style="display:none;">
<div class="screen-filters" style="margin-bottom:6px;">
<div class="filter-group">
<label>Objective</label>
<select id="objective">
<option value="maximize_revenue">Maximize Revenue</option>
<option value="maximize_roas">Maximize ROAS</option>
<option value="volume_growth">Volume Growth Target</option>
<option value="profit_max">Profit Maximization</option>
</select>
</div>
<div class="filter-group">
<label>Business KPI</label>
<select id="businessKPI">
{% for k in sim_kpis %}
<option value="{{ k.value }}">{{ k.label }}</option>
{% endfor %}
</select>
</div>
<div class="filter-group">
<label>Growth Target (%)</label>
<input type="number" id="targetGrowth" value="5" min="1" max="50" class="sim-input" style="width:80px;">
</div>
<div class="filter-group">
<label>Total Budget ($)</label>
<input type="number" id="totalBudget" placeholder="Auto" class="sim-input" style="width:130px;">
</div>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════
STEP 2: THREE-BUCKET ALLOCATION
═══════════════════════════════════════════════════════════════ -->
<div class="section-header">
<h3>&#x1F4B0; Step 2: Marketing Mix Allocation</h3>
<span class="section-subtitle">Configure Media, Consumer Promo, and Trade investments</span>
</div>
<!-- Tab Navigation for 3 Buckets -->
<div class="bucket-tabs" style="display:flex;gap:0;margin-bottom:0;border-bottom:2px solid rgba(255,255,255,0.08);">
<button class="bucket-tab active" data-bucket="media" onclick="switchBucket('media')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:16px;height:16px;"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>
Media
</button>
<button class="bucket-tab" data-bucket="promo" onclick="switchBucket('promo')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:16px;height:16px;"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/><line x1="7" y1="7" x2="7.01" y2="7"/></svg>
Consumer Promo
</button>
<button class="bucket-tab" data-bucket="trade" onclick="switchBucket('trade')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:16px;height:16px;"><rect x="1" y="3" width="15" height="13"/><polygon points="16 8 20 8 23 11 23 16 16 16 16 8"/><circle cx="5.5" cy="18.5" r="2.5"/><circle cx="18.5" cy="18.5" r="2.5"/></svg>
Trade Promo
</button>
</div>
<!-- ── Media Bucket ──────────────────────────────────── -->
<div id="bucket-media" class="bucket-panel" style="display:block;">
<div class="table-container" style="margin-bottom:12px;">
<div class="table-header">
<h3>Media Channel Allocation</h3>
<span style="color:#9ca3af;font-size:12px;">Set spend per channel (TV, Digital, etc.)</span>
</div>
<div id="mediaSliders" style="padding:16px;">
{% for ch in media_channels %}
<div class="slider-row" style="display:grid;grid-template-columns:140px 1fr 200px;align-items:center;gap:12px;margin-bottom:10px;">
<label style="font-weight:600;color:#e0e0e0;font-size:13px;">{{ ch }}</label>
<input type="range" class="media-slider" data-channel="{{ ch }}"
min="0" max="{{ (media_spend_data.get(ch, 500000) * 3)|int }}"
step="{{ (media_spend_data.get(ch, 500000) / 100)|int or 1000 }}"
value="{{ media_spend_data.get(ch, 200000)|int }}"
oninput="updateMediaLabel(this)">
<div style="display:flex;align-items:center;gap:8px;justify-content:flex-end;">
<span class="media-val" style="font-weight:600;color:var(--accent-teal);min-width:90px;text-align:right;">${{ '{:,.0f}'.format(media_spend_data.get(ch, 200000)) }}</span>
<input type="number" class="media-input" data-channel="{{ ch }}"
value="{{ media_spend_data.get(ch, 200000)|int }}" min="0"
style="width:100px;" class="sim-input"
onchange="syncMediaSlider(this)">
</div>
</div>
{% endfor %}
{% if not media_channels %}
<div style="color:#6b7280;text-align:center;padding:20px;">No media channels found in data. Using defaults.</div>
{% endif %}
<div style="border-top:1px solid rgba(255,255,255,0.08);margin-top:8px;padding-top:8px;display:flex;justify-content:space-between;align-items:center;">
<strong style="color:#c98500;">Total Media Spend:</strong>
<strong id="totalMediaSpend" style="color:#c98500;font-size:16px;">$0</strong>
</div>
</div>
</div>
</div>
<!-- ── Consumer Promo Bucket ─────────────────────────── -->
<div id="bucket-promo" class="bucket-panel" style="display:none;">
<div class="table-container" style="margin-bottom:12px;">
<div class="table-header">
<h3>Consumer Promo Events</h3>
<button class="btn-apply" onclick="addPromoEvent()" style="font-size:12px;padding:4px 12px;">+ Add Promo Event</button>
</div>
<div class="table-wrapper">
<table class="data-table" id="promoEventsTable">
<thead>
<tr>
<th>PPG</th>
<th>Mechanic</th>
<th>Offer Spec</th>
<th>Feature</th>
<th>Display</th>
<th>Start</th>
<th>End</th>
<th>Action</th>
</tr>
</thead>
<tbody id="promoEventsBody">
<tr id="noPromoRow"><td colspan="8" style="text-align:center;color:#6b7280;padding:14px;">No promo events. Click "+ Add Promo Event" to create events with BOGO, TPR, Multi-Buy, or Dollar Off mechanics.</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- ── Trade Bucket ──────────────────────────────────── -->
<div id="bucket-trade" class="bucket-panel" style="display:none;">
<div class="table-container" style="margin-bottom:12px;">
<div class="table-header">
<h3>Trade Promo Events</h3>
<button class="btn-apply" onclick="addTradeEvent()" style="font-size:12px;padding:4px 12px;">+ Add Trade Event</button>
</div>
<div class="table-wrapper">
<table class="data-table" id="tradeEventsTable">
<thead>
<tr>
<th>Event Name</th>
<th>Trade Mechanic</th>
<th>Retailer</th>
<th>Start</th>
<th>End</th>
<th class="num">Spend ($)</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tradeEventsBody">
<tr id="noTradeRow"><td colspan="7" style="text-align:center;color:#6b7280;padding:14px;">No trade events. Click "+ Add Trade Event" to create Off-invoice, Bill-back, Scan-down, etc.</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- ── Run / Save Buttons ────────────────────────────── -->
<div style="display:flex;gap:12px;margin:16px 0 20px;">
<button class="btn-apply" onclick="runScenario()" style="padding:10px 32px;font-size:14px;">
&#x25B6; Run Scenario
</button>
<button class="btn-apply" id="runOptimBtn" onclick="runOptimization()" style="padding:10px 24px;font-size:14px;display:none;">
&#x1F504; Run Optimization
</button>
<button class="btn-apply" onclick="saveScenario()" id="saveBtn" style="padding:10px 24px;font-size:14px;opacity:0.5;pointer-events:none;">
&#x1F4BE; Save Scenario
</button>
</div>
<!-- ═══════════════════════════════════════════════════════════════
STEP 3: RESULTS
═══════════════════════════════════════════════════════════════ -->
<div id="resultsSection" style="display:none;">
<div class="section-header">
<h3>&#x1F4CA; Step 3: Results</h3>
<span class="section-subtitle">Simulation output across all 3 buckets</span>
</div>
<!-- KPI Cards -->
<div class="kpi-grid" id="createKpiGrid"></div>
<!-- Budget + Waterfall -->
<div class="charts-grid">
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Budget Allocation by Bucket</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_budget')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_budget"></div>
</div>
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Revenue Impact Waterfall</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_waterfall')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_waterfall"></div>
</div>
</div>
<!-- Media Channels + Trade -->
<div class="charts-grid" id="mediaTradeCharts" style="display:none;">
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Media Channel Performance (Spend vs Response)</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_media')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_media"></div>
</div>
<div class="chart-container" id="tradeChartContainer" style="display:none;">
<div class="chart-header">
<span class="chart-title">Trade Events (Spend vs Incremental Revenue)</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_trade')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_trade"></div>
</div>
</div>
<!-- Promo Calendar + PPG Summary -->
<div class="charts-grid" id="promoCharts" style="display:none;">
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Promo &amp; Trade Calendar</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_promo_cal')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_promo_cal"></div>
</div>
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">PPG Performance (iGP &amp; Volume Lift)</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_ppg')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_ppg"></div>
</div>
</div>
<!-- Optimization Charts -->
<div id="optimCharts" style="display:none;">
<div class="section-header">
<h3>&#x1F3AF; Optimization Results</h3>
<span class="section-subtitle">Current vs Optimized allocation across Media &amp; Trade</span>
</div>
<div class="charts-grid">
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Current vs Optimized Allocation</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_optim_donuts')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_optim_donuts"></div>
</div>
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Reallocation Revenue Waterfall</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_reallocation')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_reallocation"></div>
</div>
</div>
<div class="charts-grid">
<div class="chart-container full-width">
<div class="chart-header">
<span class="chart-title">Sensitivity Analysis (Tornado)</span>
<div class="chart-actions"><button class="chart-action-btn" onclick="expandChart('chart_tornado')" title="Fullscreen"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg></button></div>
</div>
<div class="chart-area" id="chart_tornado"></div>
</div>
</div>
<!-- Optimized Promo Calendar -->
<div class="charts-grid" id="optCalendarSection" style="display:none;">
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">&#x2B50; Optimized Promo Calendar</span>
</div>
<div class="chart-area" id="chart_opt_calendar"></div>
</div>
<div class="chart-container">
<div class="chart-header">
<span class="chart-title">Optimized PPG Performance</span>
</div>
<div class="chart-area" id="chart_opt_ppg"></div>
</div>
</div>
<!-- Optimization Detail Table -->
<div class="table-container">
<div class="table-header"><h3>Optimization Detail</h3></div>
<div class="table-wrapper">
<table class="data-table" id="optimTable">
<thead>
<tr>
<th>Bucket</th>
<th>Channel / Mechanic</th>
<th class="num">Current Spend</th>
<th class="num">Optimized Spend</th>
<th class="num">Change</th>
<th class="num">Current Response</th>
<th class="num">Optimized Response</th>
<th class="num">Incremental</th>
<th class="num">Cur. ROAS</th>
<th class="num">Opt. ROAS</th>
</tr>
</thead>
<tbody id="optimBody"></tbody>
</table>
</div>
</div>
</div>
<!-- PPG Summary Table (Simulation) -->
<div id="ppgTableSection" style="display:none;">
<div class="table-container">
<div class="table-header"><h3>PPG Financial Summary</h3></div>
<div class="table-wrapper">
<table class="data-table" id="ppgTable">
<thead>
<tr>
<th>PPG</th>
<th class="num">Baseline Units</th>
<th class="num">Total Units</th>
<th class="num">Incremental</th>
<th class="num">Lift %</th>
<th class="num">iGTS</th>
<th class="num">iNTS</th>
<th class="num">iGP</th>
<th class="num">ROI</th>
</tr>
</thead>
<tbody id="ppgBody"></tbody>
</table>
</div>
</div>
</div>
<!-- Media Summary Table -->
<div id="mediaTableSection" style="display:none;">
<div class="table-container">
<div class="table-header"><h3>Media Channel Detail</h3></div>
<div class="table-wrapper">
<table class="data-table" id="mediaTable">
<thead>
<tr>
<th>Channel</th>
<th class="num">Spend</th>
<th class="num">Response</th>
<th class="num">ROAS</th>
<th class="num">Marginal Return</th>
<th class="num">Saturation %</th>
</tr>
</thead>
<tbody id="mediaBody"></tbody>
</table>
</div>
</div>
</div>
</div>
<style>
.sim-input{padding:6px 10px;border-radius:6px;border:1px solid rgba(255,255,255,0.1);background:var(--bg-primary);color:var(--text-primary);font-size:13px;}
.bucket-tabs{display:flex;gap:0;margin-bottom:0;border-bottom:2px solid rgba(255,255,255,0.08);}
.bucket-tab{padding:10px 20px;background:none;border:none;color:var(--text-muted);font-size:13px;font-weight:600;cursor:pointer;display:flex;align-items:center;gap:6px;border-bottom:2px solid transparent;transition:all 0.2s;}
.bucket-tab:hover{color:var(--text-primary);background:rgba(255,255,255,0.03);}
.bucket-tab.active{color:var(--text-primary);border-bottom-color:var(--text-primary);background:rgba(255,255,255,0.04);}
.slider-row input[type="range"]{-webkit-appearance:none;height:6px;border-radius:3px;background:rgba(255,255,255,0.12);outline:none;}
.slider-row input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;width:18px;height:18px;border-radius:50%;background:var(--accent-gradient);cursor:pointer;border:2px solid var(--bg-primary);}
.slider-row input[type="number"]{padding:4px 8px;border-radius:4px;border:1px solid rgba(255,255,255,0.1);background:var(--bg-primary);color:var(--text-primary);font-size:12px;}
</style>
{% endblock %}
{% block scripts %}
<script>
const SIM_PPGS = {{ sim_ppgs | tojson }};
const SIM_MECHANICS = {{ sim_mechanics | tojson }};
const SIM_OFFER_SPECS = {{ sim_offer_specs | tojson }};
const SIM_FEATURES = {{ sim_features | tojson }};
const SIM_DISPLAYS = {{ sim_displays | tojson }};
const TRADE_MECHANIC_TYPES = {{ trade_mechanic_types | tojson }};
const SIM_RETAILERS = {{ sim_retailers | tojson }};
</script>
<script src="{{ url_for('static', filename='js/strategy_create.js') }}"></script>
{% endblock %}