body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
color: #333;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
h1 {
text-align: center;
color: white;
margin-bottom: 30px;
font-size: 2.5rem;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.section {
background: rgba(255, 255, 255, 0.95);
margin-bottom: 20px;
padding: 25px;
border-radius: 15px;
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.section h2, .section h3 {
color: #333;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #667eea;
}
.form-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-direction: column;
}
label {
font-weight: 600;
margin-bottom: 5px;
color: #555;
}
input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select,
button {
padding: 12px 15px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 14px;
transition: all 0.3s ease;
background: white;
}
input:focus, select:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
cursor: pointer;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
transition: all 0.3s ease;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.hidden {
display: none;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin: 20px 0;
}
.stat-card {
background: linear-gradient(135deg, #4CAF50, #45a049);
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.stat-card.profit {
background: linear-gradient(135deg, #2196F3, #1976D2);
}
.stat-card.revenue {
background: linear-gradient(135deg, #FF9800, #F57C00);
}
.stat-card h4 {
font-size: 0.9rem;
opacity: 0.9;
margin-bottom: 5px;
}
.stat-card .value {
font-size: 1.5rem;
font-weight: bold;
}
canvas {
max-width: 100%;
height: 400px !important;
border-radius: 10px;
background: white;
}
ul {
list-style-type: none;
padding: 0;
}
li {
background: #f8f9fa;
margin: 8px 0;
padding: 15px;
border-radius: 8px;
border-left: 4px solid #667eea;
display: flex;
justify-content: space-between;
align-items: center;
transition: all 0.3s ease;
}
li:hover {
transform: translateX(5px);
background: #e9ecef;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
li .item-info {
flex-grow: 1;
}
li .item-info strong {
display: block;
color: #333;
margin-bottom: 5px;
}
li .item-info small {
color: #666;
}
.delete-btn {
background: linear-gradient(135deg, #ff4757, #ff3742) !important;
padding: 8px 12px !important;
font-size: 12px !important;
margin: 0 !important;
opacity: 0.7;
transition: all 0.3s ease;
}
.delete-btn:hover {
opacity: 1;
transform: scale(1.05);
}
.alert {
padding: 15px;
margin: 15px 0;
border-radius: 8px;
font-weight: 500;
}
.alert-success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.alert-error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.alert-warning {
background: #fff3cd;
color: #856404;
border: 1px solid #ffeaa7;
}
.low-stock-item {
border-left-color: #ff9800 !important;
background: linear-gradient(90deg, #fff3e0, #f8f9fa) !important;
}
.chart-controls {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.loading {
text-align: center;
color: #666;
font-style: italic;
}
@media (max-width: 768px) {
.form-grid {
grid-template-columns: 1fr;
}
.stats-grid {
grid-template-columns: 1fr;
}
h1 {
font-size: 2rem;
}
.section {
padding: 15px;
}
}
<!-- Admin Login -->
<div class="section">
<h2>π Admin Access</h2>
<div class="form-grid">
<div class="form-group">
<label for="adminPassword">Admin Password:</label>
<input type="password" id="adminPassword" placeholder="Enter password">
</div>
<div class="form-group">
<button onclick="checkAdminPassword()">Login</button>
</div>
</div>
<div id="loginAlert"></div>
</div>
<!-- Stock Management (Admin Only) -->
<div id="adminSection" class="hidden section">
<h3>π¦ Stock Management</h3>
<div class="form-grid">
<div class="form-group">
<label for="stockItem">Item Name:</label>
<input type="text" id="stockItem" placeholder="Enter item name">
</div>
<div class="form-group">
<label for="stockCost">Cost Price (KES):</label>
<input type="number" step="0.01" id="stockCost" placeholder="0.00">
</div>
<div class="form-group">
<label for="stockQuantity">Initial Quantity:</label>
<input type="number" step="1" id="stockQuantity" placeholder="0" value="1">
</div>
<div class="form-group">
<label for="stockSellingPrice">Suggested Selling Price (KES):</label>
<input type="number" step="0.01" id="stockSellingPrice" placeholder="0.00">
</div>
</div>
<button onclick="addStock()">Add to Stock</button>
<div id="stockAlert"></div>
<h4>π Current Stock</h4>
<ul id="stockList"></ul>
</div>
<!-- Sales Entry -->
<div class="section">
<h3>π° Sales Entry</h3>
<div class="form-grid">
<div class="form-group">
<label for="saleItemDropdown">Select Item:</label>
<select id="saleItemDropdown">
<option value="" disabled selected>Choose an item</option>
</select>
</div>
<div class="form-group">
<label for="saleQuantity">Quantity:</label>
<input type="number" step="0.01" id="saleQuantity" placeholder="1" min="0.01">
</div>
<div class="form-group">
<label for="salePrice">Selling Price per item (KES):</label>
<input type="number" step="0.01" id="salePrice" placeholder="0.00">
</div>
<div class="form-group">
<label for="saleDate">Sale Date:</label>
<input type="date" id="saleDate">
</div>
</div>
<button onclick="addSale()">Record Sale</button>
<div id="saleAlert"></div>
</div>
<!-- Business Analytics -->
<div class="section">
<h3>π Business Analytics</h3>
<div class="stats-grid">
<div class="stat-card">
<h4>Today's Sales</h4>
<div class="value" id="dailyTotal">KES 0.00</div>
</div>
<div class="stat-card profit">
<h4>Today's Profit</h4>
<div class="value" id="dailyProfit">KES 0.00</div>
</div>
<div class="stat-card revenue">
<h4>Total Revenue</h4>
<div class="value" id="totalRevenue">KES 0.00</div>
</div>
<div class="stat-card">
<h4>Total Profit</h4>
<div class="value" id="totalProfit">KES 0.00</div>
</div>
</div>
<div id="lowStockAlert"></div>
</div>
<!-- Sales Records -->
<div class="section">
<h3>π Sales Records</h3>
<div class="chart-controls">
<button onclick="showAllSales()">Show All Sales</button>
<button onclick="showTodaySales()">Today's Sales Only</button>
<button onclick="exportSales()">Export Sales Data</button>
</div>
<ul id="salesList"></ul>
</div>
<!-- Sales Chart -->
<div class="section">
<h3>π Sales Analytics Chart</h3>
<div class="chart-controls">
<button onclick="updateChart('daily')">Daily Sales</button>
<button onclick="updateChart('items')">By Items</button>
<button onclick="updateChart('profit')">Profit Analysis</button>
</div>
<canvas id="salesChart"></canvas>
</div>
${message}
`;
setTimeout(() => {
element.innerHTML = '';
}, 3000);
}
function checkAdminPassword() {
const pwd = document.getElementById('adminPassword').value;
if (pwd === 'Cliff') {
document.getElementById('adminSection').classList.remove('hidden');
showAlert('loginAlert', 'β
Admin access granted successfully!');
document.getElementById('adminPassword').value = '';
} else {
showAlert('loginAlert', 'β Invalid password. Please try again.', 'error');
}
}
function addStock() {
const item = document.getElementById('stockItem').value.trim();
const cost = parseFloat(document.getElementById('stockCost').value);
const quantity = parseInt(document.getElementById('stockQuantity').value) || 1;
const sellingPrice = parseFloat(document.getElementById('stockSellingPrice').value) || 0;
if (!item || isNaN(cost) || cost <= 0) {
showAlert('stockAlert', 'β Please provide valid item name and cost price.', 'error');
return;
}
const existingStock = stock.find(s => s.item.toLowerCase() === item.toLowerCase());
if (existingStock) {
existingStock.quantity += quantity;
existingStock.cost = cost; // Update cost
if (sellingPrice > 0) existingStock.sellingPrice = sellingPrice;
showAlert('stockAlert', `β
Updated ${item} - Added ${quantity} units`);
} else {
stock.push({ item, cost, quantity, sellingPrice });
showAlert('stockAlert', `β
Added new item: ${item}`);
}
// Clear form
document.getElementById('stockItem').value = '';
document.getElementById('stockCost').value = '';
document.getElementById('stockQuantity').value = '1';
document.getElementById('stockSellingPrice').value = '';
updateAll();
}
function updateStockList() {
const ul = document.getElementById('stockList');
if (stock.length === 0) {
ul.innerHTML = 'π¨ OUT OF STOCK: ${outOfStockItems.map(s => s.item).join(', ')}
`;
}
if (lowStockItems.length > 0) {
alertHtml += `