Download index.html from Hugdrigo/inventorypulse-reorder-studio: direct link, hf CLI and curl.
- Browser
- Download file 58.5 kB
-
https://huggingface.co/spaces/Hugdrigo/inventorypulse-reorder-studio/resolve/main/index.html
- Command line
-
hf download hf://spaces/Hugdrigo/inventorypulse-reorder-studio/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Hugdrigo/inventorypulse-reorder-studio/resolve/main/index.html
58.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <meta name="theme-color" content="#10182b"> | |
| <meta name="description" content="InventoryPulse: transparent inventory forecasting, reorder recommendations, ABC segmentation, and supply-chain scenario planning."> | |
| <title>InventoryPulse | Intelligent Inventory & Reorder Studio</title> | |
| <style> | |
| :root{--bg:#0a1020;--panel:#131c30;--panel2:#18243b;--line:#2b3850;--text:#f1f5ff;--muted:#9eacc5;--teal:#54dec6;--blue:#91abff;--coral:#ff937e;--amber:#ffd18a;--green:#7ce4ac;--input:#0f182b;--shadow:0 20px 60px rgba(2,7,17,.22)} | |
| *{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--text);font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-size:14px;line-height:1.48}button,input,select{font:inherit}button{cursor:pointer}button:disabled{cursor:not-allowed;opacity:.4}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--teal);outline-offset:3px}a{color:var(--teal)}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}.shell{display:flex;min-height:100vh}.sidebar{position:sticky;top:0;min-width:228px;width:228px;height:100vh;padding:24px 16px 20px;background:#0f192d;border-right:1px solid var(--line);display:flex;flex-direction:column}.brand{display:flex;align-items:center;gap:10px;padding:4px 9px 28px;font-weight:780;font-size:20px;letter-spacing:-.7px}.brand-logo{width:38px;height:38px;border-radius:13px;display:grid;place-items:center;background:linear-gradient(135deg,#5ce1c8,#728dff);color:#091325;font-size:23px;box-shadow:0 5px 20px #38d9bf28}.brand small{display:block;font-weight:600;letter-spacing:1.8px;font-size:9px;color:var(--muted);margin-top:-3px}.nav-caption,.sidebar-meta small{font-size:10px;color:#73829e;letter-spacing:1.6px;font-weight:750;text-transform:uppercase;margin:6px 13px 9px}.nav{display:flex;flex-direction:column;gap:5px}.nav a{display:flex;gap:11px;align-items:center;padding:12px 13px;color:#aab8d1;border-radius:11px;text-decoration:none;font-weight:620;transition:background .15s,color .15s}.nav a:hover,.nav a.active{background:#22334d;color:#fff}.nav a.active{box-shadow:inset 3px 0 0 var(--teal)}.nav svg{width:18px;height:18px;flex-shrink:0;stroke:currentColor}.sidebar-meta{margin-top:auto;border:1px solid #2c3d54;background:#17243a;border-radius:14px;padding:15px}.sidebar-meta small{margin:0;display:block}.sidebar-meta strong{font-size:13px;display:block;margin:7px 0}.sidebar-meta p{font-size:11px;color:var(--muted);margin:0}.sidebar-foot{color:#61718c;font-size:11px;margin:20px 8px 0}.main{max-width:1590px;width:100%;min-width:0;margin:0 auto;padding:28px clamp(18px,3.4vw,55px) 70px}.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:27px}.crumb{color:var(--muted);font-size:12px;font-weight:650}.crumb span{color:var(--teal)}.top-actions,.actions{display:flex;gap:9px;align-items:center;flex-wrap:wrap}.pill{border:1px solid #344861;background:#1b2a43;border-radius:100px;color:#c6d6ea;padding:7px 10px;font-size:11px;letter-spacing:.2px}.pill i{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--green);margin-right:5px}.btn{appearance:none;border:1px solid #40506c;border-radius:10px;background:#1b2841;color:var(--text);font-weight:690;padding:10px 14px;min-height:40px;transition:.15s;display:inline-flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap}.btn:hover{border-color:#88a0c6;background:#233653}.btn.primary{background:var(--teal);color:#08222a;border-color:var(--teal)}.btn.primary:hover{background:#9af4e5}.btn.ghost{background:transparent;border-color:transparent;color:#b6c5dc}.btn.small{min-height:33px;padding:7px 10px;font-size:11px}.btn.danger{border-color:#805160;color:#ffbac0}.btn svg{width:16px;height:16px;stroke:currentColor}.hero{position:relative;overflow:hidden;border:1px solid #34455f;border-radius:22px;background:linear-gradient(110deg,#1d3450 0%,#17253e 54%,#25325f 100%);padding:32px 35px 30px;margin-bottom:22px}.hero:before,.hero:after{position:absolute;content:"";border-radius:50%;filter:blur(8px);pointer-events:none}.hero:before{width:270px;height:270px;right:12%;top:-155px;background:#46d9c41e}.hero:after{width:280px;height:280px;right:-150px;bottom:-155px;background:#91a2ff22}.eyebrow{font-size:10px;text-transform:uppercase;letter-spacing:2.4px;color:var(--teal);font-weight:800;margin-bottom:9px}.hero h1{font-size:clamp(27px,3.1vw,43px);line-height:1.13;margin:0 0 12px;letter-spacing:-1.5px;font-weight:780}.hero p{color:#c0cde1;margin:0;max-width:690px;font-size:14px}.hero-bottom{display:flex;justify-content:space-between;gap:15px;margin-top:23px;align-items:center;flex-wrap:wrap;position:relative}.meta{display:flex;gap:16px;align-items:center;color:#abbdd6;font-size:11px}.meta b{color:#e9fffc}.section{scroll-margin-top:20px;margin-top:27px}.section-head{display:flex;justify-content:space-between;gap:15px;align-items:flex-end;margin-bottom:15px;flex-wrap:wrap}.section-head h2{font-size:20px;letter-spacing:-.6px;margin:0 0 3px}.section-head p{color:var(--muted);margin:0;font-size:12px}.section-tag{font-size:10px;font-weight:750;padding:6px 9px;border-radius:7px;background:#24354e;color:var(--teal);text-transform:uppercase;letter-spacing:.6px}.kpi-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.kpi{background:var(--panel);border:1px solid var(--line);border-radius:15px;padding:20px 18px;min-width:0;position:relative;overflow:hidden}.kpi:after{content:"";width:78px;height:78px;position:absolute;right:-42px;top:-42px;border:1px solid #536e9161;border-radius:50%}.kpi-label{color:#acbdd4;font-size:12px;font-weight:570}.kpi-value{font-size:clamp(21px,2.4vw,33px);line-height:1.23;letter-spacing:-1.2px;font-weight:780;margin:13px 0 8px}.kpi-bottom{display:flex;align-items:center;gap:7px;color:#91a6be;font-size:11px}.dot{width:7px;height:7px;border-radius:50%;display:inline-block;background:var(--teal);flex:0 0 auto}.dot.alert{background:var(--coral)}.dot.amber{background:var(--amber)}.cols{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(290px,1fr);gap:15px}.card{min-width:0;background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:20px 20px 19px;box-shadow:0 3px 15px #04091513}.card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:19px}.card h3{font-size:14px;font-weight:730;margin:0}.card .sub{font-size:11px;color:var(--muted);margin:4px 0 0}.chart-wrap{height:230px;position:relative}svg.chart{height:100%;width:100%;overflow:visible}.chart-label{fill:#91a4c0;font:11px Inter,system-ui,sans-serif}.legend{display:flex;align-items:center;gap:12px;flex-wrap:wrap;color:#a9b8d0;font-size:11px}.legend span:before{content:"";display:inline-block;width:8px;height:8px;border-radius:3px;background:var(--teal);margin-right:6px}.legend span:nth-child(2):before{background:var(--blue)}.legend span:nth-child(3):before{background:var(--amber)}.donut-outer{display:grid;grid-template-columns:155px 1fr;align-items:center;gap:13px;min-height:230px}.donut{width:154px;height:154px;position:relative;margin:auto}.donut svg{width:100%;height:100%;transform:rotate(-90deg)}.donut-center{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}.donut-center strong{font-size:27px;letter-spacing:-.7px}.donut-center span{font-size:10px;color:var(--muted)}.donut-list{display:flex;flex-direction:column;gap:15px}.donut-row{display:grid;grid-template-columns:10px 1fr auto;gap:10px;align-items:center;font-size:12px;color:var(--muted)}.donut-row b{color:var(--text);font-size:12px}.line-dot{width:9px;height:9px;border-radius:3px}.filters{display:flex;align-items:center;gap:9px;flex-wrap:wrap}.field,.select{border:1px solid #33445e;border-radius:9px;background:var(--input);color:var(--text);height:40px;padding:0 12px;min-width:0}.field::placeholder{color:#75849b}.select{padding-right:20px}.search-field{min-width:min(235px,100%)}.table-scroller{overflow-x:auto;border-radius:11px;border:1px solid var(--line)}table{border-collapse:collapse;width:100%;min-width:865px;text-align:left}thead{background:#202e46}th{color:#94a9c4;font-size:10px;letter-spacing:.6px;text-transform:uppercase;font-weight:780;padding:14px 14px;white-space:nowrap}td{padding:15px 14px;border-top:1px solid #28354a;white-space:nowrap;font-size:12px;color:#c0cce0}tbody tr:hover{background:#192842}td strong{color:#f0f6ff;font-weight:700}.sku-id{display:block;color:#7f91af;font-size:10px;margin-top:3px}.status{display:inline-flex;align-items:center;border-radius:7px;padding:5px 8px;font-size:10px;font-weight:730}.status.critical{color:#ffb8b3;background:#532d3c}.status.reorder{color:#ffd19d;background:#503c32}.status.healthy{color:#95eac3;background:#22443e}.abc{display:inline-grid;place-items:center;width:25px;height:25px;font-size:11px;border-radius:7px;font-weight:800;background:#314969;color:var(--blue)}.abc.A{color:#9af1db;background:#21473f}.abc.B{color:#ffd8a6;background:#534239}.abc.C{color:#acc2ff;background:#313b5d}.muted{color:var(--muted)}.right{text-align:right}.empty{padding:30px;text-align:center;color:var(--muted)}.mini-stat-row{display:flex;justify-content:space-between;gap:12px;border-bottom:1px solid #2d3d54;padding:12px 0;color:var(--muted);font-size:12px}.mini-stat-row strong{color:var(--text)}.lab-grid{display:grid;grid-template-columns:1.05fr 1fr;gap:15px}.control-line{margin-bottom:20px}.control-head{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px;margin-bottom:8px;color:#c1cde0}.control-head strong{color:var(--teal);font-variant-numeric:tabular-nums}.range{width:100%;appearance:none;height:6px;border-radius:10px;outline:0;background:#334763;cursor:pointer}.range::-webkit-slider-thumb{appearance:none;width:16px;height:16px;border:3px solid #f4fffb;border-radius:50%;background:var(--teal);box-shadow:0 0 0 3px #54dec52a}.preset-row{display:flex;gap:7px;margin-bottom:22px;flex-wrap:wrap}.preset{border:1px solid #364863;background:#142039;color:#c5d4e5;border-radius:30px;padding:7px 12px;font-size:11px}.preset.active{background:#27534f;border-color:var(--teal);color:#d6fff8}.scenario-compare{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:8px 0 13px}.metric-tile{border:1px solid #30415a;border-radius:11px;padding:14px;background:#17263c}.metric-tile span{display:block;color:#a7b9d0;font-size:11px;margin-bottom:7px}.metric-tile strong{font-size:20px;letter-spacing:-.7px}.metric-tile small{display:block;color:#91a5bf;margin-top:6px}.budget-bar{height:9px;border-radius:8px;background:#30415b;overflow:hidden;margin-top:8px}.budget-fill{height:100%;width:0;background:linear-gradient(90deg,#54dec6,#91abff);transition:width .2s}.budget-fill.over{background:linear-gradient(90deg,#ffcf90,#fa897e)}.insight{background:linear-gradient(115deg,#1e3548,#1c2b44);border:1px solid #34506a;padding:16px;border-radius:12px;margin-top:13px;font-size:12px;color:#c6d7e9}.insight b{color:#ecfffb}.insight p{margin:5px 0 0}.methods{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.method{background:var(--panel);border:1px solid var(--line);border-radius:13px;padding:19px}.method b{font-size:12px;color:#e6f5ff}.method p{font-size:12px;color:var(--muted);margin:9px 0 0}.footer{border-top:1px solid var(--line);margin-top:35px;padding-top:18px;display:flex;justify-content:space-between;gap:16px;flex-wrap:wrap;color:#8193af;font-size:11px}.footer b{color:var(--teal)}.overlay{position:fixed;inset:0;z-index:20;background:#030916d9;display:none;align-items:center;justify-content:center;padding:22px;overflow:auto}.overlay.open{display:flex}.modal{width:min(710px,100%);border:1px solid #455b7b;border-radius:19px;background:#172238;box-shadow:0 35px 110px #000b;max-height:90vh;overflow:auto}.modal-head,.modal-foot{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:21px 25px;border-bottom:1px solid #304159}.modal-foot{border-bottom:0;border-top:1px solid #304159;justify-content:flex-end}.modal-head h2{font-size:18px;margin:0}.modal-body{padding:23px 25px}.form-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.form-grid .wide{grid-column:span 3}.form-grid label{display:block;font-size:11px;color:#aebed2;margin-bottom:7px}.form-grid input,.form-grid select{width:100%;height:40px}.hint{color:#93a5bd;font-size:11px;margin:8px 0 0}.close{border:0;background:#2c3c54;color:#cfdded;width:33px;height:33px;border-radius:9px;font-size:20px}.history-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:9px;margin-top:11px}.history-grid label{display:block;color:#98abc5;font-size:10px;margin-bottom:5px}.history-grid input{width:100%;height:36px}.modal-divider{margin:22px 0 18px;border:0;border-top:1px solid #36475d}.help-code{padding:12px;background:#0f1a2c;border:1px solid #344761;border-radius:8px;color:#aee8dc;font-size:11px;overflow:auto;white-space:nowrap}.toast{position:fixed;bottom:25px;right:25px;background:#1e3f43;color:#e4fff9;border:1px solid #51d7c6;border-radius:12px;z-index:40;padding:12px 16px;box-shadow:var(--shadow);max-width:350px;display:none}.toast.on{display:block}.error{color:#ffafab!important}.low{color:var(--coral)}.up{color:var(--green)}.nowrap{white-space:nowrap}.note{padding:11px 13px;background:#1a2d43;border-left:3px solid var(--teal);border-radius:6px;color:#aebed1;font-size:12px;margin-top:16px}.help-actions{display:flex;gap:9px;flex-wrap:wrap;margin-top:18px}.mobile-nav{display:none}body.light{--bg:#eef3fa;--panel:#ffffff;--panel2:#ecf4fb;--line:#d4dfe9;--text:#15243b;--muted:#647690;--input:#f9fbff;--shadow:0 20px 60px #17345720;color:var(--text)}body.light .sidebar{background:#e6ecf5}body.light .nav a{color:#52657f}body.light .nav a.active,body.light .nav a:hover{background:#ccdbe9;color:#10263c}body.light .card,body.light .kpi,body.light .method{box-shadow:0 3px 22px #1632510b}body.light .hero{color:#fff}body.light .crumb{color:#63768c}body.light .crumb span{color:#227d7f}body.light .btn{background:#fff;color:#213955;border-color:#bfd0e0}body.light .btn.primary{background:#147f7b;color:white}body.light .btn.ghost{background:transparent}body.light .pill{background:#fff;color:#51647c;border-color:#ccdbe9}body.light .sidebar-meta{background:#fff;border-color:#ced9e6}body.light .kpi-label{color:#64758e}body.light .kpi-bottom{color:#687c95}body.light .select,body.light .field{color:#163047;border-color:#c9d7e5}body.light .modal{background:#fff}body.light .modal-head,body.light .modal-foot{border-color:#d5e0ed}body.light .modal .close{color:#1c324a;background:#e9eff5}body.light .modal .hint{color:#64758e}body.light .status.critical{color:#923c3c;background:#ffe7e6}body.light .status.reorder{color:#986010;background:#fff1db}body.light .status.healthy{color:#197459;background:#dbf6e9}body.light .abc.A{color:#1b7963;background:#d5f2e9}body.light .abc.B{color:#966719;background:#fff0d4}body.light .abc.C{color:#4a62a3;background:#e5eafe}body.light thead{background:#f0f5fb}body.light th{color:#5d7291}body.light td{color:#556982;border-color:#e0e8f1}body.light td strong{color:#17324d}body.light tbody tr:hover{background:#f4f8ff}body.light .card h3{color:#162e4d}body.light .kpi-value{color:#122744}body.light .metric-tile{background:#eff5fb;border-color:#d6e2ee}body.light .metric-tile strong,body.light .mini-stat-row strong{color:#18314e}body.light .metric-tile span,body.light .metric-tile small{color:#687c96}body.light .insight{background:#e7f6f4;border-color:#b6d9d3;color:#35636c}body.light .insight b{color:#193c45}body.light .method b{color:#17344f}body.light .preset{background:#edf4fb;color:#506583}body.light .preset.active{background:#d6f7f0;color:#0c756f}body.light .help-code{background:#e9f2f6;color:#285962}body.light .note{background:#e9f7f6;color:#496678}body.light .donut-list .donut-row b{color:#192c47} | |
| @media(max-width:1200px){.sidebar{min-width:197px;width:197px}.kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.cols{grid-template-columns:1fr 1fr}.donut-outer{grid-template-columns:1fr;min-height:0}.donut-list{display:grid;grid-template-columns:repeat(3,1fr)}.donut-row{grid-template-columns:10px 1fr}.donut-row b{grid-column:2}.donut{width:140px;height:140px}.methods{grid-template-columns:1fr 1fr}}@media(max-width:850px){.sidebar{display:none}.mobile-nav{display:flex;position:sticky;top:0;z-index:10;justify-content:space-around;gap:6px;background:#0f192df7;border-bottom:1px solid #354760;padding:10px 12px;backdrop-filter:blur(15px)}.mobile-nav a{color:#c4d5ec;text-decoration:none;font-size:11px;padding:6px 8px}.main{padding:22px 17px 45px}.topbar{margin-bottom:19px}.cols,.lab-grid{grid-template-columns:1fr}.donut-outer{grid-template-columns:150px 1fr}.donut-list{display:flex}.hero{padding:24px}.methods{grid-template-columns:1fr 1fr}}@media(max-width:580px){.hero{padding:22px}.hero-bottom,.section-head{align-items:flex-start}.topbar{align-items:flex-start}.top-actions .pill{display:none}.top-actions .btn{font-size:11px;padding:8px}.kpi-grid{gap:9px}.kpi{padding:15px}.kpi-value{font-size:23px}.kpi-label{font-size:11px}.kpi-bottom{font-size:10px}.card{padding:16px}.donut-outer{grid-template-columns:1fr}.donut-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}.donut-row{grid-template-columns:10px 1fr;font-size:11px}.donut-row b{grid-column:2}.filters{width:100%}.filters .field{width:100%}.filters .select{flex:1}.methods{grid-template-columns:1fr}.scenario-compare{grid-template-columns:1fr 1fr}.metric-tile{padding:10px}.metric-tile strong{font-size:17px}.form-grid{grid-template-columns:1fr 1fr}.form-grid .wide{grid-column:span 2}.history-grid{grid-template-columns:repeat(4,minmax(0,1fr))}.modal-body,.modal-head,.modal-foot{padding:16px}.meta{gap:10px}.footer{flex-direction:column}} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="shell"> | |
| <aside class="sidebar" aria-label="Primary navigation"> | |
| <div class="brand"><div class="brand-logo" aria-hidden="true">◈</div><div>Inventory<span style="color:var(--teal)">Pulse</span><small>OPERATIONS INTELLIGENCE</small></div></div> | |
| <div class="nav-caption">Workspace</div> | |
| <nav class="nav"> | |
| <a href="#overview" class="active"><svg viewBox="0 0 24 24" fill="none" stroke-width="1.7"><rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="5" rx="2"/><rect x="13" y="10" width="8" height="11" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/></svg>Executive overview</a> | |
| <a href="#planner"><svg viewBox="0 0 24 24" fill="none" stroke-width="1.7"><path d="M3 7h18M5 7l2 13h10l2-13M9 3v4m6-4v4M9 12h6m-6 4h6"/></svg>Reorder planner</a> | |
| <a href="#lab"><svg viewBox="0 0 24 24" fill="none" stroke-width="1.7"><path d="m7 3 4 4-4 4M13 13h8M2 19h20M3 4h2m-2 8h2"/></svg>Scenario laboratory</a> | |
| <a href="#methods"><svg viewBox="0 0 24 24" fill="none" stroke-width="1.7"><circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-10v1"/></svg>Methods & assumptions</a> | |
| </nav> | |
| <div class="sidebar-meta"><small>Workspace health</small><strong><span class="dot"></span> Local, private engine</strong><p>No account, API key, external service, or paid compute required.</p></div> | |
| <div class="sidebar-foot">PROJECT 077 · HUGDRIGO<br>Portfolio edition · 2026</div> | |
| </aside> | |
| <div style="width:100%;min-width:0"> | |
| <nav class="mobile-nav" aria-label="Mobile navigation"><a href="#overview">Overview</a><a href="#planner">Planner</a><a href="#lab">Scenarios</a><a href="#methods">Methods</a></nav> | |
| <main class="main" id="overview"> | |
| <div class="topbar"><div class="crumb">HUGDRIGO / PORTFOLIO / <span>PROJECT 077</span></div><div class="top-actions"><span class="pill"><i></i>Offline-ready</span><button class="btn small" id="themeBtn" aria-label="Toggle light and dark appearance">☼ Theme</button></div></div> | |
| <section class="hero" aria-labelledby="heroTitle"><div class="eyebrow">Supply chain decision intelligence</div><h1 id="heroTitle">Smarter inventory.<br>Clearer decisions.</h1><p>A transparent command center for demand signals, safety stock, actionable replenishment, ABC prioritization, and stress-tested scenarios. All calculations run in your browser.</p><div class="hero-bottom"><div class="actions"><button class="btn primary" id="addBtn">+ Add inventory item</button><button class="btn" id="importBtn">⇧ Import CSV</button><button class="btn" id="exportBtn">⇩ Export plan</button></div><div class="meta"><span><b id="skuCountHero">14</b> sample SKUs</span><span>● Model v1.0</span></div></div></section> | |
| <section class="section" aria-labelledby="execTitle"><div class="section-head"><div><h2 id="execTitle">Executive overview</h2><p>Live decision metrics based on your products and current scenario.</p></div><span class="section-tag" id="scenarioLabel">BASELINE MODEL</span></div><div class="kpi-grid" id="kpis"></div></section> | |
| <section class="section cols" aria-label="Demand trend and inventory concentration"> | |
| <div class="card"><div class="card-head"><div><h3>Demand momentum</h3><p class="sub">Portfolio monthly history and forward 3-month signal</p></div><div class="legend"><span>Actual</span><span>Outlook</span></div></div><div class="chart-wrap" id="demandChart" role="img" aria-label="Monthly demand history and three-month forecast"></div></div> | |
| <div class="card"><div class="card-head"><div><h3>ABC portfolio</h3><p class="sub">Annualized demand value, using unit cost</p></div><span class="section-tag">PARETO</span></div><div class="donut-outer"><div class="donut" id="abcDonut"></div><div class="donut-list" id="abcLegend"></div></div></div> | |
| </section> | |
| <section class="section" id="planner" aria-labelledby="plannerTitle"><div class="section-head"><div><h2 id="plannerTitle">Reorder planner</h2><p>Rank replenishment by forecast demand, lead-time exposure, and inventory position.</p></div><div class="filters"><label class="sr-only" for="search">Search inventory</label><input class="field search-field" id="search" placeholder="Search SKU or product" autocomplete="off"><label class="sr-only" for="riskFilter">Filter by risk</label><select class="select" id="riskFilter"><option value="all">All statuses</option><option value="critical">Critical</option><option value="reorder">Reorder soon</option><option value="healthy">Healthy</option></select><label class="sr-only" for="sortBy">Sort products</label><select class="select" id="sortBy"><option value="priority">Priority first</option><option value="spend">Highest spend</option><option value="coverage">Lowest coverage</option><option value="name">A to Z</option></select></div></div> | |
| <div class="table-scroller"><table><thead><tr><th>Product / SKU</th><th>ABC</th><th class="right">On hand</th><th class="right">Reorder point</th><th class="right">Coverage</th><th class="right">Order units</th><th class="right">Est. spend</th><th>Signal</th><th>Inspect</th></tr></thead><tbody id="planRows"></tbody></table></div><div class="note">Status measures stock on hand against expected lead-time demand and inventory position against the reorder point. <b>Recommendations are decision support, not automatic purchase orders.</b></div> | |
| </section> | |
| <section class="section" id="lab" aria-labelledby="labTitle"><div class="section-head"><div><h2 id="labTitle">Scenario laboratory</h2><p>Test demand spikes, slower supply, service policies, and budget exposure instantly.</p></div><button class="btn small" id="resetScenarioBtn">↺ Reset scenario</button></div> | |
| <div class="lab-grid"><div class="card"><div class="card-head"><div><h3>Demand and supply levers</h3><p class="sub">Independent planning assumptions, not historical data edits</p></div></div><div class="preset-row"><button class="preset active" data-preset="baseline">Baseline</button><button class="preset" data-preset="surge">Demand surge</button><button class="preset" data-preset="delay">Supply disruption</button><button class="preset" data-preset="lean">Lean capital</button></div> | |
| <div class="control-line"><div class="control-head"><label for="demandFactor">Demand multiplier</label><strong id="demandFactorValue">1.00×</strong></div><input class="range" id="demandFactor" type="range" min="0.7" max="1.6" step="0.05" value="1"></div> | |
| <div class="control-line"><div class="control-head"><label for="leadDelay">Additional lead time</label><strong id="leadDelayValue">+0 days</strong></div><input class="range" id="leadDelay" type="range" min="-5" max="21" step="1" value="0"></div> | |
| <div class="control-line"><div class="control-head"><label for="serviceLevel">Target cycle service</label><strong id="serviceLevelValue">95%</strong></div><input class="range" id="serviceLevel" type="range" min="90" max="99.5" step="0.5" value="95"></div> | |
| <div class="control-line"><div class="control-head"><label for="horizon">Post-lead-time coverage</label><strong id="horizonValue">30 days</strong></div><input class="range" id="horizon" type="range" min="15" max="90" step="5" value="30"></div> | |
| <div class="control-head"><label for="budget">Purchase budget (USD)</label><strong>Non-binding limit</strong></div><input class="field" id="budget" type="number" min="0" max="99999999" step="1000" value="35000" style="width:100%"><p class="hint">Budget is used for comparison only. It does not silently suppress required orders.</p> | |
| </div> | |
| <div class="card"><div class="card-head"><div><h3>Scenario impact</h3><p class="sub">Changes versus unchanged assumptions and the same SKU dataset</p></div><span class="section-tag">LIVE</span></div><div class="scenario-compare"><div class="metric-tile"><span>Baseline purchase plan</span><strong id="baseCost">$0</strong><small id="baseUnits">0 units</small></div><div class="metric-tile"><span>Scenario purchase plan</span><strong id="scenarioCost">$0</strong><small id="scenarioUnits">0 units</small></div><div class="metric-tile"><span>Cost movement</span><strong id="changeCost">0%</strong><small>Against baseline</small></div><div class="metric-tile"><span>Reorder flags</span><strong id="riskDelta">0</strong><small id="riskDeltaText">Across active SKUs</small></div></div> | |
| <div class="control-head"><span>Budget utilization</span><strong id="budgetValue">0%</strong></div><div class="budget-bar" aria-label="Budget utilization"><div id="budgetFill" class="budget-fill"></div></div><div class="insight" id="scenarioInsight"><b>Planning insight</b><p>Scenario notes appear here.</p></div> | |
| <div class="help-actions"><button class="btn small" id="downloadScenarioBtn">⇩ Export scenario (JSON)</button><button class="btn small" id="downloadTemplateBtn">▤ CSV template</button></div></div></div></section> | |
| <section class="section" id="methods" aria-labelledby="methodsTitle"><div class="section-head"><div><h2 id="methodsTitle">Methodology and limits</h2><p>Traceable arithmetic with transparent, editable assumptions.</p></div><button class="btn small" id="resetAllBtn">↺ Restore sample data</button></div><div class="methods"><div class="method"><b>01 / Demand signal</b><p>The last six months receive linearly increasing weights. A capped, damped three-month trend is added. Monthly demand is normalized to 30.44 days. No external AI service or trained model is claimed.</p></div><div class="method"><b>02 / Uncertainty buffer</b><p>Safety stock uses a normal service z-score and a variance approximation combining observed monthly demand fluctuations with configurable lead-time variability. Actual demand distributions may differ.</p></div><div class="method"><b>03 / Replenishment policy</b><p>Order trigger: inventory position ≤ reorder point. Recommended quantity raises projected position toward lead-time demand plus the chosen coverage horizon and buffer, rounded to packs and MOQ.</p></div><div class="method"><b>04 / ABC prioritization</b><p>SKUs are ranked by forecast annual usage value (forecast units × 12 × unit cost). Cumulative value up to 80% is A, up to 95% B, remainder C; boundary items may push a class beyond the threshold.</p></div><div class="method"><b>05 / Data quality</b><p>Demo products are fictional and deterministic. CSV headers must match the template. Forecasting assumes at least 12 monthly observations and stable cost/currency inputs. Past 12 months are oldest to newest.</p></div><div class="method"><b>06 / Operating boundary</b><p>Everything runs client-side. Saved edits remain only in this browser's local storage. No uploads, ERP integration, real-time inventory sync, or automatic purchase execution. Reloading resets nothing unless explicitly requested.</p></div></div></section> | |
| <div class="footer"><div><b>◈ InventoryPulse</b> | A Hugdrigo portfolio project | MIT License</div><div>Standalone HTML · No dependencies · No analytics tracking · USD display</div></div> | |
| </main></div></div> | |
| <input type="file" id="csvFile" accept=".csv,text/csv" hidden> | |
| <div class="overlay" id="editOverlay" role="dialog" aria-modal="true" aria-labelledby="editTitle"><div class="modal"><div class="modal-head"><div><h2 id="editTitle">Inventory item</h2><div class="hint">Product economics, supply assumptions, and sales history</div></div><button class="close" id="closeEdit" aria-label="Close editor">×</button></div><form id="editorForm"><div class="modal-body"><div class="form-grid"> | |
| <div class="wide"><label for="fName">Product name</label><input required maxlength="80" class="field" id="fName" placeholder="e.g., Smart valve kit"></div> | |
| <div><label for="fId">SKU (unique)</label><input required maxlength="30" class="field" id="fId" placeholder="SKU-1001"></div> | |
| <div><label for="fCategory">Category</label><input required maxlength="40" class="field" id="fCategory" placeholder="e.g., Components"></div> | |
| <div><label for="fCost">Unit cost (USD)</label><input required min="0.01" step="0.01" max="1000000" class="field" type="number" id="fCost"></div> | |
| <div><label for="fPrice">Unit selling price (USD)</label><input required min="0.01" step="0.01" max="1000000" class="field" type="number" id="fPrice"></div> | |
| <div><label for="fOnHand">On-hand units</label><input required min="0" step="1" max="10000000" class="field" type="number" id="fOnHand"></div> | |
| <div><label for="fOnOrder">Units on open order</label><input required min="0" step="1" max="10000000" class="field" type="number" id="fOnOrder"></div> | |
| <div><label for="fLead">Mean lead time (days)</label><input required min="1" max="365" step="1" class="field" type="number" id="fLead"></div> | |
| <div><label for="fLeadSd">Lead-time SD (days)</label><input required min="0" max="120" step="0.1" class="field" type="number" id="fLeadSd"></div> | |
| <div><label for="fMoq">Minimum order quantity</label><input required min="1" max="10000000" step="1" class="field" type="number" id="fMoq"></div> | |
| <div><label for="fPack">Pack multiple (units)</label><input required min="1" max="10000000" step="1" class="field" type="number" id="fPack"></div> | |
| </div><hr class="modal-divider"><div style="display:flex;justify-content:space-between;align-items:center"><strong>12-month demand history</strong><span class="muted" style="font-size:11px">Oldest → newest</span></div><div id="historyInputs" class="history-grid"></div><p class="hint">All entries must be nonnegative whole-unit counts. The demo is editable; exports include your modifications.</p><p class="error" id="formError" role="alert" style="display:none"></p></div><div class="modal-foot"><button class="btn ghost" type="button" id="cancelEdit">Cancel</button><button class="btn danger" type="button" id="deleteSkuBtn" hidden>Delete SKU</button><button class="btn primary" type="submit">Save SKU</button></div></form></div></div> | |
| <div class="overlay" id="importOverlay" role="dialog" aria-modal="true" aria-labelledby="importTitle"><div class="modal"><div class="modal-head"><h2 id="importTitle">Import inventory CSV</h2><button class="close" id="closeImport" aria-label="Close import dialog">×</button></div><div class="modal-body"><p style="margin-top:0">Import will <b>merge by SKU</b>, updating matches and adding new rows. Unmentioned SKUs stay untouched. Use the template for exact column names. Review your inputs before committing changes.</p><div class="help-code">id,name,category,unitCost,sellingPrice,onHand,onOrder,leadDays,leadSdDays,moq,pack,m01,...,m12</div><p class="hint">All 12 monthly columns (m01 through m12) are mandatory. Max 500 rows per CSV. Invalid inputs leave your saved dataset unchanged.</p><div class="help-actions"><button id="templateInModal" class="btn small">⇩ Download template</button><button id="pickCsvBtn" class="btn primary">⇧ Choose CSV file</button></div><p id="importFeedback" class="hint" aria-live="polite"></p></div><div class="modal-foot"><button class="btn" id="closeImportFoot">Close</button></div></div></div> | |
| <div class="toast" id="toast" role="status" aria-live="polite"></div> | |
| <script> | |
| (()=>{'use strict'; | |
| const D=30.44,KEY='inventorypulse77-data-v1',SCENARIO_KEY='inventorypulse77-scenario-v1',THEME_KEY='inventorypulse77-theme-v1'; | |
| const $=id=>document.getElementById(id); | |
| const money=n=>new Intl.NumberFormat('en-US',{style:'currency',currency:'USD',maximumFractionDigits:0}).format(n); | |
| const num=n=>new Intl.NumberFormat('en-US',{maximumFractionDigits:0}).format(n); | |
| const esc=s=>String(s).replace(/[&<>"']/g,x=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[x])); | |
| const clamp=(x,a,b)=>Math.min(b,Math.max(a,x)); | |
| const defaultScenario=()=>({demandFactor:1,leadDelay:0,serviceLevel:95,horizon:30,budget:35000}); | |
| function demo(){const names=[ | |
| ['IP-101','Precision bearing kit','Mechanical',42,76,145,15,18,3,20,5, [118,130,125,128,135,140,152,149,158,163,171,176]], | |
| ['IP-102','Smart temperature probe','Sensors',86,139,46,8,28,5,10,2,[45,42,48,51,49,53,58,61,60,66,70,76]], | |
| ['IP-103','Hydraulic seal pack','Mechanical',19,39,272,0,14,2,25,5,[183,190,178,201,205,217,220,222,234,239,253,262]], | |
| ['IP-104','Control module X2','Electronics',218,389,25,4,36,6,5,1,[20,22,24,24,27,26,28,30,29,32,35,38]], | |
| ['IP-105','Flow sensor S7','Sensors',115,189,108,10,24,4,10,2,[58,62,57,65,60,66,71,74,76,75,78,83]], | |
| ['IP-106','Industrial connector 12-pin','Electronics',14,30,520,0,12,1.5,50,10,[275,280,292,298,308,297,324,325,336,350,359,372]], | |
| ['IP-107','Pneumatic actuator','Mechanical',178,289,72,5,31,5,4,2,[37,40,39,43,44,47,45,52,49,53,57,61]], | |
| ['IP-108','Surgical-grade filter','Consumables',7.8,18,890,0,8,1,100,25,[480,500,530,520,540,555,574,583,598,610,630,651]], | |
| ['IP-109','Robotic joint assembly','Robotics',465,740,19,2,42,7,2,1,[9,10,11,12,12,13,15,17,16,17,20,22]], | |
| ['IP-110','Optical encoder array','Sensors',74,135,64,0,25,3,5,1,[35,31,37,38,42,44,45,46,48,53,56,59]], | |
| ['IP-111','High-torque servo motor','Robotics',320,535,42,0,39,5,2,1,[18,19,20,21,24,23,25,24,26,27,28,31]], | |
| ['IP-112','Circuit protection bundle','Electronics',26,58,240,20,15,2,20,5,[133,140,145,154,150,159,169,175,183,187,192,201]], | |
| ['IP-113','Microfluidic tubing roll','Consumables',12,34,580,0,10,1,50,10,[310,322,330,345,360,377,391,397,403,415,432,455]], | |
| ['IP-114','Laser alignment bracket','Mechanical',55,116,84,8,21,2.5,10,2,[40,43,48,46,50,53,53,55,61,60,67,69]] | |
| ];return names.map(r=>({id:r[0],name:r[1],category:r[2],unitCost:r[3],sellingPrice:r[4],onHand:r[5],onOrder:r[6],leadDays:r[7],leadSdDays:r[8],moq:r[9],pack:r[10],history:r[11]}));} | |
| function loadData(){try{const x=JSON.parse(localStorage.getItem(KEY));if(Array.isArray(x)&&x.length<=500&&x.every(validSku)&&new Set(x.map(i=>i.id)).size===x.length)return x;}catch(e){}return demo();} | |
| function loadScenario(){try{const x=JSON.parse(localStorage.getItem(SCENARIO_KEY));if(x&&Object.keys(defaultScenario()).every(k=>Number.isFinite(+x[k])))return {...defaultScenario(),...Object.fromEntries(Object.keys(defaultScenario()).map(k=>[k,+x[k]]))};}catch(e){}return defaultScenario();} | |
| function validSku(s){return !!s&&typeof s.id==='string'&&s.id.length>0&&s.id.length<=30&&typeof s.name==='string'&&s.name.length>0&&s.name.length<=80&&typeof s.category==='string'&&s.category.length>0&&s.category.length<=40&&['unitCost','sellingPrice','onHand','onOrder','leadDays','leadSdDays','moq','pack'].every(k=>Number.isFinite(s[k])&&s[k]>=0&&s[k]<=10000000)&&s.unitCost>0&&s.sellingPrice>0&&s.leadDays>=1&&s.leadDays<=365&&s.leadSdDays<=120&&s.moq>=1&&s.pack>=1&&Number.isInteger(s.onHand)&&Number.isInteger(s.onOrder)&&Number.isInteger(s.moq)&&Number.isInteger(s.pack)&&Array.isArray(s.history)&&s.history.length===12&&s.history.every(v=>Number.isInteger(v)&&v>=0&&v<=10000000);} | |
| let skus=loadData(),scenario=loadScenario(),editing=null,toastTimer=null; | |
| function save(){try{localStorage.setItem(KEY,JSON.stringify(skus));return true;}catch(e){toast('Browser storage unavailable; export your work to retain it.');return false;}} | |
| function saveScenario(){try{localStorage.setItem(SCENARIO_KEY,JSON.stringify(scenario));}catch(e){}} | |
| function toast(msg){const el=$('toast');el.textContent=msg;el.classList.add('on');clearTimeout(toastTimer);toastTimer=setTimeout(()=>el.classList.remove('on'),3500);} | |
| // A transparent, intentionally small data model; no statistical inference or trained AI is claimed. | |
| function forecast(history){const last6=history.slice(-6),weights=[1,2,3,4,5,6];const wma=last6.reduce((sum,v,i)=>sum+v*weights[i],0)/21;const avg3=history.slice(-3).reduce((a,b)=>a+b,0)/3;const old3=history.slice(-6,-3).reduce((a,b)=>a+b,0)/3;const tr=clamp((avg3-old3)*.35,-wma*.35,wma*.35);const avg6=last6.reduce((a,b)=>a+b,0)/6;const variance=last6.reduce((s,x)=>s+(x-avg6)**2,0)/(last6.length-1);return {monthly:Math.max(0,wma+tr),stdMonth:Math.sqrt(Math.max(variance,0)),wma,trend:tr};} | |
| function zScore(p){ // Acklam inverse normal CDF, finite for 0<p<1 | |
| if(!(p>0&&p<1))throw new Error('Invalid service probability'); | |
| const a=[-39.6968302866538,220.946098424521,-275.928510446969,138.357751867269,-30.6647980661472,2.50662827745924]; | |
| const b=[-54.4760987982241,161.585836858041,-155.698979859887,66.8013118877197,-13.2806815528857]; | |
| const c=[-.00778489400243029,-.322396458041136,-2.40075827716184,-2.54973253934373,4.37466414146497,2.93816398269878]; | |
| const d=[.00778469570904146,.32246712907004,2.445134137143,3.75440866190742]; | |
| const plow=.02425,phigh=1-plow;let q,r; | |
| if(p<plow){q=Math.sqrt(-2*Math.log(p));const top=c.reduce((v,x)=>v*q+x,0),bottom=d.reduce((v,x)=>v*q+x,0)*q+1;return top/bottom;} | |
| if(p>phigh){q=Math.sqrt(-2*Math.log(1-p));const top=c.reduce((v,x)=>v*q+x,0),bottom=d.reduce((v,x)=>v*q+x,0)*q+1;return -top/bottom;} | |
| q=p-.5;r=q*q;const top=a.reduce((v,x)=>v*r+x,0)*q,bottom=b.reduce((v,x)=>v*r+x,0)*r+1;return top/bottom; | |
| } | |
| function calculate(s,spec=scenario){const f=forecast(s.history),monthly=f.monthly*spec.demandFactor,daily=monthly/D;const lead=Math.max(1,s.leadDays+spec.leadDelay);const sigmaDaily=f.stdMonth/Math.sqrt(D)*spec.demandFactor;const z=zScore(spec.serviceLevel/100);const safety=Math.ceil(z*Math.sqrt(lead*sigmaDaily*sigmaDaily+daily*daily*s.leadSdDays*s.leadSdDays));const leadDemand=daily*lead;const rop=Math.ceil(leadDemand+safety);const position=s.onHand+s.onOrder;const flagged=position<=rop;const target=Math.ceil(leadDemand+daily*spec.horizon+safety);let qty=0;if(flagged){const raw=Math.max(1,target-position,s.moq);qty=Math.ceil(raw/s.pack)*s.pack;}const coverage=daily>0?s.onHand/daily:Infinity;const status=(daily>0&&s.onHand<leadDemand)?'critical':flagged?'reorder':'healthy';return {...s,monthly,daily,lead,safety,leadDemand,rop,position,flagged,target,qty,coverage,status,spend:qty*s.unitCost,annualValue:monthly*12*s.unitCost,trend:f.trend};} | |
| function abcClassify(rows){const sorted=[...rows].sort((a,b)=>b.annualValue-a.annualValue),total=sorted.reduce((s,r)=>s+r.annualValue,0);let cum=0;const map={};for(const r of sorted){const before=total>0?cum/total:1;map[r.id]=before<.8?'A':before<.95?'B':'C';cum+=r.annualValue;}return map;} | |
| function derive(spec=scenario){const rows=skus.map(s=>calculate(s,spec));const abc=abcClassify(rows);for(const r of rows)r.abc=abc[r.id];return {rows,spend:rows.reduce((s,r)=>s+r.spend,0),units:rows.reduce((s,r)=>s+r.qty,0),inventory:rows.reduce((s,r)=>s+r.onHand*r.unitCost,0),flagged:rows.filter(r=>r.flagged).length,critical:rows.filter(r=>r.status==='critical').length,totalMonthly:rows.reduce((s,r)=>s+r.monthly,0)};} | |
| const baseline=()=>derive(defaultScenario()); | |
| function renderKpis(ds){const markup=[['Inventory capital',money(ds.inventory),'Current on-hand × unit cost',''],['Purchase plan',money(ds.spend),num(ds.units)+' replenishment units',''],['Reorder alerts',num(ds.flagged)+' <small>/ '+num(ds.rows.length)+'</small>',num(ds.critical)+' critical lead-time exposures',ds.critical?'alert':''],['Forecast demand',num(ds.totalMonthly),'Estimated units per month','']];$('kpis').innerHTML=markup.map(([l,v,s,d])=>`<article class="kpi"><div class="kpi-label">${l}</div><div class="kpi-value">${v}</div><div class="kpi-bottom"><i class="dot ${d}"></i>${s}</div></article>`).join('');$('skuCountHero').textContent=skus.length;} | |
| function svgDemand(ds){const w=730,h=225,pl=47,pr=18,pt=18,pb=35;const historical=Array.from({length:12},(_,i)=>skus.reduce((s,r)=>s+r.history[i],0));const forecasts=[1,2,3].map((m)=>ds.totalMonthly*(1+Math.min(.045,m*.012)));const values=[...historical,...forecasts];let max=Math.max(...values,1)*1.15;const x=i=>pl+(w-pl-pr)*i/14,y=n=>pt+(h-pt-pb)*(1-n/max);let lines='';for(let k=0;k<=4;k++){const v=max*k/4,yy=y(v);lines+=`<line x1="${pl}" y1="${yy}" x2="${w-pr}" y2="${yy}" stroke="#35445d" stroke-dasharray="3 5"/><text class="chart-label" x="${pl-8}" y="${yy+4}" text-anchor="end">${num(v)}</text>`;} | |
| const path=(vals,start)=>vals.map((v,i)=>`${i?'L':'M'}${x(start+i).toFixed(1)},${y(v).toFixed(1)}`).join(' '); | |
| const act=path(historical,0),fc=path([historical[11],...forecasts],11);const fill=`${act} L ${x(11)},${h-pb} L${x(0)},${h-pb} Z`; | |
| const labels=[['M01',0],['M03',2],['M05',4],['M07',6],['M09',8],['M11',10],['+1',12],['+3',14]]; | |
| $('demandChart').innerHTML=`<svg class="chart" viewBox="0 0 ${w} ${h}" preserveAspectRatio="none" aria-hidden="true"><defs><linearGradient id="areaFill" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#54dec6" stop-opacity=".28"/><stop offset="1" stop-color="#54dec6" stop-opacity="0"/></linearGradient></defs>${lines}<path d="${fill}" fill="url(#areaFill)"/><line x1="${x(11.5)}" x2="${x(11.5)}" y1="${pt}" y2="${h-pb}" stroke="#7889a4" stroke-dasharray="5 5" opacity=".7"/><path d="${act}" fill="none" stroke="#54dec6" stroke-width="3.1" stroke-linejoin="round" stroke-linecap="round"/><path d="${fc}" fill="none" stroke="#91abff" stroke-width="2.6" stroke-dasharray="7 5" stroke-linecap="round"/>${historical.map((v,i)=>`<circle r="2.5" cx="${x(i)}" cy="${y(v)}" fill="#54dec6"/>`).join('')}${labels.map(([l,i])=>`<text class="chart-label" x="${x(i)}" y="${h-9}" text-anchor="middle">${l}</text>`).join('')}</svg>`; | |
| $('demandChart').setAttribute('aria-label',`Demand: ${num(historical[11])} units in the last month, ${num(ds.totalMonthly)} projected units per month; 3-month outlook is illustrative.`); | |
| } | |
| function renderABC(ds){const v={A:0,B:0,C:0},cnt={A:0,B:0,C:0};ds.rows.forEach(r=>{v[r.abc]+=r.annualValue;cnt[r.abc]++;});const total=v.A+v.B+v.C;const colors=['#54dec6','#91abff','#ffd18a'];const circ=2*Math.PI*62;let off=0;const segments=['A','B','C'].map((k,i)=>{const pct=total>0?v[k]/total:0;const out=`<circle r="62" cx="80" cy="80" fill="none" stroke="${colors[i]}" stroke-width="16" stroke-dasharray="${pct*circ} ${circ}" stroke-dashoffset="${-off*circ}"/>`;off+=pct;return out;}).join('');$('abcDonut').innerHTML=`<svg viewBox="0 0 160 160" aria-label="Annual usage value by ABC class" role="img"><circle r="62" cx="80" cy="80" fill="none" stroke="#33435c" stroke-width="16"/>${segments}</svg><div class="donut-center"><strong>${ds.rows.length}</strong><span>total SKUs</span></div>`;$('abcLegend').innerHTML=['A','B','C'].map((k,i)=>`<div class="donut-row"><i class="line-dot" style="background:${colors[i]}"></i><span>Class ${k} · ${cnt[k]} SKUs</span><b>${total?Math.round(v[k]/total*100):0}% value</b></div>`).join('');} | |
| function renderTable(ds){let rows=ds.rows;const search=$('search').value.trim().toLowerCase(),risk=$('riskFilter').value,sort=$('sortBy').value;rows=rows.filter(r=>(!search||`${r.id} ${r.name} ${r.category}`.toLowerCase().includes(search))&&(risk==='all'||r.status===risk));rows.sort((a,b)=>{if(sort==='spend')return b.spend-a.spend;if(sort==='coverage')return a.coverage-b.coverage;if(sort==='name')return a.name.localeCompare(b.name);const rank={critical:0,reorder:1,healthy:2};return rank[a.status]-rank[b.status]||b.spend-a.spend;});$('planRows').innerHTML=rows.length?rows.map(r=>`<tr><td><strong>${esc(r.name)}</strong><span class="sku-id">${esc(r.id)} · ${esc(r.category)}</span></td><td><span class="abc ${r.abc}">${r.abc}</span></td><td class="right">${num(r.onHand)}</td><td class="right">${num(r.rop)}</td><td class="right">${Number.isFinite(r.coverage)?r.coverage.toFixed(1)+'d':'∞'}</td><td class="right"><strong>${num(r.qty)}</strong></td><td class="right">${money(r.spend)}</td><td><span class="status ${r.status}">${r.status==='critical'?'Critical':r.status==='reorder'?'Reorder soon':'Healthy'}</span></td><td><button class="btn small" data-edit="${esc(r.id)}" aria-label="Edit ${esc(r.name)}">Edit</button></td></tr>`).join(''):`<tr><td colspan="9" class="empty">No products match these filters.</td></tr>`;} | |
| function renderScenario(ds){const base=baseline();$('baseCost').textContent=money(base.spend);$('scenarioCost').textContent=money(ds.spend);$('baseUnits').textContent=num(base.units)+' units';$('scenarioUnits').textContent=num(ds.units)+' units';const delta=base.spend>0?(ds.spend/base.spend-1)*100:(ds.spend>0?100:0);$('changeCost').textContent=(delta>=0?'+':'')+delta.toFixed(1)+'%';$('changeCost').className=delta>0?'low':delta<0?'up':'';$('riskDelta').textContent=ds.flagged;$('riskDeltaText').textContent=(ds.flagged-base.flagged>=0?'+':'')+(ds.flagged-base.flagged)+' vs baseline';const budget=Math.max(0,scenario.budget);const pct=budget>0?ds.spend/budget*100:(ds.spend>0?Infinity:0);$('budgetValue').textContent=Number.isFinite(pct)?pct.toFixed(0)+'%':'No budget';$('budgetFill').style.width=Math.min(100,Number.isFinite(pct)?pct:100)+'%';$('budgetFill').classList.toggle('over',pct>100);const diff=ds.spend-budget;const advice=budget===0?'Set a nonzero purchase budget to compare capital exposure.':diff>0?`The proposed orders exceed budget by <b>${money(diff)}</b>. Prioritize critical and A-class SKUs before changing purchase orders.`:`The proposal leaves <b>${money(-diff)}</b> of the budget unallocated. Review lead-time exposure before spending the remainder.`;$('scenarioInsight').innerHTML=`<b>Planning insight</b><p>${advice} ${ds.critical?`<b>${ds.critical}</b> SKU(s) may run short before mean replenishment time.`:'There are no immediate lead-time shortages under these assumptions.'}</p>`;$('scenarioLabel').textContent=isBaseline()?'BASELINE MODEL':'CUSTOM SCENARIO';} | |
| function isBaseline(){return scenario.demandFactor===1&&scenario.leadDelay===0&&scenario.serviceLevel===95&&scenario.horizon===30;} | |
| function syncControls(){for(const k of ['demandFactor','leadDelay','serviceLevel','horizon','budget'])$(k).value=scenario[k];$('demandFactorValue').textContent=Number(scenario.demandFactor).toFixed(2)+'×';$('leadDelayValue').textContent=(scenario.leadDelay>=0?'+':'')+scenario.leadDelay+' days';$('serviceLevelValue').textContent=scenario.serviceLevel+'%';$('horizonValue').textContent=scenario.horizon+' days';for(const b of document.querySelectorAll('[data-preset]')){const p=presets[b.dataset.preset];b.classList.toggle('active',p&&['demandFactor','leadDelay','serviceLevel','horizon'].every(k=>p[k]===scenario[k]));}} | |
| const presets={baseline:{demandFactor:1,leadDelay:0,serviceLevel:95,horizon:30},surge:{demandFactor:1.35,leadDelay:3,serviceLevel:97,horizon:45},delay:{demandFactor:1,leadDelay:14,serviceLevel:98,horizon:40},lean:{demandFactor:.9,leadDelay:0,serviceLevel:90,horizon:15}}; | |
| function render(){syncControls();const ds=derive();renderKpis(ds);svgDemand(ds);renderABC(ds);renderTable(ds);renderScenario(ds);} | |
| function overlay(id,open){$(id).classList.toggle('open',open);document.body.style.overflow=document.querySelector('.overlay.open')?'hidden':'';if(open){const focusable=$(id).querySelector('input:not([type=hidden]),button');if(focusable)focusable.focus();}} | |
| function openEditor(id){editing=id||null;const item=id?skus.find(x=>x.id===id):{id:'',name:'',category:'',unitCost:25,sellingPrice:49,onHand:0,onOrder:0,leadDays:14,leadSdDays:2,moq:1,pack:1,history:Array(12).fill(20)};if(!item)return;const map={fId:'id',fName:'name',fCategory:'category',fCost:'unitCost',fPrice:'sellingPrice',fOnHand:'onHand',fOnOrder:'onOrder',fLead:'leadDays',fLeadSd:'leadSdDays',fMoq:'moq',fPack:'pack'};Object.entries(map).forEach(([id,k])=>$(id).value=item[k]);$('fId').readOnly=!!id;$('historyInputs').innerHTML=item.history.map((v,i)=>`<div><label for="mh${i}">M${String(i+1).padStart(2,'0')}</label><input class="field" type="number" id="mh${i}" min="0" max="10000000" step="1" required value="${v}"></div>`).join('');$('editTitle').textContent=id?'Edit inventory item':'Add inventory item';$('deleteSkuBtn').hidden=!id;$('formError').style.display='none';overlay('editOverlay',true);} | |
| function saveEditor(e){e.preventDefault();const val=k=>Number($(k).value),item={id:$('fId').value.trim(),name:$('fName').value.trim(),category:$('fCategory').value.trim(),unitCost:val('fCost'),sellingPrice:val('fPrice'),onHand:val('fOnHand'),onOrder:val('fOnOrder'),leadDays:val('fLead'),leadSdDays:val('fLeadSd'),moq:val('fMoq'),pack:val('fPack'),history:Array.from({length:12},(_,i)=>Number($('mh'+i).value))};const err=$('formError');if(!validSku(item)){err.textContent='Check all fields. Quantities and history must be whole numbers, and all values must be in the permitted range.';err.style.display='block';return;}if(!editing&&skus.some(s=>s.id===item.id)){err.textContent='This SKU already exists. Choose a unique SKU code.';err.style.display='block';return;}if(!editing&&skus.length>=500){err.textContent='The workspace supports up to 500 SKUs.';err.style.display='block';return;}if(editing){skus=skus.map(s=>s.id===editing?item:s);}else skus.push(item);save();overlay('editOverlay',false);render();toast('Inventory item saved locally.');} | |
| function download(name,content,mime='text/plain;charset=utf-8'){const url=URL.createObjectURL(new Blob([content],{type:mime}));const a=document.createElement('a');a.href=url;a.download=name;document.body.appendChild(a);a.click();a.remove();setTimeout(()=>URL.revokeObjectURL(url),1000);} | |
| const cols=['id','name','category','unitCost','sellingPrice','onHand','onOrder','leadDays','leadSdDays','moq','pack',...Array.from({length:12},(_,i)=>'m'+String(i+1).padStart(2,'0'))]; | |
| const csvCell=s=>{const t=String(s);return /[",\r\n]/.test(t)?'"'+t.replace(/"/g,'""')+'"':t;}; | |
| function safeCsvCell(s){const v=String(s);return csvCell(/^[\s]*[=+\-@]/.test(v)?"'"+v:v);} // Prevent spreadsheet formula execution in exports. | |
| function toCSV(data){return [cols.join(','),...data.map(s=>[s.id,s.name,s.category,s.unitCost,s.sellingPrice,s.onHand,s.onOrder,s.leadDays,s.leadSdDays,s.moq,s.pack,...s.history].map(csvCell).join(','))].join('\r\n');} | |
| function exportPlan(){const ds=derive();const headers=['sku','name','category','abc','status','monthlyForecast','leadTimeDays','safetyStock','reorderPoint','onHand','onOrder','targetStock','recommendedOrderUnits','unitCostUSD','estimatedSpendUSD'];const rows=ds.rows.map(r=>[r.id,r.name,r.category,r.abc,r.status,r.monthly.toFixed(2),r.lead,r.safety,r.rop,r.onHand,r.onOrder,r.target,r.qty,r.unitCost,r.spend.toFixed(2)]);download('InventoryPulse_Reorder_Plan.csv',[headers.join(','),...rows.map(r=>r.map(safeCsvCell).join(','))].join('\r\n'),'text/csv;charset=utf-8');toast('Replenishment plan exported as CSV.');} | |
| function exportScenario(){const obj={app:'InventoryPulse',version:'1.0',project:77,generatedAt:new Date().toISOString(),currency:'USD',scenario:{...scenario},summary:{...((({inventory,spend,units,flagged,critical,totalMonthly})=>({inventory,spend,units,flagged,critical,totalMonthly}))(derive()))},products:skus,notes:'Browser-local snapshot: no automatic purchasing or real-time integration.'};download('InventoryPulse_Scenario_Snapshot.json',JSON.stringify(obj,null,2),'application/json;charset=utf-8');toast('Scenario and product data exported as JSON.');} | |
| function parseCsv(text){const rows=[];let row=[],cell='',quote=false;const t=text.replace(/^\uFEFF/,'');for(let i=0;i<t.length;i++){const c=t[i];if(quote){if(c==='"'&&t[i+1]==='"'){cell+='"';i++;}else if(c==='"')quote=false;else cell+=c;}else if(c==='"'){if(cell.length)throw Error('Unexpected quote in CSV.');quote=true;}else if(c===','){row.push(cell);cell='';}else if(c==='\n'){row.push(cell.replace(/\r$/,''));if(row.some(s=>s.trim()!==''))rows.push(row);row=[];cell='';}else cell+=c;}if(quote)throw Error('Unclosed quoted field.');row.push(cell.replace(/\r$/,''));if(row.some(s=>s.trim()!==''))rows.push(row);return rows;} | |
| function importCsv(text){const parsed=parseCsv(text);if(parsed.length<2)throw Error('CSV must include headers and at least one product.');const headers=parsed[0].map(x=>x.trim()),indexes=cols.map(k=>headers.indexOf(k));if(indexes.some(x=>x<0))throw Error('Missing required columns. Download the template for exact headers.');if(parsed.length-1>500)throw Error('Maximum 500 data rows per import.');const incoming=[],ids=new Set();for(const [idx,row] of parsed.slice(1).entries()){const get=k=>row[indexes[cols.indexOf(k)]]??'';const int=k=>Number(get(k));const s={id:get('id').trim(),name:get('name').trim(),category:get('category').trim(),unitCost:int('unitCost'),sellingPrice:int('sellingPrice'),onHand:int('onHand'),onOrder:int('onOrder'),leadDays:int('leadDays'),leadSdDays:int('leadSdDays'),moq:int('moq'),pack:int('pack'),history:cols.slice(11).map(int)};if(!validSku(s)||cols.some(k=>get(k)===''))throw Error(`Invalid or missing data in CSV row ${idx+2}.`);if(ids.has(s.id))throw Error(`Repeated SKU ${s.id} in CSV.`);ids.add(s.id);incoming.push(s);}const result=new Map(skus.map(s=>[s.id,s]));for(const s of incoming)result.set(s.id,s);if(result.size>500)throw Error('Combined dataset would exceed 500 SKUs.');skus=[...result.values()];save();render();return incoming.length;} | |
| function downloadTemplate(){download('InventoryPulse_Import_Template.csv',toCSV(demo().slice(0,3)),'text/csv;charset=utf-8');toast('CSV import template exported.');} | |
| function hideModals(){overlay('editOverlay',false);overlay('importOverlay',false);} | |
| $('addBtn').addEventListener('click',()=>openEditor(null));$('importBtn').addEventListener('click',()=>{ $('importFeedback').textContent='';overlay('importOverlay',true);});$('exportBtn').addEventListener('click',exportPlan);$('downloadScenarioBtn').addEventListener('click',exportScenario);$('downloadTemplateBtn').addEventListener('click',downloadTemplate);$('templateInModal').addEventListener('click',downloadTemplate);$('pickCsvBtn').addEventListener('click',()=>$('csvFile').click());$('csvFile').addEventListener('change',async e=>{const f=e.target.files[0];e.target.value='';if(!f)return;try{if(f.size>1500000)throw Error('File is too large: maximum 1.5 MB.');const n=importCsv(await f.text());$('importFeedback').textContent=`Imported ${n} SKU rows successfully. Dataset merged and saved locally.`;toast(`Imported ${n} rows.`);}catch(err){$('importFeedback').textContent=err.message;$('importFeedback').classList.add('error');}}); | |
| $('editorForm').addEventListener('submit',saveEditor);$('closeEdit').addEventListener('click',hideModals);$('cancelEdit').addEventListener('click',hideModals);$('closeImport').addEventListener('click',hideModals);$('closeImportFoot').addEventListener('click',hideModals);$('deleteSkuBtn').addEventListener('click',()=>{if(!editing||!confirm(`Delete local SKU ${editing}? This does not affect any Hugging Face repository.`))return;skus=skus.filter(s=>s.id!==editing);save();hideModals();render();toast('SKU removed from this local dataset.');}); | |
| for(const k of ['search','riskFilter','sortBy'])$(k).addEventListener(k==='search'?'input':'change',()=>renderTable(derive())); | |
| for(const k of ['demandFactor','leadDelay','serviceLevel','horizon','budget'])$(k).addEventListener('input',e=>{const n=Number(e.target.value);if(!Number.isFinite(n))return;scenario[k]=k==='budget'?clamp(n,0,99999999):n;saveScenario();render();}); | |
| for(const b of document.querySelectorAll('[data-preset]'))b.addEventListener('click',()=>{scenario={...scenario,...presets[b.dataset.preset]};saveScenario();render();toast('Scenario preset applied.');}); | |
| $('resetScenarioBtn').addEventListener('click',()=>{scenario=defaultScenario();saveScenario();render();toast('Scenario reset to baseline.');}); | |
| $('resetAllBtn').addEventListener('click',()=>{if(!confirm('Restore original demo inventory and scenario? Your current browser-local edits will be replaced. Export a snapshot first if you want a backup.'))return;skus=demo();scenario=defaultScenario();save();saveScenario();render();toast('Sample inventory restored.');}); | |
| $('themeBtn').addEventListener('click',()=>{document.body.classList.toggle('light');try{localStorage.setItem(THEME_KEY,document.body.classList.contains('light')?'light':'dark');}catch(e){}}); | |
| $('planRows').addEventListener('click',e=>{const b=e.target.closest('[data-edit]');if(b)openEditor(b.dataset.edit);}); | |
| for(const id of ['editOverlay','importOverlay'])$(id).addEventListener('click',e=>{if(e.target===$(id))hideModals();});document.addEventListener('keydown',e=>{if(e.key==='Escape')hideModals();}); | |
| for(const nav of document.querySelectorAll('.nav a'))nav.addEventListener('click',()=>{document.querySelectorAll('.nav a').forEach(x=>x.classList.remove('active'));nav.classList.add('active');}); | |
| try{if(localStorage.getItem(THEME_KEY)==='light')document.body.classList.add('light');}catch(e){} | |
| window.InventoryPulseTest=Object.freeze({forecast,zScore,calculate,abcClassify,validSku,parseCsv,toCSV,importCsv,derive,demo,setDataForTest:rows=>{skus=rows;render();},getData:()=>JSON.parse(JSON.stringify(skus)),getScenario:()=>({...scenario})}); | |
| render(); | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |