{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1a76b7ed",
   "metadata": {},
   "source": [
    "# 02 — Costs Analysis\n",
    "\n",
    "**Study:** Forrester TEI™ Of Amazon Connect (Feb 2026)\n",
    "\n",
    "Three cost categories, three-year horizon, 10% discount rate.\n",
    "Target risk-adjusted PV = **$22,983,076**."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "46446223",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "from pathlib import Path\n",
    "\n",
    "ROOT = Path.cwd().resolve()\n",
    "while ROOT != ROOT.parent and not (ROOT / 'core').is_dir():\n",
    "    ROOT = ROOT.parent\n",
    "if str(ROOT) not in sys.path:\n",
    "    sys.path.insert(0, str(ROOT))\n",
    "STUDY = ROOT / 'studies' / '202602_AmazonConnect'\n",
    "if str(STUDY) not in sys.path:\n",
    "    sys.path.insert(0, str(STUDY))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4ec64198",
   "metadata": {},
   "outputs": [],
   "source": [
    "import config\n",
    "import seed_data\n",
    "from core.calculations import npv, risk_adjust_cost\n",
    "from core.notebook_helpers import charts, display, tables"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26f1d385",
   "metadata": {},
   "source": [
    "## Costs — nominal & risk-adjusted\n",
    "\n",
    "| Ref | Cost | Initial | Y1 | Y2 | Y3 | Risk Adj |\n",
    "|---|---|---|---|---|---|---|\n",
    "| Ft | Amazon Connect usage | — | $6.5M | $8.0M | $9.8M | ↑5% |\n",
    "| Gt | Implementation & migration | $1.09M | $188K | $188K | — | ↑10% |\n",
    "| Ht | Ongoing management | — | $256K | $187K | $187K | ↑15% |\n",
    "\n",
    "Note **costs are risk-adjusted *upward*** (higher risk → higher modelled cost)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9635f334",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "</style>\n",
       "<table id=\"T_032a1\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th id=\"T_032a1_level0_col0\" class=\"col_heading level0 col0\" >field_key</th>\n",
       "      <th id=\"T_032a1_level0_col1\" class=\"col_heading level0 col1\" >label</th>\n",
       "      <th id=\"T_032a1_level0_col2\" class=\"col_heading level0 col2\" >category</th>\n",
       "      <th id=\"T_032a1_level0_col3\" class=\"col_heading level0 col3\" >risk_adjustment</th>\n",
       "      <th id=\"T_032a1_level0_col4\" class=\"col_heading level0 col4\" >Initial</th>\n",
       "      <th id=\"T_032a1_level0_col5\" class=\"col_heading level0 col5\" >Initial (RA)</th>\n",
       "      <th id=\"T_032a1_level0_col6\" class=\"col_heading level0 col6\" >Year 1</th>\n",
       "      <th id=\"T_032a1_level0_col7\" class=\"col_heading level0 col7\" >Year 1 (RA)</th>\n",
       "      <th id=\"T_032a1_level0_col8\" class=\"col_heading level0 col8\" >Year 2</th>\n",
       "      <th id=\"T_032a1_level0_col9\" class=\"col_heading level0 col9\" >Year 2 (RA)</th>\n",
       "      <th id=\"T_032a1_level0_col10\" class=\"col_heading level0 col10\" >Year 3</th>\n",
       "      <th id=\"T_032a1_level0_col11\" class=\"col_heading level0 col11\" >Year 3 (RA)</th>\n",
       "      <th id=\"T_032a1_level0_col12\" class=\"col_heading level0 col12\" >Total</th>\n",
       "      <th id=\"T_032a1_level0_col13\" class=\"col_heading level0 col13\" >Total (RA)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_032a1_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_032a1_row0_col0\" class=\"data row0 col0\" >amazon_connect_usage</td>\n",
       "      <td id=\"T_032a1_row0_col1\" class=\"data row0 col1\" >Amazon Connect usage cost</td>\n",
       "      <td id=\"T_032a1_row0_col2\" class=\"data row0 col2\" >Subscription</td>\n",
       "      <td id=\"T_032a1_row0_col3\" class=\"data row0 col3\" >0.050000</td>\n",
       "      <td id=\"T_032a1_row0_col4\" class=\"data row0 col4\" >$0</td>\n",
       "      <td id=\"T_032a1_row0_col5\" class=\"data row0 col5\" >$0</td>\n",
       "      <td id=\"T_032a1_row0_col6\" class=\"data row0 col6\" >$6,456,448</td>\n",
       "      <td id=\"T_032a1_row0_col7\" class=\"data row0 col7\" >$6,779,270</td>\n",
       "      <td id=\"T_032a1_row0_col8\" class=\"data row0 col8\" >$7,951,164</td>\n",
       "      <td id=\"T_032a1_row0_col9\" class=\"data row0 col9\" >$8,348,722</td>\n",
       "      <td id=\"T_032a1_row0_col10\" class=\"data row0 col10\" >$9,832,961</td>\n",
       "      <td id=\"T_032a1_row0_col11\" class=\"data row0 col11\" >$10,324,609</td>\n",
       "      <td id=\"T_032a1_row0_col12\" class=\"data row0 col12\" >$24,240,573</td>\n",
       "      <td id=\"T_032a1_row0_col13\" class=\"data row0 col13\" >$25,452,602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_032a1_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_032a1_row1_col0\" class=\"data row1 col0\" >implementation_migration</td>\n",
       "      <td id=\"T_032a1_row1_col1\" class=\"data row1 col1\" >Implementation and migration cost</td>\n",
       "      <td id=\"T_032a1_row1_col2\" class=\"data row1 col2\" >Implementation</td>\n",
       "      <td id=\"T_032a1_row1_col3\" class=\"data row1 col3\" >0.100000</td>\n",
       "      <td id=\"T_032a1_row1_col4\" class=\"data row1 col4\" >$1,087,500</td>\n",
       "      <td id=\"T_032a1_row1_col5\" class=\"data row1 col5\" >$1,196,250</td>\n",
       "      <td id=\"T_032a1_row1_col6\" class=\"data row1 col6\" >$188,333</td>\n",
       "      <td id=\"T_032a1_row1_col7\" class=\"data row1 col7\" >$207,166</td>\n",
       "      <td id=\"T_032a1_row1_col8\" class=\"data row1 col8\" >$188,333</td>\n",
       "      <td id=\"T_032a1_row1_col9\" class=\"data row1 col9\" >$207,166</td>\n",
       "      <td id=\"T_032a1_row1_col10\" class=\"data row1 col10\" >$0</td>\n",
       "      <td id=\"T_032a1_row1_col11\" class=\"data row1 col11\" >$0</td>\n",
       "      <td id=\"T_032a1_row1_col12\" class=\"data row1 col12\" >$1,464,166</td>\n",
       "      <td id=\"T_032a1_row1_col13\" class=\"data row1 col13\" >$1,610,583</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_032a1_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_032a1_row2_col0\" class=\"data row2 col0\" >ongoing_management</td>\n",
       "      <td id=\"T_032a1_row2_col1\" class=\"data row2 col1\" >Ongoing management</td>\n",
       "      <td id=\"T_032a1_row2_col2\" class=\"data row2 col2\" >Operations</td>\n",
       "      <td id=\"T_032a1_row2_col3\" class=\"data row2 col3\" >0.150000</td>\n",
       "      <td id=\"T_032a1_row2_col4\" class=\"data row2 col4\" >$0</td>\n",
       "      <td id=\"T_032a1_row2_col5\" class=\"data row2 col5\" >$0</td>\n",
       "      <td id=\"T_032a1_row2_col6\" class=\"data row2 col6\" >$256,200</td>\n",
       "      <td id=\"T_032a1_row2_col7\" class=\"data row2 col7\" >$294,630</td>\n",
       "      <td id=\"T_032a1_row2_col8\" class=\"data row2 col8\" >$187,200</td>\n",
       "      <td id=\"T_032a1_row2_col9\" class=\"data row2 col9\" >$215,280</td>\n",
       "      <td id=\"T_032a1_row2_col10\" class=\"data row2 col10\" >$187,200</td>\n",
       "      <td id=\"T_032a1_row2_col11\" class=\"data row2 col11\" >$215,280</td>\n",
       "      <td id=\"T_032a1_row2_col12\" class=\"data row2 col12\" >$630,600</td>\n",
       "      <td id=\"T_032a1_row2_col13\" class=\"data row2 col13\" >$725,190</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x10a22eab0>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = tables.costs_table(seed_data.COSTS)\n",
    "df.style.format({c: '${:,.0f}' for c in df.columns if c not in ('field_key','label','category','risk_adjustment')})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0667d1da",
   "metadata": {},
   "source": [
    "## Local validation\n",
    "\n",
    "Reproduce the **$22,983,076** Costs PV from the PDF Cash Flow Analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3e35a794",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "</style>\n",
       "<table id=\"T_dc982\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th id=\"T_dc982_level0_col0\" class=\"col_heading level0 col0\" >Cost</th>\n",
       "      <th id=\"T_dc982_level0_col1\" class=\"col_heading level0 col1\" >Initial (RA)</th>\n",
       "      <th id=\"T_dc982_level0_col2\" class=\"col_heading level0 col2\" >Y1 (RA)</th>\n",
       "      <th id=\"T_dc982_level0_col3\" class=\"col_heading level0 col3\" >Y2 (RA)</th>\n",
       "      <th id=\"T_dc982_level0_col4\" class=\"col_heading level0 col4\" >Y3 (RA)</th>\n",
       "      <th id=\"T_dc982_level0_col5\" class=\"col_heading level0 col5\" >PV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_dc982_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_dc982_row0_col0\" class=\"data row0 col0\" >Amazon Connect usage cost</td>\n",
       "      <td id=\"T_dc982_row0_col1\" class=\"data row0 col1\" >$0</td>\n",
       "      <td id=\"T_dc982_row0_col2\" class=\"data row0 col2\" >$6,779,270</td>\n",
       "      <td id=\"T_dc982_row0_col3\" class=\"data row0 col3\" >$8,348,722</td>\n",
       "      <td id=\"T_dc982_row0_col4\" class=\"data row0 col4\" >$10,324,609</td>\n",
       "      <td id=\"T_dc982_row0_col5\" class=\"data row0 col5\" >$20,819,775</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_dc982_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_dc982_row1_col0\" class=\"data row1 col0\" >Implementation and migration cost</td>\n",
       "      <td id=\"T_dc982_row1_col1\" class=\"data row1 col1\" >$1,196,250</td>\n",
       "      <td id=\"T_dc982_row1_col2\" class=\"data row1 col2\" >$207,166</td>\n",
       "      <td id=\"T_dc982_row1_col3\" class=\"data row1 col3\" >$207,166</td>\n",
       "      <td id=\"T_dc982_row1_col4\" class=\"data row1 col4\" >$0</td>\n",
       "      <td id=\"T_dc982_row1_col5\" class=\"data row1 col5\" >$1,555,795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_dc982_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_dc982_row2_col0\" class=\"data row2 col0\" >Ongoing management</td>\n",
       "      <td id=\"T_dc982_row2_col1\" class=\"data row2 col1\" >$0</td>\n",
       "      <td id=\"T_dc982_row2_col2\" class=\"data row2 col2\" >$294,630</td>\n",
       "      <td id=\"T_dc982_row2_col3\" class=\"data row2 col3\" >$215,280</td>\n",
       "      <td id=\"T_dc982_row2_col4\" class=\"data row2 col4\" >$215,280</td>\n",
       "      <td id=\"T_dc982_row2_col5\" class=\"data row2 col5\" >$607,506</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_dc982_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_dc982_row3_col0\" class=\"data row3 col0\" >TOTAL</td>\n",
       "      <td id=\"T_dc982_row3_col1\" class=\"data row3 col1\" >$1,196,250</td>\n",
       "      <td id=\"T_dc982_row3_col2\" class=\"data row3 col2\" >$7,281,067</td>\n",
       "      <td id=\"T_dc982_row3_col3\" class=\"data row3 col3\" >$8,771,168</td>\n",
       "      <td id=\"T_dc982_row3_col4\" class=\"data row3 col4\" >$10,539,889</td>\n",
       "      <td id=\"T_dc982_row3_col5\" class=\"data row3 col5\" >$22,983,076</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x10ac1fbf0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "rows = []\n",
    "for c in seed_data.COSTS:\n",
    "    rf = c['risk_adjustment']\n",
    "    init_ra = risk_adjust_cost(c.get('initial') or 0, rf)\n",
    "    yr = [c['year_values'][str(y)] for y in (1, 2, 3)]\n",
    "    yr_ra = [risk_adjust_cost(v, rf) for v in yr]\n",
    "    pv = npv(yr_ra, config.DISCOUNT_RATE, initial=init_ra)\n",
    "    rows.append({\n",
    "        'Cost': c['label'],\n",
    "        'Initial (RA)': init_ra,\n",
    "        'Y1 (RA)': yr_ra[0],\n",
    "        'Y2 (RA)': yr_ra[1],\n",
    "        'Y3 (RA)': yr_ra[2],\n",
    "        'PV': pv,\n",
    "    })\n",
    "df_check = pd.DataFrame(rows)\n",
    "totals = df_check.drop(columns='Cost').sum()\n",
    "df_check.loc[len(df_check)] = ['TOTAL'] + totals.tolist()\n",
    "df_check.style.format({c: '${:,.0f}' for c in df_check.columns if c != 'Cost'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4109784e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"padding:10px 14px;border-left:4px solid #2e7d32;background:#e8f5e9;color:#1a1a1a;border-radius:4px;margin:6px 0;\">Computed Costs PV: <b>$22,983,076</b><br>Forrester target:  <b>$22,983,076</b><br>Δ = $-0</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "expected_pv = 22_983_076\n",
    "computed_pv = df_check.iloc[-1]['PV']\n",
    "delta = computed_pv - expected_pv\n",
    "kind = 'success' if abs(delta) < 1_000 else 'warning'\n",
    "display.alert(\n",
    "    f'Computed Costs PV: <b>${computed_pv:,.0f}</b><br>'\n",
    "    f'Forrester target:  <b>${expected_pv:,.0f}</b><br>'\n",
    "    f'Δ = ${delta:,.0f}',\n",
    "    kind,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd1b3c04",
   "metadata": {},
   "source": [
    "## Cost mix\n",
    "\n",
    "Most of the three-year cost (~90%) is Amazon Connect *usage* (Ft) —\n",
    "consistent with the PDF's framing that consumption-based pricing dominates,\n",
    "with implementation a one-time investment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "90e9b5e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "hole": 0.35,
         "labels": [
          "Amazon Connect usage cost",
          "Implementation and migration cost",
          "Ongoing management"
         ],
         "type": "pie",
         "values": [
          25452601.650000002,
          1610582.6,
          725190
         ]
        }
       ],
       "layout": {
        "margin": {
         "b": 40,
         "l": 40,
         "r": 20,
         "t": 60
        },
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermap": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermap"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "Cost Breakdown (Three-Year, Risk-Adjusted)"
        }
       }
      },
      "image/png": "[encoded data, 52476 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "charts.cost_breakdown_pie(seed_data.COSTS).show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d15ae10",
   "metadata": {},
   "source": [
    "## Push to Athena"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "03547040",
   "metadata": {},
   "outputs": [],
   "source": [
    "if config.TOOL_PUBLIC_ID:\n",
    "    from core.tei_client import TEIClient\n",
    "\n",
    "    client = TEIClient()\n",
    "    client.update_values(config.TOOL_PUBLIC_ID, seed_data.COSTS)\n",
    "    display.alert(f'Pushed {len(seed_data.COSTS)} cost rows to '\n",
    "                  f'tool <code>{config.TOOL_PUBLIC_ID}</code>.', 'success')\n",
    "else:\n",
    "    display.alert('No TOOL_PUBLIC_ID set — skipped Athena push.', 'info')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f5befbb",
   "metadata": {},
   "source": [
    "Continue with [`03_business_case.ipynb`](03_business_case.ipynb) →"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
