:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--card-bg); border-right: 1px solid var(--border); padding: 20px 0; position: fixed; height: 100vh; overflow-y: auto; }
.sidebar-header { padding: 0 20px 20px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { color: var(--primary); font-size: 1.25rem; }
.sidebar-nav { display: flex; flex-direction: column; padding: 10px 0; }
.nav-item { padding: 12px 20px; color: var(--text); text-decoration: none; transition: 0.2s; border-left: 3px solid transparent; }
.nav-item:hover, .nav-item.active { background: #f9fafb; color: var(--primary); border-left-color: var(--primary); }
.nav-item.logout { margin-top: auto; color: var(--danger); }
.main-content { flex: 1; margin-left: 250px; padding: 20px; }

/* Components */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card h3 { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 1.5rem; font-weight: bold; color: var(--primary); }

/* Forms & Buttons */
.btn { padding: 8px 16px; border: none; border-radius: var(--radius); cursor: pointer; font-weight: 500; transition: 0.2s; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; text-align: center; }
.btn-lg { padding: 12px; font-size: 1.1rem; }
.btn-sm { padding: 4px 8px; font-size: 0.8rem; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9rem; }
.form-control, input[type="text"], input[type="number"], input[type="password"], select, textarea {
    width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; transition: 0.2s;
}
.form-control:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f9fafb; font-weight: 600; }
.table-actions { margin-bottom: 15px; }

/* Modals */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal.active { display: flex; }
.modal-content { background: white; padding: 20px; border-radius: var(--radius); width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; animation: slideDown 0.3s ease; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close { cursor: pointer; font-size: 1.5rem; color: var(--text-muted); }

/* POS Screen */
.pos-layout { display: grid; grid-template-columns: 1fr 400px; gap: 20px; height: calc(100vh - 40px); }
.pos-left { display: flex; flex-direction: column; background: var(--card-bg); border-radius: var(--radius); padding: 15px; overflow: hidden; }
.pos-search { margin-bottom: 15px; }
.pos-categories { display: flex; gap: 10px; margin-bottom: 15px; overflow-x: auto; padding-bottom: 5px; }
.cat-btn { padding: 8px 16px; border: 1px solid var(--border); background: white; border-radius: 20px; cursor: pointer; white-space: nowrap; }
.cat-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; overflow-y: auto; flex: 1; }
.pos-product-card { background: #f9fafb; border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; cursor: pointer; transition: 0.2s; text-align: center; }
.pos-product-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.pos-product-name { font-weight: 600; margin-bottom: 5px; font-size: 0.9rem; }
.pos-product-price { color: var(--primary); font-weight: bold; }
.pos-product-stock { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }

.pos-right { background: var(--card-bg); border-radius: var(--radius); display: flex; flex-direction: column; }
.cart-header { padding: 15px; border-bottom: 1px solid var(--border); }
.cart-items { flex: 1; overflow-y: auto; padding: 15px; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cart-item-info { flex: 1; }
.cart-item-qty { display: flex; align-items: center; gap: 10px; }
.qty-btn { width: 24px; height: 24px; border: 1px solid var(--border); background: white; border-radius: 4px; cursor: pointer; }
.cart-footer { padding: 15px; border-top: 1px solid var(--border); background: #f9fafb; }
.cart-totals { margin-bottom: 15px; }
.total-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.total-row.grand { font-size: 1.2rem; font-weight: bold; color: var(--primary); border-top: 2px solid var(--border); padding-top: 10px; margin-top: 10px; }
.payment-methods { display: flex; gap: 10px; margin-bottom: 15px; }
.pay-btn { flex: 1; padding: 10px; border: 1px solid var(--border); background: white; border-radius: var(--radius); cursor: pointer; }
.pay-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Utilities */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mt-2 { margin-top: 20px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.alert { padding: 10px; border-radius: var(--radius); margin-bottom: 15px; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* Login */
.login-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%); }
.login-card { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 100%; max-width: 400px; text-align: center; }
.login-card h1 { color: var(--primary); margin-bottom: 10px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 30px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .main-content { margin-left: 0; }
    .app-layout { flex-direction: column; }
    .pos-layout { grid-template-columns: 1fr; height: auto; }
    .grid-2 { grid-template-columns: 1fr; }
}

@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }