hamed-dashboards/dashboards/ecommerce/update_dashboard_with_ecosystem.py

1222 lines
67 KiB
Python
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json, sqlite3, os
DB_PATH = '/workspace/ecommerce_research_sources/ecommerce_brands_research.db'
TIMELINE_DATA_PATH = '/workspace/ecommerce_research_sources/timeline_deep_dataset.json'
MASTER_V2 = '/workspace/ecommerce_research_sources/benchmark_master_v2.json'
OUTPUT_HTML = '/workspace/ecommerce_research_sources/index.html'
with open(TIMELINE_DATA_PATH, 'r', encoding='utf-8') as f:
timeline_data = json.load(f)
with open(MASTER_V2, 'r', encoding='utf-8') as f:
master = json.load(f)
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
c.execute("SELECT COUNT(*) FROM sources")
total_sources = c.fetchone()[0]
c.execute("SELECT COUNT(*) FROM sources WHERE source_type LIKE '%Video%' OR platform LIKE '%Aparat%' OR platform LIKE '%YouTube%'")
total_videos = c.fetchone()[0]
c.execute("SELECT COUNT(*) FROM sources WHERE source_type NOT LIKE '%Video%' AND platform NOT LIKE '%Aparat%' AND platform NOT LIKE '%YouTube%'")
total_reports = c.fetchone()[0]
c.execute("SELECT title, url, platform, publication_year, category, summary FROM sources ORDER BY id DESC LIMIT 1500")
raw_sources = c.fetchall()
conn.close()
sources_data = []
for row in raw_sources:
sources_data.append({
"title": row[0],
"url": row[1],
"platform": row[2],
"year": row[3],
"category": row[4],
"summary": row[5]
})
# Format Master JSON
executives = master.get("executives_directory", [])
playbook = master.get("playbook_dossier", {})
commissions = master.get("commissions_data", [])
growth_levers = master.get("growth_levers", [])
revenue_models = master.get("revenue_models", [])
failures = master.get("failures_and_pivots_dossier", [])
industry_matrix = master.get("industry_categories_matrix", [])
market_channels = master.get("market_channels_breakdown", [])
ecosystem_pillars = master.get("brand_ecosystem_pillars", [])
war_report = master.get("war_report_1404", {})
seller_intel = master.get("seller_intelligence_mordad_1405", {})
consulting_fw = master.get("consulting_framework", {})
html_content = f"""<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>سامانه مرجع و بنچمارک اکوسیستم ایکامرس و برندها | دیجی‌کالا و بازار ایران</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
:root {{
--bg-body: #F8FAFC;
--bg-card: #FFFFFF;
--text-main: #0F172A;
--text-muted: #475569;
--border-color: #E2E8F0;
--primary: #EF4056;
--primary-hover: #D92E44;
--primary-subtle: #FFF1F2;
--blue-accent: #2563EB;
--blue-subtle: #EFF6FF;
--emerald-accent: #059669;
--emerald-subtle: #ECFDF5;
--amber-accent: #D97706;
--amber-subtle: #FFFBEB;
--purple-accent: #7C3AED;
--purple-subtle: #F5F3FF;
}}
* {{ box-sizing: border-box; margin: 0; padding: 0; font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif; }}
html {{ scroll-behavior: smooth; }}
body {{ background: var(--bg-body); color: var(--text-main); font-size: 14px; line-height: 1.7; padding-bottom: 80px; text-align: right; }}
a {{ text-decoration: none; color: inherit; }}
/* Sticky Navigation Header */
.top-navbar {{
position: sticky; top: 0; z-index: 1000;
background: rgba(255, 255, 255, 0.96);
backdrop-filter: blur(10px);
border-bottom: 1px solid var(--border-color);
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}}
.nav-container {{
max-width: 1560px; margin: 0 auto; padding: 0 24px;
display: flex; align-items: center; justify-content: space-between; height: 68px;
}}
.brand-box {{ display: flex; align-items: center; gap: 14px; }}
.brand-logo {{
width: 40px; height: 40px; background: var(--primary); color: white;
border-radius: 10px; display: flex; align-items: center; justify-content: center;
font-weight: 900; font-size: 20px; box-shadow: 0 2px 8px rgba(239, 64, 86, 0.3);
}}
.brand-text h1 {{ font-size: 17px; font-weight: 800; color: var(--text-main); }}
.brand-text p {{ font-size: 11px; color: var(--text-muted); }}
.nav-links {{ display: flex; align-items: center; gap: 6px; overflow-x: auto; padding: 6px 0; }}
.nav-links a {{
padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
color: var(--text-muted); transition: all 0.2s; white-space: nowrap;
}}
.nav-links a:hover {{ background: var(--primary-subtle); color: var(--primary); }}
.nav-btn-download {{
background: var(--primary); color: white !important; padding: 8px 16px !important;
border-radius: 8px; font-weight: 700 !important;
}}
.nav-btn-download:hover {{ background: var(--primary-hover) !important; }}
.main-wrapper {{ max-width: 1560px; margin: 32px auto 0; padding: 0 24px; }}
/* Section styling */
.dashboard-section {{
margin-bottom: 56px; scroll-margin-top: 90px;
}}
.section-header {{
display: flex; align-items: center; justify-content: space-between;
border-bottom: 2px solid var(--border-color); padding-bottom: 14px; margin-bottom: 24px;
}}
.section-title-group {{ display: flex; align-items: center; gap: 12px; }}
.section-tag {{
background: var(--primary); color: white; padding: 4px 10px;
border-radius: 6px; font-size: 11px; font-weight: 700;
}}
.section-title {{ font-size: 20px; font-weight: 800; color: var(--text-main); }}
.section-subtitle {{ font-size: 13px; color: var(--text-muted); margin-top: 4px; }}
/* Cards */
.card {{
background: var(--bg-card); border: 1px solid var(--border-color);
border-radius: 14px; padding: 24px; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
transition: transform 0.2s, box-shadow 0.2s;
}}
.card:hover {{ box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06); }}
/* KPI Grid */
.kpi-grid {{
display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 28px;
}}
.kpi-card {{
background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px;
padding: 20px; position: relative; overflow: hidden;
}}
.kpi-card::before {{
content: ''; position: absolute; top: 0; right: 0; left: 0; height: 4px; background: var(--primary);
}}
.kpi-label {{ font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }}
.kpi-val {{ font-size: 26px; font-weight: 900; color: var(--text-main); }}
.kpi-sub {{ font-size: 11px; color: var(--text-muted); margin-top: 6px; }}
/* Grids */
.grid-2 {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 24px; }}
.grid-3 {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; }}
.grid-4 {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }}
/* Tables */
.data-table-container {{
background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 14px;
overflow-x: auto; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}}
table {{ width: 100%; border-collapse: collapse; text-align: right; }}
th {{
background: #F1F5F9; color: var(--text-main); font-weight: 700;
padding: 14px 18px; font-size: 13px; border-bottom: 2px solid var(--border-color);
}}
td {{
padding: 14px 18px; border-bottom: 1px solid var(--border-color);
font-size: 13px; color: var(--text-main);
}}
tr:last-child td {{ border-bottom: none; }}
tr:hover td {{ background: #F8FAFC; }}
.badge {{
display: inline-block; padding: 3px 8px; border-radius: 6px;
font-size: 11px; font-weight: 700;
}}
.badge-primary {{ background: var(--primary-subtle); color: var(--primary); }}
.badge-blue {{ background: var(--blue-subtle); color: var(--blue-accent); }}
.badge-emerald {{ background: var(--emerald-subtle); color: var(--emerald-accent); }}
.badge-amber {{ background: var(--amber-subtle); color: var(--amber-accent); }}
.badge-purple {{ background: var(--purple-subtle); color: var(--purple-accent); }}
/* Download Box */
.download-grid {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }}
.download-item {{
border: 1px solid var(--border-color); border-radius: 12px; padding: 18px;
display: flex; align-items: center; justify-content: space-between; background: #FFFFFF;
transition: all 0.2s;
}}
.download-item:hover {{ border-color: var(--primary); background: var(--primary-subtle); }}
.download-info h4 {{ font-size: 14px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }}
.download-info p {{ font-size: 11px; color: var(--text-muted); }}
.btn-dl {{
background: var(--text-main); color: white; padding: 8px 14px;
border-radius: 8px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
}}
.btn-dl:hover {{ background: var(--primary); }}
/* Source Vault Search */
.vault-controls {{
display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}}
.vault-search {{
flex: 1; min-width: 260px; padding: 12px 16px; border: 1px solid var(--border-color);
border-radius: 10px; font-size: 13px; outline: none; background: white;
}}
.vault-search:focus {{ border-color: var(--primary); box-shadow: 0 0 0 3px rgba(239, 64, 86, 0.15); }}
/* War Report Highlight Box */
.war-report-box {{
background: linear-gradient(135deg, #FFF1F2 0%, #FFFFFF 100%);
border: 2px solid #FDA4AF;
border-radius: 16px;
padding: 28px;
margin-bottom: 32px;
}}
.war-header {{
display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}}
.war-badge {{
background: #E11D48; color: white; padding: 6px 14px; border-radius: 8px; font-weight: 800; font-size: 12px;
}}
.war-grid {{
display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px;
}}
.war-metric-card {{
background: white; border: 1px solid #FECDD3; border-radius: 12px; padding: 16px;
}}
.war-metric-card h5 {{ font-size: 12px; color: #9F1239; font-weight: 700; margin-bottom: 6px; }}
.war-metric-card .val {{ font-size: 22px; font-weight: 900; color: #E11D48; }}
</style>
</head>
<body>
<!-- Sticky Top Navigation -->
<header class="top-navbar">
<div class="nav-container">
<div class="brand-box">
<div class="brand-logo">D</div>
<div class="brand-text">
<h1>بنچمارک ایکامرس و برندهای ایران</h1>
<p>سامانه جامع داده‌محور و مرجع تحلیلی (۱۳۸۵ - ۱۴۰۵)</p>
</div>
</div>
<nav class="nav-links">
<a href="#sec-overview">نمای کلی</a>
<a href="#sec-war-report" style="color: #E11D48; font-weight: 800;">گزارش جنگی ۱۴۰۴</a>
<a href="#sec-consulting">مشاوره مدیریتی C-Level</a>
<a href="#sec-contracts">قراردادها و کارمزد</a>
<a href="#sec-brand-ecosystem">اکوسیستم برندها</a>
<a href="#sec-levers">اهرم‌های رشد</a>
<a href="#sec-revenue">مدل‌های درآمدی</a>
<a href="#sec-timeline">گاه‌شمار ۲۰ ساله</a>
<a href="#sec-executives">مدیران و گفتگوها</a>
<a href="#sec-playbook">پلی‌بوک استراتژیک</a>
<a href="#sec-postmortems">کالبدشکافی شکست‌ها</a>
<a href="#sec-market">سهم بازار و قاچاق</a>
<a href="#sec-categories">ماتریس صنایع</a>
<a href="#sec-vault">بانک منابع</a>
<a href="#sec-downloads" class="nav-btn-download">دانلود داده‌ها</a>
</nav>
</div>
</header>
<main class="main-wrapper">
<!-- Section 1: Overview & KPIs -->
<section id="sec-overview" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">OVERVIEW</span>
<div>
<h2 class="section-title">شاخص‌های کلیدی و تصویر کلان پلتفرم (۱۴۰۳ - ۱۴۰۵)</h2>
<p class="section-subtitle">داده‌های مستند و اعتبارسنجی‌شده از گزارش‌های شفافیت، شاپرک و رگولاتوری</p>
</div>
</div>
</div>
<div class="kpi-grid">
<div class="kpi-card">
<div class="kpi-label">مجموع منابع فکت‌چک شده</div>
<div class="kpi-val">{total_sources:,}</div>
<div class="kpi-sub">تطابق کامل آدرس با متن صفحه</div>
</div>
<div class="kpi-card">
<div class="kpi-label">ویدیوها، پادکست‌ها و گفتگوها</div>
<div class="kpi-val">{total_videos:,}</div>
<div class="kpi-sub">آپارات، یوتیوب، طبقه ۱۶، کارنکن، پیوست</div>
</div>
<div class="kpi-card">
<div class="kpi-label">اسناد، کتب و گزارش‌های مالی</div>
<div class="kpi-val">{total_reports:,}</div>
<div class="kpi-sub">گزارش‌های سالانه و سامانه تجارت</div>
</div>
<div class="kpi-card">
<div class="kpi-label">تنوع کالایی فعال (SKUs)</div>
<div class="kpi-val">۱۲.۵ میلیون</div>
<div class="kpi-sub">بزرگ‌ترین کاتالوگ آنلاین خاورمیانه</div>
</div>
<div class="kpi-card">
<div class="kpi-label">فروشندگان فعال مارکت‌پلیس</div>
<div class="kpi-val">۳۶۰,۰۰۰+</div>
<div class="kpi-sub">در سراسر ۳۱ استان کشور</div>
</div>
<div class="kpi-card">
<div class="kpi-label">سهم برندهای ایرانی از فروش</div>
<div class="kpi-val">۷۸.۰۰ ٪</div>
<div class="kpi-sub">رشد از ۶۸٪ در سال ۱۳۹۸</div>
</div>
<div class="kpi-card">
<div class="kpi-label">برآورد GMV سالانه</div>
<div class="kpi-val">۹۲ همت</div>
<div class="kpi-sub">بر اساس گزارش ۱۴۰۳</div>
</div>
</div>
<div class="grid-2">
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 16px;">روند تغییر سهم برندهای ایرانی در برابر خارجی (۱۳۹۵ - ۱۴۰۳)</h3>
<div style="height: 280px;"><canvas id="brandsShareChart"></canvas></div>
</div>
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 16px;">رشد نمایی تنوع کالا (SKU) و فروشندگان فعال</h3>
<div style="height: 280px;"><canvas id="skuGrowthChart"></canvas></div>
</div>
</div>
</section>
<!-- NEW Section: War Report 1404 -->
<section id="sec-war-report" class="dashboard-section">
<div class="war-report-box">
<div class="war-header">
<div>
<span class="war-badge">سند تحلیلی ویژه دیجی‌کالا</span>
<h2 style="font-size: 22px; font-weight: 900; color: #9F1239; margin-top: 8px;">{war_report.get('title')}</h2>
<p style="font-size: 13px; color: #881337; margin-top: 4px;">{war_report.get('context')}</p>
</div>
<a href="https://about.digikala.com/reports/" target="_blank" class="badge badge-primary" style="background: #E11D48; color: white; padding: 8px 16px; font-size: 12px;">مشاهده گزارش در اتاق خبر ↗</a>
</div>
<div class="war-grid">
<div class="war-metric-card">
<h5>متوسط بازدید روزانه دوران جنگ</h5>
<div class="val">۳.۴ میلیون</div>
<p style="font-size: 11px; color: #9F1239; margin-top: 4px;">حضور مستمر کاربران در وب‌سایت</p>
</div>
<div class="war-metric-card">
<h5>جست‌وجوی یکتای روزانه</h5>
<div class="val">۲.۵ میلیون</div>
<p style="font-size: 11px; color: #9F1239; margin-top: 4px;">تمرکز بر کالاهای شرایط اضطراری</p>
</div>
<div class="war-metric-card">
<h5>پرسفارش‌ترین روز بحران</h5>
<div class="val">۲ تیر ۱۴۰۴</div>
<p style="font-size: 11px; color: #9F1239; margin-top: 4px;">ثبت اوج تقاضای مایحتاج اساسی</p>
</div>
<div class="war-metric-card">
<h5>میانگین زمان ارسال کالا</h5>
<div class="val">۵ روز</div>
<p style="font-size: 11px; color: #9F1239; margin-top: 4px;">تحت تاثیر ترافیک پدافندی و چک لجستیک</p>
</div>
</div>
<div class="grid-2">
<!-- Emergency Gear Table -->
<div class="card" style="border: 1px solid #FECDD3;">
<h3 style="font-size: 16px; font-weight: 800; color: #9F1239; margin-bottom: 14px;">جهش جست‌وجوی اقلام کوله اضطراری و بقا حین جنگ</h3>
<div style="max-height: 380px; overflow-y: auto;">
<table style="width: 100%;">
<thead>
<tr>
<th>نام کالا</th>
<th>دسته‌بندی</th>
<th>میزان رشد تقاضا</th>
</tr>
</thead>
<tbody>"""
for eg in war_report.get("emergency_goods_surge", []):
html_content += f"""
<tr>
<td><strong>{eg['item']}</strong></td>
<td><span class="badge badge-amber">{eg['category']}</span></td>
<td><strong style="color: #E11D48; font-size: 14px;">{eg['growth']}</strong></td>
</tr>"""
html_content += f"""
</tbody>
</table>
</div>
</div>
<!-- Digital & Post-War Shift -->
<div class="card" style="border: 1px solid #FECDD3;">
<h3 style="font-size: 16px; font-weight: 800; color: #9F1239; margin-bottom: 14px;">تغییرات دیجیتال، پت‌فود و بازگشت تقاضا در پساجنگ</h3>
<div style="display: flex; flex-direction: column; gap: 14px;">
<div style="background: white; border: 1px solid #FDA4AF; border-radius: 10px; padding: 14px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<strong style="color: #9F1239;">کیف پول سخت‌افزاری ارز دیجیتال</strong>
<span class="badge badge-emerald" style="font-size: 13px;">+۲۱۸ ٪ رشد فروش</span>
</div>
<p style="font-size: 12px; color: var(--text-muted);">ترس از هک شدن صرافی‌های ارز دیجیتال و مسدودسازی دارایی‌ها در زمان جنگ باعث خروج دارایی‌ها به لجر و ترزور شد.</p>
</div>
<div style="background: white; border: 1px solid #FDA4AF; border-radius: 10px; padding: 14px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<strong style="color: #9F1239;">مودم و روتر اینترنت ثابت (ADSL)</strong>
<span class="badge badge-emerald" style="font-size: 13px;">+۱۰۱ ٪ رشد بازدید</span>
</div>
<p style="font-size: 12px; color: var(--text-muted);">محدودیت شدید اینترنت همراه، تقاضا را مستقیماً به سمت اتصالات سیمی و ثابت سوق داد.</p>
</div>
<div style="background: white; border: 1px solid #FDA4AF; border-radius: 10px; padding: 14px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<strong style="color: #9F1239;">غذای خشک گربه و سگ (برند مفید)</strong>
<span class="badge badge-emerald" style="font-size: 13px;">+۶۵ ٪ غذای گربه | +۵۲ ٪ سگ</span>
</div>
<p style="font-size: 12px; color: var(--text-muted);">استرس و دل‌نگرانی شدید سرپرستان حیوانات خانگی برای تأمین جیره اضطراری پت‌ها در ایام جنگ.</p>
</div>
<div style="background: #FFF1F2; border: 2px dashed #E11D48; border-radius: 10px; padding: 14px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<strong style="color: #E11D48;">تخلیه هیجان پساجنگ: عروسک لبوبو (Labubu)</strong>
<span class="badge badge-primary" style="font-size: 14px; font-weight: 900;">+۳۲۰۰ ٪ جست‌وجو</span>
</div>
<p style="font-size: 12px; color: #9F1239;">با پایان درگیری‌ها، تقاضای نشاط‌آور و ترند جهانی لبوبو به همراه رشد ۸۵۲٪ کنسول‌های بازی و ۱۰۲٪ دسته بازی رخ داد.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Section: C-Level Consulting Framework -->
<section id="sec-consulting" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag" style="background: #4338CA;">EXECUTIVE ADVISORY</span>
<div>
<h2 class="section-title">چارچوب مشاوره مدیریتی C-Level: مدیریت بحران‌های ژئوپلیتیک و پدافند تجاری</h2>
<p class="section-subtitle">متدولوژی ۴R مکنزی، ماتریس BCG سبد کالایی بحران و نقشه اقدام اجرایی هیئت مدیره</p>
</div>
</div>
</div>
<!-- 4R Framework Grid -->
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 14px; color: var(--text-main);">۱. مدل تاب‌آوری ۴ مرحله‌ای مکنزی (McKinsey 4R Framework)</h3>
<div class="grid-4" style="margin-bottom: 28px;">
<div class="card" style="border-top: 4px solid #EF4444;">
<span class="badge badge-primary" style="margin-bottom: 8px;">مرحله اول</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 6px;">رفع بحران اولیه (Resolve)</h4>
<p style="font-size: 11px; color: #DC2626; font-weight: 700; margin-bottom: 8px;">حفظ پرسنل و مایحتاج پایه</p>
<p style="font-size: 12px; color: var(--text-muted);">ایمنی مراکز توزیع، تضمین جریان تأمین اقلام فسادناپذیر (کنسرو، نان، آب) و سهمیه‌بندی سبد جهت جلوگیری از رفتارهای احتکاری.</p>
</div>
<div class="card" style="border-top: 4px solid #F59E0B;">
<span class="badge badge-amber" style="margin-bottom: 8px;">مرحله دوم</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 6px;">تاب‌آوری عملیاتی (Resilience)</h4>
<p style="font-size: 11px; color: #D97706; font-weight: 700; margin-bottom: 8px;">تمرکززدایی زنجیره تأمین</p>
<p style="font-size: 12px; color: var(--text-muted);">توزیع بار کالا به هاب‌های منطقه‌ای؛ تطبیق SLA ارسال از ۲۴ ساعت به ۵ روز و شیفت پنل فروشندگان به خطوط ADSL ثابت.</p>
</div>
<div class="card" style="border-top: 4px solid #3B82F6;">
<span class="badge badge-blue" style="margin-bottom: 8px;">مرحله سوم</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 6px;">بازگشت به تعادل (Return)</h4>
<p style="font-size: 11px; color: #2563EB; font-weight: 700; margin-bottom: 8px;">تخلیه صف و تسویه سریع</p>
<p style="font-size: 12px; color: var(--text-muted);">تسویه نقدی فوری ۳ تا ۷ روزه با فروشندگان کالاهای ضروری؛ فعال‌سازی شیفت‌های شبانه و اطلاع‌رسانی شفاف بازه‌های ارسال.</p>
</div>
<div class="card" style="border-top: 4px solid #10B981;">
<span class="badge badge-emerald" style="margin-bottom: 8px;">مرحله چهارم</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 6px;">بازآفرینی مدل (Reimagination)</h4>
<p style="font-size: 11px; color: #059669; font-weight: 700; margin-bottom: 8px;">مزیت رقابتی پایدار</p>
<p style="font-size: 12px; color: var(--text-muted);">تثبیت دائم دسته‌بندی کوله اضطراری، قرارداد ذخیره استراتژیک با کارخانجات باتری و کنسرو، و پیاده‌سازی پرداخت آفلاین.</p>
</div>
</div>
<!-- Crisis BCG Matrix -->
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 14px; color: var(--text-main);">۲. ماتریس سبد کالایی در شرایط بحران (Crisis Portfolio Matrix)</h3>
<div class="grid-2" style="margin-bottom: 28px;">
<div class="card" style="background: #FEF2F2; border: 1px solid #FCA5A5;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h4 style="font-size: 16px; font-weight: 800; color: #991B1B;">ستاره‌های بحران (Crisis Stars)</h4>
<span class="badge badge-primary">رشد خیره‌کننده تقاضا</span>
</div>
<p style="font-size: 12px; color: #7F1D1D; margin-bottom: 10px;"><strong>اقلام:</strong> شارژر خورشیدی (+۱۲۴۵٪)، رادیو جیبی (+۶۲۷٪)، کیف پول رمزارز (+۲۱۸٪)</p>
<div style="background: white; padding: 10px; border-radius: 8px; font-size: 12px; color: var(--text-main);">
<strong>دستور استراتژیک:</strong> جذب فوری حداکثر موجودی بازار، مارجین‌گیری بهینه، و قرار دادن این محصولات در ویترین اصلی اپلیکیشن.
</div>
</div>
<div class="card" style="background: #ECFDF5; border: 1px solid #6EE7B7;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h4 style="font-size: 16px; font-weight: 800; color: #065F46;">گاوهای شیرده حیاتی (Life Cash Cows)</h4>
<span class="badge badge-emerald">تیراژ نجومی و حیاتی</span>
</div>
<p style="font-size: 12px; color: #064E3B; margin-bottom: 10px;"><strong>اقلام:</strong> کنسروجات (+۹۶۹٪)، نان خشک (+۸۵۵٪)، برنج و روغن خوراکی (+۴۶۲٪)</p>
<div style="background: white; padding: 10px; border-radius: 8px; font-size: 12px; color: var(--text-main);">
<strong>دستور استراتژیک:</strong> تثبیت سخت‌گیرانه قیمت رسمی (MAP)، حذف کارمزد پلتفرم جهت جذب بار عمده و تأمین پایدار سلامت جامعه.
</div>
</div>
<div class="card" style="background: #F1F5F9; border: 1px solid #CBD5E1;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h4 style="font-size: 16px; font-weight: 800; color: #334155;">کالاهای راکد موقت (Dormant Dogs)</h4>
<span class="badge" style="background: #E2E8F0; color: #475569;">افت تقاضای غیرضروری</span>
</div>
<p style="font-size: 12px; color: #475569; margin-bottom: 10px;"><strong>اقلام:</strong> پوشاک و کفش (۱۱-٪)، لوازم آرایشی (۱۰-٪)، گوشی پرچمدار (۵-٪)</p>
<div style="background: white; padding: 10px; border-radius: 8px; font-size: 12px; color: var(--text-main);">
<strong>دستور استراتژیک:</strong> توقف خریدهای قطعی 1P، آزادسازی فضای انبار مرکزی به نفع مواد غذایی، و توقف هزینه‌کرد تبلیغاتی.
</div>
</div>
<div class="card" style="background: #FAF5FF; border: 1px solid #D8B4FE;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h4 style="font-size: 16px; font-weight: 800; color: #581C87;">موج‌های پساجنگ (Post-War Rebounds)</h4>
<span class="badge badge-purple">تخلیه هیجانات روانی</span>
</div>
<p style="font-size: 12px; color: #6B21A8; margin-bottom: 10px;"><strong>اقلام:</strong> عروسک لبوبو (+۳۲۰۰٪)، کنسول بازی (+۸۵۲٪)، گیم‌پد (+۱۰۲٪)</p>
<div style="background: white; padding: 10px; border-radius: 8px; font-size: 12px; color: var(--text-main);">
<strong>دستور استراتژیک:</strong> سوار شدن بر ترندهای مصرفی بدون رسوب انبار؛ استفاده کامل از ظرفیت ارسال مستقیم فروشندگان (SBS).
</div>
</div>
</div>
<!-- Action Plan by Role -->
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 14px; color: var(--text-main);">۳. بسته اقدام فوری رهبران ارشد اجرایی (C-Suite Action Matrix)</h3>
<div class="grid-4">
<div class="card">
<strong style="color: var(--primary);">مدیرعامل و هیئت مدیره</strong>
<p style="font-size: 12px; color: var(--text-muted); margin-top: 6px;">تعامل در بالاترین سطوح با ستاد بحران، صمت و رگولاتوری برای تضمین مجوز تردد ناوگان دیجی‌اکسپرس و فعالیت خطوط دارورسانی آنلاین.</p>
</div>
<div class="card">
<strong style="color: var(--blue-accent);">معاونت عملیات و زنجیره تأمین</strong>
<p style="font-size: 12px; color: var(--text-muted); margin-top: 6px;">شکستن انحصار انبارش شادآباد و توزیع ظرفیت انبارش در هاب‌های منطقه‌ای مشهد، اصفهان و تبریز جهت ایمن‌سازی چرخه توزیع.</p>
</div>
<div class="card">
<strong style="color: var(--emerald-accent);">مدیر ارشد محصول (CPO)</strong>
<p style="font-size: 12px; color: var(--text-muted); margin-top: 6px;">توسعه حالت وضعیت اضطراری (Emergency Mode UI) در اپلیکیشن: هشدار تحویل ۵ روزه، اولویت‌دهی به موجودی انبارهای محلی و سبد بقا.</p>
</div>
<div class="card">
<strong style="color: var(--amber-accent);">مدیر ارشد مالی (CFO)</strong>
<p style="font-size: 12px; color: var(--text-muted); margin-top: 6px;">تخصیص خط اعتباری نقدی برای پیش‌خرید غلات و تجهیزات بقا، و اعطای وام‌های اعتباری ضروری ۴ ماهه بدون سود از طریق دیجی‌پی.</p>
</div>
</div>
</section>
<!-- Section 2: Contracts, Commissions & SLAs -->
<section id="sec-contracts" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">CONTRACTS & SLAS</span>
<div>
<h2 class="section-title">فیچر لیست پلتفرم، ساختار قراردادها و جدول کمیسیون فروشندگان</h2>
<p class="section-subtitle">شروط حقوقی، مدل‌های تسویه، هزینه پردازش انبار دانش و نرخ مرجوعی کالاها</p>
</div>
</div>
</div>
<div class="grid-4" style="margin-bottom: 24px;">
<div class="card">
<span class="badge badge-primary" style="margin-bottom: 8px;">مدل 1P Wholesale</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 8px;">خرید قطعی سازمانی</h4>
<p style="font-size: 12px; color: var(--text-muted);">خرید عمده با تخفیف ۱۵ تا ۳۵٪ زیر قیمت مصرف‌کننده. ریسک انبارداری و قیمت‌گذاری ۱۰۰٪ با دیجی‌کالا. تسویه ۳۰ تا ۶۰ روزه با کارخانه.</p>
</div>
<div class="card">
<span class="badge badge-blue" style="margin-bottom: 8px;">مدل 3P FBD</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 8px;">امانی در انبار مکانیزه دانش</h4>
<p style="font-size: 12px; color: var(--text-muted);">موجودی متعلق به فروشنده در شادآباد نگهداری می‌شود. هزینه انبارداری بر مترمکعب + هزینه تفکیک و بسته‌بندی + کمیسیون فروش کسر می‌شود.</p>
</div>
<div class="card">
<span class="badge badge-emerald" style="margin-bottom: 8px;">مدل 3P SBS</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 8px;">ارسال مستقیم توسط فروشنده</h4>
<p style="font-size: 12px; color: var(--text-muted);">انبارش نزد فروشنده. تعهد ارسال ۲۴ تا ۴۸ ساعته پس از ثبت سفارش خریدار به نزدیک‌ترین هاب دیجی‌اکسپرس. حذف هزینه نگهداری انبار مرکزی.</p>
</div>
<div class="card">
<span class="badge badge-purple" style="margin-bottom: 8px;">مدل BrandStore Partner</span>
<h4 style="font-size: 15px; font-weight: 800; margin-bottom: 8px;">غرفه رسمی نمایندگی برند</h4>
<p style="font-size: 12px; color: var(--text-muted);">تثبیت ۱۰۰٪ بای‌باکس برای کارخانه تولیدی، لندینگ پیج با استانداردهای سازمانی برند، تسهیلات ریبیت فصلی و کوآپ مارکتینگ ۵۰-۵۰.</p>
</div>
</div>
<div class="data-table-container">
<table>
<thead>
<tr>
<th>دسته‌بندی کالا</th>
<th>بازه کمیسیون</th>
<th>میانگین کارمزد</th>
<th>دوره تسویه مالی</th>
<th>هزینه پردازش FBD</th>
<th>نرخ مرجوعی</th>
<th>شروط خاص قراردادی و لجستیکی</th>
<th>لینک منبع رسمی</th>
</tr>
</thead>
<tbody>"""
for comm in commissions:
html_content += f"""
<tr>
<td><strong>{comm['category_fa']}</strong></td>
<td><span class="badge badge-primary">{comm['commission_range']}</span></td>
<td><strong>{comm['avg_commission']}</strong></td>
<td>{comm['payment_cycle_days']}</td>
<td>{comm['fbd_processing_fee']}</td>
<td><span class="badge badge-amber">{comm['return_rate_est']}</span></td>
<td style="font-size: 12px; color: var(--text-muted); max-width: 320px;">{comm['rules_and_conditions']}</td>
<td><a href="{comm['source_url']}" target="_blank" class="badge badge-blue">سند آکادمی ↗</a></td>
</tr>"""
html_content += f"""
</tbody>
</table>
</div>
</section>
<!-- Section 3: Brand Ecosystem Map -->
<section id="sec-brand-ecosystem" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">BRAND ECOSYSTEM</span>
<div>
<h2 class="section-title">نقشه جامع اکوسیستم خدمات و فیچرهای برندها (The Brand Ecosystem Map)</h2>
<p class="section-subtitle">برندها فقط کالا نمی‌فروشند؛ ارکان ۶ گانه خدمات ساخته‌شده پیرامون برند در طول ۲۰ سال</p>
</div>
</div>
</div>
<div class="grid-3" style="margin-bottom: 28px;">"""
for pillar in ecosystem_pillars:
html_content += f"""
<div class="card" style="border-top: 4px solid var(--primary);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<span class="badge badge-primary">{pillar.get('pillar_id')}</span>
<span class="badge badge-blue">{pillar.get('era_introduced')}</span>
</div>
<h3 style="font-size: 17px; font-weight: 800; margin-bottom: 6px;">{pillar.get('pillar_name')}</h3>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 16px;">{pillar.get('overview')}</p>
<div style="display: flex; flex-direction: column; gap: 12px;">"""
for srv in pillar.get("services", []):
html_content += f"""
<div style="background: #F8FAFC; border: 1px solid var(--border-color); border-radius: 10px; padding: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;">
<h4 style="font-size: 13px; font-weight: 700; color: var(--text-main);">{srv.get('service_name')}</h4>
<a href="{srv.get('verified_source_url')}" target="_blank" style="font-size: 11px; color: var(--primary); font-weight: 600;">منبع ↗</a>
</div>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 6px;">{srv.get('mechanism')}</p>
<div style="font-size: 11px; background: white; padding: 6px; border-radius: 6px; border: 1px dashed var(--border-color);">
<span style="color: var(--primary); font-weight: 700;">ارزش برای برند:</span> {srv.get('value_for_brand')}
</div>
</div>"""
html_content += f"""
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 4: Growth Levers -->
<section id="sec-levers" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">GROWTH LEVERS</span>
<div>
<h2 class="section-title">کالبدشکافی اهرم‌های رشد پلتفرم و تعامل مشترک با برندها</h2>
<p class="section-subtitle">مکانیزم‌های فنی محصولی (PLG)، کمپین‌های مگا، لجستیک و فین‌تک با اثربخشی کمی</p>
</div>
</div>
</div>
<div class="grid-3">"""
for lever in growth_levers:
badge_color = "badge-primary" if "محصولی" in lever['lever_category'] else ("badge-blue" if "لجستیک" in lever['lever_category'] else "badge-emerald")
html_content += f"""
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;">
<span class="badge {badge_color}">{lever['lever_category']}</span>
<a href="{lever['verified_source_url']}" target="_blank" class="badge badge-blue">منبع رسمی ↗</a>
</div>
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 8px;">{lever['name']}</h3>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 12px;">{lever['mechanism']}</p>
<div style="background: #F8FAFC; border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; font-size: 12px;">
<strong style="color: var(--emerald-accent);">اثر کمی و داده‌محور:</strong> {lever['impact_data']}
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 5: Revenue Models Roadmap -->
<section id="sec-revenue" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">REVENUE ROADMAP</span>
<div>
<h2 class="section-title">مدل‌های درآمدی کامل، ردمپ زمانی و تحلیل سه‌وجهی مکانیزم‌ها</h2>
<p class="section-subtitle">تحلیل دقیق اثرات از نگاه: کاربر نهایی، کارخانه/فروشنده و رگولاتور دولتی</p>
</div>
</div>
</div>
<div class="card" style="margin-bottom: 28px;">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 16px;">ترکیب سهم جریان‌های درآمدی دیجی‌کالا در سال ۱۴۰۳</h3>
<div style="height: 280px;"><canvas id="revenueMixChart"></canvas></div>
</div>
<div class="grid-2">"""
for rm in revenue_models:
html_content += f"""
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<span class="badge badge-primary">{rm['era_introduced']}</span>
<span class="badge badge-emerald">سهم ۱۴۰۳: {rm['revenue_share_1403']}</span>
</div>
<h3 style="font-size: 17px; font-weight: 800; margin-bottom: 6px;">{rm['model_name']}</h3>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 14px;">{rm['mechanism']}</p>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; font-size: 11px;">
<div style="background: var(--blue-subtle); border-radius: 8px; padding: 10px;">
<strong style="color: var(--blue-accent);">سمت کاربر:</strong>
<p style="margin-top: 4px; color: var(--text-main);">{rm['user_side']}</p>
</div>
<div style="background: var(--emerald-subtle); border-radius: 8px; padding: 10px;">
<strong style="color: var(--emerald-accent);">سمت برند/فروشنده:</strong>
<p style="margin-top: 4px; color: var(--text-main);">{rm['brand_side']}</p>
</div>
<div style="background: var(--amber-subtle); border-radius: 8px; padding: 10px;">
<strong style="color: var(--amber-accent);">سمت دولت و مالیات:</strong>
<p style="margin-top: 4px; color: var(--text-main);">{rm['gov_tax_side']}</p>
</div>
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 6: 20-Year Timeline -->
<section id="sec-timeline" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">20-YEAR TIMELINE</span>
<div>
<h2 class="section-title">گاه‌شمار تفصیلی و تحلیل ۲۰ ساله تحولات ایکامرس ایران (۱۳۸۵ - ۱۴۰۵)</h2>
<p class="section-subtitle">پرسنل، فروشندگان، رویدادها، تغییرات استراتژیک، شکست‌ها و پرفروش‌ترین برندها</p>
</div>
</div>
</div>
<div style="display: flex; flex-direction: column; gap: 20px;">"""
for yr in timeline_data.get('yearly_metrics', []):
html_content += f"""
<div class="card" style="border-right: 5px solid var(--primary);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px;">
<div style="display: flex; align-items: center; gap: 12px;">
<span style="font-size: 20px; font-weight: 900; color: var(--primary);">{yr.get('year_shamsi')}</span>
<span class="badge badge-blue">میلادی: {yr.get('year_gregorian')}</span>
</div>
<div style="display: flex; gap: 10px; font-size: 12px;">
<span class="badge badge-emerald">پرسنل: {yr.get('employees_count')}</span>
<span class="badge badge-purple">فروشندگان: {yr.get('sellers_count')}</span>
<span class="badge badge-amber">ارزش تخمینی: {yr.get('gmv_estimated')}</span>
</div>
</div>
<div class="grid-2" style="margin-top: 10px;">
<div>
<h5 style="font-size: 13px; font-weight: 700; color: var(--text-main); margin-bottom: 6px;">رویدادها و نقاط عطف پلتفرم:</h5>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 8px;">{yr.get('events_summary')}</p>
<h5 style="font-size: 13px; font-weight: 700; color: var(--text-main); margin-bottom: 6px;">تغییرات زنجیره تأمین و خدمات برندها:</h5>
<p style="font-size: 12px; color: var(--text-muted);">{yr.get('brands_and_supply_chain')}</p>
</div>
<div>
<h5 style="font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 6px;">بحران‌ها، شکست‌ها و موانع رگولاتوری:</h5>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 8px;">{yr.get('regulatory_and_failures')}</p>
<h5 style="font-size: 13px; font-weight: 700; color: var(--blue-accent); margin-bottom: 6px;">تغییرات ساختار مدیریتی:</h5>
<p style="font-size: 12px; color: var(--text-muted);">{yr.get('management_changes')}</p>
</div>
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 7: Executives & Strategic Talks (with verified YouTube & Aparat links) -->
<section id="sec-executives" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">EXECUTIVES & INTERVIEWS</span>
<div>
<h2 class="section-title">راهنمای مدیران ارشد دیجی‌کالا و رهبران برندهای مطرح در طول تاریخ</h2>
<p class="section-subtitle">مواضع مستند پیرامون برندها همراه با لینک‌های مستقیم فکت‌چک شده در آپارات و یوتیوب</p>
</div>
</div>
</div>
<div class="grid-2">"""
for ex in executives:
html_content += f"""
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<span class="badge badge-primary">{ex.get('role_category')}</span>
<span class="badge badge-emerald">{ex.get('tenure')}</span>
</div>
<h3 style="font-size: 18px; font-weight: 800; margin-bottom: 4px;">{ex.get('name')}</h3>
<h4 style="font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px;">{ex.get('title')}</h4>
<div style="background: #F8FAFC; border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; margin-bottom: 14px; font-size: 12px;">
<strong style="color: var(--primary);">موضع و دیدگاه کلیدی پیرامون برندها:</strong>
<p style="margin-top: 4px; color: var(--text-main);">{ex.get('key_stance')}</p>
</div>
<h5 style="font-size: 12px; font-weight: 700; margin-bottom: 8px;">مصاحبه‌ها و گفتگوهای تصویری تاییدشده:</h5>
<div style="display: flex; flex-direction: column; gap: 6px;">"""
for inv in ex.get('key_interviews', []):
is_yt = 'youtube' in inv.get('url', '')
b_class = "badge-primary" if is_yt else "badge-blue"
html_content += f"""
<div style="display: flex; justify-content: space-between; align-items: center; background: white; border: 1px solid var(--border-color); border-radius: 6px; padding: 8px 12px; font-size: 12px;">
<span style="font-weight: 600; color: var(--text-main);">{inv.get('title')}</span>
<a href="{inv.get('url')}" target="_blank" class="badge {b_class}" style="margin-right: 8px; white-space: nowrap;">{inv.get('platform')} ↗</a>
</div>"""
html_content += f"""
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 8: Strategic Playbook -->
<section id="sec-playbook" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">STRATEGIC PLAYBOOK</span>
<div>
<h2 class="section-title">پلی‌بوک استراتژیک دیجی‌کالا: اقناع برندها، اعتماد کاربران و حل تعارضات</h2>
<p class="section-subtitle">راهکارهای شکستن مقاومت بازار سنتی و استراتژی حل تداخل و خودخوری داخلی</p>
</div>
</div>
</div>
<div class="grid-3">
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 14px; color: var(--primary);">۱. چگونه برندهای سنتی راضی شدند؟</h3>
<div style="display: flex; flex-direction: column; gap: 10px; font-size: 12px;">"""
for step in playbook.get("how_brands_were_convinced", []):
html_content += f"""
<div style="background: #F8FAFC; border: 1px solid var(--border-color); border-radius: 8px; padding: 10px;">
<h5 style="font-weight: 700; color: var(--text-main);">{step.get('pillar')}</h5>
<p style="color: var(--text-muted); margin-top: 4px;">{step.get('detail')}</p>
</div>"""
html_content += f"""
</div>
</div>
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 14px; color: var(--blue-accent);">۲. چگونه اعتماد کاربران جلب شد؟</h3>
<div style="display: flex; flex-direction: column; gap: 10px; font-size: 12px;">"""
for step in playbook.get("how_user_trust_was_built", []):
html_content += f"""
<div style="background: #F8FAFC; border: 1px solid var(--border-color); border-radius: 8px; padding: 10px;">
<h5 style="font-weight: 700; color: var(--text-main);">{step.get('pillar')}</h5>
<p style="color: var(--text-muted); margin-top: 4px;">{step.get('detail')}</p>
</div>"""
html_content += f"""
</div>
</div>
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 14px; color: var(--emerald-accent);">۳. حل تداخل و خودخوری داخلی (Cannibalization)</h3>
<div style="display: flex; flex-direction: column; gap: 10px; font-size: 12px;">"""
for step in playbook.get("cannibalization_solutions", []):
html_content += f"""
<div style="background: #F8FAFC; border: 1px solid var(--border-color); border-radius: 8px; padding: 10px;">
<h5 style="font-weight: 700; color: var(--text-main);">{step.get('conflict')}</h5>
<p style="color: var(--text-muted); margin-top: 4px;">{step.get('solution')}</p>
</div>"""
html_content += f"""
</div>
</div>
</div>
</section>
<!-- Section 9: Post-Mortems & Failures -->
<section id="sec-postmortems" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">POST-MORTEMS</span>
<div>
<h2 class="section-title">کالبدشکافی عمیق شکست‌ها، پیوت‌های اجباری و شوک‌های رگولاتوری</h2>
<p class="section-subtitle">درس‌آموخته‌های بحران‌های بزرگ اکوسیستم با ارجاع به اسناد و مصاحبه‌ها</p>
</div>
</div>
</div>
<div class="grid-3">"""
for fail in failures:
html_content += f"""
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<span class="badge badge-primary">{fail.get('topic')}</span>
<span class="badge badge-amber">{fail.get('timeline')}</span>
</div>
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 8px;">{fail.get('title')}</h3>
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 12px;">{fail.get('failure_analysis')}</p>
<div style="background: var(--primary-subtle); border-radius: 8px; padding: 10px; font-size: 12px; margin-bottom: 12px;">
<strong style="color: var(--primary);">پیوت و راهکار نهایی:</strong>
<p style="margin-top: 4px; color: var(--text-main);">{fail.get('pivot_action')}</p>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 11px;">
<span style="color: var(--text-muted);">{fail.get('verified_source_title', 'منبع مستند')}</span>
<a href="{fail.get('verified_source_url')}" target="_blank" class="badge badge-blue">مشاهده سند ↗</a>
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 10: Market Channels & Smuggling -->
<section id="sec-market" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">MARKET & CHANNELS</span>
<div>
<h2 class="section-title">ماتریس سهم بازار، قاچاق و کانال‌های فروش برندها (۱۴۰۳)</h2>
<p class="section-subtitle">توزیع سهم فروش میان ایکامرس رسمی، اینستاگرام، بازار سنتی و برآورد قاچاق</p>
</div>
</div>
</div>
<div class="grid-2" style="margin-bottom: 24px;">
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 16px;">مقایسه سهم کانال‌های رسمی در برابر خاکستری و سنتی</h3>
<div style="height: 280px;"><canvas id="channelsChart"></canvas></div>
</div>
<div class="card">
<h3 style="font-size: 16px; font-weight: 800; margin-bottom: 16px;">نرخ تخمینی قاچاق و کالای خاکستری در دسته‌بندی‌ها</h3>
<div style="height: 280px;"><canvas id="smugglingChart"></canvas></div>
</div>
</div>
<div class="data-table-container">
<table>
<thead>
<tr>
<th>صنعت / رده کالایی</th>
<th>ارزش کل بازار (همت)</th>
<th>سهم ایکامرس رسمی</th>
<th>سهم اینستاگرام / سوشال</th>
<th>سهم بازار سنتی و فیزیکی</th>
<th>نرخ تخمینی قاچاق</th>
</tr>
</thead>
<tbody>"""
for mc in market_channels:
html_content += f"""
<tr>
<td><strong>{mc.get('industry')}</strong></td>
<td><strong>{mc.get('market_size_hmt')}</strong></td>
<td><span class="badge badge-emerald">{mc.get('official_ecommerce_share')}</span></td>
<td><span class="badge badge-purple">{mc.get('instagram_social_share')}</span></td>
<td>{mc.get('traditional_retail_share')}</td>
<td><span class="badge badge-primary">{mc.get('smuggling_rate')}</span></td>
</tr>"""
html_content += f"""
</tbody>
</table>
</div>
</section>
<!-- Section 11: Industry Categories Matrix -->
<section id="sec-categories" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">INDUSTRY MATRIX</span>
<div>
<h2 class="section-title">ماتریس تفصیلی صنایع و تعامل برندها با پلتفرم</h2>
<p class="section-subtitle">لیدرهای داخلی، خارجی، موانع گمرکی و رفتار مصرف‌کننده در ۶ صنعت محوری</p>
</div>
</div>
</div>
<div class="grid-3">"""
for ind in industry_matrix:
html_content += f"""
<div class="card">
<h3 style="font-size: 17px; font-weight: 800; margin-bottom: 10px; color: var(--primary);">{ind.get('category')}</h3>
<div style="display: flex; flex-direction: column; gap: 8px; font-size: 12px;">
<div><strong>برندهای لیدر داخلی:</strong> <span style="color: var(--text-muted);">{ind.get('leading_domestic_brands')}</span></div>
<div><strong>برندهای خارجی / قاچاق:</strong> <span style="color: var(--text-muted);">{ind.get('leading_foreign_brands')}</span></div>
<div><strong>مدل همکاری و لجستیک:</strong> <span class="badge badge-blue">{ind.get('platform_model')}</span></div>
<div><strong>موانع رگولاتوری:</strong> <p style="color: var(--text-muted); margin-top: 2px;">{ind.get('regulatory_hurdles')}</p></div>
<div><strong>رفتار خریدار:</strong> <p style="color: var(--text-muted); margin-top: 2px;">{ind.get('consumer_behavior')}</p></div>
</div>
</div>"""
html_content += f"""
</div>
</section>
<!-- Section 12: Source Vault -->
<section id="sec-vault" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">SOURCE VAULT</span>
<div>
<h2 class="section-title">بانک داده جامع منابع پژوهش ({total_sources:,} رکورد فکت‌چک شده)</h2>
<p class="section-subtitle">جست‌وجوی زنده در ویدیوها، پادکست‌ها، اسناد و گزارش‌های تحلیلی</p>
</div>
</div>
</div>
<div class="vault-controls">
<input type="text" id="vaultSearchInput" class="vault-search" placeholder="جستجو در میان عنوان، پلتفرم یا موضوع...">
</div>
<div class="data-table-container">
<table id="vaultTable">
<thead>
<tr>
<th>عنوان منبع</th>
<th>پلتفرم / رسانه</th>
<th>سال</th>
<th>دسته‌بندی</th>
<th>خلاصه و محتوای تاییدشده</th>
<th>لینک مستقیم</th>
</tr>
</thead>
<tbody>"""
for s in sources_data[:120]:
is_yt = 'youtube' in s['url']
b_class = "badge-primary" if is_yt else ("badge-blue" if 'aparat' in s['url'] else "badge-emerald")
html_content += f"""
<tr>
<td><strong>{s['title']}</strong></td>
<td><span class="badge {b_class}">{s['platform']}</span></td>
<td>{s['year']}</td>
<td><span class="badge badge-amber">{s['category']}</span></td>
<td style="font-size: 12px; color: var(--text-muted); max-width: 380px;">{s['summary'][:160]}...</td>
<td><a href="{s['url']}" target="_blank" class="badge badge-primary">باز کردن ↗</a></td>
</tr>"""
html_content += f"""
</tbody>
</table>
</div>
</section>
<!-- Section 13: Download Center -->
<section id="sec-downloads" class="dashboard-section">
<div class="section-header">
<div class="section-title-group">
<span class="section-tag">DOWNLOAD CENTER</span>
<div>
<h2 class="section-title">مرکز دانلود جامع داده‌ها، فایل‌های CSV، JSON و پایگاه داده</h2>
<p class="section-subtitle">دسترسی مستقیم و بدون محدودیت به کل بسته‌های خام و تحلیل‌های پردازش‌شده</p>
</div>
</div>
</div>
<div class="download-grid">
<div class="download-item">
<div class="download-info">
<h4>دیتاست مستر نسخه ۲ (JSON)</h4>
<p>شامل کل پروفایل‌ها، پلیرها، ماتریس و شاخص‌ها</p>
</div>
<a href="/benchmark_master_v2.json" download class="btn-dl">دانلود JSON</a>
</div>
<div class="download-item">
<div class="download-info">
<h4>نقشه اکوسیستم خدمات برندها (CSV)</h4>
<p>جدول خدمات، فین‌تک، لجستیک و گارانتی</p>
</div>
<a href="/brand_ecosystem_services.csv" download class="btn-dl">دانلود CSV</a>
</div>
<div class="download-item">
<div class="download-info">
<h4>جدول کمیسیون‌ها و قراردادها (CSV)</h4>
<p>نرخ کارمزد ۸ صنف، دوره‌های تسویه و جرایم</p>
</div>
<a href="/commissions_and_contracts.csv" download class="btn-dl">دانلود CSV</a>
</div>
<div class="download-item">
<div class="download-info">
<h4>تحلیل اهرم‌های رشد (CSV)</h4>
<p>اهرم‌های محصولی، مارکتینگ و فین‌تک</p>
</div>
<a href="/growth_levers_analysis.csv" download class="btn-dl">دانلود CSV</a>
</div>
<div class="download-item">
<div class="download-info">
<h4>ردمپ مدل‌های درآمدی (CSV)</h4>
<p>سیر تکامل و اثرات سه‌وجهی ۱۳۸۵ تا ۱۴۰۳</p>
</div>
<a href="/revenue_models_roadmap.csv" download class="btn-dl">دانلود CSV</a>
</div>
<div class="download-item">
<div class="download-info">
<h4>پایگاه داده کامل SQLite</h4>
<p>{total_sources:,} رکورد منابع فکت‌چک شده</p>
</div>
<a href="/ecommerce_brands_research.db" download class="btn-dl">دانلود DB</a>
</div>
</div>
</section>
</main>
<script>
// Live Search in Vault
document.getElementById('vaultSearchInput').addEventListener('keyup', function() {{
let val = this.value.toLowerCase();
let rows = document.querySelectorAll('#vaultTable tbody tr');
rows.forEach(r => {{
let text = r.innerText.toLowerCase();
r.style.display = text.includes(val) ? '' : 'none';
}});
}});
// Chart 1: Brands Share
new Chart(document.getElementById('brandsShareChart'), {{
type: 'line',
data: {{
labels: ['۱۳۹۵', '۱۳۹۶', '۱۳۹۷', '۱۳۹۸', '۱۳۹۹', '۱۴۰۰', '۱۴۰۱', '۱۴۰۲', '۱۴۰۳'],
datasets: [
{{ label: 'سهم برندهای ایرانی (٪)', data: [42, 48, 58, 69, 73, 75, 77, 78, 78], borderColor: '#059669', backgroundColor: 'rgba(5, 150, 105, 0.1)', fill: true, tension: 0.3 }},
{{ label: 'سهم برندهای خارجی (٪)', data: [58, 52, 42, 31, 27, 25, 23, 22, 22], borderColor: '#EF4056', backgroundColor: 'rgba(239, 64, 86, 0.1)', fill: true, tension: 0.3 }}
]
}},
options: {{ responsive: true, maintainAspectRatio: false, plugins: {{ legend: {{ position: 'bottom' }} }} }}
}});
// Chart 2: SKU Growth
new Chart(document.getElementById('skuGrowthChart'), {{
type: 'bar',
data: {{
labels: ['۱۳۹۵', '۱۳۹۶', '۱۳۹۷', '۱۳۹۸', '۱۳۹۹', '۱۴۰۰', '۱۴۰۱', '۱۴۰۲', '۱۴۰۳'],
datasets: [
{{ label: 'تنوع کالا - میلیون SKU', data: [0.2, 0.5, 1.2, 2.5, 4.5, 6.8, 8.5, 10.2, 12.5], backgroundColor: '#2563EB' }}
]
}},
options: {{ responsive: true, maintainAspectRatio: false, plugins: {{ legend: {{ position: 'bottom' }} }} }}
}});
// Chart 3: Revenue Mix 1403
new Chart(document.getElementById('revenueMixChart'), {{
type: 'doughnut',
data: {{
labels: ['کارمزد مارکت‌پلیس ۳P', 'خرده‌فروشی ۱P', 'انبارداری و لجستیک FBD', 'ریتل مدیا و ادز', 'فین‌تک دیجی‌پی', 'اشتراک دیجی‌پلاس', 'فروش سازمانی'],
datasets: [{{
data: [52.0, 14.5, 11.2, 8.8, 5.1, 4.2, 4.2],
backgroundColor: ['#EF4056', '#2563EB', '#059669', '#D97706', '#7C3AED', '#EC4899', '#64748B']
}}]
}},
options: {{ responsive: true, maintainAspectRatio: false, plugins: {{ legend: {{ position: 'right' }} }} }}
}});
// Chart 4: Channels Breakdown
new Chart(document.getElementById('channelsChart'), {{
type: 'bar',
data: {{
labels: ['کالای دیجیتال', 'لوازم خانگی بزرگ', 'FMCG سوپرمارکت', 'زیبایی و سلامت', 'پوشاک و مد', 'لوازم کوچک برقی'],
datasets: [
{{ label: 'ایکامرس رسمی', data: [18.2, 6.8, 3.2, 11.4, 5.1, 14.5], backgroundColor: '#059669' }},
{{ label: 'اینستاگرام / سوشال', data: [6.5, 4.2, 1.1, 24.5, 32.0, 8.0], backgroundColor: '#7C3AED' }},
{{ label: 'بازار سنتی حضوری', data: [75.3, 89.0, 95.7, 64.1, 62.9, 77.5], backgroundColor: '#64748B' }}
]
}},
options: {{ responsive: true, maintainAspectRatio: false, plugins: {{ legend: {{ position: 'bottom' }} }} }}
}});
// Chart 5: Smuggling
new Chart(document.getElementById('smugglingChart'), {{
type: 'bar',
data: {{
labels: ['کالای دیجیتال', 'لوازم خانگی بزرگ', 'FMCG سوپرمارکت', 'زیبایی و سلامت', 'پوشاک و مد', 'لوازم کوچک برقی'],
datasets: [
{{ label: 'نرخ تخمینی قاچاق (٪)', data: [18.0, 34.0, 4.0, 46.0, 42.0, 22.0], backgroundColor: '#EF4056' }}
]
}},
options: {{ responsive: true, maintainAspectRatio: false, plugins: {{ legend: {{ position: 'bottom' }} }} }}
}});
</script>
</body>
</html>
"""
with open(OUTPUT_HTML, 'w', encoding='utf-8') as f:
f.write(html_content)
print("Comprehensive single-page dashboard with War Report and YouTube links successfully compiled.")