{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "231c773a",
   "metadata": {},
   "source": [
    "# 01 — Benefits Analysis\n",
    "\n",
    "**Study:** Forrester *Total Economic Impact™ Of Amazon Connect* (Feb 2026)\n",
    "\n",
    "Quantify the five benefit categories Forrester identified for the\n",
    "composite organization, push them into Athena, and verify the totals\n",
    "match the published study (Benefits PV ≈ **$101.7M**)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "110d7e61",
   "metadata": {},
   "source": [
    "## Setup\n",
    "\n",
    "We add the project root to `sys.path` so the notebook can import `core` and\n",
    "the study's local modules without `pip install -e .`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c83c2758",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Project root: /Users/robert/git/palladium\n",
      "Study root:   /Users/robert/git/palladium/studies/202602_AmazonConnect\n"
     ]
    }
   ],
   "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",
    "\n",
    "STUDY = ROOT / 'studies' / '202602_AmazonConnect'\n",
    "if str(STUDY) not in sys.path:\n",
    "    sys.path.insert(0, str(STUDY))\n",
    "print(f'Project root: {ROOT}')\n",
    "print(f'Study root:   {STUDY}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c371ef85",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"padding:10px 14px;border-left:4px solid #0277bd;background:#e1f5fe;color:#1a1a1a;border-radius:4px;margin:6px 0;\">Study: <b>202602_AmazonConnect</b> • discount rate 10% • 3-year horizon</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import config\n",
    "import seed_data\n",
    "from core.calculations import npv, risk_adjust_benefit\n",
    "from core.notebook_helpers import charts, display, tables\n",
    "\n",
    "display.alert(\n",
    "    f'Study: <b>{config.STUDY_SLUG}</b> • discount rate {config.DISCOUNT_RATE:.0%} '\n",
    "    f'• {config.ANALYSIS_YEARS}-year horizon',\n",
    "    'info',\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd94503d",
   "metadata": {},
   "source": [
    "## Benefits — nominal & risk-adjusted\n",
    "\n",
    "Forrester quantifies five benefit categories:\n",
    "\n",
    "| Ref | Benefit | Y1 | Y2 | Y3 | Risk Adj |\n",
    "|---|---|---|---|---|---|\n",
    "| At | AI-driven contact resolution efficiency | $13.9M | $23.9M | $37.8M | 15% |\n",
    "| Bt | AI-powered content & sentiment analysis | $4.6M | $5.4M | $6.3M | 15% |\n",
    "| Ct | AI-enabled forecasting & supervision | $6.7M | $9.1M | $12.4M | 15% |\n",
    "| Dt | Data-driven profit lift (conversion +20%) | $1.2M | $1.6M | $2.0M | 20% |\n",
    "| Et | Legacy solution cost savings | $6.2M | $8.0M | $10.4M | 20% |\n",
    "\n",
    "All five are seeded in `seed_data.BENEFITS` with full source notes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6177ea7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "</style>\n",
       "<table id=\"T_59c3d\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th id=\"T_59c3d_level0_col0\" class=\"col_heading level0 col0\" >field_key</th>\n",
       "      <th id=\"T_59c3d_level0_col1\" class=\"col_heading level0 col1\" >label</th>\n",
       "      <th id=\"T_59c3d_level0_col2\" class=\"col_heading level0 col2\" >category</th>\n",
       "      <th id=\"T_59c3d_level0_col3\" class=\"col_heading level0 col3\" >risk_adjustment</th>\n",
       "      <th id=\"T_59c3d_level0_col4\" class=\"col_heading level0 col4\" >Year 1</th>\n",
       "      <th id=\"T_59c3d_level0_col5\" class=\"col_heading level0 col5\" >Year 1 (RA)</th>\n",
       "      <th id=\"T_59c3d_level0_col6\" class=\"col_heading level0 col6\" >Year 2</th>\n",
       "      <th id=\"T_59c3d_level0_col7\" class=\"col_heading level0 col7\" >Year 2 (RA)</th>\n",
       "      <th id=\"T_59c3d_level0_col8\" class=\"col_heading level0 col8\" >Year 3</th>\n",
       "      <th id=\"T_59c3d_level0_col9\" class=\"col_heading level0 col9\" >Year 3 (RA)</th>\n",
       "      <th id=\"T_59c3d_level0_col10\" class=\"col_heading level0 col10\" >Total</th>\n",
       "      <th id=\"T_59c3d_level0_col11\" class=\"col_heading level0 col11\" >Total (RA)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_59c3d_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_59c3d_row0_col0\" class=\"data row0 col0\" >ai_contact_resolution</td>\n",
       "      <td id=\"T_59c3d_row0_col1\" class=\"data row0 col1\" >AI-driven contact resolution efficiency</td>\n",
       "      <td id=\"T_59c3d_row0_col2\" class=\"data row0 col2\" >Productivity</td>\n",
       "      <td id=\"T_59c3d_row0_col3\" class=\"data row0 col3\" >0.150000</td>\n",
       "      <td id=\"T_59c3d_row0_col4\" class=\"data row0 col4\" >$13,911,040</td>\n",
       "      <td id=\"T_59c3d_row0_col5\" class=\"data row0 col5\" >$11,824,384</td>\n",
       "      <td id=\"T_59c3d_row0_col6\" class=\"data row0 col6\" >$23,932,480</td>\n",
       "      <td id=\"T_59c3d_row0_col7\" class=\"data row0 col7\" >$20,342,608</td>\n",
       "      <td id=\"T_59c3d_row0_col8\" class=\"data row0 col8\" >$37,797,760</td>\n",
       "      <td id=\"T_59c3d_row0_col9\" class=\"data row0 col9\" >$32,128,096</td>\n",
       "      <td id=\"T_59c3d_row0_col10\" class=\"data row0 col10\" >$75,641,280</td>\n",
       "      <td id=\"T_59c3d_row0_col11\" class=\"data row0 col11\" >$64,295,088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_59c3d_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_59c3d_row1_col0\" class=\"data row1 col0\" >ai_content_sentiment</td>\n",
       "      <td id=\"T_59c3d_row1_col1\" class=\"data row1 col1\" >AI-powered content and sentiment analysis savings</td>\n",
       "      <td id=\"T_59c3d_row1_col2\" class=\"data row1 col2\" >Productivity</td>\n",
       "      <td id=\"T_59c3d_row1_col3\" class=\"data row1 col3\" >0.150000</td>\n",
       "      <td id=\"T_59c3d_row1_col4\" class=\"data row1 col4\" >$4,586,620</td>\n",
       "      <td id=\"T_59c3d_row1_col5\" class=\"data row1 col5\" >$3,898,627</td>\n",
       "      <td id=\"T_59c3d_row1_col6\" class=\"data row1 col6\" >$5,358,412</td>\n",
       "      <td id=\"T_59c3d_row1_col7\" class=\"data row1 col7\" >$4,554,650</td>\n",
       "      <td id=\"T_59c3d_row1_col8\" class=\"data row1 col8\" >$6,291,680</td>\n",
       "      <td id=\"T_59c3d_row1_col9\" class=\"data row1 col9\" >$5,347,928</td>\n",
       "      <td id=\"T_59c3d_row1_col10\" class=\"data row1 col10\" >$16,236,712</td>\n",
       "      <td id=\"T_59c3d_row1_col11\" class=\"data row1 col11\" >$13,801,205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_59c3d_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_59c3d_row2_col0\" class=\"data row2 col0\" >ai_forecasting_supervision</td>\n",
       "      <td id=\"T_59c3d_row2_col1\" class=\"data row2 col1\" >AI-enabled forecasting, agent scheduling, and supervision</td>\n",
       "      <td id=\"T_59c3d_row2_col2\" class=\"data row2 col2\" >Productivity</td>\n",
       "      <td id=\"T_59c3d_row2_col3\" class=\"data row2 col3\" >0.150000</td>\n",
       "      <td id=\"T_59c3d_row2_col4\" class=\"data row2 col4\" >$6,651,680</td>\n",
       "      <td id=\"T_59c3d_row2_col5\" class=\"data row2 col5\" >$5,653,928</td>\n",
       "      <td id=\"T_59c3d_row2_col6\" class=\"data row2 col6\" >$9,133,760</td>\n",
       "      <td id=\"T_59c3d_row2_col7\" class=\"data row2 col7\" >$7,763,696</td>\n",
       "      <td id=\"T_59c3d_row2_col8\" class=\"data row2 col8\" >$12,391,712</td>\n",
       "      <td id=\"T_59c3d_row2_col9\" class=\"data row2 col9\" >$10,532,955</td>\n",
       "      <td id=\"T_59c3d_row2_col10\" class=\"data row2 col10\" >$28,177,152</td>\n",
       "      <td id=\"T_59c3d_row2_col11\" class=\"data row2 col11\" >$23,950,579</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_59c3d_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_59c3d_row3_col0\" class=\"data row3 col0\" >data_driven_profit_lift</td>\n",
       "      <td id=\"T_59c3d_row3_col1\" class=\"data row3 col1\" >Data-driven profit lift with increased conversion</td>\n",
       "      <td id=\"T_59c3d_row3_col2\" class=\"data row3 col2\" >Revenue</td>\n",
       "      <td id=\"T_59c3d_row3_col3\" class=\"data row3 col3\" >0.200000</td>\n",
       "      <td id=\"T_59c3d_row3_col4\" class=\"data row3 col4\" >$1,200,000</td>\n",
       "      <td id=\"T_59c3d_row3_col5\" class=\"data row3 col5\" >$960,000</td>\n",
       "      <td id=\"T_59c3d_row3_col6\" class=\"data row3 col6\" >$1,560,000</td>\n",
       "      <td id=\"T_59c3d_row3_col7\" class=\"data row3 col7\" >$1,248,000</td>\n",
       "      <td id=\"T_59c3d_row3_col8\" class=\"data row3 col8\" >$2,028,000</td>\n",
       "      <td id=\"T_59c3d_row3_col9\" class=\"data row3 col9\" >$1,622,400</td>\n",
       "      <td id=\"T_59c3d_row3_col10\" class=\"data row3 col10\" >$4,788,000</td>\n",
       "      <td id=\"T_59c3d_row3_col11\" class=\"data row3 col11\" >$3,830,400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_59c3d_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",
       "      <td id=\"T_59c3d_row4_col0\" class=\"data row4 col0\" >legacy_solution_savings</td>\n",
       "      <td id=\"T_59c3d_row4_col1\" class=\"data row4 col1\" >Legacy solution cost savings</td>\n",
       "      <td id=\"T_59c3d_row4_col2\" class=\"data row4 col2\" >Cost Savings</td>\n",
       "      <td id=\"T_59c3d_row4_col3\" class=\"data row4 col3\" >0.200000</td>\n",
       "      <td id=\"T_59c3d_row4_col4\" class=\"data row4 col4\" >$6,177,600</td>\n",
       "      <td id=\"T_59c3d_row4_col5\" class=\"data row4 col5\" >$4,942,080</td>\n",
       "      <td id=\"T_59c3d_row4_col6\" class=\"data row4 col6\" >$8,030,880</td>\n",
       "      <td id=\"T_59c3d_row4_col7\" class=\"data row4 col7\" >$6,424,704</td>\n",
       "      <td id=\"T_59c3d_row4_col8\" class=\"data row4 col8\" >$10,440,144</td>\n",
       "      <td id=\"T_59c3d_row4_col9\" class=\"data row4 col9\" >$8,352,115</td>\n",
       "      <td id=\"T_59c3d_row4_col10\" class=\"data row4 col10\" >$24,648,624</td>\n",
       "      <td id=\"T_59c3d_row4_col11\" class=\"data row4 col11\" >$19,718,899</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x11c133a40>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = tables.benefits_table(seed_data.BENEFITS)\n",
    "df.style.format({col: '${:,.0f}' for col in df.columns if col not in ('field_key','label','category','risk_adjustment')})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "573f12d8",
   "metadata": {},
   "source": [
    "## Local validation against the PDF\n",
    "\n",
    "Re-derive the per-benefit risk-adjusted PV and confirm we land on Forrester's\n",
    "**$101,696,791** total within rounding."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8cf32003",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "</style>\n",
       "<table id=\"T_a110f\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th id=\"T_a110f_level0_col0\" class=\"col_heading level0 col0\" >Benefit</th>\n",
       "      <th id=\"T_a110f_level0_col1\" class=\"col_heading level0 col1\" >Y1 (RA)</th>\n",
       "      <th id=\"T_a110f_level0_col2\" class=\"col_heading level0 col2\" >Y2 (RA)</th>\n",
       "      <th id=\"T_a110f_level0_col3\" class=\"col_heading level0 col3\" >Y3 (RA)</th>\n",
       "      <th id=\"T_a110f_level0_col4\" class=\"col_heading level0 col4\" >PV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_a110f_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_a110f_row0_col0\" class=\"data row0 col0\" >AI-driven contact resolution efficiency</td>\n",
       "      <td id=\"T_a110f_row0_col1\" class=\"data row0 col1\" >$11,824,384</td>\n",
       "      <td id=\"T_a110f_row0_col2\" class=\"data row0 col2\" >$20,342,608</td>\n",
       "      <td id=\"T_a110f_row0_col3\" class=\"data row0 col3\" >$32,128,096</td>\n",
       "      <td id=\"T_a110f_row0_col4\" class=\"data row0 col4\" >$51,699,827</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a110f_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_a110f_row1_col0\" class=\"data row1 col0\" >AI-powered content and sentiment analysis savings</td>\n",
       "      <td id=\"T_a110f_row1_col1\" class=\"data row1 col1\" >$3,898,627</td>\n",
       "      <td id=\"T_a110f_row1_col2\" class=\"data row1 col2\" >$4,554,650</td>\n",
       "      <td id=\"T_a110f_row1_col3\" class=\"data row1 col3\" >$5,347,928</td>\n",
       "      <td id=\"T_a110f_row1_col4\" class=\"data row1 col4\" >$11,326,358</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a110f_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_a110f_row2_col0\" class=\"data row2 col0\" >AI-enabled forecasting, agent scheduling, and supervision</td>\n",
       "      <td id=\"T_a110f_row2_col1\" class=\"data row2 col1\" >$5,653,928</td>\n",
       "      <td id=\"T_a110f_row2_col2\" class=\"data row2 col2\" >$7,763,696</td>\n",
       "      <td id=\"T_a110f_row2_col3\" class=\"data row2 col3\" >$10,532,955</td>\n",
       "      <td id=\"T_a110f_row2_col4\" class=\"data row2 col4\" >$19,469,777</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a110f_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_a110f_row3_col0\" class=\"data row3 col0\" >Data-driven profit lift with increased conversion</td>\n",
       "      <td id=\"T_a110f_row3_col1\" class=\"data row3 col1\" >$960,000</td>\n",
       "      <td id=\"T_a110f_row3_col2\" class=\"data row3 col2\" >$1,248,000</td>\n",
       "      <td id=\"T_a110f_row3_col3\" class=\"data row3 col3\" >$1,622,400</td>\n",
       "      <td id=\"T_a110f_row3_col4\" class=\"data row3 col4\" >$3,123,065</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a110f_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",
       "      <td id=\"T_a110f_row4_col0\" class=\"data row4 col0\" >Legacy solution cost savings</td>\n",
       "      <td id=\"T_a110f_row4_col1\" class=\"data row4 col1\" >$4,942,080</td>\n",
       "      <td id=\"T_a110f_row4_col2\" class=\"data row4 col2\" >$6,424,704</td>\n",
       "      <td id=\"T_a110f_row4_col3\" class=\"data row4 col3\" >$8,352,115</td>\n",
       "      <td id=\"T_a110f_row4_col4\" class=\"data row4 col4\" >$16,077,540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a110f_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n",
       "      <td id=\"T_a110f_row5_col0\" class=\"data row5 col0\" >TOTAL</td>\n",
       "      <td id=\"T_a110f_row5_col1\" class=\"data row5 col1\" >$27,279,019</td>\n",
       "      <td id=\"T_a110f_row5_col2\" class=\"data row5 col2\" >$40,333,658</td>\n",
       "      <td id=\"T_a110f_row5_col3\" class=\"data row5 col3\" >$57,983,494</td>\n",
       "      <td id=\"T_a110f_row5_col4\" class=\"data row5 col4\" >$101,696,568</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x12a29a690>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "rows = []\n",
    "for b in seed_data.BENEFITS:\n",
    "    rf = b['risk_adjustment']\n",
    "    yr = [b['year_values'][str(y)] for y in (1, 2, 3)]\n",
    "    yr_ra = [risk_adjust_benefit(v, rf) for v in yr]\n",
    "    pv = npv(yr_ra, config.DISCOUNT_RATE)\n",
    "    rows.append({\n",
    "        'Benefit': b['label'],\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",
    "df_check.loc[len(df_check)] = ['TOTAL', df_check['Y1 (RA)'].sum(), df_check['Y2 (RA)'].sum(), df_check['Y3 (RA)'].sum(), df_check['PV'].sum()]\n",
    "df_check.style.format({c: '${:,.0f}' for c in df_check.columns if c != 'Benefit'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3ded50c8",
   "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 Benefits PV: <b>$101,696,568</b><br>Forrester target:     <b>$101,696,791</b><br>Δ = $-223 (rounding)</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "expected_pv = 101_696_791\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 Benefits PV: <b>${computed_pv:,.0f}</b><br>'\n",
    "    f'Forrester target:     <b>${expected_pv:,.0f}</b><br>'\n",
    "    f'Δ = ${delta:,.0f} (rounding)',\n",
    "    kind,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a5ad453a",
   "metadata": {},
   "source": [
    "## Visualize\n",
    "\n",
    "Horizontal bar chart of risk-adjusted three-year totals — mirrors the PDF p.6\n",
    "*Benefits (Three-Year)* graphic."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "452b8408",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "marker": {
          "color": "#2E7D32"
         },
         "orientation": "h",
         "text": [
          "$64.3M",
          "$13.8M",
          "$24.0M",
          "$3.8M",
          "$19.7M"
         ],
         "textposition": "auto",
         "type": "bar",
         "x": [
          64295088,
          13801205.2,
          23950579.2,
          3830400,
          19718899.2
         ],
         "y": [
          "AI-driven contact resolution efficiency",
          "AI-powered content and sentiment analysis savings",
          "AI-enabled forecasting, agent scheduling, and supervision",
          "Data-driven profit lift with increased conversion",
          "Legacy solution cost savings"
         ]
        }
       ],
       "layout": {
        "font": {
         "color": "#1F2937",
         "family": "Helvetica, Arial, sans-serif"
        },
        "legend": {
         "font": {
          "color": "#1F2937",
          "family": "Helvetica, Arial, sans-serif"
         }
        },
        "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": {
         "font": {
          "color": "#1F2937",
          "family": "Helvetica Neue, Arial, sans-serif"
         },
         "text": "Benefits (Three-Year)"
        },
        "xaxis": {
         "tickformat": "$,.0f"
        },
        "yaxis": {
         "autorange": "reversed"
        }
       }
      },
      "image/png": "[encoded data, 58576 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "charts.benefits_bar(seed_data.BENEFITS).show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c4591f5",
   "metadata": {},
   "source": [
    "## Push to Athena\n",
    "\n",
    "When `config.TOOL_PUBLIC_ID` is set, persist the seed values to the live\n",
    "TEI tool. Otherwise this cell is a no-op so the notebook still runs\n",
    "offline."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d10a54b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"padding:10px 14px;border-left:4px solid #0277bd;background:#e1f5fe;color:#1a1a1a;border-radius:4px;margin:6px 0;\">No TOOL_PUBLIC_ID set in config.py — skipped Athena push. Set <code>PALLADIUM_TOOL_PUBLIC_ID</code> in your environment or edit config.py to enable.</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "if config.TOOL_PUBLIC_ID:\n",
    "    from core.tei_client import TEIClient\n",
    "\n",
    "    client = TEIClient()\n",
    "    result = client.update_values(config.TOOL_PUBLIC_ID, seed_data.BENEFITS)\n",
    "    display.alert(f'Pushed {len(seed_data.BENEFITS)} benefit rows to '\n",
    "                  f'tool <code>{config.TOOL_PUBLIC_ID}</code>.', 'success')\n",
    "else:\n",
    "    display.alert(\n",
    "        'No TOOL_PUBLIC_ID set in config.py — skipped Athena push. '\n",
    "        'Set <code>PALLADIUM_TOOL_PUBLIC_ID</code> in your environment '\n",
    "        'or edit config.py to enable.',\n",
    "        'info',\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78693c14",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "Continue with [`02_costs.ipynb`](02_costs.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
}
